|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[40542],{
|
|
|
|
|
|
/***/ 56448:
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./node_modules/ali-oss/dist/aliyun-oss-sdk.js ***!
|
|
|
\*****************************************************/
|
|
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
|
|
|
|
// Aliyun OSS SDK for JavaScript v6.10.0
|
|
|
// Copyright Aliyun.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
// License at https://github.com/ali-sdk/ali-oss/blob/master/LICENSE
|
|
|
(function(f){if(true){module.exports=f()}else { var g; }})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=undefined;if(!f&&c)return require(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=undefined,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var OSS = require('./browser/client');
|
|
|
OSS.Buffer = require('buffer').Buffer;
|
|
|
OSS.urllib = require('../shims/xhr');
|
|
|
OSS.version = require('./browser/version').version;
|
|
|
|
|
|
module.exports = OSS;
|
|
|
|
|
|
},{"../shims/xhr":291,"./browser/client":2,"./browser/version":5,"buffer":73}],2:[function(require,module,exports){
|
|
|
(function (Buffer,process){
|
|
|
'use strict';
|
|
|
|
|
|
var _promise = require('babel-runtime/core-js/promise');
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var debug = require('debug')('ali-oss');
|
|
|
var copy = require('copy-to');
|
|
|
var xml = require('xml2js');
|
|
|
var AgentKeepalive = require('agentkeepalive');
|
|
|
var merge = require('merge-descriptors');
|
|
|
var urlutil = require('url');
|
|
|
var is = require('is-type-of');
|
|
|
var platform = require('platform');
|
|
|
var utility = require('utility');
|
|
|
var urllib = require('urllib');
|
|
|
var pkg = require('./version');
|
|
|
var bowser = require('bowser');
|
|
|
var signUtils = require('../common/signUtils');
|
|
|
|
|
|
var _require = require('../common/utils/isIP'),
|
|
|
_isIP = _require.isIP;
|
|
|
|
|
|
var _initOptions = require('../common/client/initOptions');
|
|
|
|
|
|
var _require2 = require('../common/utils/createRequest'),
|
|
|
createRequest = _require2.createRequest;
|
|
|
|
|
|
var globalHttpAgent = new AgentKeepalive();
|
|
|
|
|
|
function _unSupportBrowserTip() {
|
|
|
var name = platform.name,
|
|
|
version = platform.version;
|
|
|
|
|
|
if (name && name.toLowerCase && name.toLowerCase() === 'ie' && version.split('.')[0] < 10) {
|
|
|
// eslint-disable-next-line no-console
|
|
|
console.warn('ali-oss does not support the current browser');
|
|
|
}
|
|
|
}
|
|
|
// check local web protocol,if https secure default set true , if http secure default set false
|
|
|
function isHttpsWebProtocol() {
|
|
|
// for web worker not use window.location.
|
|
|
// eslint-disable-next-line no-restricted-globals
|
|
|
return location && location.protocol === 'https:';
|
|
|
}
|
|
|
|
|
|
function Client(options, ctx) {
|
|
|
_unSupportBrowserTip();
|
|
|
if (!(this instanceof Client)) {
|
|
|
return new Client(options, ctx);
|
|
|
}
|
|
|
if (options && options.inited) {
|
|
|
this.options = options;
|
|
|
} else {
|
|
|
this.options = Client.initOptions(options);
|
|
|
}
|
|
|
|
|
|
this.options.cancelFlag = false; // cancel flag: if true need to be cancelled, default false
|
|
|
|
|
|
// support custom agent and urllib client
|
|
|
if (this.options.urllib) {
|
|
|
this.urllib = this.options.urllib;
|
|
|
} else {
|
|
|
this.urllib = urllib;
|
|
|
this.agent = this.options.agent || globalHttpAgent;
|
|
|
}
|
|
|
this.ctx = ctx;
|
|
|
this.userAgent = this._getUserAgent();
|
|
|
|
|
|
// record the time difference between client and server
|
|
|
this.options.amendTimeSkewed = 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Expose `Client`
|
|
|
*/
|
|
|
|
|
|
module.exports = Client;
|
|
|
|
|
|
Client.initOptions = function initOptions(options) {
|
|
|
if (!options.stsToken) {
|
|
|
console.warn('Please use STS Token for safety, see more details at https://help.aliyun.com/document_detail/32077.html');
|
|
|
}
|
|
|
var opts = (0, _assign2.default)({
|
|
|
secure: isHttpsWebProtocol(),
|
|
|
// for browser compatibility disable fetch.
|
|
|
useFetch: false
|
|
|
}, options);
|
|
|
|
|
|
return _initOptions(opts);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* prototype
|
|
|
*/
|
|
|
|
|
|
var proto = Client.prototype;
|
|
|
|
|
|
// mount debug on proto
|
|
|
proto.debug = debug;
|
|
|
|
|
|
/**
|
|
|
* Object operations
|
|
|
*/
|
|
|
merge(proto, require('./object'));
|
|
|
/**
|
|
|
* Bucket operations
|
|
|
*/
|
|
|
merge(proto, require('../common/bucket/getBucketWebsite'));
|
|
|
merge(proto, require('../common/bucket/putBucketWebsite'));
|
|
|
merge(proto, require('../common/bucket/deleteBucketWebsite'));
|
|
|
|
|
|
// lifecycle
|
|
|
merge(proto, require('../common/bucket/getBucketLifecycle'));
|
|
|
merge(proto, require('../common/bucket/putBucketLifecycle'));
|
|
|
merge(proto, require('../common/bucket/deleteBucketLifecycle'));
|
|
|
|
|
|
// multiversion
|
|
|
merge(proto, require('../common/bucket/putBucketVersioning'));
|
|
|
merge(proto, require('../common/bucket/getBucketVersioning'));
|
|
|
|
|
|
// multipart upload
|
|
|
merge(proto, require('./managed-upload'));
|
|
|
/**
|
|
|
* Multipart operations
|
|
|
*/
|
|
|
merge(proto, require('../common/multipart'));
|
|
|
|
|
|
/**
|
|
|
* Common module parallel
|
|
|
*/
|
|
|
merge(proto, require('../common/parallel'));
|
|
|
|
|
|
/**
|
|
|
* get OSS signature
|
|
|
* @param {String} stringToSign
|
|
|
* @return {String} the signature
|
|
|
*/
|
|
|
proto.signature = function signature(stringToSign) {
|
|
|
this.debug('authorization stringToSign: %s', stringToSign, 'info');
|
|
|
|
|
|
return signUtils.computeSignature(this.options.accessKeySecret, stringToSign);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* get author header
|
|
|
*
|
|
|
* "Authorization: OSS " + Access Key Id + ":" + Signature
|
|
|
*
|
|
|
* Signature = base64(hmac-sha1(Access Key Secret + "\n"
|
|
|
* + VERB + "\n"
|
|
|
* + CONTENT-MD5 + "\n"
|
|
|
* + CONTENT-TYPE + "\n"
|
|
|
* + DATE + "\n"
|
|
|
* + CanonicalizedOSSHeaders
|
|
|
* + CanonicalizedResource))
|
|
|
*
|
|
|
* @param {String} method
|
|
|
* @param {String} resource
|
|
|
* @param {Object} header
|
|
|
* @return {String}
|
|
|
*
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
proto.authorization = function authorization(method, resource, subres, headers) {
|
|
|
var stringToSign = signUtils.buildCanonicalString(method.toUpperCase(), resource, {
|
|
|
headers: headers,
|
|
|
parameters: subres
|
|
|
});
|
|
|
|
|
|
return signUtils.authorization(this.options.accessKeyId, this.options.accessKeySecret, stringToSign);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* request oss server
|
|
|
* @param {Object} params
|
|
|
* - {String} object
|
|
|
* - {String} bucket
|
|
|
* - {Object} [headers]
|
|
|
* - {Object} [query]
|
|
|
* - {Buffer} [content]
|
|
|
* - {Stream} [stream]
|
|
|
* - {Stream} [writeStream]
|
|
|
* - {String} [mime]
|
|
|
* - {Boolean} [xmlResponse]
|
|
|
* - {Boolean} [customResponse]
|
|
|
* - {Number} [timeout]
|
|
|
* - {Object} [ctx] request context, default is `this.ctx`
|
|
|
*
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
proto.request = function request(params) {
|
|
|
var reqParams, result, reqErr, useStream, err, parseData;
|
|
|
return _regenerator2.default.async(function request$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
reqParams = createRequest.call(this, params);
|
|
|
|
|
|
|
|
|
if (!this.options.useFetch) {
|
|
|
reqParams.params.mode = 'disable-fetch';
|
|
|
}
|
|
|
result = void 0;
|
|
|
reqErr = void 0;
|
|
|
useStream = !!params.stream;
|
|
|
_context.prev = 5;
|
|
|
_context.next = 8;
|
|
|
return _regenerator2.default.awrap(this.urllib.request(reqParams.url, reqParams.params));
|
|
|
|
|
|
case 8:
|
|
|
result = _context.sent;
|
|
|
|
|
|
this.debug('response %s %s, got %s, headers: %j', params.method, reqParams.url, result.status, result.headers, 'info');
|
|
|
_context.next = 15;
|
|
|
break;
|
|
|
|
|
|
case 12:
|
|
|
_context.prev = 12;
|
|
|
_context.t0 = _context['catch'](5);
|
|
|
|
|
|
reqErr = _context.t0;
|
|
|
|
|
|
case 15:
|
|
|
err = void 0;
|
|
|
|
|
|
if (!(result && params.successStatuses && params.successStatuses.indexOf(result.status) === -1)) {
|
|
|
_context.next = 28;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context.next = 19;
|
|
|
return _regenerator2.default.awrap(this.requestError(result));
|
|
|
|
|
|
case 19:
|
|
|
err = _context.sent;
|
|
|
|
|
|
if (!(err.code === 'RequestTimeTooSkewed' && !useStream)) {
|
|
|
_context.next = 25;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
this.options.amendTimeSkewed = +new Date(err.serverTime) - new Date();
|
|
|
_context.next = 24;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 24:
|
|
|
return _context.abrupt('return', _context.sent);
|
|
|
|
|
|
case 25:
|
|
|
err.params = params;
|
|
|
_context.next = 32;
|
|
|
break;
|
|
|
|
|
|
case 28:
|
|
|
if (!reqErr) {
|
|
|
_context.next = 32;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context.next = 31;
|
|
|
return _regenerator2.default.awrap(this.requestError(reqErr));
|
|
|
|
|
|
case 31:
|
|
|
err = _context.sent;
|
|
|
|
|
|
case 32:
|
|
|
if (!err) {
|
|
|
_context.next = 34;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw err;
|
|
|
|
|
|
case 34:
|
|
|
if (!params.xmlResponse) {
|
|
|
_context.next = 39;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context.next = 37;
|
|
|
return _regenerator2.default.awrap(this.parseXML(result.data));
|
|
|
|
|
|
case 37:
|
|
|
parseData = _context.sent;
|
|
|
|
|
|
result.data = parseData;
|
|
|
|
|
|
case 39:
|
|
|
return _context.abrupt('return', result);
|
|
|
|
|
|
case 40:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this, [[5, 12]]);
|
|
|
};
|
|
|
|
|
|
proto._getResource = function _getResource(params) {
|
|
|
var resource = '/';
|
|
|
if (params.bucket) resource += params.bucket + '/';
|
|
|
if (params.object) resource += params.object;
|
|
|
|
|
|
return resource;
|
|
|
};
|
|
|
|
|
|
proto._isIP = _isIP;
|
|
|
|
|
|
proto._escape = function _escape(name) {
|
|
|
return utility.encodeURIComponent(name).replace(/%2F/g, '/');
|
|
|
};
|
|
|
|
|
|
proto._getReqUrl = function _getReqUrl(params) {
|
|
|
var ep = {};
|
|
|
copy(this.options.endpoint).to(ep);
|
|
|
var isIP = this._isIP(ep.hostname);
|
|
|
var isCname = this.options.cname;
|
|
|
if (params.bucket && !isCname && !isIP) {
|
|
|
ep.host = params.bucket + '.' + ep.host;
|
|
|
}
|
|
|
|
|
|
var reourcePath = '/';
|
|
|
if (params.bucket && isIP) {
|
|
|
reourcePath += params.bucket + '/';
|
|
|
}
|
|
|
|
|
|
if (params.object) {
|
|
|
// Preserve '/' in result url
|
|
|
reourcePath += this._escape(params.object).replace(/\+/g, '%2B');
|
|
|
}
|
|
|
ep.pathname = reourcePath;
|
|
|
|
|
|
var query = {};
|
|
|
if (params.query) {
|
|
|
merge(query, params.query);
|
|
|
}
|
|
|
|
|
|
if (params.subres) {
|
|
|
var subresAsQuery = {};
|
|
|
if (is.string(params.subres)) {
|
|
|
subresAsQuery[params.subres] = '';
|
|
|
} else if (is.array(params.subres)) {
|
|
|
params.subres.forEach(function (k) {
|
|
|
subresAsQuery[k] = '';
|
|
|
});
|
|
|
} else {
|
|
|
subresAsQuery = params.subres;
|
|
|
}
|
|
|
merge(query, subresAsQuery);
|
|
|
}
|
|
|
|
|
|
ep.query = query;
|
|
|
|
|
|
return urlutil.format(ep);
|
|
|
};
|
|
|
|
|
|
/*
|
|
|
* Get User-Agent for browser & node.js
|
|
|
* @example
|
|
|
* aliyun-sdk-nodejs/4.1.2 Node.js 5.3.0 on Darwin 64-bit
|
|
|
* aliyun-sdk-js/4.1.2 Safari 9.0 on Apple iPhone(iOS 9.2.1)
|
|
|
* aliyun-sdk-js/4.1.2 Chrome 43.0.2357.134 32-bit on Windows Server 2008 R2 / 7 64-bit
|
|
|
*/
|
|
|
|
|
|
proto._getUserAgent = function _getUserAgent() {
|
|
|
var agent = process && process.browser ? 'js' : 'nodejs';
|
|
|
var sdk = 'aliyun-sdk-' + agent + '/' + pkg.version;
|
|
|
var plat = platform.description;
|
|
|
if (!plat && process) {
|
|
|
plat = 'Node.js ' + process.version.slice(1) + ' on ' + process.platform + ' ' + process.arch;
|
|
|
}
|
|
|
|
|
|
return this._checkUserAgent(sdk + ' ' + plat);
|
|
|
};
|
|
|
|
|
|
proto._checkUserAgent = function _checkUserAgent(ua) {
|
|
|
var userAgent = ua.replace(/\u03b1/, 'alpha').replace(/\u03b2/, 'beta');
|
|
|
return userAgent;
|
|
|
};
|
|
|
|
|
|
/*
|
|
|
* Check Browser And Version
|
|
|
* @param {String} [name] browser name: like IE, Chrome, Firefox
|
|
|
* @param {String} [version] browser major version: like 10(IE 10.x), 55(Chrome 55.x), 50(Firefox 50.x)
|
|
|
* @return {Bool} true or false
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
proto.checkBrowserAndVersion = function checkBrowserAndVersion(name, version) {
|
|
|
return bowser.name === name && bowser.version.split('.')[0] === version;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* thunkify xml.parseString
|
|
|
* @param {String|Buffer} str
|
|
|
*
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
proto.parseXML = function parseXMLThunk(str) {
|
|
|
return new _promise2.default(function (resolve, reject) {
|
|
|
if (Buffer.isBuffer(str)) {
|
|
|
str = str.toString();
|
|
|
}
|
|
|
xml.parseString(str, {
|
|
|
explicitRoot: false,
|
|
|
explicitArray: false
|
|
|
}, function (err, result) {
|
|
|
if (err) {
|
|
|
reject(err);
|
|
|
} else {
|
|
|
resolve(result);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* generater a request error with request response
|
|
|
* @param {Object} result
|
|
|
*
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
proto.requestError = function requestError(result) {
|
|
|
var err, message, info, msg;
|
|
|
return _regenerator2.default.async(function requestError$(_context2) {
|
|
|
while (1) {
|
|
|
switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
err = null;
|
|
|
|
|
|
if (!(!result.data || !result.data.length)) {
|
|
|
_context2.next = 5;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (result.status === -1 || result.status === -2) {
|
|
|
// -1 is net error , -2 is timeout
|
|
|
err = new Error(result.message);
|
|
|
err.name = result.name;
|
|
|
err.status = result.status;
|
|
|
err.code = result.name;
|
|
|
} else {
|
|
|
// HEAD not exists resource
|
|
|
if (result.status === 404) {
|
|
|
err = new Error('Object not exists');
|
|
|
err.name = 'NoSuchKeyError';
|
|
|
err.status = 404;
|
|
|
err.code = 'NoSuchKey';
|
|
|
} else if (result.status === 412) {
|
|
|
err = new Error('Pre condition failed');
|
|
|
err.name = 'PreconditionFailedError';
|
|
|
err.status = 412;
|
|
|
err.code = 'PreconditionFailed';
|
|
|
} else {
|
|
|
err = new Error('Unknow error, status: ' + result.status);
|
|
|
err.name = 'UnknowError';
|
|
|
err.status = result.status;
|
|
|
}
|
|
|
err.requestId = result.headers['x-oss-request-id'];
|
|
|
err.host = '';
|
|
|
}
|
|
|
_context2.next = 33;
|
|
|
break;
|
|
|
|
|
|
case 5:
|
|
|
message = String(result.data);
|
|
|
|
|
|
this.debug('request response error data: %s', message, 'error');
|
|
|
|
|
|
info = void 0;
|
|
|
_context2.prev = 8;
|
|
|
_context2.next = 11;
|
|
|
return _regenerator2.default.awrap(this.parseXML(message));
|
|
|
|
|
|
case 11:
|
|
|
_context2.t0 = _context2.sent;
|
|
|
|
|
|
if (_context2.t0) {
|
|
|
_context2.next = 14;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context2.t0 = {};
|
|
|
|
|
|
case 14:
|
|
|
info = _context2.t0;
|
|
|
_context2.next = 24;
|
|
|
break;
|
|
|
|
|
|
case 17:
|
|
|
_context2.prev = 17;
|
|
|
_context2.t1 = _context2['catch'](8);
|
|
|
|
|
|
this.debug(message, 'error');
|
|
|
_context2.t1.message += '\nraw xml: ' + message;
|
|
|
_context2.t1.status = result.status;
|
|
|
_context2.t1.requestId = result.headers['x-oss-request-id'];
|
|
|
return _context2.abrupt('return', _context2.t1);
|
|
|
|
|
|
case 24:
|
|
|
msg = info.Message || 'unknow request error, status: ' + result.status;
|
|
|
|
|
|
if (info.Condition) {
|
|
|
msg += ' (condition: ' + info.Condition + ')';
|
|
|
}
|
|
|
err = new Error(msg);
|
|
|
err.name = info.Code ? info.Code + 'Error' : 'UnknowError';
|
|
|
err.status = result.status;
|
|
|
err.code = info.Code;
|
|
|
err.requestId = info.RequestId;
|
|
|
err.hostId = info.HostId;
|
|
|
err.serverTime = info.ServerTime;
|
|
|
|
|
|
case 33:
|
|
|
|
|
|
this.debug('generate error %j', err, 'error');
|
|
|
return _context2.abrupt('return', err);
|
|
|
|
|
|
case 35:
|
|
|
case 'end':
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this, [[8, 17]]);
|
|
|
};
|
|
|
|
|
|
}).call(this,{"isBuffer":require("../../node_modules/is-buffer/index.js")},require('_process'))
|
|
|
},{"../../node_modules/is-buffer/index.js":197,"../common/bucket/deleteBucketLifecycle":6,"../common/bucket/deleteBucketWebsite":7,"../common/bucket/getBucketLifecycle":8,"../common/bucket/getBucketVersioning":9,"../common/bucket/getBucketWebsite":10,"../common/bucket/putBucketLifecycle":11,"../common/bucket/putBucketVersioning":12,"../common/bucket/putBucketWebsite":13,"../common/client/initOptions":15,"../common/multipart":18,"../common/parallel":33,"../common/signUtils":34,"../common/utils/createRequest":38,"../common/utils/isIP":45,"./managed-upload":3,"./object":4,"./version":5,"_process":208,"agentkeepalive":48,"babel-runtime/core-js/object/assign":54,"babel-runtime/core-js/promise":61,"babel-runtime/regenerator":68,"bowser":70,"copy-to":76,"debug":288,"is-type-of":289,"merge-descriptors":200,"platform":206,"url":238,"urllib":291,"utility":290,"xml2js":249}],3:[function(require,module,exports){
|
|
|
(function (Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _from = require('babel-runtime/core-js/array/from');
|
|
|
|
|
|
var _from2 = _interopRequireDefault(_from);
|
|
|
|
|
|
var _promise = require('babel-runtime/core-js/promise');
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// var debug = require('debug')('ali-oss:multipart');
|
|
|
var is = require('is-type-of');
|
|
|
var util = require('util');
|
|
|
var path = require('path');
|
|
|
var mime = require('mime');
|
|
|
var copy = require('copy-to');
|
|
|
|
|
|
var _require = require('../common/utils/isBlob'),
|
|
|
isBlob = _require.isBlob;
|
|
|
|
|
|
var _require2 = require('../common/utils/isFile'),
|
|
|
isFile = _require2.isFile;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
/**
|
|
|
* Multipart operations
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* Upload a file to OSS using multipart uploads
|
|
|
* @param {String} name
|
|
|
* @param {String|File} file
|
|
|
* @param {Object} options
|
|
|
* {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
|
|
|
* {String} options.callback.url the OSS sends a callback request to this URL
|
|
|
* {String} options.callback.host The host header value for initiating callback requests
|
|
|
* {String} options.callback.body The value of the request body when a callback is initiated
|
|
|
* {String} options.callback.contentType The Content-Type of the callback requests initiatiated
|
|
|
* {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
|
|
|
* customValue = {
|
|
|
* key1: 'value1',
|
|
|
* key2: 'value2'
|
|
|
* }
|
|
|
*/
|
|
|
proto.multipartUpload = function multipartUpload(name, file, options) {
|
|
|
var minPartSize, fileSize, stream, result, ret, initResult, uploadId, partSize, checkpoint;
|
|
|
return _regenerator2.default.async(function multipartUpload$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
this.resetCancelFlag();
|
|
|
options = options || {};
|
|
|
|
|
|
if (!(options.checkpoint && options.checkpoint.uploadId)) {
|
|
|
_context.next = 6;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context.next = 5;
|
|
|
return _regenerator2.default.awrap(this._resumeMultipart(options.checkpoint, options));
|
|
|
|
|
|
case 5:
|
|
|
return _context.abrupt('return', _context.sent);
|
|
|
|
|
|
case 6:
|
|
|
minPartSize = 100 * 1024;
|
|
|
|
|
|
|
|
|
if (!options.mime) {
|
|
|
if (isFile(file)) {
|
|
|
options.mime = mime.getType(path.extname(file.name));
|
|
|
} else if (isBlob(file)) {
|
|
|
options.mime = file.type;
|
|
|
} else {
|
|
|
options.mime = mime.getType(path.extname(file));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
options.headers = options.headers || {};
|
|
|
this._convertMetaToHeaders(options.meta, options.headers);
|
|
|
|
|
|
_context.next = 12;
|
|
|
return _regenerator2.default.awrap(this._getFileSize(file));
|
|
|
|
|
|
case 12:
|
|
|
fileSize = _context.sent;
|
|
|
|
|
|
if (!(fileSize < minPartSize)) {
|
|
|
_context.next = 25;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
stream = this._createStream(file, 0, fileSize);
|
|
|
|
|
|
options.contentLength = fileSize;
|
|
|
|
|
|
_context.next = 18;
|
|
|
return _regenerator2.default.awrap(this.putStream(name, stream, options));
|
|
|
|
|
|
case 18:
|
|
|
result = _context.sent;
|
|
|
|
|
|
if (!(options && options.progress)) {
|
|
|
_context.next = 22;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context.next = 22;
|
|
|
return _regenerator2.default.awrap(options.progress(1));
|
|
|
|
|
|
case 22:
|
|
|
ret = {
|
|
|
res: result.res,
|
|
|
bucket: this.options.bucket,
|
|
|
name: name,
|
|
|
etag: result.res.headers.etag
|
|
|
};
|
|
|
|
|
|
|
|
|
if (options.headers && options.headers['x-oss-callback'] || options.callback) {
|
|
|
ret.data = result.data;
|
|
|
}
|
|
|
|
|
|
return _context.abrupt('return', ret);
|
|
|
|
|
|
case 25:
|
|
|
if (!(options.partSize && !(parseInt(options.partSize, 10) === options.partSize))) {
|
|
|
_context.next = 27;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error('partSize must be int number');
|
|
|
|
|
|
case 27:
|
|
|
if (!(options.partSize && options.partSize < minPartSize)) {
|
|
|
_context.next = 29;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error('partSize must not be smaller than ' + minPartSize);
|
|
|
|
|
|
case 29:
|
|
|
_context.next = 31;
|
|
|
return _regenerator2.default.awrap(this.initMultipartUpload(name, options));
|
|
|
|
|
|
case 31:
|
|
|
initResult = _context.sent;
|
|
|
uploadId = initResult.uploadId;
|
|
|
partSize = this._getPartSize(fileSize, options.partSize);
|
|
|
checkpoint = {
|
|
|
file: file,
|
|
|
name: name,
|
|
|
fileSize: fileSize,
|
|
|
partSize: partSize,
|
|
|
uploadId: uploadId,
|
|
|
doneParts: []
|
|
|
};
|
|
|
|
|
|
if (!(options && options.progress)) {
|
|
|
_context.next = 38;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context.next = 38;
|
|
|
return _regenerator2.default.awrap(options.progress(0, checkpoint, initResult.res));
|
|
|
|
|
|
case 38:
|
|
|
_context.next = 40;
|
|
|
return _regenerator2.default.awrap(this._resumeMultipart(checkpoint, options));
|
|
|
|
|
|
case 40:
|
|
|
return _context.abrupt('return', _context.sent);
|
|
|
|
|
|
case 41:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/*
|
|
|
* Resume multipart upload from checkpoint. The checkpoint will be
|
|
|
* updated after each successful part upload.
|
|
|
* @param {Object} checkpoint the checkpoint
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
proto._resumeMultipart = function _resumeMultipart(checkpoint, options) {
|
|
|
var that, file, fileSize, partSize, uploadId, doneParts, name, internalDoneParts, partOffs, numParts, multipartFinish, uploadPartJob, all, done, todo, defaultParallel, parallel, jobErr;
|
|
|
return _regenerator2.default.async(function _resumeMultipart$(_context3) {
|
|
|
while (1) {
|
|
|
switch (_context3.prev = _context3.next) {
|
|
|
case 0:
|
|
|
that = this;
|
|
|
|
|
|
if (!this.isCancel()) {
|
|
|
_context3.next = 3;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw this._makeCancelEvent();
|
|
|
|
|
|
case 3:
|
|
|
file = checkpoint.file, fileSize = checkpoint.fileSize, partSize = checkpoint.partSize, uploadId = checkpoint.uploadId, doneParts = checkpoint.doneParts, name = checkpoint.name;
|
|
|
internalDoneParts = [];
|
|
|
|
|
|
|
|
|
if (doneParts.length > 0) {
|
|
|
copy(doneParts).to(internalDoneParts);
|
|
|
}
|
|
|
|
|
|
partOffs = this._divideParts(fileSize, partSize);
|
|
|
numParts = partOffs.length;
|
|
|
multipartFinish = false;
|
|
|
|
|
|
uploadPartJob = function uploadPartJob(self, partNo) {
|
|
|
var _this = this;
|
|
|
|
|
|
// eslint-disable-next-line no-async-promise-executor
|
|
|
return new _promise2.default(function _callee(resolve, reject) {
|
|
|
var pi, data, result, tempErr;
|
|
|
return _regenerator2.default.async(function _callee$(_context2) {
|
|
|
while (1) {
|
|
|
switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
_context2.prev = 0;
|
|
|
|
|
|
if (self.isCancel()) {
|
|
|
_context2.next = 18;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
pi = partOffs[partNo - 1];
|
|
|
data = {
|
|
|
stream: self._createStream(file, pi.start, pi.end),
|
|
|
size: pi.end - pi.start
|
|
|
};
|
|
|
_context2.next = 6;
|
|
|
return _regenerator2.default.awrap(self._uploadPart(name, uploadId, partNo, data));
|
|
|
|
|
|
case 6:
|
|
|
result = _context2.sent;
|
|
|
|
|
|
if (!(!self.isCancel() && !multipartFinish)) {
|
|
|
_context2.next = 15;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
checkpoint.doneParts.push({
|
|
|
number: partNo,
|
|
|
etag: result.res.headers.etag
|
|
|
});
|
|
|
|
|
|
if (!options.progress) {
|
|
|
_context2.next = 12;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context2.next = 12;
|
|
|
return _regenerator2.default.awrap(options.progress(doneParts.length / numParts, checkpoint, result.res));
|
|
|
|
|
|
case 12:
|
|
|
|
|
|
resolve({
|
|
|
number: partNo,
|
|
|
etag: result.res.headers.etag
|
|
|
});
|
|
|
_context2.next = 16;
|
|
|
break;
|
|
|
|
|
|
case 15:
|
|
|
resolve();
|
|
|
|
|
|
case 16:
|
|
|
_context2.next = 19;
|
|
|
break;
|
|
|
|
|
|
case 18:
|
|
|
resolve();
|
|
|
|
|
|
case 19:
|
|
|
_context2.next = 30;
|
|
|
break;
|
|
|
|
|
|
case 21:
|
|
|
_context2.prev = 21;
|
|
|
_context2.t0 = _context2['catch'](0);
|
|
|
tempErr = new Error();
|
|
|
|
|
|
tempErr.name = _context2.t0.name;
|
|
|
tempErr.message = _context2.t0.message;
|
|
|
tempErr.stack = _context2.t0.stack;
|
|
|
tempErr.partNum = partNo;
|
|
|
copy(_context2.t0).to(tempErr);
|
|
|
reject(tempErr);
|
|
|
|
|
|
case 30:
|
|
|
case 'end':
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, _this, [[0, 21]]);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
all = (0, _from2.default)(new Array(numParts), function (x, i) {
|
|
|
return i + 1;
|
|
|
});
|
|
|
done = internalDoneParts.map(function (p) {
|
|
|
return p.number;
|
|
|
});
|
|
|
todo = all.filter(function (p) {
|
|
|
return done.indexOf(p) < 0;
|
|
|
});
|
|
|
defaultParallel = 5;
|
|
|
parallel = options.parallel || defaultParallel;
|
|
|
|
|
|
// upload in parallel
|
|
|
|
|
|
_context3.next = 17;
|
|
|
return _regenerator2.default.awrap(this._parallel(todo, parallel, function (value) {
|
|
|
return new _promise2.default(function (resolve, reject) {
|
|
|
uploadPartJob(that, value).then(function (result) {
|
|
|
if (result) {
|
|
|
internalDoneParts.push(result);
|
|
|
}
|
|
|
resolve();
|
|
|
}).catch(function (err) {
|
|
|
reject(err);
|
|
|
});
|
|
|
});
|
|
|
}));
|
|
|
|
|
|
case 17:
|
|
|
jobErr = _context3.sent;
|
|
|
|
|
|
multipartFinish = true;
|
|
|
|
|
|
if (!this.isCancel()) {
|
|
|
_context3.next = 22;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
uploadPartJob = null;
|
|
|
throw this._makeCancelEvent();
|
|
|
|
|
|
case 22:
|
|
|
if (!(jobErr && jobErr.length > 0)) {
|
|
|
_context3.next = 25;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
jobErr[0].message = 'Failed to upload some parts with error: ' + jobErr[0].toString() + ' part_num: ' + jobErr[0].partNum;
|
|
|
throw jobErr[0];
|
|
|
|
|
|
case 25:
|
|
|
_context3.next = 27;
|
|
|
return _regenerator2.default.awrap(this.completeMultipartUpload(name, uploadId, internalDoneParts, options));
|
|
|
|
|
|
case 27:
|
|
|
return _context3.abrupt('return', _context3.sent);
|
|
|
|
|
|
case 28:
|
|
|
case 'end':
|
|
|
return _context3.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Get file size
|
|
|
*/
|
|
|
proto._getFileSize = function _getFileSize(file) {
|
|
|
return _regenerator2.default.async(function _getFileSize$(_context4) {
|
|
|
while (1) {
|
|
|
switch (_context4.prev = _context4.next) {
|
|
|
case 0:
|
|
|
if (!is.buffer(file)) {
|
|
|
_context4.next = 4;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return _context4.abrupt('return', file.length);
|
|
|
|
|
|
case 4:
|
|
|
if (!(isBlob(file) || isFile(file))) {
|
|
|
_context4.next = 6;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return _context4.abrupt('return', file.size);
|
|
|
|
|
|
case 6:
|
|
|
throw new Error('_getFileSize requires Buffer/File/Blob.');
|
|
|
|
|
|
case 7:
|
|
|
case 'end':
|
|
|
return _context4.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/*
|
|
|
* Readable stream for Web File
|
|
|
*/
|
|
|
|
|
|
var _require3 = require('stream'),
|
|
|
Readable = _require3.Readable;
|
|
|
|
|
|
function WebFileReadStream(file, options) {
|
|
|
if (!(this instanceof WebFileReadStream)) {
|
|
|
return new WebFileReadStream(file, options);
|
|
|
}
|
|
|
|
|
|
Readable.call(this, options);
|
|
|
|
|
|
this.file = file;
|
|
|
this.reader = new FileReader();
|
|
|
this.start = 0;
|
|
|
this.finish = false;
|
|
|
this.fileBuffer = null;
|
|
|
}
|
|
|
util.inherits(WebFileReadStream, Readable);
|
|
|
|
|
|
WebFileReadStream.prototype.readFileAndPush = function readFileAndPush(size) {
|
|
|
if (this.fileBuffer) {
|
|
|
var pushRet = true;
|
|
|
while (pushRet && this.fileBuffer && this.start < this.fileBuffer.length) {
|
|
|
var start = this.start;
|
|
|
|
|
|
var end = start + size;
|
|
|
end = end > this.fileBuffer.length ? this.fileBuffer.length : end;
|
|
|
this.start = end;
|
|
|
pushRet = this.push(this.fileBuffer.slice(start, end));
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
WebFileReadStream.prototype._read = function _read(size) {
|
|
|
if (this.file && this.start >= this.file.size || this.fileBuffer && this.start >= this.fileBuffer.length || this.finish || this.start === 0 && !this.file) {
|
|
|
if (!this.finish) {
|
|
|
this.fileBuffer = null;
|
|
|
this.finish = true;
|
|
|
}
|
|
|
this.push(null);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var defaultReadSize = 16 * 1024;
|
|
|
size = size || defaultReadSize;
|
|
|
|
|
|
var that = this;
|
|
|
this.reader.onload = function onload(e) {
|
|
|
that.fileBuffer = Buffer.from(new Uint8Array(e.target.result));
|
|
|
that.file = null;
|
|
|
that.readFileAndPush(size);
|
|
|
};
|
|
|
|
|
|
if (this.start === 0) {
|
|
|
this.reader.readAsArrayBuffer(this.file);
|
|
|
} else {
|
|
|
this.readFileAndPush(size);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
proto._createStream = function _createStream(file, start, end) {
|
|
|
if (isBlob(file) || isFile(file)) {
|
|
|
return new WebFileReadStream(file.slice(start, end));
|
|
|
}
|
|
|
|
|
|
throw new Error('_createStream requires File/Blob.');
|
|
|
};
|
|
|
|
|
|
proto._getPartSize = function _getPartSize(fileSize, partSize) {
|
|
|
var maxNumParts = 10 * 1000;
|
|
|
var defaultPartSize = 1024 * 1024;
|
|
|
|
|
|
if (!partSize) {
|
|
|
return defaultPartSize;
|
|
|
}
|
|
|
|
|
|
return Math.max(Math.ceil(fileSize / maxNumParts), partSize);
|
|
|
};
|
|
|
|
|
|
proto._divideParts = function _divideParts(fileSize, partSize) {
|
|
|
var numParts = Math.ceil(fileSize / partSize);
|
|
|
|
|
|
var partOffs = [];
|
|
|
for (var i = 0; i < numParts; i++) {
|
|
|
var start = partSize * i;
|
|
|
var end = Math.min(start + partSize, fileSize);
|
|
|
|
|
|
partOffs.push({
|
|
|
start: start,
|
|
|
end: end
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return partOffs;
|
|
|
};
|
|
|
|
|
|
}).call(this,require("buffer").Buffer)
|
|
|
},{"../common/utils/isBlob":43,"../common/utils/isFile":44,"babel-runtime/core-js/array/from":52,"babel-runtime/core-js/promise":61,"babel-runtime/regenerator":68,"buffer":73,"copy-to":76,"is-type-of":289,"mime":202,"path":205,"stream":230,"util":243}],4:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _promise = require('babel-runtime/core-js/promise');
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// const debug = require('debug')('ali-oss:object');
|
|
|
var utility = require('utility');
|
|
|
var fs = require('fs');
|
|
|
var is = require('is-type-of');
|
|
|
var urlutil = require('url');
|
|
|
var copy = require('copy-to');
|
|
|
var path = require('path');
|
|
|
var mime = require('mime');
|
|
|
var callback = require('../common/callback');
|
|
|
var signHelper = require('../common/signUtils');
|
|
|
var merge = require('merge-descriptors');
|
|
|
|
|
|
var _require = require('../common/utils/isBlob'),
|
|
|
isBlob = _require.isBlob;
|
|
|
|
|
|
var _require2 = require('../common/utils/isFile'),
|
|
|
isFile = _require2.isFile;
|
|
|
|
|
|
// var assert = require('assert');
|
|
|
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
/**
|
|
|
* Object operations
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* append an object from String(file path)/Buffer/ReadableStream
|
|
|
* @param {String} name the object key
|
|
|
* @param {Mixed} file String(file path)/Buffer/ReadableStream
|
|
|
* @param {Object} options
|
|
|
* @return {Object}
|
|
|
*/
|
|
|
proto.append = function append(name, file, options) {
|
|
|
var result;
|
|
|
return _regenerator2.default.async(function append$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
if (options.position === undefined) options.position = '0';
|
|
|
options.subres = {
|
|
|
append: '',
|
|
|
position: options.position
|
|
|
};
|
|
|
options.method = 'POST';
|
|
|
|
|
|
_context.next = 6;
|
|
|
return _regenerator2.default.awrap(this.put(name, file, options));
|
|
|
|
|
|
case 6:
|
|
|
result = _context.sent;
|
|
|
|
|
|
result.nextAppendPosition = result.res.headers['x-oss-next-append-position'];
|
|
|
return _context.abrupt('return', result);
|
|
|
|
|
|
case 9:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* put an object from String(file path)/Buffer/ReadableStream
|
|
|
* @param {String} name the object key
|
|
|
* @param {Mixed} file String(file path)/Buffer/ReadableStream
|
|
|
* @param {Object} options
|
|
|
* {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
|
|
|
* {String} options.callback.url the OSS sends a callback request to this URL
|
|
|
* {String} options.callback.host The host header value for initiating callback requests
|
|
|
* {String} options.callback.body The value of the request body when a callback is initiated
|
|
|
* {String} options.callback.contentType The Content-Type of the callback requests initiatiated
|
|
|
* {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
|
|
|
* customValue = {
|
|
|
* key1: 'value1',
|
|
|
* key2: 'value2'
|
|
|
* }
|
|
|
* @return {Object}
|
|
|
*/
|
|
|
proto.put = function put(name, file, options) {
|
|
|
var content, stream, _result, method, params, result, ret;
|
|
|
|
|
|
return _regenerator2.default.async(function put$(_context2) {
|
|
|
while (1) {
|
|
|
switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
content = void 0;
|
|
|
|
|
|
options = options || {};
|
|
|
name = this._objectName(name);
|
|
|
|
|
|
if (!is.buffer(file)) {
|
|
|
_context2.next = 7;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
content = file;
|
|
|
_context2.next = 33;
|
|
|
break;
|
|
|
|
|
|
case 7:
|
|
|
if (!(isBlob(file) || isFile(file))) {
|
|
|
_context2.next = 32;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (!options.mime) {
|
|
|
if (isFile(file)) {
|
|
|
options.mime = mime.getType(path.extname(file.name));
|
|
|
} else {
|
|
|
options.mime = file.type;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
stream = this._createStream(file, 0, file.size);
|
|
|
_context2.next = 12;
|
|
|
return _regenerator2.default.awrap(this._getFileSize(file));
|
|
|
|
|
|
case 12:
|
|
|
options.contentLength = _context2.sent;
|
|
|
_context2.prev = 13;
|
|
|
_context2.next = 16;
|
|
|
return _regenerator2.default.awrap(this.putStream(name, stream, options));
|
|
|
|
|
|
case 16:
|
|
|
_result = _context2.sent;
|
|
|
return _context2.abrupt('return', _result);
|
|
|
|
|
|
case 20:
|
|
|
_context2.prev = 20;
|
|
|
_context2.t0 = _context2['catch'](13);
|
|
|
|
|
|
if (!(_context2.t0.code === 'RequestTimeTooSkewed')) {
|
|
|
_context2.next = 29;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
this.options.amendTimeSkewed = +new Date(_context2.t0.serverTime) - new Date();
|
|
|
_context2.next = 26;
|
|
|
return _regenerator2.default.awrap(this.put(name, file, options));
|
|
|
|
|
|
case 26:
|
|
|
return _context2.abrupt('return', _context2.sent);
|
|
|
|
|
|
case 29:
|
|
|
throw _context2.t0;
|
|
|
|
|
|
case 30:
|
|
|
_context2.next = 33;
|
|
|
break;
|
|
|
|
|
|
case 32:
|
|
|
throw new TypeError('Must provide Buffer/Blob/File for put.');
|
|
|
|
|
|
case 33:
|
|
|
|
|
|
options.headers = options.headers || {};
|
|
|
this._convertMetaToHeaders(options.meta, options.headers);
|
|
|
|
|
|
method = options.method || 'PUT';
|
|
|
params = this._objectRequestParams(method, name, options);
|
|
|
|
|
|
callback.encodeCallback(params, options);
|
|
|
params.mime = options.mime;
|
|
|
params.content = content;
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
_context2.next = 43;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 43:
|
|
|
result = _context2.sent;
|
|
|
ret = {
|
|
|
name: name,
|
|
|
url: this._objectUrl(name),
|
|
|
res: result.res
|
|
|
};
|
|
|
|
|
|
|
|
|
if (params.headers && params.headers['x-oss-callback']) {
|
|
|
ret.data = JSON.parse(result.data.toString());
|
|
|
}
|
|
|
|
|
|
return _context2.abrupt('return', ret);
|
|
|
|
|
|
case 47:
|
|
|
case 'end':
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this, [[13, 20]]);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* put an object from ReadableStream. If `options.contentLength` is
|
|
|
* not provided, chunked encoding is used.
|
|
|
* @param {String} name the object key
|
|
|
* @param {Readable} stream the ReadableStream
|
|
|
* @param {Object} options
|
|
|
* @return {Object}
|
|
|
*/
|
|
|
proto.putStream = function putStream(name, stream, options) {
|
|
|
var method, params, result, ret;
|
|
|
return _regenerator2.default.async(function putStream$(_context3) {
|
|
|
while (1) {
|
|
|
switch (_context3.prev = _context3.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
options.headers = options.headers || {};
|
|
|
name = this._objectName(name);
|
|
|
if (options.contentLength) {
|
|
|
options.headers['Content-Length'] = options.contentLength;
|
|
|
} else {
|
|
|
options.headers['Transfer-Encoding'] = 'chunked';
|
|
|
}
|
|
|
this._convertMetaToHeaders(options.meta, options.headers);
|
|
|
|
|
|
method = options.method || 'PUT';
|
|
|
params = this._objectRequestParams(method, name, options);
|
|
|
|
|
|
callback.encodeCallback(params, options);
|
|
|
params.mime = options.mime;
|
|
|
params.stream = stream;
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
_context3.next = 13;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 13:
|
|
|
result = _context3.sent;
|
|
|
ret = {
|
|
|
name: name,
|
|
|
url: this._objectUrl(name),
|
|
|
res: result.res
|
|
|
};
|
|
|
|
|
|
|
|
|
if (params.headers && params.headers['x-oss-callback']) {
|
|
|
ret.data = JSON.parse(result.data.toString());
|
|
|
}
|
|
|
|
|
|
return _context3.abrupt('return', ret);
|
|
|
|
|
|
case 17:
|
|
|
case 'end':
|
|
|
return _context3.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
merge(proto, require('../common/object/copyObject'));
|
|
|
merge(proto, require('../common/object/getObjectTagging'));
|
|
|
merge(proto, require('../common/object/putObjectTagging'));
|
|
|
merge(proto, require('../common/object/deleteObjectTagging'));
|
|
|
merge(proto, require('../common/image'));
|
|
|
merge(proto, require('../common/object/getBucketVersions'));
|
|
|
merge(proto, require('../common/object/getACL'));
|
|
|
merge(proto, require('../common/object/putACL'));
|
|
|
merge(proto, require('../common/object/head'));
|
|
|
merge(proto, require('../common/object/delete'));
|
|
|
merge(proto, require('../common/object/get'));
|
|
|
merge(proto, require('../common/object/putSymlink'));
|
|
|
merge(proto, require('../common/object/getSymlink'));
|
|
|
merge(proto, require('../common/object/deleteMulti'));
|
|
|
merge(proto, require('../common/object/getObjectMeta'));
|
|
|
|
|
|
proto.putMeta = function putMeta(name, meta, options) {
|
|
|
var copyResult;
|
|
|
return _regenerator2.default.async(function putMeta$(_context4) {
|
|
|
while (1) {
|
|
|
switch (_context4.prev = _context4.next) {
|
|
|
case 0:
|
|
|
_context4.next = 2;
|
|
|
return _regenerator2.default.awrap(this.copy(name, name, {
|
|
|
meta: meta || {},
|
|
|
timeout: options && options.timeout,
|
|
|
ctx: options && options.ctx
|
|
|
}));
|
|
|
|
|
|
case 2:
|
|
|
copyResult = _context4.sent;
|
|
|
return _context4.abrupt('return', copyResult);
|
|
|
|
|
|
case 4:
|
|
|
case 'end':
|
|
|
return _context4.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
proto.list = function list(query, options) {
|
|
|
var params, result, objects, that, prefixes;
|
|
|
return _regenerator2.default.async(function list$(_context5) {
|
|
|
while (1) {
|
|
|
switch (_context5.prev = _context5.next) {
|
|
|
case 0:
|
|
|
// prefix, marker, max-keys, delimiter
|
|
|
|
|
|
params = this._objectRequestParams('GET', '', options);
|
|
|
|
|
|
params.query = query;
|
|
|
params.xmlResponse = true;
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
_context5.next = 6;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 6:
|
|
|
result = _context5.sent;
|
|
|
objects = result.data.Contents;
|
|
|
that = this;
|
|
|
|
|
|
if (objects) {
|
|
|
if (!Array.isArray(objects)) {
|
|
|
objects = [objects];
|
|
|
}
|
|
|
objects = objects.map(function (obj) {
|
|
|
return {
|
|
|
name: obj.Key,
|
|
|
url: that._objectUrl(obj.Key),
|
|
|
lastModified: obj.LastModified,
|
|
|
etag: obj.ETag,
|
|
|
type: obj.Type,
|
|
|
size: Number(obj.Size),
|
|
|
storageClass: obj.StorageClass,
|
|
|
owner: {
|
|
|
id: obj.Owner.ID,
|
|
|
displayName: obj.Owner.DisplayName
|
|
|
}
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
prefixes = result.data.CommonPrefixes || null;
|
|
|
|
|
|
if (prefixes) {
|
|
|
if (!Array.isArray(prefixes)) {
|
|
|
prefixes = [prefixes];
|
|
|
}
|
|
|
prefixes = prefixes.map(function (item) {
|
|
|
return item.Prefix;
|
|
|
});
|
|
|
}
|
|
|
return _context5.abrupt('return', {
|
|
|
res: result.res,
|
|
|
objects: objects,
|
|
|
prefixes: prefixes,
|
|
|
nextMarker: result.data.NextMarker || null,
|
|
|
isTruncated: result.data.IsTruncated === 'true'
|
|
|
});
|
|
|
|
|
|
case 13:
|
|
|
case 'end':
|
|
|
return _context5.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Restore Object
|
|
|
* @param {String} name the object key
|
|
|
* @param {Object} options
|
|
|
* @returns {{res}}
|
|
|
*/
|
|
|
proto.restore = function restore(name, options) {
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function restore$(_context6) {
|
|
|
while (1) {
|
|
|
switch (_context6.prev = _context6.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
options.subres = (0, _assign2.default)({ restore: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
params = this._objectRequestParams('POST', name, options);
|
|
|
|
|
|
params.successStatuses = [202];
|
|
|
|
|
|
_context6.next = 7;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 7:
|
|
|
result = _context6.sent;
|
|
|
return _context6.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 9:
|
|
|
case 'end':
|
|
|
return _context6.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
proto.signatureUrl = function signatureUrl(name, options) {
|
|
|
options = options || {};
|
|
|
name = this._objectName(name);
|
|
|
options.method = options.method || 'GET';
|
|
|
var expires = utility.timestamp() + (options.expires || 1800);
|
|
|
var params = {
|
|
|
bucket: this.options.bucket,
|
|
|
object: name
|
|
|
};
|
|
|
|
|
|
var resource = this._getResource(params);
|
|
|
|
|
|
if (this.options.stsToken) {
|
|
|
options['security-token'] = this.options.stsToken;
|
|
|
}
|
|
|
|
|
|
var signRes = signHelper._signatureForURL(this.options.accessKeySecret, options, resource, expires);
|
|
|
|
|
|
var url = urlutil.parse(this._getReqUrl(params));
|
|
|
url.query = {
|
|
|
OSSAccessKeyId: this.options.accessKeyId,
|
|
|
Expires: expires,
|
|
|
Signature: signRes.Signature
|
|
|
};
|
|
|
|
|
|
copy(signRes.subResource).to(url.query);
|
|
|
|
|
|
return url.format();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Get Object url by name
|
|
|
* @param {String} name - object name
|
|
|
* @param {String} [baseUrl] - If provide `baseUrl`,
|
|
|
* will use `baseUrl` instead the default `endpoint`.
|
|
|
* @return {String} object url
|
|
|
*/
|
|
|
proto.getObjectUrl = function getObjectUrl(name, baseUrl) {
|
|
|
if (!baseUrl) {
|
|
|
baseUrl = this.options.endpoint.format();
|
|
|
} else if (baseUrl[baseUrl.length - 1] !== '/') {
|
|
|
baseUrl += '/';
|
|
|
}
|
|
|
return baseUrl + this._escape(this._objectName(name));
|
|
|
};
|
|
|
|
|
|
proto._objectUrl = function _objectUrl(name) {
|
|
|
return this._getReqUrl({ bucket: this.options.bucket, object: name });
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Get Object url by name
|
|
|
* @param {String} name - object name
|
|
|
* @param {String} [baseUrl] - If provide `baseUrl`, will use `baseUrl` instead the default `endpoint and bucket`.
|
|
|
* @return {String} object url include bucket
|
|
|
*/
|
|
|
proto.generateObjectUrl = function (name, baseUrl) {
|
|
|
if (!baseUrl) {
|
|
|
baseUrl = this.options.endpoint.format();
|
|
|
var copyUrl = urlutil.parse(baseUrl);
|
|
|
var bucket = this.options.bucket;
|
|
|
|
|
|
|
|
|
copyUrl.hostname = bucket + '.' + copyUrl.hostname;
|
|
|
copyUrl.host = bucket + '.' + copyUrl.host;
|
|
|
baseUrl = copyUrl.format();
|
|
|
} else if (baseUrl[baseUrl.length - 1] !== '/') {
|
|
|
baseUrl += '/';
|
|
|
}
|
|
|
return baseUrl + this._escape(this._objectName(name));
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* generator request params
|
|
|
* @return {Object} params
|
|
|
*
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
proto._objectRequestParams = function _objectRequestParams(method, name, options) {
|
|
|
if (!this.options.bucket) {
|
|
|
throw new Error('Please create a bucket first');
|
|
|
}
|
|
|
|
|
|
options = options || {};
|
|
|
name = this._objectName(name);
|
|
|
var params = {
|
|
|
object: name,
|
|
|
bucket: this.options.bucket,
|
|
|
method: method,
|
|
|
subres: options && options.subres,
|
|
|
timeout: options && options.timeout,
|
|
|
ctx: options && options.ctx
|
|
|
};
|
|
|
|
|
|
if (options.headers) {
|
|
|
params.headers = {};
|
|
|
copy(options.headers).to(params.headers);
|
|
|
}
|
|
|
return params;
|
|
|
};
|
|
|
|
|
|
proto._objectName = function _objectName(name) {
|
|
|
return name.replace(/^\/+/, '');
|
|
|
};
|
|
|
|
|
|
proto._convertMetaToHeaders = function _convertMetaToHeaders(meta, headers) {
|
|
|
if (!meta) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
(0, _keys2.default)(meta).forEach(function (k) {
|
|
|
headers['x-oss-meta-' + k] = meta[k];
|
|
|
});
|
|
|
};
|
|
|
|
|
|
proto._deleteFileSafe = function _deleteFileSafe(filepath) {
|
|
|
var _this = this;
|
|
|
|
|
|
return new _promise2.default(function (resolve) {
|
|
|
fs.exists(filepath, function (exists) {
|
|
|
if (!exists) {
|
|
|
resolve();
|
|
|
} else {
|
|
|
fs.unlink(filepath, function (err) {
|
|
|
if (err) {
|
|
|
_this.debug('unlink %j error: %s', filepath, err, 'error');
|
|
|
}
|
|
|
resolve();
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
},{"../common/callback":14,"../common/image":16,"../common/object/copyObject":19,"../common/object/delete":20,"../common/object/deleteMulti":21,"../common/object/deleteObjectTagging":22,"../common/object/get":23,"../common/object/getACL":24,"../common/object/getBucketVersions":25,"../common/object/getObjectMeta":26,"../common/object/getObjectTagging":27,"../common/object/getSymlink":28,"../common/object/head":29,"../common/object/putACL":30,"../common/object/putObjectTagging":31,"../common/object/putSymlink":32,"../common/signUtils":34,"../common/utils/isBlob":43,"../common/utils/isFile":44,"babel-runtime/core-js/object/assign":54,"babel-runtime/core-js/object/keys":60,"babel-runtime/core-js/promise":61,"babel-runtime/regenerator":68,"copy-to":76,"fs":71,"is-type-of":289,"merge-descriptors":200,"mime":202,"path":205,"url":238,"utility":290}],5:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
exports.version = "6.10.0";
|
|
|
|
|
|
},{}],6:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto.deleteBucketLifecycle = function deleteBucketLifecycle(name, options) {
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function deleteBucketLifecycle$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_checkBucketName(name);
|
|
|
params = this._bucketRequestParams('DELETE', name, 'lifecycle', options);
|
|
|
|
|
|
params.successStatuses = [204];
|
|
|
_context.next = 5;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 5:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 7:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"babel-runtime/regenerator":68}],7:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto.deleteBucketWebsite = function deleteBucketWebsite(name, options) {
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function deleteBucketWebsite$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_checkBucketName(name);
|
|
|
params = this._bucketRequestParams('DELETE', name, 'website', options);
|
|
|
|
|
|
params.successStatuses = [204];
|
|
|
_context.next = 5;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 5:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 7:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"babel-runtime/regenerator":68}],8:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var _require2 = require('../utils/isArray'),
|
|
|
isArray = _require2.isArray;
|
|
|
|
|
|
var _require3 = require('../utils/formatObjKey'),
|
|
|
formatObjKey = _require3.formatObjKey;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto.getBucketLifecycle = function getBucketLifecycle(name, options) {
|
|
|
var params, result, rules;
|
|
|
return _regenerator2.default.async(function getBucketLifecycle$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_checkBucketName(name);
|
|
|
params = this._bucketRequestParams('GET', name, 'lifecycle', options);
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
params.xmlResponse = true;
|
|
|
_context.next = 6;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 6:
|
|
|
result = _context.sent;
|
|
|
rules = result.data.Rule || null;
|
|
|
|
|
|
if (rules) {
|
|
|
if (!isArray(rules)) {
|
|
|
rules = [rules];
|
|
|
}
|
|
|
rules = rules.map(function (_) {
|
|
|
if (_.ID) {
|
|
|
_.id = _.ID;
|
|
|
delete _.ID;
|
|
|
}
|
|
|
if (_.Tag && !isArray(_.Tag)) {
|
|
|
_.Tag = [_.Tag];
|
|
|
}
|
|
|
return formatObjKey(_, 'firstLowerCase');
|
|
|
});
|
|
|
}
|
|
|
return _context.abrupt('return', {
|
|
|
rules: rules,
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 10:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"../utils/formatObjKey":40,"../utils/isArray":42,"babel-runtime/regenerator":68}],9:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* getBucketVersioning
|
|
|
* @param {String} bucketName - bucket name
|
|
|
*/
|
|
|
|
|
|
proto.getBucketVersioning = function getBucketVersioning(bucketName, options) {
|
|
|
var params, result, versionStatus;
|
|
|
return _regenerator2.default.async(function getBucketVersioning$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_checkBucketName(bucketName);
|
|
|
params = this._bucketRequestParams('GET', bucketName, 'versioning', options);
|
|
|
|
|
|
params.xmlResponse = true;
|
|
|
params.successStatuses = [200];
|
|
|
_context.next = 6;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 6:
|
|
|
result = _context.sent;
|
|
|
versionStatus = result.data.Status;
|
|
|
return _context.abrupt('return', {
|
|
|
status: result.status,
|
|
|
versionStatus: versionStatus,
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 9:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"babel-runtime/regenerator":68}],10:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var _require2 = require('../utils/isObject'),
|
|
|
isObject = _require2.isObject;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto.getBucketWebsite = function getBucketWebsite(name, options) {
|
|
|
var params, result, routingRules;
|
|
|
return _regenerator2.default.async(function getBucketWebsite$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_checkBucketName(name);
|
|
|
params = this._bucketRequestParams('GET', name, 'website', options);
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
params.xmlResponse = true;
|
|
|
_context.next = 6;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 6:
|
|
|
result = _context.sent;
|
|
|
routingRules = [];
|
|
|
|
|
|
if (result.data.RoutingRules && result.data.RoutingRules.RoutingRule) {
|
|
|
if (isObject(result.data.RoutingRules.RoutingRule)) {
|
|
|
routingRules = [result.data.RoutingRules.RoutingRule];
|
|
|
} else {
|
|
|
routingRules = result.data.RoutingRules.RoutingRule;
|
|
|
}
|
|
|
}
|
|
|
return _context.abrupt('return', {
|
|
|
index: result.data.IndexDocument && result.data.IndexDocument.Suffix || '',
|
|
|
supportSubDir: result.data.IndexDocument && result.data.IndexDocument.SupportSubDir || 'false',
|
|
|
type: result.data.IndexDocument && result.data.IndexDocument.Type,
|
|
|
routingRules: routingRules,
|
|
|
error: result.data.ErrorDocument && result.data.ErrorDocument.Key || null,
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 10:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"../utils/isObject":46,"babel-runtime/regenerator":68}],11:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
/* eslint-disable no-use-before-define */
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var _require2 = require('../utils/isArray'),
|
|
|
isArray = _require2.isArray;
|
|
|
|
|
|
var _require3 = require('../utils/deepCopy'),
|
|
|
deepCopy = _require3.deepCopy;
|
|
|
|
|
|
var _require4 = require('../utils/isObject'),
|
|
|
isObject = _require4.isObject;
|
|
|
|
|
|
var _require5 = require('../utils/obj2xml'),
|
|
|
obj2xml = _require5.obj2xml;
|
|
|
|
|
|
var _require6 = require('../utils/checkObjectTag'),
|
|
|
checkObjectTag = _require6.checkObjectTag;
|
|
|
|
|
|
var _require7 = require('../utils/getStrBytesCount'),
|
|
|
getStrBytesCount = _require7.getStrBytesCount;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto.putBucketLifecycle = function putBucketLifecycle(name, rules, options) {
|
|
|
var params, Rule, paramXMLObj, paramXML, result;
|
|
|
return _regenerator2.default.async(function putBucketLifecycle$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_checkBucketName(name);
|
|
|
|
|
|
if (isArray(rules)) {
|
|
|
_context.next = 3;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error('rules must be Array');
|
|
|
|
|
|
case 3:
|
|
|
params = this._bucketRequestParams('PUT', name, 'lifecycle', options);
|
|
|
Rule = [];
|
|
|
paramXMLObj = {
|
|
|
LifecycleConfiguration: {
|
|
|
Rule: Rule
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
rules.forEach(function (_) {
|
|
|
defaultDaysAndDate2Expiration(_); // todo delete, 兼容旧版本
|
|
|
checkRule(_);
|
|
|
if (_.id) {
|
|
|
_.ID = _.id;
|
|
|
delete _.id;
|
|
|
}
|
|
|
Rule.push(_);
|
|
|
});
|
|
|
|
|
|
paramXML = obj2xml(paramXMLObj, {
|
|
|
headers: true,
|
|
|
firstUpperCase: true
|
|
|
});
|
|
|
|
|
|
|
|
|
params.content = paramXML;
|
|
|
params.mime = 'xml';
|
|
|
params.successStatuses = [200];
|
|
|
_context.next = 13;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 13:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 15:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
// todo delete, 兼容旧版本
|
|
|
function defaultDaysAndDate2Expiration(obj) {
|
|
|
if (obj.days) {
|
|
|
obj.expiration = {
|
|
|
days: obj.days
|
|
|
};
|
|
|
}
|
|
|
if (obj.date) {
|
|
|
obj.expiration = {
|
|
|
createdBeforeDate: obj.date
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function checkDaysAndDate(obj, key) {
|
|
|
var days = obj.days,
|
|
|
createdBeforeDate = obj.createdBeforeDate;
|
|
|
|
|
|
if (!days && !createdBeforeDate) {
|
|
|
throw new Error(key + ' must includes days or createdBeforeDate');
|
|
|
} else if (days && !/^[1-9][0-9]*$/.test(days)) {
|
|
|
throw new Error('days must be a positive integer');
|
|
|
} else if (createdBeforeDate && !/\d{4}-\d{2}-\d{2}T00:00:00.000Z/.test(createdBeforeDate)) {
|
|
|
throw new Error('createdBeforeDate must be date and conform to iso8601 format');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function handleCheckTag(tag) {
|
|
|
if (!isArray(tag) && !isObject(tag)) {
|
|
|
throw new Error('tag must be Object or Array');
|
|
|
}
|
|
|
tag = isObject(tag) ? [tag] : tag;
|
|
|
var tagObj = {};
|
|
|
var tagClone = deepCopy(tag);
|
|
|
tagClone.forEach(function (v) {
|
|
|
tagObj[v.key] = v.value;
|
|
|
});
|
|
|
|
|
|
checkObjectTag(tagObj);
|
|
|
}
|
|
|
|
|
|
function checkRule(rule) {
|
|
|
if (rule.id && getStrBytesCount(rule.id) > 255) throw new Error('ID is composed of 255 bytes at most');
|
|
|
|
|
|
if (rule.prefix === '' || rule.prefix === undefined) throw new Error('Rule must includes prefix');
|
|
|
|
|
|
if (!['Enabled', 'Disabled'].includes(rule.status)) throw new Error('Status must be Enabled or Disabled');
|
|
|
|
|
|
if (rule.transition) {
|
|
|
if (!['IA', 'Archive'].includes(rule.transition.storageClass)) throw new Error('StorageClass must be IA or Archive');
|
|
|
checkDaysAndDate(rule.transition, 'Transition');
|
|
|
}
|
|
|
|
|
|
if (rule.expiration) {
|
|
|
if (!rule.expiration.expiredObjectDeleteMarker) {
|
|
|
checkDaysAndDate(rule.expiration, 'Expiration');
|
|
|
} else if (rule.expiration.days || rule.expiration.createdBeforeDate) {
|
|
|
throw new Error('expiredObjectDeleteMarker cannot be used with days or createdBeforeDate');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (rule.abortMultipartUpload) {
|
|
|
checkDaysAndDate(rule.abortMultipartUpload, 'AbortMultipartUpload');
|
|
|
}
|
|
|
|
|
|
if (!rule.expiration && !rule.abortMultipartUpload && !rule.transition && !rule.noncurrentVersionTransition) {
|
|
|
throw new Error('Rule must includes expiration or abortMultipartUpload or transition or noncurrentVersionTransition');
|
|
|
}
|
|
|
|
|
|
if (rule.tag) {
|
|
|
if (rule.abortMultipartUpload) {
|
|
|
throw new Error('Tag cannot be used with abortMultipartUpload');
|
|
|
}
|
|
|
handleCheckTag(rule.tag);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"../utils/checkObjectTag":36,"../utils/deepCopy":39,"../utils/getStrBytesCount":41,"../utils/isArray":42,"../utils/isObject":46,"../utils/obj2xml":47,"babel-runtime/regenerator":68}],12:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var _require2 = require('../utils/obj2xml'),
|
|
|
obj2xml = _require2.obj2xml;
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* putBucketVersioning
|
|
|
* @param {String} name - bucket name
|
|
|
* @param {String} status
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
|
|
|
proto.putBucketVersioning = function putBucketVersioning(name, status) {
|
|
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
|
var params, paramXMLObj, result;
|
|
|
return _regenerator2.default.async(function putBucketVersioning$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_checkBucketName(name);
|
|
|
|
|
|
if (['Enabled', 'Suspended'].includes(status)) {
|
|
|
_context.next = 3;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error('status must be Enabled or Suspended');
|
|
|
|
|
|
case 3:
|
|
|
params = this._bucketRequestParams('PUT', name, 'versioning', options);
|
|
|
paramXMLObj = {
|
|
|
VersioningConfiguration: {
|
|
|
Status: status
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
params.mime = 'xml';
|
|
|
params.content = obj2xml(paramXMLObj, {
|
|
|
headers: true
|
|
|
});
|
|
|
|
|
|
_context.next = 9;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 9:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res,
|
|
|
status: result.status
|
|
|
});
|
|
|
|
|
|
case 11:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"../utils/obj2xml":47,"babel-runtime/regenerator":68}],13:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var _require2 = require('../utils/obj2xml'),
|
|
|
obj2xml = _require2.obj2xml;
|
|
|
|
|
|
var _require3 = require('../utils/isArray'),
|
|
|
isArray = _require3.isArray;
|
|
|
|
|
|
var proto = exports;
|
|
|
proto.putBucketWebsite = function putBucketWebsite(name) {
|
|
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var options = arguments[2];
|
|
|
var params, IndexDocument, WebsiteConfiguration, website, result;
|
|
|
return _regenerator2.default.async(function putBucketWebsite$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_checkBucketName(name);
|
|
|
params = this._bucketRequestParams('PUT', name, 'website', options);
|
|
|
IndexDocument = {
|
|
|
Suffix: config.index || 'index.html'
|
|
|
};
|
|
|
WebsiteConfiguration = {
|
|
|
IndexDocument: IndexDocument
|
|
|
};
|
|
|
website = {
|
|
|
WebsiteConfiguration: WebsiteConfiguration
|
|
|
};
|
|
|
|
|
|
|
|
|
if (config.supportSubDir) {
|
|
|
IndexDocument.SupportSubDir = config.supportSubDir;
|
|
|
}
|
|
|
|
|
|
if (config.type) {
|
|
|
IndexDocument.Type = config.type;
|
|
|
}
|
|
|
|
|
|
if (config.error) {
|
|
|
WebsiteConfiguration.ErrorDocument = {
|
|
|
Key: config.error
|
|
|
};
|
|
|
}
|
|
|
|
|
|
if (!(config.routingRules !== undefined)) {
|
|
|
_context.next = 12;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (isArray(config.routingRules)) {
|
|
|
_context.next = 11;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error('RoutingRules must be Array');
|
|
|
|
|
|
case 11:
|
|
|
WebsiteConfiguration.RoutingRules = {
|
|
|
RoutingRule: config.routingRules
|
|
|
};
|
|
|
|
|
|
case 12:
|
|
|
|
|
|
website = obj2xml(website);
|
|
|
params.content = website;
|
|
|
params.mime = 'xml';
|
|
|
params.successStatuses = [200];
|
|
|
_context.next = 18;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 18:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 20:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"../utils/isArray":42,"../utils/obj2xml":47,"babel-runtime/regenerator":68}],14:[function(require,module,exports){
|
|
|
(function (Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
exports.encodeCallback = function encodeCallback(reqParams, options) {
|
|
|
reqParams.headers = reqParams.headers || {};
|
|
|
if (!Object.prototype.hasOwnProperty.call(reqParams.headers, 'x-oss-callback')) {
|
|
|
if (options.callback) {
|
|
|
var json = {
|
|
|
callbackUrl: encodeURI(options.callback.url),
|
|
|
callbackBody: options.callback.body
|
|
|
};
|
|
|
if (options.callback.host) {
|
|
|
json.callbackHost = options.callback.host;
|
|
|
}
|
|
|
if (options.callback.contentType) {
|
|
|
json.callbackBodyType = options.callback.contentType;
|
|
|
}
|
|
|
var callback = Buffer.from((0, _stringify2.default)(json)).toString('base64');
|
|
|
reqParams.headers['x-oss-callback'] = callback;
|
|
|
|
|
|
if (options.callback.customValue) {
|
|
|
var callbackVar = {};
|
|
|
(0, _keys2.default)(options.callback.customValue).forEach(function (key) {
|
|
|
callbackVar['x:' + key] = options.callback.customValue[key];
|
|
|
});
|
|
|
reqParams.headers['x-oss-callback-var'] = Buffer.from((0, _stringify2.default)(callbackVar)).toString('base64');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
}).call(this,require("buffer").Buffer)
|
|
|
},{"babel-runtime/core-js/json/stringify":53,"babel-runtime/core-js/object/keys":60,"buffer":73}],15:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var ms = require('humanize-ms');
|
|
|
var urlutil = require('url');
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
function setEndpoint(endpoint, secure) {
|
|
|
var url = urlutil.parse(endpoint);
|
|
|
|
|
|
if (!url.protocol) {
|
|
|
url = urlutil.parse('http' + (secure ? 's' : '') + '://' + endpoint);
|
|
|
}
|
|
|
|
|
|
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
|
throw new Error('Endpoint protocol must be http or https.');
|
|
|
}
|
|
|
|
|
|
return url;
|
|
|
}
|
|
|
|
|
|
function setRegion(region, internal, secure) {
|
|
|
var protocol = secure ? 'https://' : 'http://';
|
|
|
var suffix = internal ? '-internal.aliyuncs.com' : '.aliyuncs.com';
|
|
|
var prefix = 'vpc100-oss-cn-';
|
|
|
// aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html
|
|
|
if (region.substr(0, prefix.length) === prefix) {
|
|
|
suffix = '.aliyuncs.com';
|
|
|
}
|
|
|
|
|
|
return urlutil.parse(protocol + region + suffix);
|
|
|
}
|
|
|
|
|
|
module.exports = function (options) {
|
|
|
if (!options || !options.accessKeyId || !options.accessKeySecret) {
|
|
|
throw new Error('require accessKeyId, accessKeySecret');
|
|
|
}
|
|
|
if (options.bucket) {
|
|
|
_checkBucketName(options.bucket);
|
|
|
}
|
|
|
var opts = (0, _assign2.default)({
|
|
|
region: 'oss-cn-hangzhou',
|
|
|
internal: false,
|
|
|
secure: false,
|
|
|
timeout: 60000,
|
|
|
bucket: null,
|
|
|
endpoint: null,
|
|
|
cname: false,
|
|
|
isRequestPay: false,
|
|
|
sldEnable: false
|
|
|
}, options);
|
|
|
|
|
|
opts.accessKeyId = opts.accessKeyId.trim();
|
|
|
opts.accessKeySecret = opts.accessKeySecret.trim();
|
|
|
|
|
|
if (opts.timeout) {
|
|
|
opts.timeout = ms(opts.timeout);
|
|
|
}
|
|
|
|
|
|
if (opts.endpoint) {
|
|
|
opts.endpoint = setEndpoint(opts.endpoint, opts.secure);
|
|
|
} else if (opts.region) {
|
|
|
opts.endpoint = setRegion(opts.region, opts.internal, opts.secure);
|
|
|
} else {
|
|
|
throw new Error('require options.endpoint or options.region');
|
|
|
}
|
|
|
|
|
|
opts.inited = true;
|
|
|
return opts;
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"babel-runtime/core-js/object/assign":54,"humanize-ms":194,"url":238}],16:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var merge = require('merge-descriptors');
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
merge(proto, require('./processObjectSave'));
|
|
|
|
|
|
},{"./processObjectSave":17,"merge-descriptors":200}],17:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
/* eslint-disable no-use-before-define */
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var querystring = require('querystring');
|
|
|
|
|
|
var _require2 = require('js-base64'),
|
|
|
str2Base64 = _require2.Base64.encode;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto.processObjectSave = function processObjectSave(sourceObject, targetObject, process, targetBucket) {
|
|
|
var params, bucketParam, content, result;
|
|
|
return _regenerator2.default.async(function processObjectSave$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
checkArgs(sourceObject, 'sourceObject');
|
|
|
checkArgs(targetObject, 'targetObject');
|
|
|
checkArgs(process, 'process');
|
|
|
targetObject = this._objectName(targetObject);
|
|
|
if (targetBucket) {
|
|
|
_checkBucketName(targetBucket);
|
|
|
}
|
|
|
|
|
|
params = this._objectRequestParams('POST', sourceObject, {
|
|
|
subres: 'x-oss-process'
|
|
|
});
|
|
|
bucketParam = targetBucket ? ',b_' + str2Base64(targetBucket) : '';
|
|
|
|
|
|
targetObject = str2Base64(targetObject);
|
|
|
|
|
|
content = {
|
|
|
'x-oss-process': process + '|sys/saveas,o_' + targetObject + bucketParam
|
|
|
};
|
|
|
|
|
|
params.content = querystring.stringify(content);
|
|
|
|
|
|
_context.next = 12;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 12:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res,
|
|
|
status: result.res.status
|
|
|
});
|
|
|
|
|
|
case 14:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
function checkArgs(name, key) {
|
|
|
if (!name) {
|
|
|
throw new Error(key + ' is required');
|
|
|
}
|
|
|
if (typeof name !== 'string') {
|
|
|
throw new Error(key + ' must be String');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"babel-runtime/regenerator":68,"js-base64":199,"querystring":212}],18:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var copy = require('copy-to');
|
|
|
var callback = require('./callback');
|
|
|
|
|
|
var _require = require('./utils/deepCopy'),
|
|
|
deepCopy = _require.deepCopy;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
/**
|
|
|
* List the on-going multipart uploads
|
|
|
* https://help.aliyun.com/document_detail/31997.html
|
|
|
* @param {Object} options
|
|
|
* @return {Array} the multipart uploads
|
|
|
*/
|
|
|
proto.listUploads = function listUploads(query, options) {
|
|
|
var opt, params, result, uploads;
|
|
|
return _regenerator2.default.async(function listUploads$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
opt = {};
|
|
|
|
|
|
copy(options).to(opt);
|
|
|
opt.subres = 'uploads';
|
|
|
params = this._objectRequestParams('GET', '', opt);
|
|
|
|
|
|
params.query = query;
|
|
|
params.xmlResponse = true;
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
_context.next = 10;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 10:
|
|
|
result = _context.sent;
|
|
|
uploads = result.data.Upload || [];
|
|
|
|
|
|
if (!Array.isArray(uploads)) {
|
|
|
uploads = [uploads];
|
|
|
}
|
|
|
uploads = uploads.map(function (up) {
|
|
|
return {
|
|
|
name: up.Key,
|
|
|
uploadId: up.UploadId,
|
|
|
initiated: up.Initiated
|
|
|
};
|
|
|
});
|
|
|
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res,
|
|
|
uploads: uploads,
|
|
|
bucket: result.data.Bucket,
|
|
|
nextKeyMarker: result.data.NextKeyMarker,
|
|
|
nextUploadIdMarker: result.data.NextUploadIdMarker,
|
|
|
isTruncated: result.data.IsTruncated === 'true'
|
|
|
});
|
|
|
|
|
|
case 15:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* List the done uploadPart parts
|
|
|
* @param {String} name object name
|
|
|
* @param {String} uploadId multipart upload id
|
|
|
* @param {Object} query
|
|
|
* {Number} query.max-parts The maximum part number in the response of the OSS. Default value: 1000
|
|
|
* {Number} query.part-number-marker Starting position of a specific list.
|
|
|
* {String} query.encoding-type Specify the encoding of the returned content and the encoding type.
|
|
|
* @param {Object} options
|
|
|
* @return {Object} result
|
|
|
*/
|
|
|
proto.listParts = function listParts(name, uploadId, query, options) {
|
|
|
var opt, params, result;
|
|
|
return _regenerator2.default.async(function listParts$(_context2) {
|
|
|
while (1) {
|
|
|
switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
opt = {};
|
|
|
|
|
|
copy(options).to(opt);
|
|
|
opt.subres = {
|
|
|
uploadId: uploadId
|
|
|
};
|
|
|
params = this._objectRequestParams('GET', name, opt);
|
|
|
|
|
|
params.query = query;
|
|
|
params.xmlResponse = true;
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
_context2.next = 10;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 10:
|
|
|
result = _context2.sent;
|
|
|
return _context2.abrupt('return', {
|
|
|
res: result.res,
|
|
|
uploadId: result.data.UploadId,
|
|
|
bucket: result.data.Bucket,
|
|
|
name: result.data.Key,
|
|
|
partNumberMarker: result.data.PartNumberMarker,
|
|
|
nextPartNumberMarker: result.data.NextPartNumberMarker,
|
|
|
maxParts: result.data.MaxParts,
|
|
|
isTruncated: result.data.IsTruncated,
|
|
|
parts: result.data.Part || []
|
|
|
});
|
|
|
|
|
|
case 12:
|
|
|
case 'end':
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Abort a multipart upload transaction
|
|
|
* @param {String} name the object name
|
|
|
* @param {String} uploadId the upload id
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
proto.abortMultipartUpload = function abortMultipartUpload(name, uploadId, options) {
|
|
|
var opt, params, result;
|
|
|
return _regenerator2.default.async(function abortMultipartUpload$(_context3) {
|
|
|
while (1) {
|
|
|
switch (_context3.prev = _context3.next) {
|
|
|
case 0:
|
|
|
this._stop();
|
|
|
options = options || {};
|
|
|
opt = {};
|
|
|
|
|
|
copy(options).to(opt);
|
|
|
opt.subres = { uploadId: uploadId };
|
|
|
params = this._objectRequestParams('DELETE', name, opt);
|
|
|
|
|
|
params.successStatuses = [204];
|
|
|
|
|
|
_context3.next = 9;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 9:
|
|
|
result = _context3.sent;
|
|
|
return _context3.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 11:
|
|
|
case 'end':
|
|
|
return _context3.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Initiate a multipart upload transaction
|
|
|
* @param {String} name the object name
|
|
|
* @param {Object} options
|
|
|
* @return {String} upload id
|
|
|
*/
|
|
|
proto.initMultipartUpload = function initMultipartUpload(name, options) {
|
|
|
var opt, params, result;
|
|
|
return _regenerator2.default.async(function initMultipartUpload$(_context4) {
|
|
|
while (1) {
|
|
|
switch (_context4.prev = _context4.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
opt = {};
|
|
|
|
|
|
copy(options).to(opt);
|
|
|
opt.headers = opt.headers || {};
|
|
|
this._convertMetaToHeaders(options.meta, opt.headers);
|
|
|
|
|
|
opt.subres = 'uploads';
|
|
|
params = this._objectRequestParams('POST', name, opt);
|
|
|
|
|
|
params.mime = options.mime;
|
|
|
params.xmlResponse = true;
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
_context4.next = 12;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 12:
|
|
|
result = _context4.sent;
|
|
|
return _context4.abrupt('return', {
|
|
|
res: result.res,
|
|
|
bucket: result.data.Bucket,
|
|
|
name: result.data.Key,
|
|
|
uploadId: result.data.UploadId
|
|
|
});
|
|
|
|
|
|
case 14:
|
|
|
case 'end':
|
|
|
return _context4.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Upload a part in a multipart upload transaction
|
|
|
* @param {String} name the object name
|
|
|
* @param {String} uploadId the upload id
|
|
|
* @param {Integer} partNo the part number
|
|
|
* @param {File} file upload File, whole File
|
|
|
* @param {Integer} start part start bytes e.g: 102400
|
|
|
* @param {Integer} end part end bytes e.g: 204800
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
proto.uploadPart = function uploadPart(name, uploadId, partNo, file, start, end, options) {
|
|
|
var data;
|
|
|
return _regenerator2.default.async(function uploadPart$(_context5) {
|
|
|
while (1) {
|
|
|
switch (_context5.prev = _context5.next) {
|
|
|
case 0:
|
|
|
data = {
|
|
|
stream: this._createStream(file, start, end),
|
|
|
size: end - start
|
|
|
};
|
|
|
_context5.next = 3;
|
|
|
return _regenerator2.default.awrap(this._uploadPart(name, uploadId, partNo, data, options));
|
|
|
|
|
|
case 3:
|
|
|
return _context5.abrupt('return', _context5.sent);
|
|
|
|
|
|
case 4:
|
|
|
case 'end':
|
|
|
return _context5.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Complete a multipart upload transaction
|
|
|
* @param {String} name the object name
|
|
|
* @param {String} uploadId the upload id
|
|
|
* @param {Array} parts the uploaded parts, each in the structure:
|
|
|
* {Integer} number partNo
|
|
|
* {String} etag part etag uploadPartCopy result.res.header.etag
|
|
|
* @param {Object} options
|
|
|
* {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
|
|
|
* {String} options.callback.url the OSS sends a callback request to this URL
|
|
|
* {String} options.callback.host The host header value for initiating callback requests
|
|
|
* {String} options.callback.body The value of the request body when a callback is initiated
|
|
|
* {String} options.callback.contentType The Content-Type of the callback requests initiatiated
|
|
|
* {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
|
|
|
* customValue = {
|
|
|
* key1: 'value1',
|
|
|
* key2: 'value2'
|
|
|
* }
|
|
|
*/
|
|
|
proto.completeMultipartUpload = function completeMultipartUpload(name, uploadId, parts, options) {
|
|
|
var completeParts, xml, i, p, opt, params, result, ret;
|
|
|
return _regenerator2.default.async(function completeMultipartUpload$(_context6) {
|
|
|
while (1) {
|
|
|
switch (_context6.prev = _context6.next) {
|
|
|
case 0:
|
|
|
completeParts = parts.concat().sort(function (a, b) {
|
|
|
return a.number - b.number;
|
|
|
}).filter(function (item, index, arr) {
|
|
|
return !index || item.number !== arr[index - 1].number;
|
|
|
});
|
|
|
xml = '<?xml version="1.0" encoding="UTF-8"?>\n<CompleteMultipartUpload>\n';
|
|
|
|
|
|
for (i = 0; i < completeParts.length; i++) {
|
|
|
p = completeParts[i];
|
|
|
|
|
|
xml += '<Part>\n';
|
|
|
xml += '<PartNumber>' + p.number + '</PartNumber>\n';
|
|
|
xml += '<ETag>' + p.etag + '</ETag>\n';
|
|
|
xml += '</Part>\n';
|
|
|
}
|
|
|
xml += '</CompleteMultipartUpload>';
|
|
|
|
|
|
options = options || {};
|
|
|
opt = {};
|
|
|
|
|
|
opt = deepCopy(options);
|
|
|
if (opt.headers) delete opt.headers['x-oss-server-side-encryption'];
|
|
|
opt.subres = { uploadId: uploadId };
|
|
|
|
|
|
params = this._objectRequestParams('POST', name, opt);
|
|
|
|
|
|
callback.encodeCallback(params, opt);
|
|
|
params.mime = 'xml';
|
|
|
params.content = xml;
|
|
|
|
|
|
if (!(params.headers && params.headers['x-oss-callback'])) {
|
|
|
params.xmlResponse = true;
|
|
|
}
|
|
|
params.successStatuses = [200];
|
|
|
_context6.next = 17;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 17:
|
|
|
result = _context6.sent;
|
|
|
ret = {
|
|
|
res: result.res,
|
|
|
bucket: params.bucket,
|
|
|
name: name,
|
|
|
etag: result.res.headers.etag
|
|
|
};
|
|
|
|
|
|
|
|
|
if (params.headers && params.headers['x-oss-callback']) {
|
|
|
ret.data = JSON.parse(result.data.toString());
|
|
|
}
|
|
|
|
|
|
return _context6.abrupt('return', ret);
|
|
|
|
|
|
case 21:
|
|
|
case 'end':
|
|
|
return _context6.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Upload a part in a multipart upload transaction
|
|
|
* @param {String} name the object name
|
|
|
* @param {String} uploadId the upload id
|
|
|
* @param {Integer} partNo the part number
|
|
|
* @param {Object} data the body data
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
proto._uploadPart = function _uploadPart(name, uploadId, partNo, data, options) {
|
|
|
var opt, params, result;
|
|
|
return _regenerator2.default.async(function _uploadPart$(_context7) {
|
|
|
while (1) {
|
|
|
switch (_context7.prev = _context7.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
opt = {};
|
|
|
|
|
|
copy(options).to(opt);
|
|
|
opt.headers = {
|
|
|
'Content-Length': data.size
|
|
|
};
|
|
|
|
|
|
opt.subres = {
|
|
|
partNumber: partNo,
|
|
|
uploadId: uploadId
|
|
|
};
|
|
|
params = this._objectRequestParams('PUT', name, opt);
|
|
|
|
|
|
params.mime = opt.mime;
|
|
|
params.stream = data.stream;
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
_context7.next = 11;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 11:
|
|
|
result = _context7.sent;
|
|
|
|
|
|
if (result.res.headers.etag) {
|
|
|
_context7.next = 14;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error('Please set the etag of expose-headers in OSS \n https://help.aliyun.com/document_detail/32069.html');
|
|
|
|
|
|
case 14:
|
|
|
|
|
|
data.stream = null;
|
|
|
params.stream = null;
|
|
|
return _context7.abrupt('return', {
|
|
|
name: name,
|
|
|
etag: result.res.headers.etag,
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 17:
|
|
|
case 'end':
|
|
|
return _context7.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"./callback":14,"./utils/deepCopy":39,"babel-runtime/regenerator":68,"copy-to":76}],19:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/checkBucketName'),
|
|
|
_checkBucketName = _require.checkBucketName;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto.copy = function copy(name, sourceName, bucketName, options) {
|
|
|
var params, result, data;
|
|
|
return _regenerator2.default.async(function copy$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
if ((typeof bucketName === 'undefined' ? 'undefined' : (0, _typeof3.default)(bucketName)) === 'object') {
|
|
|
options = bucketName; // 兼容旧版本,旧版本第三个参数为options
|
|
|
}
|
|
|
options = options || {};
|
|
|
options.headers = options.headers || {};
|
|
|
|
|
|
(0, _keys2.default)(options.headers).forEach(function (key) {
|
|
|
options.headers['x-oss-copy-source-' + key.toLowerCase()] = options.headers[key];
|
|
|
});
|
|
|
if (options.meta) {
|
|
|
options.headers['x-oss-metadata-directive'] = 'REPLACE';
|
|
|
}
|
|
|
this._convertMetaToHeaders(options.meta, options.headers);
|
|
|
|
|
|
sourceName = this._getSourceName(sourceName, bucketName);
|
|
|
|
|
|
if (options.versionId) {
|
|
|
sourceName = sourceName + '?versionId=' + options.versionId;
|
|
|
}
|
|
|
|
|
|
options.headers['x-oss-copy-source'] = sourceName;
|
|
|
|
|
|
params = this._objectRequestParams('PUT', name, options);
|
|
|
|
|
|
params.xmlResponse = true;
|
|
|
params.successStatuses = [200, 304];
|
|
|
|
|
|
_context.next = 14;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 14:
|
|
|
result = _context.sent;
|
|
|
data = result.data;
|
|
|
|
|
|
if (data) {
|
|
|
data = {
|
|
|
etag: data.ETag,
|
|
|
lastModified: data.LastModified
|
|
|
};
|
|
|
}
|
|
|
|
|
|
return _context.abrupt('return', {
|
|
|
data: data,
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 18:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
// todo delete
|
|
|
proto._getSourceName = function _getSourceName(sourceName, bucketName) {
|
|
|
if (typeof bucketName === 'string') {
|
|
|
sourceName = this._objectName(sourceName);
|
|
|
} else if (sourceName[0] !== '/') {
|
|
|
bucketName = this.options.bucket;
|
|
|
} else {
|
|
|
bucketName = sourceName.replace(/\/(.+?)(\/.*)/, '$1');
|
|
|
sourceName = sourceName.replace(/(\/.+?\/)(.*)/, '$2');
|
|
|
}
|
|
|
|
|
|
_checkBucketName(bucketName);
|
|
|
|
|
|
sourceName = encodeURI(sourceName);
|
|
|
|
|
|
sourceName = '/' + bucketName + '/' + sourceName;
|
|
|
return sourceName;
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkBucketName":35,"babel-runtime/core-js/object/keys":60,"babel-runtime/helpers/typeof":67,"babel-runtime/regenerator":68}],20:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* delete
|
|
|
* @param {String} name - object name
|
|
|
* @param {Object} options
|
|
|
* @param {{res}}
|
|
|
*/
|
|
|
|
|
|
proto.delete = function _delete(name) {
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function _delete$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options.subres = (0, _assign2.default)({}, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
params = this._objectRequestParams('DELETE', name, options);
|
|
|
|
|
|
params.successStatuses = [204];
|
|
|
|
|
|
_context.next = 6;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 6:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 8:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68}],21:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
/* eslint-disable object-curly-newline */
|
|
|
var utility = require('utility');
|
|
|
|
|
|
var _require = require('../utils/obj2xml'),
|
|
|
obj2xml = _require.obj2xml;
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto.deleteMulti = function deleteMulti(names) {
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
|
|
|
var objects, i, object, _names$i, key, versionId, paramXMLObj, paramXML, params, result, r, deleted;
|
|
|
|
|
|
return _regenerator2.default.async(function deleteMulti$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
objects = [];
|
|
|
|
|
|
if (!(!names || !names.length)) {
|
|
|
_context.next = 3;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error('names is required');
|
|
|
|
|
|
case 3:
|
|
|
for (i = 0; i < names.length; i++) {
|
|
|
object = {};
|
|
|
|
|
|
if (typeof names[i] === 'string') {
|
|
|
object.Key = utility.escape(this._objectName(names[i]));
|
|
|
} else {
|
|
|
_names$i = names[i], key = _names$i.key, versionId = _names$i.versionId;
|
|
|
|
|
|
object.Key = utility.escape(this._objectName(key));
|
|
|
object.VersionId = versionId;
|
|
|
}
|
|
|
objects.push(object);
|
|
|
}
|
|
|
|
|
|
paramXMLObj = {
|
|
|
Delete: {
|
|
|
Quiet: !!options.quiet,
|
|
|
Object: objects
|
|
|
}
|
|
|
};
|
|
|
paramXML = obj2xml(paramXMLObj, {
|
|
|
headers: true
|
|
|
});
|
|
|
|
|
|
|
|
|
options.subres = (0, _assign2.default)({ delete: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
params = this._objectRequestParams('POST', '', options);
|
|
|
|
|
|
params.mime = 'xml';
|
|
|
params.content = paramXML;
|
|
|
params.xmlResponse = true;
|
|
|
params.successStatuses = [200];
|
|
|
_context.next = 15;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 15:
|
|
|
result = _context.sent;
|
|
|
r = result.data;
|
|
|
deleted = r && r.Deleted || null;
|
|
|
|
|
|
if (deleted) {
|
|
|
if (!Array.isArray(deleted)) {
|
|
|
deleted = [deleted];
|
|
|
}
|
|
|
}
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res,
|
|
|
deleted: deleted || []
|
|
|
});
|
|
|
|
|
|
case 20:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/obj2xml":47,"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68,"utility":290}],22:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* deleteObjectTagging
|
|
|
* @param {String} name - object name
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
|
|
|
proto.deleteObjectTagging = function deleteObjectTagging(name) {
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function deleteObjectTagging$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options.subres = (0, _assign2.default)({ tagging: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
name = this._objectName(name);
|
|
|
params = this._objectRequestParams('DELETE', name, options);
|
|
|
|
|
|
params.successStatuses = [204];
|
|
|
_context.next = 7;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 7:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
status: result.status,
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 9:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68}],23:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var fs = require('fs');
|
|
|
var is = require('is-type-of');
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* get
|
|
|
* @param {String} name - object name
|
|
|
* @param {String | Stream} file
|
|
|
* @param {Object} options
|
|
|
* @param {{res}}
|
|
|
*/
|
|
|
proto.get = function get(name, file) {
|
|
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
|
var writeStream, needDestroy, result, params;
|
|
|
return _regenerator2.default.async(function get$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
writeStream = null;
|
|
|
needDestroy = false;
|
|
|
|
|
|
|
|
|
if (is.writableStream(file)) {
|
|
|
writeStream = file;
|
|
|
} else if (is.string(file)) {
|
|
|
writeStream = fs.createWriteStream(file);
|
|
|
needDestroy = true;
|
|
|
} else {
|
|
|
// get(name, options)
|
|
|
options = file;
|
|
|
}
|
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
options.subres = (0, _assign2.default)({}, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
if (options.process) {
|
|
|
options.subres['x-oss-process'] = options.process;
|
|
|
}
|
|
|
|
|
|
result = void 0;
|
|
|
_context.prev = 8;
|
|
|
params = this._objectRequestParams('GET', name, options);
|
|
|
|
|
|
params.writeStream = writeStream;
|
|
|
params.successStatuses = [200, 206, 304];
|
|
|
|
|
|
_context.next = 14;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 14:
|
|
|
result = _context.sent;
|
|
|
|
|
|
|
|
|
if (needDestroy) {
|
|
|
writeStream.destroy();
|
|
|
}
|
|
|
_context.next = 25;
|
|
|
break;
|
|
|
|
|
|
case 18:
|
|
|
_context.prev = 18;
|
|
|
_context.t0 = _context['catch'](8);
|
|
|
|
|
|
if (!needDestroy) {
|
|
|
_context.next = 24;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
writeStream.destroy();
|
|
|
// should delete the exists file before throw error
|
|
|
_context.next = 24;
|
|
|
return _regenerator2.default.awrap(this._deleteFileSafe(file));
|
|
|
|
|
|
case 24:
|
|
|
throw _context.t0;
|
|
|
|
|
|
case 25:
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res,
|
|
|
content: result.data
|
|
|
});
|
|
|
|
|
|
case 26:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this, [[8, 18]]);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68,"fs":71,"is-type-of":289}],24:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
/*
|
|
|
* Get object's ACL
|
|
|
* @param {String} name the object key
|
|
|
* @param {Object} options
|
|
|
* @return {Object}
|
|
|
*/
|
|
|
proto.getACL = function getACL(name) {
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function getACL$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options.subres = (0, _assign2.default)({ acl: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
name = this._objectName(name);
|
|
|
|
|
|
params = this._objectRequestParams('GET', name, options);
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
params.xmlResponse = true;
|
|
|
|
|
|
_context.next = 8;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 8:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
acl: result.data.AccessControlList.Grant,
|
|
|
owner: {
|
|
|
id: result.data.Owner.ID,
|
|
|
displayName: result.data.Owner.DisplayName
|
|
|
},
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 10:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68}],25:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
/* eslint-disable no-use-before-define */
|
|
|
var proto = exports;
|
|
|
|
|
|
var _require = require('../utils/isObject'),
|
|
|
isObject = _require.isObject;
|
|
|
|
|
|
var _require2 = require('../utils/isArray'),
|
|
|
isArray = _require2.isArray;
|
|
|
|
|
|
proto.getBucketVersions = getBucketVersions;
|
|
|
proto.listObjectVersions = getBucketVersions;
|
|
|
|
|
|
function getBucketVersions() {
|
|
|
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var params, result, objects, deleteMarker, that, prefixes;
|
|
|
return _regenerator2.default.async(function getBucketVersions$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
if (!(query.versionIdMarker && query.keyMarker === undefined)) {
|
|
|
_context.next = 2;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error('A version-id marker cannot be specified without a key marker');
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
options.subres = (0, _assign2.default)({ versions: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
params = this._objectRequestParams('GET', '', options);
|
|
|
|
|
|
params.xmlResponse = true;
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
params.query = formatQuery(query);
|
|
|
|
|
|
_context.next = 10;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 10:
|
|
|
result = _context.sent;
|
|
|
objects = result.data.Version || [];
|
|
|
deleteMarker = result.data.DeleteMarker || [];
|
|
|
that = this;
|
|
|
|
|
|
if (objects) {
|
|
|
if (!Array.isArray(objects)) {
|
|
|
objects = [objects];
|
|
|
}
|
|
|
objects = objects.map(function (obj) {
|
|
|
return {
|
|
|
name: obj.Key,
|
|
|
url: that._objectUrl(obj.Key),
|
|
|
lastModified: obj.LastModified,
|
|
|
isLatest: obj.IsLatest === 'true',
|
|
|
versionId: obj.VersionId,
|
|
|
etag: obj.ETag,
|
|
|
type: obj.Type,
|
|
|
size: Number(obj.Size),
|
|
|
storageClass: obj.StorageClass,
|
|
|
owner: {
|
|
|
id: obj.Owner.ID,
|
|
|
displayName: obj.Owner.DisplayName
|
|
|
}
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
if (deleteMarker) {
|
|
|
if (!isArray(deleteMarker)) {
|
|
|
deleteMarker = [deleteMarker];
|
|
|
}
|
|
|
deleteMarker = deleteMarker.map(function (obj) {
|
|
|
return {
|
|
|
name: obj.Key,
|
|
|
lastModified: obj.LastModified,
|
|
|
versionId: obj.VersionId,
|
|
|
owner: {
|
|
|
id: obj.Owner.ID,
|
|
|
displayName: obj.Owner.DisplayName
|
|
|
}
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
prefixes = result.data.CommonPrefixes || null;
|
|
|
|
|
|
if (prefixes) {
|
|
|
if (!isArray(prefixes)) {
|
|
|
prefixes = [prefixes];
|
|
|
}
|
|
|
prefixes = prefixes.map(function (item) {
|
|
|
return item.Prefix;
|
|
|
});
|
|
|
}
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res,
|
|
|
objects: objects,
|
|
|
deleteMarker: deleteMarker,
|
|
|
prefixes: prefixes,
|
|
|
nextMarker: result.data.NextMarker || null,
|
|
|
NextVersionIdMarker: result.data.NextVersionIdMarker || null,
|
|
|
isTruncated: result.data.IsTruncated === 'true'
|
|
|
});
|
|
|
|
|
|
case 19:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
}
|
|
|
|
|
|
function camel2Line(name) {
|
|
|
return name.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
|
}
|
|
|
|
|
|
function formatQuery() {
|
|
|
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
|
|
|
|
var obj = {};
|
|
|
if (isObject(query)) {
|
|
|
(0, _keys2.default)(query).forEach(function (key) {
|
|
|
obj[camel2Line(key)] = query[key];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
},{"../utils/isArray":42,"../utils/isObject":46,"babel-runtime/core-js/object/assign":54,"babel-runtime/core-js/object/keys":60,"babel-runtime/regenerator":68}],26:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* getObjectMeta
|
|
|
* @param {String} name - object name
|
|
|
* @param {Object} options
|
|
|
* @param {{res}}
|
|
|
*/
|
|
|
|
|
|
proto.getObjectMeta = function getObjectMeta(name, options) {
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function getObjectMeta$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
name = this._objectName(name);
|
|
|
options.subres = (0, _assign2.default)({ objectMeta: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
params = this._objectRequestParams('HEAD', name, options);
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
_context.next = 8;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 8:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
status: result.status,
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 10:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68}],27:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
var _require = require('../utils/isObject'),
|
|
|
isObject = _require.isObject;
|
|
|
/**
|
|
|
* getObjectTagging
|
|
|
* @param {String} name - object name
|
|
|
* @param {Object} options
|
|
|
* @return {Object}
|
|
|
*/
|
|
|
|
|
|
proto.getObjectTagging = function getObjectTagging(name) {
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var params, result, Tagging, Tag, tag;
|
|
|
return _regenerator2.default.async(function getObjectTagging$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options.subres = (0, _assign2.default)({ tagging: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
name = this._objectName(name);
|
|
|
params = this._objectRequestParams('GET', name, options);
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
_context.next = 7;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 7:
|
|
|
result = _context.sent;
|
|
|
_context.next = 10;
|
|
|
return _regenerator2.default.awrap(this.parseXML(result.data));
|
|
|
|
|
|
case 10:
|
|
|
Tagging = _context.sent;
|
|
|
Tag = Tagging.TagSet.Tag;
|
|
|
|
|
|
Tag = Tag && isObject(Tag) ? [Tag] : Tag || [];
|
|
|
|
|
|
tag = {};
|
|
|
|
|
|
|
|
|
Tag.forEach(function (item) {
|
|
|
tag[item.Key] = item.Value;
|
|
|
});
|
|
|
|
|
|
return _context.abrupt('return', {
|
|
|
status: result.status,
|
|
|
res: result.res,
|
|
|
tag: tag
|
|
|
});
|
|
|
|
|
|
case 16:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/isObject":46,"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68}],28:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* getSymlink
|
|
|
* @param {String} name - object name
|
|
|
* @param {Object} options
|
|
|
* @param {{res}}
|
|
|
*/
|
|
|
|
|
|
proto.getSymlink = function getSymlink(name) {
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var params, result, target;
|
|
|
return _regenerator2.default.async(function getSymlink$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options.subres = (0, _assign2.default)({ symlink: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
name = this._objectName(name);
|
|
|
params = this._objectRequestParams('GET', name, options);
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
_context.next = 7;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 7:
|
|
|
result = _context.sent;
|
|
|
target = result.res.headers['x-oss-symlink-target'];
|
|
|
return _context.abrupt('return', {
|
|
|
targetName: decodeURIComponent(target),
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 10:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68}],29:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* head
|
|
|
* @param {String} name - object name
|
|
|
* @param {Object} options
|
|
|
* @param {{res}}
|
|
|
*/
|
|
|
|
|
|
proto.head = function head(name) {
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var params, result, data;
|
|
|
return _regenerator2.default.async(function head$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options.subres = (0, _assign2.default)({}, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
params = this._objectRequestParams('HEAD', name, options);
|
|
|
|
|
|
params.successStatuses = [200, 304];
|
|
|
|
|
|
_context.next = 6;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 6:
|
|
|
result = _context.sent;
|
|
|
data = {
|
|
|
meta: null,
|
|
|
res: result.res,
|
|
|
status: result.status
|
|
|
};
|
|
|
|
|
|
|
|
|
if (result.status === 200) {
|
|
|
(0, _keys2.default)(result.headers).forEach(function (k) {
|
|
|
if (k.indexOf('x-oss-meta-') === 0) {
|
|
|
if (!data.meta) {
|
|
|
data.meta = {};
|
|
|
}
|
|
|
data.meta[k.substring(11)] = result.headers[k];
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
return _context.abrupt('return', data);
|
|
|
|
|
|
case 10:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/core-js/object/keys":60,"babel-runtime/regenerator":68}],30:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
/*
|
|
|
* Set object's ACL
|
|
|
* @param {String} name the object key
|
|
|
* @param {String} acl the object ACL
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
proto.putACL = function putACL(name, acl, options) {
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function putACL$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
options.subres = (0, _assign2.default)({ acl: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
options.headers = options.headers || {};
|
|
|
options.headers['x-oss-object-acl'] = acl;
|
|
|
name = this._objectName(name);
|
|
|
|
|
|
params = this._objectRequestParams('PUT', name, options);
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
|
|
|
_context.next = 10;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 10:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 12:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68}],31:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('../utils/obj2xml'),
|
|
|
obj2xml = _require.obj2xml;
|
|
|
|
|
|
var _require2 = require('../utils/checkObjectTag'),
|
|
|
checkObjectTag = _require2.checkObjectTag;
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* putObjectTagging
|
|
|
* @param {String} name - object name
|
|
|
* @param {Object} tag - object tag, eg: `{a: "1", b: "2"}`
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
|
|
|
proto.putObjectTagging = function putObjectTagging(name, tag) {
|
|
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
|
var params, paramXMLObj, result;
|
|
|
return _regenerator2.default.async(function putObjectTagging$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
checkObjectTag(tag);
|
|
|
|
|
|
options.subres = (0, _assign2.default)({ tagging: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
name = this._objectName(name);
|
|
|
params = this._objectRequestParams('PUT', name, options);
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
tag = (0, _keys2.default)(tag).map(function (key) {
|
|
|
return {
|
|
|
Key: key,
|
|
|
Value: tag[key]
|
|
|
};
|
|
|
});
|
|
|
|
|
|
paramXMLObj = {
|
|
|
Tagging: {
|
|
|
TagSet: {
|
|
|
Tag: tag
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
params.mime = 'xml';
|
|
|
params.content = obj2xml(paramXMLObj);
|
|
|
|
|
|
_context.next = 12;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 12:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res,
|
|
|
status: result.status
|
|
|
});
|
|
|
|
|
|
case 14:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"../utils/checkObjectTag":36,"../utils/obj2xml":47,"babel-runtime/core-js/object/assign":54,"babel-runtime/core-js/object/keys":60,"babel-runtime/regenerator":68}],32:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
/**
|
|
|
* putSymlink
|
|
|
* @param {String} name - object name
|
|
|
* @param {String} targetName - target name
|
|
|
* @param {Object} options
|
|
|
* @param {{res}}
|
|
|
*/
|
|
|
|
|
|
proto.putSymlink = function putSymlink(name, targetName, options) {
|
|
|
var params, result;
|
|
|
return _regenerator2.default.async(function putSymlink$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
options = options || {};
|
|
|
options.headers = options.headers || {};
|
|
|
targetName = this._escape(this._objectName(targetName));
|
|
|
this._convertMetaToHeaders(options.meta, options.headers);
|
|
|
options.headers['x-oss-symlink-target'] = targetName;
|
|
|
options.subres = (0, _assign2.default)({ symlink: '' }, options.subres);
|
|
|
if (options.versionId) {
|
|
|
options.subres.versionId = options.versionId;
|
|
|
}
|
|
|
|
|
|
if (options.storageClass) {
|
|
|
options.headers['x-oss-storage-class'] = options.storageClass;
|
|
|
}
|
|
|
|
|
|
name = this._objectName(name);
|
|
|
params = this._objectRequestParams('PUT', name, options);
|
|
|
|
|
|
|
|
|
params.successStatuses = [200];
|
|
|
_context.next = 13;
|
|
|
return _regenerator2.default.awrap(this.request(params));
|
|
|
|
|
|
case 13:
|
|
|
result = _context.sent;
|
|
|
return _context.abrupt('return', {
|
|
|
res: result.res
|
|
|
});
|
|
|
|
|
|
case 15:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this);
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/regenerator":68}],33:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
var _promise = require('babel-runtime/core-js/promise');
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var proto = exports;
|
|
|
|
|
|
proto._parallelNode = function _parallelNode(todo, parallel, fn, sourceData) {
|
|
|
var that, jobErr, jobs, tempBatch, remainder, batch, taskIndex, i;
|
|
|
return _regenerator2.default.async(function _parallelNode$(_context) {
|
|
|
while (1) {
|
|
|
switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
that = this;
|
|
|
// upload in parallel
|
|
|
|
|
|
jobErr = [];
|
|
|
jobs = [];
|
|
|
tempBatch = todo.length / parallel;
|
|
|
remainder = todo.length % parallel;
|
|
|
batch = remainder === 0 ? tempBatch : (todo.length - remainder) / parallel + 1;
|
|
|
taskIndex = 1;
|
|
|
i = 0;
|
|
|
|
|
|
case 8:
|
|
|
if (!(i < todo.length)) {
|
|
|
_context.next = 26;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (!that.isCancel()) {
|
|
|
_context.next = 11;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return _context.abrupt('break', 26);
|
|
|
|
|
|
case 11:
|
|
|
|
|
|
if (sourceData) {
|
|
|
jobs.push(fn(that, todo[i], sourceData));
|
|
|
} else {
|
|
|
jobs.push(fn(that, todo[i]));
|
|
|
}
|
|
|
|
|
|
if (!(jobs.length === parallel || taskIndex === batch && i === todo.length - 1)) {
|
|
|
_context.next = 23;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
_context.prev = 13;
|
|
|
|
|
|
taskIndex += 1;
|
|
|
/* eslint no-await-in-loop: [0] */
|
|
|
_context.next = 17;
|
|
|
return _regenerator2.default.awrap(_promise2.default.all(jobs));
|
|
|
|
|
|
case 17:
|
|
|
_context.next = 22;
|
|
|
break;
|
|
|
|
|
|
case 19:
|
|
|
_context.prev = 19;
|
|
|
_context.t0 = _context['catch'](13);
|
|
|
|
|
|
jobErr.push(_context.t0);
|
|
|
|
|
|
case 22:
|
|
|
jobs = [];
|
|
|
|
|
|
case 23:
|
|
|
i++;
|
|
|
_context.next = 8;
|
|
|
break;
|
|
|
|
|
|
case 26:
|
|
|
return _context.abrupt('return', jobErr);
|
|
|
|
|
|
case 27:
|
|
|
case 'end':
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}
|
|
|
}, null, this, [[13, 19]]);
|
|
|
};
|
|
|
|
|
|
proto._parallel = function _parallel(todo, parallel, jobPromise) {
|
|
|
var that = this;
|
|
|
return new _promise2.default(function (resolve) {
|
|
|
var _jobErr = [];
|
|
|
if (parallel <= 0 || !todo) {
|
|
|
resolve(_jobErr);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
function onlyOnce(fn) {
|
|
|
return function () {
|
|
|
if (fn === null) throw new Error('Callback was already called.');
|
|
|
var callFn = fn;
|
|
|
fn = null;
|
|
|
|
|
|
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
|
args[_key] = arguments[_key];
|
|
|
}
|
|
|
|
|
|
callFn.apply(this, args);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function createArrayIterator(coll) {
|
|
|
var i = -1;
|
|
|
var len = coll.length;
|
|
|
return function next() {
|
|
|
return ++i < len && !that.isCancel() ? { value: coll[i], key: i } : null;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
var nextElem = createArrayIterator(todo);
|
|
|
var done = false;
|
|
|
var running = 0;
|
|
|
var looping = false;
|
|
|
|
|
|
function iterateeCallback(err, value) {
|
|
|
running -= 1;
|
|
|
if (err) {
|
|
|
done = true;
|
|
|
_jobErr.push(err);
|
|
|
resolve(_jobErr);
|
|
|
} else if (value === {} || done && running <= 0) {
|
|
|
done = true;
|
|
|
resolve(_jobErr);
|
|
|
} else if (!looping) {
|
|
|
/* eslint no-use-before-define: [0] */
|
|
|
if (that.isCancel()) {
|
|
|
resolve(_jobErr);
|
|
|
} else {
|
|
|
replenish();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function iteratee(value, callback) {
|
|
|
jobPromise(value).then(function (result) {
|
|
|
callback(null, result);
|
|
|
}).catch(function (err) {
|
|
|
callback(err);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function replenish() {
|
|
|
looping = true;
|
|
|
while (running < parallel && !done && !that.isCancel()) {
|
|
|
var elem = nextElem();
|
|
|
if (elem === null || _jobErr.length > 0) {
|
|
|
done = true;
|
|
|
if (running <= 0) {
|
|
|
resolve(_jobErr);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
running += 1;
|
|
|
iteratee(elem.value, onlyOnce(iterateeCallback));
|
|
|
}
|
|
|
looping = false;
|
|
|
}
|
|
|
|
|
|
replenish();
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* cancel operation, now can use with multipartUpload
|
|
|
* @param {Object} abort
|
|
|
* {String} anort.name object key
|
|
|
* {String} anort.uploadId upload id
|
|
|
* {String} anort.options timeout
|
|
|
*/
|
|
|
proto.cancel = function cancel(abort) {
|
|
|
this.options.cancelFlag = true;
|
|
|
if (abort) {
|
|
|
this.abortMultipartUpload(abort.name, abort.uploadId, abort.options);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
proto.isCancel = function isCancel() {
|
|
|
return this.options.cancelFlag;
|
|
|
};
|
|
|
|
|
|
proto.resetCancelFlag = function resetCancelFlag() {
|
|
|
this.options.cancelFlag = false;
|
|
|
};
|
|
|
|
|
|
proto._stop = function _stop() {
|
|
|
this.options.cancelFlag = true;
|
|
|
};
|
|
|
|
|
|
// cancel is not error , so create an object
|
|
|
proto._makeCancelEvent = function _makeCancelEvent() {
|
|
|
var cancelEvent = {
|
|
|
status: 0,
|
|
|
name: 'cancel'
|
|
|
};
|
|
|
return cancelEvent;
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/promise":61,"babel-runtime/regenerator":68}],34:[function(require,module,exports){
|
|
|
(function (Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var crypto = require('./../../shims/crypto/crypto.js');
|
|
|
var is = require('is-type-of');
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param {String} resourcePath
|
|
|
* @param {Object} parameters
|
|
|
* @return
|
|
|
*/
|
|
|
exports.buildCanonicalizedResource = function buildCanonicalizedResource(resourcePath, parameters) {
|
|
|
var canonicalizedResource = '' + resourcePath;
|
|
|
var separatorString = '?';
|
|
|
|
|
|
if (is.string(parameters) && parameters.trim() !== '') {
|
|
|
canonicalizedResource += separatorString + parameters;
|
|
|
} else if (is.array(parameters)) {
|
|
|
parameters.sort();
|
|
|
canonicalizedResource += separatorString + parameters.join('&');
|
|
|
} else if (parameters) {
|
|
|
var compareFunc = function compareFunc(entry1, entry2) {
|
|
|
if (entry1[0] > entry2[0]) {
|
|
|
return 1;
|
|
|
} else if (entry1[0] < entry2[0]) {
|
|
|
return -1;
|
|
|
}
|
|
|
return 0;
|
|
|
};
|
|
|
var processFunc = function processFunc(key) {
|
|
|
canonicalizedResource += separatorString + key;
|
|
|
if (parameters[key]) {
|
|
|
canonicalizedResource += '=' + parameters[key];
|
|
|
}
|
|
|
separatorString = '&';
|
|
|
};
|
|
|
(0, _keys2.default)(parameters).sort(compareFunc).forEach(processFunc);
|
|
|
}
|
|
|
|
|
|
return canonicalizedResource;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* @param {String} method
|
|
|
* @param {String} resourcePath
|
|
|
* @param {Object} request
|
|
|
* @param {String} expires
|
|
|
* @return {String} canonicalString
|
|
|
*/
|
|
|
exports.buildCanonicalString = function canonicalString(method, resourcePath, request, expires) {
|
|
|
request = request || {};
|
|
|
var headers = request.headers || {};
|
|
|
var OSS_PREFIX = 'x-oss-';
|
|
|
var ossHeaders = [];
|
|
|
var headersToSign = {};
|
|
|
|
|
|
var signContent = [method.toUpperCase(), headers['Content-Md5'] || '', headers['Content-Type'] || headers['Content-Type'.toLowerCase()], expires || headers['x-oss-date']];
|
|
|
|
|
|
(0, _keys2.default)(headers).forEach(function (key) {
|
|
|
var lowerKey = key.toLowerCase();
|
|
|
if (lowerKey.indexOf(OSS_PREFIX) === 0) {
|
|
|
headersToSign[lowerKey] = String(headers[key]).trim();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
(0, _keys2.default)(headersToSign).sort().forEach(function (key) {
|
|
|
ossHeaders.push(key + ':' + headersToSign[key]);
|
|
|
});
|
|
|
|
|
|
signContent = signContent.concat(ossHeaders);
|
|
|
|
|
|
signContent.push(this.buildCanonicalizedResource(resourcePath, request.parameters));
|
|
|
|
|
|
return signContent.join('\n');
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* @param {String} accessKeySecret
|
|
|
* @param {String} canonicalString
|
|
|
*/
|
|
|
exports.computeSignature = function computeSignature(accessKeySecret, canonicalString) {
|
|
|
var signature = crypto.createHmac('sha1', accessKeySecret);
|
|
|
return signature.update(Buffer.from(canonicalString, 'utf8')).digest('base64');
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* @param {String} accessKeyId
|
|
|
* @param {String} accessKeySecret
|
|
|
* @param {String} canonicalString
|
|
|
*/
|
|
|
exports.authorization = function authorization(accessKeyId, accessKeySecret, canonicalString) {
|
|
|
return 'OSS ' + accessKeyId + ':' + this.computeSignature(accessKeySecret, canonicalString);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param {String} accessKeySecret
|
|
|
* @param {Object} options
|
|
|
* @param {String} resource
|
|
|
* @param {Number} expires
|
|
|
*/
|
|
|
exports._signatureForURL = function _signatureForURL(accessKeySecret) {
|
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var resource = arguments[2];
|
|
|
var expires = arguments[3];
|
|
|
|
|
|
var headers = {};
|
|
|
var _options$subResource = options.subResource,
|
|
|
subResource = _options$subResource === undefined ? {} : _options$subResource;
|
|
|
|
|
|
|
|
|
if (options.process) {
|
|
|
var processKeyword = 'x-oss-process';
|
|
|
subResource[processKeyword] = options.process;
|
|
|
}
|
|
|
|
|
|
if (options.trafficLimit) {
|
|
|
var trafficLimitKey = 'x-oss-traffic-limit';
|
|
|
subResource[trafficLimitKey] = options.trafficLimit;
|
|
|
}
|
|
|
|
|
|
if (options.response) {
|
|
|
(0, _keys2.default)(options.response).forEach(function (k) {
|
|
|
var key = 'response-' + k.toLowerCase();
|
|
|
subResource[key] = options.response[k];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
(0, _keys2.default)(options).forEach(function (key) {
|
|
|
var lowerKey = key.toLowerCase();
|
|
|
var value = options[key];
|
|
|
if (lowerKey.indexOf('x-oss-') === 0) {
|
|
|
headers[lowerKey] = value;
|
|
|
} else if (lowerKey.indexOf('content-md5') === 0) {
|
|
|
headers[key] = value;
|
|
|
} else if (lowerKey.indexOf('content-type') === 0) {
|
|
|
headers[key] = value;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (Object.prototype.hasOwnProperty.call(options, 'security-token')) {
|
|
|
subResource['security-token'] = options['security-token'];
|
|
|
}
|
|
|
|
|
|
if (Object.prototype.hasOwnProperty.call(options, 'callback')) {
|
|
|
var json = {
|
|
|
callbackUrl: encodeURI(options.callback.url),
|
|
|
callbackBody: options.callback.body
|
|
|
};
|
|
|
if (options.callback.host) {
|
|
|
json.callbackHost = options.callback.host;
|
|
|
}
|
|
|
if (options.callback.contentType) {
|
|
|
json.callbackBodyType = options.callback.contentType;
|
|
|
}
|
|
|
subResource.callback = Buffer.from((0, _stringify2.default)(json)).toString('base64');
|
|
|
|
|
|
if (options.callback.customValue) {
|
|
|
var callbackVar = {};
|
|
|
(0, _keys2.default)(options.callback.customValue).forEach(function (key) {
|
|
|
callbackVar['x:' + key] = options.callback.customValue[key];
|
|
|
});
|
|
|
subResource['callback-var'] = Buffer.from((0, _stringify2.default)(callbackVar)).toString('base64');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var canonicalString = this.buildCanonicalString(options.method, resource, {
|
|
|
headers: headers,
|
|
|
parameters: subResource
|
|
|
}, expires.toString());
|
|
|
|
|
|
return {
|
|
|
Signature: this.computeSignature(accessKeySecret, canonicalString),
|
|
|
subResource: subResource
|
|
|
};
|
|
|
};
|
|
|
|
|
|
}).call(this,require("buffer").Buffer)
|
|
|
},{"./../../shims/crypto/crypto.js":284,"babel-runtime/core-js/json/stringify":53,"babel-runtime/core-js/object/keys":60,"buffer":73,"is-type-of":289}],35:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.checkBucketName = void 0;
|
|
|
exports.checkBucketName = function (name, createBucket) {
|
|
|
var bucketRegex = createBucket ? /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/ : /^[a-z0-9_][a-z0-9-_]{1,61}[a-z0-9_]$/;
|
|
|
if (!bucketRegex.test(name)) {
|
|
|
throw new Error('The bucket must be conform to the specifications');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
},{}],36:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
var _entries = require("babel-runtime/core-js/object/entries");
|
|
|
|
|
|
var _entries2 = _interopRequireDefault(_entries);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.checkObjectTag = void 0;
|
|
|
|
|
|
var _require = require('./checkValid'),
|
|
|
checkValid = _require.checkValid;
|
|
|
|
|
|
var _require2 = require('./isObject'),
|
|
|
isObject = _require2.isObject;
|
|
|
|
|
|
var commonRules = [{
|
|
|
validator: function validator(value) {
|
|
|
if (typeof value !== 'string') {
|
|
|
throw new Error('the key and value of the tag must be String');
|
|
|
}
|
|
|
}
|
|
|
}, {
|
|
|
pattern: /^[a-zA-Z0-9 +-=._:/]+$/,
|
|
|
msg: 'tag can contain letters, numbers, spaces, and the following symbols: plus sign (+), hyphen (-), equal sign (=), period (.), underscore (_), colon (:), and forward slash (/)'
|
|
|
}];
|
|
|
var rules = {
|
|
|
key: [].concat(commonRules, [{
|
|
|
pattern: /^.{1,128}$/,
|
|
|
msg: 'tag key can be a maximum of 128 bytes in length'
|
|
|
}]),
|
|
|
value: [].concat(commonRules, [{
|
|
|
pattern: /^.{0,256}$/,
|
|
|
msg: 'tag value can be a maximum of 256 bytes in length'
|
|
|
}])
|
|
|
};
|
|
|
function checkObjectTag(tag) {
|
|
|
if (!isObject(tag)) {
|
|
|
throw new Error('tag must be Object');
|
|
|
}
|
|
|
var entries = (0, _entries2.default)(tag);
|
|
|
if (entries.length > 10) {
|
|
|
throw new Error('maximum of 10 tags for a object');
|
|
|
}
|
|
|
var rulesIndexKey = ['key', 'value'];
|
|
|
entries.forEach(function (keyValue) {
|
|
|
keyValue.forEach(function (item, index) {
|
|
|
checkValid(item, rules[rulesIndexKey[index]]);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
exports.checkObjectTag = checkObjectTag;
|
|
|
|
|
|
},{"./checkValid":37,"./isObject":46,"babel-runtime/core-js/object/entries":57}],37:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.checkValid = void 0;
|
|
|
function checkValid(_value, _rules) {
|
|
|
_rules.forEach(function (rule) {
|
|
|
if (rule.validator) {
|
|
|
rule.validator(_value);
|
|
|
} else if (rule.pattern && !rule.pattern.test(_value)) {
|
|
|
throw new Error(rule.msg);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
exports.checkValid = checkValid;
|
|
|
|
|
|
},{}],38:[function(require,module,exports){
|
|
|
(function (Buffer){
|
|
|
"use strict";
|
|
|
|
|
|
var _assign = require("babel-runtime/core-js/object/assign");
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.createRequest = void 0;
|
|
|
var crypto = require('./../../../shims/crypto/crypto.js');
|
|
|
var debug = require('debug')('ali-oss');
|
|
|
var mime = require('mime');
|
|
|
var dateFormat = require('dateformat');
|
|
|
var copy = require('copy-to');
|
|
|
var path = require('path');
|
|
|
function getHeader(headers, name) {
|
|
|
return headers[name] || headers[name.toLowerCase()];
|
|
|
}
|
|
|
function delHeader(headers, name) {
|
|
|
delete headers[name];
|
|
|
delete headers[name.toLowerCase()];
|
|
|
}
|
|
|
function createRequest(params) {
|
|
|
var date = new Date();
|
|
|
if (this.options.amendTimeSkewed) {
|
|
|
date = +new Date() + this.options.amendTimeSkewed;
|
|
|
}
|
|
|
var headers = {
|
|
|
'x-oss-date': dateFormat(date, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''),
|
|
|
'x-oss-user-agent': this.userAgent
|
|
|
};
|
|
|
if (this.userAgent.includes('nodejs')) {
|
|
|
headers['User-Agent'] = this.userAgent;
|
|
|
}
|
|
|
if (this.options.isRequestPay) {
|
|
|
(0, _assign2.default)(headers, { 'x-oss-request-payer': 'requester' });
|
|
|
}
|
|
|
if (this.options.stsToken) {
|
|
|
headers['x-oss-security-token'] = this.options.stsToken;
|
|
|
}
|
|
|
copy(params.headers).to(headers);
|
|
|
if (!getHeader(headers, 'Content-Type')) {
|
|
|
if (params.mime && params.mime.indexOf('/') > 0) {
|
|
|
headers['Content-Type'] = params.mime;
|
|
|
} else {
|
|
|
headers['Content-Type'] = mime.getType(params.mime || path.extname(params.object || ''));
|
|
|
}
|
|
|
}
|
|
|
if (!getHeader(headers, 'Content-Type')) {
|
|
|
delHeader(headers, 'Content-Type');
|
|
|
}
|
|
|
if (params.content) {
|
|
|
headers['Content-Md5'] = crypto.createHash('md5').update(Buffer.from(params.content, 'utf8')).digest('base64');
|
|
|
if (!headers['Content-Length']) {
|
|
|
headers['Content-Length'] = params.content.length;
|
|
|
}
|
|
|
}
|
|
|
var authResource = this._getResource(params);
|
|
|
headers.authorization = this.authorization(params.method, authResource, params.subres, headers);
|
|
|
var url = this._getReqUrl(params);
|
|
|
debug('request %s %s, with headers %j, !!stream: %s', params.method, url, headers, !!params.stream);
|
|
|
var timeout = params.timeout || this.options.timeout;
|
|
|
var reqParams = {
|
|
|
method: params.method,
|
|
|
content: params.content,
|
|
|
stream: params.stream,
|
|
|
headers: headers,
|
|
|
timeout: timeout,
|
|
|
writeStream: params.writeStream,
|
|
|
customResponse: params.customResponse,
|
|
|
ctx: params.ctx || this.ctx
|
|
|
};
|
|
|
if (this.agent) {
|
|
|
reqParams.agent = this.agent;
|
|
|
}
|
|
|
if (this.httpsAgent) {
|
|
|
reqParams.httpsAgent = this.httpsAgent;
|
|
|
}
|
|
|
return {
|
|
|
url: url,
|
|
|
params: reqParams
|
|
|
};
|
|
|
}
|
|
|
exports.createRequest = createRequest;
|
|
|
|
|
|
}).call(this,require("buffer").Buffer)
|
|
|
},{"./../../../shims/crypto/crypto.js":284,"babel-runtime/core-js/object/assign":54,"buffer":73,"copy-to":76,"dateformat":190,"debug":288,"mime":202,"path":205}],39:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
var _keys = require("babel-runtime/core-js/object/keys");
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _typeof2 = require("babel-runtime/helpers/typeof");
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.deepCopy = void 0;
|
|
|
exports.deepCopy = function (obj) {
|
|
|
if (obj === null || (typeof obj === "undefined" ? "undefined" : (0, _typeof3.default)(obj)) !== 'object') {
|
|
|
return obj;
|
|
|
}
|
|
|
var copy = Array.isArray(obj) ? [] : {};
|
|
|
(0, _keys2.default)(obj).forEach(function (key) {
|
|
|
copy[key] = exports.deepCopy(obj[key]);
|
|
|
});
|
|
|
return copy;
|
|
|
};
|
|
|
|
|
|
},{"babel-runtime/core-js/object/keys":60,"babel-runtime/helpers/typeof":67}],40:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
var _keys = require("babel-runtime/core-js/object/keys");
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _typeof2 = require("babel-runtime/helpers/typeof");
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.formatObjKey = void 0;
|
|
|
function formatObjKey(obj, type) {
|
|
|
if (obj === null || (typeof obj === "undefined" ? "undefined" : (0, _typeof3.default)(obj)) !== 'object') {
|
|
|
return obj;
|
|
|
}
|
|
|
var o = void 0;
|
|
|
if (Array.isArray(obj)) {
|
|
|
o = [];
|
|
|
for (var i = 0; i < obj.length; i++) {
|
|
|
o.push(formatObjKey(obj[i], type));
|
|
|
}
|
|
|
} else {
|
|
|
o = {};
|
|
|
(0, _keys2.default)(obj).forEach(function (key) {
|
|
|
o[handelFormat(key, type)] = formatObjKey(obj[key], type);
|
|
|
});
|
|
|
}
|
|
|
return o;
|
|
|
}
|
|
|
exports.formatObjKey = formatObjKey;
|
|
|
function handelFormat(key, type) {
|
|
|
if (type === 'firstUpperCase') {
|
|
|
key = key.replace(/^./, function (_) {
|
|
|
return _.toUpperCase();
|
|
|
});
|
|
|
} else if (type === 'firstLowerCase') {
|
|
|
key = key.replace(/^./, function (_) {
|
|
|
return _.toLowerCase();
|
|
|
});
|
|
|
}
|
|
|
return key;
|
|
|
}
|
|
|
|
|
|
},{"babel-runtime/core-js/object/keys":60,"babel-runtime/helpers/typeof":67}],41:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.getStrBytesCount = void 0;
|
|
|
function getStrBytesCount(str) {
|
|
|
var bytesCount = 0;
|
|
|
for (var i = 0; i < str.length; i++) {
|
|
|
var c = str.charAt(i);
|
|
|
if (/^[\u00-\uff]$/.test(c)) {
|
|
|
bytesCount += 1;
|
|
|
} else {
|
|
|
bytesCount += 2;
|
|
|
}
|
|
|
}
|
|
|
return bytesCount;
|
|
|
}
|
|
|
exports.getStrBytesCount = getStrBytesCount;
|
|
|
|
|
|
},{}],42:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.isArray = void 0;
|
|
|
exports.isArray = function (obj) {
|
|
|
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
|
};
|
|
|
|
|
|
},{}],43:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.isBlob = void 0;
|
|
|
function isBlob(blob) {
|
|
|
return typeof Blob !== 'undefined' && blob instanceof Blob;
|
|
|
}
|
|
|
exports.isBlob = isBlob;
|
|
|
|
|
|
},{}],44:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.isFile = void 0;
|
|
|
exports.isFile = function (obj) {
|
|
|
return typeof File !== 'undefined' && obj instanceof File;
|
|
|
};
|
|
|
|
|
|
},{}],45:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.isIP = void 0;
|
|
|
// it provide commont methods for node and browser , we will add more solutions later in this file
|
|
|
/**
|
|
|
* Judge isIP include ipv4 or ipv6
|
|
|
* @param {String} options
|
|
|
* @return {Array} the multipart uploads
|
|
|
*/
|
|
|
exports.isIP = function (host) {
|
|
|
var ipv4Regex = /^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/;
|
|
|
var ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
|
|
|
return ipv4Regex.test(host) || ipv6Regex.test(host);
|
|
|
};
|
|
|
|
|
|
},{}],46:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.isObject = void 0;
|
|
|
exports.isObject = function (obj) {
|
|
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
|
};
|
|
|
|
|
|
},{}],47:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
var _keys = require("babel-runtime/core-js/object/keys");
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.obj2xml = void 0;
|
|
|
var formatObjKey_1 = require("./formatObjKey");
|
|
|
function type(params) {
|
|
|
return Object.prototype.toString.call(params).replace(/(.*? |])/g, '').toLowerCase();
|
|
|
}
|
|
|
function obj2xml(obj, options) {
|
|
|
var s = '';
|
|
|
if (options && options.headers) {
|
|
|
s = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
|
}
|
|
|
if (options && options.firstUpperCase) {
|
|
|
obj = formatObjKey_1.formatObjKey(obj, 'firstUpperCase');
|
|
|
}
|
|
|
if (type(obj) === 'object') {
|
|
|
(0, _keys2.default)(obj).forEach(function (key) {
|
|
|
if (type(obj[key]) === 'string' || type(obj[key]) === 'number') {
|
|
|
s += "<" + key + ">" + obj[key] + "</" + key + ">";
|
|
|
} else if (type(obj[key]) === 'object') {
|
|
|
s += "<" + key + ">" + obj2xml(obj[key]) + "</" + key + ">";
|
|
|
} else if (type(obj[key]) === 'array') {
|
|
|
s += obj[key].map(function (keyChild) {
|
|
|
return "<" + key + ">" + obj2xml(keyChild) + "</" + key + ">";
|
|
|
}).join('');
|
|
|
} else {
|
|
|
s += "<" + key + ">" + obj[key].toString() + "</" + key + ">";
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
s += obj.toString();
|
|
|
}
|
|
|
return s;
|
|
|
}
|
|
|
exports.obj2xml = obj2xml;
|
|
|
|
|
|
},{"./formatObjKey":40,"babel-runtime/core-js/object/keys":60}],48:[function(require,module,exports){
|
|
|
module.exports = noop;
|
|
|
module.exports.HttpsAgent = noop;
|
|
|
|
|
|
// Noop function for browser since native api's don't use agents.
|
|
|
function noop () {}
|
|
|
|
|
|
},{}],49:[function(require,module,exports){
|
|
|
module.exports = require('./register')().Promise
|
|
|
|
|
|
},{"./register":51}],50:[function(require,module,exports){
|
|
|
"use strict"
|
|
|
// global key for user preferred registration
|
|
|
var REGISTRATION_KEY = '@@any-promise/REGISTRATION',
|
|
|
// Prior registration (preferred or detected)
|
|
|
registered = null
|
|
|
|
|
|
/**
|
|
|
* Registers the given implementation. An implementation must
|
|
|
* be registered prior to any call to `require("any-promise")`,
|
|
|
* typically on application load.
|
|
|
*
|
|
|
* If called with no arguments, will return registration in
|
|
|
* following priority:
|
|
|
*
|
|
|
* For Node.js:
|
|
|
*
|
|
|
* 1. Previous registration
|
|
|
* 2. global.Promise if node.js version >= 0.12
|
|
|
* 3. Auto detected promise based on first sucessful require of
|
|
|
* known promise libraries. Note this is a last resort, as the
|
|
|
* loaded library is non-deterministic. node.js >= 0.12 will
|
|
|
* always use global.Promise over this priority list.
|
|
|
* 4. Throws error.
|
|
|
*
|
|
|
* For Browser:
|
|
|
*
|
|
|
* 1. Previous registration
|
|
|
* 2. window.Promise
|
|
|
* 3. Throws error.
|
|
|
*
|
|
|
* Options:
|
|
|
*
|
|
|
* Promise: Desired Promise constructor
|
|
|
* global: Boolean - Should the registration be cached in a global variable to
|
|
|
* allow cross dependency/bundle registration? (default true)
|
|
|
*/
|
|
|
module.exports = function(root, loadImplementation){
|
|
|
return function register(implementation, opts){
|
|
|
implementation = implementation || null
|
|
|
opts = opts || {}
|
|
|
// global registration unless explicitly {global: false} in options (default true)
|
|
|
var registerGlobal = opts.global !== false;
|
|
|
|
|
|
// load any previous global registration
|
|
|
if(registered === null && registerGlobal){
|
|
|
registered = root[REGISTRATION_KEY] || null
|
|
|
}
|
|
|
|
|
|
if(registered !== null
|
|
|
&& implementation !== null
|
|
|
&& registered.implementation !== implementation){
|
|
|
// Throw error if attempting to redefine implementation
|
|
|
throw new Error('any-promise already defined as "'+registered.implementation+
|
|
|
'". You can only register an implementation before the first '+
|
|
|
' call to require("any-promise") and an implementation cannot be changed')
|
|
|
}
|
|
|
|
|
|
if(registered === null){
|
|
|
// use provided implementation
|
|
|
if(implementation !== null && typeof opts.Promise !== 'undefined'){
|
|
|
registered = {
|
|
|
Promise: opts.Promise,
|
|
|
implementation: implementation
|
|
|
}
|
|
|
} else {
|
|
|
// require implementation if implementation is specified but not provided
|
|
|
registered = loadImplementation(implementation)
|
|
|
}
|
|
|
|
|
|
if(registerGlobal){
|
|
|
// register preference globally in case multiple installations
|
|
|
root[REGISTRATION_KEY] = registered
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return registered
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},{}],51:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
module.exports = require('./loader')(window, loadImplementation)
|
|
|
|
|
|
/**
|
|
|
* Browser specific loadImplementation. Always uses `window.Promise`
|
|
|
*
|
|
|
* To register a custom implementation, must register with `Promise` option.
|
|
|
*/
|
|
|
function loadImplementation(){
|
|
|
if(typeof window.Promise === 'undefined'){
|
|
|
throw new Error("any-promise browser requires a polyfill or explicit registration"+
|
|
|
" e.g: require('any-promise/register/bluebird')")
|
|
|
}
|
|
|
return {
|
|
|
Promise: window.Promise,
|
|
|
implementation: 'window.Promise'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},{"./loader":50}],52:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true };
|
|
|
},{"core-js/library/fn/array/from":77}],53:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true };
|
|
|
},{"core-js/library/fn/json/stringify":78}],54:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/object/assign"), __esModule: true };
|
|
|
},{"core-js/library/fn/object/assign":79}],55:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/object/create"), __esModule: true };
|
|
|
},{"core-js/library/fn/object/create":80}],56:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/object/define-property"), __esModule: true };
|
|
|
},{"core-js/library/fn/object/define-property":81}],57:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/object/entries"), __esModule: true };
|
|
|
},{"core-js/library/fn/object/entries":82}],58:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/object/get-own-property-names"), __esModule: true };
|
|
|
},{"core-js/library/fn/object/get-own-property-names":83}],59:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/object/get-prototype-of"), __esModule: true };
|
|
|
},{"core-js/library/fn/object/get-prototype-of":84}],60:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/object/keys"), __esModule: true };
|
|
|
},{"core-js/library/fn/object/keys":85}],61:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/promise"), __esModule: true };
|
|
|
},{"core-js/library/fn/promise":86}],62:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/set-immediate"), __esModule: true };
|
|
|
},{"core-js/library/fn/set-immediate":87}],63:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/string/from-code-point"), __esModule: true };
|
|
|
},{"core-js/library/fn/string/from-code-point":88}],64:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/symbol"), __esModule: true };
|
|
|
},{"core-js/library/fn/symbol":90}],65:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/symbol/has-instance"), __esModule: true };
|
|
|
},{"core-js/library/fn/symbol/has-instance":89}],66:[function(require,module,exports){
|
|
|
module.exports = { "default": require("core-js/library/fn/symbol/iterator"), __esModule: true };
|
|
|
},{"core-js/library/fn/symbol/iterator":91}],67:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
exports.__esModule = true;
|
|
|
|
|
|
var _iterator = require("../core-js/symbol/iterator");
|
|
|
|
|
|
var _iterator2 = _interopRequireDefault(_iterator);
|
|
|
|
|
|
var _symbol = require("../core-js/symbol");
|
|
|
|
|
|
var _symbol2 = _interopRequireDefault(_symbol);
|
|
|
|
|
|
var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
|
|
|
return typeof obj === "undefined" ? "undefined" : _typeof(obj);
|
|
|
} : function (obj) {
|
|
|
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
|
|
|
};
|
|
|
},{"../core-js/symbol":64,"../core-js/symbol/iterator":66}],68:[function(require,module,exports){
|
|
|
module.exports = require("regenerator-runtime");
|
|
|
|
|
|
},{"regenerator-runtime":226}],69:[function(require,module,exports){
|
|
|
'use strict'
|
|
|
|
|
|
exports.byteLength = byteLength
|
|
|
exports.toByteArray = toByteArray
|
|
|
exports.fromByteArray = fromByteArray
|
|
|
|
|
|
var lookup = []
|
|
|
var revLookup = []
|
|
|
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
|
|
|
|
|
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
|
for (var i = 0, len = code.length; i < len; ++i) {
|
|
|
lookup[i] = code[i]
|
|
|
revLookup[code.charCodeAt(i)] = i
|
|
|
}
|
|
|
|
|
|
// Support decoding URL-safe base64 strings, as Node.js does.
|
|
|
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
|
|
revLookup['-'.charCodeAt(0)] = 62
|
|
|
revLookup['_'.charCodeAt(0)] = 63
|
|
|
|
|
|
function getLens (b64) {
|
|
|
var len = b64.length
|
|
|
|
|
|
if (len % 4 > 0) {
|
|
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
|
}
|
|
|
|
|
|
// Trim off extra bytes after placeholder bytes are found
|
|
|
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
|
var validLen = b64.indexOf('=')
|
|
|
if (validLen === -1) validLen = len
|
|
|
|
|
|
var placeHoldersLen = validLen === len
|
|
|
? 0
|
|
|
: 4 - (validLen % 4)
|
|
|
|
|
|
return [validLen, placeHoldersLen]
|
|
|
}
|
|
|
|
|
|
// base64 is 4/3 + up to two characters of the original data
|
|
|
function byteLength (b64) {
|
|
|
var lens = getLens(b64)
|
|
|
var validLen = lens[0]
|
|
|
var placeHoldersLen = lens[1]
|
|
|
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
|
}
|
|
|
|
|
|
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
|
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
|
}
|
|
|
|
|
|
function toByteArray (b64) {
|
|
|
var tmp
|
|
|
var lens = getLens(b64)
|
|
|
var validLen = lens[0]
|
|
|
var placeHoldersLen = lens[1]
|
|
|
|
|
|
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
|
|
|
|
|
var curByte = 0
|
|
|
|
|
|
// if there are placeholders, only get up to the last complete 4 chars
|
|
|
var len = placeHoldersLen > 0
|
|
|
? validLen - 4
|
|
|
: validLen
|
|
|
|
|
|
var i
|
|
|
for (i = 0; i < len; i += 4) {
|
|
|
tmp =
|
|
|
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
|
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
|
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
|
revLookup[b64.charCodeAt(i + 3)]
|
|
|
arr[curByte++] = (tmp >> 16) & 0xFF
|
|
|
arr[curByte++] = (tmp >> 8) & 0xFF
|
|
|
arr[curByte++] = tmp & 0xFF
|
|
|
}
|
|
|
|
|
|
if (placeHoldersLen === 2) {
|
|
|
tmp =
|
|
|
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
|
(revLookup[b64.charCodeAt(i + 1)] >> 4)
|
|
|
arr[curByte++] = tmp & 0xFF
|
|
|
}
|
|
|
|
|
|
if (placeHoldersLen === 1) {
|
|
|
tmp =
|
|
|
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
|
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
|
(revLookup[b64.charCodeAt(i + 2)] >> 2)
|
|
|
arr[curByte++] = (tmp >> 8) & 0xFF
|
|
|
arr[curByte++] = tmp & 0xFF
|
|
|
}
|
|
|
|
|
|
return arr
|
|
|
}
|
|
|
|
|
|
function tripletToBase64 (num) {
|
|
|
return lookup[num >> 18 & 0x3F] +
|
|
|
lookup[num >> 12 & 0x3F] +
|
|
|
lookup[num >> 6 & 0x3F] +
|
|
|
lookup[num & 0x3F]
|
|
|
}
|
|
|
|
|
|
function encodeChunk (uint8, start, end) {
|
|
|
var tmp
|
|
|
var output = []
|
|
|
for (var i = start; i < end; i += 3) {
|
|
|
tmp =
|
|
|
((uint8[i] << 16) & 0xFF0000) +
|
|
|
((uint8[i + 1] << 8) & 0xFF00) +
|
|
|
(uint8[i + 2] & 0xFF)
|
|
|
output.push(tripletToBase64(tmp))
|
|
|
}
|
|
|
return output.join('')
|
|
|
}
|
|
|
|
|
|
function fromByteArray (uint8) {
|
|
|
var tmp
|
|
|
var len = uint8.length
|
|
|
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
|
|
var parts = []
|
|
|
var maxChunkLength = 16383 // must be multiple of 3
|
|
|
|
|
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
|
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
|
parts.push(encodeChunk(
|
|
|
uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
|
|
|
))
|
|
|
}
|
|
|
|
|
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
|
if (extraBytes === 1) {
|
|
|
tmp = uint8[len - 1]
|
|
|
parts.push(
|
|
|
lookup[tmp >> 2] +
|
|
|
lookup[(tmp << 4) & 0x3F] +
|
|
|
'=='
|
|
|
)
|
|
|
} else if (extraBytes === 2) {
|
|
|
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
|
|
parts.push(
|
|
|
lookup[tmp >> 10] +
|
|
|
lookup[(tmp >> 4) & 0x3F] +
|
|
|
lookup[(tmp << 2) & 0x3F] +
|
|
|
'='
|
|
|
)
|
|
|
}
|
|
|
|
|
|
return parts.join('')
|
|
|
}
|
|
|
|
|
|
},{}],70:[function(require,module,exports){
|
|
|
/*!
|
|
|
* Bowser - a browser detector
|
|
|
* https://github.com/ded/bowser
|
|
|
* MIT License | (c) Dustin Diaz 2015
|
|
|
*/
|
|
|
|
|
|
!function (root, name, definition) {
|
|
|
if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
|
|
else if (typeof define == 'function' && define.amd) define(name, definition)
|
|
|
else root[name] = definition()
|
|
|
}(this, 'bowser', function () {
|
|
|
/**
|
|
|
* See useragents.js for examples of navigator.userAgent
|
|
|
*/
|
|
|
|
|
|
var t = true
|
|
|
|
|
|
function detect(ua) {
|
|
|
|
|
|
function getFirstMatch(regex) {
|
|
|
var match = ua.match(regex);
|
|
|
return (match && match.length > 1 && match[1]) || '';
|
|
|
}
|
|
|
|
|
|
function getSecondMatch(regex) {
|
|
|
var match = ua.match(regex);
|
|
|
return (match && match.length > 1 && match[2]) || '';
|
|
|
}
|
|
|
|
|
|
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
|
|
|
, likeAndroid = /like android/i.test(ua)
|
|
|
, android = !likeAndroid && /android/i.test(ua)
|
|
|
, nexusMobile = /nexus\s*[0-6]\s*/i.test(ua)
|
|
|
, nexusTablet = !nexusMobile && /nexus\s*[0-9]+/i.test(ua)
|
|
|
, chromeos = /CrOS/.test(ua)
|
|
|
, silk = /silk/i.test(ua)
|
|
|
, sailfish = /sailfish/i.test(ua)
|
|
|
, tizen = /tizen/i.test(ua)
|
|
|
, webos = /(web|hpw)(o|0)s/i.test(ua)
|
|
|
, windowsphone = /windows phone/i.test(ua)
|
|
|
, samsungBrowser = /SamsungBrowser/i.test(ua)
|
|
|
, windows = !windowsphone && /windows/i.test(ua)
|
|
|
, mac = !iosdevice && !silk && /macintosh/i.test(ua)
|
|
|
, linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
|
|
|
, edgeVersion = getSecondMatch(/edg([ea]|ios)\/(\d+(\.\d+)?)/i)
|
|
|
, versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
|
|
|
, tablet = /tablet/i.test(ua) && !/tablet pc/i.test(ua)
|
|
|
, mobile = !tablet && /[^-]mobi/i.test(ua)
|
|
|
, xbox = /xbox/i.test(ua)
|
|
|
, result
|
|
|
|
|
|
if (/opera/i.test(ua)) {
|
|
|
// an old Opera
|
|
|
result = {
|
|
|
name: 'Opera'
|
|
|
, opera: t
|
|
|
, version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
} else if (/opr\/|opios/i.test(ua)) {
|
|
|
// a new Opera
|
|
|
result = {
|
|
|
name: 'Opera'
|
|
|
, opera: t
|
|
|
, version: getFirstMatch(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i) || versionIdentifier
|
|
|
}
|
|
|
}
|
|
|
else if (/SamsungBrowser/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Samsung Internet for Android'
|
|
|
, samsungBrowser: t
|
|
|
, version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/Whale/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'NAVER Whale browser'
|
|
|
, whale: t
|
|
|
, version: getFirstMatch(/(?:whale)[\s\/](\d+(?:\.\d+)+)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/MZBrowser/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'MZ Browser'
|
|
|
, mzbrowser: t
|
|
|
, version: getFirstMatch(/(?:MZBrowser)[\s\/](\d+(?:\.\d+)+)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/coast/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Opera Coast'
|
|
|
, coast: t
|
|
|
, version: versionIdentifier || getFirstMatch(/(?:coast)[\s\/](\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/focus/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Focus'
|
|
|
, focus: t
|
|
|
, version: getFirstMatch(/(?:focus)[\s\/](\d+(?:\.\d+)+)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/yabrowser/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Yandex Browser'
|
|
|
, yandexbrowser: t
|
|
|
, version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/ucbrowser/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'UC Browser'
|
|
|
, ucbrowser: t
|
|
|
, version: getFirstMatch(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/mxios/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Maxthon'
|
|
|
, maxthon: t
|
|
|
, version: getFirstMatch(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/epiphany/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Epiphany'
|
|
|
, epiphany: t
|
|
|
, version: getFirstMatch(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/puffin/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Puffin'
|
|
|
, puffin: t
|
|
|
, version: getFirstMatch(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/sleipnir/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Sleipnir'
|
|
|
, sleipnir: t
|
|
|
, version: getFirstMatch(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/k-meleon/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'K-Meleon'
|
|
|
, kMeleon: t
|
|
|
, version: getFirstMatch(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (windowsphone) {
|
|
|
result = {
|
|
|
name: 'Windows Phone'
|
|
|
, osname: 'Windows Phone'
|
|
|
, windowsphone: t
|
|
|
}
|
|
|
if (edgeVersion) {
|
|
|
result.msedge = t
|
|
|
result.version = edgeVersion
|
|
|
}
|
|
|
else {
|
|
|
result.msie = t
|
|
|
result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/msie|trident/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Internet Explorer'
|
|
|
, msie: t
|
|
|
, version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
} else if (chromeos) {
|
|
|
result = {
|
|
|
name: 'Chrome'
|
|
|
, osname: 'Chrome OS'
|
|
|
, chromeos: t
|
|
|
, chromeBook: t
|
|
|
, chrome: t
|
|
|
, version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
} else if (/edg([ea]|ios)/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Microsoft Edge'
|
|
|
, msedge: t
|
|
|
, version: edgeVersion
|
|
|
}
|
|
|
}
|
|
|
else if (/vivaldi/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Vivaldi'
|
|
|
, vivaldi: t
|
|
|
, version: getFirstMatch(/vivaldi\/(\d+(\.\d+)?)/i) || versionIdentifier
|
|
|
}
|
|
|
}
|
|
|
else if (sailfish) {
|
|
|
result = {
|
|
|
name: 'Sailfish'
|
|
|
, osname: 'Sailfish OS'
|
|
|
, sailfish: t
|
|
|
, version: getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/seamonkey\//i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'SeaMonkey'
|
|
|
, seamonkey: t
|
|
|
, version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/firefox|iceweasel|fxios/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Firefox'
|
|
|
, firefox: t
|
|
|
, version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
|
|
|
result.firefoxos = t
|
|
|
result.osname = 'Firefox OS'
|
|
|
}
|
|
|
}
|
|
|
else if (silk) {
|
|
|
result = {
|
|
|
name: 'Amazon Silk'
|
|
|
, silk: t
|
|
|
, version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/phantom/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'PhantomJS'
|
|
|
, phantom: t
|
|
|
, version: getFirstMatch(/phantomjs\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/slimerjs/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'SlimerJS'
|
|
|
, slimer: t
|
|
|
, version: getFirstMatch(/slimerjs\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (/blackberry|\bbb\d+/i.test(ua) || /rim\stablet/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'BlackBerry'
|
|
|
, osname: 'BlackBerry OS'
|
|
|
, blackberry: t
|
|
|
, version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (webos) {
|
|
|
result = {
|
|
|
name: 'WebOS'
|
|
|
, osname: 'WebOS'
|
|
|
, webos: t
|
|
|
, version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)
|
|
|
};
|
|
|
/touchpad\//i.test(ua) && (result.touchpad = t)
|
|
|
}
|
|
|
else if (/bada/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Bada'
|
|
|
, osname: 'Bada'
|
|
|
, bada: t
|
|
|
, version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
|
|
|
};
|
|
|
}
|
|
|
else if (tizen) {
|
|
|
result = {
|
|
|
name: 'Tizen'
|
|
|
, osname: 'Tizen'
|
|
|
, tizen: t
|
|
|
, version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
|
|
|
};
|
|
|
}
|
|
|
else if (/qupzilla/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'QupZilla'
|
|
|
, qupzilla: t
|
|
|
, version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier
|
|
|
}
|
|
|
}
|
|
|
else if (/chromium/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Chromium'
|
|
|
, chromium: t
|
|
|
, version: getFirstMatch(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i) || versionIdentifier
|
|
|
}
|
|
|
}
|
|
|
else if (/chrome|crios|crmo/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Chrome'
|
|
|
, chrome: t
|
|
|
, version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
}
|
|
|
else if (android) {
|
|
|
result = {
|
|
|
name: 'Android'
|
|
|
, version: versionIdentifier
|
|
|
}
|
|
|
}
|
|
|
else if (/safari|applewebkit/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Safari'
|
|
|
, safari: t
|
|
|
}
|
|
|
if (versionIdentifier) {
|
|
|
result.version = versionIdentifier
|
|
|
}
|
|
|
}
|
|
|
else if (iosdevice) {
|
|
|
result = {
|
|
|
name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod'
|
|
|
}
|
|
|
// WTF: version is not part of user agent in web apps
|
|
|
if (versionIdentifier) {
|
|
|
result.version = versionIdentifier
|
|
|
}
|
|
|
}
|
|
|
else if(/googlebot/i.test(ua)) {
|
|
|
result = {
|
|
|
name: 'Googlebot'
|
|
|
, googlebot: t
|
|
|
, version: getFirstMatch(/googlebot\/(\d+(\.\d+))/i) || versionIdentifier
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
result = {
|
|
|
name: getFirstMatch(/^(.*)\/(.*) /),
|
|
|
version: getSecondMatch(/^(.*)\/(.*) /)
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// set webkit or gecko flag for browsers based on these engines
|
|
|
if (!result.msedge && /(apple)?webkit/i.test(ua)) {
|
|
|
if (/(apple)?webkit\/537\.36/i.test(ua)) {
|
|
|
result.name = result.name || "Blink"
|
|
|
result.blink = t
|
|
|
} else {
|
|
|
result.name = result.name || "Webkit"
|
|
|
result.webkit = t
|
|
|
}
|
|
|
if (!result.version && versionIdentifier) {
|
|
|
result.version = versionIdentifier
|
|
|
}
|
|
|
} else if (!result.opera && /gecko\//i.test(ua)) {
|
|
|
result.name = result.name || "Gecko"
|
|
|
result.gecko = t
|
|
|
result.version = result.version || getFirstMatch(/gecko\/(\d+(\.\d+)?)/i)
|
|
|
}
|
|
|
|
|
|
// set OS flags for platforms that have multiple browsers
|
|
|
if (!result.windowsphone && (android || result.silk)) {
|
|
|
result.android = t
|
|
|
result.osname = 'Android'
|
|
|
} else if (!result.windowsphone && iosdevice) {
|
|
|
result[iosdevice] = t
|
|
|
result.ios = t
|
|
|
result.osname = 'iOS'
|
|
|
} else if (mac) {
|
|
|
result.mac = t
|
|
|
result.osname = 'macOS'
|
|
|
} else if (xbox) {
|
|
|
result.xbox = t
|
|
|
result.osname = 'Xbox'
|
|
|
} else if (windows) {
|
|
|
result.windows = t
|
|
|
result.osname = 'Windows'
|
|
|
} else if (linux) {
|
|
|
result.linux = t
|
|
|
result.osname = 'Linux'
|
|
|
}
|
|
|
|
|
|
function getWindowsVersion (s) {
|
|
|
switch (s) {
|
|
|
case 'NT': return 'NT'
|
|
|
case 'XP': return 'XP'
|
|
|
case 'NT 5.0': return '2000'
|
|
|
case 'NT 5.1': return 'XP'
|
|
|
case 'NT 5.2': return '2003'
|
|
|
case 'NT 6.0': return 'Vista'
|
|
|
case 'NT 6.1': return '7'
|
|
|
case 'NT 6.2': return '8'
|
|
|
case 'NT 6.3': return '8.1'
|
|
|
case 'NT 10.0': return '10'
|
|
|
default: return undefined
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// OS version extraction
|
|
|
var osVersion = '';
|
|
|
if (result.windows) {
|
|
|
osVersion = getWindowsVersion(getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i))
|
|
|
} else if (result.windowsphone) {
|
|
|
osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
|
|
|
} else if (result.mac) {
|
|
|
osVersion = getFirstMatch(/Mac OS X (\d+([_\.\s]\d+)*)/i);
|
|
|
osVersion = osVersion.replace(/[_\s]/g, '.');
|
|
|
} else if (iosdevice) {
|
|
|
osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
|
|
|
osVersion = osVersion.replace(/[_\s]/g, '.');
|
|
|
} else if (android) {
|
|
|
osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
|
|
|
} else if (result.webos) {
|
|
|
osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
|
|
|
} else if (result.blackberry) {
|
|
|
osVersion = getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i);
|
|
|
} else if (result.bada) {
|
|
|
osVersion = getFirstMatch(/bada\/(\d+(\.\d+)*)/i);
|
|
|
} else if (result.tizen) {
|
|
|
osVersion = getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i);
|
|
|
}
|
|
|
if (osVersion) {
|
|
|
result.osversion = osVersion;
|
|
|
}
|
|
|
|
|
|
// device type extraction
|
|
|
var osMajorVersion = !result.windows && osVersion.split('.')[0];
|
|
|
if (
|
|
|
tablet
|
|
|
|| nexusTablet
|
|
|
|| iosdevice == 'ipad'
|
|
|
|| (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile)))
|
|
|
|| result.silk
|
|
|
) {
|
|
|
result.tablet = t
|
|
|
} else if (
|
|
|
mobile
|
|
|
|| iosdevice == 'iphone'
|
|
|
|| iosdevice == 'ipod'
|
|
|
|| android
|
|
|
|| nexusMobile
|
|
|
|| result.blackberry
|
|
|
|| result.webos
|
|
|
|| result.bada
|
|
|
) {
|
|
|
result.mobile = t
|
|
|
}
|
|
|
|
|
|
// Graded Browser Support
|
|
|
// http://developer.yahoo.com/yui/articles/gbs
|
|
|
if (result.msedge ||
|
|
|
(result.msie && result.version >= 10) ||
|
|
|
(result.yandexbrowser && result.version >= 15) ||
|
|
|
(result.vivaldi && result.version >= 1.0) ||
|
|
|
(result.chrome && result.version >= 20) ||
|
|
|
(result.samsungBrowser && result.version >= 4) ||
|
|
|
(result.whale && compareVersions([result.version, '1.0']) === 1) ||
|
|
|
(result.mzbrowser && compareVersions([result.version, '6.0']) === 1) ||
|
|
|
(result.focus && compareVersions([result.version, '1.0']) === 1) ||
|
|
|
(result.firefox && result.version >= 20.0) ||
|
|
|
(result.safari && result.version >= 6) ||
|
|
|
(result.opera && result.version >= 10.0) ||
|
|
|
(result.ios && result.osversion && result.osversion.split(".")[0] >= 6) ||
|
|
|
(result.blackberry && result.version >= 10.1)
|
|
|
|| (result.chromium && result.version >= 20)
|
|
|
) {
|
|
|
result.a = t;
|
|
|
}
|
|
|
else if ((result.msie && result.version < 10) ||
|
|
|
(result.chrome && result.version < 20) ||
|
|
|
(result.firefox && result.version < 20.0) ||
|
|
|
(result.safari && result.version < 6) ||
|
|
|
(result.opera && result.version < 10.0) ||
|
|
|
(result.ios && result.osversion && result.osversion.split(".")[0] < 6)
|
|
|
|| (result.chromium && result.version < 20)
|
|
|
) {
|
|
|
result.c = t
|
|
|
} else result.x = t
|
|
|
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')
|
|
|
|
|
|
bowser.test = function (browserList) {
|
|
|
for (var i = 0; i < browserList.length; ++i) {
|
|
|
var browserItem = browserList[i];
|
|
|
if (typeof browserItem=== 'string') {
|
|
|
if (browserItem in bowser) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get version precisions count
|
|
|
*
|
|
|
* @example
|
|
|
* getVersionPrecision("1.10.3") // 3
|
|
|
*
|
|
|
* @param {string} version
|
|
|
* @return {number}
|
|
|
*/
|
|
|
function getVersionPrecision(version) {
|
|
|
return version.split(".").length;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Array::map polyfill
|
|
|
*
|
|
|
* @param {Array} arr
|
|
|
* @param {Function} iterator
|
|
|
* @return {Array}
|
|
|
*/
|
|
|
function map(arr, iterator) {
|
|
|
var result = [], i;
|
|
|
if (Array.prototype.map) {
|
|
|
return Array.prototype.map.call(arr, iterator);
|
|
|
}
|
|
|
for (i = 0; i < arr.length; i++) {
|
|
|
result.push(iterator(arr[i]));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Calculate browser version weight
|
|
|
*
|
|
|
* @example
|
|
|
* compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1
|
|
|
* compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1
|
|
|
* compareVersions(['1.10.2.1', '1.10.2.1']); // 0
|
|
|
* compareVersions(['1.10.2.1', '1.0800.2']); // -1
|
|
|
*
|
|
|
* @param {Array<String>} versions versions to compare
|
|
|
* @return {Number} comparison result
|
|
|
*/
|
|
|
function compareVersions(versions) {
|
|
|
// 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
|
|
|
var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));
|
|
|
var chunks = map(versions, function (version) {
|
|
|
var delta = precision - getVersionPrecision(version);
|
|
|
|
|
|
// 2) "9" -> "9.0" (for precision = 2)
|
|
|
version = version + new Array(delta + 1).join(".0");
|
|
|
|
|
|
// 3) "9.0" -> ["000000000"", "000000009"]
|
|
|
return map(version.split("."), function (chunk) {
|
|
|
return new Array(20 - chunk.length).join("0") + chunk;
|
|
|
}).reverse();
|
|
|
});
|
|
|
|
|
|
// iterate in reverse order by reversed chunks array
|
|
|
while (--precision >= 0) {
|
|
|
// 4) compare: "000000009" > "000000010" = false (but "9" > "10" = true)
|
|
|
if (chunks[0][precision] > chunks[1][precision]) {
|
|
|
return 1;
|
|
|
}
|
|
|
else if (chunks[0][precision] === chunks[1][precision]) {
|
|
|
if (precision === 0) {
|
|
|
// all version chunks are same
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check if browser is unsupported
|
|
|
*
|
|
|
* @example
|
|
|
* bowser.isUnsupportedBrowser({
|
|
|
* msie: "10",
|
|
|
* firefox: "23",
|
|
|
* chrome: "29",
|
|
|
* safari: "5.1",
|
|
|
* opera: "16",
|
|
|
* phantom: "534"
|
|
|
* });
|
|
|
*
|
|
|
* @param {Object} minVersions map of minimal version to browser
|
|
|
* @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
|
|
|
* @param {String} [ua] user agent string
|
|
|
* @return {Boolean}
|
|
|
*/
|
|
|
function isUnsupportedBrowser(minVersions, strictMode, ua) {
|
|
|
var _bowser = bowser;
|
|
|
|
|
|
// make strictMode param optional with ua param usage
|
|
|
if (typeof strictMode === 'string') {
|
|
|
ua = strictMode;
|
|
|
strictMode = void(0);
|
|
|
}
|
|
|
|
|
|
if (strictMode === void(0)) {
|
|
|
strictMode = false;
|
|
|
}
|
|
|
if (ua) {
|
|
|
_bowser = detect(ua);
|
|
|
}
|
|
|
|
|
|
var version = "" + _bowser.version;
|
|
|
for (var browser in minVersions) {
|
|
|
if (minVersions.hasOwnProperty(browser)) {
|
|
|
if (_bowser[browser]) {
|
|
|
if (typeof minVersions[browser] !== 'string') {
|
|
|
throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));
|
|
|
}
|
|
|
|
|
|
// browser version and min supported version.
|
|
|
return compareVersions([version, minVersions[browser]]) < 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return strictMode; // not found
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check if browser is supported
|
|
|
*
|
|
|
* @param {Object} minVersions map of minimal version to browser
|
|
|
* @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
|
|
|
* @param {String} [ua] user agent string
|
|
|
* @return {Boolean}
|
|
|
*/
|
|
|
function check(minVersions, strictMode, ua) {
|
|
|
return !isUnsupportedBrowser(minVersions, strictMode, ua);
|
|
|
}
|
|
|
|
|
|
bowser.isUnsupportedBrowser = isUnsupportedBrowser;
|
|
|
bowser.compareVersions = compareVersions;
|
|
|
bowser.check = check;
|
|
|
|
|
|
/*
|
|
|
* Set our detect method to the main bowser object so we can
|
|
|
* reuse it to test other user agents.
|
|
|
* This is needed to implement future tests.
|
|
|
*/
|
|
|
bowser._detect = detect;
|
|
|
|
|
|
/*
|
|
|
* Set our detect public method to the main bowser object
|
|
|
* This is needed to implement bowser in server side
|
|
|
*/
|
|
|
bowser.detect = detect;
|
|
|
return bowser
|
|
|
});
|
|
|
|
|
|
},{}],71:[function(require,module,exports){
|
|
|
|
|
|
},{}],72:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
var Buffer = require('buffer').Buffer;
|
|
|
|
|
|
var isBufferEncoding = Buffer.isEncoding
|
|
|
|| function(encoding) {
|
|
|
switch (encoding && encoding.toLowerCase()) {
|
|
|
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': return true;
|
|
|
default: return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
function assertEncoding(encoding) {
|
|
|
if (encoding && !isBufferEncoding(encoding)) {
|
|
|
throw new Error('Unknown encoding: ' + encoding);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// StringDecoder provides an interface for efficiently splitting a series of
|
|
|
// buffers into a series of JS strings without breaking apart multi-byte
|
|
|
// characters. CESU-8 is handled as part of the UTF-8 encoding.
|
|
|
//
|
|
|
// @TODO Handling all encodings inside a single object makes it very difficult
|
|
|
// to reason about this code, so it should be split up in the future.
|
|
|
// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
|
|
|
// points as used by CESU-8.
|
|
|
var StringDecoder = exports.StringDecoder = function(encoding) {
|
|
|
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
|
|
|
assertEncoding(encoding);
|
|
|
switch (this.encoding) {
|
|
|
case 'utf8':
|
|
|
// CESU-8 represents each of Surrogate Pair by 3-bytes
|
|
|
this.surrogateSize = 3;
|
|
|
break;
|
|
|
case 'ucs2':
|
|
|
case 'utf16le':
|
|
|
// UTF-16 represents each of Surrogate Pair by 2-bytes
|
|
|
this.surrogateSize = 2;
|
|
|
this.detectIncompleteChar = utf16DetectIncompleteChar;
|
|
|
break;
|
|
|
case 'base64':
|
|
|
// Base-64 stores 3 bytes in 4 chars, and pads the remainder.
|
|
|
this.surrogateSize = 3;
|
|
|
this.detectIncompleteChar = base64DetectIncompleteChar;
|
|
|
break;
|
|
|
default:
|
|
|
this.write = passThroughWrite;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Enough space to store all bytes of a single character. UTF-8 needs 4
|
|
|
// bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
|
|
|
this.charBuffer = new Buffer(6);
|
|
|
// Number of bytes received for the current incomplete multi-byte character.
|
|
|
this.charReceived = 0;
|
|
|
// Number of bytes expected for the current incomplete multi-byte character.
|
|
|
this.charLength = 0;
|
|
|
};
|
|
|
|
|
|
|
|
|
// write decodes the given buffer and returns it as JS string that is
|
|
|
// guaranteed to not contain any partial multi-byte characters. Any partial
|
|
|
// character found at the end of the buffer is buffered up, and will be
|
|
|
// returned when calling write again with the remaining bytes.
|
|
|
//
|
|
|
// Note: Converting a Buffer containing an orphan surrogate to a String
|
|
|
// currently works, but converting a String to a Buffer (via `new Buffer`, or
|
|
|
// Buffer#write) will replace incomplete surrogates with the unicode
|
|
|
// replacement character. See https://codereview.chromium.org/121173009/ .
|
|
|
StringDecoder.prototype.write = function(buffer) {
|
|
|
var charStr = '';
|
|
|
// if our last write ended with an incomplete multibyte character
|
|
|
while (this.charLength) {
|
|
|
// determine how many remaining bytes this buffer has to offer for this char
|
|
|
var available = (buffer.length >= this.charLength - this.charReceived) ?
|
|
|
this.charLength - this.charReceived :
|
|
|
buffer.length;
|
|
|
|
|
|
// add the new bytes to the char buffer
|
|
|
buffer.copy(this.charBuffer, this.charReceived, 0, available);
|
|
|
this.charReceived += available;
|
|
|
|
|
|
if (this.charReceived < this.charLength) {
|
|
|
// still not enough chars in this buffer? wait for more ...
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
// remove bytes belonging to the current character from the buffer
|
|
|
buffer = buffer.slice(available, buffer.length);
|
|
|
|
|
|
// get the character that was split
|
|
|
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
|
|
|
|
|
// CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
|
|
|
var charCode = charStr.charCodeAt(charStr.length - 1);
|
|
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
|
this.charLength += this.surrogateSize;
|
|
|
charStr = '';
|
|
|
continue;
|
|
|
}
|
|
|
this.charReceived = this.charLength = 0;
|
|
|
|
|
|
// if there are no more bytes in this buffer, just emit our char
|
|
|
if (buffer.length === 0) {
|
|
|
return charStr;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// determine and set charLength / charReceived
|
|
|
this.detectIncompleteChar(buffer);
|
|
|
|
|
|
var end = buffer.length;
|
|
|
if (this.charLength) {
|
|
|
// buffer the incomplete character bytes we got
|
|
|
buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
|
|
|
end -= this.charReceived;
|
|
|
}
|
|
|
|
|
|
charStr += buffer.toString(this.encoding, 0, end);
|
|
|
|
|
|
var end = charStr.length - 1;
|
|
|
var charCode = charStr.charCodeAt(end);
|
|
|
// CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
|
|
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
|
var size = this.surrogateSize;
|
|
|
this.charLength += size;
|
|
|
this.charReceived += size;
|
|
|
this.charBuffer.copy(this.charBuffer, size, 0, size);
|
|
|
buffer.copy(this.charBuffer, 0, 0, size);
|
|
|
return charStr.substring(0, end);
|
|
|
}
|
|
|
|
|
|
// or just emit the charStr
|
|
|
return charStr;
|
|
|
};
|
|
|
|
|
|
// detectIncompleteChar determines if there is an incomplete UTF-8 character at
|
|
|
// the end of the given buffer. If so, it sets this.charLength to the byte
|
|
|
// length that character, and sets this.charReceived to the number of bytes
|
|
|
// that are available for this character.
|
|
|
StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
|
|
// determine how many bytes we have to check at the end of this buffer
|
|
|
var i = (buffer.length >= 3) ? 3 : buffer.length;
|
|
|
|
|
|
// Figure out if one of the last i bytes of our buffer announces an
|
|
|
// incomplete char.
|
|
|
for (; i > 0; i--) {
|
|
|
var c = buffer[buffer.length - i];
|
|
|
|
|
|
// See http://en.wikipedia.org/wiki/UTF-8#Description
|
|
|
|
|
|
// 110XXXXX
|
|
|
if (i == 1 && c >> 5 == 0x06) {
|
|
|
this.charLength = 2;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 1110XXXX
|
|
|
if (i <= 2 && c >> 4 == 0x0E) {
|
|
|
this.charLength = 3;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 11110XXX
|
|
|
if (i <= 3 && c >> 3 == 0x1E) {
|
|
|
this.charLength = 4;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
this.charReceived = i;
|
|
|
};
|
|
|
|
|
|
StringDecoder.prototype.end = function(buffer) {
|
|
|
var res = '';
|
|
|
if (buffer && buffer.length)
|
|
|
res = this.write(buffer);
|
|
|
|
|
|
if (this.charReceived) {
|
|
|
var cr = this.charReceived;
|
|
|
var buf = this.charBuffer;
|
|
|
var enc = this.encoding;
|
|
|
res += buf.slice(0, cr).toString(enc);
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
function passThroughWrite(buffer) {
|
|
|
return buffer.toString(this.encoding);
|
|
|
}
|
|
|
|
|
|
function utf16DetectIncompleteChar(buffer) {
|
|
|
this.charReceived = buffer.length % 2;
|
|
|
this.charLength = this.charReceived ? 2 : 0;
|
|
|
}
|
|
|
|
|
|
function base64DetectIncompleteChar(buffer) {
|
|
|
this.charReceived = buffer.length % 3;
|
|
|
this.charLength = this.charReceived ? 3 : 0;
|
|
|
}
|
|
|
|
|
|
},{"buffer":73}],73:[function(require,module,exports){
|
|
|
(function (global,Buffer){
|
|
|
/*!
|
|
|
* The buffer module from node.js, for the browser.
|
|
|
*
|
|
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
|
* @license MIT
|
|
|
*/
|
|
|
/* eslint-disable no-proto */
|
|
|
|
|
|
'use strict'
|
|
|
|
|
|
var base64 = require('base64-js')
|
|
|
var ieee754 = require('ieee754')
|
|
|
var isArray = require('isarray')
|
|
|
|
|
|
exports.Buffer = Buffer
|
|
|
exports.SlowBuffer = SlowBuffer
|
|
|
exports.INSPECT_MAX_BYTES = 50
|
|
|
|
|
|
/**
|
|
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
|
* === true Use Uint8Array implementation (fastest)
|
|
|
* === false Use Object implementation (most compatible, even IE6)
|
|
|
*
|
|
|
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
|
* Opera 11.6+, iOS 4.2+.
|
|
|
*
|
|
|
* Due to various browser bugs, sometimes the Object implementation will be used even
|
|
|
* when the browser supports typed arrays.
|
|
|
*
|
|
|
* Note:
|
|
|
*
|
|
|
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
|
|
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
|
|
*
|
|
|
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
|
|
*
|
|
|
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
|
|
* incorrect length in some situations.
|
|
|
|
|
|
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
|
|
* get the Object implementation, which is slower but behaves correctly.
|
|
|
*/
|
|
|
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
|
|
? global.TYPED_ARRAY_SUPPORT
|
|
|
: typedArraySupport()
|
|
|
|
|
|
/*
|
|
|
* Export kMaxLength after typed array support is determined.
|
|
|
*/
|
|
|
exports.kMaxLength = kMaxLength()
|
|
|
|
|
|
function typedArraySupport () {
|
|
|
try {
|
|
|
var arr = new Uint8Array(1)
|
|
|
arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
|
|
|
return arr.foo() === 42 && // typed array instances can be augmented
|
|
|
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
|
|
|
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
|
|
|
} catch (e) {
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function kMaxLength () {
|
|
|
return Buffer.TYPED_ARRAY_SUPPORT
|
|
|
? 0x7fffffff
|
|
|
: 0x3fffffff
|
|
|
}
|
|
|
|
|
|
function createBuffer (that, length) {
|
|
|
if (kMaxLength() < length) {
|
|
|
throw new RangeError('Invalid typed array length')
|
|
|
}
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
// Return an augmented `Uint8Array` instance, for best performance
|
|
|
that = new Uint8Array(length)
|
|
|
that.__proto__ = Buffer.prototype
|
|
|
} else {
|
|
|
// Fallback: Return an object instance of the Buffer class
|
|
|
if (that === null) {
|
|
|
that = new Buffer(length)
|
|
|
}
|
|
|
that.length = length
|
|
|
}
|
|
|
|
|
|
return that
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
|
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
|
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
|
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
|
* returns a single octet.
|
|
|
*
|
|
|
* The `Uint8Array` prototype remains unmodified.
|
|
|
*/
|
|
|
|
|
|
function Buffer (arg, encodingOrOffset, length) {
|
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
|
|
|
return new Buffer(arg, encodingOrOffset, length)
|
|
|
}
|
|
|
|
|
|
// Common case.
|
|
|
if (typeof arg === 'number') {
|
|
|
if (typeof encodingOrOffset === 'string') {
|
|
|
throw new Error(
|
|
|
'If encoding is specified then the first argument must be a string'
|
|
|
)
|
|
|
}
|
|
|
return allocUnsafe(this, arg)
|
|
|
}
|
|
|
return from(this, arg, encodingOrOffset, length)
|
|
|
}
|
|
|
|
|
|
Buffer.poolSize = 8192 // not used by this implementation
|
|
|
|
|
|
// TODO: Legacy, not needed anymore. Remove in next major version.
|
|
|
Buffer._augment = function (arr) {
|
|
|
arr.__proto__ = Buffer.prototype
|
|
|
return arr
|
|
|
}
|
|
|
|
|
|
function from (that, value, encodingOrOffset, length) {
|
|
|
if (typeof value === 'number') {
|
|
|
throw new TypeError('"value" argument must not be a number')
|
|
|
}
|
|
|
|
|
|
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
|
|
|
return fromArrayBuffer(that, value, encodingOrOffset, length)
|
|
|
}
|
|
|
|
|
|
if (typeof value === 'string') {
|
|
|
return fromString(that, value, encodingOrOffset)
|
|
|
}
|
|
|
|
|
|
return fromObject(that, value)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
|
* if value is a number.
|
|
|
* Buffer.from(str[, encoding])
|
|
|
* Buffer.from(array)
|
|
|
* Buffer.from(buffer)
|
|
|
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
|
**/
|
|
|
Buffer.from = function (value, encodingOrOffset, length) {
|
|
|
return from(null, value, encodingOrOffset, length)
|
|
|
}
|
|
|
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
Buffer.prototype.__proto__ = Uint8Array.prototype
|
|
|
Buffer.__proto__ = Uint8Array
|
|
|
if (typeof Symbol !== 'undefined' && Symbol.species &&
|
|
|
Buffer[Symbol.species] === Buffer) {
|
|
|
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
|
|
Object.defineProperty(Buffer, Symbol.species, {
|
|
|
value: null,
|
|
|
configurable: true
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function assertSize (size) {
|
|
|
if (typeof size !== 'number') {
|
|
|
throw new TypeError('"size" argument must be a number')
|
|
|
} else if (size < 0) {
|
|
|
throw new RangeError('"size" argument must not be negative')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function alloc (that, size, fill, encoding) {
|
|
|
assertSize(size)
|
|
|
if (size <= 0) {
|
|
|
return createBuffer(that, size)
|
|
|
}
|
|
|
if (fill !== undefined) {
|
|
|
// Only pay attention to encoding if it's a string. This
|
|
|
// prevents accidentally sending in a number that would
|
|
|
// be interpretted as a start offset.
|
|
|
return typeof encoding === 'string'
|
|
|
? createBuffer(that, size).fill(fill, encoding)
|
|
|
: createBuffer(that, size).fill(fill)
|
|
|
}
|
|
|
return createBuffer(that, size)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Creates a new filled Buffer instance.
|
|
|
* alloc(size[, fill[, encoding]])
|
|
|
**/
|
|
|
Buffer.alloc = function (size, fill, encoding) {
|
|
|
return alloc(null, size, fill, encoding)
|
|
|
}
|
|
|
|
|
|
function allocUnsafe (that, size) {
|
|
|
assertSize(size)
|
|
|
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
|
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
for (var i = 0; i < size; ++i) {
|
|
|
that[i] = 0
|
|
|
}
|
|
|
}
|
|
|
return that
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
|
* */
|
|
|
Buffer.allocUnsafe = function (size) {
|
|
|
return allocUnsafe(null, size)
|
|
|
}
|
|
|
/**
|
|
|
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
|
*/
|
|
|
Buffer.allocUnsafeSlow = function (size) {
|
|
|
return allocUnsafe(null, size)
|
|
|
}
|
|
|
|
|
|
function fromString (that, string, encoding) {
|
|
|
if (typeof encoding !== 'string' || encoding === '') {
|
|
|
encoding = 'utf8'
|
|
|
}
|
|
|
|
|
|
if (!Buffer.isEncoding(encoding)) {
|
|
|
throw new TypeError('"encoding" must be a valid string encoding')
|
|
|
}
|
|
|
|
|
|
var length = byteLength(string, encoding) | 0
|
|
|
that = createBuffer(that, length)
|
|
|
|
|
|
var actual = that.write(string, encoding)
|
|
|
|
|
|
if (actual !== length) {
|
|
|
// Writing a hex string, for example, that contains invalid characters will
|
|
|
// cause everything after the first invalid character to be ignored. (e.g.
|
|
|
// 'abxxcd' will be treated as 'ab')
|
|
|
that = that.slice(0, actual)
|
|
|
}
|
|
|
|
|
|
return that
|
|
|
}
|
|
|
|
|
|
function fromArrayLike (that, array) {
|
|
|
var length = array.length < 0 ? 0 : checked(array.length) | 0
|
|
|
that = createBuffer(that, length)
|
|
|
for (var i = 0; i < length; i += 1) {
|
|
|
that[i] = array[i] & 255
|
|
|
}
|
|
|
return that
|
|
|
}
|
|
|
|
|
|
function fromArrayBuffer (that, array, byteOffset, length) {
|
|
|
array.byteLength // this throws if `array` is not a valid ArrayBuffer
|
|
|
|
|
|
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
|
throw new RangeError('\'offset\' is out of bounds')
|
|
|
}
|
|
|
|
|
|
if (array.byteLength < byteOffset + (length || 0)) {
|
|
|
throw new RangeError('\'length\' is out of bounds')
|
|
|
}
|
|
|
|
|
|
if (byteOffset === undefined && length === undefined) {
|
|
|
array = new Uint8Array(array)
|
|
|
} else if (length === undefined) {
|
|
|
array = new Uint8Array(array, byteOffset)
|
|
|
} else {
|
|
|
array = new Uint8Array(array, byteOffset, length)
|
|
|
}
|
|
|
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
// Return an augmented `Uint8Array` instance, for best performance
|
|
|
that = array
|
|
|
that.__proto__ = Buffer.prototype
|
|
|
} else {
|
|
|
// Fallback: Return an object instance of the Buffer class
|
|
|
that = fromArrayLike(that, array)
|
|
|
}
|
|
|
return that
|
|
|
}
|
|
|
|
|
|
function fromObject (that, obj) {
|
|
|
if (Buffer.isBuffer(obj)) {
|
|
|
var len = checked(obj.length) | 0
|
|
|
that = createBuffer(that, len)
|
|
|
|
|
|
if (that.length === 0) {
|
|
|
return that
|
|
|
}
|
|
|
|
|
|
obj.copy(that, 0, 0, len)
|
|
|
return that
|
|
|
}
|
|
|
|
|
|
if (obj) {
|
|
|
if ((typeof ArrayBuffer !== 'undefined' &&
|
|
|
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
|
|
|
if (typeof obj.length !== 'number' || isnan(obj.length)) {
|
|
|
return createBuffer(that, 0)
|
|
|
}
|
|
|
return fromArrayLike(that, obj)
|
|
|
}
|
|
|
|
|
|
if (obj.type === 'Buffer' && isArray(obj.data)) {
|
|
|
return fromArrayLike(that, obj.data)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
|
|
|
}
|
|
|
|
|
|
function checked (length) {
|
|
|
// Note: cannot use `length < kMaxLength()` here because that fails when
|
|
|
// length is NaN (which is otherwise coerced to zero.)
|
|
|
if (length >= kMaxLength()) {
|
|
|
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
|
'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
|
|
}
|
|
|
return length | 0
|
|
|
}
|
|
|
|
|
|
function SlowBuffer (length) {
|
|
|
if (+length != length) { // eslint-disable-line eqeqeq
|
|
|
length = 0
|
|
|
}
|
|
|
return Buffer.alloc(+length)
|
|
|
}
|
|
|
|
|
|
Buffer.isBuffer = function isBuffer (b) {
|
|
|
return !!(b != null && b._isBuffer)
|
|
|
}
|
|
|
|
|
|
Buffer.compare = function compare (a, b) {
|
|
|
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
|
throw new TypeError('Arguments must be Buffers')
|
|
|
}
|
|
|
|
|
|
if (a === b) return 0
|
|
|
|
|
|
var x = a.length
|
|
|
var y = b.length
|
|
|
|
|
|
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
|
if (a[i] !== b[i]) {
|
|
|
x = a[i]
|
|
|
y = b[i]
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (x < y) return -1
|
|
|
if (y < x) return 1
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
Buffer.isEncoding = function isEncoding (encoding) {
|
|
|
switch (String(encoding).toLowerCase()) {
|
|
|
case 'hex':
|
|
|
case 'utf8':
|
|
|
case 'utf-8':
|
|
|
case 'ascii':
|
|
|
case 'latin1':
|
|
|
case 'binary':
|
|
|
case 'base64':
|
|
|
case 'ucs2':
|
|
|
case 'ucs-2':
|
|
|
case 'utf16le':
|
|
|
case 'utf-16le':
|
|
|
return true
|
|
|
default:
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Buffer.concat = function concat (list, length) {
|
|
|
if (!isArray(list)) {
|
|
|
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
|
}
|
|
|
|
|
|
if (list.length === 0) {
|
|
|
return Buffer.alloc(0)
|
|
|
}
|
|
|
|
|
|
var i
|
|
|
if (length === undefined) {
|
|
|
length = 0
|
|
|
for (i = 0; i < list.length; ++i) {
|
|
|
length += list[i].length
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var buffer = Buffer.allocUnsafe(length)
|
|
|
var pos = 0
|
|
|
for (i = 0; i < list.length; ++i) {
|
|
|
var buf = list[i]
|
|
|
if (!Buffer.isBuffer(buf)) {
|
|
|
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
|
}
|
|
|
buf.copy(buffer, pos)
|
|
|
pos += buf.length
|
|
|
}
|
|
|
return buffer
|
|
|
}
|
|
|
|
|
|
function byteLength (string, encoding) {
|
|
|
if (Buffer.isBuffer(string)) {
|
|
|
return string.length
|
|
|
}
|
|
|
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
|
|
|
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
|
|
|
return string.byteLength
|
|
|
}
|
|
|
if (typeof string !== 'string') {
|
|
|
string = '' + string
|
|
|
}
|
|
|
|
|
|
var len = string.length
|
|
|
if (len === 0) return 0
|
|
|
|
|
|
// Use a for loop to avoid recursion
|
|
|
var loweredCase = false
|
|
|
for (;;) {
|
|
|
switch (encoding) {
|
|
|
case 'ascii':
|
|
|
case 'latin1':
|
|
|
case 'binary':
|
|
|
return len
|
|
|
case 'utf8':
|
|
|
case 'utf-8':
|
|
|
case undefined:
|
|
|
return utf8ToBytes(string).length
|
|
|
case 'ucs2':
|
|
|
case 'ucs-2':
|
|
|
case 'utf16le':
|
|
|
case 'utf-16le':
|
|
|
return len * 2
|
|
|
case 'hex':
|
|
|
return len >>> 1
|
|
|
case 'base64':
|
|
|
return base64ToBytes(string).length
|
|
|
default:
|
|
|
if (loweredCase) return utf8ToBytes(string).length // assume utf8
|
|
|
encoding = ('' + encoding).toLowerCase()
|
|
|
loweredCase = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
Buffer.byteLength = byteLength
|
|
|
|
|
|
function slowToString (encoding, start, end) {
|
|
|
var loweredCase = false
|
|
|
|
|
|
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
|
// property of a typed array.
|
|
|
|
|
|
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
|
// to their upper/lower bounds if the value passed is out of range.
|
|
|
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
|
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
|
if (start === undefined || start < 0) {
|
|
|
start = 0
|
|
|
}
|
|
|
// Return early if start > this.length. Done here to prevent potential uint32
|
|
|
// coercion fail below.
|
|
|
if (start > this.length) {
|
|
|
return ''
|
|
|
}
|
|
|
|
|
|
if (end === undefined || end > this.length) {
|
|
|
end = this.length
|
|
|
}
|
|
|
|
|
|
if (end <= 0) {
|
|
|
return ''
|
|
|
}
|
|
|
|
|
|
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
|
|
|
end >>>= 0
|
|
|
start >>>= 0
|
|
|
|
|
|
if (end <= start) {
|
|
|
return ''
|
|
|
}
|
|
|
|
|
|
if (!encoding) encoding = 'utf8'
|
|
|
|
|
|
while (true) {
|
|
|
switch (encoding) {
|
|
|
case 'hex':
|
|
|
return hexSlice(this, start, end)
|
|
|
|
|
|
case 'utf8':
|
|
|
case 'utf-8':
|
|
|
return utf8Slice(this, start, end)
|
|
|
|
|
|
case 'ascii':
|
|
|
return asciiSlice(this, start, end)
|
|
|
|
|
|
case 'latin1':
|
|
|
case 'binary':
|
|
|
return latin1Slice(this, start, end)
|
|
|
|
|
|
case 'base64':
|
|
|
return base64Slice(this, start, end)
|
|
|
|
|
|
case 'ucs2':
|
|
|
case 'ucs-2':
|
|
|
case 'utf16le':
|
|
|
case 'utf-16le':
|
|
|
return utf16leSlice(this, start, end)
|
|
|
|
|
|
default:
|
|
|
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
|
encoding = (encoding + '').toLowerCase()
|
|
|
loweredCase = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
|
|
|
// Buffer instances.
|
|
|
Buffer.prototype._isBuffer = true
|
|
|
|
|
|
function swap (b, n, m) {
|
|
|
var i = b[n]
|
|
|
b[n] = b[m]
|
|
|
b[m] = i
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.swap16 = function swap16 () {
|
|
|
var len = this.length
|
|
|
if (len % 2 !== 0) {
|
|
|
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
|
}
|
|
|
for (var i = 0; i < len; i += 2) {
|
|
|
swap(this, i, i + 1)
|
|
|
}
|
|
|
return this
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.swap32 = function swap32 () {
|
|
|
var len = this.length
|
|
|
if (len % 4 !== 0) {
|
|
|
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
|
}
|
|
|
for (var i = 0; i < len; i += 4) {
|
|
|
swap(this, i, i + 3)
|
|
|
swap(this, i + 1, i + 2)
|
|
|
}
|
|
|
return this
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.swap64 = function swap64 () {
|
|
|
var len = this.length
|
|
|
if (len % 8 !== 0) {
|
|
|
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
|
}
|
|
|
for (var i = 0; i < len; i += 8) {
|
|
|
swap(this, i, i + 7)
|
|
|
swap(this, i + 1, i + 6)
|
|
|
swap(this, i + 2, i + 5)
|
|
|
swap(this, i + 3, i + 4)
|
|
|
}
|
|
|
return this
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.toString = function toString () {
|
|
|
var length = this.length | 0
|
|
|
if (length === 0) return ''
|
|
|
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
|
return slowToString.apply(this, arguments)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.equals = function equals (b) {
|
|
|
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
|
if (this === b) return true
|
|
|
return Buffer.compare(this, b) === 0
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.inspect = function inspect () {
|
|
|
var str = ''
|
|
|
var max = exports.INSPECT_MAX_BYTES
|
|
|
if (this.length > 0) {
|
|
|
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
|
|
if (this.length > max) str += ' ... '
|
|
|
}
|
|
|
return '<Buffer ' + str + '>'
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
|
if (!Buffer.isBuffer(target)) {
|
|
|
throw new TypeError('Argument must be a Buffer')
|
|
|
}
|
|
|
|
|
|
if (start === undefined) {
|
|
|
start = 0
|
|
|
}
|
|
|
if (end === undefined) {
|
|
|
end = target ? target.length : 0
|
|
|
}
|
|
|
if (thisStart === undefined) {
|
|
|
thisStart = 0
|
|
|
}
|
|
|
if (thisEnd === undefined) {
|
|
|
thisEnd = this.length
|
|
|
}
|
|
|
|
|
|
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
|
throw new RangeError('out of range index')
|
|
|
}
|
|
|
|
|
|
if (thisStart >= thisEnd && start >= end) {
|
|
|
return 0
|
|
|
}
|
|
|
if (thisStart >= thisEnd) {
|
|
|
return -1
|
|
|
}
|
|
|
if (start >= end) {
|
|
|
return 1
|
|
|
}
|
|
|
|
|
|
start >>>= 0
|
|
|
end >>>= 0
|
|
|
thisStart >>>= 0
|
|
|
thisEnd >>>= 0
|
|
|
|
|
|
if (this === target) return 0
|
|
|
|
|
|
var x = thisEnd - thisStart
|
|
|
var y = end - start
|
|
|
var len = Math.min(x, y)
|
|
|
|
|
|
var thisCopy = this.slice(thisStart, thisEnd)
|
|
|
var targetCopy = target.slice(start, end)
|
|
|
|
|
|
for (var i = 0; i < len; ++i) {
|
|
|
if (thisCopy[i] !== targetCopy[i]) {
|
|
|
x = thisCopy[i]
|
|
|
y = targetCopy[i]
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (x < y) return -1
|
|
|
if (y < x) return 1
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
|
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
|
//
|
|
|
// Arguments:
|
|
|
// - buffer - a Buffer to search
|
|
|
// - val - a string, Buffer, or number
|
|
|
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
|
// - encoding - an optional encoding, relevant is val is a string
|
|
|
// - dir - true for indexOf, false for lastIndexOf
|
|
|
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
|
// Empty buffer means no match
|
|
|
if (buffer.length === 0) return -1
|
|
|
|
|
|
// Normalize byteOffset
|
|
|
if (typeof byteOffset === 'string') {
|
|
|
encoding = byteOffset
|
|
|
byteOffset = 0
|
|
|
} else if (byteOffset > 0x7fffffff) {
|
|
|
byteOffset = 0x7fffffff
|
|
|
} else if (byteOffset < -0x80000000) {
|
|
|
byteOffset = -0x80000000
|
|
|
}
|
|
|
byteOffset = +byteOffset // Coerce to Number.
|
|
|
if (isNaN(byteOffset)) {
|
|
|
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
|
byteOffset = dir ? 0 : (buffer.length - 1)
|
|
|
}
|
|
|
|
|
|
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
|
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
|
|
|
if (byteOffset >= buffer.length) {
|
|
|
if (dir) return -1
|
|
|
else byteOffset = buffer.length - 1
|
|
|
} else if (byteOffset < 0) {
|
|
|
if (dir) byteOffset = 0
|
|
|
else return -1
|
|
|
}
|
|
|
|
|
|
// Normalize val
|
|
|
if (typeof val === 'string') {
|
|
|
val = Buffer.from(val, encoding)
|
|
|
}
|
|
|
|
|
|
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
|
if (Buffer.isBuffer(val)) {
|
|
|
// Special case: looking for empty string/buffer always fails
|
|
|
if (val.length === 0) {
|
|
|
return -1
|
|
|
}
|
|
|
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
|
} else if (typeof val === 'number') {
|
|
|
val = val & 0xFF // Search for a byte value [0-255]
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT &&
|
|
|
typeof Uint8Array.prototype.indexOf === 'function') {
|
|
|
if (dir) {
|
|
|
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
|
} else {
|
|
|
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
|
}
|
|
|
}
|
|
|
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
|
|
}
|
|
|
|
|
|
throw new TypeError('val must be string, number or Buffer')
|
|
|
}
|
|
|
|
|
|
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
|
var indexSize = 1
|
|
|
var arrLength = arr.length
|
|
|
var valLength = val.length
|
|
|
|
|
|
if (encoding !== undefined) {
|
|
|
encoding = String(encoding).toLowerCase()
|
|
|
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
|
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
|
if (arr.length < 2 || val.length < 2) {
|
|
|
return -1
|
|
|
}
|
|
|
indexSize = 2
|
|
|
arrLength /= 2
|
|
|
valLength /= 2
|
|
|
byteOffset /= 2
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function read (buf, i) {
|
|
|
if (indexSize === 1) {
|
|
|
return buf[i]
|
|
|
} else {
|
|
|
return buf.readUInt16BE(i * indexSize)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var i
|
|
|
if (dir) {
|
|
|
var foundIndex = -1
|
|
|
for (i = byteOffset; i < arrLength; i++) {
|
|
|
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
|
if (foundIndex === -1) foundIndex = i
|
|
|
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
|
} else {
|
|
|
if (foundIndex !== -1) i -= i - foundIndex
|
|
|
foundIndex = -1
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
|
|
for (i = byteOffset; i >= 0; i--) {
|
|
|
var found = true
|
|
|
for (var j = 0; j < valLength; j++) {
|
|
|
if (read(arr, i + j) !== read(val, j)) {
|
|
|
found = false
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
if (found) return i
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return -1
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
|
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
|
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
|
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
|
}
|
|
|
|
|
|
function hexWrite (buf, string, offset, length) {
|
|
|
offset = Number(offset) || 0
|
|
|
var remaining = buf.length - offset
|
|
|
if (!length) {
|
|
|
length = remaining
|
|
|
} else {
|
|
|
length = Number(length)
|
|
|
if (length > remaining) {
|
|
|
length = remaining
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// must be an even number of digits
|
|
|
var strLen = string.length
|
|
|
if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
|
|
|
|
|
|
if (length > strLen / 2) {
|
|
|
length = strLen / 2
|
|
|
}
|
|
|
for (var i = 0; i < length; ++i) {
|
|
|
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
|
|
if (isNaN(parsed)) return i
|
|
|
buf[offset + i] = parsed
|
|
|
}
|
|
|
return i
|
|
|
}
|
|
|
|
|
|
function utf8Write (buf, string, offset, length) {
|
|
|
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
|
}
|
|
|
|
|
|
function asciiWrite (buf, string, offset, length) {
|
|
|
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
|
}
|
|
|
|
|
|
function latin1Write (buf, string, offset, length) {
|
|
|
return asciiWrite(buf, string, offset, length)
|
|
|
}
|
|
|
|
|
|
function base64Write (buf, string, offset, length) {
|
|
|
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
|
}
|
|
|
|
|
|
function ucs2Write (buf, string, offset, length) {
|
|
|
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
|
// Buffer#write(string)
|
|
|
if (offset === undefined) {
|
|
|
encoding = 'utf8'
|
|
|
length = this.length
|
|
|
offset = 0
|
|
|
// Buffer#write(string, encoding)
|
|
|
} else if (length === undefined && typeof offset === 'string') {
|
|
|
encoding = offset
|
|
|
length = this.length
|
|
|
offset = 0
|
|
|
// Buffer#write(string, offset[, length][, encoding])
|
|
|
} else if (isFinite(offset)) {
|
|
|
offset = offset | 0
|
|
|
if (isFinite(length)) {
|
|
|
length = length | 0
|
|
|
if (encoding === undefined) encoding = 'utf8'
|
|
|
} else {
|
|
|
encoding = length
|
|
|
length = undefined
|
|
|
}
|
|
|
// legacy write(string, encoding, offset, length) - remove in v0.13
|
|
|
} else {
|
|
|
throw new Error(
|
|
|
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
|
)
|
|
|
}
|
|
|
|
|
|
var remaining = this.length - offset
|
|
|
if (length === undefined || length > remaining) length = remaining
|
|
|
|
|
|
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
|
throw new RangeError('Attempt to write outside buffer bounds')
|
|
|
}
|
|
|
|
|
|
if (!encoding) encoding = 'utf8'
|
|
|
|
|
|
var loweredCase = false
|
|
|
for (;;) {
|
|
|
switch (encoding) {
|
|
|
case 'hex':
|
|
|
return hexWrite(this, string, offset, length)
|
|
|
|
|
|
case 'utf8':
|
|
|
case 'utf-8':
|
|
|
return utf8Write(this, string, offset, length)
|
|
|
|
|
|
case 'ascii':
|
|
|
return asciiWrite(this, string, offset, length)
|
|
|
|
|
|
case 'latin1':
|
|
|
case 'binary':
|
|
|
return latin1Write(this, string, offset, length)
|
|
|
|
|
|
case 'base64':
|
|
|
// Warning: maxLength not taken into account in base64Write
|
|
|
return base64Write(this, string, offset, length)
|
|
|
|
|
|
case 'ucs2':
|
|
|
case 'ucs-2':
|
|
|
case 'utf16le':
|
|
|
case 'utf-16le':
|
|
|
return ucs2Write(this, string, offset, length)
|
|
|
|
|
|
default:
|
|
|
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
|
encoding = ('' + encoding).toLowerCase()
|
|
|
loweredCase = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.toJSON = function toJSON () {
|
|
|
return {
|
|
|
type: 'Buffer',
|
|
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function base64Slice (buf, start, end) {
|
|
|
if (start === 0 && end === buf.length) {
|
|
|
return base64.fromByteArray(buf)
|
|
|
} else {
|
|
|
return base64.fromByteArray(buf.slice(start, end))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function utf8Slice (buf, start, end) {
|
|
|
end = Math.min(buf.length, end)
|
|
|
var res = []
|
|
|
|
|
|
var i = start
|
|
|
while (i < end) {
|
|
|
var firstByte = buf[i]
|
|
|
var codePoint = null
|
|
|
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
|
|
: (firstByte > 0xDF) ? 3
|
|
|
: (firstByte > 0xBF) ? 2
|
|
|
: 1
|
|
|
|
|
|
if (i + bytesPerSequence <= end) {
|
|
|
var secondByte, thirdByte, fourthByte, tempCodePoint
|
|
|
|
|
|
switch (bytesPerSequence) {
|
|
|
case 1:
|
|
|
if (firstByte < 0x80) {
|
|
|
codePoint = firstByte
|
|
|
}
|
|
|
break
|
|
|
case 2:
|
|
|
secondByte = buf[i + 1]
|
|
|
if ((secondByte & 0xC0) === 0x80) {
|
|
|
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
|
|
if (tempCodePoint > 0x7F) {
|
|
|
codePoint = tempCodePoint
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
case 3:
|
|
|
secondByte = buf[i + 1]
|
|
|
thirdByte = buf[i + 2]
|
|
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
|
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
|
|
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
|
codePoint = tempCodePoint
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
case 4:
|
|
|
secondByte = buf[i + 1]
|
|
|
thirdByte = buf[i + 2]
|
|
|
fourthByte = buf[i + 3]
|
|
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
|
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
|
|
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
|
codePoint = tempCodePoint
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (codePoint === null) {
|
|
|
// we did not generate a valid codePoint so insert a
|
|
|
// replacement char (U+FFFD) and advance only 1 byte
|
|
|
codePoint = 0xFFFD
|
|
|
bytesPerSequence = 1
|
|
|
} else if (codePoint > 0xFFFF) {
|
|
|
// encode to utf16 (surrogate pair dance)
|
|
|
codePoint -= 0x10000
|
|
|
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
|
|
codePoint = 0xDC00 | codePoint & 0x3FF
|
|
|
}
|
|
|
|
|
|
res.push(codePoint)
|
|
|
i += bytesPerSequence
|
|
|
}
|
|
|
|
|
|
return decodeCodePointsArray(res)
|
|
|
}
|
|
|
|
|
|
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
|
// the lowest limit is Chrome, with 0x10000 args.
|
|
|
// We go 1 magnitude less, for safety
|
|
|
var MAX_ARGUMENTS_LENGTH = 0x1000
|
|
|
|
|
|
function decodeCodePointsArray (codePoints) {
|
|
|
var len = codePoints.length
|
|
|
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
|
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
|
}
|
|
|
|
|
|
// Decode in chunks to avoid "call stack size exceeded".
|
|
|
var res = ''
|
|
|
var i = 0
|
|
|
while (i < len) {
|
|
|
res += String.fromCharCode.apply(
|
|
|
String,
|
|
|
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
|
)
|
|
|
}
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
function asciiSlice (buf, start, end) {
|
|
|
var ret = ''
|
|
|
end = Math.min(buf.length, end)
|
|
|
|
|
|
for (var i = start; i < end; ++i) {
|
|
|
ret += String.fromCharCode(buf[i] & 0x7F)
|
|
|
}
|
|
|
return ret
|
|
|
}
|
|
|
|
|
|
function latin1Slice (buf, start, end) {
|
|
|
var ret = ''
|
|
|
end = Math.min(buf.length, end)
|
|
|
|
|
|
for (var i = start; i < end; ++i) {
|
|
|
ret += String.fromCharCode(buf[i])
|
|
|
}
|
|
|
return ret
|
|
|
}
|
|
|
|
|
|
function hexSlice (buf, start, end) {
|
|
|
var len = buf.length
|
|
|
|
|
|
if (!start || start < 0) start = 0
|
|
|
if (!end || end < 0 || end > len) end = len
|
|
|
|
|
|
var out = ''
|
|
|
for (var i = start; i < end; ++i) {
|
|
|
out += toHex(buf[i])
|
|
|
}
|
|
|
return out
|
|
|
}
|
|
|
|
|
|
function utf16leSlice (buf, start, end) {
|
|
|
var bytes = buf.slice(start, end)
|
|
|
var res = ''
|
|
|
for (var i = 0; i < bytes.length; i += 2) {
|
|
|
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
|
|
}
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.slice = function slice (start, end) {
|
|
|
var len = this.length
|
|
|
start = ~~start
|
|
|
end = end === undefined ? len : ~~end
|
|
|
|
|
|
if (start < 0) {
|
|
|
start += len
|
|
|
if (start < 0) start = 0
|
|
|
} else if (start > len) {
|
|
|
start = len
|
|
|
}
|
|
|
|
|
|
if (end < 0) {
|
|
|
end += len
|
|
|
if (end < 0) end = 0
|
|
|
} else if (end > len) {
|
|
|
end = len
|
|
|
}
|
|
|
|
|
|
if (end < start) end = start
|
|
|
|
|
|
var newBuf
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
newBuf = this.subarray(start, end)
|
|
|
newBuf.__proto__ = Buffer.prototype
|
|
|
} else {
|
|
|
var sliceLen = end - start
|
|
|
newBuf = new Buffer(sliceLen, undefined)
|
|
|
for (var i = 0; i < sliceLen; ++i) {
|
|
|
newBuf[i] = this[i + start]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return newBuf
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
|
*/
|
|
|
function checkOffset (offset, ext, length) {
|
|
|
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
|
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
|
offset = offset | 0
|
|
|
byteLength = byteLength | 0
|
|
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
|
|
|
|
var val = this[offset]
|
|
|
var mul = 1
|
|
|
var i = 0
|
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
|
val += this[offset + i] * mul
|
|
|
}
|
|
|
|
|
|
return val
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
|
offset = offset | 0
|
|
|
byteLength = byteLength | 0
|
|
|
if (!noAssert) {
|
|
|
checkOffset(offset, byteLength, this.length)
|
|
|
}
|
|
|
|
|
|
var val = this[offset + --byteLength]
|
|
|
var mul = 1
|
|
|
while (byteLength > 0 && (mul *= 0x100)) {
|
|
|
val += this[offset + --byteLength] * mul
|
|
|
}
|
|
|
|
|
|
return val
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
|
return this[offset]
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
|
return this[offset] | (this[offset + 1] << 8)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
|
return (this[offset] << 8) | this[offset + 1]
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
|
|
|
return ((this[offset]) |
|
|
|
(this[offset + 1] << 8) |
|
|
|
(this[offset + 2] << 16)) +
|
|
|
(this[offset + 3] * 0x1000000)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
|
|
|
return (this[offset] * 0x1000000) +
|
|
|
((this[offset + 1] << 16) |
|
|
|
(this[offset + 2] << 8) |
|
|
|
this[offset + 3])
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
|
offset = offset | 0
|
|
|
byteLength = byteLength | 0
|
|
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
|
|
|
|
var val = this[offset]
|
|
|
var mul = 1
|
|
|
var i = 0
|
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
|
val += this[offset + i] * mul
|
|
|
}
|
|
|
mul *= 0x80
|
|
|
|
|
|
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
|
|
|
|
return val
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
|
offset = offset | 0
|
|
|
byteLength = byteLength | 0
|
|
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
|
|
|
|
var i = byteLength
|
|
|
var mul = 1
|
|
|
var val = this[offset + --i]
|
|
|
while (i > 0 && (mul *= 0x100)) {
|
|
|
val += this[offset + --i] * mul
|
|
|
}
|
|
|
mul *= 0x80
|
|
|
|
|
|
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
|
|
|
|
return val
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
|
if (!(this[offset] & 0x80)) return (this[offset])
|
|
|
return ((0xff - this[offset] + 1) * -1)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
|
var val = this[offset] | (this[offset + 1] << 8)
|
|
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
|
var val = this[offset + 1] | (this[offset] << 8)
|
|
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
|
|
|
return (this[offset]) |
|
|
|
(this[offset + 1] << 8) |
|
|
|
(this[offset + 2] << 16) |
|
|
|
(this[offset + 3] << 24)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
|
|
|
return (this[offset] << 24) |
|
|
|
(this[offset + 1] << 16) |
|
|
|
(this[offset + 2] << 8) |
|
|
|
(this[offset + 3])
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
return ieee754.read(this, offset, true, 23, 4)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
|
return ieee754.read(this, offset, false, 23, 4)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
|
return ieee754.read(this, offset, true, 52, 8)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
|
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
|
return ieee754.read(this, offset, false, 52, 8)
|
|
|
}
|
|
|
|
|
|
function checkInt (buf, value, offset, ext, max, min) {
|
|
|
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
|
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
byteLength = byteLength | 0
|
|
|
if (!noAssert) {
|
|
|
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
|
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
|
|
}
|
|
|
|
|
|
var mul = 1
|
|
|
var i = 0
|
|
|
this[offset] = value & 0xFF
|
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
|
this[offset + i] = (value / mul) & 0xFF
|
|
|
}
|
|
|
|
|
|
return offset + byteLength
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
byteLength = byteLength | 0
|
|
|
if (!noAssert) {
|
|
|
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
|
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
|
|
}
|
|
|
|
|
|
var i = byteLength - 1
|
|
|
var mul = 1
|
|
|
this[offset + i] = value & 0xFF
|
|
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
|
this[offset + i] = (value / mul) & 0xFF
|
|
|
}
|
|
|
|
|
|
return offset + byteLength
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
|
|
this[offset] = (value & 0xff)
|
|
|
return offset + 1
|
|
|
}
|
|
|
|
|
|
function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
|
|
if (value < 0) value = 0xffff + value + 1
|
|
|
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
|
|
|
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
|
|
(littleEndian ? i : 1 - i) * 8
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
this[offset] = (value & 0xff)
|
|
|
this[offset + 1] = (value >>> 8)
|
|
|
} else {
|
|
|
objectWriteUInt16(this, value, offset, true)
|
|
|
}
|
|
|
return offset + 2
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
this[offset] = (value >>> 8)
|
|
|
this[offset + 1] = (value & 0xff)
|
|
|
} else {
|
|
|
objectWriteUInt16(this, value, offset, false)
|
|
|
}
|
|
|
return offset + 2
|
|
|
}
|
|
|
|
|
|
function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
|
|
if (value < 0) value = 0xffffffff + value + 1
|
|
|
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
|
|
|
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
this[offset + 3] = (value >>> 24)
|
|
|
this[offset + 2] = (value >>> 16)
|
|
|
this[offset + 1] = (value >>> 8)
|
|
|
this[offset] = (value & 0xff)
|
|
|
} else {
|
|
|
objectWriteUInt32(this, value, offset, true)
|
|
|
}
|
|
|
return offset + 4
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
this[offset] = (value >>> 24)
|
|
|
this[offset + 1] = (value >>> 16)
|
|
|
this[offset + 2] = (value >>> 8)
|
|
|
this[offset + 3] = (value & 0xff)
|
|
|
} else {
|
|
|
objectWriteUInt32(this, value, offset, false)
|
|
|
}
|
|
|
return offset + 4
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) {
|
|
|
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
|
|
|
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
|
}
|
|
|
|
|
|
var i = 0
|
|
|
var mul = 1
|
|
|
var sub = 0
|
|
|
this[offset] = value & 0xFF
|
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
|
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
|
sub = 1
|
|
|
}
|
|
|
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
|
}
|
|
|
|
|
|
return offset + byteLength
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) {
|
|
|
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
|
|
|
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
|
}
|
|
|
|
|
|
var i = byteLength - 1
|
|
|
var mul = 1
|
|
|
var sub = 0
|
|
|
this[offset + i] = value & 0xFF
|
|
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
|
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
|
sub = 1
|
|
|
}
|
|
|
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
|
}
|
|
|
|
|
|
return offset + byteLength
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
|
|
if (value < 0) value = 0xff + value + 1
|
|
|
this[offset] = (value & 0xff)
|
|
|
return offset + 1
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
this[offset] = (value & 0xff)
|
|
|
this[offset + 1] = (value >>> 8)
|
|
|
} else {
|
|
|
objectWriteUInt16(this, value, offset, true)
|
|
|
}
|
|
|
return offset + 2
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
this[offset] = (value >>> 8)
|
|
|
this[offset + 1] = (value & 0xff)
|
|
|
} else {
|
|
|
objectWriteUInt16(this, value, offset, false)
|
|
|
}
|
|
|
return offset + 2
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
this[offset] = (value & 0xff)
|
|
|
this[offset + 1] = (value >>> 8)
|
|
|
this[offset + 2] = (value >>> 16)
|
|
|
this[offset + 3] = (value >>> 24)
|
|
|
} else {
|
|
|
objectWriteUInt32(this, value, offset, true)
|
|
|
}
|
|
|
return offset + 4
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
|
value = +value
|
|
|
offset = offset | 0
|
|
|
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
|
if (value < 0) value = 0xffffffff + value + 1
|
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
this[offset] = (value >>> 24)
|
|
|
this[offset + 1] = (value >>> 16)
|
|
|
this[offset + 2] = (value >>> 8)
|
|
|
this[offset + 3] = (value & 0xff)
|
|
|
} else {
|
|
|
objectWriteUInt32(this, value, offset, false)
|
|
|
}
|
|
|
return offset + 4
|
|
|
}
|
|
|
|
|
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
|
if (offset < 0) throw new RangeError('Index out of range')
|
|
|
}
|
|
|
|
|
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
|
if (!noAssert) {
|
|
|
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
|
}
|
|
|
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
|
return offset + 4
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
|
return writeFloat(this, value, offset, true, noAssert)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
|
return writeFloat(this, value, offset, false, noAssert)
|
|
|
}
|
|
|
|
|
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
|
if (!noAssert) {
|
|
|
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
|
}
|
|
|
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
|
return offset + 8
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
|
return writeDouble(this, value, offset, true, noAssert)
|
|
|
}
|
|
|
|
|
|
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
|
return writeDouble(this, value, offset, false, noAssert)
|
|
|
}
|
|
|
|
|
|
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
|
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
|
if (!start) start = 0
|
|
|
if (!end && end !== 0) end = this.length
|
|
|
if (targetStart >= target.length) targetStart = target.length
|
|
|
if (!targetStart) targetStart = 0
|
|
|
if (end > 0 && end < start) end = start
|
|
|
|
|
|
// Copy 0 bytes; we're done
|
|
|
if (end === start) return 0
|
|
|
if (target.length === 0 || this.length === 0) return 0
|
|
|
|
|
|
// Fatal error conditions
|
|
|
if (targetStart < 0) {
|
|
|
throw new RangeError('targetStart out of bounds')
|
|
|
}
|
|
|
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
|
|
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
|
|
|
|
// Are we oob?
|
|
|
if (end > this.length) end = this.length
|
|
|
if (target.length - targetStart < end - start) {
|
|
|
end = target.length - targetStart + start
|
|
|
}
|
|
|
|
|
|
var len = end - start
|
|
|
var i
|
|
|
|
|
|
if (this === target && start < targetStart && targetStart < end) {
|
|
|
// descending copy from end
|
|
|
for (i = len - 1; i >= 0; --i) {
|
|
|
target[i + targetStart] = this[i + start]
|
|
|
}
|
|
|
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
|
|
// ascending copy from start
|
|
|
for (i = 0; i < len; ++i) {
|
|
|
target[i + targetStart] = this[i + start]
|
|
|
}
|
|
|
} else {
|
|
|
Uint8Array.prototype.set.call(
|
|
|
target,
|
|
|
this.subarray(start, start + len),
|
|
|
targetStart
|
|
|
)
|
|
|
}
|
|
|
|
|
|
return len
|
|
|
}
|
|
|
|
|
|
// Usage:
|
|
|
// buffer.fill(number[, offset[, end]])
|
|
|
// buffer.fill(buffer[, offset[, end]])
|
|
|
// buffer.fill(string[, offset[, end]][, encoding])
|
|
|
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
|
// Handle string cases:
|
|
|
if (typeof val === 'string') {
|
|
|
if (typeof start === 'string') {
|
|
|
encoding = start
|
|
|
start = 0
|
|
|
end = this.length
|
|
|
} else if (typeof end === 'string') {
|
|
|
encoding = end
|
|
|
end = this.length
|
|
|
}
|
|
|
if (val.length === 1) {
|
|
|
var code = val.charCodeAt(0)
|
|
|
if (code < 256) {
|
|
|
val = code
|
|
|
}
|
|
|
}
|
|
|
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
|
throw new TypeError('encoding must be a string')
|
|
|
}
|
|
|
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
|
throw new TypeError('Unknown encoding: ' + encoding)
|
|
|
}
|
|
|
} else if (typeof val === 'number') {
|
|
|
val = val & 255
|
|
|
}
|
|
|
|
|
|
// Invalid ranges are not set to a default, so can range check early.
|
|
|
if (start < 0 || this.length < start || this.length < end) {
|
|
|
throw new RangeError('Out of range index')
|
|
|
}
|
|
|
|
|
|
if (end <= start) {
|
|
|
return this
|
|
|
}
|
|
|
|
|
|
start = start >>> 0
|
|
|
end = end === undefined ? this.length : end >>> 0
|
|
|
|
|
|
if (!val) val = 0
|
|
|
|
|
|
var i
|
|
|
if (typeof val === 'number') {
|
|
|
for (i = start; i < end; ++i) {
|
|
|
this[i] = val
|
|
|
}
|
|
|
} else {
|
|
|
var bytes = Buffer.isBuffer(val)
|
|
|
? val
|
|
|
: utf8ToBytes(new Buffer(val, encoding).toString())
|
|
|
var len = bytes.length
|
|
|
for (i = 0; i < end - start; ++i) {
|
|
|
this[i + start] = bytes[i % len]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return this
|
|
|
}
|
|
|
|
|
|
// HELPER FUNCTIONS
|
|
|
// ================
|
|
|
|
|
|
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
|
|
|
|
|
function base64clean (str) {
|
|
|
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
|
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
|
|
// Node converts strings with length < 2 to ''
|
|
|
if (str.length < 2) return ''
|
|
|
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
|
while (str.length % 4 !== 0) {
|
|
|
str = str + '='
|
|
|
}
|
|
|
return str
|
|
|
}
|
|
|
|
|
|
function stringtrim (str) {
|
|
|
if (str.trim) return str.trim()
|
|
|
return str.replace(/^\s+|\s+$/g, '')
|
|
|
}
|
|
|
|
|
|
function toHex (n) {
|
|
|
if (n < 16) return '0' + n.toString(16)
|
|
|
return n.toString(16)
|
|
|
}
|
|
|
|
|
|
function utf8ToBytes (string, units) {
|
|
|
units = units || Infinity
|
|
|
var codePoint
|
|
|
var length = string.length
|
|
|
var leadSurrogate = null
|
|
|
var bytes = []
|
|
|
|
|
|
for (var i = 0; i < length; ++i) {
|
|
|
codePoint = string.charCodeAt(i)
|
|
|
|
|
|
// is surrogate component
|
|
|
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
|
// last char was a lead
|
|
|
if (!leadSurrogate) {
|
|
|
// no lead yet
|
|
|
if (codePoint > 0xDBFF) {
|
|
|
// unexpected trail
|
|
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
|
continue
|
|
|
} else if (i + 1 === length) {
|
|
|
// unpaired lead
|
|
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
// valid lead
|
|
|
leadSurrogate = codePoint
|
|
|
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
// 2 leads in a row
|
|
|
if (codePoint < 0xDC00) {
|
|
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
|
leadSurrogate = codePoint
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
// valid surrogate pair
|
|
|
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
|
|
} else if (leadSurrogate) {
|
|
|
// valid bmp char, but last char was a lead
|
|
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
|
}
|
|
|
|
|
|
leadSurrogate = null
|
|
|
|
|
|
// encode utf8
|
|
|
if (codePoint < 0x80) {
|
|
|
if ((units -= 1) < 0) break
|
|
|
bytes.push(codePoint)
|
|
|
} else if (codePoint < 0x800) {
|
|
|
if ((units -= 2) < 0) break
|
|
|
bytes.push(
|
|
|
codePoint >> 0x6 | 0xC0,
|
|
|
codePoint & 0x3F | 0x80
|
|
|
)
|
|
|
} else if (codePoint < 0x10000) {
|
|
|
if ((units -= 3) < 0) break
|
|
|
bytes.push(
|
|
|
codePoint >> 0xC | 0xE0,
|
|
|
codePoint >> 0x6 & 0x3F | 0x80,
|
|
|
codePoint & 0x3F | 0x80
|
|
|
)
|
|
|
} else if (codePoint < 0x110000) {
|
|
|
if ((units -= 4) < 0) break
|
|
|
bytes.push(
|
|
|
codePoint >> 0x12 | 0xF0,
|
|
|
codePoint >> 0xC & 0x3F | 0x80,
|
|
|
codePoint >> 0x6 & 0x3F | 0x80,
|
|
|
codePoint & 0x3F | 0x80
|
|
|
)
|
|
|
} else {
|
|
|
throw new Error('Invalid code point')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return bytes
|
|
|
}
|
|
|
|
|
|
function asciiToBytes (str) {
|
|
|
var byteArray = []
|
|
|
for (var i = 0; i < str.length; ++i) {
|
|
|
// Node's code seems to be doing this and not & 0x7F..
|
|
|
byteArray.push(str.charCodeAt(i) & 0xFF)
|
|
|
}
|
|
|
return byteArray
|
|
|
}
|
|
|
|
|
|
function utf16leToBytes (str, units) {
|
|
|
var c, hi, lo
|
|
|
var byteArray = []
|
|
|
for (var i = 0; i < str.length; ++i) {
|
|
|
if ((units -= 2) < 0) break
|
|
|
|
|
|
c = str.charCodeAt(i)
|
|
|
hi = c >> 8
|
|
|
lo = c % 256
|
|
|
byteArray.push(lo)
|
|
|
byteArray.push(hi)
|
|
|
}
|
|
|
|
|
|
return byteArray
|
|
|
}
|
|
|
|
|
|
function base64ToBytes (str) {
|
|
|
return base64.toByteArray(base64clean(str))
|
|
|
}
|
|
|
|
|
|
function blitBuffer (src, dst, offset, length) {
|
|
|
for (var i = 0; i < length; ++i) {
|
|
|
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
|
dst[i + offset] = src[i]
|
|
|
}
|
|
|
return i
|
|
|
}
|
|
|
|
|
|
function isnan (val) {
|
|
|
return val !== val // eslint-disable-line no-self-compare
|
|
|
}
|
|
|
|
|
|
}).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
|
|
|
},{"base64-js":69,"buffer":73,"ieee754":195,"isarray":198}],74:[function(require,module,exports){
|
|
|
module.exports = {
|
|
|
"100": "Continue",
|
|
|
"101": "Switching Protocols",
|
|
|
"102": "Processing",
|
|
|
"200": "OK",
|
|
|
"201": "Created",
|
|
|
"202": "Accepted",
|
|
|
"203": "Non-Authoritative Information",
|
|
|
"204": "No Content",
|
|
|
"205": "Reset Content",
|
|
|
"206": "Partial Content",
|
|
|
"207": "Multi-Status",
|
|
|
"208": "Already Reported",
|
|
|
"226": "IM Used",
|
|
|
"300": "Multiple Choices",
|
|
|
"301": "Moved Permanently",
|
|
|
"302": "Found",
|
|
|
"303": "See Other",
|
|
|
"304": "Not Modified",
|
|
|
"305": "Use Proxy",
|
|
|
"307": "Temporary Redirect",
|
|
|
"308": "Permanent Redirect",
|
|
|
"400": "Bad Request",
|
|
|
"401": "Unauthorized",
|
|
|
"402": "Payment Required",
|
|
|
"403": "Forbidden",
|
|
|
"404": "Not Found",
|
|
|
"405": "Method Not Allowed",
|
|
|
"406": "Not Acceptable",
|
|
|
"407": "Proxy Authentication Required",
|
|
|
"408": "Request Timeout",
|
|
|
"409": "Conflict",
|
|
|
"410": "Gone",
|
|
|
"411": "Length Required",
|
|
|
"412": "Precondition Failed",
|
|
|
"413": "Payload Too Large",
|
|
|
"414": "URI Too Long",
|
|
|
"415": "Unsupported Media Type",
|
|
|
"416": "Range Not Satisfiable",
|
|
|
"417": "Expectation Failed",
|
|
|
"418": "I'm a teapot",
|
|
|
"421": "Misdirected Request",
|
|
|
"422": "Unprocessable Entity",
|
|
|
"423": "Locked",
|
|
|
"424": "Failed Dependency",
|
|
|
"425": "Unordered Collection",
|
|
|
"426": "Upgrade Required",
|
|
|
"428": "Precondition Required",
|
|
|
"429": "Too Many Requests",
|
|
|
"431": "Request Header Fields Too Large",
|
|
|
"451": "Unavailable For Legal Reasons",
|
|
|
"500": "Internal Server Error",
|
|
|
"501": "Not Implemented",
|
|
|
"502": "Bad Gateway",
|
|
|
"503": "Service Unavailable",
|
|
|
"504": "Gateway Timeout",
|
|
|
"505": "HTTP Version Not Supported",
|
|
|
"506": "Variant Also Negotiates",
|
|
|
"507": "Insufficient Storage",
|
|
|
"508": "Loop Detected",
|
|
|
"509": "Bandwidth Limit Exceeded",
|
|
|
"510": "Not Extended",
|
|
|
"511": "Network Authentication Required"
|
|
|
}
|
|
|
|
|
|
},{}],75:[function(require,module,exports){
|
|
|
module.exports={
|
|
|
"O_RDONLY": 0,
|
|
|
"O_WRONLY": 1,
|
|
|
"O_RDWR": 2,
|
|
|
"S_IFMT": 61440,
|
|
|
"S_IFREG": 32768,
|
|
|
"S_IFDIR": 16384,
|
|
|
"S_IFCHR": 8192,
|
|
|
"S_IFBLK": 24576,
|
|
|
"S_IFIFO": 4096,
|
|
|
"S_IFLNK": 40960,
|
|
|
"S_IFSOCK": 49152,
|
|
|
"O_CREAT": 512,
|
|
|
"O_EXCL": 2048,
|
|
|
"O_NOCTTY": 131072,
|
|
|
"O_TRUNC": 1024,
|
|
|
"O_APPEND": 8,
|
|
|
"O_DIRECTORY": 1048576,
|
|
|
"O_NOFOLLOW": 256,
|
|
|
"O_SYNC": 128,
|
|
|
"O_SYMLINK": 2097152,
|
|
|
"O_NONBLOCK": 4,
|
|
|
"S_IRWXU": 448,
|
|
|
"S_IRUSR": 256,
|
|
|
"S_IWUSR": 128,
|
|
|
"S_IXUSR": 64,
|
|
|
"S_IRWXG": 56,
|
|
|
"S_IRGRP": 32,
|
|
|
"S_IWGRP": 16,
|
|
|
"S_IXGRP": 8,
|
|
|
"S_IRWXO": 7,
|
|
|
"S_IROTH": 4,
|
|
|
"S_IWOTH": 2,
|
|
|
"S_IXOTH": 1,
|
|
|
"E2BIG": 7,
|
|
|
"EACCES": 13,
|
|
|
"EADDRINUSE": 48,
|
|
|
"EADDRNOTAVAIL": 49,
|
|
|
"EAFNOSUPPORT": 47,
|
|
|
"EAGAIN": 35,
|
|
|
"EALREADY": 37,
|
|
|
"EBADF": 9,
|
|
|
"EBADMSG": 94,
|
|
|
"EBUSY": 16,
|
|
|
"ECANCELED": 89,
|
|
|
"ECHILD": 10,
|
|
|
"ECONNABORTED": 53,
|
|
|
"ECONNREFUSED": 61,
|
|
|
"ECONNRESET": 54,
|
|
|
"EDEADLK": 11,
|
|
|
"EDESTADDRREQ": 39,
|
|
|
"EDOM": 33,
|
|
|
"EDQUOT": 69,
|
|
|
"EEXIST": 17,
|
|
|
"EFAULT": 14,
|
|
|
"EFBIG": 27,
|
|
|
"EHOSTUNREACH": 65,
|
|
|
"EIDRM": 90,
|
|
|
"EILSEQ": 92,
|
|
|
"EINPROGRESS": 36,
|
|
|
"EINTR": 4,
|
|
|
"EINVAL": 22,
|
|
|
"EIO": 5,
|
|
|
"EISCONN": 56,
|
|
|
"EISDIR": 21,
|
|
|
"ELOOP": 62,
|
|
|
"EMFILE": 24,
|
|
|
"EMLINK": 31,
|
|
|
"EMSGSIZE": 40,
|
|
|
"EMULTIHOP": 95,
|
|
|
"ENAMETOOLONG": 63,
|
|
|
"ENETDOWN": 50,
|
|
|
"ENETRESET": 52,
|
|
|
"ENETUNREACH": 51,
|
|
|
"ENFILE": 23,
|
|
|
"ENOBUFS": 55,
|
|
|
"ENODATA": 96,
|
|
|
"ENODEV": 19,
|
|
|
"ENOENT": 2,
|
|
|
"ENOEXEC": 8,
|
|
|
"ENOLCK": 77,
|
|
|
"ENOLINK": 97,
|
|
|
"ENOMEM": 12,
|
|
|
"ENOMSG": 91,
|
|
|
"ENOPROTOOPT": 42,
|
|
|
"ENOSPC": 28,
|
|
|
"ENOSR": 98,
|
|
|
"ENOSTR": 99,
|
|
|
"ENOSYS": 78,
|
|
|
"ENOTCONN": 57,
|
|
|
"ENOTDIR": 20,
|
|
|
"ENOTEMPTY": 66,
|
|
|
"ENOTSOCK": 38,
|
|
|
"ENOTSUP": 45,
|
|
|
"ENOTTY": 25,
|
|
|
"ENXIO": 6,
|
|
|
"EOPNOTSUPP": 102,
|
|
|
"EOVERFLOW": 84,
|
|
|
"EPERM": 1,
|
|
|
"EPIPE": 32,
|
|
|
"EPROTO": 100,
|
|
|
"EPROTONOSUPPORT": 43,
|
|
|
"EPROTOTYPE": 41,
|
|
|
"ERANGE": 34,
|
|
|
"EROFS": 30,
|
|
|
"ESPIPE": 29,
|
|
|
"ESRCH": 3,
|
|
|
"ESTALE": 70,
|
|
|
"ETIME": 101,
|
|
|
"ETIMEDOUT": 60,
|
|
|
"ETXTBSY": 26,
|
|
|
"EWOULDBLOCK": 35,
|
|
|
"EXDEV": 18,
|
|
|
"SIGHUP": 1,
|
|
|
"SIGINT": 2,
|
|
|
"SIGQUIT": 3,
|
|
|
"SIGILL": 4,
|
|
|
"SIGTRAP": 5,
|
|
|
"SIGABRT": 6,
|
|
|
"SIGIOT": 6,
|
|
|
"SIGBUS": 10,
|
|
|
"SIGFPE": 8,
|
|
|
"SIGKILL": 9,
|
|
|
"SIGUSR1": 30,
|
|
|
"SIGSEGV": 11,
|
|
|
"SIGUSR2": 31,
|
|
|
"SIGPIPE": 13,
|
|
|
"SIGALRM": 14,
|
|
|
"SIGTERM": 15,
|
|
|
"SIGCHLD": 20,
|
|
|
"SIGCONT": 19,
|
|
|
"SIGSTOP": 17,
|
|
|
"SIGTSTP": 18,
|
|
|
"SIGTTIN": 21,
|
|
|
"SIGTTOU": 22,
|
|
|
"SIGURG": 16,
|
|
|
"SIGXCPU": 24,
|
|
|
"SIGXFSZ": 25,
|
|
|
"SIGVTALRM": 26,
|
|
|
"SIGPROF": 27,
|
|
|
"SIGWINCH": 28,
|
|
|
"SIGIO": 23,
|
|
|
"SIGSYS": 12,
|
|
|
"SSL_OP_ALL": 2147486719,
|
|
|
"SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": 262144,
|
|
|
"SSL_OP_CIPHER_SERVER_PREFERENCE": 4194304,
|
|
|
"SSL_OP_CISCO_ANYCONNECT": 32768,
|
|
|
"SSL_OP_COOKIE_EXCHANGE": 8192,
|
|
|
"SSL_OP_CRYPTOPRO_TLSEXT_BUG": 2147483648,
|
|
|
"SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": 2048,
|
|
|
"SSL_OP_EPHEMERAL_RSA": 0,
|
|
|
"SSL_OP_LEGACY_SERVER_CONNECT": 4,
|
|
|
"SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER": 32,
|
|
|
"SSL_OP_MICROSOFT_SESS_ID_BUG": 1,
|
|
|
"SSL_OP_MSIE_SSLV2_RSA_PADDING": 0,
|
|
|
"SSL_OP_NETSCAPE_CA_DN_BUG": 536870912,
|
|
|
"SSL_OP_NETSCAPE_CHALLENGE_BUG": 2,
|
|
|
"SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG": 1073741824,
|
|
|
"SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG": 8,
|
|
|
"SSL_OP_NO_COMPRESSION": 131072,
|
|
|
"SSL_OP_NO_QUERY_MTU": 4096,
|
|
|
"SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": 65536,
|
|
|
"SSL_OP_NO_SSLv2": 16777216,
|
|
|
"SSL_OP_NO_SSLv3": 33554432,
|
|
|
"SSL_OP_NO_TICKET": 16384,
|
|
|
"SSL_OP_NO_TLSv1": 67108864,
|
|
|
"SSL_OP_NO_TLSv1_1": 268435456,
|
|
|
"SSL_OP_NO_TLSv1_2": 134217728,
|
|
|
"SSL_OP_PKCS1_CHECK_1": 0,
|
|
|
"SSL_OP_PKCS1_CHECK_2": 0,
|
|
|
"SSL_OP_SINGLE_DH_USE": 1048576,
|
|
|
"SSL_OP_SINGLE_ECDH_USE": 524288,
|
|
|
"SSL_OP_SSLEAY_080_CLIENT_DH_BUG": 128,
|
|
|
"SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG": 0,
|
|
|
"SSL_OP_TLS_BLOCK_PADDING_BUG": 512,
|
|
|
"SSL_OP_TLS_D5_BUG": 256,
|
|
|
"SSL_OP_TLS_ROLLBACK_BUG": 8388608,
|
|
|
"ENGINE_METHOD_DSA": 2,
|
|
|
"ENGINE_METHOD_DH": 4,
|
|
|
"ENGINE_METHOD_RAND": 8,
|
|
|
"ENGINE_METHOD_ECDH": 16,
|
|
|
"ENGINE_METHOD_ECDSA": 32,
|
|
|
"ENGINE_METHOD_CIPHERS": 64,
|
|
|
"ENGINE_METHOD_DIGESTS": 128,
|
|
|
"ENGINE_METHOD_STORE": 256,
|
|
|
"ENGINE_METHOD_PKEY_METHS": 512,
|
|
|
"ENGINE_METHOD_PKEY_ASN1_METHS": 1024,
|
|
|
"ENGINE_METHOD_ALL": 65535,
|
|
|
"ENGINE_METHOD_NONE": 0,
|
|
|
"DH_CHECK_P_NOT_SAFE_PRIME": 2,
|
|
|
"DH_CHECK_P_NOT_PRIME": 1,
|
|
|
"DH_UNABLE_TO_CHECK_GENERATOR": 4,
|
|
|
"DH_NOT_SUITABLE_GENERATOR": 8,
|
|
|
"NPN_ENABLED": 1,
|
|
|
"RSA_PKCS1_PADDING": 1,
|
|
|
"RSA_SSLV23_PADDING": 2,
|
|
|
"RSA_NO_PADDING": 3,
|
|
|
"RSA_PKCS1_OAEP_PADDING": 4,
|
|
|
"RSA_X931_PADDING": 5,
|
|
|
"RSA_PKCS1_PSS_PADDING": 6,
|
|
|
"POINT_CONVERSION_COMPRESSED": 2,
|
|
|
"POINT_CONVERSION_UNCOMPRESSED": 4,
|
|
|
"POINT_CONVERSION_HYBRID": 6,
|
|
|
"F_OK": 0,
|
|
|
"R_OK": 4,
|
|
|
"W_OK": 2,
|
|
|
"X_OK": 1,
|
|
|
"UV_UDP_REUSEADDR": 4
|
|
|
}
|
|
|
|
|
|
},{}],76:[function(require,module,exports){
|
|
|
/*!
|
|
|
* copy-to - index.js
|
|
|
* Copyright(c) 2014 dead_horse <dead_horse@qq.com>
|
|
|
* MIT Licensed
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
/**
|
|
|
* slice() reference.
|
|
|
*/
|
|
|
|
|
|
var slice = Array.prototype.slice;
|
|
|
|
|
|
/**
|
|
|
* Expose copy
|
|
|
*
|
|
|
* ```
|
|
|
* copy({foo: 'nar', hello: 'copy'}).to({hello: 'world'});
|
|
|
* copy({foo: 'nar', hello: 'copy'}).toCover({hello: 'world'});
|
|
|
* ```
|
|
|
*
|
|
|
* @param {Object} src
|
|
|
* @return {Copy}
|
|
|
*/
|
|
|
|
|
|
module.exports = Copy;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Copy
|
|
|
* @param {Object} src
|
|
|
* @param {Boolean} withAccess
|
|
|
*/
|
|
|
|
|
|
function Copy(src, withAccess) {
|
|
|
if (!(this instanceof Copy)) return new Copy(src, withAccess);
|
|
|
this.src = src;
|
|
|
this._withAccess = withAccess;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* copy properties include getter and setter
|
|
|
* @param {[type]} val [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
|
|
|
Copy.prototype.withAccess = function (w) {
|
|
|
this._withAccess = w !== false;
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* pick keys in src
|
|
|
*
|
|
|
* @api: public
|
|
|
*/
|
|
|
|
|
|
Copy.prototype.pick = function(keys) {
|
|
|
if (!Array.isArray(keys)) {
|
|
|
keys = slice.call(arguments);
|
|
|
}
|
|
|
if (keys.length) {
|
|
|
this.keys = keys;
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* copy src to target,
|
|
|
* do not cover any property target has
|
|
|
* @param {Object} to
|
|
|
*
|
|
|
* @api: public
|
|
|
*/
|
|
|
|
|
|
Copy.prototype.to = function(to) {
|
|
|
to = to || {};
|
|
|
|
|
|
if (!this.src) return to;
|
|
|
var keys = this.keys || Object.keys(this.src);
|
|
|
|
|
|
if (!this._withAccess) {
|
|
|
for (var i = 0; i < keys.length; i++) {
|
|
|
key = keys[i];
|
|
|
if (to[key] !== undefined) continue;
|
|
|
to[key] = this.src[key];
|
|
|
}
|
|
|
return to;
|
|
|
}
|
|
|
|
|
|
for (var i = 0; i < keys.length; i++) {
|
|
|
var key = keys[i];
|
|
|
if (!notDefined(to, key)) continue;
|
|
|
var getter = this.src.__lookupGetter__(key);
|
|
|
var setter = this.src.__lookupSetter__(key);
|
|
|
if (getter) to.__defineGetter__(key, getter);
|
|
|
if (setter) to.__defineSetter__(key, setter);
|
|
|
|
|
|
if (!getter && !setter) {
|
|
|
to[key] = this.src[key];
|
|
|
}
|
|
|
}
|
|
|
return to;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* copy src to target,
|
|
|
* override any property target has
|
|
|
* @param {Object} to
|
|
|
*
|
|
|
* @api: public
|
|
|
*/
|
|
|
|
|
|
Copy.prototype.toCover = function(to) {
|
|
|
var keys = this.keys || Object.keys(this.src);
|
|
|
|
|
|
for (var i = 0; i < keys.length; i++) {
|
|
|
var key = keys[i];
|
|
|
delete to[key];
|
|
|
var getter = this.src.__lookupGetter__(key);
|
|
|
var setter = this.src.__lookupSetter__(key);
|
|
|
if (getter) to.__defineGetter__(key, getter);
|
|
|
if (setter) to.__defineSetter__(key, setter);
|
|
|
|
|
|
if (!getter && !setter) {
|
|
|
to[key] = this.src[key];
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Copy.prototype.override = Copy.prototype.toCover;
|
|
|
|
|
|
/**
|
|
|
* append another object to src
|
|
|
* @param {Obj} obj
|
|
|
* @return {Copy}
|
|
|
*/
|
|
|
|
|
|
Copy.prototype.and = function (obj) {
|
|
|
var src = {};
|
|
|
this.to(src);
|
|
|
this.src = obj;
|
|
|
this.to(src);
|
|
|
this.src = src;
|
|
|
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* check obj[key] if not defiend
|
|
|
* @param {Object} obj
|
|
|
* @param {String} key
|
|
|
* @return {Boolean}
|
|
|
*/
|
|
|
|
|
|
function notDefined(obj, key) {
|
|
|
return obj[key] === undefined
|
|
|
&& obj.__lookupGetter__(key) === undefined
|
|
|
&& obj.__lookupSetter__(key) === undefined;
|
|
|
}
|
|
|
|
|
|
},{}],77:[function(require,module,exports){
|
|
|
require('../../modules/es6.string.iterator');
|
|
|
require('../../modules/es6.array.from');
|
|
|
module.exports = require('../../modules/_core').Array.from;
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.array.from":168,"../../modules/es6.string.iterator":180}],78:[function(require,module,exports){
|
|
|
var core = require('../../modules/_core');
|
|
|
var $JSON = core.JSON || (core.JSON = { stringify: JSON.stringify });
|
|
|
module.exports = function stringify(it) { // eslint-disable-line no-unused-vars
|
|
|
return $JSON.stringify.apply($JSON, arguments);
|
|
|
};
|
|
|
|
|
|
},{"../../modules/_core":99}],79:[function(require,module,exports){
|
|
|
require('../../modules/es6.object.assign');
|
|
|
module.exports = require('../../modules/_core').Object.assign;
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.object.assign":171}],80:[function(require,module,exports){
|
|
|
require('../../modules/es6.object.create');
|
|
|
var $Object = require('../../modules/_core').Object;
|
|
|
module.exports = function create(P, D) {
|
|
|
return $Object.create(P, D);
|
|
|
};
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.object.create":172}],81:[function(require,module,exports){
|
|
|
require('../../modules/es6.object.define-property');
|
|
|
var $Object = require('../../modules/_core').Object;
|
|
|
module.exports = function defineProperty(it, key, desc) {
|
|
|
return $Object.defineProperty(it, key, desc);
|
|
|
};
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.object.define-property":173}],82:[function(require,module,exports){
|
|
|
require('../../modules/es7.object.entries');
|
|
|
module.exports = require('../../modules/_core').Object.entries;
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es7.object.entries":182}],83:[function(require,module,exports){
|
|
|
require('../../modules/es6.object.get-own-property-names');
|
|
|
var $Object = require('../../modules/_core').Object;
|
|
|
module.exports = function getOwnPropertyNames(it) {
|
|
|
return $Object.getOwnPropertyNames(it);
|
|
|
};
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.object.get-own-property-names":174}],84:[function(require,module,exports){
|
|
|
require('../../modules/es6.object.get-prototype-of');
|
|
|
module.exports = require('../../modules/_core').Object.getPrototypeOf;
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.object.get-prototype-of":175}],85:[function(require,module,exports){
|
|
|
require('../../modules/es6.object.keys');
|
|
|
module.exports = require('../../modules/_core').Object.keys;
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.object.keys":176}],86:[function(require,module,exports){
|
|
|
require('../modules/es6.object.to-string');
|
|
|
require('../modules/es6.string.iterator');
|
|
|
require('../modules/web.dom.iterable');
|
|
|
require('../modules/es6.promise');
|
|
|
require('../modules/es7.promise.finally');
|
|
|
require('../modules/es7.promise.try');
|
|
|
module.exports = require('../modules/_core').Promise;
|
|
|
|
|
|
},{"../modules/_core":99,"../modules/es6.object.to-string":177,"../modules/es6.promise":178,"../modules/es6.string.iterator":180,"../modules/es7.promise.finally":183,"../modules/es7.promise.try":184,"../modules/web.dom.iterable":187}],87:[function(require,module,exports){
|
|
|
require('../modules/web.immediate');
|
|
|
module.exports = require('../modules/_core').setImmediate;
|
|
|
|
|
|
},{"../modules/_core":99,"../modules/web.immediate":188}],88:[function(require,module,exports){
|
|
|
require('../../modules/es6.string.from-code-point');
|
|
|
module.exports = require('../../modules/_core').String.fromCodePoint;
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.string.from-code-point":179}],89:[function(require,module,exports){
|
|
|
require('../../modules/es6.function.has-instance');
|
|
|
module.exports = require('../../modules/_wks-ext').f('hasInstance');
|
|
|
|
|
|
},{"../../modules/_wks-ext":165,"../../modules/es6.function.has-instance":170}],90:[function(require,module,exports){
|
|
|
require('../../modules/es6.symbol');
|
|
|
require('../../modules/es6.object.to-string');
|
|
|
require('../../modules/es7.symbol.async-iterator');
|
|
|
require('../../modules/es7.symbol.observable');
|
|
|
module.exports = require('../../modules/_core').Symbol;
|
|
|
|
|
|
},{"../../modules/_core":99,"../../modules/es6.object.to-string":177,"../../modules/es6.symbol":181,"../../modules/es7.symbol.async-iterator":185,"../../modules/es7.symbol.observable":186}],91:[function(require,module,exports){
|
|
|
require('../../modules/es6.string.iterator');
|
|
|
require('../../modules/web.dom.iterable');
|
|
|
module.exports = require('../../modules/_wks-ext').f('iterator');
|
|
|
|
|
|
},{"../../modules/_wks-ext":165,"../../modules/es6.string.iterator":180,"../../modules/web.dom.iterable":187}],92:[function(require,module,exports){
|
|
|
module.exports = function (it) {
|
|
|
if (typeof it != 'function') throw TypeError(it + ' is not a function!');
|
|
|
return it;
|
|
|
};
|
|
|
|
|
|
},{}],93:[function(require,module,exports){
|
|
|
module.exports = function () { /* empty */ };
|
|
|
|
|
|
},{}],94:[function(require,module,exports){
|
|
|
module.exports = function (it, Constructor, name, forbiddenField) {
|
|
|
if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
|
|
|
throw TypeError(name + ': incorrect invocation!');
|
|
|
} return it;
|
|
|
};
|
|
|
|
|
|
},{}],95:[function(require,module,exports){
|
|
|
var isObject = require('./_is-object');
|
|
|
module.exports = function (it) {
|
|
|
if (!isObject(it)) throw TypeError(it + ' is not an object!');
|
|
|
return it;
|
|
|
};
|
|
|
|
|
|
},{"./_is-object":119}],96:[function(require,module,exports){
|
|
|
// false -> Array#indexOf
|
|
|
// true -> Array#includes
|
|
|
var toIObject = require('./_to-iobject');
|
|
|
var toLength = require('./_to-length');
|
|
|
var toAbsoluteIndex = require('./_to-absolute-index');
|
|
|
module.exports = function (IS_INCLUDES) {
|
|
|
return function ($this, el, fromIndex) {
|
|
|
var O = toIObject($this);
|
|
|
var length = toLength(O.length);
|
|
|
var index = toAbsoluteIndex(fromIndex, length);
|
|
|
var value;
|
|
|
// Array#includes uses SameValueZero equality algorithm
|
|
|
// eslint-disable-next-line no-self-compare
|
|
|
if (IS_INCLUDES && el != el) while (length > index) {
|
|
|
value = O[index++];
|
|
|
// eslint-disable-next-line no-self-compare
|
|
|
if (value != value) return true;
|
|
|
// Array#indexOf ignores holes, Array#includes - not
|
|
|
} else for (;length > index; index++) if (IS_INCLUDES || index in O) {
|
|
|
if (O[index] === el) return IS_INCLUDES || index || 0;
|
|
|
} return !IS_INCLUDES && -1;
|
|
|
};
|
|
|
};
|
|
|
|
|
|
},{"./_to-absolute-index":156,"./_to-iobject":158,"./_to-length":159}],97:[function(require,module,exports){
|
|
|
// getting tag from 19.1.3.6 Object.prototype.toString()
|
|
|
var cof = require('./_cof');
|
|
|
var TAG = require('./_wks')('toStringTag');
|
|
|
// ES3 wrong here
|
|
|
var ARG = cof(function () { return arguments; }()) == 'Arguments';
|
|
|
|
|
|
// fallback for IE11 Script Access Denied error
|
|
|
var tryGet = function (it, key) {
|
|
|
try {
|
|
|
return it[key];
|
|
|
} catch (e) { /* empty */ }
|
|
|
};
|
|
|
|
|
|
module.exports = function (it) {
|
|
|
var O, T, B;
|
|
|
return it === undefined ? 'Undefined' : it === null ? 'Null'
|
|
|
// @@toStringTag case
|
|
|
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
|
|
|
// builtinTag case
|
|
|
: ARG ? cof(O)
|
|
|
// ES3 arguments fallback
|
|
|
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
|
|
};
|
|
|
|
|
|
},{"./_cof":98,"./_wks":166}],98:[function(require,module,exports){
|
|
|
var toString = {}.toString;
|
|
|
|
|
|
module.exports = function (it) {
|
|
|
return toString.call(it).slice(8, -1);
|
|
|
};
|
|
|
|
|
|
},{}],99:[function(require,module,exports){
|
|
|
var core = module.exports = { version: '2.6.11' };
|
|
|
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
|
|
|
|
|
|
},{}],100:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var $defineProperty = require('./_object-dp');
|
|
|
var createDesc = require('./_property-desc');
|
|
|
|
|
|
module.exports = function (object, index, value) {
|
|
|
if (index in object) $defineProperty.f(object, index, createDesc(0, value));
|
|
|
else object[index] = value;
|
|
|
};
|
|
|
|
|
|
},{"./_object-dp":132,"./_property-desc":146}],101:[function(require,module,exports){
|
|
|
// optional / simple context binding
|
|
|
var aFunction = require('./_a-function');
|
|
|
module.exports = function (fn, that, length) {
|
|
|
aFunction(fn);
|
|
|
if (that === undefined) return fn;
|
|
|
switch (length) {
|
|
|
case 1: return function (a) {
|
|
|
return fn.call(that, a);
|
|
|
};
|
|
|
case 2: return function (a, b) {
|
|
|
return fn.call(that, a, b);
|
|
|
};
|
|
|
case 3: return function (a, b, c) {
|
|
|
return fn.call(that, a, b, c);
|
|
|
};
|
|
|
}
|
|
|
return function (/* ...args */) {
|
|
|
return fn.apply(that, arguments);
|
|
|
};
|
|
|
};
|
|
|
|
|
|
},{"./_a-function":92}],102:[function(require,module,exports){
|
|
|
// 7.2.1 RequireObjectCoercible(argument)
|
|
|
module.exports = function (it) {
|
|
|
if (it == undefined) throw TypeError("Can't call method on " + it);
|
|
|
return it;
|
|
|
};
|
|
|
|
|
|
},{}],103:[function(require,module,exports){
|
|
|
// Thank's IE8 for his funny defineProperty
|
|
|
module.exports = !require('./_fails')(function () {
|
|
|
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
|
|
|
});
|
|
|
|
|
|
},{"./_fails":108}],104:[function(require,module,exports){
|
|
|
var isObject = require('./_is-object');
|
|
|
var document = require('./_global').document;
|
|
|
// typeof document.createElement is 'object' in old IE
|
|
|
var is = isObject(document) && isObject(document.createElement);
|
|
|
module.exports = function (it) {
|
|
|
return is ? document.createElement(it) : {};
|
|
|
};
|
|
|
|
|
|
},{"./_global":110,"./_is-object":119}],105:[function(require,module,exports){
|
|
|
// IE 8- don't enum bug keys
|
|
|
module.exports = (
|
|
|
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
|
|
|
).split(',');
|
|
|
|
|
|
},{}],106:[function(require,module,exports){
|
|
|
// all enumerable object keys, includes symbols
|
|
|
var getKeys = require('./_object-keys');
|
|
|
var gOPS = require('./_object-gops');
|
|
|
var pIE = require('./_object-pie');
|
|
|
module.exports = function (it) {
|
|
|
var result = getKeys(it);
|
|
|
var getSymbols = gOPS.f;
|
|
|
if (getSymbols) {
|
|
|
var symbols = getSymbols(it);
|
|
|
var isEnum = pIE.f;
|
|
|
var i = 0;
|
|
|
var key;
|
|
|
while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
|
|
|
} return result;
|
|
|
};
|
|
|
|
|
|
},{"./_object-gops":137,"./_object-keys":140,"./_object-pie":141}],107:[function(require,module,exports){
|
|
|
var global = require('./_global');
|
|
|
var core = require('./_core');
|
|
|
var ctx = require('./_ctx');
|
|
|
var hide = require('./_hide');
|
|
|
var has = require('./_has');
|
|
|
var PROTOTYPE = 'prototype';
|
|
|
|
|
|
var $export = function (type, name, source) {
|
|
|
var IS_FORCED = type & $export.F;
|
|
|
var IS_GLOBAL = type & $export.G;
|
|
|
var IS_STATIC = type & $export.S;
|
|
|
var IS_PROTO = type & $export.P;
|
|
|
var IS_BIND = type & $export.B;
|
|
|
var IS_WRAP = type & $export.W;
|
|
|
var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
|
|
|
var expProto = exports[PROTOTYPE];
|
|
|
var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
|
|
|
var key, own, out;
|
|
|
if (IS_GLOBAL) source = name;
|
|
|
for (key in source) {
|
|
|
// contains in native
|
|
|
own = !IS_FORCED && target && target[key] !== undefined;
|
|
|
if (own && has(exports, key)) continue;
|
|
|
// export native or passed
|
|
|
out = own ? target[key] : source[key];
|
|
|
// prevent global pollution for namespaces
|
|
|
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
|
|
|
// bind timers to global for call from export context
|
|
|
: IS_BIND && own ? ctx(out, global)
|
|
|
// wrap global constructors for prevent change them in library
|
|
|
: IS_WRAP && target[key] == out ? (function (C) {
|
|
|
var F = function (a, b, c) {
|
|
|
if (this instanceof C) {
|
|
|
switch (arguments.length) {
|
|
|
case 0: return new C();
|
|
|
case 1: return new C(a);
|
|
|
case 2: return new C(a, b);
|
|
|
} return new C(a, b, c);
|
|
|
} return C.apply(this, arguments);
|
|
|
};
|
|
|
F[PROTOTYPE] = C[PROTOTYPE];
|
|
|
return F;
|
|
|
// make static versions for prototype methods
|
|
|
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
|
|
|
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
|
|
|
if (IS_PROTO) {
|
|
|
(exports.virtual || (exports.virtual = {}))[key] = out;
|
|
|
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
|
|
|
if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
// type bitmap
|
|
|
$export.F = 1; // forced
|
|
|
$export.G = 2; // global
|
|
|
$export.S = 4; // static
|
|
|
$export.P = 8; // proto
|
|
|
$export.B = 16; // bind
|
|
|
$export.W = 32; // wrap
|
|
|
$export.U = 64; // safe
|
|
|
$export.R = 128; // real proto method for `library`
|
|
|
module.exports = $export;
|
|
|
|
|
|
},{"./_core":99,"./_ctx":101,"./_global":110,"./_has":111,"./_hide":112}],108:[function(require,module,exports){
|
|
|
module.exports = function (exec) {
|
|
|
try {
|
|
|
return !!exec();
|
|
|
} catch (e) {
|
|
|
return true;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
},{}],109:[function(require,module,exports){
|
|
|
var ctx = require('./_ctx');
|
|
|
var call = require('./_iter-call');
|
|
|
var isArrayIter = require('./_is-array-iter');
|
|
|
var anObject = require('./_an-object');
|
|
|
var toLength = require('./_to-length');
|
|
|
var getIterFn = require('./core.get-iterator-method');
|
|
|
var BREAK = {};
|
|
|
var RETURN = {};
|
|
|
var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
|
|
|
var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
|
|
|
var f = ctx(fn, that, entries ? 2 : 1);
|
|
|
var index = 0;
|
|
|
var length, step, iterator, result;
|
|
|
if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
|
|
|
// fast case for arrays with default iterator
|
|
|
if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
|
|
|
result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
|
|
|
if (result === BREAK || result === RETURN) return result;
|
|
|
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
|
|
|
result = call(iterator, f, step.value, entries);
|
|
|
if (result === BREAK || result === RETURN) return result;
|
|
|
}
|
|
|
};
|
|
|
exports.BREAK = BREAK;
|
|
|
exports.RETURN = RETURN;
|
|
|
|
|
|
},{"./_an-object":95,"./_ctx":101,"./_is-array-iter":117,"./_iter-call":120,"./_to-length":159,"./core.get-iterator-method":167}],110:[function(require,module,exports){
|
|
|
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
|
var global = module.exports = typeof window != 'undefined' && window.Math == Math
|
|
|
? window : typeof self != 'undefined' && self.Math == Math ? self
|
|
|
// eslint-disable-next-line no-new-func
|
|
|
: Function('return this')();
|
|
|
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
|
|
|
|
|
|
},{}],111:[function(require,module,exports){
|
|
|
var hasOwnProperty = {}.hasOwnProperty;
|
|
|
module.exports = function (it, key) {
|
|
|
return hasOwnProperty.call(it, key);
|
|
|
};
|
|
|
|
|
|
},{}],112:[function(require,module,exports){
|
|
|
var dP = require('./_object-dp');
|
|
|
var createDesc = require('./_property-desc');
|
|
|
module.exports = require('./_descriptors') ? function (object, key, value) {
|
|
|
return dP.f(object, key, createDesc(1, value));
|
|
|
} : function (object, key, value) {
|
|
|
object[key] = value;
|
|
|
return object;
|
|
|
};
|
|
|
|
|
|
},{"./_descriptors":103,"./_object-dp":132,"./_property-desc":146}],113:[function(require,module,exports){
|
|
|
var document = require('./_global').document;
|
|
|
module.exports = document && document.documentElement;
|
|
|
|
|
|
},{"./_global":110}],114:[function(require,module,exports){
|
|
|
module.exports = !require('./_descriptors') && !require('./_fails')(function () {
|
|
|
return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
|
|
|
});
|
|
|
|
|
|
},{"./_descriptors":103,"./_dom-create":104,"./_fails":108}],115:[function(require,module,exports){
|
|
|
// fast apply, http://jsperf.lnkit.com/fast-apply/5
|
|
|
module.exports = function (fn, args, that) {
|
|
|
var un = that === undefined;
|
|
|
switch (args.length) {
|
|
|
case 0: return un ? fn()
|
|
|
: fn.call(that);
|
|
|
case 1: return un ? fn(args[0])
|
|
|
: fn.call(that, args[0]);
|
|
|
case 2: return un ? fn(args[0], args[1])
|
|
|
: fn.call(that, args[0], args[1]);
|
|
|
case 3: return un ? fn(args[0], args[1], args[2])
|
|
|
: fn.call(that, args[0], args[1], args[2]);
|
|
|
case 4: return un ? fn(args[0], args[1], args[2], args[3])
|
|
|
: fn.call(that, args[0], args[1], args[2], args[3]);
|
|
|
} return fn.apply(that, args);
|
|
|
};
|
|
|
|
|
|
},{}],116:[function(require,module,exports){
|
|
|
// fallback for non-array-like ES3 and non-enumerable old V8 strings
|
|
|
var cof = require('./_cof');
|
|
|
// eslint-disable-next-line no-prototype-builtins
|
|
|
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
|
|
|
return cof(it) == 'String' ? it.split('') : Object(it);
|
|
|
};
|
|
|
|
|
|
},{"./_cof":98}],117:[function(require,module,exports){
|
|
|
// check on default Array iterator
|
|
|
var Iterators = require('./_iterators');
|
|
|
var ITERATOR = require('./_wks')('iterator');
|
|
|
var ArrayProto = Array.prototype;
|
|
|
|
|
|
module.exports = function (it) {
|
|
|
return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
|
|
|
};
|
|
|
|
|
|
},{"./_iterators":125,"./_wks":166}],118:[function(require,module,exports){
|
|
|
// 7.2.2 IsArray(argument)
|
|
|
var cof = require('./_cof');
|
|
|
module.exports = Array.isArray || function isArray(arg) {
|
|
|
return cof(arg) == 'Array';
|
|
|
};
|
|
|
|
|
|
},{"./_cof":98}],119:[function(require,module,exports){
|
|
|
module.exports = function (it) {
|
|
|
return typeof it === 'object' ? it !== null : typeof it === 'function';
|
|
|
};
|
|
|
|
|
|
},{}],120:[function(require,module,exports){
|
|
|
// call something on iterator step with safe closing on error
|
|
|
var anObject = require('./_an-object');
|
|
|
module.exports = function (iterator, fn, value, entries) {
|
|
|
try {
|
|
|
return entries ? fn(anObject(value)[0], value[1]) : fn(value);
|
|
|
// 7.4.6 IteratorClose(iterator, completion)
|
|
|
} catch (e) {
|
|
|
var ret = iterator['return'];
|
|
|
if (ret !== undefined) anObject(ret.call(iterator));
|
|
|
throw e;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
},{"./_an-object":95}],121:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var create = require('./_object-create');
|
|
|
var descriptor = require('./_property-desc');
|
|
|
var setToStringTag = require('./_set-to-string-tag');
|
|
|
var IteratorPrototype = {};
|
|
|
|
|
|
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
|
|
|
require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });
|
|
|
|
|
|
module.exports = function (Constructor, NAME, next) {
|
|
|
Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
|
|
|
setToStringTag(Constructor, NAME + ' Iterator');
|
|
|
};
|
|
|
|
|
|
},{"./_hide":112,"./_object-create":131,"./_property-desc":146,"./_set-to-string-tag":150,"./_wks":166}],122:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var LIBRARY = require('./_library');
|
|
|
var $export = require('./_export');
|
|
|
var redefine = require('./_redefine');
|
|
|
var hide = require('./_hide');
|
|
|
var Iterators = require('./_iterators');
|
|
|
var $iterCreate = require('./_iter-create');
|
|
|
var setToStringTag = require('./_set-to-string-tag');
|
|
|
var getPrototypeOf = require('./_object-gpo');
|
|
|
var ITERATOR = require('./_wks')('iterator');
|
|
|
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
|
|
|
var FF_ITERATOR = '@@iterator';
|
|
|
var KEYS = 'keys';
|
|
|
var VALUES = 'values';
|
|
|
|
|
|
var returnThis = function () { return this; };
|
|
|
|
|
|
module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
|
|
|
$iterCreate(Constructor, NAME, next);
|
|
|
var getMethod = function (kind) {
|
|
|
if (!BUGGY && kind in proto) return proto[kind];
|
|
|
switch (kind) {
|
|
|
case KEYS: return function keys() { return new Constructor(this, kind); };
|
|
|
case VALUES: return function values() { return new Constructor(this, kind); };
|
|
|
} return function entries() { return new Constructor(this, kind); };
|
|
|
};
|
|
|
var TAG = NAME + ' Iterator';
|
|
|
var DEF_VALUES = DEFAULT == VALUES;
|
|
|
var VALUES_BUG = false;
|
|
|
var proto = Base.prototype;
|
|
|
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
|
|
|
var $default = $native || getMethod(DEFAULT);
|
|
|
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
|
|
|
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
|
|
|
var methods, key, IteratorPrototype;
|
|
|
// Fix native
|
|
|
if ($anyNative) {
|
|
|
IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
|
|
|
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
|
|
|
// Set @@toStringTag to native iterators
|
|
|
setToStringTag(IteratorPrototype, TAG, true);
|
|
|
// fix for some old engines
|
|
|
if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
|
|
|
}
|
|
|
}
|
|
|
// fix Array#{values, @@iterator}.name in V8 / FF
|
|
|
if (DEF_VALUES && $native && $native.name !== VALUES) {
|
|
|
VALUES_BUG = true;
|
|
|
$default = function values() { return $native.call(this); };
|
|
|
}
|
|
|
// Define iterator
|
|
|
if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
|
|
|
hide(proto, ITERATOR, $default);
|
|
|
}
|
|
|
// Plug for library
|
|
|
Iterators[NAME] = $default;
|
|
|
Iterators[TAG] = returnThis;
|
|
|
if (DEFAULT) {
|
|
|
methods = {
|
|
|
values: DEF_VALUES ? $default : getMethod(VALUES),
|
|
|
keys: IS_SET ? $default : getMethod(KEYS),
|
|
|
entries: $entries
|
|
|
};
|
|
|
if (FORCED) for (key in methods) {
|
|
|
if (!(key in proto)) redefine(proto, key, methods[key]);
|
|
|
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
|
|
|
}
|
|
|
return methods;
|
|
|
};
|
|
|
|
|
|
},{"./_export":107,"./_hide":112,"./_iter-create":121,"./_iterators":125,"./_library":126,"./_object-gpo":138,"./_redefine":148,"./_set-to-string-tag":150,"./_wks":166}],123:[function(require,module,exports){
|
|
|
var ITERATOR = require('./_wks')('iterator');
|
|
|
var SAFE_CLOSING = false;
|
|
|
|
|
|
try {
|
|
|
var riter = [7][ITERATOR]();
|
|
|
riter['return'] = function () { SAFE_CLOSING = true; };
|
|
|
// eslint-disable-next-line no-throw-literal
|
|
|
Array.from(riter, function () { throw 2; });
|
|
|
} catch (e) { /* empty */ }
|
|
|
|
|
|
module.exports = function (exec, skipClosing) {
|
|
|
if (!skipClosing && !SAFE_CLOSING) return false;
|
|
|
var safe = false;
|
|
|
try {
|
|
|
var arr = [7];
|
|
|
var iter = arr[ITERATOR]();
|
|
|
iter.next = function () { return { done: safe = true }; };
|
|
|
arr[ITERATOR] = function () { return iter; };
|
|
|
exec(arr);
|
|
|
} catch (e) { /* empty */ }
|
|
|
return safe;
|
|
|
};
|
|
|
|
|
|
},{"./_wks":166}],124:[function(require,module,exports){
|
|
|
module.exports = function (done, value) {
|
|
|
return { value: value, done: !!done };
|
|
|
};
|
|
|
|
|
|
},{}],125:[function(require,module,exports){
|
|
|
module.exports = {};
|
|
|
|
|
|
},{}],126:[function(require,module,exports){
|
|
|
module.exports = true;
|
|
|
|
|
|
},{}],127:[function(require,module,exports){
|
|
|
var META = require('./_uid')('meta');
|
|
|
var isObject = require('./_is-object');
|
|
|
var has = require('./_has');
|
|
|
var setDesc = require('./_object-dp').f;
|
|
|
var id = 0;
|
|
|
var isExtensible = Object.isExtensible || function () {
|
|
|
return true;
|
|
|
};
|
|
|
var FREEZE = !require('./_fails')(function () {
|
|
|
return isExtensible(Object.preventExtensions({}));
|
|
|
});
|
|
|
var setMeta = function (it) {
|
|
|
setDesc(it, META, { value: {
|
|
|
i: 'O' + ++id, // object ID
|
|
|
w: {} // weak collections IDs
|
|
|
} });
|
|
|
};
|
|
|
var fastKey = function (it, create) {
|
|
|
// return primitive with prefix
|
|
|
if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
|
|
if (!has(it, META)) {
|
|
|
// can't set metadata to uncaught frozen object
|
|
|
if (!isExtensible(it)) return 'F';
|
|
|
// not necessary to add metadata
|
|
|
if (!create) return 'E';
|
|
|
// add missing metadata
|
|
|
setMeta(it);
|
|
|
// return object ID
|
|
|
} return it[META].i;
|
|
|
};
|
|
|
var getWeak = function (it, create) {
|
|
|
if (!has(it, META)) {
|
|
|
// can't set metadata to uncaught frozen object
|
|
|
if (!isExtensible(it)) return true;
|
|
|
// not necessary to add metadata
|
|
|
if (!create) return false;
|
|
|
// add missing metadata
|
|
|
setMeta(it);
|
|
|
// return hash weak collections IDs
|
|
|
} return it[META].w;
|
|
|
};
|
|
|
// add metadata on freeze-family methods calling
|
|
|
var onFreeze = function (it) {
|
|
|
if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
|
|
|
return it;
|
|
|
};
|
|
|
var meta = module.exports = {
|
|
|
KEY: META,
|
|
|
NEED: false,
|
|
|
fastKey: fastKey,
|
|
|
getWeak: getWeak,
|
|
|
onFreeze: onFreeze
|
|
|
};
|
|
|
|
|
|
},{"./_fails":108,"./_has":111,"./_is-object":119,"./_object-dp":132,"./_uid":162}],128:[function(require,module,exports){
|
|
|
var global = require('./_global');
|
|
|
var macrotask = require('./_task').set;
|
|
|
var Observer = global.MutationObserver || global.WebKitMutationObserver;
|
|
|
var process = global.process;
|
|
|
var Promise = global.Promise;
|
|
|
var isNode = require('./_cof')(process) == 'process';
|
|
|
|
|
|
module.exports = function () {
|
|
|
var head, last, notify;
|
|
|
|
|
|
var flush = function () {
|
|
|
var parent, fn;
|
|
|
if (isNode && (parent = process.domain)) parent.exit();
|
|
|
while (head) {
|
|
|
fn = head.fn;
|
|
|
head = head.next;
|
|
|
try {
|
|
|
fn();
|
|
|
} catch (e) {
|
|
|
if (head) notify();
|
|
|
else last = undefined;
|
|
|
throw e;
|
|
|
}
|
|
|
} last = undefined;
|
|
|
if (parent) parent.enter();
|
|
|
};
|
|
|
|
|
|
// Node.js
|
|
|
if (isNode) {
|
|
|
notify = function () {
|
|
|
process.nextTick(flush);
|
|
|
};
|
|
|
// browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
|
|
|
} else if (Observer && !(global.navigator && global.navigator.standalone)) {
|
|
|
var toggle = true;
|
|
|
var node = document.createTextNode('');
|
|
|
new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
|
|
|
notify = function () {
|
|
|
node.data = toggle = !toggle;
|
|
|
};
|
|
|
// environments with maybe non-completely correct, but existent Promise
|
|
|
} else if (Promise && Promise.resolve) {
|
|
|
// Promise.resolve without an argument throws an error in LG WebOS 2
|
|
|
var promise = Promise.resolve(undefined);
|
|
|
notify = function () {
|
|
|
promise.then(flush);
|
|
|
};
|
|
|
// for other environments - macrotask based on:
|
|
|
// - setImmediate
|
|
|
// - MessageChannel
|
|
|
// - window.postMessag
|
|
|
// - onreadystatechange
|
|
|
// - setTimeout
|
|
|
} else {
|
|
|
notify = function () {
|
|
|
// strange IE + webpack dev server bug - use .call(global)
|
|
|
macrotask.call(global, flush);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
return function (fn) {
|
|
|
var task = { fn: fn, next: undefined };
|
|
|
if (last) last.next = task;
|
|
|
if (!head) {
|
|
|
head = task;
|
|
|
notify();
|
|
|
} last = task;
|
|
|
};
|
|
|
};
|
|
|
|
|
|
},{"./_cof":98,"./_global":110,"./_task":155}],129:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
// 25.4.1.5 NewPromiseCapability(C)
|
|
|
var aFunction = require('./_a-function');
|
|
|
|
|
|
function PromiseCapability(C) {
|
|
|
var resolve, reject;
|
|
|
this.promise = new C(function ($$resolve, $$reject) {
|
|
|
if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
|
|
|
resolve = $$resolve;
|
|
|
reject = $$reject;
|
|
|
});
|
|
|
this.resolve = aFunction(resolve);
|
|
|
this.reject = aFunction(reject);
|
|
|
}
|
|
|
|
|
|
module.exports.f = function (C) {
|
|
|
return new PromiseCapability(C);
|
|
|
};
|
|
|
|
|
|
},{"./_a-function":92}],130:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
// 19.1.2.1 Object.assign(target, source, ...)
|
|
|
var DESCRIPTORS = require('./_descriptors');
|
|
|
var getKeys = require('./_object-keys');
|
|
|
var gOPS = require('./_object-gops');
|
|
|
var pIE = require('./_object-pie');
|
|
|
var toObject = require('./_to-object');
|
|
|
var IObject = require('./_iobject');
|
|
|
var $assign = Object.assign;
|
|
|
|
|
|
// should work with symbols and should have deterministic property order (V8 bug)
|
|
|
module.exports = !$assign || require('./_fails')(function () {
|
|
|
var A = {};
|
|
|
var B = {};
|
|
|
// eslint-disable-next-line no-undef
|
|
|
var S = Symbol();
|
|
|
var K = 'abcdefghijklmnopqrst';
|
|
|
A[S] = 7;
|
|
|
K.split('').forEach(function (k) { B[k] = k; });
|
|
|
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
|
|
|
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
|
|
|
var T = toObject(target);
|
|
|
var aLen = arguments.length;
|
|
|
var index = 1;
|
|
|
var getSymbols = gOPS.f;
|
|
|
var isEnum = pIE.f;
|
|
|
while (aLen > index) {
|
|
|
var S = IObject(arguments[index++]);
|
|
|
var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
|
|
|
var length = keys.length;
|
|
|
var j = 0;
|
|
|
var key;
|
|
|
while (length > j) {
|
|
|
key = keys[j++];
|
|
|
if (!DESCRIPTORS || isEnum.call(S, key)) T[key] = S[key];
|
|
|
}
|
|
|
} return T;
|
|
|
} : $assign;
|
|
|
|
|
|
},{"./_descriptors":103,"./_fails":108,"./_iobject":116,"./_object-gops":137,"./_object-keys":140,"./_object-pie":141,"./_to-object":160}],131:[function(require,module,exports){
|
|
|
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
|
|
|
var anObject = require('./_an-object');
|
|
|
var dPs = require('./_object-dps');
|
|
|
var enumBugKeys = require('./_enum-bug-keys');
|
|
|
var IE_PROTO = require('./_shared-key')('IE_PROTO');
|
|
|
var Empty = function () { /* empty */ };
|
|
|
var PROTOTYPE = 'prototype';
|
|
|
|
|
|
// Create object with fake `null` prototype: use iframe Object with cleared prototype
|
|
|
var createDict = function () {
|
|
|
// Thrash, waste and sodomy: IE GC bug
|
|
|
var iframe = require('./_dom-create')('iframe');
|
|
|
var i = enumBugKeys.length;
|
|
|
var lt = '<';
|
|
|
var gt = '>';
|
|
|
var iframeDocument;
|
|
|
iframe.style.display = 'none';
|
|
|
require('./_html').appendChild(iframe);
|
|
|
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
|
|
|
// createDict = iframe.contentWindow.Object;
|
|
|
// html.removeChild(iframe);
|
|
|
iframeDocument = iframe.contentWindow.document;
|
|
|
iframeDocument.open();
|
|
|
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
|
|
|
iframeDocument.close();
|
|
|
createDict = iframeDocument.F;
|
|
|
while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
|
|
|
return createDict();
|
|
|
};
|
|
|
|
|
|
module.exports = Object.create || function create(O, Properties) {
|
|
|
var result;
|
|
|
if (O !== null) {
|
|
|
Empty[PROTOTYPE] = anObject(O);
|
|
|
result = new Empty();
|
|
|
Empty[PROTOTYPE] = null;
|
|
|
// add "__proto__" for Object.getPrototypeOf polyfill
|
|
|
result[IE_PROTO] = O;
|
|
|
} else result = createDict();
|
|
|
return Properties === undefined ? result : dPs(result, Properties);
|
|
|
};
|
|
|
|
|
|
},{"./_an-object":95,"./_dom-create":104,"./_enum-bug-keys":105,"./_html":113,"./_object-dps":133,"./_shared-key":151}],132:[function(require,module,exports){
|
|
|
var anObject = require('./_an-object');
|
|
|
var IE8_DOM_DEFINE = require('./_ie8-dom-define');
|
|
|
var toPrimitive = require('./_to-primitive');
|
|
|
var dP = Object.defineProperty;
|
|
|
|
|
|
exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
|
|
anObject(O);
|
|
|
P = toPrimitive(P, true);
|
|
|
anObject(Attributes);
|
|
|
if (IE8_DOM_DEFINE) try {
|
|
|
return dP(O, P, Attributes);
|
|
|
} catch (e) { /* empty */ }
|
|
|
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
|
|
|
if ('value' in Attributes) O[P] = Attributes.value;
|
|
|
return O;
|
|
|
};
|
|
|
|
|
|
},{"./_an-object":95,"./_descriptors":103,"./_ie8-dom-define":114,"./_to-primitive":161}],133:[function(require,module,exports){
|
|
|
var dP = require('./_object-dp');
|
|
|
var anObject = require('./_an-object');
|
|
|
var getKeys = require('./_object-keys');
|
|
|
|
|
|
module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
|
anObject(O);
|
|
|
var keys = getKeys(Properties);
|
|
|
var length = keys.length;
|
|
|
var i = 0;
|
|
|
var P;
|
|
|
while (length > i) dP.f(O, P = keys[i++], Properties[P]);
|
|
|
return O;
|
|
|
};
|
|
|
|
|
|
},{"./_an-object":95,"./_descriptors":103,"./_object-dp":132,"./_object-keys":140}],134:[function(require,module,exports){
|
|
|
var pIE = require('./_object-pie');
|
|
|
var createDesc = require('./_property-desc');
|
|
|
var toIObject = require('./_to-iobject');
|
|
|
var toPrimitive = require('./_to-primitive');
|
|
|
var has = require('./_has');
|
|
|
var IE8_DOM_DEFINE = require('./_ie8-dom-define');
|
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
|
|
|
|
exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {
|
|
|
O = toIObject(O);
|
|
|
P = toPrimitive(P, true);
|
|
|
if (IE8_DOM_DEFINE) try {
|
|
|
return gOPD(O, P);
|
|
|
} catch (e) { /* empty */ }
|
|
|
if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
|
|
|
};
|
|
|
|
|
|
},{"./_descriptors":103,"./_has":111,"./_ie8-dom-define":114,"./_object-pie":141,"./_property-desc":146,"./_to-iobject":158,"./_to-primitive":161}],135:[function(require,module,exports){
|
|
|
// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
|
|
|
var toIObject = require('./_to-iobject');
|
|
|
var gOPN = require('./_object-gopn').f;
|
|
|
var toString = {}.toString;
|
|
|
|
|
|
var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
|
|
|
? Object.getOwnPropertyNames(window) : [];
|
|
|
|
|
|
var getWindowNames = function (it) {
|
|
|
try {
|
|
|
return gOPN(it);
|
|
|
} catch (e) {
|
|
|
return windowNames.slice();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports.f = function getOwnPropertyNames(it) {
|
|
|
return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
|
|
|
};
|
|
|
|
|
|
},{"./_object-gopn":136,"./_to-iobject":158}],136:[function(require,module,exports){
|
|
|
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
|
|
|
var $keys = require('./_object-keys-internal');
|
|
|
var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');
|
|
|
|
|
|
exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
|
|
return $keys(O, hiddenKeys);
|
|
|
};
|
|
|
|
|
|
},{"./_enum-bug-keys":105,"./_object-keys-internal":139}],137:[function(require,module,exports){
|
|
|
exports.f = Object.getOwnPropertySymbols;
|
|
|
|
|
|
},{}],138:[function(require,module,exports){
|
|
|
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
|
|
|
var has = require('./_has');
|
|
|
var toObject = require('./_to-object');
|
|
|
var IE_PROTO = require('./_shared-key')('IE_PROTO');
|
|
|
var ObjectProto = Object.prototype;
|
|
|
|
|
|
module.exports = Object.getPrototypeOf || function (O) {
|
|
|
O = toObject(O);
|
|
|
if (has(O, IE_PROTO)) return O[IE_PROTO];
|
|
|
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
|
|
|
return O.constructor.prototype;
|
|
|
} return O instanceof Object ? ObjectProto : null;
|
|
|
};
|
|
|
|
|
|
},{"./_has":111,"./_shared-key":151,"./_to-object":160}],139:[function(require,module,exports){
|
|
|
var has = require('./_has');
|
|
|
var toIObject = require('./_to-iobject');
|
|
|
var arrayIndexOf = require('./_array-includes')(false);
|
|
|
var IE_PROTO = require('./_shared-key')('IE_PROTO');
|
|
|
|
|
|
module.exports = function (object, names) {
|
|
|
var O = toIObject(object);
|
|
|
var i = 0;
|
|
|
var result = [];
|
|
|
var key;
|
|
|
for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
|
|
|
// Don't enum bug & hidden keys
|
|
|
while (names.length > i) if (has(O, key = names[i++])) {
|
|
|
~arrayIndexOf(result, key) || result.push(key);
|
|
|
}
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
},{"./_array-includes":96,"./_has":111,"./_shared-key":151,"./_to-iobject":158}],140:[function(require,module,exports){
|
|
|
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
|
|
|
var $keys = require('./_object-keys-internal');
|
|
|
var enumBugKeys = require('./_enum-bug-keys');
|
|
|
|
|
|
module.exports = Object.keys || function keys(O) {
|
|
|
return $keys(O, enumBugKeys);
|
|
|
};
|
|
|
|
|
|
},{"./_enum-bug-keys":105,"./_object-keys-internal":139}],141:[function(require,module,exports){
|
|
|
exports.f = {}.propertyIsEnumerable;
|
|
|
|
|
|
},{}],142:[function(require,module,exports){
|
|
|
// most Object methods by ES6 should accept primitives
|
|
|
var $export = require('./_export');
|
|
|
var core = require('./_core');
|
|
|
var fails = require('./_fails');
|
|
|
module.exports = function (KEY, exec) {
|
|
|
var fn = (core.Object || {})[KEY] || Object[KEY];
|
|
|
var exp = {};
|
|
|
exp[KEY] = exec(fn);
|
|
|
$export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
|
|
|
};
|
|
|
|
|
|
},{"./_core":99,"./_export":107,"./_fails":108}],143:[function(require,module,exports){
|
|
|
var DESCRIPTORS = require('./_descriptors');
|
|
|
var getKeys = require('./_object-keys');
|
|
|
var toIObject = require('./_to-iobject');
|
|
|
var isEnum = require('./_object-pie').f;
|
|
|
module.exports = function (isEntries) {
|
|
|
return function (it) {
|
|
|
var O = toIObject(it);
|
|
|
var keys = getKeys(O);
|
|
|
var length = keys.length;
|
|
|
var i = 0;
|
|
|
var result = [];
|
|
|
var key;
|
|
|
while (length > i) {
|
|
|
key = keys[i++];
|
|
|
if (!DESCRIPTORS || isEnum.call(O, key)) {
|
|
|
result.push(isEntries ? [key, O[key]] : O[key]);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
};
|
|
|
};
|
|
|
|
|
|
},{"./_descriptors":103,"./_object-keys":140,"./_object-pie":141,"./_to-iobject":158}],144:[function(require,module,exports){
|
|
|
module.exports = function (exec) {
|
|
|
try {
|
|
|
return { e: false, v: exec() };
|
|
|
} catch (e) {
|
|
|
return { e: true, v: e };
|
|
|
}
|
|
|
};
|
|
|
|
|
|
},{}],145:[function(require,module,exports){
|
|
|
var anObject = require('./_an-object');
|
|
|
var isObject = require('./_is-object');
|
|
|
var newPromiseCapability = require('./_new-promise-capability');
|
|
|
|
|
|
module.exports = function (C, x) {
|
|
|
anObject(C);
|
|
|
if (isObject(x) && x.constructor === C) return x;
|
|
|
var promiseCapability = newPromiseCapability.f(C);
|
|
|
var resolve = promiseCapability.resolve;
|
|
|
resolve(x);
|
|
|
return promiseCapability.promise;
|
|
|
};
|
|
|
|
|
|
},{"./_an-object":95,"./_is-object":119,"./_new-promise-capability":129}],146:[function(require,module,exports){
|
|
|
module.exports = function (bitmap, value) {
|
|
|
return {
|
|
|
enumerable: !(bitmap & 1),
|
|
|
configurable: !(bitmap & 2),
|
|
|
writable: !(bitmap & 4),
|
|
|
value: value
|
|
|
};
|
|
|
};
|
|
|
|
|
|
},{}],147:[function(require,module,exports){
|
|
|
var hide = require('./_hide');
|
|
|
module.exports = function (target, src, safe) {
|
|
|
for (var key in src) {
|
|
|
if (safe && target[key]) target[key] = src[key];
|
|
|
else hide(target, key, src[key]);
|
|
|
} return target;
|
|
|
};
|
|
|
|
|
|
},{"./_hide":112}],148:[function(require,module,exports){
|
|
|
module.exports = require('./_hide');
|
|
|
|
|
|
},{"./_hide":112}],149:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var global = require('./_global');
|
|
|
var core = require('./_core');
|
|
|
var dP = require('./_object-dp');
|
|
|
var DESCRIPTORS = require('./_descriptors');
|
|
|
var SPECIES = require('./_wks')('species');
|
|
|
|
|
|
module.exports = function (KEY) {
|
|
|
var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
|
|
|
if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
|
|
|
configurable: true,
|
|
|
get: function () { return this; }
|
|
|
});
|
|
|
};
|
|
|
|
|
|
},{"./_core":99,"./_descriptors":103,"./_global":110,"./_object-dp":132,"./_wks":166}],150:[function(require,module,exports){
|
|
|
var def = require('./_object-dp').f;
|
|
|
var has = require('./_has');
|
|
|
var TAG = require('./_wks')('toStringTag');
|
|
|
|
|
|
module.exports = function (it, tag, stat) {
|
|
|
if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
|
|
|
};
|
|
|
|
|
|
},{"./_has":111,"./_object-dp":132,"./_wks":166}],151:[function(require,module,exports){
|
|
|
var shared = require('./_shared')('keys');
|
|
|
var uid = require('./_uid');
|
|
|
module.exports = function (key) {
|
|
|
return shared[key] || (shared[key] = uid(key));
|
|
|
};
|
|
|
|
|
|
},{"./_shared":152,"./_uid":162}],152:[function(require,module,exports){
|
|
|
var core = require('./_core');
|
|
|
var global = require('./_global');
|
|
|
var SHARED = '__core-js_shared__';
|
|
|
var store = global[SHARED] || (global[SHARED] = {});
|
|
|
|
|
|
(module.exports = function (key, value) {
|
|
|
return store[key] || (store[key] = value !== undefined ? value : {});
|
|
|
})('versions', []).push({
|
|
|
version: core.version,
|
|
|
mode: require('./_library') ? 'pure' : 'global',
|
|
|
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
|
|
|
});
|
|
|
|
|
|
},{"./_core":99,"./_global":110,"./_library":126}],153:[function(require,module,exports){
|
|
|
// 7.3.20 SpeciesConstructor(O, defaultConstructor)
|
|
|
var anObject = require('./_an-object');
|
|
|
var aFunction = require('./_a-function');
|
|
|
var SPECIES = require('./_wks')('species');
|
|
|
module.exports = function (O, D) {
|
|
|
var C = anObject(O).constructor;
|
|
|
var S;
|
|
|
return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
|
|
|
};
|
|
|
|
|
|
},{"./_a-function":92,"./_an-object":95,"./_wks":166}],154:[function(require,module,exports){
|
|
|
var toInteger = require('./_to-integer');
|
|
|
var defined = require('./_defined');
|
|
|
// true -> String#at
|
|
|
// false -> String#codePointAt
|
|
|
module.exports = function (TO_STRING) {
|
|
|
return function (that, pos) {
|
|
|
var s = String(defined(that));
|
|
|
var i = toInteger(pos);
|
|
|
var l = s.length;
|
|
|
var a, b;
|
|
|
if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
|
|
|
a = s.charCodeAt(i);
|
|
|
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
|
|
|
? TO_STRING ? s.charAt(i) : a
|
|
|
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
|
|
|
};
|
|
|
};
|
|
|
|
|
|
},{"./_defined":102,"./_to-integer":157}],155:[function(require,module,exports){
|
|
|
var ctx = require('./_ctx');
|
|
|
var invoke = require('./_invoke');
|
|
|
var html = require('./_html');
|
|
|
var cel = require('./_dom-create');
|
|
|
var global = require('./_global');
|
|
|
var process = global.process;
|
|
|
var setTask = global.setImmediate;
|
|
|
var clearTask = global.clearImmediate;
|
|
|
var MessageChannel = global.MessageChannel;
|
|
|
var Dispatch = global.Dispatch;
|
|
|
var counter = 0;
|
|
|
var queue = {};
|
|
|
var ONREADYSTATECHANGE = 'onreadystatechange';
|
|
|
var defer, channel, port;
|
|
|
var run = function () {
|
|
|
var id = +this;
|
|
|
// eslint-disable-next-line no-prototype-builtins
|
|
|
if (queue.hasOwnProperty(id)) {
|
|
|
var fn = queue[id];
|
|
|
delete queue[id];
|
|
|
fn();
|
|
|
}
|
|
|
};
|
|
|
var listener = function (event) {
|
|
|
run.call(event.data);
|
|
|
};
|
|
|
// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
|
|
|
if (!setTask || !clearTask) {
|
|
|
setTask = function setImmediate(fn) {
|
|
|
var args = [];
|
|
|
var i = 1;
|
|
|
while (arguments.length > i) args.push(arguments[i++]);
|
|
|
queue[++counter] = function () {
|
|
|
// eslint-disable-next-line no-new-func
|
|
|
invoke(typeof fn == 'function' ? fn : Function(fn), args);
|
|
|
};
|
|
|
defer(counter);
|
|
|
return counter;
|
|
|
};
|
|
|
clearTask = function clearImmediate(id) {
|
|
|
delete queue[id];
|
|
|
};
|
|
|
// Node.js 0.8-
|
|
|
if (require('./_cof')(process) == 'process') {
|
|
|
defer = function (id) {
|
|
|
process.nextTick(ctx(run, id, 1));
|
|
|
};
|
|
|
// Sphere (JS game engine) Dispatch API
|
|
|
} else if (Dispatch && Dispatch.now) {
|
|
|
defer = function (id) {
|
|
|
Dispatch.now(ctx(run, id, 1));
|
|
|
};
|
|
|
// Browsers with MessageChannel, includes WebWorkers
|
|
|
} else if (MessageChannel) {
|
|
|
channel = new MessageChannel();
|
|
|
port = channel.port2;
|
|
|
channel.port1.onmessage = listener;
|
|
|
defer = ctx(port.postMessage, port, 1);
|
|
|
// Browsers with postMessage, skip WebWorkers
|
|
|
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
|
|
|
} else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
|
|
|
defer = function (id) {
|
|
|
global.postMessage(id + '', '*');
|
|
|
};
|
|
|
global.addEventListener('message', listener, false);
|
|
|
// IE8-
|
|
|
} else if (ONREADYSTATECHANGE in cel('script')) {
|
|
|
defer = function (id) {
|
|
|
html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
|
|
|
html.removeChild(this);
|
|
|
run.call(id);
|
|
|
};
|
|
|
};
|
|
|
// Rest old browsers
|
|
|
} else {
|
|
|
defer = function (id) {
|
|
|
setTimeout(ctx(run, id, 1), 0);
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
module.exports = {
|
|
|
set: setTask,
|
|
|
clear: clearTask
|
|
|
};
|
|
|
|
|
|
},{"./_cof":98,"./_ctx":101,"./_dom-create":104,"./_global":110,"./_html":113,"./_invoke":115}],156:[function(require,module,exports){
|
|
|
var toInteger = require('./_to-integer');
|
|
|
var max = Math.max;
|
|
|
var min = Math.min;
|
|
|
module.exports = function (index, length) {
|
|
|
index = toInteger(index);
|
|
|
return index < 0 ? max(index + length, 0) : min(index, length);
|
|
|
};
|
|
|
|
|
|
},{"./_to-integer":157}],157:[function(require,module,exports){
|
|
|
// 7.1.4 ToInteger
|
|
|
var ceil = Math.ceil;
|
|
|
var floor = Math.floor;
|
|
|
module.exports = function (it) {
|
|
|
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
|
|
};
|
|
|
|
|
|
},{}],158:[function(require,module,exports){
|
|
|
// to indexed object, toObject with fallback for non-array-like ES3 strings
|
|
|
var IObject = require('./_iobject');
|
|
|
var defined = require('./_defined');
|
|
|
module.exports = function (it) {
|
|
|
return IObject(defined(it));
|
|
|
};
|
|
|
|
|
|
},{"./_defined":102,"./_iobject":116}],159:[function(require,module,exports){
|
|
|
// 7.1.15 ToLength
|
|
|
var toInteger = require('./_to-integer');
|
|
|
var min = Math.min;
|
|
|
module.exports = function (it) {
|
|
|
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
|
|
|
};
|
|
|
|
|
|
},{"./_to-integer":157}],160:[function(require,module,exports){
|
|
|
// 7.1.13 ToObject(argument)
|
|
|
var defined = require('./_defined');
|
|
|
module.exports = function (it) {
|
|
|
return Object(defined(it));
|
|
|
};
|
|
|
|
|
|
},{"./_defined":102}],161:[function(require,module,exports){
|
|
|
// 7.1.1 ToPrimitive(input [, PreferredType])
|
|
|
var isObject = require('./_is-object');
|
|
|
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
|
|
|
// and the second argument - flag - preferred type is a string
|
|
|
module.exports = function (it, S) {
|
|
|
if (!isObject(it)) return it;
|
|
|
var fn, val;
|
|
|
if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
|
|
|
if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
|
|
|
if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
|
|
|
throw TypeError("Can't convert object to primitive value");
|
|
|
};
|
|
|
|
|
|
},{"./_is-object":119}],162:[function(require,module,exports){
|
|
|
var id = 0;
|
|
|
var px = Math.random();
|
|
|
module.exports = function (key) {
|
|
|
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
|
|
};
|
|
|
|
|
|
},{}],163:[function(require,module,exports){
|
|
|
var global = require('./_global');
|
|
|
var navigator = global.navigator;
|
|
|
|
|
|
module.exports = navigator && navigator.userAgent || '';
|
|
|
|
|
|
},{"./_global":110}],164:[function(require,module,exports){
|
|
|
var global = require('./_global');
|
|
|
var core = require('./_core');
|
|
|
var LIBRARY = require('./_library');
|
|
|
var wksExt = require('./_wks-ext');
|
|
|
var defineProperty = require('./_object-dp').f;
|
|
|
module.exports = function (name) {
|
|
|
var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
|
|
|
if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
|
|
|
};
|
|
|
|
|
|
},{"./_core":99,"./_global":110,"./_library":126,"./_object-dp":132,"./_wks-ext":165}],165:[function(require,module,exports){
|
|
|
exports.f = require('./_wks');
|
|
|
|
|
|
},{"./_wks":166}],166:[function(require,module,exports){
|
|
|
var store = require('./_shared')('wks');
|
|
|
var uid = require('./_uid');
|
|
|
var Symbol = require('./_global').Symbol;
|
|
|
var USE_SYMBOL = typeof Symbol == 'function';
|
|
|
|
|
|
var $exports = module.exports = function (name) {
|
|
|
return store[name] || (store[name] =
|
|
|
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
|
|
|
};
|
|
|
|
|
|
$exports.store = store;
|
|
|
|
|
|
},{"./_global":110,"./_shared":152,"./_uid":162}],167:[function(require,module,exports){
|
|
|
var classof = require('./_classof');
|
|
|
var ITERATOR = require('./_wks')('iterator');
|
|
|
var Iterators = require('./_iterators');
|
|
|
module.exports = require('./_core').getIteratorMethod = function (it) {
|
|
|
if (it != undefined) return it[ITERATOR]
|
|
|
|| it['@@iterator']
|
|
|
|| Iterators[classof(it)];
|
|
|
};
|
|
|
|
|
|
},{"./_classof":97,"./_core":99,"./_iterators":125,"./_wks":166}],168:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var ctx = require('./_ctx');
|
|
|
var $export = require('./_export');
|
|
|
var toObject = require('./_to-object');
|
|
|
var call = require('./_iter-call');
|
|
|
var isArrayIter = require('./_is-array-iter');
|
|
|
var toLength = require('./_to-length');
|
|
|
var createProperty = require('./_create-property');
|
|
|
var getIterFn = require('./core.get-iterator-method');
|
|
|
|
|
|
$export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {
|
|
|
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
|
|
|
from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
|
|
|
var O = toObject(arrayLike);
|
|
|
var C = typeof this == 'function' ? this : Array;
|
|
|
var aLen = arguments.length;
|
|
|
var mapfn = aLen > 1 ? arguments[1] : undefined;
|
|
|
var mapping = mapfn !== undefined;
|
|
|
var index = 0;
|
|
|
var iterFn = getIterFn(O);
|
|
|
var length, result, step, iterator;
|
|
|
if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
|
|
|
// if object isn't iterable or it's array with default iterator - use simple case
|
|
|
if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
|
|
|
for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
|
|
|
createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
|
|
|
}
|
|
|
} else {
|
|
|
length = toLength(O.length);
|
|
|
for (result = new C(length); length > index; index++) {
|
|
|
createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
|
|
|
}
|
|
|
}
|
|
|
result.length = index;
|
|
|
return result;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
},{"./_create-property":100,"./_ctx":101,"./_export":107,"./_is-array-iter":117,"./_iter-call":120,"./_iter-detect":123,"./_to-length":159,"./_to-object":160,"./core.get-iterator-method":167}],169:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var addToUnscopables = require('./_add-to-unscopables');
|
|
|
var step = require('./_iter-step');
|
|
|
var Iterators = require('./_iterators');
|
|
|
var toIObject = require('./_to-iobject');
|
|
|
|
|
|
// 22.1.3.4 Array.prototype.entries()
|
|
|
// 22.1.3.13 Array.prototype.keys()
|
|
|
// 22.1.3.29 Array.prototype.values()
|
|
|
// 22.1.3.30 Array.prototype[@@iterator]()
|
|
|
module.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {
|
|
|
this._t = toIObject(iterated); // target
|
|
|
this._i = 0; // next index
|
|
|
this._k = kind; // kind
|
|
|
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
|
|
|
}, function () {
|
|
|
var O = this._t;
|
|
|
var kind = this._k;
|
|
|
var index = this._i++;
|
|
|
if (!O || index >= O.length) {
|
|
|
this._t = undefined;
|
|
|
return step(1);
|
|
|
}
|
|
|
if (kind == 'keys') return step(0, index);
|
|
|
if (kind == 'values') return step(0, O[index]);
|
|
|
return step(0, [index, O[index]]);
|
|
|
}, 'values');
|
|
|
|
|
|
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
|
|
|
Iterators.Arguments = Iterators.Array;
|
|
|
|
|
|
addToUnscopables('keys');
|
|
|
addToUnscopables('values');
|
|
|
addToUnscopables('entries');
|
|
|
|
|
|
},{"./_add-to-unscopables":93,"./_iter-define":122,"./_iter-step":124,"./_iterators":125,"./_to-iobject":158}],170:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var isObject = require('./_is-object');
|
|
|
var getPrototypeOf = require('./_object-gpo');
|
|
|
var HAS_INSTANCE = require('./_wks')('hasInstance');
|
|
|
var FunctionProto = Function.prototype;
|
|
|
// 19.2.3.6 Function.prototype[@@hasInstance](V)
|
|
|
if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, HAS_INSTANCE, { value: function (O) {
|
|
|
if (typeof this != 'function' || !isObject(O)) return false;
|
|
|
if (!isObject(this.prototype)) return O instanceof this;
|
|
|
// for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
|
|
|
while (O = getPrototypeOf(O)) if (this.prototype === O) return true;
|
|
|
return false;
|
|
|
} });
|
|
|
|
|
|
},{"./_is-object":119,"./_object-dp":132,"./_object-gpo":138,"./_wks":166}],171:[function(require,module,exports){
|
|
|
// 19.1.3.1 Object.assign(target, source)
|
|
|
var $export = require('./_export');
|
|
|
|
|
|
$export($export.S + $export.F, 'Object', { assign: require('./_object-assign') });
|
|
|
|
|
|
},{"./_export":107,"./_object-assign":130}],172:[function(require,module,exports){
|
|
|
var $export = require('./_export');
|
|
|
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
|
|
|
$export($export.S, 'Object', { create: require('./_object-create') });
|
|
|
|
|
|
},{"./_export":107,"./_object-create":131}],173:[function(require,module,exports){
|
|
|
var $export = require('./_export');
|
|
|
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
|
|
|
$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });
|
|
|
|
|
|
},{"./_descriptors":103,"./_export":107,"./_object-dp":132}],174:[function(require,module,exports){
|
|
|
// 19.1.2.7 Object.getOwnPropertyNames(O)
|
|
|
require('./_object-sap')('getOwnPropertyNames', function () {
|
|
|
return require('./_object-gopn-ext').f;
|
|
|
});
|
|
|
|
|
|
},{"./_object-gopn-ext":135,"./_object-sap":142}],175:[function(require,module,exports){
|
|
|
// 19.1.2.9 Object.getPrototypeOf(O)
|
|
|
var toObject = require('./_to-object');
|
|
|
var $getPrototypeOf = require('./_object-gpo');
|
|
|
|
|
|
require('./_object-sap')('getPrototypeOf', function () {
|
|
|
return function getPrototypeOf(it) {
|
|
|
return $getPrototypeOf(toObject(it));
|
|
|
};
|
|
|
});
|
|
|
|
|
|
},{"./_object-gpo":138,"./_object-sap":142,"./_to-object":160}],176:[function(require,module,exports){
|
|
|
// 19.1.2.14 Object.keys(O)
|
|
|
var toObject = require('./_to-object');
|
|
|
var $keys = require('./_object-keys');
|
|
|
|
|
|
require('./_object-sap')('keys', function () {
|
|
|
return function keys(it) {
|
|
|
return $keys(toObject(it));
|
|
|
};
|
|
|
});
|
|
|
|
|
|
},{"./_object-keys":140,"./_object-sap":142,"./_to-object":160}],177:[function(require,module,exports){
|
|
|
arguments[4][71][0].apply(exports,arguments)
|
|
|
},{"dup":71}],178:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var LIBRARY = require('./_library');
|
|
|
var global = require('./_global');
|
|
|
var ctx = require('./_ctx');
|
|
|
var classof = require('./_classof');
|
|
|
var $export = require('./_export');
|
|
|
var isObject = require('./_is-object');
|
|
|
var aFunction = require('./_a-function');
|
|
|
var anInstance = require('./_an-instance');
|
|
|
var forOf = require('./_for-of');
|
|
|
var speciesConstructor = require('./_species-constructor');
|
|
|
var task = require('./_task').set;
|
|
|
var microtask = require('./_microtask')();
|
|
|
var newPromiseCapabilityModule = require('./_new-promise-capability');
|
|
|
var perform = require('./_perform');
|
|
|
var userAgent = require('./_user-agent');
|
|
|
var promiseResolve = require('./_promise-resolve');
|
|
|
var PROMISE = 'Promise';
|
|
|
var TypeError = global.TypeError;
|
|
|
var process = global.process;
|
|
|
var versions = process && process.versions;
|
|
|
var v8 = versions && versions.v8 || '';
|
|
|
var $Promise = global[PROMISE];
|
|
|
var isNode = classof(process) == 'process';
|
|
|
var empty = function () { /* empty */ };
|
|
|
var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
|
|
|
var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
|
|
|
|
|
|
var USE_NATIVE = !!function () {
|
|
|
try {
|
|
|
// correct subclassing with @@species support
|
|
|
var promise = $Promise.resolve(1);
|
|
|
var FakePromise = (promise.constructor = {})[require('./_wks')('species')] = function (exec) {
|
|
|
exec(empty, empty);
|
|
|
};
|
|
|
// unhandled rejections tracking support, NodeJS Promise without it fails @@species test
|
|
|
return (isNode || typeof PromiseRejectionEvent == 'function')
|
|
|
&& promise.then(empty) instanceof FakePromise
|
|
|
// v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
|
|
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=830565
|
|
|
// we can't detect it synchronously, so just check versions
|
|
|
&& v8.indexOf('6.6') !== 0
|
|
|
&& userAgent.indexOf('Chrome/66') === -1;
|
|
|
} catch (e) { /* empty */ }
|
|
|
}();
|
|
|
|
|
|
// helpers
|
|
|
var isThenable = function (it) {
|
|
|
var then;
|
|
|
return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
|
|
|
};
|
|
|
var notify = function (promise, isReject) {
|
|
|
if (promise._n) return;
|
|
|
promise._n = true;
|
|
|
var chain = promise._c;
|
|
|
microtask(function () {
|
|
|
var value = promise._v;
|
|
|
var ok = promise._s == 1;
|
|
|
var i = 0;
|
|
|
var run = function (reaction) {
|
|
|
var handler = ok ? reaction.ok : reaction.fail;
|
|
|
var resolve = reaction.resolve;
|
|
|
var reject = reaction.reject;
|
|
|
var domain = reaction.domain;
|
|
|
var result, then, exited;
|
|
|
try {
|
|
|
if (handler) {
|
|
|
if (!ok) {
|
|
|
if (promise._h == 2) onHandleUnhandled(promise);
|
|
|
promise._h = 1;
|
|
|
}
|
|
|
if (handler === true) result = value;
|
|
|
else {
|
|
|
if (domain) domain.enter();
|
|
|
result = handler(value); // may throw
|
|
|
if (domain) {
|
|
|
domain.exit();
|
|
|
exited = true;
|
|
|
}
|
|
|
}
|
|
|
if (result === reaction.promise) {
|
|
|
reject(TypeError('Promise-chain cycle'));
|
|
|
} else if (then = isThenable(result)) {
|
|
|
then.call(result, resolve, reject);
|
|
|
} else resolve(result);
|
|
|
} else reject(value);
|
|
|
} catch (e) {
|
|
|
if (domain && !exited) domain.exit();
|
|
|
reject(e);
|
|
|
}
|
|
|
};
|
|
|
while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
|
|
|
promise._c = [];
|
|
|
promise._n = false;
|
|
|
if (isReject && !promise._h) onUnhandled(promise);
|
|
|
});
|
|
|
};
|
|
|
var onUnhandled = function (promise) {
|
|
|
task.call(global, function () {
|
|
|
var value = promise._v;
|
|
|
var unhandled = isUnhandled(promise);
|
|
|
var result, handler, console;
|
|
|
if (unhandled) {
|
|
|
result = perform(function () {
|
|
|
if (isNode) {
|
|
|
process.emit('unhandledRejection', value, promise);
|
|
|
} else if (handler = global.onunhandledrejection) {
|
|
|
handler({ promise: promise, reason: value });
|
|
|
} else if ((console = global.console) && console.error) {
|
|
|
console.error('Unhandled promise rejection', value);
|
|
|
}
|
|
|
});
|
|
|
// Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
|
|
|
promise._h = isNode || isUnhandled(promise) ? 2 : 1;
|
|
|
} promise._a = undefined;
|
|
|
if (unhandled && result.e) throw result.v;
|
|
|
});
|
|
|
};
|
|
|
var isUnhandled = function (promise) {
|
|
|
return promise._h !== 1 && (promise._a || promise._c).length === 0;
|
|
|
};
|
|
|
var onHandleUnhandled = function (promise) {
|
|
|
task.call(global, function () {
|
|
|
var handler;
|
|
|
if (isNode) {
|
|
|
process.emit('rejectionHandled', promise);
|
|
|
} else if (handler = global.onrejectionhandled) {
|
|
|
handler({ promise: promise, reason: promise._v });
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
var $reject = function (value) {
|
|
|
var promise = this;
|
|
|
if (promise._d) return;
|
|
|
promise._d = true;
|
|
|
promise = promise._w || promise; // unwrap
|
|
|
promise._v = value;
|
|
|
promise._s = 2;
|
|
|
if (!promise._a) promise._a = promise._c.slice();
|
|
|
notify(promise, true);
|
|
|
};
|
|
|
var $resolve = function (value) {
|
|
|
var promise = this;
|
|
|
var then;
|
|
|
if (promise._d) return;
|
|
|
promise._d = true;
|
|
|
promise = promise._w || promise; // unwrap
|
|
|
try {
|
|
|
if (promise === value) throw TypeError("Promise can't be resolved itself");
|
|
|
if (then = isThenable(value)) {
|
|
|
microtask(function () {
|
|
|
var wrapper = { _w: promise, _d: false }; // wrap
|
|
|
try {
|
|
|
then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
|
|
|
} catch (e) {
|
|
|
$reject.call(wrapper, e);
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
promise._v = value;
|
|
|
promise._s = 1;
|
|
|
notify(promise, false);
|
|
|
}
|
|
|
} catch (e) {
|
|
|
$reject.call({ _w: promise, _d: false }, e); // wrap
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// constructor polyfill
|
|
|
if (!USE_NATIVE) {
|
|
|
// 25.4.3.1 Promise(executor)
|
|
|
$Promise = function Promise(executor) {
|
|
|
anInstance(this, $Promise, PROMISE, '_h');
|
|
|
aFunction(executor);
|
|
|
Internal.call(this);
|
|
|
try {
|
|
|
executor(ctx($resolve, this, 1), ctx($reject, this, 1));
|
|
|
} catch (err) {
|
|
|
$reject.call(this, err);
|
|
|
}
|
|
|
};
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
Internal = function Promise(executor) {
|
|
|
this._c = []; // <- awaiting reactions
|
|
|
this._a = undefined; // <- checked in isUnhandled reactions
|
|
|
this._s = 0; // <- state
|
|
|
this._d = false; // <- done
|
|
|
this._v = undefined; // <- value
|
|
|
this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
|
|
|
this._n = false; // <- notify
|
|
|
};
|
|
|
Internal.prototype = require('./_redefine-all')($Promise.prototype, {
|
|
|
// 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
|
|
|
then: function then(onFulfilled, onRejected) {
|
|
|
var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
|
|
|
reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
|
|
|
reaction.fail = typeof onRejected == 'function' && onRejected;
|
|
|
reaction.domain = isNode ? process.domain : undefined;
|
|
|
this._c.push(reaction);
|
|
|
if (this._a) this._a.push(reaction);
|
|
|
if (this._s) notify(this, false);
|
|
|
return reaction.promise;
|
|
|
},
|
|
|
// 25.4.5.1 Promise.prototype.catch(onRejected)
|
|
|
'catch': function (onRejected) {
|
|
|
return this.then(undefined, onRejected);
|
|
|
}
|
|
|
});
|
|
|
OwnPromiseCapability = function () {
|
|
|
var promise = new Internal();
|
|
|
this.promise = promise;
|
|
|
this.resolve = ctx($resolve, promise, 1);
|
|
|
this.reject = ctx($reject, promise, 1);
|
|
|
};
|
|
|
newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
|
|
|
return C === $Promise || C === Wrapper
|
|
|
? new OwnPromiseCapability(C)
|
|
|
: newGenericPromiseCapability(C);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
|
|
|
require('./_set-to-string-tag')($Promise, PROMISE);
|
|
|
require('./_set-species')(PROMISE);
|
|
|
Wrapper = require('./_core')[PROMISE];
|
|
|
|
|
|
// statics
|
|
|
$export($export.S + $export.F * !USE_NATIVE, PROMISE, {
|
|
|
// 25.4.4.5 Promise.reject(r)
|
|
|
reject: function reject(r) {
|
|
|
var capability = newPromiseCapability(this);
|
|
|
var $$reject = capability.reject;
|
|
|
$$reject(r);
|
|
|
return capability.promise;
|
|
|
}
|
|
|
});
|
|
|
$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
|
|
|
// 25.4.4.6 Promise.resolve(x)
|
|
|
resolve: function resolve(x) {
|
|
|
return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
|
|
|
}
|
|
|
});
|
|
|
$export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(function (iter) {
|
|
|
$Promise.all(iter)['catch'](empty);
|
|
|
})), PROMISE, {
|
|
|
// 25.4.4.1 Promise.all(iterable)
|
|
|
all: function all(iterable) {
|
|
|
var C = this;
|
|
|
var capability = newPromiseCapability(C);
|
|
|
var resolve = capability.resolve;
|
|
|
var reject = capability.reject;
|
|
|
var result = perform(function () {
|
|
|
var values = [];
|
|
|
var index = 0;
|
|
|
var remaining = 1;
|
|
|
forOf(iterable, false, function (promise) {
|
|
|
var $index = index++;
|
|
|
var alreadyCalled = false;
|
|
|
values.push(undefined);
|
|
|
remaining++;
|
|
|
C.resolve(promise).then(function (value) {
|
|
|
if (alreadyCalled) return;
|
|
|
alreadyCalled = true;
|
|
|
values[$index] = value;
|
|
|
--remaining || resolve(values);
|
|
|
}, reject);
|
|
|
});
|
|
|
--remaining || resolve(values);
|
|
|
});
|
|
|
if (result.e) reject(result.v);
|
|
|
return capability.promise;
|
|
|
},
|
|
|
// 25.4.4.4 Promise.race(iterable)
|
|
|
race: function race(iterable) {
|
|
|
var C = this;
|
|
|
var capability = newPromiseCapability(C);
|
|
|
var reject = capability.reject;
|
|
|
var result = perform(function () {
|
|
|
forOf(iterable, false, function (promise) {
|
|
|
C.resolve(promise).then(capability.resolve, reject);
|
|
|
});
|
|
|
});
|
|
|
if (result.e) reject(result.v);
|
|
|
return capability.promise;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
},{"./_a-function":92,"./_an-instance":94,"./_classof":97,"./_core":99,"./_ctx":101,"./_export":107,"./_for-of":109,"./_global":110,"./_is-object":119,"./_iter-detect":123,"./_library":126,"./_microtask":128,"./_new-promise-capability":129,"./_perform":144,"./_promise-resolve":145,"./_redefine-all":147,"./_set-species":149,"./_set-to-string-tag":150,"./_species-constructor":153,"./_task":155,"./_user-agent":163,"./_wks":166}],179:[function(require,module,exports){
|
|
|
var $export = require('./_export');
|
|
|
var toAbsoluteIndex = require('./_to-absolute-index');
|
|
|
var fromCharCode = String.fromCharCode;
|
|
|
var $fromCodePoint = String.fromCodePoint;
|
|
|
|
|
|
// length should be 1, old FF problem
|
|
|
$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
|
|
|
// 21.1.2.2 String.fromCodePoint(...codePoints)
|
|
|
fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
|
|
|
var res = [];
|
|
|
var aLen = arguments.length;
|
|
|
var i = 0;
|
|
|
var code;
|
|
|
while (aLen > i) {
|
|
|
code = +arguments[i++];
|
|
|
if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
|
|
|
res.push(code < 0x10000
|
|
|
? fromCharCode(code)
|
|
|
: fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
|
|
|
);
|
|
|
} return res.join('');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
},{"./_export":107,"./_to-absolute-index":156}],180:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
var $at = require('./_string-at')(true);
|
|
|
|
|
|
// 21.1.3.27 String.prototype[@@iterator]()
|
|
|
require('./_iter-define')(String, 'String', function (iterated) {
|
|
|
this._t = String(iterated); // target
|
|
|
this._i = 0; // next index
|
|
|
// 21.1.5.2.1 %StringIteratorPrototype%.next()
|
|
|
}, function () {
|
|
|
var O = this._t;
|
|
|
var index = this._i;
|
|
|
var point;
|
|
|
if (index >= O.length) return { value: undefined, done: true };
|
|
|
point = $at(O, index);
|
|
|
this._i += point.length;
|
|
|
return { value: point, done: false };
|
|
|
});
|
|
|
|
|
|
},{"./_iter-define":122,"./_string-at":154}],181:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
// ECMAScript 6 symbols shim
|
|
|
var global = require('./_global');
|
|
|
var has = require('./_has');
|
|
|
var DESCRIPTORS = require('./_descriptors');
|
|
|
var $export = require('./_export');
|
|
|
var redefine = require('./_redefine');
|
|
|
var META = require('./_meta').KEY;
|
|
|
var $fails = require('./_fails');
|
|
|
var shared = require('./_shared');
|
|
|
var setToStringTag = require('./_set-to-string-tag');
|
|
|
var uid = require('./_uid');
|
|
|
var wks = require('./_wks');
|
|
|
var wksExt = require('./_wks-ext');
|
|
|
var wksDefine = require('./_wks-define');
|
|
|
var enumKeys = require('./_enum-keys');
|
|
|
var isArray = require('./_is-array');
|
|
|
var anObject = require('./_an-object');
|
|
|
var isObject = require('./_is-object');
|
|
|
var toObject = require('./_to-object');
|
|
|
var toIObject = require('./_to-iobject');
|
|
|
var toPrimitive = require('./_to-primitive');
|
|
|
var createDesc = require('./_property-desc');
|
|
|
var _create = require('./_object-create');
|
|
|
var gOPNExt = require('./_object-gopn-ext');
|
|
|
var $GOPD = require('./_object-gopd');
|
|
|
var $GOPS = require('./_object-gops');
|
|
|
var $DP = require('./_object-dp');
|
|
|
var $keys = require('./_object-keys');
|
|
|
var gOPD = $GOPD.f;
|
|
|
var dP = $DP.f;
|
|
|
var gOPN = gOPNExt.f;
|
|
|
var $Symbol = global.Symbol;
|
|
|
var $JSON = global.JSON;
|
|
|
var _stringify = $JSON && $JSON.stringify;
|
|
|
var PROTOTYPE = 'prototype';
|
|
|
var HIDDEN = wks('_hidden');
|
|
|
var TO_PRIMITIVE = wks('toPrimitive');
|
|
|
var isEnum = {}.propertyIsEnumerable;
|
|
|
var SymbolRegistry = shared('symbol-registry');
|
|
|
var AllSymbols = shared('symbols');
|
|
|
var OPSymbols = shared('op-symbols');
|
|
|
var ObjectProto = Object[PROTOTYPE];
|
|
|
var USE_NATIVE = typeof $Symbol == 'function' && !!$GOPS.f;
|
|
|
var QObject = global.QObject;
|
|
|
// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
|
|
|
var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
|
|
|
|
|
|
// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
|
|
|
var setSymbolDesc = DESCRIPTORS && $fails(function () {
|
|
|
return _create(dP({}, 'a', {
|
|
|
get: function () { return dP(this, 'a', { value: 7 }).a; }
|
|
|
})).a != 7;
|
|
|
}) ? function (it, key, D) {
|
|
|
var protoDesc = gOPD(ObjectProto, key);
|
|
|
if (protoDesc) delete ObjectProto[key];
|
|
|
dP(it, key, D);
|
|
|
if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
|
|
|
} : dP;
|
|
|
|
|
|
var wrap = function (tag) {
|
|
|
var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
|
|
|
sym._k = tag;
|
|
|
return sym;
|
|
|
};
|
|
|
|
|
|
var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
|
|
|
return typeof it == 'symbol';
|
|
|
} : function (it) {
|
|
|
return it instanceof $Symbol;
|
|
|
};
|
|
|
|
|
|
var $defineProperty = function defineProperty(it, key, D) {
|
|
|
if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
|
|
|
anObject(it);
|
|
|
key = toPrimitive(key, true);
|
|
|
anObject(D);
|
|
|
if (has(AllSymbols, key)) {
|
|
|
if (!D.enumerable) {
|
|
|
if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
|
|
|
it[HIDDEN][key] = true;
|
|
|
} else {
|
|
|
if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
|
|
|
D = _create(D, { enumerable: createDesc(0, false) });
|
|
|
} return setSymbolDesc(it, key, D);
|
|
|
} return dP(it, key, D);
|
|
|
};
|
|
|
var $defineProperties = function defineProperties(it, P) {
|
|
|
anObject(it);
|
|
|
var keys = enumKeys(P = toIObject(P));
|
|
|
var i = 0;
|
|
|
var l = keys.length;
|
|
|
var key;
|
|
|
while (l > i) $defineProperty(it, key = keys[i++], P[key]);
|
|
|
return it;
|
|
|
};
|
|
|
var $create = function create(it, P) {
|
|
|
return P === undefined ? _create(it) : $defineProperties(_create(it), P);
|
|
|
};
|
|
|
var $propertyIsEnumerable = function propertyIsEnumerable(key) {
|
|
|
var E = isEnum.call(this, key = toPrimitive(key, true));
|
|
|
if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
|
|
|
return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
|
|
|
};
|
|
|
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
|
|
|
it = toIObject(it);
|
|
|
key = toPrimitive(key, true);
|
|
|
if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
|
|
|
var D = gOPD(it, key);
|
|
|
if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
|
|
|
return D;
|
|
|
};
|
|
|
var $getOwnPropertyNames = function getOwnPropertyNames(it) {
|
|
|
var names = gOPN(toIObject(it));
|
|
|
var result = [];
|
|
|
var i = 0;
|
|
|
var key;
|
|
|
while (names.length > i) {
|
|
|
if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
|
|
|
} return result;
|
|
|
};
|
|
|
var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
|
|
|
var IS_OP = it === ObjectProto;
|
|
|
var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
|
|
|
var result = [];
|
|
|
var i = 0;
|
|
|
var key;
|
|
|
while (names.length > i) {
|
|
|
if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
|
|
|
} return result;
|
|
|
};
|
|
|
|
|
|
// 19.4.1.1 Symbol([description])
|
|
|
if (!USE_NATIVE) {
|
|
|
$Symbol = function Symbol() {
|
|
|
if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
|
|
|
var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
|
|
|
var $set = function (value) {
|
|
|
if (this === ObjectProto) $set.call(OPSymbols, value);
|
|
|
if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
|
|
|
setSymbolDesc(this, tag, createDesc(1, value));
|
|
|
};
|
|
|
if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
|
|
|
return wrap(tag);
|
|
|
};
|
|
|
redefine($Symbol[PROTOTYPE], 'toString', function toString() {
|
|
|
return this._k;
|
|
|
});
|
|
|
|
|
|
$GOPD.f = $getOwnPropertyDescriptor;
|
|
|
$DP.f = $defineProperty;
|
|
|
require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;
|
|
|
require('./_object-pie').f = $propertyIsEnumerable;
|
|
|
$GOPS.f = $getOwnPropertySymbols;
|
|
|
|
|
|
if (DESCRIPTORS && !require('./_library')) {
|
|
|
redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
|
|
|
}
|
|
|
|
|
|
wksExt.f = function (name) {
|
|
|
return wrap(wks(name));
|
|
|
};
|
|
|
}
|
|
|
|
|
|
$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
|
|
|
|
|
|
for (var es6Symbols = (
|
|
|
// 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
|
|
|
'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
|
|
|
).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
|
|
|
|
|
|
for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
|
|
|
|
|
|
$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
|
|
|
// 19.4.2.1 Symbol.for(key)
|
|
|
'for': function (key) {
|
|
|
return has(SymbolRegistry, key += '')
|
|
|
? SymbolRegistry[key]
|
|
|
: SymbolRegistry[key] = $Symbol(key);
|
|
|
},
|
|
|
// 19.4.2.5 Symbol.keyFor(sym)
|
|
|
keyFor: function keyFor(sym) {
|
|
|
if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
|
|
|
for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
|
|
|
},
|
|
|
useSetter: function () { setter = true; },
|
|
|
useSimple: function () { setter = false; }
|
|
|
});
|
|
|
|
|
|
$export($export.S + $export.F * !USE_NATIVE, 'Object', {
|
|
|
// 19.1.2.2 Object.create(O [, Properties])
|
|
|
create: $create,
|
|
|
// 19.1.2.4 Object.defineProperty(O, P, Attributes)
|
|
|
defineProperty: $defineProperty,
|
|
|
// 19.1.2.3 Object.defineProperties(O, Properties)
|
|
|
defineProperties: $defineProperties,
|
|
|
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
|
|
|
getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
|
|
|
// 19.1.2.7 Object.getOwnPropertyNames(O)
|
|
|
getOwnPropertyNames: $getOwnPropertyNames,
|
|
|
// 19.1.2.8 Object.getOwnPropertySymbols(O)
|
|
|
getOwnPropertySymbols: $getOwnPropertySymbols
|
|
|
});
|
|
|
|
|
|
// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
|
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3443
|
|
|
var FAILS_ON_PRIMITIVES = $fails(function () { $GOPS.f(1); });
|
|
|
|
|
|
$export($export.S + $export.F * FAILS_ON_PRIMITIVES, 'Object', {
|
|
|
getOwnPropertySymbols: function getOwnPropertySymbols(it) {
|
|
|
return $GOPS.f(toObject(it));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 24.3.2 JSON.stringify(value [, replacer [, space]])
|
|
|
$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
|
|
|
var S = $Symbol();
|
|
|
// MS Edge converts symbol values to JSON as {}
|
|
|
// WebKit converts symbol values to JSON as null
|
|
|
// V8 throws on boxed symbols
|
|
|
return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
|
|
|
})), 'JSON', {
|
|
|
stringify: function stringify(it) {
|
|
|
var args = [it];
|
|
|
var i = 1;
|
|
|
var replacer, $replacer;
|
|
|
while (arguments.length > i) args.push(arguments[i++]);
|
|
|
$replacer = replacer = args[1];
|
|
|
if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
|
|
|
if (!isArray(replacer)) replacer = function (key, value) {
|
|
|
if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
|
|
|
if (!isSymbol(value)) return value;
|
|
|
};
|
|
|
args[1] = replacer;
|
|
|
return _stringify.apply($JSON, args);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
|
|
|
$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
|
|
|
// 19.4.3.5 Symbol.prototype[@@toStringTag]
|
|
|
setToStringTag($Symbol, 'Symbol');
|
|
|
// 20.2.1.9 Math[@@toStringTag]
|
|
|
setToStringTag(Math, 'Math', true);
|
|
|
// 24.3.3 JSON[@@toStringTag]
|
|
|
setToStringTag(global.JSON, 'JSON', true);
|
|
|
|
|
|
},{"./_an-object":95,"./_descriptors":103,"./_enum-keys":106,"./_export":107,"./_fails":108,"./_global":110,"./_has":111,"./_hide":112,"./_is-array":118,"./_is-object":119,"./_library":126,"./_meta":127,"./_object-create":131,"./_object-dp":132,"./_object-gopd":134,"./_object-gopn":136,"./_object-gopn-ext":135,"./_object-gops":137,"./_object-keys":140,"./_object-pie":141,"./_property-desc":146,"./_redefine":148,"./_set-to-string-tag":150,"./_shared":152,"./_to-iobject":158,"./_to-object":160,"./_to-primitive":161,"./_uid":162,"./_wks":166,"./_wks-define":164,"./_wks-ext":165}],182:[function(require,module,exports){
|
|
|
// https://github.com/tc39/proposal-object-values-entries
|
|
|
var $export = require('./_export');
|
|
|
var $entries = require('./_object-to-array')(true);
|
|
|
|
|
|
$export($export.S, 'Object', {
|
|
|
entries: function entries(it) {
|
|
|
return $entries(it);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
},{"./_export":107,"./_object-to-array":143}],183:[function(require,module,exports){
|
|
|
// https://github.com/tc39/proposal-promise-finally
|
|
|
'use strict';
|
|
|
var $export = require('./_export');
|
|
|
var core = require('./_core');
|
|
|
var global = require('./_global');
|
|
|
var speciesConstructor = require('./_species-constructor');
|
|
|
var promiseResolve = require('./_promise-resolve');
|
|
|
|
|
|
$export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
|
|
|
var C = speciesConstructor(this, core.Promise || global.Promise);
|
|
|
var isFunction = typeof onFinally == 'function';
|
|
|
return this.then(
|
|
|
isFunction ? function (x) {
|
|
|
return promiseResolve(C, onFinally()).then(function () { return x; });
|
|
|
} : onFinally,
|
|
|
isFunction ? function (e) {
|
|
|
return promiseResolve(C, onFinally()).then(function () { throw e; });
|
|
|
} : onFinally
|
|
|
);
|
|
|
} });
|
|
|
|
|
|
},{"./_core":99,"./_export":107,"./_global":110,"./_promise-resolve":145,"./_species-constructor":153}],184:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
// https://github.com/tc39/proposal-promise-try
|
|
|
var $export = require('./_export');
|
|
|
var newPromiseCapability = require('./_new-promise-capability');
|
|
|
var perform = require('./_perform');
|
|
|
|
|
|
$export($export.S, 'Promise', { 'try': function (callbackfn) {
|
|
|
var promiseCapability = newPromiseCapability.f(this);
|
|
|
var result = perform(callbackfn);
|
|
|
(result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
|
|
|
return promiseCapability.promise;
|
|
|
} });
|
|
|
|
|
|
},{"./_export":107,"./_new-promise-capability":129,"./_perform":144}],185:[function(require,module,exports){
|
|
|
require('./_wks-define')('asyncIterator');
|
|
|
|
|
|
},{"./_wks-define":164}],186:[function(require,module,exports){
|
|
|
require('./_wks-define')('observable');
|
|
|
|
|
|
},{"./_wks-define":164}],187:[function(require,module,exports){
|
|
|
require('./es6.array.iterator');
|
|
|
var global = require('./_global');
|
|
|
var hide = require('./_hide');
|
|
|
var Iterators = require('./_iterators');
|
|
|
var TO_STRING_TAG = require('./_wks')('toStringTag');
|
|
|
|
|
|
var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
|
|
|
'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
|
|
|
'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
|
|
|
'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
|
|
|
'TextTrackList,TouchList').split(',');
|
|
|
|
|
|
for (var i = 0; i < DOMIterables.length; i++) {
|
|
|
var NAME = DOMIterables[i];
|
|
|
var Collection = global[NAME];
|
|
|
var proto = Collection && Collection.prototype;
|
|
|
if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
|
|
|
Iterators[NAME] = Iterators.Array;
|
|
|
}
|
|
|
|
|
|
},{"./_global":110,"./_hide":112,"./_iterators":125,"./_wks":166,"./es6.array.iterator":169}],188:[function(require,module,exports){
|
|
|
var $export = require('./_export');
|
|
|
var $task = require('./_task');
|
|
|
$export($export.G + $export.B, {
|
|
|
setImmediate: $task.set,
|
|
|
clearImmediate: $task.clear
|
|
|
});
|
|
|
|
|
|
},{"./_export":107,"./_task":155}],189:[function(require,module,exports){
|
|
|
(function (Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
|
// because it is fragile and can be easily faked with `Object.create()`.
|
|
|
|
|
|
function isArray(arg) {
|
|
|
if (Array.isArray) {
|
|
|
return Array.isArray(arg);
|
|
|
}
|
|
|
return objectToString(arg) === '[object Array]';
|
|
|
}
|
|
|
exports.isArray = isArray;
|
|
|
|
|
|
function isBoolean(arg) {
|
|
|
return typeof arg === 'boolean';
|
|
|
}
|
|
|
exports.isBoolean = isBoolean;
|
|
|
|
|
|
function isNull(arg) {
|
|
|
return arg === null;
|
|
|
}
|
|
|
exports.isNull = isNull;
|
|
|
|
|
|
function isNullOrUndefined(arg) {
|
|
|
return arg == null;
|
|
|
}
|
|
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
|
|
|
|
function isNumber(arg) {
|
|
|
return typeof arg === 'number';
|
|
|
}
|
|
|
exports.isNumber = isNumber;
|
|
|
|
|
|
function isString(arg) {
|
|
|
return typeof arg === 'string';
|
|
|
}
|
|
|
exports.isString = isString;
|
|
|
|
|
|
function isSymbol(arg) {
|
|
|
return (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'symbol';
|
|
|
}
|
|
|
exports.isSymbol = isSymbol;
|
|
|
|
|
|
function isUndefined(arg) {
|
|
|
return arg === void 0;
|
|
|
}
|
|
|
exports.isUndefined = isUndefined;
|
|
|
|
|
|
function isRegExp(re) {
|
|
|
return objectToString(re) === '[object RegExp]';
|
|
|
}
|
|
|
exports.isRegExp = isRegExp;
|
|
|
|
|
|
function isObject(arg) {
|
|
|
return (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'object' && arg !== null;
|
|
|
}
|
|
|
exports.isObject = isObject;
|
|
|
|
|
|
function isDate(d) {
|
|
|
return objectToString(d) === '[object Date]';
|
|
|
}
|
|
|
exports.isDate = isDate;
|
|
|
|
|
|
function isError(e) {
|
|
|
return objectToString(e) === '[object Error]' || e instanceof Error;
|
|
|
}
|
|
|
exports.isError = isError;
|
|
|
|
|
|
function isFunction(arg) {
|
|
|
return typeof arg === 'function';
|
|
|
}
|
|
|
exports.isFunction = isFunction;
|
|
|
|
|
|
function isPrimitive(arg) {
|
|
|
return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'symbol' || // ES6 symbol
|
|
|
typeof arg === 'undefined';
|
|
|
}
|
|
|
exports.isPrimitive = isPrimitive;
|
|
|
|
|
|
exports.isBuffer = Buffer.isBuffer;
|
|
|
|
|
|
function objectToString(o) {
|
|
|
return Object.prototype.toString.call(o);
|
|
|
}
|
|
|
|
|
|
}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
|
|
|
},{"../../is-buffer/index.js":197,"babel-runtime/helpers/typeof":67}],190:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
/*
|
|
|
* Date Format 1.2.3
|
|
|
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
|
|
|
* MIT license
|
|
|
*
|
|
|
* Includes enhancements by Scott Trenda <scott.trenda.net>
|
|
|
* and Kris Kowal <cixar.com/~kris.kowal/>
|
|
|
*
|
|
|
* Accepts a date, a mask, or a date and a mask.
|
|
|
* Returns a formatted version of the given date.
|
|
|
* The date defaults to the current date/time.
|
|
|
* The mask defaults to dateFormat.masks.default.
|
|
|
*/
|
|
|
|
|
|
(function (global) {
|
|
|
'use strict';
|
|
|
|
|
|
var dateFormat = function () {
|
|
|
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|'[^']*'|'[^']*'/g;
|
|
|
var timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
|
|
|
var timezoneClip = /[^-+\dA-Z]/g;
|
|
|
|
|
|
// Regexes and supporting functions are cached through closure
|
|
|
return function (date, mask, utc, gmt) {
|
|
|
|
|
|
// You can't provide utc if you skip other args (use the 'UTC:' mask prefix)
|
|
|
if (arguments.length === 1 && kindOf(date) === 'string' && !/\d/.test(date)) {
|
|
|
mask = date;
|
|
|
date = undefined;
|
|
|
}
|
|
|
|
|
|
date = date || new Date();
|
|
|
|
|
|
if (!(date instanceof Date)) {
|
|
|
date = new Date(date);
|
|
|
}
|
|
|
|
|
|
if (isNaN(date)) {
|
|
|
throw TypeError('Invalid date');
|
|
|
}
|
|
|
|
|
|
mask = String(dateFormat.masks[mask] || mask || dateFormat.masks['default']);
|
|
|
|
|
|
// Allow setting the utc/gmt argument via the mask
|
|
|
var maskSlice = mask.slice(0, 4);
|
|
|
if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
|
|
|
mask = mask.slice(4);
|
|
|
utc = true;
|
|
|
if (maskSlice === 'GMT:') {
|
|
|
gmt = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var _ = utc ? 'getUTC' : 'get';
|
|
|
var d = date[_ + 'Date']();
|
|
|
var D = date[_ + 'Day']();
|
|
|
var m = date[_ + 'Month']();
|
|
|
var y = date[_ + 'FullYear']();
|
|
|
var H = date[_ + 'Hours']();
|
|
|
var M = date[_ + 'Minutes']();
|
|
|
var s = date[_ + 'Seconds']();
|
|
|
var L = date[_ + 'Milliseconds']();
|
|
|
var o = utc ? 0 : date.getTimezoneOffset();
|
|
|
var W = getWeek(date);
|
|
|
var N = getDayOfWeek(date);
|
|
|
var flags = {
|
|
|
d: d,
|
|
|
dd: pad(d),
|
|
|
ddd: dateFormat.i18n.dayNames[D],
|
|
|
dddd: dateFormat.i18n.dayNames[D + 7],
|
|
|
m: m + 1,
|
|
|
mm: pad(m + 1),
|
|
|
mmm: dateFormat.i18n.monthNames[m],
|
|
|
mmmm: dateFormat.i18n.monthNames[m + 12],
|
|
|
yy: String(y).slice(2),
|
|
|
yyyy: y,
|
|
|
h: H % 12 || 12,
|
|
|
hh: pad(H % 12 || 12),
|
|
|
H: H,
|
|
|
HH: pad(H),
|
|
|
M: M,
|
|
|
MM: pad(M),
|
|
|
s: s,
|
|
|
ss: pad(s),
|
|
|
l: pad(L, 3),
|
|
|
L: pad(Math.round(L / 10)),
|
|
|
t: H < 12 ? 'a' : 'p',
|
|
|
tt: H < 12 ? 'am' : 'pm',
|
|
|
T: H < 12 ? 'A' : 'P',
|
|
|
TT: H < 12 ? 'AM' : 'PM',
|
|
|
Z: gmt ? 'GMT' : utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''),
|
|
|
o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
|
|
|
S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10],
|
|
|
W: W,
|
|
|
N: N
|
|
|
};
|
|
|
|
|
|
return mask.replace(token, function (match) {
|
|
|
if (match in flags) {
|
|
|
return flags[match];
|
|
|
}
|
|
|
return match.slice(1, match.length - 1);
|
|
|
});
|
|
|
};
|
|
|
}();
|
|
|
|
|
|
dateFormat.masks = {
|
|
|
'default': 'ddd mmm dd yyyy HH:MM:ss',
|
|
|
'shortDate': 'm/d/yy',
|
|
|
'mediumDate': 'mmm d, yyyy',
|
|
|
'longDate': 'mmmm d, yyyy',
|
|
|
'fullDate': 'dddd, mmmm d, yyyy',
|
|
|
'shortTime': 'h:MM TT',
|
|
|
'mediumTime': 'h:MM:ss TT',
|
|
|
'longTime': 'h:MM:ss TT Z',
|
|
|
'isoDate': 'yyyy-mm-dd',
|
|
|
'isoTime': 'HH:MM:ss',
|
|
|
'isoDateTime': 'yyyy-mm-dd\'T\'HH:MM:sso',
|
|
|
'isoUtcDateTime': 'UTC:yyyy-mm-dd\'T\'HH:MM:ss\'Z\'',
|
|
|
'expiresHeaderFormat': 'ddd, dd mmm yyyy HH:MM:ss Z'
|
|
|
};
|
|
|
|
|
|
// Internationalization strings
|
|
|
dateFormat.i18n = {
|
|
|
dayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
|
monthNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
|
|
};
|
|
|
|
|
|
function pad(val, len) {
|
|
|
val = String(val);
|
|
|
len = len || 2;
|
|
|
while (val.length < len) {
|
|
|
val = '0' + val;
|
|
|
}
|
|
|
return val;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the ISO 8601 week number
|
|
|
* Based on comments from
|
|
|
* http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
|
|
|
*
|
|
|
* @param {Object} `date`
|
|
|
* @return {Number}
|
|
|
*/
|
|
|
function getWeek(date) {
|
|
|
// Remove time components of date
|
|
|
var targetThursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
|
|
|
|
// Change date to Thursday same week
|
|
|
targetThursday.setDate(targetThursday.getDate() - (targetThursday.getDay() + 6) % 7 + 3);
|
|
|
|
|
|
// Take January 4th as it is always in week 1 (see ISO 8601)
|
|
|
var firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
|
|
|
|
|
|
// Change date to Thursday same week
|
|
|
firstThursday.setDate(firstThursday.getDate() - (firstThursday.getDay() + 6) % 7 + 3);
|
|
|
|
|
|
// Check if daylight-saving-time-switch occurred and correct for it
|
|
|
var ds = targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
|
|
|
targetThursday.setHours(targetThursday.getHours() - ds);
|
|
|
|
|
|
// Number of weeks between target Thursday and first Thursday
|
|
|
var weekDiff = (targetThursday - firstThursday) / (86400000 * 7);
|
|
|
return 1 + Math.floor(weekDiff);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get ISO-8601 numeric representation of the day of the week
|
|
|
* 1 (for Monday) through 7 (for Sunday)
|
|
|
*
|
|
|
* @param {Object} `date`
|
|
|
* @return {Number}
|
|
|
*/
|
|
|
function getDayOfWeek(date) {
|
|
|
var dow = date.getDay();
|
|
|
if (dow === 0) {
|
|
|
dow = 7;
|
|
|
}
|
|
|
return dow;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* kind-of shortcut
|
|
|
* @param {*} val
|
|
|
* @return {String}
|
|
|
*/
|
|
|
function kindOf(val) {
|
|
|
if (val === null) {
|
|
|
return 'null';
|
|
|
}
|
|
|
|
|
|
if (val === undefined) {
|
|
|
return 'undefined';
|
|
|
}
|
|
|
|
|
|
if ((typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) !== 'object') {
|
|
|
return typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val);
|
|
|
}
|
|
|
|
|
|
if (Array.isArray(val)) {
|
|
|
return 'array';
|
|
|
}
|
|
|
|
|
|
return {}.toString.call(val).slice(8, -1).toLowerCase();
|
|
|
};
|
|
|
|
|
|
if (typeof define === 'function' && define.amd) {
|
|
|
define(function () {
|
|
|
return dateFormat;
|
|
|
});
|
|
|
} else if ((typeof exports === 'undefined' ? 'undefined' : (0, _typeof3.default)(exports)) === 'object') {
|
|
|
module.exports = dateFormat;
|
|
|
} else {
|
|
|
global.dateFormat = dateFormat;
|
|
|
}
|
|
|
})(undefined);
|
|
|
|
|
|
},{"babel-runtime/helpers/typeof":67}],191:[function(require,module,exports){
|
|
|
/*!
|
|
|
* escape-html
|
|
|
* Copyright(c) 2012-2013 TJ Holowaychuk
|
|
|
* Copyright(c) 2015 Andreas Lubbe
|
|
|
* Copyright(c) 2015 Tiancheng "Timothy" Gu
|
|
|
* MIT Licensed
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
/**
|
|
|
* Module variables.
|
|
|
* @private
|
|
|
*/
|
|
|
|
|
|
var matchHtmlRegExp = /["'&<>]/;
|
|
|
|
|
|
/**
|
|
|
* Module exports.
|
|
|
* @public
|
|
|
*/
|
|
|
|
|
|
module.exports = escapeHtml;
|
|
|
|
|
|
/**
|
|
|
* Escape special characters in the given string of html.
|
|
|
*
|
|
|
* @param {string} string The string to escape for inserting into HTML
|
|
|
* @return {string}
|
|
|
* @public
|
|
|
*/
|
|
|
|
|
|
function escapeHtml(string) {
|
|
|
var str = '' + string;
|
|
|
var match = matchHtmlRegExp.exec(str);
|
|
|
|
|
|
if (!match) {
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
var escape;
|
|
|
var html = '';
|
|
|
var index = 0;
|
|
|
var lastIndex = 0;
|
|
|
|
|
|
for (index = match.index; index < str.length; index++) {
|
|
|
switch (str.charCodeAt(index)) {
|
|
|
case 34: // "
|
|
|
escape = '"';
|
|
|
break;
|
|
|
case 38: // &
|
|
|
escape = '&';
|
|
|
break;
|
|
|
case 39: // '
|
|
|
escape = ''';
|
|
|
break;
|
|
|
case 60: // <
|
|
|
escape = '<';
|
|
|
break;
|
|
|
case 62: // >
|
|
|
escape = '>';
|
|
|
break;
|
|
|
default:
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (lastIndex !== index) {
|
|
|
html += str.substring(lastIndex, index);
|
|
|
}
|
|
|
|
|
|
lastIndex = index + 1;
|
|
|
html += escape;
|
|
|
}
|
|
|
|
|
|
return lastIndex !== index
|
|
|
? html + str.substring(lastIndex, index)
|
|
|
: html;
|
|
|
}
|
|
|
|
|
|
},{}],192:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
function EventEmitter() {
|
|
|
this._events = this._events || {};
|
|
|
this._maxListeners = this._maxListeners || undefined;
|
|
|
}
|
|
|
module.exports = EventEmitter;
|
|
|
|
|
|
// Backwards-compat with node 0.10.x
|
|
|
EventEmitter.EventEmitter = EventEmitter;
|
|
|
|
|
|
EventEmitter.prototype._events = undefined;
|
|
|
EventEmitter.prototype._maxListeners = undefined;
|
|
|
|
|
|
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
|
// added to it. This is a useful default which helps finding memory leaks.
|
|
|
EventEmitter.defaultMaxListeners = 10;
|
|
|
|
|
|
// Obviously not all Emitters should be limited to 10. This function allows
|
|
|
// that to be increased. Set to zero for unlimited.
|
|
|
EventEmitter.prototype.setMaxListeners = function(n) {
|
|
|
if (!isNumber(n) || n < 0 || isNaN(n))
|
|
|
throw TypeError('n must be a positive number');
|
|
|
this._maxListeners = n;
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
EventEmitter.prototype.emit = function(type) {
|
|
|
var er, handler, len, args, i, listeners;
|
|
|
|
|
|
if (!this._events)
|
|
|
this._events = {};
|
|
|
|
|
|
// If there is no 'error' event listener then throw.
|
|
|
if (type === 'error') {
|
|
|
if (!this._events.error ||
|
|
|
(isObject(this._events.error) && !this._events.error.length)) {
|
|
|
er = arguments[1];
|
|
|
if (er instanceof Error) {
|
|
|
throw er; // Unhandled 'error' event
|
|
|
} else {
|
|
|
// At least give some kind of context to the user
|
|
|
var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
|
|
|
err.context = er;
|
|
|
throw err;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
handler = this._events[type];
|
|
|
|
|
|
if (isUndefined(handler))
|
|
|
return false;
|
|
|
|
|
|
if (isFunction(handler)) {
|
|
|
switch (arguments.length) {
|
|
|
// fast cases
|
|
|
case 1:
|
|
|
handler.call(this);
|
|
|
break;
|
|
|
case 2:
|
|
|
handler.call(this, arguments[1]);
|
|
|
break;
|
|
|
case 3:
|
|
|
handler.call(this, arguments[1], arguments[2]);
|
|
|
break;
|
|
|
// slower
|
|
|
default:
|
|
|
args = Array.prototype.slice.call(arguments, 1);
|
|
|
handler.apply(this, args);
|
|
|
}
|
|
|
} else if (isObject(handler)) {
|
|
|
args = Array.prototype.slice.call(arguments, 1);
|
|
|
listeners = handler.slice();
|
|
|
len = listeners.length;
|
|
|
for (i = 0; i < len; i++)
|
|
|
listeners[i].apply(this, args);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
EventEmitter.prototype.addListener = function(type, listener) {
|
|
|
var m;
|
|
|
|
|
|
if (!isFunction(listener))
|
|
|
throw TypeError('listener must be a function');
|
|
|
|
|
|
if (!this._events)
|
|
|
this._events = {};
|
|
|
|
|
|
// To avoid recursion in the case that type === "newListener"! Before
|
|
|
// adding it to the listeners, first emit "newListener".
|
|
|
if (this._events.newListener)
|
|
|
this.emit('newListener', type,
|
|
|
isFunction(listener.listener) ?
|
|
|
listener.listener : listener);
|
|
|
|
|
|
if (!this._events[type])
|
|
|
// Optimize the case of one listener. Don't need the extra array object.
|
|
|
this._events[type] = listener;
|
|
|
else if (isObject(this._events[type]))
|
|
|
// If we've already got an array, just append.
|
|
|
this._events[type].push(listener);
|
|
|
else
|
|
|
// Adding the second element, need to change to array.
|
|
|
this._events[type] = [this._events[type], listener];
|
|
|
|
|
|
// Check for listener leak
|
|
|
if (isObject(this._events[type]) && !this._events[type].warned) {
|
|
|
if (!isUndefined(this._maxListeners)) {
|
|
|
m = this._maxListeners;
|
|
|
} else {
|
|
|
m = EventEmitter.defaultMaxListeners;
|
|
|
}
|
|
|
|
|
|
if (m && m > 0 && this._events[type].length > m) {
|
|
|
this._events[type].warned = true;
|
|
|
console.error('(node) warning: possible EventEmitter memory ' +
|
|
|
'leak detected. %d listeners added. ' +
|
|
|
'Use emitter.setMaxListeners() to increase limit.',
|
|
|
this._events[type].length);
|
|
|
if (typeof console.trace === 'function') {
|
|
|
// not supported in IE 10
|
|
|
console.trace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
|
|
|
|
EventEmitter.prototype.once = function(type, listener) {
|
|
|
if (!isFunction(listener))
|
|
|
throw TypeError('listener must be a function');
|
|
|
|
|
|
var fired = false;
|
|
|
|
|
|
function g() {
|
|
|
this.removeListener(type, g);
|
|
|
|
|
|
if (!fired) {
|
|
|
fired = true;
|
|
|
listener.apply(this, arguments);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
g.listener = listener;
|
|
|
this.on(type, g);
|
|
|
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
// emits a 'removeListener' event iff the listener was removed
|
|
|
EventEmitter.prototype.removeListener = function(type, listener) {
|
|
|
var list, position, length, i;
|
|
|
|
|
|
if (!isFunction(listener))
|
|
|
throw TypeError('listener must be a function');
|
|
|
|
|
|
if (!this._events || !this._events[type])
|
|
|
return this;
|
|
|
|
|
|
list = this._events[type];
|
|
|
length = list.length;
|
|
|
position = -1;
|
|
|
|
|
|
if (list === listener ||
|
|
|
(isFunction(list.listener) && list.listener === listener)) {
|
|
|
delete this._events[type];
|
|
|
if (this._events.removeListener)
|
|
|
this.emit('removeListener', type, listener);
|
|
|
|
|
|
} else if (isObject(list)) {
|
|
|
for (i = length; i-- > 0;) {
|
|
|
if (list[i] === listener ||
|
|
|
(list[i].listener && list[i].listener === listener)) {
|
|
|
position = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (position < 0)
|
|
|
return this;
|
|
|
|
|
|
if (list.length === 1) {
|
|
|
list.length = 0;
|
|
|
delete this._events[type];
|
|
|
} else {
|
|
|
list.splice(position, 1);
|
|
|
}
|
|
|
|
|
|
if (this._events.removeListener)
|
|
|
this.emit('removeListener', type, listener);
|
|
|
}
|
|
|
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
EventEmitter.prototype.removeAllListeners = function(type) {
|
|
|
var key, listeners;
|
|
|
|
|
|
if (!this._events)
|
|
|
return this;
|
|
|
|
|
|
// not listening for removeListener, no need to emit
|
|
|
if (!this._events.removeListener) {
|
|
|
if (arguments.length === 0)
|
|
|
this._events = {};
|
|
|
else if (this._events[type])
|
|
|
delete this._events[type];
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
// emit removeListener for all listeners on all events
|
|
|
if (arguments.length === 0) {
|
|
|
for (key in this._events) {
|
|
|
if (key === 'removeListener') continue;
|
|
|
this.removeAllListeners(key);
|
|
|
}
|
|
|
this.removeAllListeners('removeListener');
|
|
|
this._events = {};
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
listeners = this._events[type];
|
|
|
|
|
|
if (isFunction(listeners)) {
|
|
|
this.removeListener(type, listeners);
|
|
|
} else if (listeners) {
|
|
|
// LIFO order
|
|
|
while (listeners.length)
|
|
|
this.removeListener(type, listeners[listeners.length - 1]);
|
|
|
}
|
|
|
delete this._events[type];
|
|
|
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
EventEmitter.prototype.listeners = function(type) {
|
|
|
var ret;
|
|
|
if (!this._events || !this._events[type])
|
|
|
ret = [];
|
|
|
else if (isFunction(this._events[type]))
|
|
|
ret = [this._events[type]];
|
|
|
else
|
|
|
ret = this._events[type].slice();
|
|
|
return ret;
|
|
|
};
|
|
|
|
|
|
EventEmitter.prototype.listenerCount = function(type) {
|
|
|
if (this._events) {
|
|
|
var evlistener = this._events[type];
|
|
|
|
|
|
if (isFunction(evlistener))
|
|
|
return 1;
|
|
|
else if (evlistener)
|
|
|
return evlistener.length;
|
|
|
}
|
|
|
return 0;
|
|
|
};
|
|
|
|
|
|
EventEmitter.listenerCount = function(emitter, type) {
|
|
|
return emitter.listenerCount(type);
|
|
|
};
|
|
|
|
|
|
function isFunction(arg) {
|
|
|
return typeof arg === 'function';
|
|
|
}
|
|
|
|
|
|
function isNumber(arg) {
|
|
|
return typeof arg === 'number';
|
|
|
}
|
|
|
|
|
|
function isObject(arg) {
|
|
|
return typeof arg === 'object' && arg !== null;
|
|
|
}
|
|
|
|
|
|
function isUndefined(arg) {
|
|
|
return arg === void 0;
|
|
|
}
|
|
|
|
|
|
},{}],193:[function(require,module,exports){
|
|
|
var http = require('http');
|
|
|
|
|
|
var https = module.exports;
|
|
|
|
|
|
for (var key in http) {
|
|
|
if (http.hasOwnProperty(key)) https[key] = http[key];
|
|
|
};
|
|
|
|
|
|
https.request = function (params, cb) {
|
|
|
if (!params) params = {};
|
|
|
params.scheme = 'https';
|
|
|
params.protocol = 'https:';
|
|
|
return http.request.call(this, params, cb);
|
|
|
}
|
|
|
|
|
|
},{"http":231}],194:[function(require,module,exports){
|
|
|
/*!
|
|
|
* humanize-ms - index.js
|
|
|
* Copyright(c) 2014 dead_horse <dead_horse@qq.com>
|
|
|
* MIT Licensed
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
/**
|
|
|
* Module dependencies.
|
|
|
*/
|
|
|
|
|
|
var util = require('util');
|
|
|
var ms = require('ms');
|
|
|
|
|
|
module.exports = function (t) {
|
|
|
if (typeof t === 'number') return t;
|
|
|
var r = ms(t);
|
|
|
if (r === undefined) {
|
|
|
var err = new Error(util.format('humanize-ms(%j) result undefined', t));
|
|
|
console.warn(err.stack);
|
|
|
}
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
},{"ms":204,"util":243}],195:[function(require,module,exports){
|
|
|
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
|
var e, m
|
|
|
var eLen = (nBytes * 8) - mLen - 1
|
|
|
var eMax = (1 << eLen) - 1
|
|
|
var eBias = eMax >> 1
|
|
|
var nBits = -7
|
|
|
var i = isLE ? (nBytes - 1) : 0
|
|
|
var d = isLE ? -1 : 1
|
|
|
var s = buffer[offset + i]
|
|
|
|
|
|
i += d
|
|
|
|
|
|
e = s & ((1 << (-nBits)) - 1)
|
|
|
s >>= (-nBits)
|
|
|
nBits += eLen
|
|
|
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
|
|
|
|
m = e & ((1 << (-nBits)) - 1)
|
|
|
e >>= (-nBits)
|
|
|
nBits += mLen
|
|
|
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
|
|
|
|
if (e === 0) {
|
|
|
e = 1 - eBias
|
|
|
} else if (e === eMax) {
|
|
|
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
|
} else {
|
|
|
m = m + Math.pow(2, mLen)
|
|
|
e = e - eBias
|
|
|
}
|
|
|
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
|
}
|
|
|
|
|
|
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
|
var e, m, c
|
|
|
var eLen = (nBytes * 8) - mLen - 1
|
|
|
var eMax = (1 << eLen) - 1
|
|
|
var eBias = eMax >> 1
|
|
|
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
|
|
var i = isLE ? 0 : (nBytes - 1)
|
|
|
var d = isLE ? 1 : -1
|
|
|
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
|
|
|
|
|
value = Math.abs(value)
|
|
|
|
|
|
if (isNaN(value) || value === Infinity) {
|
|
|
m = isNaN(value) ? 1 : 0
|
|
|
e = eMax
|
|
|
} else {
|
|
|
e = Math.floor(Math.log(value) / Math.LN2)
|
|
|
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
|
e--
|
|
|
c *= 2
|
|
|
}
|
|
|
if (e + eBias >= 1) {
|
|
|
value += rt / c
|
|
|
} else {
|
|
|
value += rt * Math.pow(2, 1 - eBias)
|
|
|
}
|
|
|
if (value * c >= 2) {
|
|
|
e++
|
|
|
c /= 2
|
|
|
}
|
|
|
|
|
|
if (e + eBias >= eMax) {
|
|
|
m = 0
|
|
|
e = eMax
|
|
|
} else if (e + eBias >= 1) {
|
|
|
m = ((value * c) - 1) * Math.pow(2, mLen)
|
|
|
e = e + eBias
|
|
|
} else {
|
|
|
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
|
|
e = 0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
|
|
|
|
e = (e << mLen) | m
|
|
|
eLen += mLen
|
|
|
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
|
|
|
|
buffer[offset + i - d] |= s * 128
|
|
|
}
|
|
|
|
|
|
},{}],196:[function(require,module,exports){
|
|
|
if (typeof Object.create === 'function') {
|
|
|
// implementation from standard node.js 'util' module
|
|
|
module.exports = function inherits(ctor, superCtor) {
|
|
|
if (superCtor) {
|
|
|
ctor.super_ = superCtor
|
|
|
ctor.prototype = Object.create(superCtor.prototype, {
|
|
|
constructor: {
|
|
|
value: ctor,
|
|
|
enumerable: false,
|
|
|
writable: true,
|
|
|
configurable: true
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
};
|
|
|
} else {
|
|
|
// old school shim for old browsers
|
|
|
module.exports = function inherits(ctor, superCtor) {
|
|
|
if (superCtor) {
|
|
|
ctor.super_ = superCtor
|
|
|
var TempCtor = function () {}
|
|
|
TempCtor.prototype = superCtor.prototype
|
|
|
ctor.prototype = new TempCtor()
|
|
|
ctor.prototype.constructor = ctor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},{}],197:[function(require,module,exports){
|
|
|
/*!
|
|
|
* Determine if an object is a Buffer
|
|
|
*
|
|
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
|
* @license MIT
|
|
|
*/
|
|
|
|
|
|
// The _isBuffer check is for Safari 5-7 support, because it's missing
|
|
|
// Object.prototype.constructor. Remove this eventually
|
|
|
module.exports = function (obj) {
|
|
|
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
|
|
|
}
|
|
|
|
|
|
function isBuffer (obj) {
|
|
|
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
|
|
|
}
|
|
|
|
|
|
// For Node v0.10 support. Remove this eventually.
|
|
|
function isSlowBuffer (obj) {
|
|
|
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
|
|
|
}
|
|
|
|
|
|
},{}],198:[function(require,module,exports){
|
|
|
var toString = {}.toString;
|
|
|
|
|
|
module.exports = Array.isArray || function (arr) {
|
|
|
return toString.call(arr) == '[object Array]';
|
|
|
};
|
|
|
|
|
|
},{}],199:[function(require,module,exports){
|
|
|
(function (global){
|
|
|
/*
|
|
|
* base64.js
|
|
|
*
|
|
|
* Licensed under the BSD 3-Clause License.
|
|
|
* http://opensource.org/licenses/BSD-3-Clause
|
|
|
*
|
|
|
* References:
|
|
|
* http://en.wikipedia.org/wiki/Base64
|
|
|
*/
|
|
|
;(function (global, factory) {
|
|
|
typeof exports === 'object' && typeof module !== 'undefined'
|
|
|
? module.exports = factory(global)
|
|
|
: typeof define === 'function' && define.amd
|
|
|
? define(factory) : factory(global)
|
|
|
}((
|
|
|
typeof self !== 'undefined' ? self
|
|
|
: typeof window !== 'undefined' ? window
|
|
|
: typeof global !== 'undefined' ? global
|
|
|
: this
|
|
|
), function(global) {
|
|
|
'use strict';
|
|
|
// existing version for noConflict()
|
|
|
global = global || {};
|
|
|
var _Base64 = global.Base64;
|
|
|
var version = "2.5.2";
|
|
|
// if node.js and NOT React Native, we use Buffer
|
|
|
var buffer;
|
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
|
try {
|
|
|
buffer = eval("require('buffer').Buffer");
|
|
|
} catch (err) {
|
|
|
buffer = undefined;
|
|
|
}
|
|
|
}
|
|
|
// constants
|
|
|
var b64chars
|
|
|
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
var b64tab = function(bin) {
|
|
|
var t = {};
|
|
|
for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
|
|
|
return t;
|
|
|
}(b64chars);
|
|
|
var fromCharCode = String.fromCharCode;
|
|
|
// encoder stuff
|
|
|
var cb_utob = function(c) {
|
|
|
if (c.length < 2) {
|
|
|
var cc = c.charCodeAt(0);
|
|
|
return cc < 0x80 ? c
|
|
|
: cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
|
|
|
+ fromCharCode(0x80 | (cc & 0x3f)))
|
|
|
: (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
|
|
|
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
|
|
|
+ fromCharCode(0x80 | ( cc & 0x3f)));
|
|
|
} else {
|
|
|
var cc = 0x10000
|
|
|
+ (c.charCodeAt(0) - 0xD800) * 0x400
|
|
|
+ (c.charCodeAt(1) - 0xDC00);
|
|
|
return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
|
|
|
+ fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
|
|
|
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
|
|
|
+ fromCharCode(0x80 | ( cc & 0x3f)));
|
|
|
}
|
|
|
};
|
|
|
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
|
|
var utob = function(u) {
|
|
|
return u.replace(re_utob, cb_utob);
|
|
|
};
|
|
|
var cb_encode = function(ccc) {
|
|
|
var padlen = [0, 2, 1][ccc.length % 3],
|
|
|
ord = ccc.charCodeAt(0) << 16
|
|
|
| ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
|
|
|
| ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
|
|
|
chars = [
|
|
|
b64chars.charAt( ord >>> 18),
|
|
|
b64chars.charAt((ord >>> 12) & 63),
|
|
|
padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
|
|
|
padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
|
|
|
];
|
|
|
return chars.join('');
|
|
|
};
|
|
|
var btoa = global.btoa ? function(b) {
|
|
|
return global.btoa(b);
|
|
|
} : function(b) {
|
|
|
return b.replace(/[\s\S]{1,3}/g, cb_encode);
|
|
|
};
|
|
|
var _encode = function(u) {
|
|
|
var isUint8Array = Object.prototype.toString.call(u) === '[object Uint8Array]';
|
|
|
return isUint8Array ? u.toString('base64')
|
|
|
: btoa(utob(String(u)));
|
|
|
}
|
|
|
var encode = function(u, urisafe) {
|
|
|
return !urisafe
|
|
|
? _encode(u)
|
|
|
: _encode(String(u)).replace(/[+\/]/g, function(m0) {
|
|
|
return m0 == '+' ? '-' : '_';
|
|
|
}).replace(/=/g, '');
|
|
|
};
|
|
|
var encodeURI = function(u) { return encode(u, true) };
|
|
|
// decoder stuff
|
|
|
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
|
|
var cb_btou = function(cccc) {
|
|
|
switch(cccc.length) {
|
|
|
case 4:
|
|
|
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
|
|
|
| ((0x3f & cccc.charCodeAt(1)) << 12)
|
|
|
| ((0x3f & cccc.charCodeAt(2)) << 6)
|
|
|
| (0x3f & cccc.charCodeAt(3)),
|
|
|
offset = cp - 0x10000;
|
|
|
return (fromCharCode((offset >>> 10) + 0xD800)
|
|
|
+ fromCharCode((offset & 0x3FF) + 0xDC00));
|
|
|
case 3:
|
|
|
return fromCharCode(
|
|
|
((0x0f & cccc.charCodeAt(0)) << 12)
|
|
|
| ((0x3f & cccc.charCodeAt(1)) << 6)
|
|
|
| (0x3f & cccc.charCodeAt(2))
|
|
|
);
|
|
|
default:
|
|
|
return fromCharCode(
|
|
|
((0x1f & cccc.charCodeAt(0)) << 6)
|
|
|
| (0x3f & cccc.charCodeAt(1))
|
|
|
);
|
|
|
}
|
|
|
};
|
|
|
var btou = function(b) {
|
|
|
return b.replace(re_btou, cb_btou);
|
|
|
};
|
|
|
var cb_decode = function(cccc) {
|
|
|
var len = cccc.length,
|
|
|
padlen = len % 4,
|
|
|
n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
|
|
|
| (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
|
|
|
| (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
|
|
|
| (len > 3 ? b64tab[cccc.charAt(3)] : 0),
|
|
|
chars = [
|
|
|
fromCharCode( n >>> 16),
|
|
|
fromCharCode((n >>> 8) & 0xff),
|
|
|
fromCharCode( n & 0xff)
|
|
|
];
|
|
|
chars.length -= [0, 0, 2, 1][padlen];
|
|
|
return chars.join('');
|
|
|
};
|
|
|
var _atob = global.atob ? function(a) {
|
|
|
return global.atob(a);
|
|
|
} : function(a){
|
|
|
return a.replace(/\S{1,4}/g, cb_decode);
|
|
|
};
|
|
|
var atob = function(a) {
|
|
|
return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
|
|
|
};
|
|
|
var _decode = buffer ?
|
|
|
buffer.from && Uint8Array && buffer.from !== Uint8Array.from
|
|
|
? function(a) {
|
|
|
return (a.constructor === buffer.constructor
|
|
|
? a : buffer.from(a, 'base64')).toString();
|
|
|
}
|
|
|
: function(a) {
|
|
|
return (a.constructor === buffer.constructor
|
|
|
? a : new buffer(a, 'base64')).toString();
|
|
|
}
|
|
|
: function(a) { return btou(_atob(a)) };
|
|
|
var decode = function(a){
|
|
|
return _decode(
|
|
|
String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
|
|
|
.replace(/[^A-Za-z0-9\+\/]/g, '')
|
|
|
);
|
|
|
};
|
|
|
var noConflict = function() {
|
|
|
var Base64 = global.Base64;
|
|
|
global.Base64 = _Base64;
|
|
|
return Base64;
|
|
|
};
|
|
|
// export Base64
|
|
|
global.Base64 = {
|
|
|
VERSION: version,
|
|
|
atob: atob,
|
|
|
btoa: btoa,
|
|
|
fromBase64: decode,
|
|
|
toBase64: encode,
|
|
|
utob: utob,
|
|
|
encode: encode,
|
|
|
encodeURI: encodeURI,
|
|
|
btou: btou,
|
|
|
decode: decode,
|
|
|
noConflict: noConflict,
|
|
|
__buffer__: buffer
|
|
|
};
|
|
|
// if ES5 is available, make Base64.extendString() available
|
|
|
if (typeof Object.defineProperty === 'function') {
|
|
|
var noEnum = function(v){
|
|
|
return {value:v,enumerable:false,writable:true,configurable:true};
|
|
|
};
|
|
|
global.Base64.extendString = function () {
|
|
|
Object.defineProperty(
|
|
|
String.prototype, 'fromBase64', noEnum(function () {
|
|
|
return decode(this)
|
|
|
}));
|
|
|
Object.defineProperty(
|
|
|
String.prototype, 'toBase64', noEnum(function (urisafe) {
|
|
|
return encode(this, urisafe)
|
|
|
}));
|
|
|
Object.defineProperty(
|
|
|
String.prototype, 'toBase64URI', noEnum(function () {
|
|
|
return encode(this, true)
|
|
|
}));
|
|
|
};
|
|
|
}
|
|
|
//
|
|
|
// export Base64 to the namespace
|
|
|
//
|
|
|
if (global['Meteor']) { // Meteor.js
|
|
|
Base64 = global.Base64;
|
|
|
}
|
|
|
// module.exports and AMD are mutually exclusive.
|
|
|
// module.exports has precedence.
|
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
|
module.exports.Base64 = global.Base64;
|
|
|
}
|
|
|
else if (typeof define === 'function' && define.amd) {
|
|
|
// AMD. Register as an anonymous module.
|
|
|
define([], function(){ return global.Base64 });
|
|
|
}
|
|
|
// that's it!
|
|
|
return {Base64: global.Base64}
|
|
|
}));
|
|
|
|
|
|
|
|
|
}).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{}],200:[function(require,module,exports){
|
|
|
/*!
|
|
|
* merge-descriptors
|
|
|
* Copyright(c) 2014 Jonathan Ong
|
|
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
|
* MIT Licensed
|
|
|
*/
|
|
|
|
|
|
'use strict'
|
|
|
|
|
|
/**
|
|
|
* Module exports.
|
|
|
* @public
|
|
|
*/
|
|
|
|
|
|
module.exports = merge
|
|
|
|
|
|
/**
|
|
|
* Module variables.
|
|
|
* @private
|
|
|
*/
|
|
|
|
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty
|
|
|
|
|
|
/**
|
|
|
* Merge the property descriptors of `src` into `dest`
|
|
|
*
|
|
|
* @param {object} dest Object to add descriptors to
|
|
|
* @param {object} src Object to clone descriptors from
|
|
|
* @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
|
|
|
* @returns {object} Reference to dest
|
|
|
* @public
|
|
|
*/
|
|
|
|
|
|
function merge(dest, src, redefine) {
|
|
|
if (!dest) {
|
|
|
throw new TypeError('argument dest is required')
|
|
|
}
|
|
|
|
|
|
if (!src) {
|
|
|
throw new TypeError('argument src is required')
|
|
|
}
|
|
|
|
|
|
if (redefine === undefined) {
|
|
|
// Default to true
|
|
|
redefine = true
|
|
|
}
|
|
|
|
|
|
Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {
|
|
|
if (!redefine && hasOwnProperty.call(dest, name)) {
|
|
|
// Skip desriptor
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// Copy descriptor
|
|
|
var descriptor = Object.getOwnPropertyDescriptor(src, name)
|
|
|
Object.defineProperty(dest, name, descriptor)
|
|
|
})
|
|
|
|
|
|
return dest
|
|
|
}
|
|
|
|
|
|
},{}],201:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
/**
|
|
|
* @param typeMap [Object] Map of MIME type -> Array[extensions]
|
|
|
* @param ...
|
|
|
*/
|
|
|
function Mime() {
|
|
|
this._types = Object.create(null);
|
|
|
this._extensions = Object.create(null);
|
|
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
|
this.define(arguments[i]);
|
|
|
}
|
|
|
|
|
|
this.define = this.define.bind(this);
|
|
|
this.getType = this.getType.bind(this);
|
|
|
this.getExtension = this.getExtension.bind(this);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
|
|
* to an array of extensions associated with the type. The first extension is
|
|
|
* used as the default extension for the type.
|
|
|
*
|
|
|
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
|
|
*
|
|
|
* If a type declares an extension that has already been defined, an error will
|
|
|
* be thrown. To suppress this error and force the extension to be associated
|
|
|
* with the new type, pass `force`=true. Alternatively, you may prefix the
|
|
|
* extension with "*" to map the type to extension, without mapping the
|
|
|
* extension to the type.
|
|
|
*
|
|
|
* e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
|
|
|
*
|
|
|
*
|
|
|
* @param map (Object) type definitions
|
|
|
* @param force (Boolean) if true, force overriding of existing definitions
|
|
|
*/
|
|
|
Mime.prototype.define = function(typeMap, force) {
|
|
|
for (var type in typeMap) {
|
|
|
var extensions = typeMap[type].map(function(t) {return t.toLowerCase()});
|
|
|
type = type.toLowerCase();
|
|
|
|
|
|
for (var i = 0; i < extensions.length; i++) {
|
|
|
var ext = extensions[i];
|
|
|
|
|
|
// '*' prefix = not the preferred type for this extension. So fixup the
|
|
|
// extension, and skip it.
|
|
|
if (ext[0] == '*') {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (!force && (ext in this._types)) {
|
|
|
throw new Error(
|
|
|
'Attempt to change mapping for "' + ext +
|
|
|
'" extension from "' + this._types[ext] + '" to "' + type +
|
|
|
'". Pass `force=true` to allow this, otherwise remove "' + ext +
|
|
|
'" from the list of extensions for "' + type + '".'
|
|
|
);
|
|
|
}
|
|
|
|
|
|
this._types[ext] = type;
|
|
|
}
|
|
|
|
|
|
// Use first extension as default
|
|
|
if (force || !this._extensions[type]) {
|
|
|
var ext = extensions[0];
|
|
|
this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1)
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Lookup a mime type based on extension
|
|
|
*/
|
|
|
Mime.prototype.getType = function(path) {
|
|
|
path = String(path);
|
|
|
var last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
|
|
var ext = last.replace(/^.*\./, '').toLowerCase();
|
|
|
|
|
|
var hasPath = last.length < path.length;
|
|
|
var hasDot = ext.length < last.length - 1;
|
|
|
|
|
|
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Return file extension associated with a mime type
|
|
|
*/
|
|
|
Mime.prototype.getExtension = function(type) {
|
|
|
type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
|
|
|
return type && this._extensions[type.toLowerCase()] || null;
|
|
|
};
|
|
|
|
|
|
module.exports = Mime;
|
|
|
|
|
|
},{}],202:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var Mime = require('./Mime');
|
|
|
module.exports = new Mime(require('./types/standard'));
|
|
|
|
|
|
},{"./Mime":201,"./types/standard":203}],203:[function(require,module,exports){
|
|
|
module.exports = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/urc-ressheet+xml":["rsheet"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};
|
|
|
},{}],204:[function(require,module,exports){
|
|
|
/**
|
|
|
* Helpers.
|
|
|
*/
|
|
|
|
|
|
var s = 1000;
|
|
|
var m = s * 60;
|
|
|
var h = m * 60;
|
|
|
var d = h * 24;
|
|
|
var w = d * 7;
|
|
|
var y = d * 365.25;
|
|
|
|
|
|
/**
|
|
|
* Parse or format the given `val`.
|
|
|
*
|
|
|
* Options:
|
|
|
*
|
|
|
* - `long` verbose formatting [false]
|
|
|
*
|
|
|
* @param {String|Number} val
|
|
|
* @param {Object} [options]
|
|
|
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
|
* @return {String|Number}
|
|
|
* @api public
|
|
|
*/
|
|
|
|
|
|
module.exports = function(val, options) {
|
|
|
options = options || {};
|
|
|
var type = typeof val;
|
|
|
if (type === 'string' && val.length > 0) {
|
|
|
return parse(val);
|
|
|
} else if (type === 'number' && isFinite(val)) {
|
|
|
return options.long ? fmtLong(val) : fmtShort(val);
|
|
|
}
|
|
|
throw new Error(
|
|
|
'val is not a non-empty string or a valid number. val=' +
|
|
|
JSON.stringify(val)
|
|
|
);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Parse the given `str` and return milliseconds.
|
|
|
*
|
|
|
* @param {String} str
|
|
|
* @return {Number}
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
function parse(str) {
|
|
|
str = String(str);
|
|
|
if (str.length > 100) {
|
|
|
return;
|
|
|
}
|
|
|
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(
|
|
|
str
|
|
|
);
|
|
|
if (!match) {
|
|
|
return;
|
|
|
}
|
|
|
var n = parseFloat(match[1]);
|
|
|
var type = (match[2] || 'ms').toLowerCase();
|
|
|
switch (type) {
|
|
|
case 'years':
|
|
|
case 'year':
|
|
|
case 'yrs':
|
|
|
case 'yr':
|
|
|
case 'y':
|
|
|
return n * y;
|
|
|
case 'weeks':
|
|
|
case 'week':
|
|
|
case 'w':
|
|
|
return n * w;
|
|
|
case 'days':
|
|
|
case 'day':
|
|
|
case 'd':
|
|
|
return n * d;
|
|
|
case 'hours':
|
|
|
case 'hour':
|
|
|
case 'hrs':
|
|
|
case 'hr':
|
|
|
case 'h':
|
|
|
return n * h;
|
|
|
case 'minutes':
|
|
|
case 'minute':
|
|
|
case 'mins':
|
|
|
case 'min':
|
|
|
case 'm':
|
|
|
return n * m;
|
|
|
case 'seconds':
|
|
|
case 'second':
|
|
|
case 'secs':
|
|
|
case 'sec':
|
|
|
case 's':
|
|
|
return n * s;
|
|
|
case 'milliseconds':
|
|
|
case 'millisecond':
|
|
|
case 'msecs':
|
|
|
case 'msec':
|
|
|
case 'ms':
|
|
|
return n;
|
|
|
default:
|
|
|
return undefined;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Short format for `ms`.
|
|
|
*
|
|
|
* @param {Number} ms
|
|
|
* @return {String}
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
function fmtShort(ms) {
|
|
|
var msAbs = Math.abs(ms);
|
|
|
if (msAbs >= d) {
|
|
|
return Math.round(ms / d) + 'd';
|
|
|
}
|
|
|
if (msAbs >= h) {
|
|
|
return Math.round(ms / h) + 'h';
|
|
|
}
|
|
|
if (msAbs >= m) {
|
|
|
return Math.round(ms / m) + 'm';
|
|
|
}
|
|
|
if (msAbs >= s) {
|
|
|
return Math.round(ms / s) + 's';
|
|
|
}
|
|
|
return ms + 'ms';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Long format for `ms`.
|
|
|
*
|
|
|
* @param {Number} ms
|
|
|
* @return {String}
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
function fmtLong(ms) {
|
|
|
var msAbs = Math.abs(ms);
|
|
|
if (msAbs >= d) {
|
|
|
return plural(ms, msAbs, d, 'day');
|
|
|
}
|
|
|
if (msAbs >= h) {
|
|
|
return plural(ms, msAbs, h, 'hour');
|
|
|
}
|
|
|
if (msAbs >= m) {
|
|
|
return plural(ms, msAbs, m, 'minute');
|
|
|
}
|
|
|
if (msAbs >= s) {
|
|
|
return plural(ms, msAbs, s, 'second');
|
|
|
}
|
|
|
return ms + ' ms';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Pluralization helper.
|
|
|
*/
|
|
|
|
|
|
function plural(ms, msAbs, n, name) {
|
|
|
var isPlural = msAbs >= n * 1.5;
|
|
|
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
|
|
}
|
|
|
|
|
|
},{}],205:[function(require,module,exports){
|
|
|
(function (process){
|
|
|
// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
|
|
|
// backported and transplited with Babel, with backwards-compat fixes
|
|
|
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
// resolves . and .. elements in a path array with directory names there
|
|
|
// must be no slashes, empty elements, or device names (c:\) in the array
|
|
|
// (so also no leading and trailing slashes - it does not distinguish
|
|
|
// relative and absolute paths)
|
|
|
function normalizeArray(parts, allowAboveRoot) {
|
|
|
// if the path tries to go above the root, `up` ends up > 0
|
|
|
var up = 0;
|
|
|
for (var i = parts.length - 1; i >= 0; i--) {
|
|
|
var last = parts[i];
|
|
|
if (last === '.') {
|
|
|
parts.splice(i, 1);
|
|
|
} else if (last === '..') {
|
|
|
parts.splice(i, 1);
|
|
|
up++;
|
|
|
} else if (up) {
|
|
|
parts.splice(i, 1);
|
|
|
up--;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if the path is allowed to go above the root, restore leading ..s
|
|
|
if (allowAboveRoot) {
|
|
|
for (; up--; up) {
|
|
|
parts.unshift('..');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return parts;
|
|
|
}
|
|
|
|
|
|
// path.resolve([from ...], to)
|
|
|
// posix version
|
|
|
exports.resolve = function() {
|
|
|
var resolvedPath = '',
|
|
|
resolvedAbsolute = false;
|
|
|
|
|
|
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
|
var path = (i >= 0) ? arguments[i] : process.cwd();
|
|
|
|
|
|
// Skip empty and invalid entries
|
|
|
if (typeof path !== 'string') {
|
|
|
throw new TypeError('Arguments to path.resolve must be strings');
|
|
|
} else if (!path) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
resolvedPath = path + '/' + resolvedPath;
|
|
|
resolvedAbsolute = path.charAt(0) === '/';
|
|
|
}
|
|
|
|
|
|
// At this point the path should be resolved to a full absolute path, but
|
|
|
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
|
|
|
|
// Normalize the path
|
|
|
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
|
|
return !!p;
|
|
|
}), !resolvedAbsolute).join('/');
|
|
|
|
|
|
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
|
|
};
|
|
|
|
|
|
// path.normalize(path)
|
|
|
// posix version
|
|
|
exports.normalize = function(path) {
|
|
|
var isAbsolute = exports.isAbsolute(path),
|
|
|
trailingSlash = substr(path, -1) === '/';
|
|
|
|
|
|
// Normalize the path
|
|
|
path = normalizeArray(filter(path.split('/'), function(p) {
|
|
|
return !!p;
|
|
|
}), !isAbsolute).join('/');
|
|
|
|
|
|
if (!path && !isAbsolute) {
|
|
|
path = '.';
|
|
|
}
|
|
|
if (path && trailingSlash) {
|
|
|
path += '/';
|
|
|
}
|
|
|
|
|
|
return (isAbsolute ? '/' : '') + path;
|
|
|
};
|
|
|
|
|
|
// posix version
|
|
|
exports.isAbsolute = function(path) {
|
|
|
return path.charAt(0) === '/';
|
|
|
};
|
|
|
|
|
|
// posix version
|
|
|
exports.join = function() {
|
|
|
var paths = Array.prototype.slice.call(arguments, 0);
|
|
|
return exports.normalize(filter(paths, function(p, index) {
|
|
|
if (typeof p !== 'string') {
|
|
|
throw new TypeError('Arguments to path.join must be strings');
|
|
|
}
|
|
|
return p;
|
|
|
}).join('/'));
|
|
|
};
|
|
|
|
|
|
|
|
|
// path.relative(from, to)
|
|
|
// posix version
|
|
|
exports.relative = function(from, to) {
|
|
|
from = exports.resolve(from).substr(1);
|
|
|
to = exports.resolve(to).substr(1);
|
|
|
|
|
|
function trim(arr) {
|
|
|
var start = 0;
|
|
|
for (; start < arr.length; start++) {
|
|
|
if (arr[start] !== '') break;
|
|
|
}
|
|
|
|
|
|
var end = arr.length - 1;
|
|
|
for (; end >= 0; end--) {
|
|
|
if (arr[end] !== '') break;
|
|
|
}
|
|
|
|
|
|
if (start > end) return [];
|
|
|
return arr.slice(start, end - start + 1);
|
|
|
}
|
|
|
|
|
|
var fromParts = trim(from.split('/'));
|
|
|
var toParts = trim(to.split('/'));
|
|
|
|
|
|
var length = Math.min(fromParts.length, toParts.length);
|
|
|
var samePartsLength = length;
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
if (fromParts[i] !== toParts[i]) {
|
|
|
samePartsLength = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var outputParts = [];
|
|
|
for (var i = samePartsLength; i < fromParts.length; i++) {
|
|
|
outputParts.push('..');
|
|
|
}
|
|
|
|
|
|
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
|
|
|
|
|
return outputParts.join('/');
|
|
|
};
|
|
|
|
|
|
exports.sep = '/';
|
|
|
exports.delimiter = ':';
|
|
|
|
|
|
exports.dirname = function (path) {
|
|
|
if (typeof path !== 'string') path = path + '';
|
|
|
if (path.length === 0) return '.';
|
|
|
var code = path.charCodeAt(0);
|
|
|
var hasRoot = code === 47 /*/*/;
|
|
|
var end = -1;
|
|
|
var matchedSlash = true;
|
|
|
for (var i = path.length - 1; i >= 1; --i) {
|
|
|
code = path.charCodeAt(i);
|
|
|
if (code === 47 /*/*/) {
|
|
|
if (!matchedSlash) {
|
|
|
end = i;
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
|
// We saw the first non-path separator
|
|
|
matchedSlash = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (end === -1) return hasRoot ? '/' : '.';
|
|
|
if (hasRoot && end === 1) {
|
|
|
// return '//';
|
|
|
// Backwards-compat fix:
|
|
|
return '/';
|
|
|
}
|
|
|
return path.slice(0, end);
|
|
|
};
|
|
|
|
|
|
function basename(path) {
|
|
|
if (typeof path !== 'string') path = path + '';
|
|
|
|
|
|
var start = 0;
|
|
|
var end = -1;
|
|
|
var matchedSlash = true;
|
|
|
var i;
|
|
|
|
|
|
for (i = path.length - 1; i >= 0; --i) {
|
|
|
if (path.charCodeAt(i) === 47 /*/*/) {
|
|
|
// If we reached a path separator that was not part of a set of path
|
|
|
// separators at the end of the string, stop now
|
|
|
if (!matchedSlash) {
|
|
|
start = i + 1;
|
|
|
break;
|
|
|
}
|
|
|
} else if (end === -1) {
|
|
|
// We saw the first non-path separator, mark this as the end of our
|
|
|
// path component
|
|
|
matchedSlash = false;
|
|
|
end = i + 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (end === -1) return '';
|
|
|
return path.slice(start, end);
|
|
|
}
|
|
|
|
|
|
// Uses a mixed approach for backwards-compatibility, as ext behavior changed
|
|
|
// in new Node.js versions, so only basename() above is backported here
|
|
|
exports.basename = function (path, ext) {
|
|
|
var f = basename(path);
|
|
|
if (ext && f.substr(-1 * ext.length) === ext) {
|
|
|
f = f.substr(0, f.length - ext.length);
|
|
|
}
|
|
|
return f;
|
|
|
};
|
|
|
|
|
|
exports.extname = function (path) {
|
|
|
if (typeof path !== 'string') path = path + '';
|
|
|
var startDot = -1;
|
|
|
var startPart = 0;
|
|
|
var end = -1;
|
|
|
var matchedSlash = true;
|
|
|
// Track the state of characters (if any) we see before our first dot and
|
|
|
// after any path separator we find
|
|
|
var preDotState = 0;
|
|
|
for (var i = path.length - 1; i >= 0; --i) {
|
|
|
var code = path.charCodeAt(i);
|
|
|
if (code === 47 /*/*/) {
|
|
|
// If we reached a path separator that was not part of a set of path
|
|
|
// separators at the end of the string, stop now
|
|
|
if (!matchedSlash) {
|
|
|
startPart = i + 1;
|
|
|
break;
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
if (end === -1) {
|
|
|
// We saw the first non-path separator, mark this as the end of our
|
|
|
// extension
|
|
|
matchedSlash = false;
|
|
|
end = i + 1;
|
|
|
}
|
|
|
if (code === 46 /*.*/) {
|
|
|
// If this is our first dot, mark it as the start of our extension
|
|
|
if (startDot === -1)
|
|
|
startDot = i;
|
|
|
else if (preDotState !== 1)
|
|
|
preDotState = 1;
|
|
|
} else if (startDot !== -1) {
|
|
|
// We saw a non-dot and non-path separator before our dot, so we should
|
|
|
// have a good chance at having a non-empty extension
|
|
|
preDotState = -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (startDot === -1 || end === -1 ||
|
|
|
// We saw a non-dot character immediately before the dot
|
|
|
preDotState === 0 ||
|
|
|
// The (right-most) trimmed path component is exactly '..'
|
|
|
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
|
return '';
|
|
|
}
|
|
|
return path.slice(startDot, end);
|
|
|
};
|
|
|
|
|
|
function filter (xs, f) {
|
|
|
if (xs.filter) return xs.filter(f);
|
|
|
var res = [];
|
|
|
for (var i = 0; i < xs.length; i++) {
|
|
|
if (f(xs[i], i, xs)) res.push(xs[i]);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
// String.prototype.substr - negative index don't work in IE8
|
|
|
var substr = true
|
|
|
? function (str, start, len) { return str.substr(start, len) }
|
|
|
: 0
|
|
|
;
|
|
|
|
|
|
}).call(this,require('_process'))
|
|
|
},{"_process":208}],206:[function(require,module,exports){
|
|
|
(function (global){
|
|
|
/*!
|
|
|
* Platform.js <https://mths.be/platform>
|
|
|
* Copyright 2014-2018 Benjamin Tan <https://bnjmnt4n.now.sh/>
|
|
|
* Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
|
|
|
* Available under MIT license <https://mths.be/mit>
|
|
|
*/
|
|
|
;(function() {
|
|
|
'use strict';
|
|
|
|
|
|
/** Used to determine if values are of the language type `Object`. */
|
|
|
var objectTypes = {
|
|
|
'function': true,
|
|
|
'object': true
|
|
|
};
|
|
|
|
|
|
/** Used as a reference to the global object. */
|
|
|
var root = (objectTypes[typeof window] && window) || this;
|
|
|
|
|
|
/** Backup possible global object. */
|
|
|
var oldRoot = root;
|
|
|
|
|
|
/** Detect free variable `exports`. */
|
|
|
var freeExports = objectTypes[typeof exports] && exports;
|
|
|
|
|
|
/** Detect free variable `module`. */
|
|
|
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
|
|
|
|
|
/** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
|
|
|
var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
|
|
|
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
|
|
|
root = freeGlobal;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Used as the maximum length of an array-like object.
|
|
|
* See the [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
|
|
|
* for more details.
|
|
|
*/
|
|
|
var maxSafeInteger = Math.pow(2, 53) - 1;
|
|
|
|
|
|
/** Regular expression to detect Opera. */
|
|
|
var reOpera = /\bOpera/;
|
|
|
|
|
|
/** Possible global object. */
|
|
|
var thisBinding = this;
|
|
|
|
|
|
/** Used for native method references. */
|
|
|
var objectProto = Object.prototype;
|
|
|
|
|
|
/** Used to check for own properties of an object. */
|
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
|
|
|
|
/** Used to resolve the internal `[[Class]]` of values. */
|
|
|
var toString = objectProto.toString;
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
/**
|
|
|
* Capitalizes a string value.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {string} string The string to capitalize.
|
|
|
* @returns {string} The capitalized string.
|
|
|
*/
|
|
|
function capitalize(string) {
|
|
|
string = String(string);
|
|
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* A utility function to clean up the OS name.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {string} os The OS name to clean up.
|
|
|
* @param {string} [pattern] A `RegExp` pattern matching the OS name.
|
|
|
* @param {string} [label] A label for the OS.
|
|
|
*/
|
|
|
function cleanupOS(os, pattern, label) {
|
|
|
// Platform tokens are defined at:
|
|
|
// http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
|
|
|
// http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
|
|
|
var data = {
|
|
|
'10.0': '10',
|
|
|
'6.4': '10 Technical Preview',
|
|
|
'6.3': '8.1',
|
|
|
'6.2': '8',
|
|
|
'6.1': 'Server 2008 R2 / 7',
|
|
|
'6.0': 'Server 2008 / Vista',
|
|
|
'5.2': 'Server 2003 / XP 64-bit',
|
|
|
'5.1': 'XP',
|
|
|
'5.01': '2000 SP1',
|
|
|
'5.0': '2000',
|
|
|
'4.0': 'NT',
|
|
|
'4.90': 'ME'
|
|
|
};
|
|
|
// Detect Windows version from platform tokens.
|
|
|
if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) &&
|
|
|
(data = data[/[\d.]+$/.exec(os)])) {
|
|
|
os = 'Windows ' + data;
|
|
|
}
|
|
|
// Correct character case and cleanup string.
|
|
|
os = String(os);
|
|
|
|
|
|
if (pattern && label) {
|
|
|
os = os.replace(RegExp(pattern, 'i'), label);
|
|
|
}
|
|
|
|
|
|
os = format(
|
|
|
os.replace(/ ce$/i, ' CE')
|
|
|
.replace(/\bhpw/i, 'web')
|
|
|
.replace(/\bMacintosh\b/, 'Mac OS')
|
|
|
.replace(/_PowerPC\b/i, ' OS')
|
|
|
.replace(/\b(OS X) [^ \d]+/i, '$1')
|
|
|
.replace(/\bMac (OS X)\b/, '$1')
|
|
|
.replace(/\/(\d)/, ' $1')
|
|
|
.replace(/_/g, '.')
|
|
|
.replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '')
|
|
|
.replace(/\bx86\.64\b/gi, 'x86_64')
|
|
|
.replace(/\b(Windows Phone) OS\b/, '$1')
|
|
|
.replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1')
|
|
|
.split(' on ')[0]
|
|
|
);
|
|
|
|
|
|
return os;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* An iteration utility for arrays and objects.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Array|Object} object The object to iterate over.
|
|
|
* @param {Function} callback The function called per iteration.
|
|
|
*/
|
|
|
function each(object, callback) {
|
|
|
var index = -1,
|
|
|
length = object ? object.length : 0;
|
|
|
|
|
|
if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
|
|
|
while (++index < length) {
|
|
|
callback(object[index], index, object);
|
|
|
}
|
|
|
} else {
|
|
|
forOwn(object, callback);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Trim and conditionally capitalize string values.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {string} string The string to format.
|
|
|
* @returns {string} The formatted string.
|
|
|
*/
|
|
|
function format(string) {
|
|
|
string = trim(string);
|
|
|
return /^(?:webOS|i(?:OS|P))/.test(string)
|
|
|
? string
|
|
|
: capitalize(string);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Iterates over an object's own properties, executing the `callback` for each.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Object} object The object to iterate over.
|
|
|
* @param {Function} callback The function executed per own property.
|
|
|
*/
|
|
|
function forOwn(object, callback) {
|
|
|
for (var key in object) {
|
|
|
if (hasOwnProperty.call(object, key)) {
|
|
|
callback(object[key], key, object);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Gets the internal `[[Class]]` of a value.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {*} value The value.
|
|
|
* @returns {string} The `[[Class]]`.
|
|
|
*/
|
|
|
function getClassOf(value) {
|
|
|
return value == null
|
|
|
? capitalize(value)
|
|
|
: toString.call(value).slice(8, -1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Host objects can return type values that are different from their actual
|
|
|
* data type. The objects we are concerned with usually return non-primitive
|
|
|
* types of "object", "function", or "unknown".
|
|
|
*
|
|
|
* @private
|
|
|
* @param {*} object The owner of the property.
|
|
|
* @param {string} property The property to check.
|
|
|
* @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.
|
|
|
*/
|
|
|
function isHostType(object, property) {
|
|
|
var type = object != null ? typeof object[property] : 'number';
|
|
|
return !/^(?:boolean|number|string|undefined)$/.test(type) &&
|
|
|
(type == 'object' ? !!object[property] : true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Prepares a string for use in a `RegExp` by making hyphens and spaces optional.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {string} string The string to qualify.
|
|
|
* @returns {string} The qualified string.
|
|
|
*/
|
|
|
function qualify(string) {
|
|
|
return String(string).replace(/([ -])(?!$)/g, '$1?');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* A bare-bones `Array#reduce` like utility function.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Array} array The array to iterate over.
|
|
|
* @param {Function} callback The function called per iteration.
|
|
|
* @returns {*} The accumulated result.
|
|
|
*/
|
|
|
function reduce(array, callback) {
|
|
|
var accumulator = null;
|
|
|
each(array, function(value, index) {
|
|
|
accumulator = callback(accumulator, value, index, array);
|
|
|
});
|
|
|
return accumulator;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Removes leading and trailing whitespace from a string.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {string} string The string to trim.
|
|
|
* @returns {string} The trimmed string.
|
|
|
*/
|
|
|
function trim(string) {
|
|
|
return String(string).replace(/^ +| +$/g, '');
|
|
|
}
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
/**
|
|
|
* Creates a new platform object.
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @param {Object|string} [ua=navigator.userAgent] The user agent string or
|
|
|
* context object.
|
|
|
* @returns {Object} A platform object.
|
|
|
*/
|
|
|
function parse(ua) {
|
|
|
|
|
|
/** The environment context object. */
|
|
|
var context = root;
|
|
|
|
|
|
/** Used to flag when a custom context is provided. */
|
|
|
var isCustomContext = ua && typeof ua == 'object' && getClassOf(ua) != 'String';
|
|
|
|
|
|
// Juggle arguments.
|
|
|
if (isCustomContext) {
|
|
|
context = ua;
|
|
|
ua = null;
|
|
|
}
|
|
|
|
|
|
/** Browser navigator object. */
|
|
|
var nav = context.navigator || {};
|
|
|
|
|
|
/** Browser user agent string. */
|
|
|
var userAgent = nav.userAgent || '';
|
|
|
|
|
|
ua || (ua = userAgent);
|
|
|
|
|
|
/** Used to flag when `thisBinding` is the [ModuleScope]. */
|
|
|
var isModuleScope = isCustomContext || thisBinding == oldRoot;
|
|
|
|
|
|
/** Used to detect if browser is like Chrome. */
|
|
|
var likeChrome = isCustomContext
|
|
|
? !!nav.likeChrome
|
|
|
: /\bChrome\b/.test(ua) && !/internal|\n/i.test(toString.toString());
|
|
|
|
|
|
/** Internal `[[Class]]` value shortcuts. */
|
|
|
var objectClass = 'Object',
|
|
|
airRuntimeClass = isCustomContext ? objectClass : 'ScriptBridgingProxyObject',
|
|
|
enviroClass = isCustomContext ? objectClass : 'Environment',
|
|
|
javaClass = (isCustomContext && context.java) ? 'JavaPackage' : getClassOf(context.java),
|
|
|
phantomClass = isCustomContext ? objectClass : 'RuntimeObject';
|
|
|
|
|
|
/** Detect Java environments. */
|
|
|
var java = /\bJava/.test(javaClass) && context.java;
|
|
|
|
|
|
/** Detect Rhino. */
|
|
|
var rhino = java && getClassOf(context.environment) == enviroClass;
|
|
|
|
|
|
/** A character to represent alpha. */
|
|
|
var alpha = java ? 'a' : '\u03b1';
|
|
|
|
|
|
/** A character to represent beta. */
|
|
|
var beta = java ? 'b' : '\u03b2';
|
|
|
|
|
|
/** Browser document object. */
|
|
|
var doc = context.document || {};
|
|
|
|
|
|
/**
|
|
|
* Detect Opera browser (Presto-based).
|
|
|
* http://www.howtocreate.co.uk/operaStuff/operaObject.html
|
|
|
* http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini
|
|
|
*/
|
|
|
var opera = context.operamini || context.opera;
|
|
|
|
|
|
/** Opera `[[Class]]`. */
|
|
|
var operaClass = reOpera.test(operaClass = (isCustomContext && opera) ? opera['[[Class]]'] : getClassOf(opera))
|
|
|
? operaClass
|
|
|
: (opera = null);
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
/** Temporary variable used over the script's lifetime. */
|
|
|
var data;
|
|
|
|
|
|
/** The CPU architecture. */
|
|
|
var arch = ua;
|
|
|
|
|
|
/** Platform description array. */
|
|
|
var description = [];
|
|
|
|
|
|
/** Platform alpha/beta indicator. */
|
|
|
var prerelease = null;
|
|
|
|
|
|
/** A flag to indicate that environment features should be used to resolve the platform. */
|
|
|
var useFeatures = ua == userAgent;
|
|
|
|
|
|
/** The browser/environment version. */
|
|
|
var version = useFeatures && opera && typeof opera.version == 'function' && opera.version();
|
|
|
|
|
|
/** A flag to indicate if the OS ends with "/ Version" */
|
|
|
var isSpecialCasedOS;
|
|
|
|
|
|
/* Detectable layout engines (order is important). */
|
|
|
var layout = getLayout([
|
|
|
{ 'label': 'EdgeHTML', 'pattern': 'Edge' },
|
|
|
'Trident',
|
|
|
{ 'label': 'WebKit', 'pattern': 'AppleWebKit' },
|
|
|
'iCab',
|
|
|
'Presto',
|
|
|
'NetFront',
|
|
|
'Tasman',
|
|
|
'KHTML',
|
|
|
'Gecko'
|
|
|
]);
|
|
|
|
|
|
/* Detectable browser names (order is important). */
|
|
|
var name = getName([
|
|
|
'Adobe AIR',
|
|
|
'Arora',
|
|
|
'Avant Browser',
|
|
|
'Breach',
|
|
|
'Camino',
|
|
|
'Electron',
|
|
|
'Epiphany',
|
|
|
'Fennec',
|
|
|
'Flock',
|
|
|
'Galeon',
|
|
|
'GreenBrowser',
|
|
|
'iCab',
|
|
|
'Iceweasel',
|
|
|
'K-Meleon',
|
|
|
'Konqueror',
|
|
|
'Lunascape',
|
|
|
'Maxthon',
|
|
|
{ 'label': 'Microsoft Edge', 'pattern': 'Edge' },
|
|
|
'Midori',
|
|
|
'Nook Browser',
|
|
|
'PaleMoon',
|
|
|
'PhantomJS',
|
|
|
'Raven',
|
|
|
'Rekonq',
|
|
|
'RockMelt',
|
|
|
{ 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' },
|
|
|
'SeaMonkey',
|
|
|
{ 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
|
|
|
'Sleipnir',
|
|
|
'SlimBrowser',
|
|
|
{ 'label': 'SRWare Iron', 'pattern': 'Iron' },
|
|
|
'Sunrise',
|
|
|
'Swiftfox',
|
|
|
'Waterfox',
|
|
|
'WebPositive',
|
|
|
'Opera Mini',
|
|
|
{ 'label': 'Opera Mini', 'pattern': 'OPiOS' },
|
|
|
'Opera',
|
|
|
{ 'label': 'Opera', 'pattern': 'OPR' },
|
|
|
'Chrome',
|
|
|
{ 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
|
|
|
{ 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
|
|
|
{ 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },
|
|
|
{ 'label': 'IE', 'pattern': 'IEMobile' },
|
|
|
{ 'label': 'IE', 'pattern': 'MSIE' },
|
|
|
'Safari'
|
|
|
]);
|
|
|
|
|
|
/* Detectable products (order is important). */
|
|
|
var product = getProduct([
|
|
|
{ 'label': 'BlackBerry', 'pattern': 'BB10' },
|
|
|
'BlackBerry',
|
|
|
{ 'label': 'Galaxy S', 'pattern': 'GT-I9000' },
|
|
|
{ 'label': 'Galaxy S2', 'pattern': 'GT-I9100' },
|
|
|
{ 'label': 'Galaxy S3', 'pattern': 'GT-I9300' },
|
|
|
{ 'label': 'Galaxy S4', 'pattern': 'GT-I9500' },
|
|
|
{ 'label': 'Galaxy S5', 'pattern': 'SM-G900' },
|
|
|
{ 'label': 'Galaxy S6', 'pattern': 'SM-G920' },
|
|
|
{ 'label': 'Galaxy S6 Edge', 'pattern': 'SM-G925' },
|
|
|
{ 'label': 'Galaxy S7', 'pattern': 'SM-G930' },
|
|
|
{ 'label': 'Galaxy S7 Edge', 'pattern': 'SM-G935' },
|
|
|
'Google TV',
|
|
|
'Lumia',
|
|
|
'iPad',
|
|
|
'iPod',
|
|
|
'iPhone',
|
|
|
'Kindle',
|
|
|
{ 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
|
|
|
'Nexus',
|
|
|
'Nook',
|
|
|
'PlayBook',
|
|
|
'PlayStation Vita',
|
|
|
'PlayStation',
|
|
|
'TouchPad',
|
|
|
'Transformer',
|
|
|
{ 'label': 'Wii U', 'pattern': 'WiiU' },
|
|
|
'Wii',
|
|
|
'Xbox One',
|
|
|
{ 'label': 'Xbox 360', 'pattern': 'Xbox' },
|
|
|
'Xoom'
|
|
|
]);
|
|
|
|
|
|
/* Detectable manufacturers. */
|
|
|
var manufacturer = getManufacturer({
|
|
|
'Apple': { 'iPad': 1, 'iPhone': 1, 'iPod': 1 },
|
|
|
'Archos': {},
|
|
|
'Amazon': { 'Kindle': 1, 'Kindle Fire': 1 },
|
|
|
'Asus': { 'Transformer': 1 },
|
|
|
'Barnes & Noble': { 'Nook': 1 },
|
|
|
'BlackBerry': { 'PlayBook': 1 },
|
|
|
'Google': { 'Google TV': 1, 'Nexus': 1 },
|
|
|
'HP': { 'TouchPad': 1 },
|
|
|
'HTC': {},
|
|
|
'LG': {},
|
|
|
'Microsoft': { 'Xbox': 1, 'Xbox One': 1 },
|
|
|
'Motorola': { 'Xoom': 1 },
|
|
|
'Nintendo': { 'Wii U': 1, 'Wii': 1 },
|
|
|
'Nokia': { 'Lumia': 1 },
|
|
|
'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1, 'Galaxy S3': 1, 'Galaxy S4': 1 },
|
|
|
'Sony': { 'PlayStation': 1, 'PlayStation Vita': 1 }
|
|
|
});
|
|
|
|
|
|
/* Detectable operating systems (order is important). */
|
|
|
var os = getOS([
|
|
|
'Windows Phone',
|
|
|
'Android',
|
|
|
'CentOS',
|
|
|
{ 'label': 'Chrome OS', 'pattern': 'CrOS' },
|
|
|
'Debian',
|
|
|
'Fedora',
|
|
|
'FreeBSD',
|
|
|
'Gentoo',
|
|
|
'Haiku',
|
|
|
'Kubuntu',
|
|
|
'Linux Mint',
|
|
|
'OpenBSD',
|
|
|
'Red Hat',
|
|
|
'SuSE',
|
|
|
'Ubuntu',
|
|
|
'Xubuntu',
|
|
|
'Cygwin',
|
|
|
'Symbian OS',
|
|
|
'hpwOS',
|
|
|
'webOS ',
|
|
|
'webOS',
|
|
|
'Tablet OS',
|
|
|
'Tizen',
|
|
|
'Linux',
|
|
|
'Mac OS X',
|
|
|
'Macintosh',
|
|
|
'Mac',
|
|
|
'Windows 98;',
|
|
|
'Windows '
|
|
|
]);
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
/**
|
|
|
* Picks the layout engine from an array of guesses.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Array} guesses An array of guesses.
|
|
|
* @returns {null|string} The detected layout engine.
|
|
|
*/
|
|
|
function getLayout(guesses) {
|
|
|
return reduce(guesses, function(result, guess) {
|
|
|
return result || RegExp('\\b' + (
|
|
|
guess.pattern || qualify(guess)
|
|
|
) + '\\b', 'i').exec(ua) && (guess.label || guess);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Picks the manufacturer from an array of guesses.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Array} guesses An object of guesses.
|
|
|
* @returns {null|string} The detected manufacturer.
|
|
|
*/
|
|
|
function getManufacturer(guesses) {
|
|
|
return reduce(guesses, function(result, value, key) {
|
|
|
// Lookup the manufacturer by product or scan the UA for the manufacturer.
|
|
|
return result || (
|
|
|
value[product] ||
|
|
|
value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] ||
|
|
|
RegExp('\\b' + qualify(key) + '(?:\\b|\\w*\\d)', 'i').exec(ua)
|
|
|
) && key;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Picks the browser name from an array of guesses.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Array} guesses An array of guesses.
|
|
|
* @returns {null|string} The detected browser name.
|
|
|
*/
|
|
|
function getName(guesses) {
|
|
|
return reduce(guesses, function(result, guess) {
|
|
|
return result || RegExp('\\b' + (
|
|
|
guess.pattern || qualify(guess)
|
|
|
) + '\\b', 'i').exec(ua) && (guess.label || guess);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Picks the OS name from an array of guesses.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Array} guesses An array of guesses.
|
|
|
* @returns {null|string} The detected OS name.
|
|
|
*/
|
|
|
function getOS(guesses) {
|
|
|
return reduce(guesses, function(result, guess) {
|
|
|
var pattern = guess.pattern || qualify(guess);
|
|
|
if (!result && (result =
|
|
|
RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua)
|
|
|
)) {
|
|
|
result = cleanupOS(result, pattern, guess.label || guess);
|
|
|
}
|
|
|
return result;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Picks the product name from an array of guesses.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Array} guesses An array of guesses.
|
|
|
* @returns {null|string} The detected product name.
|
|
|
*/
|
|
|
function getProduct(guesses) {
|
|
|
return reduce(guesses, function(result, guess) {
|
|
|
var pattern = guess.pattern || qualify(guess);
|
|
|
if (!result && (result =
|
|
|
RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) ||
|
|
|
RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||
|
|
|
RegExp('\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)', 'i').exec(ua)
|
|
|
)) {
|
|
|
// Split by forward slash and append product version if needed.
|
|
|
if ((result = String((guess.label && !RegExp(pattern, 'i').test(guess.label)) ? guess.label : result).split('/'))[1] && !/[\d.]+/.test(result[0])) {
|
|
|
result[0] += ' ' + result[1];
|
|
|
}
|
|
|
// Correct character case and cleanup string.
|
|
|
guess = guess.label || guess;
|
|
|
result = format(result[0]
|
|
|
.replace(RegExp(pattern, 'i'), guess)
|
|
|
.replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ')
|
|
|
.replace(RegExp('(' + guess + ')[-_.]?(\\w)', 'i'), '$1 $2'));
|
|
|
}
|
|
|
return result;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Resolves the version using an array of UA patterns.
|
|
|
*
|
|
|
* @private
|
|
|
* @param {Array} patterns An array of UA patterns.
|
|
|
* @returns {null|string} The detected version.
|
|
|
*/
|
|
|
function getVersion(patterns) {
|
|
|
return reduce(patterns, function(result, pattern) {
|
|
|
return result || (RegExp(pattern +
|
|
|
'(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Returns `platform.description` when the platform object is coerced to a string.
|
|
|
*
|
|
|
* @name toString
|
|
|
* @memberOf platform
|
|
|
* @returns {string} Returns `platform.description` if available, else an empty string.
|
|
|
*/
|
|
|
function toStringPlatform() {
|
|
|
return this.description || '';
|
|
|
}
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
// Convert layout to an array so we can add extra details.
|
|
|
layout && (layout = [layout]);
|
|
|
|
|
|
// Detect product names that contain their manufacturer's name.
|
|
|
if (manufacturer && !product) {
|
|
|
product = getProduct([manufacturer]);
|
|
|
}
|
|
|
// Clean up Google TV.
|
|
|
if ((data = /\bGoogle TV\b/.exec(product))) {
|
|
|
product = data[0];
|
|
|
}
|
|
|
// Detect simulators.
|
|
|
if (/\bSimulator\b/i.test(ua)) {
|
|
|
product = (product ? product + ' ' : '') + 'Simulator';
|
|
|
}
|
|
|
// Detect Opera Mini 8+ running in Turbo/Uncompressed mode on iOS.
|
|
|
if (name == 'Opera Mini' && /\bOPiOS\b/.test(ua)) {
|
|
|
description.push('running in Turbo/Uncompressed mode');
|
|
|
}
|
|
|
// Detect IE Mobile 11.
|
|
|
if (name == 'IE' && /\blike iPhone OS\b/.test(ua)) {
|
|
|
data = parse(ua.replace(/like iPhone OS/, ''));
|
|
|
manufacturer = data.manufacturer;
|
|
|
product = data.product;
|
|
|
}
|
|
|
// Detect iOS.
|
|
|
else if (/^iP/.test(product)) {
|
|
|
name || (name = 'Safari');
|
|
|
os = 'iOS' + ((data = / OS ([\d_]+)/i.exec(ua))
|
|
|
? ' ' + data[1].replace(/_/g, '.')
|
|
|
: '');
|
|
|
}
|
|
|
// Detect Kubuntu.
|
|
|
else if (name == 'Konqueror' && !/buntu/i.test(os)) {
|
|
|
os = 'Kubuntu';
|
|
|
}
|
|
|
// Detect Android browsers.
|
|
|
else if ((manufacturer && manufacturer != 'Google' &&
|
|
|
((/Chrome/.test(name) && !/\bMobile Safari\b/i.test(ua)) || /\bVita\b/.test(product))) ||
|
|
|
(/\bAndroid\b/.test(os) && /^Chrome/.test(name) && /\bVersion\//i.test(ua))) {
|
|
|
name = 'Android Browser';
|
|
|
os = /\bAndroid\b/.test(os) ? os : 'Android';
|
|
|
}
|
|
|
// Detect Silk desktop/accelerated modes.
|
|
|
else if (name == 'Silk') {
|
|
|
if (!/\bMobi/i.test(ua)) {
|
|
|
os = 'Android';
|
|
|
description.unshift('desktop mode');
|
|
|
}
|
|
|
if (/Accelerated *= *true/i.test(ua)) {
|
|
|
description.unshift('accelerated');
|
|
|
}
|
|
|
}
|
|
|
// Detect PaleMoon identifying as Firefox.
|
|
|
else if (name == 'PaleMoon' && (data = /\bFirefox\/([\d.]+)\b/.exec(ua))) {
|
|
|
description.push('identifying as Firefox ' + data[1]);
|
|
|
}
|
|
|
// Detect Firefox OS and products running Firefox.
|
|
|
else if (name == 'Firefox' && (data = /\b(Mobile|Tablet|TV)\b/i.exec(ua))) {
|
|
|
os || (os = 'Firefox OS');
|
|
|
product || (product = data[1]);
|
|
|
}
|
|
|
// Detect false positives for Firefox/Safari.
|
|
|
else if (!name || (data = !/\bMinefield\b/i.test(ua) && /\b(?:Firefox|Safari)\b/.exec(name))) {
|
|
|
// Escape the `/` for Firefox 1.
|
|
|
if (name && !product && /[\/,]|^[^(]+?\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) {
|
|
|
// Clear name of false positives.
|
|
|
name = null;
|
|
|
}
|
|
|
// Reassign a generic name.
|
|
|
if ((data = product || manufacturer || os) &&
|
|
|
(product || manufacturer || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(os))) {
|
|
|
name = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(os) ? os : data) + ' Browser';
|
|
|
}
|
|
|
}
|
|
|
// Add Chrome version to description for Electron.
|
|
|
else if (name == 'Electron' && (data = (/\bChrome\/([\d.]+)\b/.exec(ua) || 0)[1])) {
|
|
|
description.push('Chromium ' + data);
|
|
|
}
|
|
|
// Detect non-Opera (Presto-based) versions (order is important).
|
|
|
if (!version) {
|
|
|
version = getVersion([
|
|
|
'(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))',
|
|
|
'Version',
|
|
|
qualify(name),
|
|
|
'(?:Firefox|Minefield|NetFront)'
|
|
|
]);
|
|
|
}
|
|
|
// Detect stubborn layout engines.
|
|
|
if ((data =
|
|
|
layout == 'iCab' && parseFloat(version) > 3 && 'WebKit' ||
|
|
|
/\bOpera\b/.test(name) && (/\bOPR\b/.test(ua) ? 'Blink' : 'Presto') ||
|
|
|
/\b(?:Midori|Nook|Safari)\b/i.test(ua) && !/^(?:Trident|EdgeHTML)$/.test(layout) && 'WebKit' ||
|
|
|
!layout && /\bMSIE\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident') ||
|
|
|
layout == 'WebKit' && /\bPlayStation\b(?! Vita\b)/i.test(name) && 'NetFront'
|
|
|
)) {
|
|
|
layout = [data];
|
|
|
}
|
|
|
// Detect Windows Phone 7 desktop mode.
|
|
|
if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
|
|
|
name += ' Mobile';
|
|
|
os = 'Windows Phone ' + (/\+$/.test(data) ? data : data + '.x');
|
|
|
description.unshift('desktop mode');
|
|
|
}
|
|
|
// Detect Windows Phone 8.x desktop mode.
|
|
|
else if (/\bWPDesktop\b/i.test(ua)) {
|
|
|
name = 'IE Mobile';
|
|
|
os = 'Windows Phone 8.x';
|
|
|
description.unshift('desktop mode');
|
|
|
version || (version = (/\brv:([\d.]+)/.exec(ua) || 0)[1]);
|
|
|
}
|
|
|
// Detect IE 11 identifying as other browsers.
|
|
|
else if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
|
|
|
if (name) {
|
|
|
description.push('identifying as ' + name + (version ? ' ' + version : ''));
|
|
|
}
|
|
|
name = 'IE';
|
|
|
version = data[1];
|
|
|
}
|
|
|
// Leverage environment features.
|
|
|
if (useFeatures) {
|
|
|
// Detect server-side environments.
|
|
|
// Rhino has a global function while others have a global object.
|
|
|
if (isHostType(context, 'global')) {
|
|
|
if (java) {
|
|
|
data = java.lang.System;
|
|
|
arch = data.getProperty('os.arch');
|
|
|
os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');
|
|
|
}
|
|
|
if (rhino) {
|
|
|
try {
|
|
|
version = context.require('ringo/engine').version.join('.');
|
|
|
name = 'RingoJS';
|
|
|
} catch(e) {
|
|
|
if ((data = context.system) && data.global.system == context.system) {
|
|
|
name = 'Narwhal';
|
|
|
os || (os = data[0].os || null);
|
|
|
}
|
|
|
}
|
|
|
if (!name) {
|
|
|
name = 'Rhino';
|
|
|
}
|
|
|
}
|
|
|
else if (
|
|
|
typeof context.process == 'object' && !context.process.browser &&
|
|
|
(data = context.process)
|
|
|
) {
|
|
|
if (typeof data.versions == 'object') {
|
|
|
if (typeof data.versions.electron == 'string') {
|
|
|
description.push('Node ' + data.versions.node);
|
|
|
name = 'Electron';
|
|
|
version = data.versions.electron;
|
|
|
} else if (typeof data.versions.nw == 'string') {
|
|
|
description.push('Chromium ' + version, 'Node ' + data.versions.node);
|
|
|
name = 'NW.js';
|
|
|
version = data.versions.nw;
|
|
|
}
|
|
|
}
|
|
|
if (!name) {
|
|
|
name = 'Node.js';
|
|
|
arch = data.arch;
|
|
|
os = data.platform;
|
|
|
version = /[\d.]+/.exec(data.version);
|
|
|
version = version ? version[0] : null;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// Detect Adobe AIR.
|
|
|
else if (getClassOf((data = context.runtime)) == airRuntimeClass) {
|
|
|
name = 'Adobe AIR';
|
|
|
os = data.flash.system.Capabilities.os;
|
|
|
}
|
|
|
// Detect PhantomJS.
|
|
|
else if (getClassOf((data = context.phantom)) == phantomClass) {
|
|
|
name = 'PhantomJS';
|
|
|
version = (data = data.version || null) && (data.major + '.' + data.minor + '.' + data.patch);
|
|
|
}
|
|
|
// Detect IE compatibility modes.
|
|
|
else if (typeof doc.documentMode == 'number' && (data = /\bTrident\/(\d+)/i.exec(ua))) {
|
|
|
// We're in compatibility mode when the Trident version + 4 doesn't
|
|
|
// equal the document mode.
|
|
|
version = [version, doc.documentMode];
|
|
|
if ((data = +data[1] + 4) != version[1]) {
|
|
|
description.push('IE ' + version[1] + ' mode');
|
|
|
layout && (layout[1] = '');
|
|
|
version[1] = data;
|
|
|
}
|
|
|
version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];
|
|
|
}
|
|
|
// Detect IE 11 masking as other browsers.
|
|
|
else if (typeof doc.documentMode == 'number' && /^(?:Chrome|Firefox)\b/.test(name)) {
|
|
|
description.push('masking as ' + name + ' ' + version);
|
|
|
name = 'IE';
|
|
|
version = '11.0';
|
|
|
layout = ['Trident'];
|
|
|
os = 'Windows';
|
|
|
}
|
|
|
os = os && format(os);
|
|
|
}
|
|
|
// Detect prerelease phases.
|
|
|
if (version && (data =
|
|
|
/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) ||
|
|
|
/(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) ||
|
|
|
/\bMinefield\b/i.test(ua) && 'a'
|
|
|
)) {
|
|
|
prerelease = /b/i.test(data) ? 'beta' : 'alpha';
|
|
|
version = version.replace(RegExp(data + '\\+?$'), '') +
|
|
|
(prerelease == 'beta' ? beta : alpha) + (/\d+\+?/.exec(data) || '');
|
|
|
}
|
|
|
// Detect Firefox Mobile.
|
|
|
if (name == 'Fennec' || name == 'Firefox' && /\b(?:Android|Firefox OS)\b/.test(os)) {
|
|
|
name = 'Firefox Mobile';
|
|
|
}
|
|
|
// Obscure Maxthon's unreliable version.
|
|
|
else if (name == 'Maxthon' && version) {
|
|
|
version = version.replace(/\.[\d.]+/, '.x');
|
|
|
}
|
|
|
// Detect Xbox 360 and Xbox One.
|
|
|
else if (/\bXbox\b/i.test(product)) {
|
|
|
if (product == 'Xbox 360') {
|
|
|
os = null;
|
|
|
}
|
|
|
if (product == 'Xbox 360' && /\bIEMobile\b/.test(ua)) {
|
|
|
description.unshift('mobile mode');
|
|
|
}
|
|
|
}
|
|
|
// Add mobile postfix.
|
|
|
else if ((/^(?:Chrome|IE|Opera)$/.test(name) || name && !product && !/Browser|Mobi/.test(name)) &&
|
|
|
(os == 'Windows CE' || /Mobi/i.test(ua))) {
|
|
|
name += ' Mobile';
|
|
|
}
|
|
|
// Detect IE platform preview.
|
|
|
else if (name == 'IE' && useFeatures) {
|
|
|
try {
|
|
|
if (context.external === null) {
|
|
|
description.unshift('platform preview');
|
|
|
}
|
|
|
} catch(e) {
|
|
|
description.unshift('embedded');
|
|
|
}
|
|
|
}
|
|
|
// Detect BlackBerry OS version.
|
|
|
// http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp
|
|
|
else if ((/\bBlackBerry\b/.test(product) || /\bBB10\b/.test(ua)) && (data =
|
|
|
(RegExp(product.replace(/ +/g, ' *') + '/([.\\d]+)', 'i').exec(ua) || 0)[1] ||
|
|
|
version
|
|
|
)) {
|
|
|
data = [data, /BB10/.test(ua)];
|
|
|
os = (data[1] ? (product = null, manufacturer = 'BlackBerry') : 'Device Software') + ' ' + data[0];
|
|
|
version = null;
|
|
|
}
|
|
|
// Detect Opera identifying/masking itself as another browser.
|
|
|
// http://www.opera.com/support/kb/view/843/
|
|
|
else if (this != forOwn && product != 'Wii' && (
|
|
|
(useFeatures && opera) ||
|
|
|
(/Opera/.test(name) && /\b(?:MSIE|Firefox)\b/i.test(ua)) ||
|
|
|
(name == 'Firefox' && /\bOS X (?:\d+\.){2,}/.test(os)) ||
|
|
|
(name == 'IE' && (
|
|
|
(os && !/^Win/.test(os) && version > 5.5) ||
|
|
|
/\bWindows XP\b/.test(os) && version > 8 ||
|
|
|
version == 8 && !/\bTrident\b/.test(ua)
|
|
|
))
|
|
|
) && !reOpera.test((data = parse.call(forOwn, ua.replace(reOpera, '') + ';'))) && data.name) {
|
|
|
// When "identifying", the UA contains both Opera and the other browser's name.
|
|
|
data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
|
|
|
if (reOpera.test(name)) {
|
|
|
if (/\bIE\b/.test(data) && os == 'Mac OS') {
|
|
|
os = null;
|
|
|
}
|
|
|
data = 'identify' + data;
|
|
|
}
|
|
|
// When "masking", the UA contains only the other browser's name.
|
|
|
else {
|
|
|
data = 'mask' + data;
|
|
|
if (operaClass) {
|
|
|
name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2'));
|
|
|
} else {
|
|
|
name = 'Opera';
|
|
|
}
|
|
|
if (/\bIE\b/.test(data)) {
|
|
|
os = null;
|
|
|
}
|
|
|
if (!useFeatures) {
|
|
|
version = null;
|
|
|
}
|
|
|
}
|
|
|
layout = ['Presto'];
|
|
|
description.push(data);
|
|
|
}
|
|
|
// Detect WebKit Nightly and approximate Chrome/Safari versions.
|
|
|
if ((data = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
|
|
|
// Correct build number for numeric comparison.
|
|
|
// (e.g. "532.5" becomes "532.05")
|
|
|
data = [parseFloat(data.replace(/\.(\d)$/, '.0$1')), data];
|
|
|
// Nightly builds are postfixed with a "+".
|
|
|
if (name == 'Safari' && data[1].slice(-1) == '+') {
|
|
|
name = 'WebKit Nightly';
|
|
|
prerelease = 'alpha';
|
|
|
version = data[1].slice(0, -1);
|
|
|
}
|
|
|
// Clear incorrect browser versions.
|
|
|
else if (version == data[1] ||
|
|
|
version == (data[2] = (/\bSafari\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
|
|
|
version = null;
|
|
|
}
|
|
|
// Use the full Chrome version when available.
|
|
|
data[1] = (/\bChrome\/([\d.]+)/i.exec(ua) || 0)[1];
|
|
|
// Detect Blink layout engine.
|
|
|
if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
|
|
|
layout = ['Blink'];
|
|
|
}
|
|
|
// Detect JavaScriptCore.
|
|
|
// http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi
|
|
|
if (!useFeatures || (!likeChrome && !data[1])) {
|
|
|
layout && (layout[1] = 'like Safari');
|
|
|
data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : data < 537 ? 6 : data < 538 ? 7 : data < 601 ? 8 : '8');
|
|
|
} else {
|
|
|
layout && (layout[1] = 'like Chrome');
|
|
|
data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : data < 537.11 ? '21+' : data < 537.13 ? 23 : data < 537.18 ? 24 : data < 537.24 ? 25 : data < 537.36 ? 26 : layout != 'Blink' ? '27' : '28');
|
|
|
}
|
|
|
// Add the postfix of ".x" or "+" for approximate versions.
|
|
|
layout && (layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'));
|
|
|
// Obscure version for some Safari 1-2 releases.
|
|
|
if (name == 'Safari' && (!version || parseInt(version) > 45)) {
|
|
|
version = data;
|
|
|
}
|
|
|
}
|
|
|
// Detect Opera desktop modes.
|
|
|
if (name == 'Opera' && (data = /\bzbov|zvav$/.exec(os))) {
|
|
|
name += ' ';
|
|
|
description.unshift('desktop mode');
|
|
|
if (data == 'zvav') {
|
|
|
name += 'Mini';
|
|
|
version = null;
|
|
|
} else {
|
|
|
name += 'Mobile';
|
|
|
}
|
|
|
os = os.replace(RegExp(' *' + data + '$'), '');
|
|
|
}
|
|
|
// Detect Chrome desktop mode.
|
|
|
else if (name == 'Safari' && /\bChrome\b/.exec(layout && layout[1])) {
|
|
|
description.unshift('desktop mode');
|
|
|
name = 'Chrome Mobile';
|
|
|
version = null;
|
|
|
|
|
|
if (/\bOS X\b/.test(os)) {
|
|
|
manufacturer = 'Apple';
|
|
|
os = 'iOS 4.3+';
|
|
|
} else {
|
|
|
os = null;
|
|
|
}
|
|
|
}
|
|
|
// Strip incorrect OS versions.
|
|
|
if (version && version.indexOf((data = /[\d.]+$/.exec(os))) == 0 &&
|
|
|
ua.indexOf('/' + data + '-') > -1) {
|
|
|
os = trim(os.replace(data, ''));
|
|
|
}
|
|
|
// Add layout engine.
|
|
|
if (layout && !/\b(?:Avant|Nook)\b/.test(name) && (
|
|
|
/Browser|Lunascape|Maxthon/.test(name) ||
|
|
|
name != 'Safari' && /^iOS/.test(os) && /\bSafari\b/.test(layout[1]) ||
|
|
|
/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(name) && layout[1])) {
|
|
|
// Don't add layout details to description if they are falsey.
|
|
|
(data = layout[layout.length - 1]) && description.push(data);
|
|
|
}
|
|
|
// Combine contextual information.
|
|
|
if (description.length) {
|
|
|
description = ['(' + description.join('; ') + ')'];
|
|
|
}
|
|
|
// Append manufacturer to description.
|
|
|
if (manufacturer && product && product.indexOf(manufacturer) < 0) {
|
|
|
description.push('on ' + manufacturer);
|
|
|
}
|
|
|
// Append product to description.
|
|
|
if (product) {
|
|
|
description.push((/^on /.test(description[description.length - 1]) ? '' : 'on ') + product);
|
|
|
}
|
|
|
// Parse the OS into an object.
|
|
|
if (os) {
|
|
|
data = / ([\d.+]+)$/.exec(os);
|
|
|
isSpecialCasedOS = data && os.charAt(os.length - data[0].length - 1) == '/';
|
|
|
os = {
|
|
|
'architecture': 32,
|
|
|
'family': (data && !isSpecialCasedOS) ? os.replace(data[0], '') : os,
|
|
|
'version': data ? data[1] : null,
|
|
|
'toString': function() {
|
|
|
var version = this.version;
|
|
|
return this.family + ((version && !isSpecialCasedOS) ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
// Add browser/OS architecture.
|
|
|
if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
|
|
|
if (os) {
|
|
|
os.architecture = 64;
|
|
|
os.family = os.family.replace(RegExp(' *' + data), '');
|
|
|
}
|
|
|
if (
|
|
|
name && (/\bWOW64\b/i.test(ua) ||
|
|
|
(useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform) && !/\bWin64; x64\b/i.test(ua)))
|
|
|
) {
|
|
|
description.unshift('32-bit');
|
|
|
}
|
|
|
}
|
|
|
// Chrome 39 and above on OS X is always 64-bit.
|
|
|
else if (
|
|
|
os && /^OS X/.test(os.family) &&
|
|
|
name == 'Chrome' && parseFloat(version) >= 39
|
|
|
) {
|
|
|
os.architecture = 64;
|
|
|
}
|
|
|
|
|
|
ua || (ua = null);
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
/**
|
|
|
* The platform object.
|
|
|
*
|
|
|
* @name platform
|
|
|
* @type Object
|
|
|
*/
|
|
|
var platform = {};
|
|
|
|
|
|
/**
|
|
|
* The platform description.
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type string|null
|
|
|
*/
|
|
|
platform.description = ua;
|
|
|
|
|
|
/**
|
|
|
* The name of the browser's layout engine.
|
|
|
*
|
|
|
* The list of common layout engines include:
|
|
|
* "Blink", "EdgeHTML", "Gecko", "Trident" and "WebKit"
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type string|null
|
|
|
*/
|
|
|
platform.layout = layout && layout[0];
|
|
|
|
|
|
/**
|
|
|
* The name of the product's manufacturer.
|
|
|
*
|
|
|
* The list of manufacturers include:
|
|
|
* "Apple", "Archos", "Amazon", "Asus", "Barnes & Noble", "BlackBerry",
|
|
|
* "Google", "HP", "HTC", "LG", "Microsoft", "Motorola", "Nintendo",
|
|
|
* "Nokia", "Samsung" and "Sony"
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type string|null
|
|
|
*/
|
|
|
platform.manufacturer = manufacturer;
|
|
|
|
|
|
/**
|
|
|
* The name of the browser/environment.
|
|
|
*
|
|
|
* The list of common browser names include:
|
|
|
* "Chrome", "Electron", "Firefox", "Firefox for iOS", "IE",
|
|
|
* "Microsoft Edge", "PhantomJS", "Safari", "SeaMonkey", "Silk",
|
|
|
* "Opera Mini" and "Opera"
|
|
|
*
|
|
|
* Mobile versions of some browsers have "Mobile" appended to their name:
|
|
|
* eg. "Chrome Mobile", "Firefox Mobile", "IE Mobile" and "Opera Mobile"
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type string|null
|
|
|
*/
|
|
|
platform.name = name;
|
|
|
|
|
|
/**
|
|
|
* The alpha/beta release indicator.
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type string|null
|
|
|
*/
|
|
|
platform.prerelease = prerelease;
|
|
|
|
|
|
/**
|
|
|
* The name of the product hosting the browser.
|
|
|
*
|
|
|
* The list of common products include:
|
|
|
*
|
|
|
* "BlackBerry", "Galaxy S4", "Lumia", "iPad", "iPod", "iPhone", "Kindle",
|
|
|
* "Kindle Fire", "Nexus", "Nook", "PlayBook", "TouchPad" and "Transformer"
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type string|null
|
|
|
*/
|
|
|
platform.product = product;
|
|
|
|
|
|
/**
|
|
|
* The browser's user agent string.
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type string|null
|
|
|
*/
|
|
|
platform.ua = ua;
|
|
|
|
|
|
/**
|
|
|
* The browser/environment version.
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type string|null
|
|
|
*/
|
|
|
platform.version = name && version;
|
|
|
|
|
|
/**
|
|
|
* The name of the operating system.
|
|
|
*
|
|
|
* @memberOf platform
|
|
|
* @type Object
|
|
|
*/
|
|
|
platform.os = os || {
|
|
|
|
|
|
/**
|
|
|
* The CPU architecture the OS is built for.
|
|
|
*
|
|
|
* @memberOf platform.os
|
|
|
* @type number|null
|
|
|
*/
|
|
|
'architecture': null,
|
|
|
|
|
|
/**
|
|
|
* The family of the OS.
|
|
|
*
|
|
|
* Common values include:
|
|
|
* "Windows", "Windows Server 2008 R2 / 7", "Windows Server 2008 / Vista",
|
|
|
* "Windows XP", "OS X", "Ubuntu", "Debian", "Fedora", "Red Hat", "SuSE",
|
|
|
* "Android", "iOS" and "Windows Phone"
|
|
|
*
|
|
|
* @memberOf platform.os
|
|
|
* @type string|null
|
|
|
*/
|
|
|
'family': null,
|
|
|
|
|
|
/**
|
|
|
* The version of the OS.
|
|
|
*
|
|
|
* @memberOf platform.os
|
|
|
* @type string|null
|
|
|
*/
|
|
|
'version': null,
|
|
|
|
|
|
/**
|
|
|
* Returns the OS string.
|
|
|
*
|
|
|
* @memberOf platform.os
|
|
|
* @returns {string} The OS string.
|
|
|
*/
|
|
|
'toString': function() { return 'null'; }
|
|
|
};
|
|
|
|
|
|
platform.parse = parse;
|
|
|
platform.toString = toStringPlatform;
|
|
|
|
|
|
if (platform.version) {
|
|
|
description.unshift(version);
|
|
|
}
|
|
|
if (platform.name) {
|
|
|
description.unshift(name);
|
|
|
}
|
|
|
if (os && name && !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product))) {
|
|
|
description.push(product ? '(' + os + ')' : 'on ' + os);
|
|
|
}
|
|
|
if (description.length) {
|
|
|
platform.description = description.join(' ');
|
|
|
}
|
|
|
return platform;
|
|
|
}
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
// Export platform.
|
|
|
var platform = parse();
|
|
|
|
|
|
// Some AMD build optimizers, like r.js, check for condition patterns like the following:
|
|
|
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
|
|
// Expose platform on the global object to prevent errors when platform is
|
|
|
// loaded by a script tag in the presence of an AMD loader.
|
|
|
// See http://requirejs.org/docs/errors.html#mismatch for more details.
|
|
|
root.platform = platform;
|
|
|
|
|
|
// Define as an anonymous module so platform can be aliased through path mapping.
|
|
|
define(function() {
|
|
|
return platform;
|
|
|
});
|
|
|
}
|
|
|
// Check for `exports` after `define` in case a build optimizer adds an `exports` object.
|
|
|
else if (freeExports && freeModule) {
|
|
|
// Export for CommonJS support.
|
|
|
forOwn(platform, function(value, key) {
|
|
|
freeExports[key] = value;
|
|
|
});
|
|
|
}
|
|
|
else {
|
|
|
// Export to the global object.
|
|
|
root.platform = platform;
|
|
|
}
|
|
|
}.call(this));
|
|
|
|
|
|
}).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{}],207:[function(require,module,exports){
|
|
|
(function (process){
|
|
|
'use strict';
|
|
|
|
|
|
if (typeof process === 'undefined' ||
|
|
|
!process.version ||
|
|
|
process.version.indexOf('v0.') === 0 ||
|
|
|
process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
|
|
|
module.exports = { nextTick: nextTick };
|
|
|
} else {
|
|
|
module.exports = process
|
|
|
}
|
|
|
|
|
|
function nextTick(fn, arg1, arg2, arg3) {
|
|
|
if (typeof fn !== 'function') {
|
|
|
throw new TypeError('"callback" argument must be a function');
|
|
|
}
|
|
|
var len = arguments.length;
|
|
|
var args, i;
|
|
|
switch (len) {
|
|
|
case 0:
|
|
|
case 1:
|
|
|
return process.nextTick(fn);
|
|
|
case 2:
|
|
|
return process.nextTick(function afterTickOne() {
|
|
|
fn.call(null, arg1);
|
|
|
});
|
|
|
case 3:
|
|
|
return process.nextTick(function afterTickTwo() {
|
|
|
fn.call(null, arg1, arg2);
|
|
|
});
|
|
|
case 4:
|
|
|
return process.nextTick(function afterTickThree() {
|
|
|
fn.call(null, arg1, arg2, arg3);
|
|
|
});
|
|
|
default:
|
|
|
args = new Array(len - 1);
|
|
|
i = 0;
|
|
|
while (i < args.length) {
|
|
|
args[i++] = arguments[i];
|
|
|
}
|
|
|
return process.nextTick(function afterTick() {
|
|
|
fn.apply(null, args);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}).call(this,require('_process'))
|
|
|
},{"_process":208}],208:[function(require,module,exports){
|
|
|
// shim for using process in browser
|
|
|
var process = module.exports = {};
|
|
|
|
|
|
// cached from whatever global is present so that test runners that stub it
|
|
|
// don't break things. But we need to wrap it in a try catch in case it is
|
|
|
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
|
|
// function because try/catches deoptimize in certain engines.
|
|
|
|
|
|
var cachedSetTimeout;
|
|
|
var cachedClearTimeout;
|
|
|
|
|
|
function defaultSetTimout() {
|
|
|
throw new Error('setTimeout has not been defined');
|
|
|
}
|
|
|
function defaultClearTimeout () {
|
|
|
throw new Error('clearTimeout has not been defined');
|
|
|
}
|
|
|
(function () {
|
|
|
try {
|
|
|
if (typeof setTimeout === 'function') {
|
|
|
cachedSetTimeout = setTimeout;
|
|
|
} else {
|
|
|
cachedSetTimeout = defaultSetTimout;
|
|
|
}
|
|
|
} catch (e) {
|
|
|
cachedSetTimeout = defaultSetTimout;
|
|
|
}
|
|
|
try {
|
|
|
if (typeof clearTimeout === 'function') {
|
|
|
cachedClearTimeout = clearTimeout;
|
|
|
} else {
|
|
|
cachedClearTimeout = defaultClearTimeout;
|
|
|
}
|
|
|
} catch (e) {
|
|
|
cachedClearTimeout = defaultClearTimeout;
|
|
|
}
|
|
|
} ())
|
|
|
function runTimeout(fun) {
|
|
|
if (cachedSetTimeout === setTimeout) {
|
|
|
//normal enviroments in sane situations
|
|
|
return setTimeout(fun, 0);
|
|
|
}
|
|
|
// if setTimeout wasn't available but was latter defined
|
|
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
|
cachedSetTimeout = setTimeout;
|
|
|
return setTimeout(fun, 0);
|
|
|
}
|
|
|
try {
|
|
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
|
return cachedSetTimeout(fun, 0);
|
|
|
} catch(e){
|
|
|
try {
|
|
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
|
return cachedSetTimeout.call(null, fun, 0);
|
|
|
} catch(e){
|
|
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
|
|
return cachedSetTimeout.call(this, fun, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
function runClearTimeout(marker) {
|
|
|
if (cachedClearTimeout === clearTimeout) {
|
|
|
//normal enviroments in sane situations
|
|
|
return clearTimeout(marker);
|
|
|
}
|
|
|
// if clearTimeout wasn't available but was latter defined
|
|
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
|
cachedClearTimeout = clearTimeout;
|
|
|
return clearTimeout(marker);
|
|
|
}
|
|
|
try {
|
|
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
|
return cachedClearTimeout(marker);
|
|
|
} catch (e){
|
|
|
try {
|
|
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
|
return cachedClearTimeout.call(null, marker);
|
|
|
} catch (e){
|
|
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
|
|
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
|
return cachedClearTimeout.call(this, marker);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
var queue = [];
|
|
|
var draining = false;
|
|
|
var currentQueue;
|
|
|
var queueIndex = -1;
|
|
|
|
|
|
function cleanUpNextTick() {
|
|
|
if (!draining || !currentQueue) {
|
|
|
return;
|
|
|
}
|
|
|
draining = false;
|
|
|
if (currentQueue.length) {
|
|
|
queue = currentQueue.concat(queue);
|
|
|
} else {
|
|
|
queueIndex = -1;
|
|
|
}
|
|
|
if (queue.length) {
|
|
|
drainQueue();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function drainQueue() {
|
|
|
if (draining) {
|
|
|
return;
|
|
|
}
|
|
|
var timeout = runTimeout(cleanUpNextTick);
|
|
|
draining = true;
|
|
|
|
|
|
var len = queue.length;
|
|
|
while(len) {
|
|
|
currentQueue = queue;
|
|
|
queue = [];
|
|
|
while (++queueIndex < len) {
|
|
|
if (currentQueue) {
|
|
|
currentQueue[queueIndex].run();
|
|
|
}
|
|
|
}
|
|
|
queueIndex = -1;
|
|
|
len = queue.length;
|
|
|
}
|
|
|
currentQueue = null;
|
|
|
draining = false;
|
|
|
runClearTimeout(timeout);
|
|
|
}
|
|
|
|
|
|
process.nextTick = function (fun) {
|
|
|
var args = new Array(arguments.length - 1);
|
|
|
if (arguments.length > 1) {
|
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
|
args[i - 1] = arguments[i];
|
|
|
}
|
|
|
}
|
|
|
queue.push(new Item(fun, args));
|
|
|
if (queue.length === 1 && !draining) {
|
|
|
runTimeout(drainQueue);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// v8 likes predictible objects
|
|
|
function Item(fun, array) {
|
|
|
this.fun = fun;
|
|
|
this.array = array;
|
|
|
}
|
|
|
Item.prototype.run = function () {
|
|
|
this.fun.apply(null, this.array);
|
|
|
};
|
|
|
process.title = 'browser';
|
|
|
process.browser = true;
|
|
|
process.env = {};
|
|
|
process.argv = [];
|
|
|
process.version = ''; // empty string to avoid regexp issues
|
|
|
process.versions = {};
|
|
|
|
|
|
function noop() {}
|
|
|
|
|
|
process.on = noop;
|
|
|
process.addListener = noop;
|
|
|
process.once = noop;
|
|
|
process.off = noop;
|
|
|
process.removeListener = noop;
|
|
|
process.removeAllListeners = noop;
|
|
|
process.emit = noop;
|
|
|
process.prependListener = noop;
|
|
|
process.prependOnceListener = noop;
|
|
|
|
|
|
process.listeners = function (name) { return [] }
|
|
|
|
|
|
process.binding = function (name) {
|
|
|
throw new Error('process.binding is not supported');
|
|
|
};
|
|
|
|
|
|
process.cwd = function () { return '/' };
|
|
|
process.chdir = function (dir) {
|
|
|
throw new Error('process.chdir is not supported');
|
|
|
};
|
|
|
process.umask = function() { return 0; };
|
|
|
|
|
|
},{}],209:[function(require,module,exports){
|
|
|
(function (global){
|
|
|
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
|
;(function(root) {
|
|
|
|
|
|
/** Detect free variables */
|
|
|
var freeExports = typeof exports == 'object' && exports &&
|
|
|
!exports.nodeType && exports;
|
|
|
var freeModule = typeof module == 'object' && module &&
|
|
|
!module.nodeType && module;
|
|
|
var freeGlobal = typeof global == 'object' && global;
|
|
|
if (
|
|
|
freeGlobal.global === freeGlobal ||
|
|
|
freeGlobal.window === freeGlobal ||
|
|
|
freeGlobal.self === freeGlobal
|
|
|
) {
|
|
|
root = freeGlobal;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* The `punycode` object.
|
|
|
* @name punycode
|
|
|
* @type Object
|
|
|
*/
|
|
|
var punycode,
|
|
|
|
|
|
/** Highest positive signed 32-bit float value */
|
|
|
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
|
|
|
|
|
|
/** Bootstring parameters */
|
|
|
base = 36,
|
|
|
tMin = 1,
|
|
|
tMax = 26,
|
|
|
skew = 38,
|
|
|
damp = 700,
|
|
|
initialBias = 72,
|
|
|
initialN = 128, // 0x80
|
|
|
delimiter = '-', // '\x2D'
|
|
|
|
|
|
/** Regular expressions */
|
|
|
regexPunycode = /^xn--/,
|
|
|
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
|
|
|
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
|
|
|
|
|
|
/** Error messages */
|
|
|
errors = {
|
|
|
'overflow': 'Overflow: input needs wider integers to process',
|
|
|
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
|
'invalid-input': 'Invalid input'
|
|
|
},
|
|
|
|
|
|
/** Convenience shortcuts */
|
|
|
baseMinusTMin = base - tMin,
|
|
|
floor = Math.floor,
|
|
|
stringFromCharCode = String.fromCharCode,
|
|
|
|
|
|
/** Temporary variable */
|
|
|
key;
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
/**
|
|
|
* A generic error utility function.
|
|
|
* @private
|
|
|
* @param {String} type The error type.
|
|
|
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
|
|
*/
|
|
|
function error(type) {
|
|
|
throw new RangeError(errors[type]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* A generic `Array#map` utility function.
|
|
|
* @private
|
|
|
* @param {Array} array The array to iterate over.
|
|
|
* @param {Function} callback The function that gets called for every array
|
|
|
* item.
|
|
|
* @returns {Array} A new array of values returned by the callback function.
|
|
|
*/
|
|
|
function map(array, fn) {
|
|
|
var length = array.length;
|
|
|
var result = [];
|
|
|
while (length--) {
|
|
|
result[length] = fn(array[length]);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
|
|
* addresses.
|
|
|
* @private
|
|
|
* @param {String} domain The domain name or email address.
|
|
|
* @param {Function} callback The function that gets called for every
|
|
|
* character.
|
|
|
* @returns {Array} A new string of characters returned by the callback
|
|
|
* function.
|
|
|
*/
|
|
|
function mapDomain(string, fn) {
|
|
|
var parts = string.split('@');
|
|
|
var result = '';
|
|
|
if (parts.length > 1) {
|
|
|
// In email addresses, only the domain name should be punycoded. Leave
|
|
|
// the local part (i.e. everything up to `@`) intact.
|
|
|
result = parts[0] + '@';
|
|
|
string = parts[1];
|
|
|
}
|
|
|
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
|
|
string = string.replace(regexSeparators, '\x2E');
|
|
|
var labels = string.split('.');
|
|
|
var encoded = map(labels, fn).join('.');
|
|
|
return result + encoded;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Creates an array containing the numeric code points of each Unicode
|
|
|
* character in the string. While JavaScript uses UCS-2 internally,
|
|
|
* this function will convert a pair of surrogate halves (each of which
|
|
|
* UCS-2 exposes as separate characters) into a single code point,
|
|
|
* matching UTF-16.
|
|
|
* @see `punycode.ucs2.encode`
|
|
|
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
|
* @memberOf punycode.ucs2
|
|
|
* @name decode
|
|
|
* @param {String} string The Unicode input string (UCS-2).
|
|
|
* @returns {Array} The new array of code points.
|
|
|
*/
|
|
|
function ucs2decode(string) {
|
|
|
var output = [],
|
|
|
counter = 0,
|
|
|
length = string.length,
|
|
|
value,
|
|
|
extra;
|
|
|
while (counter < length) {
|
|
|
value = string.charCodeAt(counter++);
|
|
|
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
|
|
// high surrogate, and there is a next character
|
|
|
extra = string.charCodeAt(counter++);
|
|
|
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
|
|
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
|
} else {
|
|
|
// unmatched surrogate; only append this code unit, in case the next
|
|
|
// code unit is the high surrogate of a surrogate pair
|
|
|
output.push(value);
|
|
|
counter--;
|
|
|
}
|
|
|
} else {
|
|
|
output.push(value);
|
|
|
}
|
|
|
}
|
|
|
return output;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Creates a string based on an array of numeric code points.
|
|
|
* @see `punycode.ucs2.decode`
|
|
|
* @memberOf punycode.ucs2
|
|
|
* @name encode
|
|
|
* @param {Array} codePoints The array of numeric code points.
|
|
|
* @returns {String} The new Unicode string (UCS-2).
|
|
|
*/
|
|
|
function ucs2encode(array) {
|
|
|
return map(array, function(value) {
|
|
|
var output = '';
|
|
|
if (value > 0xFFFF) {
|
|
|
value -= 0x10000;
|
|
|
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
|
|
value = 0xDC00 | value & 0x3FF;
|
|
|
}
|
|
|
output += stringFromCharCode(value);
|
|
|
return output;
|
|
|
}).join('');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Converts a basic code point into a digit/integer.
|
|
|
* @see `digitToBasic()`
|
|
|
* @private
|
|
|
* @param {Number} codePoint The basic numeric code point value.
|
|
|
* @returns {Number} The numeric value of a basic code point (for use in
|
|
|
* representing integers) in the range `0` to `base - 1`, or `base` if
|
|
|
* the code point does not represent a value.
|
|
|
*/
|
|
|
function basicToDigit(codePoint) {
|
|
|
if (codePoint - 48 < 10) {
|
|
|
return codePoint - 22;
|
|
|
}
|
|
|
if (codePoint - 65 < 26) {
|
|
|
return codePoint - 65;
|
|
|
}
|
|
|
if (codePoint - 97 < 26) {
|
|
|
return codePoint - 97;
|
|
|
}
|
|
|
return base;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Converts a digit/integer into a basic code point.
|
|
|
* @see `basicToDigit()`
|
|
|
* @private
|
|
|
* @param {Number} digit The numeric value of a basic code point.
|
|
|
* @returns {Number} The basic code point whose value (when used for
|
|
|
* representing integers) is `digit`, which needs to be in the range
|
|
|
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
|
|
* used; else, the lowercase form is used. The behavior is undefined
|
|
|
* if `flag` is non-zero and `digit` has no uppercase form.
|
|
|
*/
|
|
|
function digitToBasic(digit, flag) {
|
|
|
// 0..25 map to ASCII a..z or A..Z
|
|
|
// 26..35 map to ASCII 0..9
|
|
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Bias adaptation function as per section 3.4 of RFC 3492.
|
|
|
* https://tools.ietf.org/html/rfc3492#section-3.4
|
|
|
* @private
|
|
|
*/
|
|
|
function adapt(delta, numPoints, firstTime) {
|
|
|
var k = 0;
|
|
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
|
delta += floor(delta / numPoints);
|
|
|
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
|
delta = floor(delta / baseMinusTMin);
|
|
|
}
|
|
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
|
|
* symbols.
|
|
|
* @memberOf punycode
|
|
|
* @param {String} input The Punycode string of ASCII-only symbols.
|
|
|
* @returns {String} The resulting string of Unicode symbols.
|
|
|
*/
|
|
|
function decode(input) {
|
|
|
// Don't use UCS-2
|
|
|
var output = [],
|
|
|
inputLength = input.length,
|
|
|
out,
|
|
|
i = 0,
|
|
|
n = initialN,
|
|
|
bias = initialBias,
|
|
|
basic,
|
|
|
j,
|
|
|
index,
|
|
|
oldi,
|
|
|
w,
|
|
|
k,
|
|
|
digit,
|
|
|
t,
|
|
|
/** Cached calculation results */
|
|
|
baseMinusT;
|
|
|
|
|
|
// Handle the basic code points: let `basic` be the number of input code
|
|
|
// points before the last delimiter, or `0` if there is none, then copy
|
|
|
// the first basic code points to the output.
|
|
|
|
|
|
basic = input.lastIndexOf(delimiter);
|
|
|
if (basic < 0) {
|
|
|
basic = 0;
|
|
|
}
|
|
|
|
|
|
for (j = 0; j < basic; ++j) {
|
|
|
// if it's not a basic code point
|
|
|
if (input.charCodeAt(j) >= 0x80) {
|
|
|
error('not-basic');
|
|
|
}
|
|
|
output.push(input.charCodeAt(j));
|
|
|
}
|
|
|
|
|
|
// Main decoding loop: start just after the last delimiter if any basic code
|
|
|
// points were copied; start at the beginning otherwise.
|
|
|
|
|
|
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
|
|
|
|
|
// `index` is the index of the next character to be consumed.
|
|
|
// Decode a generalized variable-length integer into `delta`,
|
|
|
// which gets added to `i`. The overflow checking is easier
|
|
|
// if we increase `i` as we go, then subtract off its starting
|
|
|
// value at the end to obtain `delta`.
|
|
|
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
|
|
|
|
|
|
if (index >= inputLength) {
|
|
|
error('invalid-input');
|
|
|
}
|
|
|
|
|
|
digit = basicToDigit(input.charCodeAt(index++));
|
|
|
|
|
|
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
|
|
error('overflow');
|
|
|
}
|
|
|
|
|
|
i += digit * w;
|
|
|
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
|
|
|
|
if (digit < t) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
baseMinusT = base - t;
|
|
|
if (w > floor(maxInt / baseMinusT)) {
|
|
|
error('overflow');
|
|
|
}
|
|
|
|
|
|
w *= baseMinusT;
|
|
|
|
|
|
}
|
|
|
|
|
|
out = output.length + 1;
|
|
|
bias = adapt(i - oldi, out, oldi == 0);
|
|
|
|
|
|
// `i` was supposed to wrap around from `out` to `0`,
|
|
|
// incrementing `n` each time, so we'll fix that now:
|
|
|
if (floor(i / out) > maxInt - n) {
|
|
|
error('overflow');
|
|
|
}
|
|
|
|
|
|
n += floor(i / out);
|
|
|
i %= out;
|
|
|
|
|
|
// Insert `n` at position `i` of the output
|
|
|
output.splice(i++, 0, n);
|
|
|
|
|
|
}
|
|
|
|
|
|
return ucs2encode(output);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
|
|
* Punycode string of ASCII-only symbols.
|
|
|
* @memberOf punycode
|
|
|
* @param {String} input The string of Unicode symbols.
|
|
|
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
|
|
*/
|
|
|
function encode(input) {
|
|
|
var n,
|
|
|
delta,
|
|
|
handledCPCount,
|
|
|
basicLength,
|
|
|
bias,
|
|
|
j,
|
|
|
m,
|
|
|
q,
|
|
|
k,
|
|
|
t,
|
|
|
currentValue,
|
|
|
output = [],
|
|
|
/** `inputLength` will hold the number of code points in `input`. */
|
|
|
inputLength,
|
|
|
/** Cached calculation results */
|
|
|
handledCPCountPlusOne,
|
|
|
baseMinusT,
|
|
|
qMinusT;
|
|
|
|
|
|
// Convert the input in UCS-2 to Unicode
|
|
|
input = ucs2decode(input);
|
|
|
|
|
|
// Cache the length
|
|
|
inputLength = input.length;
|
|
|
|
|
|
// Initialize the state
|
|
|
n = initialN;
|
|
|
delta = 0;
|
|
|
bias = initialBias;
|
|
|
|
|
|
// Handle the basic code points
|
|
|
for (j = 0; j < inputLength; ++j) {
|
|
|
currentValue = input[j];
|
|
|
if (currentValue < 0x80) {
|
|
|
output.push(stringFromCharCode(currentValue));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
handledCPCount = basicLength = output.length;
|
|
|
|
|
|
// `handledCPCount` is the number of code points that have been handled;
|
|
|
// `basicLength` is the number of basic code points.
|
|
|
|
|
|
// Finish the basic string - if it is not empty - with a delimiter
|
|
|
if (basicLength) {
|
|
|
output.push(delimiter);
|
|
|
}
|
|
|
|
|
|
// Main encoding loop:
|
|
|
while (handledCPCount < inputLength) {
|
|
|
|
|
|
// All non-basic code points < n have been handled already. Find the next
|
|
|
// larger one:
|
|
|
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
|
|
currentValue = input[j];
|
|
|
if (currentValue >= n && currentValue < m) {
|
|
|
m = currentValue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
|
|
// but guard against overflow
|
|
|
handledCPCountPlusOne = handledCPCount + 1;
|
|
|
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
|
error('overflow');
|
|
|
}
|
|
|
|
|
|
delta += (m - n) * handledCPCountPlusOne;
|
|
|
n = m;
|
|
|
|
|
|
for (j = 0; j < inputLength; ++j) {
|
|
|
currentValue = input[j];
|
|
|
|
|
|
if (currentValue < n && ++delta > maxInt) {
|
|
|
error('overflow');
|
|
|
}
|
|
|
|
|
|
if (currentValue == n) {
|
|
|
// Represent delta as a generalized variable-length integer
|
|
|
for (q = delta, k = base; /* no condition */; k += base) {
|
|
|
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
|
if (q < t) {
|
|
|
break;
|
|
|
}
|
|
|
qMinusT = q - t;
|
|
|
baseMinusT = base - t;
|
|
|
output.push(
|
|
|
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
|
|
);
|
|
|
q = floor(qMinusT / baseMinusT);
|
|
|
}
|
|
|
|
|
|
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
|
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
|
delta = 0;
|
|
|
++handledCPCount;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
++delta;
|
|
|
++n;
|
|
|
|
|
|
}
|
|
|
return output.join('');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Converts a Punycode string representing a domain name or an email address
|
|
|
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
|
|
* it doesn't matter if you call it on a string that has already been
|
|
|
* converted to Unicode.
|
|
|
* @memberOf punycode
|
|
|
* @param {String} input The Punycoded domain name or email address to
|
|
|
* convert to Unicode.
|
|
|
* @returns {String} The Unicode representation of the given Punycode
|
|
|
* string.
|
|
|
*/
|
|
|
function toUnicode(input) {
|
|
|
return mapDomain(input, function(string) {
|
|
|
return regexPunycode.test(string)
|
|
|
? decode(string.slice(4).toLowerCase())
|
|
|
: string;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Converts a Unicode string representing a domain name or an email address to
|
|
|
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
|
|
* i.e. it doesn't matter if you call it with a domain that's already in
|
|
|
* ASCII.
|
|
|
* @memberOf punycode
|
|
|
* @param {String} input The domain name or email address to convert, as a
|
|
|
* Unicode string.
|
|
|
* @returns {String} The Punycode representation of the given domain name or
|
|
|
* email address.
|
|
|
*/
|
|
|
function toASCII(input) {
|
|
|
return mapDomain(input, function(string) {
|
|
|
return regexNonASCII.test(string)
|
|
|
? 'xn--' + encode(string)
|
|
|
: string;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
/** Define the public API */
|
|
|
punycode = {
|
|
|
/**
|
|
|
* A string representing the current Punycode.js version number.
|
|
|
* @memberOf punycode
|
|
|
* @type String
|
|
|
*/
|
|
|
'version': '1.4.1',
|
|
|
/**
|
|
|
* An object of methods to convert from JavaScript's internal character
|
|
|
* representation (UCS-2) to Unicode code points, and back.
|
|
|
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
|
* @memberOf punycode
|
|
|
* @type Object
|
|
|
*/
|
|
|
'ucs2': {
|
|
|
'decode': ucs2decode,
|
|
|
'encode': ucs2encode
|
|
|
},
|
|
|
'decode': decode,
|
|
|
'encode': encode,
|
|
|
'toASCII': toASCII,
|
|
|
'toUnicode': toUnicode
|
|
|
};
|
|
|
|
|
|
/** Expose `punycode` */
|
|
|
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
|
|
// like the following:
|
|
|
if (
|
|
|
typeof define == 'function' &&
|
|
|
typeof define.amd == 'object' &&
|
|
|
define.amd
|
|
|
) {
|
|
|
define('punycode', function() {
|
|
|
return punycode;
|
|
|
});
|
|
|
} else if (freeExports && freeModule) {
|
|
|
if (module.exports == freeExports) {
|
|
|
// in Node.js, io.js, or RingoJS v0.8.0+
|
|
|
freeModule.exports = punycode;
|
|
|
} else {
|
|
|
// in Narwhal or RingoJS v0.7.0-
|
|
|
for (key in punycode) {
|
|
|
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
// in Rhino or a web browser
|
|
|
root.punycode = punycode;
|
|
|
}
|
|
|
|
|
|
}(this));
|
|
|
|
|
|
}).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{}],210:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
// If obj.hasOwnProperty has been overridden, then calling
|
|
|
// obj.hasOwnProperty(prop) will break.
|
|
|
// See: https://github.com/joyent/node/issues/1707
|
|
|
function hasOwnProperty(obj, prop) {
|
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
|
}
|
|
|
|
|
|
module.exports = function(qs, sep, eq, options) {
|
|
|
sep = sep || '&';
|
|
|
eq = eq || '=';
|
|
|
var obj = {};
|
|
|
|
|
|
if (typeof qs !== 'string' || qs.length === 0) {
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
var regexp = /\+/g;
|
|
|
qs = qs.split(sep);
|
|
|
|
|
|
var maxKeys = 1000;
|
|
|
if (options && typeof options.maxKeys === 'number') {
|
|
|
maxKeys = options.maxKeys;
|
|
|
}
|
|
|
|
|
|
var len = qs.length;
|
|
|
// maxKeys <= 0 means that we should not limit keys count
|
|
|
if (maxKeys > 0 && len > maxKeys) {
|
|
|
len = maxKeys;
|
|
|
}
|
|
|
|
|
|
for (var i = 0; i < len; ++i) {
|
|
|
var x = qs[i].replace(regexp, '%20'),
|
|
|
idx = x.indexOf(eq),
|
|
|
kstr, vstr, k, v;
|
|
|
|
|
|
if (idx >= 0) {
|
|
|
kstr = x.substr(0, idx);
|
|
|
vstr = x.substr(idx + 1);
|
|
|
} else {
|
|
|
kstr = x;
|
|
|
vstr = '';
|
|
|
}
|
|
|
|
|
|
k = decodeURIComponent(kstr);
|
|
|
v = decodeURIComponent(vstr);
|
|
|
|
|
|
if (!hasOwnProperty(obj, k)) {
|
|
|
obj[k] = v;
|
|
|
} else if (isArray(obj[k])) {
|
|
|
obj[k].push(v);
|
|
|
} else {
|
|
|
obj[k] = [obj[k], v];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return obj;
|
|
|
};
|
|
|
|
|
|
var isArray = Array.isArray || function (xs) {
|
|
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
|
};
|
|
|
|
|
|
},{}],211:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
var stringifyPrimitive = function(v) {
|
|
|
switch (typeof v) {
|
|
|
case 'string':
|
|
|
return v;
|
|
|
|
|
|
case 'boolean':
|
|
|
return v ? 'true' : 'false';
|
|
|
|
|
|
case 'number':
|
|
|
return isFinite(v) ? v : '';
|
|
|
|
|
|
default:
|
|
|
return '';
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports = function(obj, sep, eq, name) {
|
|
|
sep = sep || '&';
|
|
|
eq = eq || '=';
|
|
|
if (obj === null) {
|
|
|
obj = undefined;
|
|
|
}
|
|
|
|
|
|
if (typeof obj === 'object') {
|
|
|
return map(objectKeys(obj), function(k) {
|
|
|
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
|
|
|
if (isArray(obj[k])) {
|
|
|
return map(obj[k], function(v) {
|
|
|
return ks + encodeURIComponent(stringifyPrimitive(v));
|
|
|
}).join(sep);
|
|
|
} else {
|
|
|
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
|
|
|
}
|
|
|
}).join(sep);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!name) return '';
|
|
|
return encodeURIComponent(stringifyPrimitive(name)) + eq +
|
|
|
encodeURIComponent(stringifyPrimitive(obj));
|
|
|
};
|
|
|
|
|
|
var isArray = Array.isArray || function (xs) {
|
|
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
|
};
|
|
|
|
|
|
function map (xs, f) {
|
|
|
if (xs.map) return xs.map(f);
|
|
|
var res = [];
|
|
|
for (var i = 0; i < xs.length; i++) {
|
|
|
res.push(f(xs[i], i));
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
var objectKeys = Object.keys || function (obj) {
|
|
|
var res = [];
|
|
|
for (var key in obj) {
|
|
|
if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
|
|
|
}
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
},{}],212:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
exports.decode = exports.parse = require('./decode');
|
|
|
exports.encode = exports.stringify = require('./encode');
|
|
|
|
|
|
},{"./decode":210,"./encode":211}],213:[function(require,module,exports){
|
|
|
module.exports = require('./lib/_stream_duplex.js');
|
|
|
|
|
|
},{"./lib/_stream_duplex.js":214}],214:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
// a duplex stream is just a stream that is both readable and writable.
|
|
|
// Since JS doesn't have multiple prototypal inheritance, this class
|
|
|
// prototypally inherits from Readable, and then parasitically from
|
|
|
// Writable.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var pna = require('process-nextick-args');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var objectKeys = _keys2.default || function (obj) {
|
|
|
var keys = [];
|
|
|
for (var key in obj) {
|
|
|
keys.push(key);
|
|
|
}return keys;
|
|
|
};
|
|
|
/*</replacement>*/
|
|
|
|
|
|
module.exports = Duplex;
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var util = (0, _create2.default)(require('core-util-is'));
|
|
|
util.inherits = require('inherits');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
var Readable = require('./_stream_readable');
|
|
|
var Writable = require('./_stream_writable');
|
|
|
|
|
|
util.inherits(Duplex, Readable);
|
|
|
|
|
|
{
|
|
|
// avoid scope creep, the keys array can then be collected
|
|
|
var keys = objectKeys(Writable.prototype);
|
|
|
for (var v = 0; v < keys.length; v++) {
|
|
|
var method = keys[v];
|
|
|
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function Duplex(options) {
|
|
|
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
|
|
|
|
Readable.call(this, options);
|
|
|
Writable.call(this, options);
|
|
|
|
|
|
if (options && options.readable === false) this.readable = false;
|
|
|
|
|
|
if (options && options.writable === false) this.writable = false;
|
|
|
|
|
|
this.allowHalfOpen = true;
|
|
|
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
|
|
|
|
|
this.once('end', onend);
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
|
|
// making it explicit this property is not enumerable
|
|
|
// because otherwise some prototype manipulation in
|
|
|
// userland will fail
|
|
|
enumerable: false,
|
|
|
get: function get() {
|
|
|
return this._writableState.highWaterMark;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// the no-half-open enforcer
|
|
|
function onend() {
|
|
|
// if we allow half-open state, or if the writable side ended,
|
|
|
// then we're ok.
|
|
|
if (this.allowHalfOpen || this._writableState.ended) return;
|
|
|
|
|
|
// no more data can be written.
|
|
|
// But allow more writes to happen in this tick.
|
|
|
pna.nextTick(onEndNT, this);
|
|
|
}
|
|
|
|
|
|
function onEndNT(self) {
|
|
|
self.end();
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
|
|
get: function get() {
|
|
|
if (this._readableState === undefined || this._writableState === undefined) {
|
|
|
return false;
|
|
|
}
|
|
|
return this._readableState.destroyed && this._writableState.destroyed;
|
|
|
},
|
|
|
set: function set(value) {
|
|
|
// we ignore the value if the stream
|
|
|
// has not been initialized yet
|
|
|
if (this._readableState === undefined || this._writableState === undefined) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// backward compatibility, the user is explicitly
|
|
|
// managing destroyed
|
|
|
this._readableState.destroyed = value;
|
|
|
this._writableState.destroyed = value;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Duplex.prototype._destroy = function (err, cb) {
|
|
|
this.push(null);
|
|
|
this.end();
|
|
|
|
|
|
pna.nextTick(cb, err);
|
|
|
};
|
|
|
|
|
|
},{"./_stream_readable":216,"./_stream_writable":218,"babel-runtime/core-js/object/create":55,"babel-runtime/core-js/object/keys":60,"core-util-is":189,"inherits":196,"process-nextick-args":207}],215:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
// a passthrough stream.
|
|
|
// basically just the most minimal sort of Transform stream.
|
|
|
// Every written chunk gets output as-is.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
module.exports = PassThrough;
|
|
|
|
|
|
var Transform = require('./_stream_transform');
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var util = (0, _create2.default)(require('core-util-is'));
|
|
|
util.inherits = require('inherits');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
util.inherits(PassThrough, Transform);
|
|
|
|
|
|
function PassThrough(options) {
|
|
|
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
|
|
|
|
Transform.call(this, options);
|
|
|
}
|
|
|
|
|
|
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
|
|
cb(null, chunk);
|
|
|
};
|
|
|
|
|
|
},{"./_stream_transform":217,"babel-runtime/core-js/object/create":55,"core-util-is":189,"inherits":196}],216:[function(require,module,exports){
|
|
|
(function (process,global){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
|
|
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
|
|
|
|
|
|
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var pna = require('process-nextick-args');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
module.exports = Readable;
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var isArray = require('isarray');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var Duplex;
|
|
|
/*</replacement>*/
|
|
|
|
|
|
Readable.ReadableState = ReadableState;
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var EE = require('events').EventEmitter;
|
|
|
|
|
|
var EElistenerCount = function EElistenerCount(emitter, type) {
|
|
|
return emitter.listeners(type).length;
|
|
|
};
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var Stream = require('./internal/streams/stream');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
|
|
var Buffer = require('safe-buffer').Buffer;
|
|
|
var OurUint8Array = global.Uint8Array || function () {};
|
|
|
function _uint8ArrayToBuffer(chunk) {
|
|
|
return Buffer.from(chunk);
|
|
|
}
|
|
|
function _isUint8Array(obj) {
|
|
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
|
}
|
|
|
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var util = (0, _create2.default)(require('core-util-is'));
|
|
|
util.inherits = require('inherits');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var debugUtil = require('util');
|
|
|
var debug = void 0;
|
|
|
if (debugUtil && debugUtil.debuglog) {
|
|
|
debug = debugUtil.debuglog('stream');
|
|
|
} else {
|
|
|
debug = function debug() {};
|
|
|
}
|
|
|
/*</replacement>*/
|
|
|
|
|
|
var BufferList = require('./internal/streams/BufferList');
|
|
|
var destroyImpl = require('./internal/streams/destroy');
|
|
|
var StringDecoder;
|
|
|
|
|
|
util.inherits(Readable, Stream);
|
|
|
|
|
|
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
|
|
|
|
function prependListener(emitter, event, fn) {
|
|
|
// Sadly this is not cacheable as some libraries bundle their own
|
|
|
// event emitter implementation with them.
|
|
|
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
|
|
|
// userland ones. NEVER DO THIS. This is here only because this code needs
|
|
|
// to continue to work with older versions of Node.js that do not include
|
|
|
// the prependListener() method. The goal is to eventually remove this hack.
|
|
|
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
|
|
|
}
|
|
|
|
|
|
function ReadableState(options, stream) {
|
|
|
Duplex = Duplex || require('./_stream_duplex');
|
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
// Duplex streams are both readable and writable, but share
|
|
|
// the same options object.
|
|
|
// However, some cases require setting options to different
|
|
|
// values for the readable and the writable sides of the duplex stream.
|
|
|
// These options can be provided separately as readableXXX and writableXXX.
|
|
|
var isDuplex = stream instanceof Duplex;
|
|
|
|
|
|
// object stream flag. Used to make read(n) ignore n and to
|
|
|
// make all the buffer merging and length checks go away
|
|
|
this.objectMode = !!options.objectMode;
|
|
|
|
|
|
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
|
|
|
|
// the point at which it stops calling _read() to fill the buffer
|
|
|
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
|
var hwm = options.highWaterMark;
|
|
|
var readableHwm = options.readableHighWaterMark;
|
|
|
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
|
|
|
|
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
|
|
|
|
|
|
// cast to ints.
|
|
|
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
|
|
|
|
// A linked list is used to store data chunks instead of an array because the
|
|
|
// linked list can remove elements from the beginning faster than
|
|
|
// array.shift()
|
|
|
this.buffer = new BufferList();
|
|
|
this.length = 0;
|
|
|
this.pipes = null;
|
|
|
this.pipesCount = 0;
|
|
|
this.flowing = null;
|
|
|
this.ended = false;
|
|
|
this.endEmitted = false;
|
|
|
this.reading = false;
|
|
|
|
|
|
// a flag to be able to tell if the event 'readable'/'data' is emitted
|
|
|
// immediately, or on a later tick. We set this to true at first, because
|
|
|
// any actions that shouldn't happen until "later" should generally also
|
|
|
// not happen before the first read call.
|
|
|
this.sync = true;
|
|
|
|
|
|
// whenever we return null, then we set a flag to say
|
|
|
// that we're awaiting a 'readable' event emission.
|
|
|
this.needReadable = false;
|
|
|
this.emittedReadable = false;
|
|
|
this.readableListening = false;
|
|
|
this.resumeScheduled = false;
|
|
|
|
|
|
// has it been destroyed
|
|
|
this.destroyed = false;
|
|
|
|
|
|
// Crypto is kind of old and crusty. Historically, its default string
|
|
|
// encoding is 'binary' so we have to make this configurable.
|
|
|
// Everything else in the universe uses 'utf8', though.
|
|
|
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
|
|
|
|
// the number of writers that are awaiting a drain event in .pipe()s
|
|
|
this.awaitDrain = 0;
|
|
|
|
|
|
// if true, a maybeReadMore has been scheduled
|
|
|
this.readingMore = false;
|
|
|
|
|
|
this.decoder = null;
|
|
|
this.encoding = null;
|
|
|
if (options.encoding) {
|
|
|
if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
|
|
|
this.decoder = new StringDecoder(options.encoding);
|
|
|
this.encoding = options.encoding;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function Readable(options) {
|
|
|
Duplex = Duplex || require('./_stream_duplex');
|
|
|
|
|
|
if (!(this instanceof Readable)) return new Readable(options);
|
|
|
|
|
|
this._readableState = new ReadableState(options, this);
|
|
|
|
|
|
// legacy
|
|
|
this.readable = true;
|
|
|
|
|
|
if (options) {
|
|
|
if (typeof options.read === 'function') this._read = options.read;
|
|
|
|
|
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
|
}
|
|
|
|
|
|
Stream.call(this);
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(Readable.prototype, 'destroyed', {
|
|
|
get: function get() {
|
|
|
if (this._readableState === undefined) {
|
|
|
return false;
|
|
|
}
|
|
|
return this._readableState.destroyed;
|
|
|
},
|
|
|
set: function set(value) {
|
|
|
// we ignore the value if the stream
|
|
|
// has not been initialized yet
|
|
|
if (!this._readableState) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// backward compatibility, the user is explicitly
|
|
|
// managing destroyed
|
|
|
this._readableState.destroyed = value;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Readable.prototype.destroy = destroyImpl.destroy;
|
|
|
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
|
Readable.prototype._destroy = function (err, cb) {
|
|
|
this.push(null);
|
|
|
cb(err);
|
|
|
};
|
|
|
|
|
|
// Manually shove something into the read() buffer.
|
|
|
// This returns true if the highWaterMark has not been hit yet,
|
|
|
// similar to how Writable.write() returns true if you should
|
|
|
// write() some more.
|
|
|
Readable.prototype.push = function (chunk, encoding) {
|
|
|
var state = this._readableState;
|
|
|
var skipChunkCheck;
|
|
|
|
|
|
if (!state.objectMode) {
|
|
|
if (typeof chunk === 'string') {
|
|
|
encoding = encoding || state.defaultEncoding;
|
|
|
if (encoding !== state.encoding) {
|
|
|
chunk = Buffer.from(chunk, encoding);
|
|
|
encoding = '';
|
|
|
}
|
|
|
skipChunkCheck = true;
|
|
|
}
|
|
|
} else {
|
|
|
skipChunkCheck = true;
|
|
|
}
|
|
|
|
|
|
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
|
};
|
|
|
|
|
|
// Unshift should *always* be something directly out of read()
|
|
|
Readable.prototype.unshift = function (chunk) {
|
|
|
return readableAddChunk(this, chunk, null, true, false);
|
|
|
};
|
|
|
|
|
|
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
|
var state = stream._readableState;
|
|
|
if (chunk === null) {
|
|
|
state.reading = false;
|
|
|
onEofChunk(stream, state);
|
|
|
} else {
|
|
|
var er;
|
|
|
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
|
|
if (er) {
|
|
|
stream.emit('error', er);
|
|
|
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
|
if (typeof chunk !== 'string' && !state.objectMode && (0, _getPrototypeOf2.default)(chunk) !== Buffer.prototype) {
|
|
|
chunk = _uint8ArrayToBuffer(chunk);
|
|
|
}
|
|
|
|
|
|
if (addToFront) {
|
|
|
if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
|
|
|
} else if (state.ended) {
|
|
|
stream.emit('error', new Error('stream.push() after EOF'));
|
|
|
} else {
|
|
|
state.reading = false;
|
|
|
if (state.decoder && !encoding) {
|
|
|
chunk = state.decoder.write(chunk);
|
|
|
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
|
|
|
} else {
|
|
|
addChunk(stream, state, chunk, false);
|
|
|
}
|
|
|
}
|
|
|
} else if (!addToFront) {
|
|
|
state.reading = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return needMoreData(state);
|
|
|
}
|
|
|
|
|
|
function addChunk(stream, state, chunk, addToFront) {
|
|
|
if (state.flowing && state.length === 0 && !state.sync) {
|
|
|
stream.emit('data', chunk);
|
|
|
stream.read(0);
|
|
|
} else {
|
|
|
// update the buffer info.
|
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
|
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
|
|
|
|
|
|
if (state.needReadable) emitReadable(stream);
|
|
|
}
|
|
|
maybeReadMore(stream, state);
|
|
|
}
|
|
|
|
|
|
function chunkInvalid(state, chunk) {
|
|
|
var er;
|
|
|
if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
|
|
er = new TypeError('Invalid non-string/buffer chunk');
|
|
|
}
|
|
|
return er;
|
|
|
}
|
|
|
|
|
|
// if it's past the high water mark, we can push in some more.
|
|
|
// Also, if we have no data yet, we can stand some
|
|
|
// more bytes. This is to work around cases where hwm=0,
|
|
|
// such as the repl. Also, if the push() triggered a
|
|
|
// readable event, and the user called read(largeNumber) such that
|
|
|
// needReadable was set, then we ought to push more, so that another
|
|
|
// 'readable' event will be triggered.
|
|
|
function needMoreData(state) {
|
|
|
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
|
|
}
|
|
|
|
|
|
Readable.prototype.isPaused = function () {
|
|
|
return this._readableState.flowing === false;
|
|
|
};
|
|
|
|
|
|
// backwards compatibility.
|
|
|
Readable.prototype.setEncoding = function (enc) {
|
|
|
if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
|
|
|
this._readableState.decoder = new StringDecoder(enc);
|
|
|
this._readableState.encoding = enc;
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
// Don't raise the hwm > 8MB
|
|
|
var MAX_HWM = 0x800000;
|
|
|
function computeNewHighWaterMark(n) {
|
|
|
if (n >= MAX_HWM) {
|
|
|
n = MAX_HWM;
|
|
|
} else {
|
|
|
// Get the next highest power of 2 to prevent increasing hwm excessively in
|
|
|
// tiny amounts
|
|
|
n--;
|
|
|
n |= n >>> 1;
|
|
|
n |= n >>> 2;
|
|
|
n |= n >>> 4;
|
|
|
n |= n >>> 8;
|
|
|
n |= n >>> 16;
|
|
|
n++;
|
|
|
}
|
|
|
return n;
|
|
|
}
|
|
|
|
|
|
// This function is designed to be inlinable, so please take care when making
|
|
|
// changes to the function body.
|
|
|
function howMuchToRead(n, state) {
|
|
|
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
|
if (state.objectMode) return 1;
|
|
|
if (n !== n) {
|
|
|
// Only flow one buffer at a time
|
|
|
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
|
|
}
|
|
|
// If we're asking for more than the current hwm, then raise the hwm.
|
|
|
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
|
if (n <= state.length) return n;
|
|
|
// Don't have enough
|
|
|
if (!state.ended) {
|
|
|
state.needReadable = true;
|
|
|
return 0;
|
|
|
}
|
|
|
return state.length;
|
|
|
}
|
|
|
|
|
|
// you can override either this method, or the async _read(n) below.
|
|
|
Readable.prototype.read = function (n) {
|
|
|
debug('read', n);
|
|
|
n = parseInt(n, 10);
|
|
|
var state = this._readableState;
|
|
|
var nOrig = n;
|
|
|
|
|
|
if (n !== 0) state.emittedReadable = false;
|
|
|
|
|
|
// if we're doing read(0) to trigger a readable event, but we
|
|
|
// already have a bunch of data in the buffer, then just trigger
|
|
|
// the 'readable' event and move on.
|
|
|
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
|
|
debug('read: emitReadable', state.length, state.ended);
|
|
|
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
n = howMuchToRead(n, state);
|
|
|
|
|
|
// if we've ended, and we're now clear, then finish it up.
|
|
|
if (n === 0 && state.ended) {
|
|
|
if (state.length === 0) endReadable(this);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
// All the actual chunk generation logic needs to be
|
|
|
// *below* the call to _read. The reason is that in certain
|
|
|
// synthetic stream cases, such as passthrough streams, _read
|
|
|
// may be a completely synchronous operation which may change
|
|
|
// the state of the read buffer, providing enough data when
|
|
|
// before there was *not* enough.
|
|
|
//
|
|
|
// So, the steps are:
|
|
|
// 1. Figure out what the state of things will be after we do
|
|
|
// a read from the buffer.
|
|
|
//
|
|
|
// 2. If that resulting state will trigger a _read, then call _read.
|
|
|
// Note that this may be asynchronous, or synchronous. Yes, it is
|
|
|
// deeply ugly to write APIs this way, but that still doesn't mean
|
|
|
// that the Readable class should behave improperly, as streams are
|
|
|
// designed to be sync/async agnostic.
|
|
|
// Take note if the _read call is sync or async (ie, if the read call
|
|
|
// has returned yet), so that we know whether or not it's safe to emit
|
|
|
// 'readable' etc.
|
|
|
//
|
|
|
// 3. Actually pull the requested chunks out of the buffer and return.
|
|
|
|
|
|
// if we need a readable event, then we need to do some reading.
|
|
|
var doRead = state.needReadable;
|
|
|
debug('need readable', doRead);
|
|
|
|
|
|
// if we currently have less than the highWaterMark, then also read some
|
|
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
|
doRead = true;
|
|
|
debug('length less than watermark', doRead);
|
|
|
}
|
|
|
|
|
|
// however, if we've ended, then there's no point, and if we're already
|
|
|
// reading, then it's unnecessary.
|
|
|
if (state.ended || state.reading) {
|
|
|
doRead = false;
|
|
|
debug('reading or ended', doRead);
|
|
|
} else if (doRead) {
|
|
|
debug('do read');
|
|
|
state.reading = true;
|
|
|
state.sync = true;
|
|
|
// if the length is currently zero, then we *need* a readable event.
|
|
|
if (state.length === 0) state.needReadable = true;
|
|
|
// call internal read method
|
|
|
this._read(state.highWaterMark);
|
|
|
state.sync = false;
|
|
|
// If _read pushed data synchronously, then `reading` will be false,
|
|
|
// and we need to re-evaluate how much data we can return to the user.
|
|
|
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
|
}
|
|
|
|
|
|
var ret;
|
|
|
if (n > 0) ret = fromList(n, state);else ret = null;
|
|
|
|
|
|
if (ret === null) {
|
|
|
state.needReadable = true;
|
|
|
n = 0;
|
|
|
} else {
|
|
|
state.length -= n;
|
|
|
}
|
|
|
|
|
|
if (state.length === 0) {
|
|
|
// If we have nothing in the buffer, then we want to know
|
|
|
// as soon as we *do* get something into the buffer.
|
|
|
if (!state.ended) state.needReadable = true;
|
|
|
|
|
|
// If we tried to read() past the EOF, then emit end on the next tick.
|
|
|
if (nOrig !== n && state.ended) endReadable(this);
|
|
|
}
|
|
|
|
|
|
if (ret !== null) this.emit('data', ret);
|
|
|
|
|
|
return ret;
|
|
|
};
|
|
|
|
|
|
function onEofChunk(stream, state) {
|
|
|
if (state.ended) return;
|
|
|
if (state.decoder) {
|
|
|
var chunk = state.decoder.end();
|
|
|
if (chunk && chunk.length) {
|
|
|
state.buffer.push(chunk);
|
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
|
}
|
|
|
}
|
|
|
state.ended = true;
|
|
|
|
|
|
// emit 'readable' now to make sure it gets picked up.
|
|
|
emitReadable(stream);
|
|
|
}
|
|
|
|
|
|
// Don't emit readable right away in sync mode, because this can trigger
|
|
|
// another read() call => stack overflow. This way, it might trigger
|
|
|
// a nextTick recursion warning, but that's not so bad.
|
|
|
function emitReadable(stream) {
|
|
|
var state = stream._readableState;
|
|
|
state.needReadable = false;
|
|
|
if (!state.emittedReadable) {
|
|
|
debug('emitReadable', state.flowing);
|
|
|
state.emittedReadable = true;
|
|
|
if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function emitReadable_(stream) {
|
|
|
debug('emit readable');
|
|
|
stream.emit('readable');
|
|
|
flow(stream);
|
|
|
}
|
|
|
|
|
|
// at this point, the user has presumably seen the 'readable' event,
|
|
|
// and called read() to consume some data. that may have triggered
|
|
|
// in turn another _read(n) call, in which case reading = true if
|
|
|
// it's in progress.
|
|
|
// However, if we're not ended, or reading, and the length < hwm,
|
|
|
// then go ahead and try to read some more preemptively.
|
|
|
function maybeReadMore(stream, state) {
|
|
|
if (!state.readingMore) {
|
|
|
state.readingMore = true;
|
|
|
pna.nextTick(maybeReadMore_, stream, state);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function maybeReadMore_(stream, state) {
|
|
|
var len = state.length;
|
|
|
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
|
|
debug('maybeReadMore read 0');
|
|
|
stream.read(0);
|
|
|
if (len === state.length)
|
|
|
// didn't get any data, stop spinning.
|
|
|
break;else len = state.length;
|
|
|
}
|
|
|
state.readingMore = false;
|
|
|
}
|
|
|
|
|
|
// abstract method. to be overridden in specific implementation classes.
|
|
|
// call cb(er, data) where data is <= n in length.
|
|
|
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
|
|
// arbitrary, and perhaps not very meaningful.
|
|
|
Readable.prototype._read = function (n) {
|
|
|
this.emit('error', new Error('_read() is not implemented'));
|
|
|
};
|
|
|
|
|
|
Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
|
var src = this;
|
|
|
var state = this._readableState;
|
|
|
|
|
|
switch (state.pipesCount) {
|
|
|
case 0:
|
|
|
state.pipes = dest;
|
|
|
break;
|
|
|
case 1:
|
|
|
state.pipes = [state.pipes, dest];
|
|
|
break;
|
|
|
default:
|
|
|
state.pipes.push(dest);
|
|
|
break;
|
|
|
}
|
|
|
state.pipesCount += 1;
|
|
|
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
|
|
|
|
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
|
|
|
|
var endFn = doEnd ? onend : unpipe;
|
|
|
if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
|
|
|
|
|
|
dest.on('unpipe', onunpipe);
|
|
|
function onunpipe(readable, unpipeInfo) {
|
|
|
debug('onunpipe');
|
|
|
if (readable === src) {
|
|
|
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
|
unpipeInfo.hasUnpiped = true;
|
|
|
cleanup();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function onend() {
|
|
|
debug('onend');
|
|
|
dest.end();
|
|
|
}
|
|
|
|
|
|
// when the dest drains, it reduces the awaitDrain counter
|
|
|
// on the source. This would be more elegant with a .once()
|
|
|
// handler in flow(), but adding and removing repeatedly is
|
|
|
// too slow.
|
|
|
var ondrain = pipeOnDrain(src);
|
|
|
dest.on('drain', ondrain);
|
|
|
|
|
|
var cleanedUp = false;
|
|
|
function cleanup() {
|
|
|
debug('cleanup');
|
|
|
// cleanup event handlers once the pipe is broken
|
|
|
dest.removeListener('close', onclose);
|
|
|
dest.removeListener('finish', onfinish);
|
|
|
dest.removeListener('drain', ondrain);
|
|
|
dest.removeListener('error', onerror);
|
|
|
dest.removeListener('unpipe', onunpipe);
|
|
|
src.removeListener('end', onend);
|
|
|
src.removeListener('end', unpipe);
|
|
|
src.removeListener('data', ondata);
|
|
|
|
|
|
cleanedUp = true;
|
|
|
|
|
|
// if the reader is waiting for a drain event from this
|
|
|
// specific writer, then it would cause it to never start
|
|
|
// flowing again.
|
|
|
// So, if this is awaiting a drain, then we just call it now.
|
|
|
// If we don't know, then assume that we are waiting for one.
|
|
|
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
|
}
|
|
|
|
|
|
// If the user pushes more data while we're writing to dest then we'll end up
|
|
|
// in ondata again. However, we only want to increase awaitDrain once because
|
|
|
// dest will only emit one 'drain' event for the multiple writes.
|
|
|
// => Introduce a guard on increasing awaitDrain.
|
|
|
var increasedAwaitDrain = false;
|
|
|
src.on('data', ondata);
|
|
|
function ondata(chunk) {
|
|
|
debug('ondata');
|
|
|
increasedAwaitDrain = false;
|
|
|
var ret = dest.write(chunk);
|
|
|
if (false === ret && !increasedAwaitDrain) {
|
|
|
// If the user unpiped during `dest.write()`, it is possible
|
|
|
// to get stuck in a permanently paused state if that write
|
|
|
// also returned false.
|
|
|
// => Check whether `dest` is still a piping destination.
|
|
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
|
debug('false write response, pause', src._readableState.awaitDrain);
|
|
|
src._readableState.awaitDrain++;
|
|
|
increasedAwaitDrain = true;
|
|
|
}
|
|
|
src.pause();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if the dest has an error, then stop piping into it.
|
|
|
// however, don't suppress the throwing behavior for this.
|
|
|
function onerror(er) {
|
|
|
debug('onerror', er);
|
|
|
unpipe();
|
|
|
dest.removeListener('error', onerror);
|
|
|
if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
|
|
|
}
|
|
|
|
|
|
// Make sure our error handler is attached before userland ones.
|
|
|
prependListener(dest, 'error', onerror);
|
|
|
|
|
|
// Both close and finish should trigger unpipe, but only once.
|
|
|
function onclose() {
|
|
|
dest.removeListener('finish', onfinish);
|
|
|
unpipe();
|
|
|
}
|
|
|
dest.once('close', onclose);
|
|
|
function onfinish() {
|
|
|
debug('onfinish');
|
|
|
dest.removeListener('close', onclose);
|
|
|
unpipe();
|
|
|
}
|
|
|
dest.once('finish', onfinish);
|
|
|
|
|
|
function unpipe() {
|
|
|
debug('unpipe');
|
|
|
src.unpipe(dest);
|
|
|
}
|
|
|
|
|
|
// tell the dest that it's being piped to
|
|
|
dest.emit('pipe', src);
|
|
|
|
|
|
// start the flow if it hasn't been started already.
|
|
|
if (!state.flowing) {
|
|
|
debug('pipe resume');
|
|
|
src.resume();
|
|
|
}
|
|
|
|
|
|
return dest;
|
|
|
};
|
|
|
|
|
|
function pipeOnDrain(src) {
|
|
|
return function () {
|
|
|
var state = src._readableState;
|
|
|
debug('pipeOnDrain', state.awaitDrain);
|
|
|
if (state.awaitDrain) state.awaitDrain--;
|
|
|
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
|
|
|
state.flowing = true;
|
|
|
flow(src);
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
Readable.prototype.unpipe = function (dest) {
|
|
|
var state = this._readableState;
|
|
|
var unpipeInfo = { hasUnpiped: false };
|
|
|
|
|
|
// if we're not piping anywhere, then do nothing.
|
|
|
if (state.pipesCount === 0) return this;
|
|
|
|
|
|
// just one destination. most common case.
|
|
|
if (state.pipesCount === 1) {
|
|
|
// passed in one, but it's not the right one.
|
|
|
if (dest && dest !== state.pipes) return this;
|
|
|
|
|
|
if (!dest) dest = state.pipes;
|
|
|
|
|
|
// got a match.
|
|
|
state.pipes = null;
|
|
|
state.pipesCount = 0;
|
|
|
state.flowing = false;
|
|
|
if (dest) dest.emit('unpipe', this, unpipeInfo);
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
// slow case. multiple pipe destinations.
|
|
|
|
|
|
if (!dest) {
|
|
|
// remove all.
|
|
|
var dests = state.pipes;
|
|
|
var len = state.pipesCount;
|
|
|
state.pipes = null;
|
|
|
state.pipesCount = 0;
|
|
|
state.flowing = false;
|
|
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
dests[i].emit('unpipe', this, unpipeInfo);
|
|
|
}return this;
|
|
|
}
|
|
|
|
|
|
// try to find the right one.
|
|
|
var index = indexOf(state.pipes, dest);
|
|
|
if (index === -1) return this;
|
|
|
|
|
|
state.pipes.splice(index, 1);
|
|
|
state.pipesCount -= 1;
|
|
|
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
|
|
|
|
dest.emit('unpipe', this, unpipeInfo);
|
|
|
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
// set up data events if they are asked for
|
|
|
// Ensure readable listeners eventually get something
|
|
|
Readable.prototype.on = function (ev, fn) {
|
|
|
var res = Stream.prototype.on.call(this, ev, fn);
|
|
|
|
|
|
if (ev === 'data') {
|
|
|
// Start flowing on next tick if stream isn't explicitly paused
|
|
|
if (this._readableState.flowing !== false) this.resume();
|
|
|
} else if (ev === 'readable') {
|
|
|
var state = this._readableState;
|
|
|
if (!state.endEmitted && !state.readableListening) {
|
|
|
state.readableListening = state.needReadable = true;
|
|
|
state.emittedReadable = false;
|
|
|
if (!state.reading) {
|
|
|
pna.nextTick(nReadingNextTick, this);
|
|
|
} else if (state.length) {
|
|
|
emitReadable(this);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
};
|
|
|
Readable.prototype.addListener = Readable.prototype.on;
|
|
|
|
|
|
function nReadingNextTick(self) {
|
|
|
debug('readable nexttick read 0');
|
|
|
self.read(0);
|
|
|
}
|
|
|
|
|
|
// pause() and resume() are remnants of the legacy readable stream API
|
|
|
// If the user uses them, then switch into old mode.
|
|
|
Readable.prototype.resume = function () {
|
|
|
var state = this._readableState;
|
|
|
if (!state.flowing) {
|
|
|
debug('resume');
|
|
|
state.flowing = true;
|
|
|
resume(this, state);
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
function resume(stream, state) {
|
|
|
if (!state.resumeScheduled) {
|
|
|
state.resumeScheduled = true;
|
|
|
pna.nextTick(resume_, stream, state);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function resume_(stream, state) {
|
|
|
if (!state.reading) {
|
|
|
debug('resume read 0');
|
|
|
stream.read(0);
|
|
|
}
|
|
|
|
|
|
state.resumeScheduled = false;
|
|
|
state.awaitDrain = 0;
|
|
|
stream.emit('resume');
|
|
|
flow(stream);
|
|
|
if (state.flowing && !state.reading) stream.read(0);
|
|
|
}
|
|
|
|
|
|
Readable.prototype.pause = function () {
|
|
|
debug('call pause flowing=%j', this._readableState.flowing);
|
|
|
if (false !== this._readableState.flowing) {
|
|
|
debug('pause');
|
|
|
this._readableState.flowing = false;
|
|
|
this.emit('pause');
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
function flow(stream) {
|
|
|
var state = stream._readableState;
|
|
|
debug('flow', state.flowing);
|
|
|
while (state.flowing && stream.read() !== null) {}
|
|
|
}
|
|
|
|
|
|
// wrap an old-style stream as the async data source.
|
|
|
// This is *not* part of the readable stream interface.
|
|
|
// It is an ugly unfortunate mess of history.
|
|
|
Readable.prototype.wrap = function (stream) {
|
|
|
var _this = this;
|
|
|
|
|
|
var state = this._readableState;
|
|
|
var paused = false;
|
|
|
|
|
|
stream.on('end', function () {
|
|
|
debug('wrapped end');
|
|
|
if (state.decoder && !state.ended) {
|
|
|
var chunk = state.decoder.end();
|
|
|
if (chunk && chunk.length) _this.push(chunk);
|
|
|
}
|
|
|
|
|
|
_this.push(null);
|
|
|
});
|
|
|
|
|
|
stream.on('data', function (chunk) {
|
|
|
debug('wrapped data');
|
|
|
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
|
|
|
|
// don't skip over falsy values in objectMode
|
|
|
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
|
|
|
|
var ret = _this.push(chunk);
|
|
|
if (!ret) {
|
|
|
paused = true;
|
|
|
stream.pause();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// proxy all the other methods.
|
|
|
// important when wrapping filters and duplexes.
|
|
|
for (var i in stream) {
|
|
|
if (this[i] === undefined && typeof stream[i] === 'function') {
|
|
|
this[i] = function (method) {
|
|
|
return function () {
|
|
|
return stream[method].apply(stream, arguments);
|
|
|
};
|
|
|
}(i);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// proxy certain important events.
|
|
|
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
|
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
|
}
|
|
|
|
|
|
// when we try to consume some more bytes, simply unpause the
|
|
|
// underlying stream.
|
|
|
this._read = function (n) {
|
|
|
debug('wrapped _read', n);
|
|
|
if (paused) {
|
|
|
paused = false;
|
|
|
stream.resume();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
|
|
|
// making it explicit this property is not enumerable
|
|
|
// because otherwise some prototype manipulation in
|
|
|
// userland will fail
|
|
|
enumerable: false,
|
|
|
get: function get() {
|
|
|
return this._readableState.highWaterMark;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// exposed for testing purposes only.
|
|
|
Readable._fromList = fromList;
|
|
|
|
|
|
// Pluck off n bytes from an array of buffers.
|
|
|
// Length is the combined lengths of all the buffers in the list.
|
|
|
// This function is designed to be inlinable, so please take care when making
|
|
|
// changes to the function body.
|
|
|
function fromList(n, state) {
|
|
|
// nothing buffered
|
|
|
if (state.length === 0) return null;
|
|
|
|
|
|
var ret;
|
|
|
if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
|
|
|
// read it all, truncate the list
|
|
|
if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
|
|
|
state.buffer.clear();
|
|
|
} else {
|
|
|
// read part of list
|
|
|
ret = fromListPartial(n, state.buffer, state.decoder);
|
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
// Extracts only enough buffered data to satisfy the amount requested.
|
|
|
// This function is designed to be inlinable, so please take care when making
|
|
|
// changes to the function body.
|
|
|
function fromListPartial(n, list, hasStrings) {
|
|
|
var ret;
|
|
|
if (n < list.head.data.length) {
|
|
|
// slice is the same for buffers and strings
|
|
|
ret = list.head.data.slice(0, n);
|
|
|
list.head.data = list.head.data.slice(n);
|
|
|
} else if (n === list.head.data.length) {
|
|
|
// first chunk is a perfect match
|
|
|
ret = list.shift();
|
|
|
} else {
|
|
|
// result spans more than one buffer
|
|
|
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
// Copies a specified amount of characters from the list of buffered data
|
|
|
// chunks.
|
|
|
// This function is designed to be inlinable, so please take care when making
|
|
|
// changes to the function body.
|
|
|
function copyFromBufferString(n, list) {
|
|
|
var p = list.head;
|
|
|
var c = 1;
|
|
|
var ret = p.data;
|
|
|
n -= ret.length;
|
|
|
while (p = p.next) {
|
|
|
var str = p.data;
|
|
|
var nb = n > str.length ? str.length : n;
|
|
|
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
|
|
n -= nb;
|
|
|
if (n === 0) {
|
|
|
if (nb === str.length) {
|
|
|
++c;
|
|
|
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
|
|
} else {
|
|
|
list.head = p;
|
|
|
p.data = str.slice(nb);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
++c;
|
|
|
}
|
|
|
list.length -= c;
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
// Copies a specified amount of bytes from the list of buffered data chunks.
|
|
|
// This function is designed to be inlinable, so please take care when making
|
|
|
// changes to the function body.
|
|
|
function copyFromBuffer(n, list) {
|
|
|
var ret = Buffer.allocUnsafe(n);
|
|
|
var p = list.head;
|
|
|
var c = 1;
|
|
|
p.data.copy(ret);
|
|
|
n -= p.data.length;
|
|
|
while (p = p.next) {
|
|
|
var buf = p.data;
|
|
|
var nb = n > buf.length ? buf.length : n;
|
|
|
buf.copy(ret, ret.length - n, 0, nb);
|
|
|
n -= nb;
|
|
|
if (n === 0) {
|
|
|
if (nb === buf.length) {
|
|
|
++c;
|
|
|
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
|
|
} else {
|
|
|
list.head = p;
|
|
|
p.data = buf.slice(nb);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
++c;
|
|
|
}
|
|
|
list.length -= c;
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
function endReadable(stream) {
|
|
|
var state = stream._readableState;
|
|
|
|
|
|
// If we get here before consuming all the bytes, then that is a
|
|
|
// bug in node. Should never happen.
|
|
|
if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
|
|
|
|
|
|
if (!state.endEmitted) {
|
|
|
state.ended = true;
|
|
|
pna.nextTick(endReadableNT, state, stream);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function endReadableNT(state, stream) {
|
|
|
// Check that we didn't get one last unshift.
|
|
|
if (!state.endEmitted && state.length === 0) {
|
|
|
state.endEmitted = true;
|
|
|
stream.readable = false;
|
|
|
stream.emit('end');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function indexOf(xs, x) {
|
|
|
for (var i = 0, l = xs.length; i < l; i++) {
|
|
|
if (xs[i] === x) return i;
|
|
|
}
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
}).call(this,require('_process'),typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{"./_stream_duplex":214,"./internal/streams/BufferList":219,"./internal/streams/destroy":220,"./internal/streams/stream":221,"_process":208,"babel-runtime/core-js/object/create":55,"babel-runtime/core-js/object/get-prototype-of":59,"core-util-is":189,"events":192,"inherits":196,"isarray":198,"process-nextick-args":207,"safe-buffer":228,"string_decoder/":235,"util":71}],217:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
// a transform stream is a readable/writable stream where you do
|
|
|
// something with the data. Sometimes it's called a "filter",
|
|
|
// but that's not a great name for it, since that implies a thing where
|
|
|
// some bits pass through, and others are simply ignored. (That would
|
|
|
// be a valid example of a transform, of course.)
|
|
|
//
|
|
|
// While the output is causally related to the input, it's not a
|
|
|
// necessarily symmetric or synchronous transformation. For example,
|
|
|
// a zlib stream might take multiple plain-text writes(), and then
|
|
|
// emit a single compressed chunk some time in the future.
|
|
|
//
|
|
|
// Here's how this works:
|
|
|
//
|
|
|
// The Transform stream has all the aspects of the readable and writable
|
|
|
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
|
|
// internally, and returns false if there's a lot of pending writes
|
|
|
// buffered up. When you call read(), that calls _read(n) until
|
|
|
// there's enough pending readable data buffered up.
|
|
|
//
|
|
|
// In a transform stream, the written data is placed in a buffer. When
|
|
|
// _read(n) is called, it transforms the queued up data, calling the
|
|
|
// buffered _write cb's as it consumes chunks. If consuming a single
|
|
|
// written chunk would result in multiple output chunks, then the first
|
|
|
// outputted bit calls the readcb, and subsequent chunks just go into
|
|
|
// the read buffer, and will cause it to emit 'readable' if necessary.
|
|
|
//
|
|
|
// This way, back-pressure is actually determined by the reading side,
|
|
|
// since _read has to be called to start processing a new chunk. However,
|
|
|
// a pathological inflate type of transform can cause excessive buffering
|
|
|
// here. For example, imagine a stream where every byte of input is
|
|
|
// interpreted as an integer from 0-255, and then results in that many
|
|
|
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
|
|
// 1kb of data being output. In this case, you could write a very small
|
|
|
// amount of input, and end up with a very large amount of output. In
|
|
|
// such a pathological inflating mechanism, there'd be no way to tell
|
|
|
// the system to stop doing the transform. A single 4MB write could
|
|
|
// cause the system to run out of memory.
|
|
|
//
|
|
|
// However, even in such a pathological case, only a single written chunk
|
|
|
// would be consumed, and then the rest would wait (un-transformed) until
|
|
|
// the results of the previous transformed chunk were consumed.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
module.exports = Transform;
|
|
|
|
|
|
var Duplex = require('./_stream_duplex');
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var util = (0, _create2.default)(require('core-util-is'));
|
|
|
util.inherits = require('inherits');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
util.inherits(Transform, Duplex);
|
|
|
|
|
|
function afterTransform(er, data) {
|
|
|
var ts = this._transformState;
|
|
|
ts.transforming = false;
|
|
|
|
|
|
var cb = ts.writecb;
|
|
|
|
|
|
if (!cb) {
|
|
|
return this.emit('error', new Error('write callback called multiple times'));
|
|
|
}
|
|
|
|
|
|
ts.writechunk = null;
|
|
|
ts.writecb = null;
|
|
|
|
|
|
if (data != null) // single equals check for both `null` and `undefined`
|
|
|
this.push(data);
|
|
|
|
|
|
cb(er);
|
|
|
|
|
|
var rs = this._readableState;
|
|
|
rs.reading = false;
|
|
|
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
|
this._read(rs.highWaterMark);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function Transform(options) {
|
|
|
if (!(this instanceof Transform)) return new Transform(options);
|
|
|
|
|
|
Duplex.call(this, options);
|
|
|
|
|
|
this._transformState = {
|
|
|
afterTransform: afterTransform.bind(this),
|
|
|
needTransform: false,
|
|
|
transforming: false,
|
|
|
writecb: null,
|
|
|
writechunk: null,
|
|
|
writeencoding: null
|
|
|
};
|
|
|
|
|
|
// start out asking for a readable event once data is transformed.
|
|
|
this._readableState.needReadable = true;
|
|
|
|
|
|
// we have implemented the _read method, and done the other things
|
|
|
// that Readable wants before the first _read call, so unset the
|
|
|
// sync guard flag.
|
|
|
this._readableState.sync = false;
|
|
|
|
|
|
if (options) {
|
|
|
if (typeof options.transform === 'function') this._transform = options.transform;
|
|
|
|
|
|
if (typeof options.flush === 'function') this._flush = options.flush;
|
|
|
}
|
|
|
|
|
|
// When the writable side finishes, then flush out anything remaining.
|
|
|
this.on('prefinish', prefinish);
|
|
|
}
|
|
|
|
|
|
function prefinish() {
|
|
|
var _this = this;
|
|
|
|
|
|
if (typeof this._flush === 'function') {
|
|
|
this._flush(function (er, data) {
|
|
|
done(_this, er, data);
|
|
|
});
|
|
|
} else {
|
|
|
done(this, null, null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Transform.prototype.push = function (chunk, encoding) {
|
|
|
this._transformState.needTransform = false;
|
|
|
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
|
};
|
|
|
|
|
|
// This is the part where you do stuff!
|
|
|
// override this function in implementation classes.
|
|
|
// 'chunk' is an input chunk.
|
|
|
//
|
|
|
// Call `push(newChunk)` to pass along transformed output
|
|
|
// to the readable side. You may call 'push' zero or more times.
|
|
|
//
|
|
|
// Call `cb(err)` when you are done with this chunk. If you pass
|
|
|
// an error, then that'll put the hurt on the whole operation. If you
|
|
|
// never call cb(), then you'll never get another chunk.
|
|
|
Transform.prototype._transform = function (chunk, encoding, cb) {
|
|
|
throw new Error('_transform() is not implemented');
|
|
|
};
|
|
|
|
|
|
Transform.prototype._write = function (chunk, encoding, cb) {
|
|
|
var ts = this._transformState;
|
|
|
ts.writecb = cb;
|
|
|
ts.writechunk = chunk;
|
|
|
ts.writeencoding = encoding;
|
|
|
if (!ts.transforming) {
|
|
|
var rs = this._readableState;
|
|
|
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// Doesn't matter what the args are here.
|
|
|
// _transform does all the work.
|
|
|
// That we got here means that the readable side wants more data.
|
|
|
Transform.prototype._read = function (n) {
|
|
|
var ts = this._transformState;
|
|
|
|
|
|
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
|
|
ts.transforming = true;
|
|
|
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
|
} else {
|
|
|
// mark that we need a transform, so that any data that comes in
|
|
|
// will get processed, now that we've asked for it.
|
|
|
ts.needTransform = true;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Transform.prototype._destroy = function (err, cb) {
|
|
|
var _this2 = this;
|
|
|
|
|
|
Duplex.prototype._destroy.call(this, err, function (err2) {
|
|
|
cb(err2);
|
|
|
_this2.emit('close');
|
|
|
});
|
|
|
};
|
|
|
|
|
|
function done(stream, er, data) {
|
|
|
if (er) return stream.emit('error', er);
|
|
|
|
|
|
if (data != null) // single equals check for both `null` and `undefined`
|
|
|
stream.push(data);
|
|
|
|
|
|
// if there's nothing in the write buffer, then that means
|
|
|
// that nothing more will ever be provided
|
|
|
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
|
|
|
|
|
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
|
|
|
|
|
return stream.push(null);
|
|
|
}
|
|
|
|
|
|
},{"./_stream_duplex":214,"babel-runtime/core-js/object/create":55,"core-util-is":189,"inherits":196}],218:[function(require,module,exports){
|
|
|
(function (process,global){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
// A bit simpler than readable streams.
|
|
|
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
|
|
// the drain event emission and buffering.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
|
|
var _defineProperty = require('babel-runtime/core-js/object/define-property');
|
|
|
|
|
|
var _defineProperty2 = _interopRequireDefault(_defineProperty);
|
|
|
|
|
|
var _hasInstance = require('babel-runtime/core-js/symbol/has-instance');
|
|
|
|
|
|
var _hasInstance2 = _interopRequireDefault(_hasInstance);
|
|
|
|
|
|
var _symbol = require('babel-runtime/core-js/symbol');
|
|
|
|
|
|
var _symbol2 = _interopRequireDefault(_symbol);
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
var _setImmediate2 = require('babel-runtime/core-js/set-immediate');
|
|
|
|
|
|
var _setImmediate3 = _interopRequireDefault(_setImmediate2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var pna = require('process-nextick-args');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
module.exports = Writable;
|
|
|
|
|
|
/* <replacement> */
|
|
|
function WriteReq(chunk, encoding, cb) {
|
|
|
this.chunk = chunk;
|
|
|
this.encoding = encoding;
|
|
|
this.callback = cb;
|
|
|
this.next = null;
|
|
|
}
|
|
|
|
|
|
// It seems a linked list but it is not
|
|
|
// there will be only 2 of these for each stream
|
|
|
function CorkedRequest(state) {
|
|
|
var _this = this;
|
|
|
|
|
|
this.next = null;
|
|
|
this.entry = null;
|
|
|
this.finish = function () {
|
|
|
onCorkedFinish(_this, state);
|
|
|
};
|
|
|
}
|
|
|
/* </replacement> */
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? _setImmediate3.default : pna.nextTick;
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var Duplex;
|
|
|
/*</replacement>*/
|
|
|
|
|
|
Writable.WritableState = WritableState;
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var util = (0, _create2.default)(require('core-util-is'));
|
|
|
util.inherits = require('inherits');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var internalUtil = {
|
|
|
deprecate: require('util-deprecate')
|
|
|
};
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
var Stream = require('./internal/streams/stream');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
|
|
var Buffer = require('safe-buffer').Buffer;
|
|
|
var OurUint8Array = global.Uint8Array || function () {};
|
|
|
function _uint8ArrayToBuffer(chunk) {
|
|
|
return Buffer.from(chunk);
|
|
|
}
|
|
|
function _isUint8Array(obj) {
|
|
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
|
}
|
|
|
|
|
|
/*</replacement>*/
|
|
|
|
|
|
var destroyImpl = require('./internal/streams/destroy');
|
|
|
|
|
|
util.inherits(Writable, Stream);
|
|
|
|
|
|
function nop() {}
|
|
|
|
|
|
function WritableState(options, stream) {
|
|
|
Duplex = Duplex || require('./_stream_duplex');
|
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
// Duplex streams are both readable and writable, but share
|
|
|
// the same options object.
|
|
|
// However, some cases require setting options to different
|
|
|
// values for the readable and the writable sides of the duplex stream.
|
|
|
// These options can be provided separately as readableXXX and writableXXX.
|
|
|
var isDuplex = stream instanceof Duplex;
|
|
|
|
|
|
// object stream flag to indicate whether or not this stream
|
|
|
// contains buffers or objects.
|
|
|
this.objectMode = !!options.objectMode;
|
|
|
|
|
|
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
|
|
|
|
// the point at which write() starts returning false
|
|
|
// Note: 0 is a valid value, means that we always return false if
|
|
|
// the entire buffer is not flushed immediately on write()
|
|
|
var hwm = options.highWaterMark;
|
|
|
var writableHwm = options.writableHighWaterMark;
|
|
|
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
|
|
|
|
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
|
|
|
|
|
// cast to ints.
|
|
|
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
|
|
|
|
// if _final has been called
|
|
|
this.finalCalled = false;
|
|
|
|
|
|
// drain event flag.
|
|
|
this.needDrain = false;
|
|
|
// at the start of calling end()
|
|
|
this.ending = false;
|
|
|
// when end() has been called, and returned
|
|
|
this.ended = false;
|
|
|
// when 'finish' is emitted
|
|
|
this.finished = false;
|
|
|
|
|
|
// has it been destroyed
|
|
|
this.destroyed = false;
|
|
|
|
|
|
// should we decode strings into buffers before passing to _write?
|
|
|
// this is here so that some node-core streams can optimize string
|
|
|
// handling at a lower level.
|
|
|
var noDecode = options.decodeStrings === false;
|
|
|
this.decodeStrings = !noDecode;
|
|
|
|
|
|
// Crypto is kind of old and crusty. Historically, its default string
|
|
|
// encoding is 'binary' so we have to make this configurable.
|
|
|
// Everything else in the universe uses 'utf8', though.
|
|
|
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
|
|
|
|
// not an actual buffer we keep track of, but a measurement
|
|
|
// of how much we're waiting to get pushed to some underlying
|
|
|
// socket or file.
|
|
|
this.length = 0;
|
|
|
|
|
|
// a flag to see when we're in the middle of a write.
|
|
|
this.writing = false;
|
|
|
|
|
|
// when true all writes will be buffered until .uncork() call
|
|
|
this.corked = 0;
|
|
|
|
|
|
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
|
// or on a later tick. We set this to true at first, because any
|
|
|
// actions that shouldn't happen until "later" should generally also
|
|
|
// not happen before the first write call.
|
|
|
this.sync = true;
|
|
|
|
|
|
// a flag to know if we're processing previously buffered items, which
|
|
|
// may call the _write() callback in the same tick, so that we don't
|
|
|
// end up in an overlapped onwrite situation.
|
|
|
this.bufferProcessing = false;
|
|
|
|
|
|
// the callback that's passed to _write(chunk,cb)
|
|
|
this.onwrite = function (er) {
|
|
|
onwrite(stream, er);
|
|
|
};
|
|
|
|
|
|
// the callback that the user supplies to write(chunk,encoding,cb)
|
|
|
this.writecb = null;
|
|
|
|
|
|
// the amount that is being written when _write is called.
|
|
|
this.writelen = 0;
|
|
|
|
|
|
this.bufferedRequest = null;
|
|
|
this.lastBufferedRequest = null;
|
|
|
|
|
|
// number of pending user-supplied write callbacks
|
|
|
// this must be 0 before 'finish' can be emitted
|
|
|
this.pendingcb = 0;
|
|
|
|
|
|
// emit prefinish if the only thing we're waiting for is _write cbs
|
|
|
// This is relevant for synchronous Transform streams
|
|
|
this.prefinished = false;
|
|
|
|
|
|
// True if the error was already emitted and should not be thrown again
|
|
|
this.errorEmitted = false;
|
|
|
|
|
|
// count buffered requests
|
|
|
this.bufferedRequestCount = 0;
|
|
|
|
|
|
// allocate the first CorkedRequest, there is always
|
|
|
// one allocated and free to use, and we maintain at most two
|
|
|
this.corkedRequestsFree = new CorkedRequest(this);
|
|
|
}
|
|
|
|
|
|
WritableState.prototype.getBuffer = function getBuffer() {
|
|
|
var current = this.bufferedRequest;
|
|
|
var out = [];
|
|
|
while (current) {
|
|
|
out.push(current);
|
|
|
current = current.next;
|
|
|
}
|
|
|
return out;
|
|
|
};
|
|
|
|
|
|
(function () {
|
|
|
try {
|
|
|
Object.defineProperty(WritableState.prototype, 'buffer', {
|
|
|
get: internalUtil.deprecate(function () {
|
|
|
return this.getBuffer();
|
|
|
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
|
|
});
|
|
|
} catch (_) {}
|
|
|
})();
|
|
|
|
|
|
// Test _writableState for inheritance to account for Duplex streams,
|
|
|
// whose prototype chain only points to Readable.
|
|
|
var realHasInstance;
|
|
|
if (typeof _symbol2.default === 'function' && _hasInstance2.default && typeof Function.prototype[_hasInstance2.default] === 'function') {
|
|
|
realHasInstance = Function.prototype[_hasInstance2.default];
|
|
|
(0, _defineProperty2.default)(Writable, _hasInstance2.default, {
|
|
|
value: function value(object) {
|
|
|
if (realHasInstance.call(this, object)) return true;
|
|
|
if (this !== Writable) return false;
|
|
|
|
|
|
return object && object._writableState instanceof WritableState;
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
realHasInstance = function realHasInstance(object) {
|
|
|
return object instanceof this;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function Writable(options) {
|
|
|
Duplex = Duplex || require('./_stream_duplex');
|
|
|
|
|
|
// Writable ctor is applied to Duplexes, too.
|
|
|
// `realHasInstance` is necessary because using plain `instanceof`
|
|
|
// would return false, as no `_writableState` property is attached.
|
|
|
|
|
|
// Trying to use the custom `instanceof` for Writable here will also break the
|
|
|
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
|
|
// `_writableState` that would lead to infinite recursion.
|
|
|
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
|
|
return new Writable(options);
|
|
|
}
|
|
|
|
|
|
this._writableState = new WritableState(options, this);
|
|
|
|
|
|
// legacy.
|
|
|
this.writable = true;
|
|
|
|
|
|
if (options) {
|
|
|
if (typeof options.write === 'function') this._write = options.write;
|
|
|
|
|
|
if (typeof options.writev === 'function') this._writev = options.writev;
|
|
|
|
|
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
|
|
|
|
if (typeof options.final === 'function') this._final = options.final;
|
|
|
}
|
|
|
|
|
|
Stream.call(this);
|
|
|
}
|
|
|
|
|
|
// Otherwise people can pipe Writable streams, which is just wrong.
|
|
|
Writable.prototype.pipe = function () {
|
|
|
this.emit('error', new Error('Cannot pipe, not readable'));
|
|
|
};
|
|
|
|
|
|
function writeAfterEnd(stream, cb) {
|
|
|
var er = new Error('write after end');
|
|
|
// TODO: defer error events consistently everywhere, not just the cb
|
|
|
stream.emit('error', er);
|
|
|
pna.nextTick(cb, er);
|
|
|
}
|
|
|
|
|
|
// Checks that a user-supplied chunk is valid, especially for the particular
|
|
|
// mode the stream is in. Currently this means that `null` is never accepted
|
|
|
// and undefined/non-string values are only allowed in object mode.
|
|
|
function validChunk(stream, state, chunk, cb) {
|
|
|
var valid = true;
|
|
|
var er = false;
|
|
|
|
|
|
if (chunk === null) {
|
|
|
er = new TypeError('May not write null values to stream');
|
|
|
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
|
|
er = new TypeError('Invalid non-string/buffer chunk');
|
|
|
}
|
|
|
if (er) {
|
|
|
stream.emit('error', er);
|
|
|
pna.nextTick(cb, er);
|
|
|
valid = false;
|
|
|
}
|
|
|
return valid;
|
|
|
}
|
|
|
|
|
|
Writable.prototype.write = function (chunk, encoding, cb) {
|
|
|
var state = this._writableState;
|
|
|
var ret = false;
|
|
|
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
|
|
|
|
|
if (isBuf && !Buffer.isBuffer(chunk)) {
|
|
|
chunk = _uint8ArrayToBuffer(chunk);
|
|
|
}
|
|
|
|
|
|
if (typeof encoding === 'function') {
|
|
|
cb = encoding;
|
|
|
encoding = null;
|
|
|
}
|
|
|
|
|
|
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
|
|
|
|
|
if (typeof cb !== 'function') cb = nop;
|
|
|
|
|
|
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
|
|
state.pendingcb++;
|
|
|
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
};
|
|
|
|
|
|
Writable.prototype.cork = function () {
|
|
|
var state = this._writableState;
|
|
|
|
|
|
state.corked++;
|
|
|
};
|
|
|
|
|
|
Writable.prototype.uncork = function () {
|
|
|
var state = this._writableState;
|
|
|
|
|
|
if (state.corked) {
|
|
|
state.corked--;
|
|
|
|
|
|
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
|
// node::ParseEncoding() requires lower case.
|
|
|
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
|
|
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
|
|
this._writableState.defaultEncoding = encoding;
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
function decodeChunk(state, chunk, encoding) {
|
|
|
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
|
|
chunk = Buffer.from(chunk, encoding);
|
|
|
}
|
|
|
return chunk;
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
|
|
// making it explicit this property is not enumerable
|
|
|
// because otherwise some prototype manipulation in
|
|
|
// userland will fail
|
|
|
enumerable: false,
|
|
|
get: function get() {
|
|
|
return this._writableState.highWaterMark;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// if we're already writing something, then just put this
|
|
|
// in the queue, and wait our turn. Otherwise, call _write
|
|
|
// If we return false, then we need a drain event, so set that flag.
|
|
|
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|
|
if (!isBuf) {
|
|
|
var newChunk = decodeChunk(state, chunk, encoding);
|
|
|
if (chunk !== newChunk) {
|
|
|
isBuf = true;
|
|
|
encoding = 'buffer';
|
|
|
chunk = newChunk;
|
|
|
}
|
|
|
}
|
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
|
|
|
|
state.length += len;
|
|
|
|
|
|
var ret = state.length < state.highWaterMark;
|
|
|
// we must ensure that previous needDrain will not be reset to false.
|
|
|
if (!ret) state.needDrain = true;
|
|
|
|
|
|
if (state.writing || state.corked) {
|
|
|
var last = state.lastBufferedRequest;
|
|
|
state.lastBufferedRequest = {
|
|
|
chunk: chunk,
|
|
|
encoding: encoding,
|
|
|
isBuf: isBuf,
|
|
|
callback: cb,
|
|
|
next: null
|
|
|
};
|
|
|
if (last) {
|
|
|
last.next = state.lastBufferedRequest;
|
|
|
} else {
|
|
|
state.bufferedRequest = state.lastBufferedRequest;
|
|
|
}
|
|
|
state.bufferedRequestCount += 1;
|
|
|
} else {
|
|
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
|
state.writelen = len;
|
|
|
state.writecb = cb;
|
|
|
state.writing = true;
|
|
|
state.sync = true;
|
|
|
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
|
|
state.sync = false;
|
|
|
}
|
|
|
|
|
|
function onwriteError(stream, state, sync, er, cb) {
|
|
|
--state.pendingcb;
|
|
|
|
|
|
if (sync) {
|
|
|
// defer the callback if we are being called synchronously
|
|
|
// to avoid piling up things on the stack
|
|
|
pna.nextTick(cb, er);
|
|
|
// this can emit finish, and it will always happen
|
|
|
// after error
|
|
|
pna.nextTick(finishMaybe, stream, state);
|
|
|
stream._writableState.errorEmitted = true;
|
|
|
stream.emit('error', er);
|
|
|
} else {
|
|
|
// the caller expect this to happen before if
|
|
|
// it is async
|
|
|
cb(er);
|
|
|
stream._writableState.errorEmitted = true;
|
|
|
stream.emit('error', er);
|
|
|
// this can emit finish, but finish must
|
|
|
// always follow error
|
|
|
finishMaybe(stream, state);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function onwriteStateUpdate(state) {
|
|
|
state.writing = false;
|
|
|
state.writecb = null;
|
|
|
state.length -= state.writelen;
|
|
|
state.writelen = 0;
|
|
|
}
|
|
|
|
|
|
function onwrite(stream, er) {
|
|
|
var state = stream._writableState;
|
|
|
var sync = state.sync;
|
|
|
var cb = state.writecb;
|
|
|
|
|
|
onwriteStateUpdate(state);
|
|
|
|
|
|
if (er) onwriteError(stream, state, sync, er, cb);else {
|
|
|
// Check if we're actually ready to finish, but don't emit yet
|
|
|
var finished = needFinish(state);
|
|
|
|
|
|
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
|
|
clearBuffer(stream, state);
|
|
|
}
|
|
|
|
|
|
if (sync) {
|
|
|
/*<replacement>*/
|
|
|
asyncWrite(afterWrite, stream, state, finished, cb);
|
|
|
/*</replacement>*/
|
|
|
} else {
|
|
|
afterWrite(stream, state, finished, cb);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function afterWrite(stream, state, finished, cb) {
|
|
|
if (!finished) onwriteDrain(stream, state);
|
|
|
state.pendingcb--;
|
|
|
cb();
|
|
|
finishMaybe(stream, state);
|
|
|
}
|
|
|
|
|
|
// Must force callback to be called on nextTick, so that we don't
|
|
|
// emit 'drain' before the write() consumer gets the 'false' return
|
|
|
// value, and has a chance to attach a 'drain' listener.
|
|
|
function onwriteDrain(stream, state) {
|
|
|
if (state.length === 0 && state.needDrain) {
|
|
|
state.needDrain = false;
|
|
|
stream.emit('drain');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if there's something in the buffer waiting, then process it
|
|
|
function clearBuffer(stream, state) {
|
|
|
state.bufferProcessing = true;
|
|
|
var entry = state.bufferedRequest;
|
|
|
|
|
|
if (stream._writev && entry && entry.next) {
|
|
|
// Fast case, write everything using _writev()
|
|
|
var l = state.bufferedRequestCount;
|
|
|
var buffer = new Array(l);
|
|
|
var holder = state.corkedRequestsFree;
|
|
|
holder.entry = entry;
|
|
|
|
|
|
var count = 0;
|
|
|
var allBuffers = true;
|
|
|
while (entry) {
|
|
|
buffer[count] = entry;
|
|
|
if (!entry.isBuf) allBuffers = false;
|
|
|
entry = entry.next;
|
|
|
count += 1;
|
|
|
}
|
|
|
buffer.allBuffers = allBuffers;
|
|
|
|
|
|
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
|
|
|
|
|
// doWrite is almost always async, defer these to save a bit of time
|
|
|
// as the hot path ends with doWrite
|
|
|
state.pendingcb++;
|
|
|
state.lastBufferedRequest = null;
|
|
|
if (holder.next) {
|
|
|
state.corkedRequestsFree = holder.next;
|
|
|
holder.next = null;
|
|
|
} else {
|
|
|
state.corkedRequestsFree = new CorkedRequest(state);
|
|
|
}
|
|
|
state.bufferedRequestCount = 0;
|
|
|
} else {
|
|
|
// Slow case, write chunks one-by-one
|
|
|
while (entry) {
|
|
|
var chunk = entry.chunk;
|
|
|
var encoding = entry.encoding;
|
|
|
var cb = entry.callback;
|
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
|
|
|
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
|
entry = entry.next;
|
|
|
state.bufferedRequestCount--;
|
|
|
// if we didn't call the onwrite immediately, then
|
|
|
// it means that we need to wait until it does.
|
|
|
// also, that means that the chunk and cb are currently
|
|
|
// being processed, so move the buffer counter past them.
|
|
|
if (state.writing) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (entry === null) state.lastBufferedRequest = null;
|
|
|
}
|
|
|
|
|
|
state.bufferedRequest = entry;
|
|
|
state.bufferProcessing = false;
|
|
|
}
|
|
|
|
|
|
Writable.prototype._write = function (chunk, encoding, cb) {
|
|
|
cb(new Error('_write() is not implemented'));
|
|
|
};
|
|
|
|
|
|
Writable.prototype._writev = null;
|
|
|
|
|
|
Writable.prototype.end = function (chunk, encoding, cb) {
|
|
|
var state = this._writableState;
|
|
|
|
|
|
if (typeof chunk === 'function') {
|
|
|
cb = chunk;
|
|
|
chunk = null;
|
|
|
encoding = null;
|
|
|
} else if (typeof encoding === 'function') {
|
|
|
cb = encoding;
|
|
|
encoding = null;
|
|
|
}
|
|
|
|
|
|
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
|
|
|
|
|
// .end() fully uncorks
|
|
|
if (state.corked) {
|
|
|
state.corked = 1;
|
|
|
this.uncork();
|
|
|
}
|
|
|
|
|
|
// ignore unnecessary end() calls.
|
|
|
if (!state.ending && !state.finished) endWritable(this, state, cb);
|
|
|
};
|
|
|
|
|
|
function needFinish(state) {
|
|
|
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
|
}
|
|
|
function callFinal(stream, state) {
|
|
|
stream._final(function (err) {
|
|
|
state.pendingcb--;
|
|
|
if (err) {
|
|
|
stream.emit('error', err);
|
|
|
}
|
|
|
state.prefinished = true;
|
|
|
stream.emit('prefinish');
|
|
|
finishMaybe(stream, state);
|
|
|
});
|
|
|
}
|
|
|
function prefinish(stream, state) {
|
|
|
if (!state.prefinished && !state.finalCalled) {
|
|
|
if (typeof stream._final === 'function') {
|
|
|
state.pendingcb++;
|
|
|
state.finalCalled = true;
|
|
|
pna.nextTick(callFinal, stream, state);
|
|
|
} else {
|
|
|
state.prefinished = true;
|
|
|
stream.emit('prefinish');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function finishMaybe(stream, state) {
|
|
|
var need = needFinish(state);
|
|
|
if (need) {
|
|
|
prefinish(stream, state);
|
|
|
if (state.pendingcb === 0) {
|
|
|
state.finished = true;
|
|
|
stream.emit('finish');
|
|
|
}
|
|
|
}
|
|
|
return need;
|
|
|
}
|
|
|
|
|
|
function endWritable(stream, state, cb) {
|
|
|
state.ending = true;
|
|
|
finishMaybe(stream, state);
|
|
|
if (cb) {
|
|
|
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
|
|
}
|
|
|
state.ended = true;
|
|
|
stream.writable = false;
|
|
|
}
|
|
|
|
|
|
function onCorkedFinish(corkReq, state, err) {
|
|
|
var entry = corkReq.entry;
|
|
|
corkReq.entry = null;
|
|
|
while (entry) {
|
|
|
var cb = entry.callback;
|
|
|
state.pendingcb--;
|
|
|
cb(err);
|
|
|
entry = entry.next;
|
|
|
}
|
|
|
if (state.corkedRequestsFree) {
|
|
|
state.corkedRequestsFree.next = corkReq;
|
|
|
} else {
|
|
|
state.corkedRequestsFree = corkReq;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(Writable.prototype, 'destroyed', {
|
|
|
get: function get() {
|
|
|
if (this._writableState === undefined) {
|
|
|
return false;
|
|
|
}
|
|
|
return this._writableState.destroyed;
|
|
|
},
|
|
|
set: function set(value) {
|
|
|
// we ignore the value if the stream
|
|
|
// has not been initialized yet
|
|
|
if (!this._writableState) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// backward compatibility, the user is explicitly
|
|
|
// managing destroyed
|
|
|
this._writableState.destroyed = value;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Writable.prototype.destroy = destroyImpl.destroy;
|
|
|
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
|
Writable.prototype._destroy = function (err, cb) {
|
|
|
this.end();
|
|
|
cb(err);
|
|
|
};
|
|
|
|
|
|
}).call(this,require('_process'),typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{"./_stream_duplex":214,"./internal/streams/destroy":220,"./internal/streams/stream":221,"_process":208,"babel-runtime/core-js/object/create":55,"babel-runtime/core-js/object/define-property":56,"babel-runtime/core-js/set-immediate":62,"babel-runtime/core-js/symbol":64,"babel-runtime/core-js/symbol/has-instance":65,"core-util-is":189,"inherits":196,"process-nextick-args":207,"safe-buffer":228,"util-deprecate":240}],219:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
function _classCallCheck(instance, Constructor) {
|
|
|
if (!(instance instanceof Constructor)) {
|
|
|
throw new TypeError("Cannot call a class as a function");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var Buffer = require('safe-buffer').Buffer;
|
|
|
var util = require('util');
|
|
|
|
|
|
function copyBuffer(src, target, offset) {
|
|
|
src.copy(target, offset);
|
|
|
}
|
|
|
|
|
|
module.exports = function () {
|
|
|
function BufferList() {
|
|
|
_classCallCheck(this, BufferList);
|
|
|
|
|
|
this.head = null;
|
|
|
this.tail = null;
|
|
|
this.length = 0;
|
|
|
}
|
|
|
|
|
|
BufferList.prototype.push = function push(v) {
|
|
|
var entry = { data: v, next: null };
|
|
|
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
|
|
this.tail = entry;
|
|
|
++this.length;
|
|
|
};
|
|
|
|
|
|
BufferList.prototype.unshift = function unshift(v) {
|
|
|
var entry = { data: v, next: this.head };
|
|
|
if (this.length === 0) this.tail = entry;
|
|
|
this.head = entry;
|
|
|
++this.length;
|
|
|
};
|
|
|
|
|
|
BufferList.prototype.shift = function shift() {
|
|
|
if (this.length === 0) return;
|
|
|
var ret = this.head.data;
|
|
|
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
|
|
--this.length;
|
|
|
return ret;
|
|
|
};
|
|
|
|
|
|
BufferList.prototype.clear = function clear() {
|
|
|
this.head = this.tail = null;
|
|
|
this.length = 0;
|
|
|
};
|
|
|
|
|
|
BufferList.prototype.join = function join(s) {
|
|
|
if (this.length === 0) return '';
|
|
|
var p = this.head;
|
|
|
var ret = '' + p.data;
|
|
|
while (p = p.next) {
|
|
|
ret += s + p.data;
|
|
|
}return ret;
|
|
|
};
|
|
|
|
|
|
BufferList.prototype.concat = function concat(n) {
|
|
|
if (this.length === 0) return Buffer.alloc(0);
|
|
|
if (this.length === 1) return this.head.data;
|
|
|
var ret = Buffer.allocUnsafe(n >>> 0);
|
|
|
var p = this.head;
|
|
|
var i = 0;
|
|
|
while (p) {
|
|
|
copyBuffer(p.data, ret, i);
|
|
|
i += p.data.length;
|
|
|
p = p.next;
|
|
|
}
|
|
|
return ret;
|
|
|
};
|
|
|
|
|
|
return BufferList;
|
|
|
}();
|
|
|
|
|
|
if (util && util.inspect && util.inspect.custom) {
|
|
|
module.exports.prototype[util.inspect.custom] = function () {
|
|
|
var obj = util.inspect({ length: this.length });
|
|
|
return this.constructor.name + ' ' + obj;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
},{"safe-buffer":228,"util":71}],220:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
|
|
var pna = require('process-nextick-args');
|
|
|
/*</replacement>*/
|
|
|
|
|
|
// undocumented cb() API, needed for core, not for public API
|
|
|
function destroy(err, cb) {
|
|
|
var _this = this;
|
|
|
|
|
|
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
|
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
|
|
|
|
if (readableDestroyed || writableDestroyed) {
|
|
|
if (cb) {
|
|
|
cb(err);
|
|
|
} else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
|
|
|
pna.nextTick(emitErrorNT, this, err);
|
|
|
}
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
// we set destroyed to true before firing error callbacks in order
|
|
|
// to make it re-entrance safe in case destroy() is called within callbacks
|
|
|
|
|
|
if (this._readableState) {
|
|
|
this._readableState.destroyed = true;
|
|
|
}
|
|
|
|
|
|
// if this is a duplex stream mark the writable part as destroyed as well
|
|
|
if (this._writableState) {
|
|
|
this._writableState.destroyed = true;
|
|
|
}
|
|
|
|
|
|
this._destroy(err || null, function (err) {
|
|
|
if (!cb && err) {
|
|
|
pna.nextTick(emitErrorNT, _this, err);
|
|
|
if (_this._writableState) {
|
|
|
_this._writableState.errorEmitted = true;
|
|
|
}
|
|
|
} else if (cb) {
|
|
|
cb(err);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
function undestroy() {
|
|
|
if (this._readableState) {
|
|
|
this._readableState.destroyed = false;
|
|
|
this._readableState.reading = false;
|
|
|
this._readableState.ended = false;
|
|
|
this._readableState.endEmitted = false;
|
|
|
}
|
|
|
|
|
|
if (this._writableState) {
|
|
|
this._writableState.destroyed = false;
|
|
|
this._writableState.ended = false;
|
|
|
this._writableState.ending = false;
|
|
|
this._writableState.finished = false;
|
|
|
this._writableState.errorEmitted = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function emitErrorNT(self, err) {
|
|
|
self.emit('error', err);
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
|
|
destroy: destroy,
|
|
|
undestroy: undestroy
|
|
|
};
|
|
|
|
|
|
},{"process-nextick-args":207}],221:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
module.exports = require('events').EventEmitter;
|
|
|
|
|
|
},{"events":192}],222:[function(require,module,exports){
|
|
|
module.exports = require('./readable').PassThrough
|
|
|
|
|
|
},{"./readable":223}],223:[function(require,module,exports){
|
|
|
exports = module.exports = require('./lib/_stream_readable.js');
|
|
|
exports.Stream = exports;
|
|
|
exports.Readable = exports;
|
|
|
exports.Writable = require('./lib/_stream_writable.js');
|
|
|
exports.Duplex = require('./lib/_stream_duplex.js');
|
|
|
exports.Transform = require('./lib/_stream_transform.js');
|
|
|
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
|
|
|
|
|
},{"./lib/_stream_duplex.js":214,"./lib/_stream_passthrough.js":215,"./lib/_stream_readable.js":216,"./lib/_stream_transform.js":217,"./lib/_stream_writable.js":218}],224:[function(require,module,exports){
|
|
|
module.exports = require('./readable').Transform
|
|
|
|
|
|
},{"./readable":223}],225:[function(require,module,exports){
|
|
|
module.exports = require('./lib/_stream_writable.js');
|
|
|
|
|
|
},{"./lib/_stream_writable.js":218}],226:[function(require,module,exports){
|
|
|
/**
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
*
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
*/
|
|
|
|
|
|
// This method of obtaining a reference to the global object needs to be
|
|
|
// kept identical to the way it is obtained in runtime.js
|
|
|
var g = (function() { return this })() || Function("return this")();
|
|
|
|
|
|
// Use `getOwnPropertyNames` because not all browsers support calling
|
|
|
// `hasOwnProperty` on the global `self` object in a worker. See #183.
|
|
|
var hadRuntime = g.regeneratorRuntime &&
|
|
|
Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
|
|
|
|
|
|
// Save the old regeneratorRuntime in case it needs to be restored later.
|
|
|
var oldRuntime = hadRuntime && g.regeneratorRuntime;
|
|
|
|
|
|
// Force reevalutation of runtime.js.
|
|
|
g.regeneratorRuntime = undefined;
|
|
|
|
|
|
module.exports = require("./runtime");
|
|
|
|
|
|
if (hadRuntime) {
|
|
|
// Restore the original runtime.
|
|
|
g.regeneratorRuntime = oldRuntime;
|
|
|
} else {
|
|
|
// Remove the global property added by runtime.js.
|
|
|
try {
|
|
|
delete g.regeneratorRuntime;
|
|
|
} catch(e) {
|
|
|
g.regeneratorRuntime = undefined;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},{"./runtime":227}],227:[function(require,module,exports){
|
|
|
/**
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
*
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
*/
|
|
|
|
|
|
!(function(global) {
|
|
|
"use strict";
|
|
|
|
|
|
var Op = Object.prototype;
|
|
|
var hasOwn = Op.hasOwnProperty;
|
|
|
var undefined; // More compressible than void 0.
|
|
|
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
|
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
|
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
|
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
|
|
|
|
var inModule = typeof module === "object";
|
|
|
var runtime = global.regeneratorRuntime;
|
|
|
if (runtime) {
|
|
|
if (inModule) {
|
|
|
// If regeneratorRuntime is defined globally and we're in a module,
|
|
|
// make the exports object identical to regeneratorRuntime.
|
|
|
module.exports = runtime;
|
|
|
}
|
|
|
// Don't bother evaluating the rest of this file if the runtime was
|
|
|
// already defined globally.
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Define the runtime globally (as expected by generated code) as either
|
|
|
// module.exports (if we're in a module) or a new, empty object.
|
|
|
runtime = global.regeneratorRuntime = inModule ? module.exports : {};
|
|
|
|
|
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
|
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
|
var generator = Object.create(protoGenerator.prototype);
|
|
|
var context = new Context(tryLocsList || []);
|
|
|
|
|
|
// The ._invoke method unifies the implementations of the .next,
|
|
|
// .throw, and .return methods.
|
|
|
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
|
|
|
|
return generator;
|
|
|
}
|
|
|
runtime.wrap = wrap;
|
|
|
|
|
|
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
|
// record like context.tryEntries[i].completion. This interface could
|
|
|
// have been (and was previously) designed to take a closure to be
|
|
|
// invoked without arguments, but in all the cases we care about we
|
|
|
// already have an existing method we want to call, so there's no need
|
|
|
// to create a new function object. We can even get away with assuming
|
|
|
// the method takes exactly one argument, since that happens to be true
|
|
|
// in every case, so we don't have to touch the arguments object. The
|
|
|
// only additional allocation required is the completion record, which
|
|
|
// has a stable shape and so hopefully should be cheap to allocate.
|
|
|
function tryCatch(fn, obj, arg) {
|
|
|
try {
|
|
|
return { type: "normal", arg: fn.call(obj, arg) };
|
|
|
} catch (err) {
|
|
|
return { type: "throw", arg: err };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var GenStateSuspendedStart = "suspendedStart";
|
|
|
var GenStateSuspendedYield = "suspendedYield";
|
|
|
var GenStateExecuting = "executing";
|
|
|
var GenStateCompleted = "completed";
|
|
|
|
|
|
// Returning this object from the innerFn has the same effect as
|
|
|
// breaking out of the dispatch switch statement.
|
|
|
var ContinueSentinel = {};
|
|
|
|
|
|
// Dummy constructor functions that we use as the .constructor and
|
|
|
// .constructor.prototype properties for functions that return Generator
|
|
|
// objects. For full spec compliance, you may wish to configure your
|
|
|
// minifier not to mangle the names of these two functions.
|
|
|
function Generator() {}
|
|
|
function GeneratorFunction() {}
|
|
|
function GeneratorFunctionPrototype() {}
|
|
|
|
|
|
// This is a polyfill for %IteratorPrototype% for environments that
|
|
|
// don't natively support it.
|
|
|
var IteratorPrototype = {};
|
|
|
IteratorPrototype[iteratorSymbol] = function () {
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
var getProto = Object.getPrototypeOf;
|
|
|
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
|
if (NativeIteratorPrototype &&
|
|
|
NativeIteratorPrototype !== Op &&
|
|
|
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
|
// This environment has a native %IteratorPrototype%; use it instead
|
|
|
// of the polyfill.
|
|
|
IteratorPrototype = NativeIteratorPrototype;
|
|
|
}
|
|
|
|
|
|
var Gp = GeneratorFunctionPrototype.prototype =
|
|
|
Generator.prototype = Object.create(IteratorPrototype);
|
|
|
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
|
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
|
GeneratorFunctionPrototype[toStringTagSymbol] =
|
|
|
GeneratorFunction.displayName = "GeneratorFunction";
|
|
|
|
|
|
// Helper for defining the .next, .throw, and .return methods of the
|
|
|
// Iterator interface in terms of a single ._invoke method.
|
|
|
function defineIteratorMethods(prototype) {
|
|
|
["next", "throw", "return"].forEach(function(method) {
|
|
|
prototype[method] = function(arg) {
|
|
|
return this._invoke(method, arg);
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
|
|
|
runtime.isGeneratorFunction = function(genFun) {
|
|
|
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
|
return ctor
|
|
|
? ctor === GeneratorFunction ||
|
|
|
// For the native GeneratorFunction constructor, the best we can
|
|
|
// do is to check its .name property.
|
|
|
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
|
: false;
|
|
|
};
|
|
|
|
|
|
runtime.mark = function(genFun) {
|
|
|
if (Object.setPrototypeOf) {
|
|
|
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
|
} else {
|
|
|
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
|
if (!(toStringTagSymbol in genFun)) {
|
|
|
genFun[toStringTagSymbol] = "GeneratorFunction";
|
|
|
}
|
|
|
}
|
|
|
genFun.prototype = Object.create(Gp);
|
|
|
return genFun;
|
|
|
};
|
|
|
|
|
|
// Within the body of any async function, `await x` is transformed to
|
|
|
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
|
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
|
// meant to be awaited.
|
|
|
runtime.awrap = function(arg) {
|
|
|
return { __await: arg };
|
|
|
};
|
|
|
|
|
|
function AsyncIterator(generator) {
|
|
|
function invoke(method, arg, resolve, reject) {
|
|
|
var record = tryCatch(generator[method], generator, arg);
|
|
|
if (record.type === "throw") {
|
|
|
reject(record.arg);
|
|
|
} else {
|
|
|
var result = record.arg;
|
|
|
var value = result.value;
|
|
|
if (value &&
|
|
|
typeof value === "object" &&
|
|
|
hasOwn.call(value, "__await")) {
|
|
|
return Promise.resolve(value.__await).then(function(value) {
|
|
|
invoke("next", value, resolve, reject);
|
|
|
}, function(err) {
|
|
|
invoke("throw", err, resolve, reject);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return Promise.resolve(value).then(function(unwrapped) {
|
|
|
// When a yielded Promise is resolved, its final value becomes
|
|
|
// the .value of the Promise<{value,done}> result for the
|
|
|
// current iteration. If the Promise is rejected, however, the
|
|
|
// result for this iteration will be rejected with the same
|
|
|
// reason. Note that rejections of yielded Promises are not
|
|
|
// thrown back into the generator function, as is the case
|
|
|
// when an awaited Promise is rejected. This difference in
|
|
|
// behavior between yield and await is important, because it
|
|
|
// allows the consumer to decide what to do with the yielded
|
|
|
// rejection (swallow it and continue, manually .throw it back
|
|
|
// into the generator, abandon iteration, whatever). With
|
|
|
// await, by contrast, there is no opportunity to examine the
|
|
|
// rejection reason outside the generator function, so the
|
|
|
// only option is to throw it from the await expression, and
|
|
|
// let the generator function handle the exception.
|
|
|
result.value = unwrapped;
|
|
|
resolve(result);
|
|
|
}, reject);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var previousPromise;
|
|
|
|
|
|
function enqueue(method, arg) {
|
|
|
function callInvokeWithMethodAndArg() {
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
invoke(method, arg, resolve, reject);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return previousPromise =
|
|
|
// If enqueue has been called before, then we want to wait until
|
|
|
// all previous Promises have been resolved before calling invoke,
|
|
|
// so that results are always delivered in the correct order. If
|
|
|
// enqueue has not been called before, then it is important to
|
|
|
// call invoke immediately, without waiting on a callback to fire,
|
|
|
// so that the async generator function has the opportunity to do
|
|
|
// any necessary setup in a predictable way. This predictability
|
|
|
// is why the Promise constructor synchronously invokes its
|
|
|
// executor callback, and why async functions synchronously
|
|
|
// execute code before the first await. Since we implement simple
|
|
|
// async functions in terms of async generators, it is especially
|
|
|
// important to get this right, even though it requires care.
|
|
|
previousPromise ? previousPromise.then(
|
|
|
callInvokeWithMethodAndArg,
|
|
|
// Avoid propagating failures to Promises returned by later
|
|
|
// invocations of the iterator.
|
|
|
callInvokeWithMethodAndArg
|
|
|
) : callInvokeWithMethodAndArg();
|
|
|
}
|
|
|
|
|
|
// Define the unified helper method that is used to implement .next,
|
|
|
// .throw, and .return (see defineIteratorMethods).
|
|
|
this._invoke = enqueue;
|
|
|
}
|
|
|
|
|
|
defineIteratorMethods(AsyncIterator.prototype);
|
|
|
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
|
return this;
|
|
|
};
|
|
|
runtime.AsyncIterator = AsyncIterator;
|
|
|
|
|
|
// Note that simple async functions are implemented on top of
|
|
|
// AsyncIterator objects; they just return a Promise for the value of
|
|
|
// the final result produced by the iterator.
|
|
|
runtime.async = function(innerFn, outerFn, self, tryLocsList) {
|
|
|
var iter = new AsyncIterator(
|
|
|
wrap(innerFn, outerFn, self, tryLocsList)
|
|
|
);
|
|
|
|
|
|
return runtime.isGeneratorFunction(outerFn)
|
|
|
? iter // If outerFn is a generator, return the full iterator.
|
|
|
: iter.next().then(function(result) {
|
|
|
return result.done ? result.value : iter.next();
|
|
|
});
|
|
|
};
|
|
|
|
|
|
function makeInvokeMethod(innerFn, self, context) {
|
|
|
var state = GenStateSuspendedStart;
|
|
|
|
|
|
return function invoke(method, arg) {
|
|
|
if (state === GenStateExecuting) {
|
|
|
throw new Error("Generator is already running");
|
|
|
}
|
|
|
|
|
|
if (state === GenStateCompleted) {
|
|
|
if (method === "throw") {
|
|
|
throw arg;
|
|
|
}
|
|
|
|
|
|
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
|
return doneResult();
|
|
|
}
|
|
|
|
|
|
context.method = method;
|
|
|
context.arg = arg;
|
|
|
|
|
|
while (true) {
|
|
|
var delegate = context.delegate;
|
|
|
if (delegate) {
|
|
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
|
if (delegateResult) {
|
|
|
if (delegateResult === ContinueSentinel) continue;
|
|
|
return delegateResult;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (context.method === "next") {
|
|
|
// Setting context._sent for legacy support of Babel's
|
|
|
// function.sent implementation.
|
|
|
context.sent = context._sent = context.arg;
|
|
|
|
|
|
} else if (context.method === "throw") {
|
|
|
if (state === GenStateSuspendedStart) {
|
|
|
state = GenStateCompleted;
|
|
|
throw context.arg;
|
|
|
}
|
|
|
|
|
|
context.dispatchException(context.arg);
|
|
|
|
|
|
} else if (context.method === "return") {
|
|
|
context.abrupt("return", context.arg);
|
|
|
}
|
|
|
|
|
|
state = GenStateExecuting;
|
|
|
|
|
|
var record = tryCatch(innerFn, self, context);
|
|
|
if (record.type === "normal") {
|
|
|
// If an exception is thrown from innerFn, we leave state ===
|
|
|
// GenStateExecuting and loop back for another invocation.
|
|
|
state = context.done
|
|
|
? GenStateCompleted
|
|
|
: GenStateSuspendedYield;
|
|
|
|
|
|
if (record.arg === ContinueSentinel) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
value: record.arg,
|
|
|
done: context.done
|
|
|
};
|
|
|
|
|
|
} else if (record.type === "throw") {
|
|
|
state = GenStateCompleted;
|
|
|
// Dispatch the exception by looping back around to the
|
|
|
// context.dispatchException(context.arg) call above.
|
|
|
context.method = "throw";
|
|
|
context.arg = record.arg;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
|
// result, either by returning a { value, done } result from the
|
|
|
// delegate iterator, or by modifying context.method and context.arg,
|
|
|
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
|
function maybeInvokeDelegate(delegate, context) {
|
|
|
var method = delegate.iterator[context.method];
|
|
|
if (method === undefined) {
|
|
|
// A .throw or .return when the delegate iterator has no .throw
|
|
|
// method always terminates the yield* loop.
|
|
|
context.delegate = null;
|
|
|
|
|
|
if (context.method === "throw") {
|
|
|
if (delegate.iterator.return) {
|
|
|
// If the delegate iterator has a return method, give it a
|
|
|
// chance to clean up.
|
|
|
context.method = "return";
|
|
|
context.arg = undefined;
|
|
|
maybeInvokeDelegate(delegate, context);
|
|
|
|
|
|
if (context.method === "throw") {
|
|
|
// If maybeInvokeDelegate(context) changed context.method from
|
|
|
// "return" to "throw", let that override the TypeError below.
|
|
|
return ContinueSentinel;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
context.method = "throw";
|
|
|
context.arg = new TypeError(
|
|
|
"The iterator does not provide a 'throw' method");
|
|
|
}
|
|
|
|
|
|
return ContinueSentinel;
|
|
|
}
|
|
|
|
|
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
|
|
|
|
if (record.type === "throw") {
|
|
|
context.method = "throw";
|
|
|
context.arg = record.arg;
|
|
|
context.delegate = null;
|
|
|
return ContinueSentinel;
|
|
|
}
|
|
|
|
|
|
var info = record.arg;
|
|
|
|
|
|
if (! info) {
|
|
|
context.method = "throw";
|
|
|
context.arg = new TypeError("iterator result is not an object");
|
|
|
context.delegate = null;
|
|
|
return ContinueSentinel;
|
|
|
}
|
|
|
|
|
|
if (info.done) {
|
|
|
// Assign the result of the finished delegate to the temporary
|
|
|
// variable specified by delegate.resultName (see delegateYield).
|
|
|
context[delegate.resultName] = info.value;
|
|
|
|
|
|
// Resume execution at the desired location (see delegateYield).
|
|
|
context.next = delegate.nextLoc;
|
|
|
|
|
|
// If context.method was "throw" but the delegate handled the
|
|
|
// exception, let the outer generator proceed normally. If
|
|
|
// context.method was "next", forget context.arg since it has been
|
|
|
// "consumed" by the delegate iterator. If context.method was
|
|
|
// "return", allow the original .return call to continue in the
|
|
|
// outer generator.
|
|
|
if (context.method !== "return") {
|
|
|
context.method = "next";
|
|
|
context.arg = undefined;
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
// Re-yield the result returned by the delegate method.
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
// The delegate iterator is finished, so forget it and continue with
|
|
|
// the outer generator.
|
|
|
context.delegate = null;
|
|
|
return ContinueSentinel;
|
|
|
}
|
|
|
|
|
|
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
|
// unified ._invoke helper method.
|
|
|
defineIteratorMethods(Gp);
|
|
|
|
|
|
Gp[toStringTagSymbol] = "Generator";
|
|
|
|
|
|
// A Generator should always return itself as the iterator object when the
|
|
|
// @@iterator function is called on it. Some browsers' implementations of the
|
|
|
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
|
// object to not be returned from this call. This ensures that doesn't happen.
|
|
|
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
|
Gp[iteratorSymbol] = function() {
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
Gp.toString = function() {
|
|
|
return "[object Generator]";
|
|
|
};
|
|
|
|
|
|
function pushTryEntry(locs) {
|
|
|
var entry = { tryLoc: locs[0] };
|
|
|
|
|
|
if (1 in locs) {
|
|
|
entry.catchLoc = locs[1];
|
|
|
}
|
|
|
|
|
|
if (2 in locs) {
|
|
|
entry.finallyLoc = locs[2];
|
|
|
entry.afterLoc = locs[3];
|
|
|
}
|
|
|
|
|
|
this.tryEntries.push(entry);
|
|
|
}
|
|
|
|
|
|
function resetTryEntry(entry) {
|
|
|
var record = entry.completion || {};
|
|
|
record.type = "normal";
|
|
|
delete record.arg;
|
|
|
entry.completion = record;
|
|
|
}
|
|
|
|
|
|
function Context(tryLocsList) {
|
|
|
// The root entry object (effectively a try statement without a catch
|
|
|
// or a finally block) gives us a place to store values thrown from
|
|
|
// locations where there is no enclosing try statement.
|
|
|
this.tryEntries = [{ tryLoc: "root" }];
|
|
|
tryLocsList.forEach(pushTryEntry, this);
|
|
|
this.reset(true);
|
|
|
}
|
|
|
|
|
|
runtime.keys = function(object) {
|
|
|
var keys = [];
|
|
|
for (var key in object) {
|
|
|
keys.push(key);
|
|
|
}
|
|
|
keys.reverse();
|
|
|
|
|
|
// Rather than returning an object with a next method, we keep
|
|
|
// things simple and return the next function itself.
|
|
|
return function next() {
|
|
|
while (keys.length) {
|
|
|
var key = keys.pop();
|
|
|
if (key in object) {
|
|
|
next.value = key;
|
|
|
next.done = false;
|
|
|
return next;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// To avoid creating an additional object, we just hang the .value
|
|
|
// and .done properties off the next function object itself. This
|
|
|
// also ensures that the minifier will not anonymize the function.
|
|
|
next.done = true;
|
|
|
return next;
|
|
|
};
|
|
|
};
|
|
|
|
|
|
function values(iterable) {
|
|
|
if (iterable) {
|
|
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
|
if (iteratorMethod) {
|
|
|
return iteratorMethod.call(iterable);
|
|
|
}
|
|
|
|
|
|
if (typeof iterable.next === "function") {
|
|
|
return iterable;
|
|
|
}
|
|
|
|
|
|
if (!isNaN(iterable.length)) {
|
|
|
var i = -1, next = function next() {
|
|
|
while (++i < iterable.length) {
|
|
|
if (hasOwn.call(iterable, i)) {
|
|
|
next.value = iterable[i];
|
|
|
next.done = false;
|
|
|
return next;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
next.value = undefined;
|
|
|
next.done = true;
|
|
|
|
|
|
return next;
|
|
|
};
|
|
|
|
|
|
return next.next = next;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Return an iterator with no values.
|
|
|
return { next: doneResult };
|
|
|
}
|
|
|
runtime.values = values;
|
|
|
|
|
|
function doneResult() {
|
|
|
return { value: undefined, done: true };
|
|
|
}
|
|
|
|
|
|
Context.prototype = {
|
|
|
constructor: Context,
|
|
|
|
|
|
reset: function(skipTempReset) {
|
|
|
this.prev = 0;
|
|
|
this.next = 0;
|
|
|
// Resetting context._sent for legacy support of Babel's
|
|
|
// function.sent implementation.
|
|
|
this.sent = this._sent = undefined;
|
|
|
this.done = false;
|
|
|
this.delegate = null;
|
|
|
|
|
|
this.method = "next";
|
|
|
this.arg = undefined;
|
|
|
|
|
|
this.tryEntries.forEach(resetTryEntry);
|
|
|
|
|
|
if (!skipTempReset) {
|
|
|
for (var name in this) {
|
|
|
// Not sure about the optimal order of these conditions:
|
|
|
if (name.charAt(0) === "t" &&
|
|
|
hasOwn.call(this, name) &&
|
|
|
!isNaN(+name.slice(1))) {
|
|
|
this[name] = undefined;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
stop: function() {
|
|
|
this.done = true;
|
|
|
|
|
|
var rootEntry = this.tryEntries[0];
|
|
|
var rootRecord = rootEntry.completion;
|
|
|
if (rootRecord.type === "throw") {
|
|
|
throw rootRecord.arg;
|
|
|
}
|
|
|
|
|
|
return this.rval;
|
|
|
},
|
|
|
|
|
|
dispatchException: function(exception) {
|
|
|
if (this.done) {
|
|
|
throw exception;
|
|
|
}
|
|
|
|
|
|
var context = this;
|
|
|
function handle(loc, caught) {
|
|
|
record.type = "throw";
|
|
|
record.arg = exception;
|
|
|
context.next = loc;
|
|
|
|
|
|
if (caught) {
|
|
|
// If the dispatched exception was caught by a catch block,
|
|
|
// then let that catch block handle the exception normally.
|
|
|
context.method = "next";
|
|
|
context.arg = undefined;
|
|
|
}
|
|
|
|
|
|
return !! caught;
|
|
|
}
|
|
|
|
|
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
|
var entry = this.tryEntries[i];
|
|
|
var record = entry.completion;
|
|
|
|
|
|
if (entry.tryLoc === "root") {
|
|
|
// Exception thrown outside of any try block that could handle
|
|
|
// it, so set the completion value of the entire function to
|
|
|
// throw the exception.
|
|
|
return handle("end");
|
|
|
}
|
|
|
|
|
|
if (entry.tryLoc <= this.prev) {
|
|
|
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
|
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
|
|
|
|
if (hasCatch && hasFinally) {
|
|
|
if (this.prev < entry.catchLoc) {
|
|
|
return handle(entry.catchLoc, true);
|
|
|
} else if (this.prev < entry.finallyLoc) {
|
|
|
return handle(entry.finallyLoc);
|
|
|
}
|
|
|
|
|
|
} else if (hasCatch) {
|
|
|
if (this.prev < entry.catchLoc) {
|
|
|
return handle(entry.catchLoc, true);
|
|
|
}
|
|
|
|
|
|
} else if (hasFinally) {
|
|
|
if (this.prev < entry.finallyLoc) {
|
|
|
return handle(entry.finallyLoc);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
throw new Error("try statement without catch or finally");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
abrupt: function(type, arg) {
|
|
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
|
var entry = this.tryEntries[i];
|
|
|
if (entry.tryLoc <= this.prev &&
|
|
|
hasOwn.call(entry, "finallyLoc") &&
|
|
|
this.prev < entry.finallyLoc) {
|
|
|
var finallyEntry = entry;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (finallyEntry &&
|
|
|
(type === "break" ||
|
|
|
type === "continue") &&
|
|
|
finallyEntry.tryLoc <= arg &&
|
|
|
arg <= finallyEntry.finallyLoc) {
|
|
|
// Ignore the finally entry if control is not jumping to a
|
|
|
// location outside the try/catch block.
|
|
|
finallyEntry = null;
|
|
|
}
|
|
|
|
|
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
|
record.type = type;
|
|
|
record.arg = arg;
|
|
|
|
|
|
if (finallyEntry) {
|
|
|
this.method = "next";
|
|
|
this.next = finallyEntry.finallyLoc;
|
|
|
return ContinueSentinel;
|
|
|
}
|
|
|
|
|
|
return this.complete(record);
|
|
|
},
|
|
|
|
|
|
complete: function(record, afterLoc) {
|
|
|
if (record.type === "throw") {
|
|
|
throw record.arg;
|
|
|
}
|
|
|
|
|
|
if (record.type === "break" ||
|
|
|
record.type === "continue") {
|
|
|
this.next = record.arg;
|
|
|
} else if (record.type === "return") {
|
|
|
this.rval = this.arg = record.arg;
|
|
|
this.method = "return";
|
|
|
this.next = "end";
|
|
|
} else if (record.type === "normal" && afterLoc) {
|
|
|
this.next = afterLoc;
|
|
|
}
|
|
|
|
|
|
return ContinueSentinel;
|
|
|
},
|
|
|
|
|
|
finish: function(finallyLoc) {
|
|
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
|
var entry = this.tryEntries[i];
|
|
|
if (entry.finallyLoc === finallyLoc) {
|
|
|
this.complete(entry.completion, entry.afterLoc);
|
|
|
resetTryEntry(entry);
|
|
|
return ContinueSentinel;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
"catch": function(tryLoc) {
|
|
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
|
var entry = this.tryEntries[i];
|
|
|
if (entry.tryLoc === tryLoc) {
|
|
|
var record = entry.completion;
|
|
|
if (record.type === "throw") {
|
|
|
var thrown = record.arg;
|
|
|
resetTryEntry(entry);
|
|
|
}
|
|
|
return thrown;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// The context.catch method must only be called with a location
|
|
|
// argument that corresponds to a known catch block.
|
|
|
throw new Error("illegal catch attempt");
|
|
|
},
|
|
|
|
|
|
delegateYield: function(iterable, resultName, nextLoc) {
|
|
|
this.delegate = {
|
|
|
iterator: values(iterable),
|
|
|
resultName: resultName,
|
|
|
nextLoc: nextLoc
|
|
|
};
|
|
|
|
|
|
if (this.method === "next") {
|
|
|
// Deliberately forget the last sent value so that we don't
|
|
|
// accidentally pass it on to the delegate.
|
|
|
this.arg = undefined;
|
|
|
}
|
|
|
|
|
|
return ContinueSentinel;
|
|
|
}
|
|
|
};
|
|
|
})(
|
|
|
// In sloppy mode, unbound `this` refers to the global object, fallback to
|
|
|
// Function constructor if we're in global strict mode. That is sadly a form
|
|
|
// of indirect eval which violates Content Security Policy.
|
|
|
(function() { return this })() || Function("return this")()
|
|
|
);
|
|
|
|
|
|
},{}],228:[function(require,module,exports){
|
|
|
/* eslint-disable node/no-deprecated-api */
|
|
|
var buffer = require('buffer')
|
|
|
var Buffer = buffer.Buffer
|
|
|
|
|
|
// alternative to using Object.keys for old browsers
|
|
|
function copyProps (src, dst) {
|
|
|
for (var key in src) {
|
|
|
dst[key] = src[key]
|
|
|
}
|
|
|
}
|
|
|
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
|
module.exports = buffer
|
|
|
} else {
|
|
|
// Copy properties from require('buffer')
|
|
|
copyProps(buffer, exports)
|
|
|
exports.Buffer = SafeBuffer
|
|
|
}
|
|
|
|
|
|
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
|
}
|
|
|
|
|
|
// Copy static methods from Buffer
|
|
|
copyProps(Buffer, SafeBuffer)
|
|
|
|
|
|
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
|
if (typeof arg === 'number') {
|
|
|
throw new TypeError('Argument must not be a number')
|
|
|
}
|
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
|
}
|
|
|
|
|
|
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
|
if (typeof size !== 'number') {
|
|
|
throw new TypeError('Argument must be a number')
|
|
|
}
|
|
|
var buf = Buffer(size)
|
|
|
if (fill !== undefined) {
|
|
|
if (typeof encoding === 'string') {
|
|
|
buf.fill(fill, encoding)
|
|
|
} else {
|
|
|
buf.fill(fill)
|
|
|
}
|
|
|
} else {
|
|
|
buf.fill(0)
|
|
|
}
|
|
|
return buf
|
|
|
}
|
|
|
|
|
|
SafeBuffer.allocUnsafe = function (size) {
|
|
|
if (typeof size !== 'number') {
|
|
|
throw new TypeError('Argument must be a number')
|
|
|
}
|
|
|
return Buffer(size)
|
|
|
}
|
|
|
|
|
|
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
|
if (typeof size !== 'number') {
|
|
|
throw new TypeError('Argument must be a number')
|
|
|
}
|
|
|
return buffer.SlowBuffer(size)
|
|
|
}
|
|
|
|
|
|
},{"buffer":73}],229:[function(require,module,exports){
|
|
|
(function (Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _fromCodePoint = require('babel-runtime/core-js/string/from-code-point');
|
|
|
|
|
|
var _fromCodePoint2 = _interopRequireDefault(_fromCodePoint);
|
|
|
|
|
|
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
var _defineProperty = require('babel-runtime/core-js/object/define-property');
|
|
|
|
|
|
var _defineProperty2 = _interopRequireDefault(_defineProperty);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
;(function (sax) {
|
|
|
// wrapper for non-node envs
|
|
|
sax.parser = function (strict, opt) {
|
|
|
return new SAXParser(strict, opt);
|
|
|
};
|
|
|
sax.SAXParser = SAXParser;
|
|
|
sax.SAXStream = SAXStream;
|
|
|
sax.createStream = createStream;
|
|
|
|
|
|
// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
|
|
|
// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
|
|
|
// since that's the earliest that a buffer overrun could occur. This way, checks are
|
|
|
// as rare as required, but as often as necessary to ensure never crossing this bound.
|
|
|
// Furthermore, buffers are only tested at most once per write(), so passing a very
|
|
|
// large string into write() might have undesirable effects, but this is manageable by
|
|
|
// the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
|
|
|
// edge case, result in creating at most one complete copy of the string passed in.
|
|
|
// Set to Infinity to have unlimited buffers.
|
|
|
sax.MAX_BUFFER_LENGTH = 64 * 1024;
|
|
|
|
|
|
var buffers = ['comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', 'procInstName', 'procInstBody', 'entity', 'attribName', 'attribValue', 'cdata', 'script'];
|
|
|
|
|
|
sax.EVENTS = ['text', 'processinginstruction', 'sgmldeclaration', 'doctype', 'comment', 'opentagstart', 'attribute', 'opentag', 'closetag', 'opencdata', 'cdata', 'closecdata', 'error', 'end', 'ready', 'script', 'opennamespace', 'closenamespace'];
|
|
|
|
|
|
function SAXParser(strict, opt) {
|
|
|
if (!(this instanceof SAXParser)) {
|
|
|
return new SAXParser(strict, opt);
|
|
|
}
|
|
|
|
|
|
var parser = this;
|
|
|
clearBuffers(parser);
|
|
|
parser.q = parser.c = '';
|
|
|
parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH;
|
|
|
parser.opt = opt || {};
|
|
|
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
|
|
|
parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase';
|
|
|
parser.tags = [];
|
|
|
parser.closed = parser.closedRoot = parser.sawRoot = false;
|
|
|
parser.tag = parser.error = null;
|
|
|
parser.strict = !!strict;
|
|
|
parser.noscript = !!(strict || parser.opt.noscript);
|
|
|
parser.state = S.BEGIN;
|
|
|
parser.strictEntities = parser.opt.strictEntities;
|
|
|
parser.ENTITIES = parser.strictEntities ? (0, _create2.default)(sax.XML_ENTITIES) : (0, _create2.default)(sax.ENTITIES);
|
|
|
parser.attribList = [];
|
|
|
|
|
|
// namespaces form a prototype chain.
|
|
|
// it always points at the current tag,
|
|
|
// which protos to its parent tag.
|
|
|
if (parser.opt.xmlns) {
|
|
|
parser.ns = (0, _create2.default)(rootNS);
|
|
|
}
|
|
|
|
|
|
// mostly just for error reporting
|
|
|
parser.trackPosition = parser.opt.position !== false;
|
|
|
if (parser.trackPosition) {
|
|
|
parser.position = parser.line = parser.column = 0;
|
|
|
}
|
|
|
emit(parser, 'onready');
|
|
|
}
|
|
|
|
|
|
if (!_create2.default) {
|
|
|
Object.create = function (o) {
|
|
|
function F() {}
|
|
|
F.prototype = o;
|
|
|
var newf = new F();
|
|
|
return newf;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
if (!_keys2.default) {
|
|
|
Object.keys = function (o) {
|
|
|
var a = [];
|
|
|
for (var i in o) {
|
|
|
if (o.hasOwnProperty(i)) a.push(i);
|
|
|
}return a;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function checkBufferLength(parser) {
|
|
|
var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10);
|
|
|
var maxActual = 0;
|
|
|
for (var i = 0, l = buffers.length; i < l; i++) {
|
|
|
var len = parser[buffers[i]].length;
|
|
|
if (len > maxAllowed) {
|
|
|
// Text/cdata nodes can get big, and since they're buffered,
|
|
|
// we can get here under normal conditions.
|
|
|
// Avoid issues by emitting the text node now,
|
|
|
// so at least it won't get any bigger.
|
|
|
switch (buffers[i]) {
|
|
|
case 'textNode':
|
|
|
closeText(parser);
|
|
|
break;
|
|
|
|
|
|
case 'cdata':
|
|
|
emitNode(parser, 'oncdata', parser.cdata);
|
|
|
parser.cdata = '';
|
|
|
break;
|
|
|
|
|
|
case 'script':
|
|
|
emitNode(parser, 'onscript', parser.script);
|
|
|
parser.script = '';
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
error(parser, 'Max buffer length exceeded: ' + buffers[i]);
|
|
|
}
|
|
|
}
|
|
|
maxActual = Math.max(maxActual, len);
|
|
|
}
|
|
|
// schedule the next check for the earliest possible buffer overrun.
|
|
|
var m = sax.MAX_BUFFER_LENGTH - maxActual;
|
|
|
parser.bufferCheckPosition = m + parser.position;
|
|
|
}
|
|
|
|
|
|
function clearBuffers(parser) {
|
|
|
for (var i = 0, l = buffers.length; i < l; i++) {
|
|
|
parser[buffers[i]] = '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function flushBuffers(parser) {
|
|
|
closeText(parser);
|
|
|
if (parser.cdata !== '') {
|
|
|
emitNode(parser, 'oncdata', parser.cdata);
|
|
|
parser.cdata = '';
|
|
|
}
|
|
|
if (parser.script !== '') {
|
|
|
emitNode(parser, 'onscript', parser.script);
|
|
|
parser.script = '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
SAXParser.prototype = {
|
|
|
end: function end() {
|
|
|
_end(this);
|
|
|
},
|
|
|
write: write,
|
|
|
resume: function resume() {
|
|
|
this.error = null;return this;
|
|
|
},
|
|
|
close: function close() {
|
|
|
return this.write(null);
|
|
|
},
|
|
|
flush: function flush() {
|
|
|
flushBuffers(this);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
var Stream;
|
|
|
try {
|
|
|
Stream = require('stream').Stream;
|
|
|
} catch (ex) {
|
|
|
Stream = function Stream() {};
|
|
|
}
|
|
|
|
|
|
var streamWraps = sax.EVENTS.filter(function (ev) {
|
|
|
return ev !== 'error' && ev !== 'end';
|
|
|
});
|
|
|
|
|
|
function createStream(strict, opt) {
|
|
|
return new SAXStream(strict, opt);
|
|
|
}
|
|
|
|
|
|
function SAXStream(strict, opt) {
|
|
|
if (!(this instanceof SAXStream)) {
|
|
|
return new SAXStream(strict, opt);
|
|
|
}
|
|
|
|
|
|
Stream.apply(this);
|
|
|
|
|
|
this._parser = new SAXParser(strict, opt);
|
|
|
this.writable = true;
|
|
|
this.readable = true;
|
|
|
|
|
|
var me = this;
|
|
|
|
|
|
this._parser.onend = function () {
|
|
|
me.emit('end');
|
|
|
};
|
|
|
|
|
|
this._parser.onerror = function (er) {
|
|
|
me.emit('error', er);
|
|
|
|
|
|
// if didn't throw, then means error was handled.
|
|
|
// go ahead and clear error, so we can write again.
|
|
|
me._parser.error = null;
|
|
|
};
|
|
|
|
|
|
this._decoder = null;
|
|
|
|
|
|
streamWraps.forEach(function (ev) {
|
|
|
(0, _defineProperty2.default)(me, 'on' + ev, {
|
|
|
get: function get() {
|
|
|
return me._parser['on' + ev];
|
|
|
},
|
|
|
set: function set(h) {
|
|
|
if (!h) {
|
|
|
me.removeAllListeners(ev);
|
|
|
me._parser['on' + ev] = h;
|
|
|
return h;
|
|
|
}
|
|
|
me.on(ev, h);
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: false
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
SAXStream.prototype = (0, _create2.default)(Stream.prototype, {
|
|
|
constructor: {
|
|
|
value: SAXStream
|
|
|
}
|
|
|
});
|
|
|
|
|
|
SAXStream.prototype.write = function (data) {
|
|
|
if (typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function' && Buffer.isBuffer(data)) {
|
|
|
if (!this._decoder) {
|
|
|
var SD = require('string_decoder').StringDecoder;
|
|
|
this._decoder = new SD('utf8');
|
|
|
}
|
|
|
data = this._decoder.write(data);
|
|
|
}
|
|
|
|
|
|
this._parser.write(data.toString());
|
|
|
this.emit('data', data);
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
SAXStream.prototype.end = function (chunk) {
|
|
|
if (chunk && chunk.length) {
|
|
|
this.write(chunk);
|
|
|
}
|
|
|
this._parser.end();
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
SAXStream.prototype.on = function (ev, handler) {
|
|
|
var me = this;
|
|
|
if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
|
|
|
me._parser['on' + ev] = function () {
|
|
|
var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
|
|
|
args.splice(0, 0, ev);
|
|
|
me.emit.apply(me, args);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
return Stream.prototype.on.call(me, ev, handler);
|
|
|
};
|
|
|
|
|
|
// this really needs to be replaced with character classes.
|
|
|
// XML allows all manner of ridiculous numbers and digits.
|
|
|
var CDATA = '[CDATA[';
|
|
|
var DOCTYPE = 'DOCTYPE';
|
|
|
var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
|
var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
|
|
|
var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE
|
|
|
|
|
|
// http://www.w3.org/TR/REC-xml/#NT-NameStartChar
|
|
|
// This implementation works on strings, a single character at a time
|
|
|
// as such, it cannot ever support astral-plane characters (10000-EFFFF)
|
|
|
// without a significant breaking change to either this parser, or the
|
|
|
// JavaScript language. Implementation of an emoji-capable xml parser
|
|
|
// is left as an exercise for the reader.
|
|
|
};var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
|
|
|
|
|
var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|
|
|
|
|
var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
|
|
var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|
|
|
|
|
function isWhitespace(c) {
|
|
|
return c === ' ' || c === '\n' || c === '\r' || c === '\t';
|
|
|
}
|
|
|
|
|
|
function isQuote(c) {
|
|
|
return c === '"' || c === '\'';
|
|
|
}
|
|
|
|
|
|
function isAttribEnd(c) {
|
|
|
return c === '>' || isWhitespace(c);
|
|
|
}
|
|
|
|
|
|
function isMatch(regex, c) {
|
|
|
return regex.test(c);
|
|
|
}
|
|
|
|
|
|
function notMatch(regex, c) {
|
|
|
return !isMatch(regex, c);
|
|
|
}
|
|
|
|
|
|
var S = 0;
|
|
|
sax.STATE = {
|
|
|
BEGIN: S++, // leading byte order mark or whitespace
|
|
|
BEGIN_WHITESPACE: S++, // leading whitespace
|
|
|
TEXT: S++, // general stuff
|
|
|
TEXT_ENTITY: S++, // & and such.
|
|
|
OPEN_WAKA: S++, // <
|
|
|
SGML_DECL: S++, // <!BLARG
|
|
|
SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
|
|
|
DOCTYPE: S++, // <!DOCTYPE
|
|
|
DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
|
|
|
DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
|
|
|
DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
|
|
|
COMMENT_STARTING: S++, // <!-
|
|
|
COMMENT: S++, // <!--
|
|
|
COMMENT_ENDING: S++, // <!-- blah -
|
|
|
COMMENT_ENDED: S++, // <!-- blah --
|
|
|
CDATA: S++, // <![CDATA[ something
|
|
|
CDATA_ENDING: S++, // ]
|
|
|
CDATA_ENDING_2: S++, // ]]
|
|
|
PROC_INST: S++, // <?hi
|
|
|
PROC_INST_BODY: S++, // <?hi there
|
|
|
PROC_INST_ENDING: S++, // <?hi "there" ?
|
|
|
OPEN_TAG: S++, // <strong
|
|
|
OPEN_TAG_SLASH: S++, // <strong /
|
|
|
ATTRIB: S++, // <a
|
|
|
ATTRIB_NAME: S++, // <a foo
|
|
|
ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
|
|
|
ATTRIB_VALUE: S++, // <a foo=
|
|
|
ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
|
|
|
ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
|
|
|
ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
|
|
|
ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="""
|
|
|
ATTRIB_VALUE_ENTITY_U: S++, // <foo bar="
|
|
|
CLOSE_TAG: S++, // </a
|
|
|
CLOSE_TAG_SAW_WHITE: S++, // </a >
|
|
|
SCRIPT: S++, // <script> ...
|
|
|
SCRIPT_ENDING: S++ // <script> ... <
|
|
|
};
|
|
|
|
|
|
sax.XML_ENTITIES = {
|
|
|
'amp': '&',
|
|
|
'gt': '>',
|
|
|
'lt': '<',
|
|
|
'quot': '"',
|
|
|
'apos': "'"
|
|
|
};
|
|
|
|
|
|
sax.ENTITIES = {
|
|
|
'amp': '&',
|
|
|
'gt': '>',
|
|
|
'lt': '<',
|
|
|
'quot': '"',
|
|
|
'apos': "'",
|
|
|
'AElig': 198,
|
|
|
'Aacute': 193,
|
|
|
'Acirc': 194,
|
|
|
'Agrave': 192,
|
|
|
'Aring': 197,
|
|
|
'Atilde': 195,
|
|
|
'Auml': 196,
|
|
|
'Ccedil': 199,
|
|
|
'ETH': 208,
|
|
|
'Eacute': 201,
|
|
|
'Ecirc': 202,
|
|
|
'Egrave': 200,
|
|
|
'Euml': 203,
|
|
|
'Iacute': 205,
|
|
|
'Icirc': 206,
|
|
|
'Igrave': 204,
|
|
|
'Iuml': 207,
|
|
|
'Ntilde': 209,
|
|
|
'Oacute': 211,
|
|
|
'Ocirc': 212,
|
|
|
'Ograve': 210,
|
|
|
'Oslash': 216,
|
|
|
'Otilde': 213,
|
|
|
'Ouml': 214,
|
|
|
'THORN': 222,
|
|
|
'Uacute': 218,
|
|
|
'Ucirc': 219,
|
|
|
'Ugrave': 217,
|
|
|
'Uuml': 220,
|
|
|
'Yacute': 221,
|
|
|
'aacute': 225,
|
|
|
'acirc': 226,
|
|
|
'aelig': 230,
|
|
|
'agrave': 224,
|
|
|
'aring': 229,
|
|
|
'atilde': 227,
|
|
|
'auml': 228,
|
|
|
'ccedil': 231,
|
|
|
'eacute': 233,
|
|
|
'ecirc': 234,
|
|
|
'egrave': 232,
|
|
|
'eth': 240,
|
|
|
'euml': 235,
|
|
|
'iacute': 237,
|
|
|
'icirc': 238,
|
|
|
'igrave': 236,
|
|
|
'iuml': 239,
|
|
|
'ntilde': 241,
|
|
|
'oacute': 243,
|
|
|
'ocirc': 244,
|
|
|
'ograve': 242,
|
|
|
'oslash': 248,
|
|
|
'otilde': 245,
|
|
|
'ouml': 246,
|
|
|
'szlig': 223,
|
|
|
'thorn': 254,
|
|
|
'uacute': 250,
|
|
|
'ucirc': 251,
|
|
|
'ugrave': 249,
|
|
|
'uuml': 252,
|
|
|
'yacute': 253,
|
|
|
'yuml': 255,
|
|
|
'copy': 169,
|
|
|
'reg': 174,
|
|
|
'nbsp': 160,
|
|
|
'iexcl': 161,
|
|
|
'cent': 162,
|
|
|
'pound': 163,
|
|
|
'curren': 164,
|
|
|
'yen': 165,
|
|
|
'brvbar': 166,
|
|
|
'sect': 167,
|
|
|
'uml': 168,
|
|
|
'ordf': 170,
|
|
|
'laquo': 171,
|
|
|
'not': 172,
|
|
|
'shy': 173,
|
|
|
'macr': 175,
|
|
|
'deg': 176,
|
|
|
'plusmn': 177,
|
|
|
'sup1': 185,
|
|
|
'sup2': 178,
|
|
|
'sup3': 179,
|
|
|
'acute': 180,
|
|
|
'micro': 181,
|
|
|
'para': 182,
|
|
|
'middot': 183,
|
|
|
'cedil': 184,
|
|
|
'ordm': 186,
|
|
|
'raquo': 187,
|
|
|
'frac14': 188,
|
|
|
'frac12': 189,
|
|
|
'frac34': 190,
|
|
|
'iquest': 191,
|
|
|
'times': 215,
|
|
|
'divide': 247,
|
|
|
'OElig': 338,
|
|
|
'oelig': 339,
|
|
|
'Scaron': 352,
|
|
|
'scaron': 353,
|
|
|
'Yuml': 376,
|
|
|
'fnof': 402,
|
|
|
'circ': 710,
|
|
|
'tilde': 732,
|
|
|
'Alpha': 913,
|
|
|
'Beta': 914,
|
|
|
'Gamma': 915,
|
|
|
'Delta': 916,
|
|
|
'Epsilon': 917,
|
|
|
'Zeta': 918,
|
|
|
'Eta': 919,
|
|
|
'Theta': 920,
|
|
|
'Iota': 921,
|
|
|
'Kappa': 922,
|
|
|
'Lambda': 923,
|
|
|
'Mu': 924,
|
|
|
'Nu': 925,
|
|
|
'Xi': 926,
|
|
|
'Omicron': 927,
|
|
|
'Pi': 928,
|
|
|
'Rho': 929,
|
|
|
'Sigma': 931,
|
|
|
'Tau': 932,
|
|
|
'Upsilon': 933,
|
|
|
'Phi': 934,
|
|
|
'Chi': 935,
|
|
|
'Psi': 936,
|
|
|
'Omega': 937,
|
|
|
'alpha': 945,
|
|
|
'beta': 946,
|
|
|
'gamma': 947,
|
|
|
'delta': 948,
|
|
|
'epsilon': 949,
|
|
|
'zeta': 950,
|
|
|
'eta': 951,
|
|
|
'theta': 952,
|
|
|
'iota': 953,
|
|
|
'kappa': 954,
|
|
|
'lambda': 955,
|
|
|
'mu': 956,
|
|
|
'nu': 957,
|
|
|
'xi': 958,
|
|
|
'omicron': 959,
|
|
|
'pi': 960,
|
|
|
'rho': 961,
|
|
|
'sigmaf': 962,
|
|
|
'sigma': 963,
|
|
|
'tau': 964,
|
|
|
'upsilon': 965,
|
|
|
'phi': 966,
|
|
|
'chi': 967,
|
|
|
'psi': 968,
|
|
|
'omega': 969,
|
|
|
'thetasym': 977,
|
|
|
'upsih': 978,
|
|
|
'piv': 982,
|
|
|
'ensp': 8194,
|
|
|
'emsp': 8195,
|
|
|
'thinsp': 8201,
|
|
|
'zwnj': 8204,
|
|
|
'zwj': 8205,
|
|
|
'lrm': 8206,
|
|
|
'rlm': 8207,
|
|
|
'ndash': 8211,
|
|
|
'mdash': 8212,
|
|
|
'lsquo': 8216,
|
|
|
'rsquo': 8217,
|
|
|
'sbquo': 8218,
|
|
|
'ldquo': 8220,
|
|
|
'rdquo': 8221,
|
|
|
'bdquo': 8222,
|
|
|
'dagger': 8224,
|
|
|
'Dagger': 8225,
|
|
|
'bull': 8226,
|
|
|
'hellip': 8230,
|
|
|
'permil': 8240,
|
|
|
'prime': 8242,
|
|
|
'Prime': 8243,
|
|
|
'lsaquo': 8249,
|
|
|
'rsaquo': 8250,
|
|
|
'oline': 8254,
|
|
|
'frasl': 8260,
|
|
|
'euro': 8364,
|
|
|
'image': 8465,
|
|
|
'weierp': 8472,
|
|
|
'real': 8476,
|
|
|
'trade': 8482,
|
|
|
'alefsym': 8501,
|
|
|
'larr': 8592,
|
|
|
'uarr': 8593,
|
|
|
'rarr': 8594,
|
|
|
'darr': 8595,
|
|
|
'harr': 8596,
|
|
|
'crarr': 8629,
|
|
|
'lArr': 8656,
|
|
|
'uArr': 8657,
|
|
|
'rArr': 8658,
|
|
|
'dArr': 8659,
|
|
|
'hArr': 8660,
|
|
|
'forall': 8704,
|
|
|
'part': 8706,
|
|
|
'exist': 8707,
|
|
|
'empty': 8709,
|
|
|
'nabla': 8711,
|
|
|
'isin': 8712,
|
|
|
'notin': 8713,
|
|
|
'ni': 8715,
|
|
|
'prod': 8719,
|
|
|
'sum': 8721,
|
|
|
'minus': 8722,
|
|
|
'lowast': 8727,
|
|
|
'radic': 8730,
|
|
|
'prop': 8733,
|
|
|
'infin': 8734,
|
|
|
'ang': 8736,
|
|
|
'and': 8743,
|
|
|
'or': 8744,
|
|
|
'cap': 8745,
|
|
|
'cup': 8746,
|
|
|
'int': 8747,
|
|
|
'there4': 8756,
|
|
|
'sim': 8764,
|
|
|
'cong': 8773,
|
|
|
'asymp': 8776,
|
|
|
'ne': 8800,
|
|
|
'equiv': 8801,
|
|
|
'le': 8804,
|
|
|
'ge': 8805,
|
|
|
'sub': 8834,
|
|
|
'sup': 8835,
|
|
|
'nsub': 8836,
|
|
|
'sube': 8838,
|
|
|
'supe': 8839,
|
|
|
'oplus': 8853,
|
|
|
'otimes': 8855,
|
|
|
'perp': 8869,
|
|
|
'sdot': 8901,
|
|
|
'lceil': 8968,
|
|
|
'rceil': 8969,
|
|
|
'lfloor': 8970,
|
|
|
'rfloor': 8971,
|
|
|
'lang': 9001,
|
|
|
'rang': 9002,
|
|
|
'loz': 9674,
|
|
|
'spades': 9824,
|
|
|
'clubs': 9827,
|
|
|
'hearts': 9829,
|
|
|
'diams': 9830
|
|
|
};
|
|
|
|
|
|
(0, _keys2.default)(sax.ENTITIES).forEach(function (key) {
|
|
|
var e = sax.ENTITIES[key];
|
|
|
var s = typeof e === 'number' ? String.fromCharCode(e) : e;
|
|
|
sax.ENTITIES[key] = s;
|
|
|
});
|
|
|
|
|
|
for (var s in sax.STATE) {
|
|
|
sax.STATE[sax.STATE[s]] = s;
|
|
|
}
|
|
|
|
|
|
// shorthand
|
|
|
S = sax.STATE;
|
|
|
|
|
|
function emit(parser, event, data) {
|
|
|
parser[event] && parser[event](data);
|
|
|
}
|
|
|
|
|
|
function emitNode(parser, nodeType, data) {
|
|
|
if (parser.textNode) closeText(parser);
|
|
|
emit(parser, nodeType, data);
|
|
|
}
|
|
|
|
|
|
function closeText(parser) {
|
|
|
parser.textNode = textopts(parser.opt, parser.textNode);
|
|
|
if (parser.textNode) emit(parser, 'ontext', parser.textNode);
|
|
|
parser.textNode = '';
|
|
|
}
|
|
|
|
|
|
function textopts(opt, text) {
|
|
|
if (opt.trim) text = text.trim();
|
|
|
if (opt.normalize) text = text.replace(/\s+/g, ' ');
|
|
|
return text;
|
|
|
}
|
|
|
|
|
|
function error(parser, er) {
|
|
|
closeText(parser);
|
|
|
if (parser.trackPosition) {
|
|
|
er += '\nLine: ' + parser.line + '\nColumn: ' + parser.column + '\nChar: ' + parser.c;
|
|
|
}
|
|
|
er = new Error(er);
|
|
|
parser.error = er;
|
|
|
emit(parser, 'onerror', er);
|
|
|
return parser;
|
|
|
}
|
|
|
|
|
|
function _end(parser) {
|
|
|
if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag');
|
|
|
if (parser.state !== S.BEGIN && parser.state !== S.BEGIN_WHITESPACE && parser.state !== S.TEXT) {
|
|
|
error(parser, 'Unexpected end');
|
|
|
}
|
|
|
closeText(parser);
|
|
|
parser.c = '';
|
|
|
parser.closed = true;
|
|
|
emit(parser, 'onend');
|
|
|
SAXParser.call(parser, parser.strict, parser.opt);
|
|
|
return parser;
|
|
|
}
|
|
|
|
|
|
function strictFail(parser, message) {
|
|
|
if ((typeof parser === 'undefined' ? 'undefined' : (0, _typeof3.default)(parser)) !== 'object' || !(parser instanceof SAXParser)) {
|
|
|
throw new Error('bad call to strictFail');
|
|
|
}
|
|
|
if (parser.strict) {
|
|
|
error(parser, message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function newTag(parser) {
|
|
|
if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]();
|
|
|
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
|
var tag = parser.tag = { name: parser.tagName, attributes: {}
|
|
|
|
|
|
// will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
|
|
|
};if (parser.opt.xmlns) {
|
|
|
tag.ns = parent.ns;
|
|
|
}
|
|
|
parser.attribList.length = 0;
|
|
|
emitNode(parser, 'onopentagstart', tag);
|
|
|
}
|
|
|
|
|
|
function qname(name, attribute) {
|
|
|
var i = name.indexOf(':');
|
|
|
var qualName = i < 0 ? ['', name] : name.split(':');
|
|
|
var prefix = qualName[0];
|
|
|
var local = qualName[1];
|
|
|
|
|
|
// <x "xmlns"="http://foo">
|
|
|
if (attribute && name === 'xmlns') {
|
|
|
prefix = 'xmlns';
|
|
|
local = '';
|
|
|
}
|
|
|
|
|
|
return { prefix: prefix, local: local };
|
|
|
}
|
|
|
|
|
|
function attrib(parser) {
|
|
|
if (!parser.strict) {
|
|
|
parser.attribName = parser.attribName[parser.looseCase]();
|
|
|
}
|
|
|
|
|
|
if (parser.attribList.indexOf(parser.attribName) !== -1 || parser.tag.attributes.hasOwnProperty(parser.attribName)) {
|
|
|
parser.attribName = parser.attribValue = '';
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (parser.opt.xmlns) {
|
|
|
var qn = qname(parser.attribName, true);
|
|
|
var prefix = qn.prefix;
|
|
|
var local = qn.local;
|
|
|
|
|
|
if (prefix === 'xmlns') {
|
|
|
// namespace binding attribute. push the binding into scope
|
|
|
if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
|
|
|
strictFail(parser, 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' + 'Actual: ' + parser.attribValue);
|
|
|
} else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
|
|
|
strictFail(parser, 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' + 'Actual: ' + parser.attribValue);
|
|
|
} else {
|
|
|
var tag = parser.tag;
|
|
|
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
|
if (tag.ns === parent.ns) {
|
|
|
tag.ns = (0, _create2.default)(parent.ns);
|
|
|
}
|
|
|
tag.ns[local] = parser.attribValue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// defer onattribute events until all attributes have been seen
|
|
|
// so any new bindings can take effect. preserve attribute order
|
|
|
// so deferred events can be emitted in document order
|
|
|
parser.attribList.push([parser.attribName, parser.attribValue]);
|
|
|
} else {
|
|
|
// in non-xmlns mode, we can emit the event right away
|
|
|
parser.tag.attributes[parser.attribName] = parser.attribValue;
|
|
|
emitNode(parser, 'onattribute', {
|
|
|
name: parser.attribName,
|
|
|
value: parser.attribValue
|
|
|
});
|
|
|
}
|
|
|
|
|
|
parser.attribName = parser.attribValue = '';
|
|
|
}
|
|
|
|
|
|
function openTag(parser, selfClosing) {
|
|
|
if (parser.opt.xmlns) {
|
|
|
// emit namespace binding events
|
|
|
var tag = parser.tag;
|
|
|
|
|
|
// add namespace info to tag
|
|
|
var qn = qname(parser.tagName);
|
|
|
tag.prefix = qn.prefix;
|
|
|
tag.local = qn.local;
|
|
|
tag.uri = tag.ns[qn.prefix] || '';
|
|
|
|
|
|
if (tag.prefix && !tag.uri) {
|
|
|
strictFail(parser, 'Unbound namespace prefix: ' + (0, _stringify2.default)(parser.tagName));
|
|
|
tag.uri = qn.prefix;
|
|
|
}
|
|
|
|
|
|
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
|
if (tag.ns && parent.ns !== tag.ns) {
|
|
|
(0, _keys2.default)(tag.ns).forEach(function (p) {
|
|
|
emitNode(parser, 'onopennamespace', {
|
|
|
prefix: p,
|
|
|
uri: tag.ns[p]
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// handle deferred onattribute events
|
|
|
// Note: do not apply default ns to attributes:
|
|
|
// http://www.w3.org/TR/REC-xml-names/#defaulting
|
|
|
for (var i = 0, l = parser.attribList.length; i < l; i++) {
|
|
|
var nv = parser.attribList[i];
|
|
|
var name = nv[0];
|
|
|
var value = nv[1];
|
|
|
var qualName = qname(name, true);
|
|
|
var prefix = qualName.prefix;
|
|
|
var local = qualName.local;
|
|
|
var uri = prefix === '' ? '' : tag.ns[prefix] || '';
|
|
|
var a = {
|
|
|
name: name,
|
|
|
value: value,
|
|
|
prefix: prefix,
|
|
|
local: local,
|
|
|
uri: uri
|
|
|
|
|
|
// if there's any attributes with an undefined namespace,
|
|
|
// then fail on them now.
|
|
|
};if (prefix && prefix !== 'xmlns' && !uri) {
|
|
|
strictFail(parser, 'Unbound namespace prefix: ' + (0, _stringify2.default)(prefix));
|
|
|
a.uri = prefix;
|
|
|
}
|
|
|
parser.tag.attributes[name] = a;
|
|
|
emitNode(parser, 'onattribute', a);
|
|
|
}
|
|
|
parser.attribList.length = 0;
|
|
|
}
|
|
|
|
|
|
parser.tag.isSelfClosing = !!selfClosing;
|
|
|
|
|
|
// process the tag
|
|
|
parser.sawRoot = true;
|
|
|
parser.tags.push(parser.tag);
|
|
|
emitNode(parser, 'onopentag', parser.tag);
|
|
|
if (!selfClosing) {
|
|
|
// special case for <script> in non-strict mode.
|
|
|
if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
|
|
|
parser.state = S.SCRIPT;
|
|
|
} else {
|
|
|
parser.state = S.TEXT;
|
|
|
}
|
|
|
parser.tag = null;
|
|
|
parser.tagName = '';
|
|
|
}
|
|
|
parser.attribName = parser.attribValue = '';
|
|
|
parser.attribList.length = 0;
|
|
|
}
|
|
|
|
|
|
function closeTag(parser) {
|
|
|
if (!parser.tagName) {
|
|
|
strictFail(parser, 'Weird empty close tag.');
|
|
|
parser.textNode += '</>';
|
|
|
parser.state = S.TEXT;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (parser.script) {
|
|
|
if (parser.tagName !== 'script') {
|
|
|
parser.script += '</' + parser.tagName + '>';
|
|
|
parser.tagName = '';
|
|
|
parser.state = S.SCRIPT;
|
|
|
return;
|
|
|
}
|
|
|
emitNode(parser, 'onscript', parser.script);
|
|
|
parser.script = '';
|
|
|
}
|
|
|
|
|
|
// first make sure that the closing tag actually exists.
|
|
|
// <a><b></c></b></a> will close everything, otherwise.
|
|
|
var t = parser.tags.length;
|
|
|
var tagName = parser.tagName;
|
|
|
if (!parser.strict) {
|
|
|
tagName = tagName[parser.looseCase]();
|
|
|
}
|
|
|
var closeTo = tagName;
|
|
|
while (t--) {
|
|
|
var close = parser.tags[t];
|
|
|
if (close.name !== closeTo) {
|
|
|
// fail the first time in strict mode
|
|
|
strictFail(parser, 'Unexpected close tag');
|
|
|
} else {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// didn't find it. we already failed for strict, so just abort.
|
|
|
if (t < 0) {
|
|
|
strictFail(parser, 'Unmatched closing tag: ' + parser.tagName);
|
|
|
parser.textNode += '</' + parser.tagName + '>';
|
|
|
parser.state = S.TEXT;
|
|
|
return;
|
|
|
}
|
|
|
parser.tagName = tagName;
|
|
|
var s = parser.tags.length;
|
|
|
while (s-- > t) {
|
|
|
var tag = parser.tag = parser.tags.pop();
|
|
|
parser.tagName = parser.tag.name;
|
|
|
emitNode(parser, 'onclosetag', parser.tagName);
|
|
|
|
|
|
var x = {};
|
|
|
for (var i in tag.ns) {
|
|
|
x[i] = tag.ns[i];
|
|
|
}
|
|
|
|
|
|
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
|
if (parser.opt.xmlns && tag.ns !== parent.ns) {
|
|
|
// remove namespace bindings introduced by tag
|
|
|
(0, _keys2.default)(tag.ns).forEach(function (p) {
|
|
|
var n = tag.ns[p];
|
|
|
emitNode(parser, 'onclosenamespace', { prefix: p, uri: n });
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
if (t === 0) parser.closedRoot = true;
|
|
|
parser.tagName = parser.attribValue = parser.attribName = '';
|
|
|
parser.attribList.length = 0;
|
|
|
parser.state = S.TEXT;
|
|
|
}
|
|
|
|
|
|
function parseEntity(parser) {
|
|
|
var entity = parser.entity;
|
|
|
var entityLC = entity.toLowerCase();
|
|
|
var num;
|
|
|
var numStr = '';
|
|
|
|
|
|
if (parser.ENTITIES[entity]) {
|
|
|
return parser.ENTITIES[entity];
|
|
|
}
|
|
|
if (parser.ENTITIES[entityLC]) {
|
|
|
return parser.ENTITIES[entityLC];
|
|
|
}
|
|
|
entity = entityLC;
|
|
|
if (entity.charAt(0) === '#') {
|
|
|
if (entity.charAt(1) === 'x') {
|
|
|
entity = entity.slice(2);
|
|
|
num = parseInt(entity, 16);
|
|
|
numStr = num.toString(16);
|
|
|
} else {
|
|
|
entity = entity.slice(1);
|
|
|
num = parseInt(entity, 10);
|
|
|
numStr = num.toString(10);
|
|
|
}
|
|
|
}
|
|
|
entity = entity.replace(/^0+/, '');
|
|
|
if (isNaN(num) || numStr.toLowerCase() !== entity) {
|
|
|
strictFail(parser, 'Invalid character entity');
|
|
|
return '&' + parser.entity + ';';
|
|
|
}
|
|
|
|
|
|
return (0, _fromCodePoint2.default)(num);
|
|
|
}
|
|
|
|
|
|
function beginWhiteSpace(parser, c) {
|
|
|
if (c === '<') {
|
|
|
parser.state = S.OPEN_WAKA;
|
|
|
parser.startTagPosition = parser.position;
|
|
|
} else if (!isWhitespace(c)) {
|
|
|
// have to process this as a text node.
|
|
|
// weird, but happens.
|
|
|
strictFail(parser, 'Non-whitespace before first tag.');
|
|
|
parser.textNode = c;
|
|
|
parser.state = S.TEXT;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function charAt(chunk, i) {
|
|
|
var result = '';
|
|
|
if (i < chunk.length) {
|
|
|
result = chunk.charAt(i);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
function write(chunk) {
|
|
|
var parser = this;
|
|
|
if (this.error) {
|
|
|
throw this.error;
|
|
|
}
|
|
|
if (parser.closed) {
|
|
|
return error(parser, 'Cannot write after close. Assign an onready handler.');
|
|
|
}
|
|
|
if (chunk === null) {
|
|
|
return _end(parser);
|
|
|
}
|
|
|
if ((typeof chunk === 'undefined' ? 'undefined' : (0, _typeof3.default)(chunk)) === 'object') {
|
|
|
chunk = chunk.toString();
|
|
|
}
|
|
|
var i = 0;
|
|
|
var c = '';
|
|
|
while (true) {
|
|
|
c = charAt(chunk, i++);
|
|
|
parser.c = c;
|
|
|
|
|
|
if (!c) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (parser.trackPosition) {
|
|
|
parser.position++;
|
|
|
if (c === '\n') {
|
|
|
parser.line++;
|
|
|
parser.column = 0;
|
|
|
} else {
|
|
|
parser.column++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
switch (parser.state) {
|
|
|
case S.BEGIN:
|
|
|
parser.state = S.BEGIN_WHITESPACE;
|
|
|
if (c === '\uFEFF') {
|
|
|
continue;
|
|
|
}
|
|
|
beginWhiteSpace(parser, c);
|
|
|
continue;
|
|
|
|
|
|
case S.BEGIN_WHITESPACE:
|
|
|
beginWhiteSpace(parser, c);
|
|
|
continue;
|
|
|
|
|
|
case S.TEXT:
|
|
|
if (parser.sawRoot && !parser.closedRoot) {
|
|
|
var starti = i - 1;
|
|
|
while (c && c !== '<' && c !== '&') {
|
|
|
c = charAt(chunk, i++);
|
|
|
if (c && parser.trackPosition) {
|
|
|
parser.position++;
|
|
|
if (c === '\n') {
|
|
|
parser.line++;
|
|
|
parser.column = 0;
|
|
|
} else {
|
|
|
parser.column++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
parser.textNode += chunk.substring(starti, i - 1);
|
|
|
}
|
|
|
if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
|
|
|
parser.state = S.OPEN_WAKA;
|
|
|
parser.startTagPosition = parser.position;
|
|
|
} else {
|
|
|
if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
|
|
|
strictFail(parser, 'Text data outside of root node.');
|
|
|
}
|
|
|
if (c === '&') {
|
|
|
parser.state = S.TEXT_ENTITY;
|
|
|
} else {
|
|
|
parser.textNode += c;
|
|
|
}
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.SCRIPT:
|
|
|
// only non-strict
|
|
|
if (c === '<') {
|
|
|
parser.state = S.SCRIPT_ENDING;
|
|
|
} else {
|
|
|
parser.script += c;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.SCRIPT_ENDING:
|
|
|
if (c === '/') {
|
|
|
parser.state = S.CLOSE_TAG;
|
|
|
} else {
|
|
|
parser.script += '<' + c;
|
|
|
parser.state = S.SCRIPT;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.OPEN_WAKA:
|
|
|
// either a /, ?, !, or text is coming next.
|
|
|
if (c === '!') {
|
|
|
parser.state = S.SGML_DECL;
|
|
|
parser.sgmlDecl = '';
|
|
|
} else if (isWhitespace(c)) {
|
|
|
// wait for it...
|
|
|
} else if (isMatch(nameStart, c)) {
|
|
|
parser.state = S.OPEN_TAG;
|
|
|
parser.tagName = c;
|
|
|
} else if (c === '/') {
|
|
|
parser.state = S.CLOSE_TAG;
|
|
|
parser.tagName = '';
|
|
|
} else if (c === '?') {
|
|
|
parser.state = S.PROC_INST;
|
|
|
parser.procInstName = parser.procInstBody = '';
|
|
|
} else {
|
|
|
strictFail(parser, 'Unencoded <');
|
|
|
// if there was some whitespace, then add that in.
|
|
|
if (parser.startTagPosition + 1 < parser.position) {
|
|
|
var pad = parser.position - parser.startTagPosition;
|
|
|
c = new Array(pad).join(' ') + c;
|
|
|
}
|
|
|
parser.textNode += '<' + c;
|
|
|
parser.state = S.TEXT;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.SGML_DECL:
|
|
|
if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
|
|
|
emitNode(parser, 'onopencdata');
|
|
|
parser.state = S.CDATA;
|
|
|
parser.sgmlDecl = '';
|
|
|
parser.cdata = '';
|
|
|
} else if (parser.sgmlDecl + c === '--') {
|
|
|
parser.state = S.COMMENT;
|
|
|
parser.comment = '';
|
|
|
parser.sgmlDecl = '';
|
|
|
} else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
|
|
|
parser.state = S.DOCTYPE;
|
|
|
if (parser.doctype || parser.sawRoot) {
|
|
|
strictFail(parser, 'Inappropriately located doctype declaration');
|
|
|
}
|
|
|
parser.doctype = '';
|
|
|
parser.sgmlDecl = '';
|
|
|
} else if (c === '>') {
|
|
|
emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl);
|
|
|
parser.sgmlDecl = '';
|
|
|
parser.state = S.TEXT;
|
|
|
} else if (isQuote(c)) {
|
|
|
parser.state = S.SGML_DECL_QUOTED;
|
|
|
parser.sgmlDecl += c;
|
|
|
} else {
|
|
|
parser.sgmlDecl += c;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.SGML_DECL_QUOTED:
|
|
|
if (c === parser.q) {
|
|
|
parser.state = S.SGML_DECL;
|
|
|
parser.q = '';
|
|
|
}
|
|
|
parser.sgmlDecl += c;
|
|
|
continue;
|
|
|
|
|
|
case S.DOCTYPE:
|
|
|
if (c === '>') {
|
|
|
parser.state = S.TEXT;
|
|
|
emitNode(parser, 'ondoctype', parser.doctype);
|
|
|
parser.doctype = true; // just remember that we saw it.
|
|
|
} else {
|
|
|
parser.doctype += c;
|
|
|
if (c === '[') {
|
|
|
parser.state = S.DOCTYPE_DTD;
|
|
|
} else if (isQuote(c)) {
|
|
|
parser.state = S.DOCTYPE_QUOTED;
|
|
|
parser.q = c;
|
|
|
}
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.DOCTYPE_QUOTED:
|
|
|
parser.doctype += c;
|
|
|
if (c === parser.q) {
|
|
|
parser.q = '';
|
|
|
parser.state = S.DOCTYPE;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.DOCTYPE_DTD:
|
|
|
parser.doctype += c;
|
|
|
if (c === ']') {
|
|
|
parser.state = S.DOCTYPE;
|
|
|
} else if (isQuote(c)) {
|
|
|
parser.state = S.DOCTYPE_DTD_QUOTED;
|
|
|
parser.q = c;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.DOCTYPE_DTD_QUOTED:
|
|
|
parser.doctype += c;
|
|
|
if (c === parser.q) {
|
|
|
parser.state = S.DOCTYPE_DTD;
|
|
|
parser.q = '';
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.COMMENT:
|
|
|
if (c === '-') {
|
|
|
parser.state = S.COMMENT_ENDING;
|
|
|
} else {
|
|
|
parser.comment += c;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.COMMENT_ENDING:
|
|
|
if (c === '-') {
|
|
|
parser.state = S.COMMENT_ENDED;
|
|
|
parser.comment = textopts(parser.opt, parser.comment);
|
|
|
if (parser.comment) {
|
|
|
emitNode(parser, 'oncomment', parser.comment);
|
|
|
}
|
|
|
parser.comment = '';
|
|
|
} else {
|
|
|
parser.comment += '-' + c;
|
|
|
parser.state = S.COMMENT;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.COMMENT_ENDED:
|
|
|
if (c !== '>') {
|
|
|
strictFail(parser, 'Malformed comment');
|
|
|
// allow <!-- blah -- bloo --> in non-strict mode,
|
|
|
// which is a comment of " blah -- bloo "
|
|
|
parser.comment += '--' + c;
|
|
|
parser.state = S.COMMENT;
|
|
|
} else {
|
|
|
parser.state = S.TEXT;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.CDATA:
|
|
|
if (c === ']') {
|
|
|
parser.state = S.CDATA_ENDING;
|
|
|
} else {
|
|
|
parser.cdata += c;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.CDATA_ENDING:
|
|
|
if (c === ']') {
|
|
|
parser.state = S.CDATA_ENDING_2;
|
|
|
} else {
|
|
|
parser.cdata += ']' + c;
|
|
|
parser.state = S.CDATA;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.CDATA_ENDING_2:
|
|
|
if (c === '>') {
|
|
|
if (parser.cdata) {
|
|
|
emitNode(parser, 'oncdata', parser.cdata);
|
|
|
}
|
|
|
emitNode(parser, 'onclosecdata');
|
|
|
parser.cdata = '';
|
|
|
parser.state = S.TEXT;
|
|
|
} else if (c === ']') {
|
|
|
parser.cdata += ']';
|
|
|
} else {
|
|
|
parser.cdata += ']]' + c;
|
|
|
parser.state = S.CDATA;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.PROC_INST:
|
|
|
if (c === '?') {
|
|
|
parser.state = S.PROC_INST_ENDING;
|
|
|
} else if (isWhitespace(c)) {
|
|
|
parser.state = S.PROC_INST_BODY;
|
|
|
} else {
|
|
|
parser.procInstName += c;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.PROC_INST_BODY:
|
|
|
if (!parser.procInstBody && isWhitespace(c)) {
|
|
|
continue;
|
|
|
} else if (c === '?') {
|
|
|
parser.state = S.PROC_INST_ENDING;
|
|
|
} else {
|
|
|
parser.procInstBody += c;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.PROC_INST_ENDING:
|
|
|
if (c === '>') {
|
|
|
emitNode(parser, 'onprocessinginstruction', {
|
|
|
name: parser.procInstName,
|
|
|
body: parser.procInstBody
|
|
|
});
|
|
|
parser.procInstName = parser.procInstBody = '';
|
|
|
parser.state = S.TEXT;
|
|
|
} else {
|
|
|
parser.procInstBody += '?' + c;
|
|
|
parser.state = S.PROC_INST_BODY;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.OPEN_TAG:
|
|
|
if (isMatch(nameBody, c)) {
|
|
|
parser.tagName += c;
|
|
|
} else {
|
|
|
newTag(parser);
|
|
|
if (c === '>') {
|
|
|
openTag(parser);
|
|
|
} else if (c === '/') {
|
|
|
parser.state = S.OPEN_TAG_SLASH;
|
|
|
} else {
|
|
|
if (!isWhitespace(c)) {
|
|
|
strictFail(parser, 'Invalid character in tag name');
|
|
|
}
|
|
|
parser.state = S.ATTRIB;
|
|
|
}
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.OPEN_TAG_SLASH:
|
|
|
if (c === '>') {
|
|
|
openTag(parser, true);
|
|
|
closeTag(parser);
|
|
|
} else {
|
|
|
strictFail(parser, 'Forward-slash in opening tag not followed by >');
|
|
|
parser.state = S.ATTRIB;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.ATTRIB:
|
|
|
// haven't read the attribute name yet.
|
|
|
if (isWhitespace(c)) {
|
|
|
continue;
|
|
|
} else if (c === '>') {
|
|
|
openTag(parser);
|
|
|
} else if (c === '/') {
|
|
|
parser.state = S.OPEN_TAG_SLASH;
|
|
|
} else if (isMatch(nameStart, c)) {
|
|
|
parser.attribName = c;
|
|
|
parser.attribValue = '';
|
|
|
parser.state = S.ATTRIB_NAME;
|
|
|
} else {
|
|
|
strictFail(parser, 'Invalid attribute name');
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.ATTRIB_NAME:
|
|
|
if (c === '=') {
|
|
|
parser.state = S.ATTRIB_VALUE;
|
|
|
} else if (c === '>') {
|
|
|
strictFail(parser, 'Attribute without value');
|
|
|
parser.attribValue = parser.attribName;
|
|
|
attrib(parser);
|
|
|
openTag(parser);
|
|
|
} else if (isWhitespace(c)) {
|
|
|
parser.state = S.ATTRIB_NAME_SAW_WHITE;
|
|
|
} else if (isMatch(nameBody, c)) {
|
|
|
parser.attribName += c;
|
|
|
} else {
|
|
|
strictFail(parser, 'Invalid attribute name');
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.ATTRIB_NAME_SAW_WHITE:
|
|
|
if (c === '=') {
|
|
|
parser.state = S.ATTRIB_VALUE;
|
|
|
} else if (isWhitespace(c)) {
|
|
|
continue;
|
|
|
} else {
|
|
|
strictFail(parser, 'Attribute without value');
|
|
|
parser.tag.attributes[parser.attribName] = '';
|
|
|
parser.attribValue = '';
|
|
|
emitNode(parser, 'onattribute', {
|
|
|
name: parser.attribName,
|
|
|
value: ''
|
|
|
});
|
|
|
parser.attribName = '';
|
|
|
if (c === '>') {
|
|
|
openTag(parser);
|
|
|
} else if (isMatch(nameStart, c)) {
|
|
|
parser.attribName = c;
|
|
|
parser.state = S.ATTRIB_NAME;
|
|
|
} else {
|
|
|
strictFail(parser, 'Invalid attribute name');
|
|
|
parser.state = S.ATTRIB;
|
|
|
}
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.ATTRIB_VALUE:
|
|
|
if (isWhitespace(c)) {
|
|
|
continue;
|
|
|
} else if (isQuote(c)) {
|
|
|
parser.q = c;
|
|
|
parser.state = S.ATTRIB_VALUE_QUOTED;
|
|
|
} else {
|
|
|
strictFail(parser, 'Unquoted attribute value');
|
|
|
parser.state = S.ATTRIB_VALUE_UNQUOTED;
|
|
|
parser.attribValue = c;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.ATTRIB_VALUE_QUOTED:
|
|
|
if (c !== parser.q) {
|
|
|
if (c === '&') {
|
|
|
parser.state = S.ATTRIB_VALUE_ENTITY_Q;
|
|
|
} else {
|
|
|
parser.attribValue += c;
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
attrib(parser);
|
|
|
parser.q = '';
|
|
|
parser.state = S.ATTRIB_VALUE_CLOSED;
|
|
|
continue;
|
|
|
|
|
|
case S.ATTRIB_VALUE_CLOSED:
|
|
|
if (isWhitespace(c)) {
|
|
|
parser.state = S.ATTRIB;
|
|
|
} else if (c === '>') {
|
|
|
openTag(parser);
|
|
|
} else if (c === '/') {
|
|
|
parser.state = S.OPEN_TAG_SLASH;
|
|
|
} else if (isMatch(nameStart, c)) {
|
|
|
strictFail(parser, 'No whitespace between attributes');
|
|
|
parser.attribName = c;
|
|
|
parser.attribValue = '';
|
|
|
parser.state = S.ATTRIB_NAME;
|
|
|
} else {
|
|
|
strictFail(parser, 'Invalid attribute name');
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.ATTRIB_VALUE_UNQUOTED:
|
|
|
if (!isAttribEnd(c)) {
|
|
|
if (c === '&') {
|
|
|
parser.state = S.ATTRIB_VALUE_ENTITY_U;
|
|
|
} else {
|
|
|
parser.attribValue += c;
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
attrib(parser);
|
|
|
if (c === '>') {
|
|
|
openTag(parser);
|
|
|
} else {
|
|
|
parser.state = S.ATTRIB;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.CLOSE_TAG:
|
|
|
if (!parser.tagName) {
|
|
|
if (isWhitespace(c)) {
|
|
|
continue;
|
|
|
} else if (notMatch(nameStart, c)) {
|
|
|
if (parser.script) {
|
|
|
parser.script += '</' + c;
|
|
|
parser.state = S.SCRIPT;
|
|
|
} else {
|
|
|
strictFail(parser, 'Invalid tagname in closing tag.');
|
|
|
}
|
|
|
} else {
|
|
|
parser.tagName = c;
|
|
|
}
|
|
|
} else if (c === '>') {
|
|
|
closeTag(parser);
|
|
|
} else if (isMatch(nameBody, c)) {
|
|
|
parser.tagName += c;
|
|
|
} else if (parser.script) {
|
|
|
parser.script += '</' + parser.tagName;
|
|
|
parser.tagName = '';
|
|
|
parser.state = S.SCRIPT;
|
|
|
} else {
|
|
|
if (!isWhitespace(c)) {
|
|
|
strictFail(parser, 'Invalid tagname in closing tag');
|
|
|
}
|
|
|
parser.state = S.CLOSE_TAG_SAW_WHITE;
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.CLOSE_TAG_SAW_WHITE:
|
|
|
if (isWhitespace(c)) {
|
|
|
continue;
|
|
|
}
|
|
|
if (c === '>') {
|
|
|
closeTag(parser);
|
|
|
} else {
|
|
|
strictFail(parser, 'Invalid characters in closing tag');
|
|
|
}
|
|
|
continue;
|
|
|
|
|
|
case S.TEXT_ENTITY:
|
|
|
case S.ATTRIB_VALUE_ENTITY_Q:
|
|
|
case S.ATTRIB_VALUE_ENTITY_U:
|
|
|
var returnState;
|
|
|
var buffer;
|
|
|
switch (parser.state) {
|
|
|
case S.TEXT_ENTITY:
|
|
|
returnState = S.TEXT;
|
|
|
buffer = 'textNode';
|
|
|
break;
|
|
|
|
|
|
case S.ATTRIB_VALUE_ENTITY_Q:
|
|
|
returnState = S.ATTRIB_VALUE_QUOTED;
|
|
|
buffer = 'attribValue';
|
|
|
break;
|
|
|
|
|
|
case S.ATTRIB_VALUE_ENTITY_U:
|
|
|
returnState = S.ATTRIB_VALUE_UNQUOTED;
|
|
|
buffer = 'attribValue';
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (c === ';') {
|
|
|
parser[buffer] += parseEntity(parser);
|
|
|
parser.entity = '';
|
|
|
parser.state = returnState;
|
|
|
} else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
|
|
|
parser.entity += c;
|
|
|
} else {
|
|
|
strictFail(parser, 'Invalid character in entity name');
|
|
|
parser[buffer] += '&' + parser.entity + c;
|
|
|
parser.entity = '';
|
|
|
parser.state = returnState;
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
default:
|
|
|
throw new Error(parser, 'Unknown state: ' + parser.state);
|
|
|
}
|
|
|
} // while
|
|
|
|
|
|
if (parser.position >= parser.bufferCheckPosition) {
|
|
|
checkBufferLength(parser);
|
|
|
}
|
|
|
return parser;
|
|
|
}
|
|
|
|
|
|
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
|
|
|
/* istanbul ignore next */
|
|
|
if (!_fromCodePoint2.default) {
|
|
|
(function () {
|
|
|
var stringFromCharCode = String.fromCharCode;
|
|
|
var floor = Math.floor;
|
|
|
var fromCodePoint = function fromCodePoint() {
|
|
|
var MAX_SIZE = 0x4000;
|
|
|
var codeUnits = [];
|
|
|
var highSurrogate;
|
|
|
var lowSurrogate;
|
|
|
var index = -1;
|
|
|
var length = arguments.length;
|
|
|
if (!length) {
|
|
|
return '';
|
|
|
}
|
|
|
var result = '';
|
|
|
while (++index < length) {
|
|
|
var codePoint = Number(arguments[index]);
|
|
|
if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
|
|
codePoint < 0 || // not a valid Unicode code point
|
|
|
codePoint > 0x10FFFF || // not a valid Unicode code point
|
|
|
floor(codePoint) !== codePoint // not an integer
|
|
|
) {
|
|
|
throw RangeError('Invalid code point: ' + codePoint);
|
|
|
}
|
|
|
if (codePoint <= 0xFFFF) {
|
|
|
// BMP code point
|
|
|
codeUnits.push(codePoint);
|
|
|
} else {
|
|
|
// Astral code point; split in surrogate halves
|
|
|
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|
|
codePoint -= 0x10000;
|
|
|
highSurrogate = (codePoint >> 10) + 0xD800;
|
|
|
lowSurrogate = codePoint % 0x400 + 0xDC00;
|
|
|
codeUnits.push(highSurrogate, lowSurrogate);
|
|
|
}
|
|
|
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
|
|
|
result += stringFromCharCode.apply(null, codeUnits);
|
|
|
codeUnits.length = 0;
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
};
|
|
|
/* istanbul ignore next */
|
|
|
if (_defineProperty2.default) {
|
|
|
Object.defineProperty(String, 'fromCodePoint', {
|
|
|
value: fromCodePoint,
|
|
|
configurable: true,
|
|
|
writable: true
|
|
|
});
|
|
|
} else {
|
|
|
String.fromCodePoint = fromCodePoint;
|
|
|
}
|
|
|
})();
|
|
|
}
|
|
|
})(typeof exports === 'undefined' ? undefined.sax = {} : exports);
|
|
|
|
|
|
}).call(this,require("buffer").Buffer)
|
|
|
},{"babel-runtime/core-js/json/stringify":53,"babel-runtime/core-js/object/create":55,"babel-runtime/core-js/object/define-property":56,"babel-runtime/core-js/object/keys":60,"babel-runtime/core-js/string/from-code-point":63,"babel-runtime/helpers/typeof":67,"buffer":73,"stream":230,"string_decoder":72}],230:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
module.exports = Stream;
|
|
|
|
|
|
var EE = require('events').EventEmitter;
|
|
|
var inherits = require('inherits');
|
|
|
|
|
|
inherits(Stream, EE);
|
|
|
Stream.Readable = require('readable-stream/readable.js');
|
|
|
Stream.Writable = require('readable-stream/writable.js');
|
|
|
Stream.Duplex = require('readable-stream/duplex.js');
|
|
|
Stream.Transform = require('readable-stream/transform.js');
|
|
|
Stream.PassThrough = require('readable-stream/passthrough.js');
|
|
|
|
|
|
// Backwards-compat with node 0.4.x
|
|
|
Stream.Stream = Stream;
|
|
|
|
|
|
|
|
|
|
|
|
// old-style streams. Note that the pipe method (the only relevant
|
|
|
// part of this class) is overridden in the Readable class.
|
|
|
|
|
|
function Stream() {
|
|
|
EE.call(this);
|
|
|
}
|
|
|
|
|
|
Stream.prototype.pipe = function(dest, options) {
|
|
|
var source = this;
|
|
|
|
|
|
function ondata(chunk) {
|
|
|
if (dest.writable) {
|
|
|
if (false === dest.write(chunk) && source.pause) {
|
|
|
source.pause();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
source.on('data', ondata);
|
|
|
|
|
|
function ondrain() {
|
|
|
if (source.readable && source.resume) {
|
|
|
source.resume();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dest.on('drain', ondrain);
|
|
|
|
|
|
// If the 'end' option is not supplied, dest.end() will be called when
|
|
|
// source gets the 'end' or 'close' events. Only dest.end() once.
|
|
|
if (!dest._isStdio && (!options || options.end !== false)) {
|
|
|
source.on('end', onend);
|
|
|
source.on('close', onclose);
|
|
|
}
|
|
|
|
|
|
var didOnEnd = false;
|
|
|
function onend() {
|
|
|
if (didOnEnd) return;
|
|
|
didOnEnd = true;
|
|
|
|
|
|
dest.end();
|
|
|
}
|
|
|
|
|
|
|
|
|
function onclose() {
|
|
|
if (didOnEnd) return;
|
|
|
didOnEnd = true;
|
|
|
|
|
|
if (typeof dest.destroy === 'function') dest.destroy();
|
|
|
}
|
|
|
|
|
|
// don't leave dangling pipes when there are errors.
|
|
|
function onerror(er) {
|
|
|
cleanup();
|
|
|
if (EE.listenerCount(this, 'error') === 0) {
|
|
|
throw er; // Unhandled stream error in pipe.
|
|
|
}
|
|
|
}
|
|
|
|
|
|
source.on('error', onerror);
|
|
|
dest.on('error', onerror);
|
|
|
|
|
|
// remove all the event listeners that were added.
|
|
|
function cleanup() {
|
|
|
source.removeListener('data', ondata);
|
|
|
dest.removeListener('drain', ondrain);
|
|
|
|
|
|
source.removeListener('end', onend);
|
|
|
source.removeListener('close', onclose);
|
|
|
|
|
|
source.removeListener('error', onerror);
|
|
|
dest.removeListener('error', onerror);
|
|
|
|
|
|
source.removeListener('end', cleanup);
|
|
|
source.removeListener('close', cleanup);
|
|
|
|
|
|
dest.removeListener('close', cleanup);
|
|
|
}
|
|
|
|
|
|
source.on('end', cleanup);
|
|
|
source.on('close', cleanup);
|
|
|
|
|
|
dest.on('close', cleanup);
|
|
|
|
|
|
dest.emit('pipe', source);
|
|
|
|
|
|
// Allow for unix-like usage: A.pipe(B).pipe(C)
|
|
|
return dest;
|
|
|
};
|
|
|
|
|
|
},{"events":192,"inherits":196,"readable-stream/duplex.js":213,"readable-stream/passthrough.js":222,"readable-stream/readable.js":223,"readable-stream/transform.js":224,"readable-stream/writable.js":225}],231:[function(require,module,exports){
|
|
|
(function (global){
|
|
|
var ClientRequest = require('./lib/request')
|
|
|
var response = require('./lib/response')
|
|
|
var extend = require('xtend')
|
|
|
var statusCodes = require('builtin-status-codes')
|
|
|
var url = require('url')
|
|
|
|
|
|
var http = exports
|
|
|
|
|
|
http.request = function (opts, cb) {
|
|
|
if (typeof opts === 'string')
|
|
|
opts = url.parse(opts)
|
|
|
else
|
|
|
opts = extend(opts)
|
|
|
|
|
|
// Normally, the page is loaded from http or https, so not specifying a protocol
|
|
|
// will result in a (valid) protocol-relative url. However, this won't work if
|
|
|
// the protocol is something else, like 'file:'
|
|
|
var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
|
|
|
|
|
|
var protocol = opts.protocol || defaultProtocol
|
|
|
var host = opts.hostname || opts.host
|
|
|
var port = opts.port
|
|
|
var path = opts.path || '/'
|
|
|
|
|
|
// Necessary for IPv6 addresses
|
|
|
if (host && host.indexOf(':') !== -1)
|
|
|
host = '[' + host + ']'
|
|
|
|
|
|
// This may be a relative url. The browser should always be able to interpret it correctly.
|
|
|
opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
|
|
|
opts.method = (opts.method || 'GET').toUpperCase()
|
|
|
opts.headers = opts.headers || {}
|
|
|
|
|
|
// Also valid opts.auth, opts.mode
|
|
|
|
|
|
var req = new ClientRequest(opts)
|
|
|
if (cb)
|
|
|
req.on('response', cb)
|
|
|
return req
|
|
|
}
|
|
|
|
|
|
http.get = function get (opts, cb) {
|
|
|
var req = http.request(opts, cb)
|
|
|
req.end()
|
|
|
return req
|
|
|
}
|
|
|
|
|
|
http.ClientRequest = ClientRequest
|
|
|
http.IncomingMessage = response.IncomingMessage
|
|
|
|
|
|
http.Agent = function () {}
|
|
|
http.Agent.defaultMaxSockets = 4
|
|
|
|
|
|
http.globalAgent = new http.Agent()
|
|
|
|
|
|
http.STATUS_CODES = statusCodes
|
|
|
|
|
|
http.METHODS = [
|
|
|
'CHECKOUT',
|
|
|
'CONNECT',
|
|
|
'COPY',
|
|
|
'DELETE',
|
|
|
'GET',
|
|
|
'HEAD',
|
|
|
'LOCK',
|
|
|
'M-SEARCH',
|
|
|
'MERGE',
|
|
|
'MKACTIVITY',
|
|
|
'MKCOL',
|
|
|
'MOVE',
|
|
|
'NOTIFY',
|
|
|
'OPTIONS',
|
|
|
'PATCH',
|
|
|
'POST',
|
|
|
'PROPFIND',
|
|
|
'PROPPATCH',
|
|
|
'PURGE',
|
|
|
'PUT',
|
|
|
'REPORT',
|
|
|
'SEARCH',
|
|
|
'SUBSCRIBE',
|
|
|
'TRACE',
|
|
|
'UNLOCK',
|
|
|
'UNSUBSCRIBE'
|
|
|
]
|
|
|
}).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{"./lib/request":233,"./lib/response":234,"builtin-status-codes":74,"url":238,"xtend":283}],232:[function(require,module,exports){
|
|
|
(function (global){
|
|
|
'use strict';
|
|
|
|
|
|
exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream);
|
|
|
|
|
|
exports.writableStream = isFunction(global.WritableStream);
|
|
|
|
|
|
exports.abortController = isFunction(global.AbortController);
|
|
|
|
|
|
exports.blobConstructor = false;
|
|
|
try {
|
|
|
new Blob([new ArrayBuffer(1)]);
|
|
|
exports.blobConstructor = true;
|
|
|
} catch (e) {}
|
|
|
|
|
|
// The xhr request to example.com may violate some restrictive CSP configurations,
|
|
|
// so if we're running in a browser that supports `fetch`, avoid calling getXHR()
|
|
|
// and assume support for certain features below.
|
|
|
var xhr;
|
|
|
function getXHR() {
|
|
|
// Cache the xhr value
|
|
|
if (xhr !== undefined) return xhr;
|
|
|
|
|
|
if (global.XMLHttpRequest) {
|
|
|
xhr = new global.XMLHttpRequest();
|
|
|
// If XDomainRequest is available (ie only, where xhr might not work
|
|
|
// cross domain), use the page location. Otherwise use example.com
|
|
|
// Note: this doesn't actually make an http request.
|
|
|
try {
|
|
|
xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com');
|
|
|
} catch (e) {
|
|
|
xhr = null;
|
|
|
}
|
|
|
} else {
|
|
|
// Service workers don't have XHR
|
|
|
xhr = null;
|
|
|
}
|
|
|
return xhr;
|
|
|
}
|
|
|
|
|
|
function checkTypeSupport(type) {
|
|
|
var xhr = getXHR();
|
|
|
if (!xhr) return false;
|
|
|
try {
|
|
|
xhr.responseType = type;
|
|
|
return xhr.responseType === type;
|
|
|
} catch (e) {}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
|
|
|
// Safari 7.1 appears to have fixed this bug.
|
|
|
var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined';
|
|
|
var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice);
|
|
|
|
|
|
// If fetch is supported, then arraybuffer will be supported too. Skip calling
|
|
|
// checkTypeSupport(), since that calls getXHR().
|
|
|
exports.arraybuffer = exports.fetch || haveArrayBuffer && checkTypeSupport('arraybuffer');
|
|
|
|
|
|
// These next two tests unavoidably show warnings in Chrome. Since fetch will always
|
|
|
// be used if it's available, just return false for these to avoid the warnings.
|
|
|
exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream');
|
|
|
exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer && checkTypeSupport('moz-chunked-arraybuffer');
|
|
|
|
|
|
// If fetch is supported, then overrideMimeType will be supported too. Skip calling
|
|
|
// getXHR().
|
|
|
exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false);
|
|
|
|
|
|
exports.vbArray = isFunction(global.VBArray);
|
|
|
|
|
|
function isFunction(value) {
|
|
|
return typeof value === 'function';
|
|
|
}
|
|
|
|
|
|
xhr = null; // Help gc
|
|
|
|
|
|
}).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{}],233:[function(require,module,exports){
|
|
|
(function (process,global,Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var capability = require('./capability');
|
|
|
var inherits = require('inherits');
|
|
|
var response = require('./response');
|
|
|
var stream = require('readable-stream');
|
|
|
var toArrayBuffer = require('to-arraybuffer');
|
|
|
|
|
|
var IncomingMessage = response.IncomingMessage;
|
|
|
var rStates = response.readyStates;
|
|
|
|
|
|
function decideMode(preferBinary, useFetch) {
|
|
|
if (capability.fetch && useFetch) {
|
|
|
return 'fetch';
|
|
|
} else if (capability.mozchunkedarraybuffer) {
|
|
|
return 'moz-chunked-arraybuffer';
|
|
|
} else if (capability.msstream) {
|
|
|
return 'ms-stream';
|
|
|
} else if (capability.arraybuffer && preferBinary) {
|
|
|
return 'arraybuffer';
|
|
|
} else if (capability.vbArray && preferBinary) {
|
|
|
return 'text:vbarray';
|
|
|
} else {
|
|
|
return 'text';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var ClientRequest = module.exports = function (opts) {
|
|
|
var self = this;
|
|
|
stream.Writable.call(self);
|
|
|
|
|
|
self._opts = opts;
|
|
|
self._body = [];
|
|
|
self._headers = {};
|
|
|
if (opts.auth) self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'));
|
|
|
(0, _keys2.default)(opts.headers).forEach(function (name) {
|
|
|
self.setHeader(name, opts.headers[name]);
|
|
|
});
|
|
|
|
|
|
var preferBinary;
|
|
|
var useFetch = true;
|
|
|
if (opts.mode === 'disable-fetch' || 'requestTimeout' in opts && !capability.abortController) {
|
|
|
// If the use of XHR should be preferred. Not typically needed.
|
|
|
useFetch = false;
|
|
|
preferBinary = true;
|
|
|
} else if (opts.mode === 'prefer-streaming') {
|
|
|
// If streaming is a high priority but binary compatibility and
|
|
|
// the accuracy of the 'content-type' header aren't
|
|
|
preferBinary = false;
|
|
|
} else if (opts.mode === 'allow-wrong-content-type') {
|
|
|
// If streaming is more important than preserving the 'content-type' header
|
|
|
preferBinary = !capability.overrideMimeType;
|
|
|
} else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
|
|
|
// Use binary if text streaming may corrupt data or the content-type header, or for speed
|
|
|
preferBinary = true;
|
|
|
} else {
|
|
|
throw new Error('Invalid value for opts.mode');
|
|
|
}
|
|
|
self._mode = decideMode(preferBinary, useFetch);
|
|
|
self._fetchTimer = null;
|
|
|
|
|
|
self.on('finish', function () {
|
|
|
self._onFinish();
|
|
|
});
|
|
|
};
|
|
|
|
|
|
inherits(ClientRequest, stream.Writable);
|
|
|
|
|
|
ClientRequest.prototype.setHeader = function (name, value) {
|
|
|
var self = this;
|
|
|
var lowerName = name.toLowerCase();
|
|
|
// This check is not necessary, but it prevents warnings from browsers about setting unsafe
|
|
|
// headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
|
|
|
// http-browserify did it, so I will too.
|
|
|
if (unsafeHeaders.indexOf(lowerName) !== -1) return;
|
|
|
|
|
|
self._headers[lowerName] = {
|
|
|
name: name,
|
|
|
value: value
|
|
|
};
|
|
|
};
|
|
|
|
|
|
ClientRequest.prototype.getHeader = function (name) {
|
|
|
var header = this._headers[name.toLowerCase()];
|
|
|
if (header) return header.value;
|
|
|
return null;
|
|
|
};
|
|
|
|
|
|
ClientRequest.prototype.removeHeader = function (name) {
|
|
|
var self = this;
|
|
|
delete self._headers[name.toLowerCase()];
|
|
|
};
|
|
|
|
|
|
ClientRequest.prototype._onFinish = function () {
|
|
|
var self = this;
|
|
|
|
|
|
if (self._destroyed) return;
|
|
|
var opts = self._opts;
|
|
|
|
|
|
var headersObj = self._headers;
|
|
|
var body = null;
|
|
|
if (opts.method !== 'GET' && opts.method !== 'HEAD') {
|
|
|
if (capability.arraybuffer) {
|
|
|
body = toArrayBuffer(Buffer.concat(self._body));
|
|
|
} else if (capability.blobConstructor) {
|
|
|
body = new global.Blob(self._body.map(function (buffer) {
|
|
|
return toArrayBuffer(buffer);
|
|
|
}), {
|
|
|
type: (headersObj['content-type'] || {}).value || ''
|
|
|
});
|
|
|
} else {
|
|
|
// get utf8 string
|
|
|
body = Buffer.concat(self._body).toString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// create flattened list of headers
|
|
|
var headersList = [];
|
|
|
(0, _keys2.default)(headersObj).forEach(function (keyName) {
|
|
|
var name = headersObj[keyName].name;
|
|
|
var value = headersObj[keyName].value;
|
|
|
if (Array.isArray(value)) {
|
|
|
value.forEach(function (v) {
|
|
|
headersList.push([name, v]);
|
|
|
});
|
|
|
} else {
|
|
|
headersList.push([name, value]);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (self._mode === 'fetch') {
|
|
|
var signal = null;
|
|
|
var fetchTimer = null;
|
|
|
if (capability.abortController) {
|
|
|
var controller = new AbortController();
|
|
|
signal = controller.signal;
|
|
|
self._fetchAbortController = controller;
|
|
|
|
|
|
if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
|
|
|
self._fetchTimer = global.setTimeout(function () {
|
|
|
self.emit('requestTimeout');
|
|
|
if (self._fetchAbortController) self._fetchAbortController.abort();
|
|
|
}, opts.requestTimeout);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
global.fetch(self._opts.url, {
|
|
|
method: self._opts.method,
|
|
|
headers: headersList,
|
|
|
body: body || undefined,
|
|
|
mode: 'cors',
|
|
|
credentials: opts.withCredentials ? 'include' : 'same-origin',
|
|
|
signal: signal
|
|
|
}).then(function (response) {
|
|
|
self._fetchResponse = response;
|
|
|
self._connect();
|
|
|
}, function (reason) {
|
|
|
global.clearTimeout(self._fetchTimer);
|
|
|
if (!self._destroyed) self.emit('error', reason);
|
|
|
});
|
|
|
} else {
|
|
|
var xhr = self._xhr = new global.XMLHttpRequest();
|
|
|
try {
|
|
|
xhr.open(self._opts.method, self._opts.url, true);
|
|
|
} catch (err) {
|
|
|
process.nextTick(function () {
|
|
|
self.emit('error', err);
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Can't set responseType on really old browsers
|
|
|
if ('responseType' in xhr) xhr.responseType = self._mode.split(':')[0];
|
|
|
|
|
|
if ('withCredentials' in xhr) xhr.withCredentials = !!opts.withCredentials;
|
|
|
|
|
|
if (self._mode === 'text' && 'overrideMimeType' in xhr) xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
|
|
|
|
|
if ('requestTimeout' in opts) {
|
|
|
xhr.timeout = opts.requestTimeout;
|
|
|
xhr.ontimeout = function () {
|
|
|
self.emit('requestTimeout');
|
|
|
};
|
|
|
}
|
|
|
|
|
|
headersList.forEach(function (header) {
|
|
|
xhr.setRequestHeader(header[0], header[1]);
|
|
|
});
|
|
|
|
|
|
self._response = null;
|
|
|
xhr.onreadystatechange = function () {
|
|
|
switch (xhr.readyState) {
|
|
|
case rStates.LOADING:
|
|
|
case rStates.DONE:
|
|
|
self._onXHRProgress();
|
|
|
break;
|
|
|
}
|
|
|
};
|
|
|
// Necessary for streaming in Firefox, since xhr.response is ONLY defined
|
|
|
// in onprogress, not in onreadystatechange with xhr.readyState = 3
|
|
|
if (self._mode === 'moz-chunked-arraybuffer') {
|
|
|
xhr.onprogress = function () {
|
|
|
self._onXHRProgress();
|
|
|
};
|
|
|
}
|
|
|
|
|
|
xhr.onerror = function () {
|
|
|
if (self._destroyed) return;
|
|
|
self.emit('error', new Error('XHR error'));
|
|
|
};
|
|
|
|
|
|
try {
|
|
|
xhr.send(body);
|
|
|
} catch (err) {
|
|
|
process.nextTick(function () {
|
|
|
self.emit('error', err);
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Checks if xhr.status is readable and non-zero, indicating no error.
|
|
|
* Even though the spec says it should be available in readyState 3,
|
|
|
* accessing it throws an exception in IE8
|
|
|
*/
|
|
|
function statusValid(xhr) {
|
|
|
try {
|
|
|
var status = xhr.status;
|
|
|
return status !== null && status !== 0;
|
|
|
} catch (e) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ClientRequest.prototype._onXHRProgress = function () {
|
|
|
var self = this;
|
|
|
|
|
|
if (!statusValid(self._xhr) || self._destroyed) return;
|
|
|
|
|
|
if (!self._response) self._connect();
|
|
|
|
|
|
self._response._onXHRProgress();
|
|
|
};
|
|
|
|
|
|
ClientRequest.prototype._connect = function () {
|
|
|
var self = this;
|
|
|
|
|
|
if (self._destroyed) return;
|
|
|
|
|
|
self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer);
|
|
|
self._response.on('error', function (err) {
|
|
|
self.emit('error', err);
|
|
|
});
|
|
|
|
|
|
self.emit('response', self._response);
|
|
|
};
|
|
|
|
|
|
ClientRequest.prototype._write = function (chunk, encoding, cb) {
|
|
|
var self = this;
|
|
|
|
|
|
self._body.push(chunk);
|
|
|
cb();
|
|
|
};
|
|
|
|
|
|
ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
|
|
|
var self = this;
|
|
|
self._destroyed = true;
|
|
|
global.clearTimeout(self._fetchTimer);
|
|
|
if (self._response) self._response._destroyed = true;
|
|
|
if (self._xhr) self._xhr.abort();else if (self._fetchAbortController) self._fetchAbortController.abort();
|
|
|
};
|
|
|
|
|
|
ClientRequest.prototype.end = function (data, encoding, cb) {
|
|
|
var self = this;
|
|
|
if (typeof data === 'function') {
|
|
|
cb = data;
|
|
|
data = undefined;
|
|
|
}
|
|
|
|
|
|
stream.Writable.prototype.end.call(self, data, encoding, cb);
|
|
|
};
|
|
|
|
|
|
ClientRequest.prototype.flushHeaders = function () {};
|
|
|
ClientRequest.prototype.setTimeout = function () {};
|
|
|
ClientRequest.prototype.setNoDelay = function () {};
|
|
|
ClientRequest.prototype.setSocketKeepAlive = function () {};
|
|
|
|
|
|
// Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
|
|
|
var unsafeHeaders = ['accept-charset', 'accept-encoding', 'access-control-request-headers', 'access-control-request-method', 'connection', 'content-length', 'cookie', 'cookie2', 'date', 'dnt', 'expect', 'host', 'keep-alive', 'origin', 'referer', 'te', 'trailer', 'transfer-encoding', 'upgrade', 'user-agent', 'via'];
|
|
|
|
|
|
}).call(this,require('_process'),typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
|
|
|
},{"./capability":232,"./response":234,"_process":208,"babel-runtime/core-js/object/keys":60,"buffer":73,"inherits":196,"readable-stream":223,"to-arraybuffer":237}],234:[function(require,module,exports){
|
|
|
(function (process,global,Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _promise = require('babel-runtime/core-js/promise');
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var capability = require('./capability');
|
|
|
var inherits = require('inherits');
|
|
|
var stream = require('readable-stream');
|
|
|
|
|
|
var rStates = exports.readyStates = {
|
|
|
UNSENT: 0,
|
|
|
OPENED: 1,
|
|
|
HEADERS_RECEIVED: 2,
|
|
|
LOADING: 3,
|
|
|
DONE: 4
|
|
|
};
|
|
|
|
|
|
var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
|
|
|
var self = this;
|
|
|
stream.Readable.call(self);
|
|
|
|
|
|
self._mode = mode;
|
|
|
self.headers = {};
|
|
|
self.rawHeaders = [];
|
|
|
self.trailers = {};
|
|
|
self.rawTrailers = [];
|
|
|
|
|
|
// Fake the 'close' event, but only once 'end' fires
|
|
|
self.on('end', function () {
|
|
|
// The nextTick is necessary to prevent the 'request' module from causing an infinite loop
|
|
|
process.nextTick(function () {
|
|
|
self.emit('close');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
if (mode === 'fetch') {
|
|
|
var read = function read() {
|
|
|
reader.read().then(function (result) {
|
|
|
if (self._destroyed) return;
|
|
|
if (result.done) {
|
|
|
global.clearTimeout(fetchTimer);
|
|
|
self.push(null);
|
|
|
return;
|
|
|
}
|
|
|
self.push(new Buffer(result.value));
|
|
|
read();
|
|
|
}).catch(function (err) {
|
|
|
global.clearTimeout(fetchTimer);
|
|
|
if (!self._destroyed) self.emit('error', err);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
self._fetchResponse = response;
|
|
|
|
|
|
self.url = response.url;
|
|
|
self.statusCode = response.status;
|
|
|
self.statusMessage = response.statusText;
|
|
|
|
|
|
response.headers.forEach(function (header, key) {
|
|
|
self.headers[key.toLowerCase()] = header;
|
|
|
self.rawHeaders.push(key, header);
|
|
|
});
|
|
|
|
|
|
if (capability.writableStream) {
|
|
|
var writable = new WritableStream({
|
|
|
write: function write(chunk) {
|
|
|
return new _promise2.default(function (resolve, reject) {
|
|
|
if (self._destroyed) {
|
|
|
reject();
|
|
|
} else if (self.push(new Buffer(chunk))) {
|
|
|
resolve();
|
|
|
} else {
|
|
|
self._resumeFetch = resolve;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
close: function close() {
|
|
|
global.clearTimeout(fetchTimer);
|
|
|
if (!self._destroyed) self.push(null);
|
|
|
},
|
|
|
abort: function abort(err) {
|
|
|
if (!self._destroyed) self.emit('error', err);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
try {
|
|
|
response.body.pipeTo(writable).catch(function (err) {
|
|
|
global.clearTimeout(fetchTimer);
|
|
|
if (!self._destroyed) self.emit('error', err);
|
|
|
});
|
|
|
return;
|
|
|
} catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
|
|
|
}
|
|
|
// fallback for when writableStream or pipeTo aren't available
|
|
|
var reader = response.body.getReader();
|
|
|
|
|
|
read();
|
|
|
} else {
|
|
|
self._xhr = xhr;
|
|
|
self._pos = 0;
|
|
|
|
|
|
self.url = xhr.responseURL;
|
|
|
self.statusCode = xhr.status;
|
|
|
self.statusMessage = xhr.statusText;
|
|
|
var headers = xhr.getAllResponseHeaders().split(/\r?\n/);
|
|
|
headers.forEach(function (header) {
|
|
|
var matches = header.match(/^([^:]+):\s*(.*)/);
|
|
|
if (matches) {
|
|
|
var key = matches[1].toLowerCase();
|
|
|
if (key === 'set-cookie') {
|
|
|
if (self.headers[key] === undefined) {
|
|
|
self.headers[key] = [];
|
|
|
}
|
|
|
self.headers[key].push(matches[2]);
|
|
|
} else if (self.headers[key] !== undefined) {
|
|
|
self.headers[key] += ', ' + matches[2];
|
|
|
} else {
|
|
|
self.headers[key] = matches[2];
|
|
|
}
|
|
|
self.rawHeaders.push(matches[1], matches[2]);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
self._charset = 'x-user-defined';
|
|
|
if (!capability.overrideMimeType) {
|
|
|
var mimeType = self.rawHeaders['mime-type'];
|
|
|
if (mimeType) {
|
|
|
var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/);
|
|
|
if (charsetMatch) {
|
|
|
self._charset = charsetMatch[1].toLowerCase();
|
|
|
}
|
|
|
}
|
|
|
if (!self._charset) self._charset = 'utf-8'; // best guess
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
inherits(IncomingMessage, stream.Readable);
|
|
|
|
|
|
IncomingMessage.prototype._read = function () {
|
|
|
var self = this;
|
|
|
|
|
|
var resolve = self._resumeFetch;
|
|
|
if (resolve) {
|
|
|
self._resumeFetch = null;
|
|
|
resolve();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
IncomingMessage.prototype._onXHRProgress = function () {
|
|
|
var self = this;
|
|
|
|
|
|
var xhr = self._xhr;
|
|
|
|
|
|
var response = null;
|
|
|
switch (self._mode) {
|
|
|
case 'text:vbarray':
|
|
|
// For IE9
|
|
|
if (xhr.readyState !== rStates.DONE) break;
|
|
|
try {
|
|
|
// This fails in IE8
|
|
|
response = new global.VBArray(xhr.responseBody).toArray();
|
|
|
} catch (e) {}
|
|
|
if (response !== null) {
|
|
|
self.push(new Buffer(response));
|
|
|
break;
|
|
|
}
|
|
|
// Falls through in IE8
|
|
|
case 'text':
|
|
|
try {
|
|
|
// This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
|
|
|
response = xhr.responseText;
|
|
|
} catch (e) {
|
|
|
self._mode = 'text:vbarray';
|
|
|
break;
|
|
|
}
|
|
|
if (response.length > self._pos) {
|
|
|
var newData = response.substr(self._pos);
|
|
|
if (self._charset === 'x-user-defined') {
|
|
|
var buffer = new Buffer(newData.length);
|
|
|
for (var i = 0; i < newData.length; i++) {
|
|
|
buffer[i] = newData.charCodeAt(i) & 0xff;
|
|
|
}self.push(buffer);
|
|
|
} else {
|
|
|
self.push(newData, self._charset);
|
|
|
}
|
|
|
self._pos = response.length;
|
|
|
}
|
|
|
break;
|
|
|
case 'arraybuffer':
|
|
|
if (xhr.readyState !== rStates.DONE || !xhr.response) break;
|
|
|
response = xhr.response;
|
|
|
self.push(new Buffer(new Uint8Array(response)));
|
|
|
break;
|
|
|
case 'moz-chunked-arraybuffer':
|
|
|
// take whole
|
|
|
response = xhr.response;
|
|
|
if (xhr.readyState !== rStates.LOADING || !response) break;
|
|
|
self.push(new Buffer(new Uint8Array(response)));
|
|
|
break;
|
|
|
case 'ms-stream':
|
|
|
response = xhr.response;
|
|
|
if (xhr.readyState !== rStates.LOADING) break;
|
|
|
var reader = new global.MSStreamReader();
|
|
|
reader.onprogress = function () {
|
|
|
if (reader.result.byteLength > self._pos) {
|
|
|
self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))));
|
|
|
self._pos = reader.result.byteLength;
|
|
|
}
|
|
|
};
|
|
|
reader.onload = function () {
|
|
|
self.push(null);
|
|
|
};
|
|
|
// reader.onerror = ??? // TODO: this
|
|
|
reader.readAsArrayBuffer(response);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// The ms-stream case handles end separately in reader.onload()
|
|
|
if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
|
|
|
self.push(null);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
}).call(this,require('_process'),typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
|
|
|
},{"./capability":232,"_process":208,"babel-runtime/core-js/promise":61,"buffer":73,"inherits":196,"readable-stream":223}],235:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
|
|
var Buffer = require('safe-buffer').Buffer;
|
|
|
/*</replacement>*/
|
|
|
|
|
|
var isEncoding = Buffer.isEncoding || function (encoding) {
|
|
|
encoding = '' + encoding;
|
|
|
switch (encoding && encoding.toLowerCase()) {
|
|
|
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':
|
|
|
return true;
|
|
|
default:
|
|
|
return false;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function _normalizeEncoding(enc) {
|
|
|
if (!enc) return 'utf8';
|
|
|
var retried;
|
|
|
while (true) {
|
|
|
switch (enc) {
|
|
|
case 'utf8':
|
|
|
case 'utf-8':
|
|
|
return 'utf8';
|
|
|
case 'ucs2':
|
|
|
case 'ucs-2':
|
|
|
case 'utf16le':
|
|
|
case 'utf-16le':
|
|
|
return 'utf16le';
|
|
|
case 'latin1':
|
|
|
case 'binary':
|
|
|
return 'latin1';
|
|
|
case 'base64':
|
|
|
case 'ascii':
|
|
|
case 'hex':
|
|
|
return enc;
|
|
|
default:
|
|
|
if (retried) return; // undefined
|
|
|
enc = ('' + enc).toLowerCase();
|
|
|
retried = true;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
|
|
// modules monkey-patch it to support additional encodings
|
|
|
function normalizeEncoding(enc) {
|
|
|
var nenc = _normalizeEncoding(enc);
|
|
|
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
|
|
|
return nenc || enc;
|
|
|
}
|
|
|
|
|
|
// StringDecoder provides an interface for efficiently splitting a series of
|
|
|
// buffers into a series of JS strings without breaking apart multi-byte
|
|
|
// characters.
|
|
|
exports.StringDecoder = StringDecoder;
|
|
|
function StringDecoder(encoding) {
|
|
|
this.encoding = normalizeEncoding(encoding);
|
|
|
var nb;
|
|
|
switch (this.encoding) {
|
|
|
case 'utf16le':
|
|
|
this.text = utf16Text;
|
|
|
this.end = utf16End;
|
|
|
nb = 4;
|
|
|
break;
|
|
|
case 'utf8':
|
|
|
this.fillLast = utf8FillLast;
|
|
|
nb = 4;
|
|
|
break;
|
|
|
case 'base64':
|
|
|
this.text = base64Text;
|
|
|
this.end = base64End;
|
|
|
nb = 3;
|
|
|
break;
|
|
|
default:
|
|
|
this.write = simpleWrite;
|
|
|
this.end = simpleEnd;
|
|
|
return;
|
|
|
}
|
|
|
this.lastNeed = 0;
|
|
|
this.lastTotal = 0;
|
|
|
this.lastChar = Buffer.allocUnsafe(nb);
|
|
|
}
|
|
|
|
|
|
StringDecoder.prototype.write = function (buf) {
|
|
|
if (buf.length === 0) return '';
|
|
|
var r;
|
|
|
var i;
|
|
|
if (this.lastNeed) {
|
|
|
r = this.fillLast(buf);
|
|
|
if (r === undefined) return '';
|
|
|
i = this.lastNeed;
|
|
|
this.lastNeed = 0;
|
|
|
} else {
|
|
|
i = 0;
|
|
|
}
|
|
|
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
|
|
return r || '';
|
|
|
};
|
|
|
|
|
|
StringDecoder.prototype.end = utf8End;
|
|
|
|
|
|
// Returns only complete characters in a Buffer
|
|
|
StringDecoder.prototype.text = utf8Text;
|
|
|
|
|
|
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
|
|
|
StringDecoder.prototype.fillLast = function (buf) {
|
|
|
if (this.lastNeed <= buf.length) {
|
|
|
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
|
|
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
|
}
|
|
|
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
|
|
this.lastNeed -= buf.length;
|
|
|
};
|
|
|
|
|
|
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
|
|
|
// continuation byte. If an invalid byte is detected, -2 is returned.
|
|
|
function utf8CheckByte(byte) {
|
|
|
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;
|
|
|
return byte >> 6 === 0x02 ? -1 : -2;
|
|
|
}
|
|
|
|
|
|
// Checks at most 3 bytes at the end of a Buffer in order to detect an
|
|
|
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
|
|
|
// needed to complete the UTF-8 character (if applicable) are returned.
|
|
|
function utf8CheckIncomplete(self, buf, i) {
|
|
|
var j = buf.length - 1;
|
|
|
if (j < i) return 0;
|
|
|
var nb = utf8CheckByte(buf[j]);
|
|
|
if (nb >= 0) {
|
|
|
if (nb > 0) self.lastNeed = nb - 1;
|
|
|
return nb;
|
|
|
}
|
|
|
if (--j < i || nb === -2) return 0;
|
|
|
nb = utf8CheckByte(buf[j]);
|
|
|
if (nb >= 0) {
|
|
|
if (nb > 0) self.lastNeed = nb - 2;
|
|
|
return nb;
|
|
|
}
|
|
|
if (--j < i || nb === -2) return 0;
|
|
|
nb = utf8CheckByte(buf[j]);
|
|
|
if (nb >= 0) {
|
|
|
if (nb > 0) {
|
|
|
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
|
|
|
}
|
|
|
return nb;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
// Validates as many continuation bytes for a multi-byte UTF-8 character as
|
|
|
// needed or are available. If we see a non-continuation byte where we expect
|
|
|
// one, we "replace" the validated continuation bytes we've seen so far with
|
|
|
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
|
|
|
// behavior. The continuation byte check is included three times in the case
|
|
|
// where all of the continuation bytes for a character exist in the same buffer.
|
|
|
// It is also done this way as a slight performance increase instead of using a
|
|
|
// loop.
|
|
|
function utf8CheckExtraBytes(self, buf, p) {
|
|
|
if ((buf[0] & 0xC0) !== 0x80) {
|
|
|
self.lastNeed = 0;
|
|
|
return '\uFFFD';
|
|
|
}
|
|
|
if (self.lastNeed > 1 && buf.length > 1) {
|
|
|
if ((buf[1] & 0xC0) !== 0x80) {
|
|
|
self.lastNeed = 1;
|
|
|
return '\uFFFD';
|
|
|
}
|
|
|
if (self.lastNeed > 2 && buf.length > 2) {
|
|
|
if ((buf[2] & 0xC0) !== 0x80) {
|
|
|
self.lastNeed = 2;
|
|
|
return '\uFFFD';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
|
|
|
function utf8FillLast(buf) {
|
|
|
var p = this.lastTotal - this.lastNeed;
|
|
|
var r = utf8CheckExtraBytes(this, buf, p);
|
|
|
if (r !== undefined) return r;
|
|
|
if (this.lastNeed <= buf.length) {
|
|
|
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
|
|
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
|
}
|
|
|
buf.copy(this.lastChar, p, 0, buf.length);
|
|
|
this.lastNeed -= buf.length;
|
|
|
}
|
|
|
|
|
|
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
|
|
|
// partial character, the character's bytes are buffered until the required
|
|
|
// number of bytes are available.
|
|
|
function utf8Text(buf, i) {
|
|
|
var total = utf8CheckIncomplete(this, buf, i);
|
|
|
if (!this.lastNeed) return buf.toString('utf8', i);
|
|
|
this.lastTotal = total;
|
|
|
var end = buf.length - (total - this.lastNeed);
|
|
|
buf.copy(this.lastChar, 0, end);
|
|
|
return buf.toString('utf8', i, end);
|
|
|
}
|
|
|
|
|
|
// For UTF-8, a replacement character is added when ending on a partial
|
|
|
// character.
|
|
|
function utf8End(buf) {
|
|
|
var r = buf && buf.length ? this.write(buf) : '';
|
|
|
if (this.lastNeed) return r + '\uFFFD';
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
// UTF-16LE typically needs two bytes per character, but even if we have an even
|
|
|
// number of bytes available, we need to check if we end on a leading/high
|
|
|
// surrogate. In that case, we need to wait for the next two bytes in order to
|
|
|
// decode the last character properly.
|
|
|
function utf16Text(buf, i) {
|
|
|
if ((buf.length - i) % 2 === 0) {
|
|
|
var r = buf.toString('utf16le', i);
|
|
|
if (r) {
|
|
|
var c = r.charCodeAt(r.length - 1);
|
|
|
if (c >= 0xD800 && c <= 0xDBFF) {
|
|
|
this.lastNeed = 2;
|
|
|
this.lastTotal = 4;
|
|
|
this.lastChar[0] = buf[buf.length - 2];
|
|
|
this.lastChar[1] = buf[buf.length - 1];
|
|
|
return r.slice(0, -1);
|
|
|
}
|
|
|
}
|
|
|
return r;
|
|
|
}
|
|
|
this.lastNeed = 1;
|
|
|
this.lastTotal = 2;
|
|
|
this.lastChar[0] = buf[buf.length - 1];
|
|
|
return buf.toString('utf16le', i, buf.length - 1);
|
|
|
}
|
|
|
|
|
|
// For UTF-16LE we do not explicitly append special replacement characters if we
|
|
|
// end on a partial character, we simply let v8 handle that.
|
|
|
function utf16End(buf) {
|
|
|
var r = buf && buf.length ? this.write(buf) : '';
|
|
|
if (this.lastNeed) {
|
|
|
var end = this.lastTotal - this.lastNeed;
|
|
|
return r + this.lastChar.toString('utf16le', 0, end);
|
|
|
}
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
function base64Text(buf, i) {
|
|
|
var n = (buf.length - i) % 3;
|
|
|
if (n === 0) return buf.toString('base64', i);
|
|
|
this.lastNeed = 3 - n;
|
|
|
this.lastTotal = 3;
|
|
|
if (n === 1) {
|
|
|
this.lastChar[0] = buf[buf.length - 1];
|
|
|
} else {
|
|
|
this.lastChar[0] = buf[buf.length - 2];
|
|
|
this.lastChar[1] = buf[buf.length - 1];
|
|
|
}
|
|
|
return buf.toString('base64', i, buf.length - n);
|
|
|
}
|
|
|
|
|
|
function base64End(buf) {
|
|
|
var r = buf && buf.length ? this.write(buf) : '';
|
|
|
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
|
|
|
function simpleWrite(buf) {
|
|
|
return buf.toString(this.encoding);
|
|
|
}
|
|
|
|
|
|
function simpleEnd(buf) {
|
|
|
return buf && buf.length ? this.write(buf) : '';
|
|
|
}
|
|
|
|
|
|
},{"safe-buffer":228}],236:[function(require,module,exports){
|
|
|
(function (setImmediate,clearImmediate){
|
|
|
var nextTick = require('process/browser.js').nextTick;
|
|
|
var apply = Function.prototype.apply;
|
|
|
var slice = Array.prototype.slice;
|
|
|
var immediateIds = {};
|
|
|
var nextImmediateId = 0;
|
|
|
|
|
|
// DOM APIs, for completeness
|
|
|
|
|
|
exports.setTimeout = function() {
|
|
|
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
|
|
|
};
|
|
|
exports.setInterval = function() {
|
|
|
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
|
|
|
};
|
|
|
exports.clearTimeout =
|
|
|
exports.clearInterval = function(timeout) { timeout.close(); };
|
|
|
|
|
|
function Timeout(id, clearFn) {
|
|
|
this._id = id;
|
|
|
this._clearFn = clearFn;
|
|
|
}
|
|
|
Timeout.prototype.unref = Timeout.prototype.ref = function() {};
|
|
|
Timeout.prototype.close = function() {
|
|
|
this._clearFn.call(window, this._id);
|
|
|
};
|
|
|
|
|
|
// Does not start the time, just sets up the members needed.
|
|
|
exports.enroll = function(item, msecs) {
|
|
|
clearTimeout(item._idleTimeoutId);
|
|
|
item._idleTimeout = msecs;
|
|
|
};
|
|
|
|
|
|
exports.unenroll = function(item) {
|
|
|
clearTimeout(item._idleTimeoutId);
|
|
|
item._idleTimeout = -1;
|
|
|
};
|
|
|
|
|
|
exports._unrefActive = exports.active = function(item) {
|
|
|
clearTimeout(item._idleTimeoutId);
|
|
|
|
|
|
var msecs = item._idleTimeout;
|
|
|
if (msecs >= 0) {
|
|
|
item._idleTimeoutId = setTimeout(function onTimeout() {
|
|
|
if (item._onTimeout)
|
|
|
item._onTimeout();
|
|
|
}, msecs);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// That's not how node.js implements it but the exposed api is the same.
|
|
|
exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
|
|
|
var id = nextImmediateId++;
|
|
|
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
|
|
|
|
|
|
immediateIds[id] = true;
|
|
|
|
|
|
nextTick(function onNextTick() {
|
|
|
if (immediateIds[id]) {
|
|
|
// fn.call() is faster so we optimize for the common use-case
|
|
|
// @see http://jsperf.com/call-apply-segu
|
|
|
if (args) {
|
|
|
fn.apply(null, args);
|
|
|
} else {
|
|
|
fn.call(null);
|
|
|
}
|
|
|
// Prevent ids from leaking
|
|
|
exports.clearImmediate(id);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return id;
|
|
|
};
|
|
|
|
|
|
exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
|
|
|
delete immediateIds[id];
|
|
|
};
|
|
|
}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
|
|
|
},{"process/browser.js":208,"timers":236}],237:[function(require,module,exports){
|
|
|
var Buffer = require('buffer').Buffer
|
|
|
|
|
|
module.exports = function (buf) {
|
|
|
// If the buffer is backed by a Uint8Array, a faster version will work
|
|
|
if (buf instanceof Uint8Array) {
|
|
|
// If the buffer isn't a subarray, return the underlying ArrayBuffer
|
|
|
if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
|
|
|
return buf.buffer
|
|
|
} else if (typeof buf.buffer.slice === 'function') {
|
|
|
// Otherwise we need to get a proper copy
|
|
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (Buffer.isBuffer(buf)) {
|
|
|
// This is the slow version that will work with any Buffer
|
|
|
// implementation (even in old browsers)
|
|
|
var arrayCopy = new Uint8Array(buf.length)
|
|
|
var len = buf.length
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
arrayCopy[i] = buf[i]
|
|
|
}
|
|
|
return arrayCopy.buffer
|
|
|
} else {
|
|
|
throw new Error('Argument must be a Buffer')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},{"buffer":73}],238:[function(require,module,exports){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
var punycode = require('punycode');
|
|
|
var util = require('./util');
|
|
|
|
|
|
exports.parse = urlParse;
|
|
|
exports.resolve = urlResolve;
|
|
|
exports.resolveObject = urlResolveObject;
|
|
|
exports.format = urlFormat;
|
|
|
|
|
|
exports.Url = Url;
|
|
|
|
|
|
function Url() {
|
|
|
this.protocol = null;
|
|
|
this.slashes = null;
|
|
|
this.auth = null;
|
|
|
this.host = null;
|
|
|
this.port = null;
|
|
|
this.hostname = null;
|
|
|
this.hash = null;
|
|
|
this.search = null;
|
|
|
this.query = null;
|
|
|
this.pathname = null;
|
|
|
this.path = null;
|
|
|
this.href = null;
|
|
|
}
|
|
|
|
|
|
// Reference: RFC 3986, RFC 1808, RFC 2396
|
|
|
|
|
|
// define these here so at least they only have to be
|
|
|
// compiled once on the first module load.
|
|
|
var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
|
|
portPattern = /:[0-9]*$/,
|
|
|
|
|
|
// Special case for a simple path URL
|
|
|
simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
|
|
|
|
|
|
// RFC 2396: characters reserved for delimiting URLs.
|
|
|
// We actually just auto-escape these.
|
|
|
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
|
|
|
|
|
// RFC 2396: characters not allowed for various reasons.
|
|
|
unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
|
|
|
|
|
|
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
|
|
|
autoEscape = ['\''].concat(unwise),
|
|
|
// Characters that are never ever allowed in a hostname.
|
|
|
// Note that any invalid chars are also handled, but these
|
|
|
// are the ones that are *expected* to be seen, so we fast-path
|
|
|
// them.
|
|
|
nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
|
|
|
hostEndingChars = ['/', '?', '#'],
|
|
|
hostnameMaxLen = 255,
|
|
|
hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
|
|
|
hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
|
|
|
// protocols that can allow "unsafe" and "unwise" chars.
|
|
|
unsafeProtocol = {
|
|
|
'javascript': true,
|
|
|
'javascript:': true
|
|
|
},
|
|
|
// protocols that never have a hostname.
|
|
|
hostlessProtocol = {
|
|
|
'javascript': true,
|
|
|
'javascript:': true
|
|
|
},
|
|
|
// protocols that always contain a // bit.
|
|
|
slashedProtocol = {
|
|
|
'http': true,
|
|
|
'https': true,
|
|
|
'ftp': true,
|
|
|
'gopher': true,
|
|
|
'file': true,
|
|
|
'http:': true,
|
|
|
'https:': true,
|
|
|
'ftp:': true,
|
|
|
'gopher:': true,
|
|
|
'file:': true
|
|
|
},
|
|
|
querystring = require('querystring');
|
|
|
|
|
|
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
|
|
if (url && util.isObject(url) && url instanceof Url) return url;
|
|
|
|
|
|
var u = new Url;
|
|
|
u.parse(url, parseQueryString, slashesDenoteHost);
|
|
|
return u;
|
|
|
}
|
|
|
|
|
|
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
|
|
|
if (!util.isString(url)) {
|
|
|
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
|
|
}
|
|
|
|
|
|
// Copy chrome, IE, opera backslash-handling behavior.
|
|
|
// Back slashes before the query string get converted to forward slashes
|
|
|
// See: https://code.google.com/p/chromium/issues/detail?id=25916
|
|
|
var queryIndex = url.indexOf('?'),
|
|
|
splitter =
|
|
|
(queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
|
|
|
uSplit = url.split(splitter),
|
|
|
slashRegex = /\\/g;
|
|
|
uSplit[0] = uSplit[0].replace(slashRegex, '/');
|
|
|
url = uSplit.join(splitter);
|
|
|
|
|
|
var rest = url;
|
|
|
|
|
|
// trim before proceeding.
|
|
|
// This is to support parse stuff like " http://foo.com \n"
|
|
|
rest = rest.trim();
|
|
|
|
|
|
if (!slashesDenoteHost && url.split('#').length === 1) {
|
|
|
// Try fast path regexp
|
|
|
var simplePath = simplePathPattern.exec(rest);
|
|
|
if (simplePath) {
|
|
|
this.path = rest;
|
|
|
this.href = rest;
|
|
|
this.pathname = simplePath[1];
|
|
|
if (simplePath[2]) {
|
|
|
this.search = simplePath[2];
|
|
|
if (parseQueryString) {
|
|
|
this.query = querystring.parse(this.search.substr(1));
|
|
|
} else {
|
|
|
this.query = this.search.substr(1);
|
|
|
}
|
|
|
} else if (parseQueryString) {
|
|
|
this.search = '';
|
|
|
this.query = {};
|
|
|
}
|
|
|
return this;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var proto = protocolPattern.exec(rest);
|
|
|
if (proto) {
|
|
|
proto = proto[0];
|
|
|
var lowerProto = proto.toLowerCase();
|
|
|
this.protocol = lowerProto;
|
|
|
rest = rest.substr(proto.length);
|
|
|
}
|
|
|
|
|
|
// figure out if it's got a host
|
|
|
// user@server is *always* interpreted as a hostname, and url
|
|
|
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
|
|
// how the browser resolves relative URLs.
|
|
|
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
|
|
var slashes = rest.substr(0, 2) === '//';
|
|
|
if (slashes && !(proto && hostlessProtocol[proto])) {
|
|
|
rest = rest.substr(2);
|
|
|
this.slashes = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!hostlessProtocol[proto] &&
|
|
|
(slashes || (proto && !slashedProtocol[proto]))) {
|
|
|
|
|
|
// there's a hostname.
|
|
|
// the first instance of /, ?, ;, or # ends the host.
|
|
|
//
|
|
|
// If there is an @ in the hostname, then non-host chars *are* allowed
|
|
|
// to the left of the last @ sign, unless some host-ending character
|
|
|
// comes *before* the @-sign.
|
|
|
// URLs are obnoxious.
|
|
|
//
|
|
|
// ex:
|
|
|
// http://a@b@c/ => user:a@b host:c
|
|
|
// http://a@b?@c => user:a host:c path:/?@c
|
|
|
|
|
|
// v0.12 TODO(isaacs): This is not quite how Chrome does things.
|
|
|
// Review our test case against browsers more comprehensively.
|
|
|
|
|
|
// find the first instance of any hostEndingChars
|
|
|
var hostEnd = -1;
|
|
|
for (var i = 0; i < hostEndingChars.length; i++) {
|
|
|
var hec = rest.indexOf(hostEndingChars[i]);
|
|
|
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
|
hostEnd = hec;
|
|
|
}
|
|
|
|
|
|
// at this point, either we have an explicit point where the
|
|
|
// auth portion cannot go past, or the last @ char is the decider.
|
|
|
var auth, atSign;
|
|
|
if (hostEnd === -1) {
|
|
|
// atSign can be anywhere.
|
|
|
atSign = rest.lastIndexOf('@');
|
|
|
} else {
|
|
|
// atSign must be in auth portion.
|
|
|
// http://a@b/c@d => host:b auth:a path:/c@d
|
|
|
atSign = rest.lastIndexOf('@', hostEnd);
|
|
|
}
|
|
|
|
|
|
// Now we have a portion which is definitely the auth.
|
|
|
// Pull that off.
|
|
|
if (atSign !== -1) {
|
|
|
auth = rest.slice(0, atSign);
|
|
|
rest = rest.slice(atSign + 1);
|
|
|
this.auth = decodeURIComponent(auth);
|
|
|
}
|
|
|
|
|
|
// the host is the remaining to the left of the first non-host char
|
|
|
hostEnd = -1;
|
|
|
for (var i = 0; i < nonHostChars.length; i++) {
|
|
|
var hec = rest.indexOf(nonHostChars[i]);
|
|
|
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
|
hostEnd = hec;
|
|
|
}
|
|
|
// if we still have not hit it, then the entire thing is a host.
|
|
|
if (hostEnd === -1)
|
|
|
hostEnd = rest.length;
|
|
|
|
|
|
this.host = rest.slice(0, hostEnd);
|
|
|
rest = rest.slice(hostEnd);
|
|
|
|
|
|
// pull out port.
|
|
|
this.parseHost();
|
|
|
|
|
|
// we've indicated that there is a hostname,
|
|
|
// so even if it's empty, it has to be present.
|
|
|
this.hostname = this.hostname || '';
|
|
|
|
|
|
// if hostname begins with [ and ends with ]
|
|
|
// assume that it's an IPv6 address.
|
|
|
var ipv6Hostname = this.hostname[0] === '[' &&
|
|
|
this.hostname[this.hostname.length - 1] === ']';
|
|
|
|
|
|
// validate a little.
|
|
|
if (!ipv6Hostname) {
|
|
|
var hostparts = this.hostname.split(/\./);
|
|
|
for (var i = 0, l = hostparts.length; i < l; i++) {
|
|
|
var part = hostparts[i];
|
|
|
if (!part) continue;
|
|
|
if (!part.match(hostnamePartPattern)) {
|
|
|
var newpart = '';
|
|
|
for (var j = 0, k = part.length; j < k; j++) {
|
|
|
if (part.charCodeAt(j) > 127) {
|
|
|
// we replace non-ASCII char with a temporary placeholder
|
|
|
// we need this to make sure size of hostname is not
|
|
|
// broken by replacing non-ASCII by nothing
|
|
|
newpart += 'x';
|
|
|
} else {
|
|
|
newpart += part[j];
|
|
|
}
|
|
|
}
|
|
|
// we test again with ASCII char only
|
|
|
if (!newpart.match(hostnamePartPattern)) {
|
|
|
var validParts = hostparts.slice(0, i);
|
|
|
var notHost = hostparts.slice(i + 1);
|
|
|
var bit = part.match(hostnamePartStart);
|
|
|
if (bit) {
|
|
|
validParts.push(bit[1]);
|
|
|
notHost.unshift(bit[2]);
|
|
|
}
|
|
|
if (notHost.length) {
|
|
|
rest = '/' + notHost.join('.') + rest;
|
|
|
}
|
|
|
this.hostname = validParts.join('.');
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (this.hostname.length > hostnameMaxLen) {
|
|
|
this.hostname = '';
|
|
|
} else {
|
|
|
// hostnames are always lower case.
|
|
|
this.hostname = this.hostname.toLowerCase();
|
|
|
}
|
|
|
|
|
|
if (!ipv6Hostname) {
|
|
|
// IDNA Support: Returns a punycoded representation of "domain".
|
|
|
// It only converts parts of the domain name that
|
|
|
// have non-ASCII characters, i.e. it doesn't matter if
|
|
|
// you call it with a domain that already is ASCII-only.
|
|
|
this.hostname = punycode.toASCII(this.hostname);
|
|
|
}
|
|
|
|
|
|
var p = this.port ? ':' + this.port : '';
|
|
|
var h = this.hostname || '';
|
|
|
this.host = h + p;
|
|
|
this.href += this.host;
|
|
|
|
|
|
// strip [ and ] from the hostname
|
|
|
// the host field still retains them, though
|
|
|
if (ipv6Hostname) {
|
|
|
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
|
|
|
if (rest[0] !== '/') {
|
|
|
rest = '/' + rest;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// now rest is set to the post-host stuff.
|
|
|
// chop off any delim chars.
|
|
|
if (!unsafeProtocol[lowerProto]) {
|
|
|
|
|
|
// First, make 100% sure that any "autoEscape" chars get
|
|
|
// escaped, even if encodeURIComponent doesn't think they
|
|
|
// need to be.
|
|
|
for (var i = 0, l = autoEscape.length; i < l; i++) {
|
|
|
var ae = autoEscape[i];
|
|
|
if (rest.indexOf(ae) === -1)
|
|
|
continue;
|
|
|
var esc = encodeURIComponent(ae);
|
|
|
if (esc === ae) {
|
|
|
esc = escape(ae);
|
|
|
}
|
|
|
rest = rest.split(ae).join(esc);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// chop off from the tail first.
|
|
|
var hash = rest.indexOf('#');
|
|
|
if (hash !== -1) {
|
|
|
// got a fragment string.
|
|
|
this.hash = rest.substr(hash);
|
|
|
rest = rest.slice(0, hash);
|
|
|
}
|
|
|
var qm = rest.indexOf('?');
|
|
|
if (qm !== -1) {
|
|
|
this.search = rest.substr(qm);
|
|
|
this.query = rest.substr(qm + 1);
|
|
|
if (parseQueryString) {
|
|
|
this.query = querystring.parse(this.query);
|
|
|
}
|
|
|
rest = rest.slice(0, qm);
|
|
|
} else if (parseQueryString) {
|
|
|
// no query string, but parseQueryString still requested
|
|
|
this.search = '';
|
|
|
this.query = {};
|
|
|
}
|
|
|
if (rest) this.pathname = rest;
|
|
|
if (slashedProtocol[lowerProto] &&
|
|
|
this.hostname && !this.pathname) {
|
|
|
this.pathname = '/';
|
|
|
}
|
|
|
|
|
|
//to support http.request
|
|
|
if (this.pathname || this.search) {
|
|
|
var p = this.pathname || '';
|
|
|
var s = this.search || '';
|
|
|
this.path = p + s;
|
|
|
}
|
|
|
|
|
|
// finally, reconstruct the href based on what has been validated.
|
|
|
this.href = this.format();
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
// format a parsed object into a url string
|
|
|
function urlFormat(obj) {
|
|
|
// ensure it's an object, and not a string url.
|
|
|
// If it's an obj, this is a no-op.
|
|
|
// this way, you can call url_format() on strings
|
|
|
// to clean up potentially wonky urls.
|
|
|
if (util.isString(obj)) obj = urlParse(obj);
|
|
|
if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
|
|
|
return obj.format();
|
|
|
}
|
|
|
|
|
|
Url.prototype.format = function() {
|
|
|
var auth = this.auth || '';
|
|
|
if (auth) {
|
|
|
auth = encodeURIComponent(auth);
|
|
|
auth = auth.replace(/%3A/i, ':');
|
|
|
auth += '@';
|
|
|
}
|
|
|
|
|
|
var protocol = this.protocol || '',
|
|
|
pathname = this.pathname || '',
|
|
|
hash = this.hash || '',
|
|
|
host = false,
|
|
|
query = '';
|
|
|
|
|
|
if (this.host) {
|
|
|
host = auth + this.host;
|
|
|
} else if (this.hostname) {
|
|
|
host = auth + (this.hostname.indexOf(':') === -1 ?
|
|
|
this.hostname :
|
|
|
'[' + this.hostname + ']');
|
|
|
if (this.port) {
|
|
|
host += ':' + this.port;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (this.query &&
|
|
|
util.isObject(this.query) &&
|
|
|
Object.keys(this.query).length) {
|
|
|
query = querystring.stringify(this.query);
|
|
|
}
|
|
|
|
|
|
var search = this.search || (query && ('?' + query)) || '';
|
|
|
|
|
|
if (protocol && protocol.substr(-1) !== ':') protocol += ':';
|
|
|
|
|
|
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
|
|
|
// unless they had them to begin with.
|
|
|
if (this.slashes ||
|
|
|
(!protocol || slashedProtocol[protocol]) && host !== false) {
|
|
|
host = '//' + (host || '');
|
|
|
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
|
|
|
} else if (!host) {
|
|
|
host = '';
|
|
|
}
|
|
|
|
|
|
if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
|
|
|
if (search && search.charAt(0) !== '?') search = '?' + search;
|
|
|
|
|
|
pathname = pathname.replace(/[?#]/g, function(match) {
|
|
|
return encodeURIComponent(match);
|
|
|
});
|
|
|
search = search.replace('#', '%23');
|
|
|
|
|
|
return protocol + host + pathname + search + hash;
|
|
|
};
|
|
|
|
|
|
function urlResolve(source, relative) {
|
|
|
return urlParse(source, false, true).resolve(relative);
|
|
|
}
|
|
|
|
|
|
Url.prototype.resolve = function(relative) {
|
|
|
return this.resolveObject(urlParse(relative, false, true)).format();
|
|
|
};
|
|
|
|
|
|
function urlResolveObject(source, relative) {
|
|
|
if (!source) return relative;
|
|
|
return urlParse(source, false, true).resolveObject(relative);
|
|
|
}
|
|
|
|
|
|
Url.prototype.resolveObject = function(relative) {
|
|
|
if (util.isString(relative)) {
|
|
|
var rel = new Url();
|
|
|
rel.parse(relative, false, true);
|
|
|
relative = rel;
|
|
|
}
|
|
|
|
|
|
var result = new Url();
|
|
|
var tkeys = Object.keys(this);
|
|
|
for (var tk = 0; tk < tkeys.length; tk++) {
|
|
|
var tkey = tkeys[tk];
|
|
|
result[tkey] = this[tkey];
|
|
|
}
|
|
|
|
|
|
// hash is always overridden, no matter what.
|
|
|
// even href="" will remove it.
|
|
|
result.hash = relative.hash;
|
|
|
|
|
|
// if the relative url is empty, then there's nothing left to do here.
|
|
|
if (relative.href === '') {
|
|
|
result.href = result.format();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
// hrefs like //foo/bar always cut to the protocol.
|
|
|
if (relative.slashes && !relative.protocol) {
|
|
|
// take everything except the protocol from relative
|
|
|
var rkeys = Object.keys(relative);
|
|
|
for (var rk = 0; rk < rkeys.length; rk++) {
|
|
|
var rkey = rkeys[rk];
|
|
|
if (rkey !== 'protocol')
|
|
|
result[rkey] = relative[rkey];
|
|
|
}
|
|
|
|
|
|
//urlParse appends trailing / to urls like http://www.example.com
|
|
|
if (slashedProtocol[result.protocol] &&
|
|
|
result.hostname && !result.pathname) {
|
|
|
result.path = result.pathname = '/';
|
|
|
}
|
|
|
|
|
|
result.href = result.format();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
if (relative.protocol && relative.protocol !== result.protocol) {
|
|
|
// if it's a known url protocol, then changing
|
|
|
// the protocol does weird things
|
|
|
// first, if it's not file:, then we MUST have a host,
|
|
|
// and if there was a path
|
|
|
// to begin with, then we MUST have a path.
|
|
|
// if it is file:, then the host is dropped,
|
|
|
// because that's known to be hostless.
|
|
|
// anything else is assumed to be absolute.
|
|
|
if (!slashedProtocol[relative.protocol]) {
|
|
|
var keys = Object.keys(relative);
|
|
|
for (var v = 0; v < keys.length; v++) {
|
|
|
var k = keys[v];
|
|
|
result[k] = relative[k];
|
|
|
}
|
|
|
result.href = result.format();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
result.protocol = relative.protocol;
|
|
|
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
|
|
var relPath = (relative.pathname || '').split('/');
|
|
|
while (relPath.length && !(relative.host = relPath.shift()));
|
|
|
if (!relative.host) relative.host = '';
|
|
|
if (!relative.hostname) relative.hostname = '';
|
|
|
if (relPath[0] !== '') relPath.unshift('');
|
|
|
if (relPath.length < 2) relPath.unshift('');
|
|
|
result.pathname = relPath.join('/');
|
|
|
} else {
|
|
|
result.pathname = relative.pathname;
|
|
|
}
|
|
|
result.search = relative.search;
|
|
|
result.query = relative.query;
|
|
|
result.host = relative.host || '';
|
|
|
result.auth = relative.auth;
|
|
|
result.hostname = relative.hostname || relative.host;
|
|
|
result.port = relative.port;
|
|
|
// to support http.request
|
|
|
if (result.pathname || result.search) {
|
|
|
var p = result.pathname || '';
|
|
|
var s = result.search || '';
|
|
|
result.path = p + s;
|
|
|
}
|
|
|
result.slashes = result.slashes || relative.slashes;
|
|
|
result.href = result.format();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
|
|
|
isRelAbs = (
|
|
|
relative.host ||
|
|
|
relative.pathname && relative.pathname.charAt(0) === '/'
|
|
|
),
|
|
|
mustEndAbs = (isRelAbs || isSourceAbs ||
|
|
|
(result.host && relative.pathname)),
|
|
|
removeAllDots = mustEndAbs,
|
|
|
srcPath = result.pathname && result.pathname.split('/') || [],
|
|
|
relPath = relative.pathname && relative.pathname.split('/') || [],
|
|
|
psychotic = result.protocol && !slashedProtocol[result.protocol];
|
|
|
|
|
|
// if the url is a non-slashed url, then relative
|
|
|
// links like ../.. should be able
|
|
|
// to crawl up to the hostname, as well. This is strange.
|
|
|
// result.protocol has already been set by now.
|
|
|
// Later on, put the first path part into the host field.
|
|
|
if (psychotic) {
|
|
|
result.hostname = '';
|
|
|
result.port = null;
|
|
|
if (result.host) {
|
|
|
if (srcPath[0] === '') srcPath[0] = result.host;
|
|
|
else srcPath.unshift(result.host);
|
|
|
}
|
|
|
result.host = '';
|
|
|
if (relative.protocol) {
|
|
|
relative.hostname = null;
|
|
|
relative.port = null;
|
|
|
if (relative.host) {
|
|
|
if (relPath[0] === '') relPath[0] = relative.host;
|
|
|
else relPath.unshift(relative.host);
|
|
|
}
|
|
|
relative.host = null;
|
|
|
}
|
|
|
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
|
|
|
}
|
|
|
|
|
|
if (isRelAbs) {
|
|
|
// it's absolute.
|
|
|
result.host = (relative.host || relative.host === '') ?
|
|
|
relative.host : result.host;
|
|
|
result.hostname = (relative.hostname || relative.hostname === '') ?
|
|
|
relative.hostname : result.hostname;
|
|
|
result.search = relative.search;
|
|
|
result.query = relative.query;
|
|
|
srcPath = relPath;
|
|
|
// fall through to the dot-handling below.
|
|
|
} else if (relPath.length) {
|
|
|
// it's relative
|
|
|
// throw away the existing file, and take the new path instead.
|
|
|
if (!srcPath) srcPath = [];
|
|
|
srcPath.pop();
|
|
|
srcPath = srcPath.concat(relPath);
|
|
|
result.search = relative.search;
|
|
|
result.query = relative.query;
|
|
|
} else if (!util.isNullOrUndefined(relative.search)) {
|
|
|
// just pull out the search.
|
|
|
// like href='?foo'.
|
|
|
// Put this after the other two cases because it simplifies the booleans
|
|
|
if (psychotic) {
|
|
|
result.hostname = result.host = srcPath.shift();
|
|
|
//occationaly the auth can get stuck only in host
|
|
|
//this especially happens in cases like
|
|
|
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
|
|
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
|
|
result.host.split('@') : false;
|
|
|
if (authInHost) {
|
|
|
result.auth = authInHost.shift();
|
|
|
result.host = result.hostname = authInHost.shift();
|
|
|
}
|
|
|
}
|
|
|
result.search = relative.search;
|
|
|
result.query = relative.query;
|
|
|
//to support http.request
|
|
|
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
|
|
|
result.path = (result.pathname ? result.pathname : '') +
|
|
|
(result.search ? result.search : '');
|
|
|
}
|
|
|
result.href = result.format();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
if (!srcPath.length) {
|
|
|
// no path at all. easy.
|
|
|
// we've already handled the other stuff above.
|
|
|
result.pathname = null;
|
|
|
//to support http.request
|
|
|
if (result.search) {
|
|
|
result.path = '/' + result.search;
|
|
|
} else {
|
|
|
result.path = null;
|
|
|
}
|
|
|
result.href = result.format();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
// if a url ENDs in . or .., then it must get a trailing slash.
|
|
|
// however, if it ends in anything else non-slashy,
|
|
|
// then it must NOT get a trailing slash.
|
|
|
var last = srcPath.slice(-1)[0];
|
|
|
var hasTrailingSlash = (
|
|
|
(result.host || relative.host || srcPath.length > 1) &&
|
|
|
(last === '.' || last === '..') || last === '');
|
|
|
|
|
|
// strip single dots, resolve double dots to parent dir
|
|
|
// if the path tries to go above the root, `up` ends up > 0
|
|
|
var up = 0;
|
|
|
for (var i = srcPath.length; i >= 0; i--) {
|
|
|
last = srcPath[i];
|
|
|
if (last === '.') {
|
|
|
srcPath.splice(i, 1);
|
|
|
} else if (last === '..') {
|
|
|
srcPath.splice(i, 1);
|
|
|
up++;
|
|
|
} else if (up) {
|
|
|
srcPath.splice(i, 1);
|
|
|
up--;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if the path is allowed to go above the root, restore leading ..s
|
|
|
if (!mustEndAbs && !removeAllDots) {
|
|
|
for (; up--; up) {
|
|
|
srcPath.unshift('..');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (mustEndAbs && srcPath[0] !== '' &&
|
|
|
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
|
|
|
srcPath.unshift('');
|
|
|
}
|
|
|
|
|
|
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
|
|
srcPath.push('');
|
|
|
}
|
|
|
|
|
|
var isAbsolute = srcPath[0] === '' ||
|
|
|
(srcPath[0] && srcPath[0].charAt(0) === '/');
|
|
|
|
|
|
// put the host back
|
|
|
if (psychotic) {
|
|
|
result.hostname = result.host = isAbsolute ? '' :
|
|
|
srcPath.length ? srcPath.shift() : '';
|
|
|
//occationaly the auth can get stuck only in host
|
|
|
//this especially happens in cases like
|
|
|
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
|
|
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
|
|
result.host.split('@') : false;
|
|
|
if (authInHost) {
|
|
|
result.auth = authInHost.shift();
|
|
|
result.host = result.hostname = authInHost.shift();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
mustEndAbs = mustEndAbs || (result.host && srcPath.length);
|
|
|
|
|
|
if (mustEndAbs && !isAbsolute) {
|
|
|
srcPath.unshift('');
|
|
|
}
|
|
|
|
|
|
if (!srcPath.length) {
|
|
|
result.pathname = null;
|
|
|
result.path = null;
|
|
|
} else {
|
|
|
result.pathname = srcPath.join('/');
|
|
|
}
|
|
|
|
|
|
//to support request.http
|
|
|
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
|
|
|
result.path = (result.pathname ? result.pathname : '') +
|
|
|
(result.search ? result.search : '');
|
|
|
}
|
|
|
result.auth = relative.auth || result.auth;
|
|
|
result.slashes = result.slashes || relative.slashes;
|
|
|
result.href = result.format();
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
Url.prototype.parseHost = function() {
|
|
|
var host = this.host;
|
|
|
var port = portPattern.exec(host);
|
|
|
if (port) {
|
|
|
port = port[0];
|
|
|
if (port !== ':') {
|
|
|
this.port = port.substr(1);
|
|
|
}
|
|
|
host = host.substr(0, host.length - port.length);
|
|
|
}
|
|
|
if (host) this.hostname = host;
|
|
|
};
|
|
|
|
|
|
},{"./util":239,"punycode":209,"querystring":212}],239:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
module.exports = {
|
|
|
isString: function(arg) {
|
|
|
return typeof(arg) === 'string';
|
|
|
},
|
|
|
isObject: function(arg) {
|
|
|
return typeof(arg) === 'object' && arg !== null;
|
|
|
},
|
|
|
isNull: function(arg) {
|
|
|
return arg === null;
|
|
|
},
|
|
|
isNullOrUndefined: function(arg) {
|
|
|
return arg == null;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
},{}],240:[function(require,module,exports){
|
|
|
(function (global){
|
|
|
|
|
|
/**
|
|
|
* Module exports.
|
|
|
*/
|
|
|
|
|
|
module.exports = deprecate;
|
|
|
|
|
|
/**
|
|
|
* Mark that a method should not be used.
|
|
|
* Returns a modified function which warns once by default.
|
|
|
*
|
|
|
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
|
|
|
*
|
|
|
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
|
|
|
* will throw an Error when invoked.
|
|
|
*
|
|
|
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
|
|
|
* will invoke `console.trace()` instead of `console.error()`.
|
|
|
*
|
|
|
* @param {Function} fn - the function to deprecate
|
|
|
* @param {String} msg - the string to print to the console when `fn` is invoked
|
|
|
* @returns {Function} a new "deprecated" version of `fn`
|
|
|
* @api public
|
|
|
*/
|
|
|
|
|
|
function deprecate (fn, msg) {
|
|
|
if (config('noDeprecation')) {
|
|
|
return fn;
|
|
|
}
|
|
|
|
|
|
var warned = false;
|
|
|
function deprecated() {
|
|
|
if (!warned) {
|
|
|
if (config('throwDeprecation')) {
|
|
|
throw new Error(msg);
|
|
|
} else if (config('traceDeprecation')) {
|
|
|
console.trace(msg);
|
|
|
} else {
|
|
|
console.warn(msg);
|
|
|
}
|
|
|
warned = true;
|
|
|
}
|
|
|
return fn.apply(this, arguments);
|
|
|
}
|
|
|
|
|
|
return deprecated;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Checks `localStorage` for boolean values for the given `name`.
|
|
|
*
|
|
|
* @param {String} name
|
|
|
* @returns {Boolean}
|
|
|
* @api private
|
|
|
*/
|
|
|
|
|
|
function config (name) {
|
|
|
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
|
|
|
try {
|
|
|
if (!global.localStorage) return false;
|
|
|
} catch (_) {
|
|
|
return false;
|
|
|
}
|
|
|
var val = global.localStorage[name];
|
|
|
if (null == val) return false;
|
|
|
return String(val).toLowerCase() === 'true';
|
|
|
}
|
|
|
|
|
|
}).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{}],241:[function(require,module,exports){
|
|
|
if (typeof Object.create === 'function') {
|
|
|
// implementation from standard node.js 'util' module
|
|
|
module.exports = function inherits(ctor, superCtor) {
|
|
|
ctor.super_ = superCtor
|
|
|
ctor.prototype = Object.create(superCtor.prototype, {
|
|
|
constructor: {
|
|
|
value: ctor,
|
|
|
enumerable: false,
|
|
|
writable: true,
|
|
|
configurable: true
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
} else {
|
|
|
// old school shim for old browsers
|
|
|
module.exports = function inherits(ctor, superCtor) {
|
|
|
ctor.super_ = superCtor
|
|
|
var TempCtor = function () {}
|
|
|
TempCtor.prototype = superCtor.prototype
|
|
|
ctor.prototype = new TempCtor()
|
|
|
ctor.prototype.constructor = ctor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},{}],242:[function(require,module,exports){
|
|
|
module.exports = function isBuffer(arg) {
|
|
|
return arg && typeof arg === 'object'
|
|
|
&& typeof arg.copy === 'function'
|
|
|
&& typeof arg.fill === 'function'
|
|
|
&& typeof arg.readUInt8 === 'function';
|
|
|
}
|
|
|
},{}],243:[function(require,module,exports){
|
|
|
(function (process,global){
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
// copy of this software and associated documentation files (the
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
// following conditions:
|
|
|
//
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
//
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
var formatRegExp = /%[sdj%]/g;
|
|
|
exports.format = function(f) {
|
|
|
if (!isString(f)) {
|
|
|
var objects = [];
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
|
objects.push(inspect(arguments[i]));
|
|
|
}
|
|
|
return objects.join(' ');
|
|
|
}
|
|
|
|
|
|
var i = 1;
|
|
|
var args = arguments;
|
|
|
var len = args.length;
|
|
|
var str = String(f).replace(formatRegExp, function(x) {
|
|
|
if (x === '%%') return '%';
|
|
|
if (i >= len) return x;
|
|
|
switch (x) {
|
|
|
case '%s': return String(args[i++]);
|
|
|
case '%d': return Number(args[i++]);
|
|
|
case '%j':
|
|
|
try {
|
|
|
return JSON.stringify(args[i++]);
|
|
|
} catch (_) {
|
|
|
return '[Circular]';
|
|
|
}
|
|
|
default:
|
|
|
return x;
|
|
|
}
|
|
|
});
|
|
|
for (var x = args[i]; i < len; x = args[++i]) {
|
|
|
if (isNull(x) || !isObject(x)) {
|
|
|
str += ' ' + x;
|
|
|
} else {
|
|
|
str += ' ' + inspect(x);
|
|
|
}
|
|
|
}
|
|
|
return str;
|
|
|
};
|
|
|
|
|
|
|
|
|
// Mark that a method should not be used.
|
|
|
// Returns a modified function which warns once by default.
|
|
|
// If --no-deprecation is set, then it is a no-op.
|
|
|
exports.deprecate = function(fn, msg) {
|
|
|
// Allow for deprecating things in the process of starting up.
|
|
|
if (isUndefined(global.process)) {
|
|
|
return function() {
|
|
|
return exports.deprecate(fn, msg).apply(this, arguments);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
if (process.noDeprecation === true) {
|
|
|
return fn;
|
|
|
}
|
|
|
|
|
|
var warned = false;
|
|
|
function deprecated() {
|
|
|
if (!warned) {
|
|
|
if (process.throwDeprecation) {
|
|
|
throw new Error(msg);
|
|
|
} else if (process.traceDeprecation) {
|
|
|
console.trace(msg);
|
|
|
} else {
|
|
|
console.error(msg);
|
|
|
}
|
|
|
warned = true;
|
|
|
}
|
|
|
return fn.apply(this, arguments);
|
|
|
}
|
|
|
|
|
|
return deprecated;
|
|
|
};
|
|
|
|
|
|
|
|
|
var debugs = {};
|
|
|
var debugEnviron;
|
|
|
exports.debuglog = function(set) {
|
|
|
if (isUndefined(debugEnviron))
|
|
|
debugEnviron = process.env.NODE_DEBUG || '';
|
|
|
set = set.toUpperCase();
|
|
|
if (!debugs[set]) {
|
|
|
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
|
|
var pid = process.pid;
|
|
|
debugs[set] = function() {
|
|
|
var msg = exports.format.apply(exports, arguments);
|
|
|
console.error('%s %d: %s', set, pid, msg);
|
|
|
};
|
|
|
} else {
|
|
|
debugs[set] = function() {};
|
|
|
}
|
|
|
}
|
|
|
return debugs[set];
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Echos the value of a value. Trys to print the value out
|
|
|
* in the best way possible given the different types.
|
|
|
*
|
|
|
* @param {Object} obj The object to print out.
|
|
|
* @param {Object} opts Optional options object that alters the output.
|
|
|
*/
|
|
|
/* legacy: obj, showHidden, depth, colors*/
|
|
|
function inspect(obj, opts) {
|
|
|
// default options
|
|
|
var ctx = {
|
|
|
seen: [],
|
|
|
stylize: stylizeNoColor
|
|
|
};
|
|
|
// legacy...
|
|
|
if (arguments.length >= 3) ctx.depth = arguments[2];
|
|
|
if (arguments.length >= 4) ctx.colors = arguments[3];
|
|
|
if (isBoolean(opts)) {
|
|
|
// legacy...
|
|
|
ctx.showHidden = opts;
|
|
|
} else if (opts) {
|
|
|
// got an "options" object
|
|
|
exports._extend(ctx, opts);
|
|
|
}
|
|
|
// set default options
|
|
|
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
|
|
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
|
|
if (isUndefined(ctx.colors)) ctx.colors = false;
|
|
|
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
|
|
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
|
|
return formatValue(ctx, obj, ctx.depth);
|
|
|
}
|
|
|
exports.inspect = inspect;
|
|
|
|
|
|
|
|
|
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
|
|
inspect.colors = {
|
|
|
'bold' : [1, 22],
|
|
|
'italic' : [3, 23],
|
|
|
'underline' : [4, 24],
|
|
|
'inverse' : [7, 27],
|
|
|
'white' : [37, 39],
|
|
|
'grey' : [90, 39],
|
|
|
'black' : [30, 39],
|
|
|
'blue' : [34, 39],
|
|
|
'cyan' : [36, 39],
|
|
|
'green' : [32, 39],
|
|
|
'magenta' : [35, 39],
|
|
|
'red' : [31, 39],
|
|
|
'yellow' : [33, 39]
|
|
|
};
|
|
|
|
|
|
// Don't use 'blue' not visible on cmd.exe
|
|
|
inspect.styles = {
|
|
|
'special': 'cyan',
|
|
|
'number': 'yellow',
|
|
|
'boolean': 'yellow',
|
|
|
'undefined': 'grey',
|
|
|
'null': 'bold',
|
|
|
'string': 'green',
|
|
|
'date': 'magenta',
|
|
|
// "name": intentionally not styling
|
|
|
'regexp': 'red'
|
|
|
};
|
|
|
|
|
|
|
|
|
function stylizeWithColor(str, styleType) {
|
|
|
var style = inspect.styles[styleType];
|
|
|
|
|
|
if (style) {
|
|
|
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
|
|
'\u001b[' + inspect.colors[style][1] + 'm';
|
|
|
} else {
|
|
|
return str;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
function stylizeNoColor(str, styleType) {
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
|
|
|
function arrayToHash(array) {
|
|
|
var hash = {};
|
|
|
|
|
|
array.forEach(function(val, idx) {
|
|
|
hash[val] = true;
|
|
|
});
|
|
|
|
|
|
return hash;
|
|
|
}
|
|
|
|
|
|
|
|
|
function formatValue(ctx, value, recurseTimes) {
|
|
|
// Provide a hook for user-specified inspect functions.
|
|
|
// Check that value is an object with an inspect function on it
|
|
|
if (ctx.customInspect &&
|
|
|
value &&
|
|
|
isFunction(value.inspect) &&
|
|
|
// Filter out the util module, it's inspect function is special
|
|
|
value.inspect !== exports.inspect &&
|
|
|
// Also filter out any prototype objects using the circular check.
|
|
|
!(value.constructor && value.constructor.prototype === value)) {
|
|
|
var ret = value.inspect(recurseTimes, ctx);
|
|
|
if (!isString(ret)) {
|
|
|
ret = formatValue(ctx, ret, recurseTimes);
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
// Primitive types cannot have properties
|
|
|
var primitive = formatPrimitive(ctx, value);
|
|
|
if (primitive) {
|
|
|
return primitive;
|
|
|
}
|
|
|
|
|
|
// Look up the keys of the object.
|
|
|
var keys = Object.keys(value);
|
|
|
var visibleKeys = arrayToHash(keys);
|
|
|
|
|
|
if (ctx.showHidden) {
|
|
|
keys = Object.getOwnPropertyNames(value);
|
|
|
}
|
|
|
|
|
|
// IE doesn't make error fields non-enumerable
|
|
|
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
|
|
|
if (isError(value)
|
|
|
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
|
|
return formatError(value);
|
|
|
}
|
|
|
|
|
|
// Some type of object without properties can be shortcutted.
|
|
|
if (keys.length === 0) {
|
|
|
if (isFunction(value)) {
|
|
|
var name = value.name ? ': ' + value.name : '';
|
|
|
return ctx.stylize('[Function' + name + ']', 'special');
|
|
|
}
|
|
|
if (isRegExp(value)) {
|
|
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
|
}
|
|
|
if (isDate(value)) {
|
|
|
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
|
|
}
|
|
|
if (isError(value)) {
|
|
|
return formatError(value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var base = '', array = false, braces = ['{', '}'];
|
|
|
|
|
|
// Make Array say that they are Array
|
|
|
if (isArray(value)) {
|
|
|
array = true;
|
|
|
braces = ['[', ']'];
|
|
|
}
|
|
|
|
|
|
// Make functions say that they are functions
|
|
|
if (isFunction(value)) {
|
|
|
var n = value.name ? ': ' + value.name : '';
|
|
|
base = ' [Function' + n + ']';
|
|
|
}
|
|
|
|
|
|
// Make RegExps say that they are RegExps
|
|
|
if (isRegExp(value)) {
|
|
|
base = ' ' + RegExp.prototype.toString.call(value);
|
|
|
}
|
|
|
|
|
|
// Make dates with properties first say the date
|
|
|
if (isDate(value)) {
|
|
|
base = ' ' + Date.prototype.toUTCString.call(value);
|
|
|
}
|
|
|
|
|
|
// Make error with message first say the error
|
|
|
if (isError(value)) {
|
|
|
base = ' ' + formatError(value);
|
|
|
}
|
|
|
|
|
|
if (keys.length === 0 && (!array || value.length == 0)) {
|
|
|
return braces[0] + base + braces[1];
|
|
|
}
|
|
|
|
|
|
if (recurseTimes < 0) {
|
|
|
if (isRegExp(value)) {
|
|
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
|
} else {
|
|
|
return ctx.stylize('[Object]', 'special');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ctx.seen.push(value);
|
|
|
|
|
|
var output;
|
|
|
if (array) {
|
|
|
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
|
} else {
|
|
|
output = keys.map(function(key) {
|
|
|
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
ctx.seen.pop();
|
|
|
|
|
|
return reduceToSingleString(output, base, braces);
|
|
|
}
|
|
|
|
|
|
|
|
|
function formatPrimitive(ctx, value) {
|
|
|
if (isUndefined(value))
|
|
|
return ctx.stylize('undefined', 'undefined');
|
|
|
if (isString(value)) {
|
|
|
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
|
|
.replace(/'/g, "\\'")
|
|
|
.replace(/\\"/g, '"') + '\'';
|
|
|
return ctx.stylize(simple, 'string');
|
|
|
}
|
|
|
if (isNumber(value))
|
|
|
return ctx.stylize('' + value, 'number');
|
|
|
if (isBoolean(value))
|
|
|
return ctx.stylize('' + value, 'boolean');
|
|
|
// For some reason typeof null is "object", so special case here.
|
|
|
if (isNull(value))
|
|
|
return ctx.stylize('null', 'null');
|
|
|
}
|
|
|
|
|
|
|
|
|
function formatError(value) {
|
|
|
return '[' + Error.prototype.toString.call(value) + ']';
|
|
|
}
|
|
|
|
|
|
|
|
|
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
|
var output = [];
|
|
|
for (var i = 0, l = value.length; i < l; ++i) {
|
|
|
if (hasOwnProperty(value, String(i))) {
|
|
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
|
String(i), true));
|
|
|
} else {
|
|
|
output.push('');
|
|
|
}
|
|
|
}
|
|
|
keys.forEach(function(key) {
|
|
|
if (!key.match(/^\d+$/)) {
|
|
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
|
key, true));
|
|
|
}
|
|
|
});
|
|
|
return output;
|
|
|
}
|
|
|
|
|
|
|
|
|
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
|
var name, str, desc;
|
|
|
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
|
|
if (desc.get) {
|
|
|
if (desc.set) {
|
|
|
str = ctx.stylize('[Getter/Setter]', 'special');
|
|
|
} else {
|
|
|
str = ctx.stylize('[Getter]', 'special');
|
|
|
}
|
|
|
} else {
|
|
|
if (desc.set) {
|
|
|
str = ctx.stylize('[Setter]', 'special');
|
|
|
}
|
|
|
}
|
|
|
if (!hasOwnProperty(visibleKeys, key)) {
|
|
|
name = '[' + key + ']';
|
|
|
}
|
|
|
if (!str) {
|
|
|
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
|
if (isNull(recurseTimes)) {
|
|
|
str = formatValue(ctx, desc.value, null);
|
|
|
} else {
|
|
|
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
|
}
|
|
|
if (str.indexOf('\n') > -1) {
|
|
|
if (array) {
|
|
|
str = str.split('\n').map(function(line) {
|
|
|
return ' ' + line;
|
|
|
}).join('\n').substr(2);
|
|
|
} else {
|
|
|
str = '\n' + str.split('\n').map(function(line) {
|
|
|
return ' ' + line;
|
|
|
}).join('\n');
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
str = ctx.stylize('[Circular]', 'special');
|
|
|
}
|
|
|
}
|
|
|
if (isUndefined(name)) {
|
|
|
if (array && key.match(/^\d+$/)) {
|
|
|
return str;
|
|
|
}
|
|
|
name = JSON.stringify('' + key);
|
|
|
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
|
name = name.substr(1, name.length - 2);
|
|
|
name = ctx.stylize(name, 'name');
|
|
|
} else {
|
|
|
name = name.replace(/'/g, "\\'")
|
|
|
.replace(/\\"/g, '"')
|
|
|
.replace(/(^"|"$)/g, "'");
|
|
|
name = ctx.stylize(name, 'string');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return name + ': ' + str;
|
|
|
}
|
|
|
|
|
|
|
|
|
function reduceToSingleString(output, base, braces) {
|
|
|
var numLinesEst = 0;
|
|
|
var length = output.reduce(function(prev, cur) {
|
|
|
numLinesEst++;
|
|
|
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
|
|
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
|
|
}, 0);
|
|
|
|
|
|
if (length > 60) {
|
|
|
return braces[0] +
|
|
|
(base === '' ? '' : base + '\n ') +
|
|
|
' ' +
|
|
|
output.join(',\n ') +
|
|
|
' ' +
|
|
|
braces[1];
|
|
|
}
|
|
|
|
|
|
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
|
|
}
|
|
|
|
|
|
|
|
|
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
|
// because it is fragile and can be easily faked with `Object.create()`.
|
|
|
function isArray(ar) {
|
|
|
return Array.isArray(ar);
|
|
|
}
|
|
|
exports.isArray = isArray;
|
|
|
|
|
|
function isBoolean(arg) {
|
|
|
return typeof arg === 'boolean';
|
|
|
}
|
|
|
exports.isBoolean = isBoolean;
|
|
|
|
|
|
function isNull(arg) {
|
|
|
return arg === null;
|
|
|
}
|
|
|
exports.isNull = isNull;
|
|
|
|
|
|
function isNullOrUndefined(arg) {
|
|
|
return arg == null;
|
|
|
}
|
|
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
|
|
|
|
function isNumber(arg) {
|
|
|
return typeof arg === 'number';
|
|
|
}
|
|
|
exports.isNumber = isNumber;
|
|
|
|
|
|
function isString(arg) {
|
|
|
return typeof arg === 'string';
|
|
|
}
|
|
|
exports.isString = isString;
|
|
|
|
|
|
function isSymbol(arg) {
|
|
|
return typeof arg === 'symbol';
|
|
|
}
|
|
|
exports.isSymbol = isSymbol;
|
|
|
|
|
|
function isUndefined(arg) {
|
|
|
return arg === void 0;
|
|
|
}
|
|
|
exports.isUndefined = isUndefined;
|
|
|
|
|
|
function isRegExp(re) {
|
|
|
return isObject(re) && objectToString(re) === '[object RegExp]';
|
|
|
}
|
|
|
exports.isRegExp = isRegExp;
|
|
|
|
|
|
function isObject(arg) {
|
|
|
return typeof arg === 'object' && arg !== null;
|
|
|
}
|
|
|
exports.isObject = isObject;
|
|
|
|
|
|
function isDate(d) {
|
|
|
return isObject(d) && objectToString(d) === '[object Date]';
|
|
|
}
|
|
|
exports.isDate = isDate;
|
|
|
|
|
|
function isError(e) {
|
|
|
return isObject(e) &&
|
|
|
(objectToString(e) === '[object Error]' || e instanceof Error);
|
|
|
}
|
|
|
exports.isError = isError;
|
|
|
|
|
|
function isFunction(arg) {
|
|
|
return typeof arg === 'function';
|
|
|
}
|
|
|
exports.isFunction = isFunction;
|
|
|
|
|
|
function isPrimitive(arg) {
|
|
|
return arg === null ||
|
|
|
typeof arg === 'boolean' ||
|
|
|
typeof arg === 'number' ||
|
|
|
typeof arg === 'string' ||
|
|
|
typeof arg === 'symbol' || // ES6 symbol
|
|
|
typeof arg === 'undefined';
|
|
|
}
|
|
|
exports.isPrimitive = isPrimitive;
|
|
|
|
|
|
exports.isBuffer = require('./support/isBuffer');
|
|
|
|
|
|
function objectToString(o) {
|
|
|
return Object.prototype.toString.call(o);
|
|
|
}
|
|
|
|
|
|
|
|
|
function pad(n) {
|
|
|
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
|
|
}
|
|
|
|
|
|
|
|
|
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
|
|
'Oct', 'Nov', 'Dec'];
|
|
|
|
|
|
// 26 Feb 16:19:34
|
|
|
function timestamp() {
|
|
|
var d = new Date();
|
|
|
var time = [pad(d.getHours()),
|
|
|
pad(d.getMinutes()),
|
|
|
pad(d.getSeconds())].join(':');
|
|
|
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
|
|
}
|
|
|
|
|
|
|
|
|
// log is just a thin wrapper to console.log that prepends a timestamp
|
|
|
exports.log = function() {
|
|
|
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Inherit the prototype methods from one constructor into another.
|
|
|
*
|
|
|
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
|
|
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
|
|
* during bootstrapping this function needs to be rewritten using some native
|
|
|
* functions as prototype setup using normal JavaScript does not work as
|
|
|
* expected during bootstrapping (see mirror.js in r114903).
|
|
|
*
|
|
|
* @param {function} ctor Constructor function which needs to inherit the
|
|
|
* prototype.
|
|
|
* @param {function} superCtor Constructor function to inherit prototype from.
|
|
|
*/
|
|
|
exports.inherits = require('inherits');
|
|
|
|
|
|
exports._extend = function(origin, add) {
|
|
|
// Don't do anything if add isn't an object
|
|
|
if (!add || !isObject(add)) return origin;
|
|
|
|
|
|
var keys = Object.keys(add);
|
|
|
var i = keys.length;
|
|
|
while (i--) {
|
|
|
origin[keys[i]] = add[keys[i]];
|
|
|
}
|
|
|
return origin;
|
|
|
};
|
|
|
|
|
|
function hasOwnProperty(obj, prop) {
|
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
|
}
|
|
|
|
|
|
}).call(this,require('_process'),typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
},{"./support/isBuffer":242,"_process":208,"inherits":241}],244:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
"use strict";
|
|
|
|
|
|
exports.stripBOM = function (str) {
|
|
|
if (str[0] === "\uFEFF") {
|
|
|
return str.substring(1);
|
|
|
} else {
|
|
|
return str;
|
|
|
}
|
|
|
};
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],245:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
"use strict";
|
|
|
|
|
|
var builder,
|
|
|
defaults,
|
|
|
escapeCDATA,
|
|
|
requiresCDATA,
|
|
|
wrapCDATA,
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
builder = require('xmlbuilder');
|
|
|
|
|
|
defaults = require('./defaults').defaults;
|
|
|
|
|
|
requiresCDATA = function requiresCDATA(entry) {
|
|
|
return typeof entry === "string" && (entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0);
|
|
|
};
|
|
|
|
|
|
wrapCDATA = function wrapCDATA(entry) {
|
|
|
return "<![CDATA[" + escapeCDATA(entry) + "]]>";
|
|
|
};
|
|
|
|
|
|
escapeCDATA = function escapeCDATA(entry) {
|
|
|
return entry.replace(']]>', ']]]]><![CDATA[>');
|
|
|
};
|
|
|
|
|
|
exports.Builder = function () {
|
|
|
function Builder(opts) {
|
|
|
var key, ref, value;
|
|
|
this.options = {};
|
|
|
ref = defaults["0.2"];
|
|
|
for (key in ref) {
|
|
|
if (!hasProp.call(ref, key)) continue;
|
|
|
value = ref[key];
|
|
|
this.options[key] = value;
|
|
|
}
|
|
|
for (key in opts) {
|
|
|
if (!hasProp.call(opts, key)) continue;
|
|
|
value = opts[key];
|
|
|
this.options[key] = value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Builder.prototype.buildObject = function (rootObj) {
|
|
|
var attrkey, charkey, render, rootElement, rootName;
|
|
|
attrkey = this.options.attrkey;
|
|
|
charkey = this.options.charkey;
|
|
|
if ((0, _keys2.default)(rootObj).length === 1 && this.options.rootName === defaults['0.2'].rootName) {
|
|
|
rootName = (0, _keys2.default)(rootObj)[0];
|
|
|
rootObj = rootObj[rootName];
|
|
|
} else {
|
|
|
rootName = this.options.rootName;
|
|
|
}
|
|
|
render = function (_this) {
|
|
|
return function (element, obj) {
|
|
|
var attr, child, entry, index, key, value;
|
|
|
if ((typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
|
|
|
if (_this.options.cdata && requiresCDATA(obj)) {
|
|
|
element.raw(wrapCDATA(obj));
|
|
|
} else {
|
|
|
element.txt(obj);
|
|
|
}
|
|
|
} else if (Array.isArray(obj)) {
|
|
|
for (index in obj) {
|
|
|
if (!hasProp.call(obj, index)) continue;
|
|
|
child = obj[index];
|
|
|
for (key in child) {
|
|
|
entry = child[key];
|
|
|
element = render(element.ele(key), entry).up();
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
for (key in obj) {
|
|
|
if (!hasProp.call(obj, key)) continue;
|
|
|
child = obj[key];
|
|
|
if (key === attrkey) {
|
|
|
if ((typeof child === 'undefined' ? 'undefined' : (0, _typeof3.default)(child)) === "object") {
|
|
|
for (attr in child) {
|
|
|
value = child[attr];
|
|
|
element = element.att(attr, value);
|
|
|
}
|
|
|
}
|
|
|
} else if (key === charkey) {
|
|
|
if (_this.options.cdata && requiresCDATA(child)) {
|
|
|
element = element.raw(wrapCDATA(child));
|
|
|
} else {
|
|
|
element = element.txt(child);
|
|
|
}
|
|
|
} else if (Array.isArray(child)) {
|
|
|
for (index in child) {
|
|
|
if (!hasProp.call(child, index)) continue;
|
|
|
entry = child[index];
|
|
|
if (typeof entry === 'string') {
|
|
|
if (_this.options.cdata && requiresCDATA(entry)) {
|
|
|
element = element.ele(key).raw(wrapCDATA(entry)).up();
|
|
|
} else {
|
|
|
element = element.ele(key, entry).up();
|
|
|
}
|
|
|
} else {
|
|
|
element = render(element.ele(key), entry).up();
|
|
|
}
|
|
|
}
|
|
|
} else if ((typeof child === 'undefined' ? 'undefined' : (0, _typeof3.default)(child)) === "object") {
|
|
|
element = render(element.ele(key), child).up();
|
|
|
} else {
|
|
|
if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) {
|
|
|
element = element.ele(key).raw(wrapCDATA(child)).up();
|
|
|
} else {
|
|
|
if (child == null) {
|
|
|
child = '';
|
|
|
}
|
|
|
element = element.ele(key, child.toString()).up();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return element;
|
|
|
};
|
|
|
}(this);
|
|
|
rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
|
|
|
headless: this.options.headless,
|
|
|
allowSurrogateChars: this.options.allowSurrogateChars
|
|
|
});
|
|
|
return render(rootElement, rootObj).end(this.options.renderOpts);
|
|
|
};
|
|
|
|
|
|
return Builder;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./defaults":246,"babel-runtime/core-js/object/keys":60,"babel-runtime/helpers/typeof":67,"xmlbuilder":282}],246:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
exports.defaults = {
|
|
|
"0.1": {
|
|
|
explicitCharkey: false,
|
|
|
trim: true,
|
|
|
normalize: true,
|
|
|
normalizeTags: false,
|
|
|
attrkey: "@",
|
|
|
charkey: "#",
|
|
|
explicitArray: false,
|
|
|
ignoreAttrs: false,
|
|
|
mergeAttrs: false,
|
|
|
explicitRoot: false,
|
|
|
validator: null,
|
|
|
xmlns: false,
|
|
|
explicitChildren: false,
|
|
|
childkey: '@@',
|
|
|
charsAsChildren: false,
|
|
|
includeWhiteChars: false,
|
|
|
async: false,
|
|
|
strict: true,
|
|
|
attrNameProcessors: null,
|
|
|
attrValueProcessors: null,
|
|
|
tagNameProcessors: null,
|
|
|
valueProcessors: null,
|
|
|
emptyTag: ''
|
|
|
},
|
|
|
"0.2": {
|
|
|
explicitCharkey: false,
|
|
|
trim: false,
|
|
|
normalize: false,
|
|
|
normalizeTags: false,
|
|
|
attrkey: "$",
|
|
|
charkey: "_",
|
|
|
explicitArray: true,
|
|
|
ignoreAttrs: false,
|
|
|
mergeAttrs: false,
|
|
|
explicitRoot: true,
|
|
|
validator: null,
|
|
|
xmlns: false,
|
|
|
explicitChildren: false,
|
|
|
preserveChildrenOrder: false,
|
|
|
childkey: '$$',
|
|
|
charsAsChildren: false,
|
|
|
includeWhiteChars: false,
|
|
|
async: false,
|
|
|
strict: true,
|
|
|
attrNameProcessors: null,
|
|
|
attrValueProcessors: null,
|
|
|
tagNameProcessors: null,
|
|
|
valueProcessors: null,
|
|
|
rootName: 'root',
|
|
|
xmldec: {
|
|
|
'version': '1.0',
|
|
|
'encoding': 'UTF-8',
|
|
|
'standalone': true
|
|
|
},
|
|
|
doctype: null,
|
|
|
renderOpts: {
|
|
|
'pretty': true,
|
|
|
'indent': ' ',
|
|
|
'newline': '\n'
|
|
|
},
|
|
|
headless: false,
|
|
|
chunkSize: 10000,
|
|
|
emptyTag: '',
|
|
|
cdata: false
|
|
|
}
|
|
|
};
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],247:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _promise = require('babel-runtime/core-js/promise');
|
|
|
|
|
|
var _promise2 = _interopRequireDefault(_promise);
|
|
|
|
|
|
var _getOwnPropertyNames = require('babel-runtime/core-js/object/get-own-property-names');
|
|
|
|
|
|
var _getOwnPropertyNames2 = _interopRequireDefault(_getOwnPropertyNames);
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
"use strict";
|
|
|
|
|
|
var bom,
|
|
|
defaults,
|
|
|
events,
|
|
|
isEmpty,
|
|
|
processItem,
|
|
|
processors,
|
|
|
sax,
|
|
|
setImmediate,
|
|
|
bind = function bind(fn, me) {
|
|
|
return function () {
|
|
|
return fn.apply(me, arguments);
|
|
|
};
|
|
|
},
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
sax = require('sax');
|
|
|
|
|
|
events = require('events');
|
|
|
|
|
|
bom = require('./bom');
|
|
|
|
|
|
processors = require('./processors');
|
|
|
|
|
|
setImmediate = require('timers').setImmediate;
|
|
|
|
|
|
defaults = require('./defaults').defaults;
|
|
|
|
|
|
isEmpty = function isEmpty(thing) {
|
|
|
return (typeof thing === 'undefined' ? 'undefined' : (0, _typeof3.default)(thing)) === "object" && thing != null && (0, _keys2.default)(thing).length === 0;
|
|
|
};
|
|
|
|
|
|
processItem = function processItem(processors, item, key) {
|
|
|
var i, len, process;
|
|
|
for (i = 0, len = processors.length; i < len; i++) {
|
|
|
process = processors[i];
|
|
|
item = process(item, key);
|
|
|
}
|
|
|
return item;
|
|
|
};
|
|
|
|
|
|
exports.Parser = function (superClass) {
|
|
|
extend(Parser, superClass);
|
|
|
|
|
|
function Parser(opts) {
|
|
|
this.parseStringPromise = bind(this.parseStringPromise, this);
|
|
|
this.parseString = bind(this.parseString, this);
|
|
|
this.reset = bind(this.reset, this);
|
|
|
this.assignOrPush = bind(this.assignOrPush, this);
|
|
|
this.processAsync = bind(this.processAsync, this);
|
|
|
var key, ref, value;
|
|
|
if (!(this instanceof exports.Parser)) {
|
|
|
return new exports.Parser(opts);
|
|
|
}
|
|
|
this.options = {};
|
|
|
ref = defaults["0.2"];
|
|
|
for (key in ref) {
|
|
|
if (!hasProp.call(ref, key)) continue;
|
|
|
value = ref[key];
|
|
|
this.options[key] = value;
|
|
|
}
|
|
|
for (key in opts) {
|
|
|
if (!hasProp.call(opts, key)) continue;
|
|
|
value = opts[key];
|
|
|
this.options[key] = value;
|
|
|
}
|
|
|
if (this.options.xmlns) {
|
|
|
this.options.xmlnskey = this.options.attrkey + "ns";
|
|
|
}
|
|
|
if (this.options.normalizeTags) {
|
|
|
if (!this.options.tagNameProcessors) {
|
|
|
this.options.tagNameProcessors = [];
|
|
|
}
|
|
|
this.options.tagNameProcessors.unshift(processors.normalize);
|
|
|
}
|
|
|
this.reset();
|
|
|
}
|
|
|
|
|
|
Parser.prototype.processAsync = function () {
|
|
|
var chunk, err;
|
|
|
try {
|
|
|
if (this.remaining.length <= this.options.chunkSize) {
|
|
|
chunk = this.remaining;
|
|
|
this.remaining = '';
|
|
|
this.saxParser = this.saxParser.write(chunk);
|
|
|
return this.saxParser.close();
|
|
|
} else {
|
|
|
chunk = this.remaining.substr(0, this.options.chunkSize);
|
|
|
this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
|
|
|
this.saxParser = this.saxParser.write(chunk);
|
|
|
return setImmediate(this.processAsync);
|
|
|
}
|
|
|
} catch (error1) {
|
|
|
err = error1;
|
|
|
if (!this.saxParser.errThrown) {
|
|
|
this.saxParser.errThrown = true;
|
|
|
return this.emit(err);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Parser.prototype.assignOrPush = function (obj, key, newValue) {
|
|
|
if (!(key in obj)) {
|
|
|
if (!this.options.explicitArray) {
|
|
|
return obj[key] = newValue;
|
|
|
} else {
|
|
|
return obj[key] = [newValue];
|
|
|
}
|
|
|
} else {
|
|
|
if (!(obj[key] instanceof Array)) {
|
|
|
obj[key] = [obj[key]];
|
|
|
}
|
|
|
return obj[key].push(newValue);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Parser.prototype.reset = function () {
|
|
|
var attrkey, charkey, ontext, stack;
|
|
|
this.removeAllListeners();
|
|
|
this.saxParser = sax.parser(this.options.strict, {
|
|
|
trim: false,
|
|
|
normalize: false,
|
|
|
xmlns: this.options.xmlns
|
|
|
});
|
|
|
this.saxParser.errThrown = false;
|
|
|
this.saxParser.onerror = function (_this) {
|
|
|
return function (error) {
|
|
|
_this.saxParser.resume();
|
|
|
if (!_this.saxParser.errThrown) {
|
|
|
_this.saxParser.errThrown = true;
|
|
|
return _this.emit("error", error);
|
|
|
}
|
|
|
};
|
|
|
}(this);
|
|
|
this.saxParser.onend = function (_this) {
|
|
|
return function () {
|
|
|
if (!_this.saxParser.ended) {
|
|
|
_this.saxParser.ended = true;
|
|
|
return _this.emit("end", _this.resultObject);
|
|
|
}
|
|
|
};
|
|
|
}(this);
|
|
|
this.saxParser.ended = false;
|
|
|
this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
|
|
|
this.resultObject = null;
|
|
|
stack = [];
|
|
|
attrkey = this.options.attrkey;
|
|
|
charkey = this.options.charkey;
|
|
|
this.saxParser.onopentag = function (_this) {
|
|
|
return function (node) {
|
|
|
var key, newValue, obj, processedKey, ref;
|
|
|
obj = {};
|
|
|
obj[charkey] = "";
|
|
|
if (!_this.options.ignoreAttrs) {
|
|
|
ref = node.attributes;
|
|
|
for (key in ref) {
|
|
|
if (!hasProp.call(ref, key)) continue;
|
|
|
if (!(attrkey in obj) && !_this.options.mergeAttrs) {
|
|
|
obj[attrkey] = {};
|
|
|
}
|
|
|
newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
|
|
|
processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
|
|
|
if (_this.options.mergeAttrs) {
|
|
|
_this.assignOrPush(obj, processedKey, newValue);
|
|
|
} else {
|
|
|
obj[attrkey][processedKey] = newValue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
|
|
|
if (_this.options.xmlns) {
|
|
|
obj[_this.options.xmlnskey] = {
|
|
|
uri: node.uri,
|
|
|
local: node.local
|
|
|
};
|
|
|
}
|
|
|
return stack.push(obj);
|
|
|
};
|
|
|
}(this);
|
|
|
this.saxParser.onclosetag = function (_this) {
|
|
|
return function () {
|
|
|
var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
|
|
|
obj = stack.pop();
|
|
|
nodeName = obj["#name"];
|
|
|
if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
|
|
|
delete obj["#name"];
|
|
|
}
|
|
|
if (obj.cdata === true) {
|
|
|
cdata = obj.cdata;
|
|
|
delete obj.cdata;
|
|
|
}
|
|
|
s = stack[stack.length - 1];
|
|
|
if (obj[charkey].match(/^\s*$/) && !cdata) {
|
|
|
emptyStr = obj[charkey];
|
|
|
delete obj[charkey];
|
|
|
} else {
|
|
|
if (_this.options.trim) {
|
|
|
obj[charkey] = obj[charkey].trim();
|
|
|
}
|
|
|
if (_this.options.normalize) {
|
|
|
obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
|
|
|
}
|
|
|
obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
|
|
|
if ((0, _keys2.default)(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
|
|
|
obj = obj[charkey];
|
|
|
}
|
|
|
}
|
|
|
if (isEmpty(obj)) {
|
|
|
obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
|
|
|
}
|
|
|
if (_this.options.validator != null) {
|
|
|
xpath = "/" + function () {
|
|
|
var i, len, results;
|
|
|
results = [];
|
|
|
for (i = 0, len = stack.length; i < len; i++) {
|
|
|
node = stack[i];
|
|
|
results.push(node["#name"]);
|
|
|
}
|
|
|
return results;
|
|
|
}().concat(nodeName).join("/");
|
|
|
(function () {
|
|
|
var err;
|
|
|
try {
|
|
|
return obj = _this.options.validator(xpath, s && s[nodeName], obj);
|
|
|
} catch (error1) {
|
|
|
err = error1;
|
|
|
return _this.emit("error", err);
|
|
|
}
|
|
|
})();
|
|
|
}
|
|
|
if (_this.options.explicitChildren && !_this.options.mergeAttrs && (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) === 'object') {
|
|
|
if (!_this.options.preserveChildrenOrder) {
|
|
|
node = {};
|
|
|
if (_this.options.attrkey in obj) {
|
|
|
node[_this.options.attrkey] = obj[_this.options.attrkey];
|
|
|
delete obj[_this.options.attrkey];
|
|
|
}
|
|
|
if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
|
|
|
node[_this.options.charkey] = obj[_this.options.charkey];
|
|
|
delete obj[_this.options.charkey];
|
|
|
}
|
|
|
if ((0, _getOwnPropertyNames2.default)(obj).length > 0) {
|
|
|
node[_this.options.childkey] = obj;
|
|
|
}
|
|
|
obj = node;
|
|
|
} else if (s) {
|
|
|
s[_this.options.childkey] = s[_this.options.childkey] || [];
|
|
|
objClone = {};
|
|
|
for (key in obj) {
|
|
|
if (!hasProp.call(obj, key)) continue;
|
|
|
objClone[key] = obj[key];
|
|
|
}
|
|
|
s[_this.options.childkey].push(objClone);
|
|
|
delete obj["#name"];
|
|
|
if ((0, _keys2.default)(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
|
|
|
obj = obj[charkey];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (stack.length > 0) {
|
|
|
return _this.assignOrPush(s, nodeName, obj);
|
|
|
} else {
|
|
|
if (_this.options.explicitRoot) {
|
|
|
old = obj;
|
|
|
obj = {};
|
|
|
obj[nodeName] = old;
|
|
|
}
|
|
|
_this.resultObject = obj;
|
|
|
_this.saxParser.ended = true;
|
|
|
return _this.emit("end", _this.resultObject);
|
|
|
}
|
|
|
};
|
|
|
}(this);
|
|
|
ontext = function (_this) {
|
|
|
return function (text) {
|
|
|
var charChild, s;
|
|
|
s = stack[stack.length - 1];
|
|
|
if (s) {
|
|
|
s[charkey] += text;
|
|
|
if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
|
|
|
s[_this.options.childkey] = s[_this.options.childkey] || [];
|
|
|
charChild = {
|
|
|
'#name': '__text__'
|
|
|
};
|
|
|
charChild[charkey] = text;
|
|
|
if (_this.options.normalize) {
|
|
|
charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
|
|
|
}
|
|
|
s[_this.options.childkey].push(charChild);
|
|
|
}
|
|
|
return s;
|
|
|
}
|
|
|
};
|
|
|
}(this);
|
|
|
this.saxParser.ontext = ontext;
|
|
|
return this.saxParser.oncdata = function (_this) {
|
|
|
return function (text) {
|
|
|
var s;
|
|
|
s = ontext(text);
|
|
|
if (s) {
|
|
|
return s.cdata = true;
|
|
|
}
|
|
|
};
|
|
|
}(this);
|
|
|
};
|
|
|
|
|
|
Parser.prototype.parseString = function (str, cb) {
|
|
|
var err;
|
|
|
if (cb != null && typeof cb === "function") {
|
|
|
this.on("end", function (result) {
|
|
|
this.reset();
|
|
|
return cb(null, result);
|
|
|
});
|
|
|
this.on("error", function (err) {
|
|
|
this.reset();
|
|
|
return cb(err);
|
|
|
});
|
|
|
}
|
|
|
try {
|
|
|
str = str.toString();
|
|
|
if (str.trim() === '') {
|
|
|
this.emit("end", null);
|
|
|
return true;
|
|
|
}
|
|
|
str = bom.stripBOM(str);
|
|
|
if (this.options.async) {
|
|
|
this.remaining = str;
|
|
|
setImmediate(this.processAsync);
|
|
|
return this.saxParser;
|
|
|
}
|
|
|
return this.saxParser.write(str).close();
|
|
|
} catch (error1) {
|
|
|
err = error1;
|
|
|
if (!(this.saxParser.errThrown || this.saxParser.ended)) {
|
|
|
this.emit('error', err);
|
|
|
return this.saxParser.errThrown = true;
|
|
|
} else if (this.saxParser.ended) {
|
|
|
throw err;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Parser.prototype.parseStringPromise = function (str) {
|
|
|
return new _promise2.default(function (_this) {
|
|
|
return function (resolve, reject) {
|
|
|
return _this.parseString(str, function (err, value) {
|
|
|
if (err) {
|
|
|
return reject(err);
|
|
|
} else {
|
|
|
return resolve(value);
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
}(this));
|
|
|
};
|
|
|
|
|
|
return Parser;
|
|
|
}(events);
|
|
|
|
|
|
exports.parseString = function (str, a, b) {
|
|
|
var cb, options, parser;
|
|
|
if (b != null) {
|
|
|
if (typeof b === 'function') {
|
|
|
cb = b;
|
|
|
}
|
|
|
if ((typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a)) === 'object') {
|
|
|
options = a;
|
|
|
}
|
|
|
} else {
|
|
|
if (typeof a === 'function') {
|
|
|
cb = a;
|
|
|
}
|
|
|
options = {};
|
|
|
}
|
|
|
parser = new exports.Parser(options);
|
|
|
return parser.parseString(str, cb);
|
|
|
};
|
|
|
|
|
|
exports.parseStringPromise = function (str, a) {
|
|
|
var options, parser;
|
|
|
if ((typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a)) === 'object') {
|
|
|
options = a;
|
|
|
}
|
|
|
parser = new exports.Parser(options);
|
|
|
return parser.parseStringPromise(str);
|
|
|
};
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./bom":244,"./defaults":246,"./processors":248,"babel-runtime/core-js/object/get-own-property-names":58,"babel-runtime/core-js/object/keys":60,"babel-runtime/core-js/promise":61,"babel-runtime/helpers/typeof":67,"events":192,"sax":229,"timers":236}],248:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
"use strict";
|
|
|
|
|
|
var prefixMatch;
|
|
|
|
|
|
prefixMatch = new RegExp(/(?!xmlns)^.*:/);
|
|
|
|
|
|
exports.normalize = function (str) {
|
|
|
return str.toLowerCase();
|
|
|
};
|
|
|
|
|
|
exports.firstCharLowerCase = function (str) {
|
|
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
|
};
|
|
|
|
|
|
exports.stripPrefix = function (str) {
|
|
|
return str.replace(prefixMatch, '');
|
|
|
};
|
|
|
|
|
|
exports.parseNumbers = function (str) {
|
|
|
if (!isNaN(str)) {
|
|
|
str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
|
|
|
}
|
|
|
return str;
|
|
|
};
|
|
|
|
|
|
exports.parseBooleans = function (str) {
|
|
|
if (/^(?:true|false)$/i.test(str)) {
|
|
|
str = str.toLowerCase() === 'true';
|
|
|
}
|
|
|
return str;
|
|
|
};
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],249:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
"use strict";
|
|
|
|
|
|
var builder,
|
|
|
defaults,
|
|
|
parser,
|
|
|
processors,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
defaults = require('./defaults');
|
|
|
|
|
|
builder = require('./builder');
|
|
|
|
|
|
parser = require('./parser');
|
|
|
|
|
|
processors = require('./processors');
|
|
|
|
|
|
exports.defaults = defaults.defaults;
|
|
|
|
|
|
exports.processors = processors;
|
|
|
|
|
|
exports.ValidationError = function (superClass) {
|
|
|
extend(ValidationError, superClass);
|
|
|
|
|
|
function ValidationError(message) {
|
|
|
this.message = message;
|
|
|
}
|
|
|
|
|
|
return ValidationError;
|
|
|
}(Error);
|
|
|
|
|
|
exports.Builder = builder.Builder;
|
|
|
|
|
|
exports.Parser = parser.Parser;
|
|
|
|
|
|
exports.parseString = parser.parseString;
|
|
|
|
|
|
exports.parseStringPromise = parser.parseStringPromise;
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./builder":245,"./defaults":246,"./parser":247,"./processors":248}],250:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
module.exports = {
|
|
|
Disconnected: 1,
|
|
|
Preceding: 2,
|
|
|
Following: 4,
|
|
|
Contains: 8,
|
|
|
ContainedBy: 16,
|
|
|
ImplementationSpecific: 32
|
|
|
};
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],251:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
module.exports = {
|
|
|
Element: 1,
|
|
|
Attribute: 2,
|
|
|
Text: 3,
|
|
|
CData: 4,
|
|
|
EntityReference: 5,
|
|
|
EntityDeclaration: 6,
|
|
|
ProcessingInstruction: 7,
|
|
|
Comment: 8,
|
|
|
Document: 9,
|
|
|
DocType: 10,
|
|
|
DocumentFragment: 11,
|
|
|
NotationDeclaration: 12,
|
|
|
Declaration: 201,
|
|
|
Raw: 202,
|
|
|
AttributeDeclaration: 203,
|
|
|
ElementDeclaration: 204,
|
|
|
Dummy: 205
|
|
|
};
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],252:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
|
|
|
|
|
|
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
var _assign = require('babel-runtime/core-js/object/assign');
|
|
|
|
|
|
var _assign2 = _interopRequireDefault(_assign);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var assign,
|
|
|
getValue,
|
|
|
isArray,
|
|
|
isEmpty,
|
|
|
isFunction,
|
|
|
isObject,
|
|
|
isPlainObject,
|
|
|
slice = [].slice,
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
assign = function assign() {
|
|
|
var i, key, len, source, sources, target;
|
|
|
target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
|
|
if (isFunction(_assign2.default)) {
|
|
|
_assign2.default.apply(null, arguments);
|
|
|
} else {
|
|
|
for (i = 0, len = sources.length; i < len; i++) {
|
|
|
source = sources[i];
|
|
|
if (source != null) {
|
|
|
for (key in source) {
|
|
|
if (!hasProp.call(source, key)) continue;
|
|
|
target[key] = source[key];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return target;
|
|
|
};
|
|
|
|
|
|
isFunction = function isFunction(val) {
|
|
|
return !!val && Object.prototype.toString.call(val) === '[object Function]';
|
|
|
};
|
|
|
|
|
|
isObject = function isObject(val) {
|
|
|
var ref;
|
|
|
return !!val && ((ref = typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) === 'function' || ref === 'object');
|
|
|
};
|
|
|
|
|
|
isArray = function isArray(val) {
|
|
|
if (isFunction(Array.isArray)) {
|
|
|
return Array.isArray(val);
|
|
|
} else {
|
|
|
return Object.prototype.toString.call(val) === '[object Array]';
|
|
|
}
|
|
|
};
|
|
|
|
|
|
isEmpty = function isEmpty(val) {
|
|
|
var key;
|
|
|
if (isArray(val)) {
|
|
|
return !val.length;
|
|
|
} else {
|
|
|
for (key in val) {
|
|
|
if (!hasProp.call(val, key)) continue;
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
isPlainObject = function isPlainObject(val) {
|
|
|
var ctor, proto;
|
|
|
return isObject(val) && (proto = (0, _getPrototypeOf2.default)(val)) && (ctor = proto.constructor) && typeof ctor === 'function' && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
|
|
|
};
|
|
|
|
|
|
getValue = function getValue(obj) {
|
|
|
if (isFunction(obj.valueOf)) {
|
|
|
return obj.valueOf();
|
|
|
} else {
|
|
|
return obj;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports.assign = assign;
|
|
|
|
|
|
module.exports.isFunction = isFunction;
|
|
|
|
|
|
module.exports.isObject = isObject;
|
|
|
|
|
|
module.exports.isArray = isArray;
|
|
|
|
|
|
module.exports.isEmpty = isEmpty;
|
|
|
|
|
|
module.exports.isPlainObject = isPlainObject;
|
|
|
|
|
|
module.exports.getValue = getValue;
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"babel-runtime/core-js/object/assign":54,"babel-runtime/core-js/object/get-prototype-of":59,"babel-runtime/helpers/typeof":67}],253:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
module.exports = {
|
|
|
None: 0,
|
|
|
OpenTag: 1,
|
|
|
InsideTag: 2,
|
|
|
CloseTag: 3
|
|
|
};
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],254:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType, XMLAttribute, XMLNode;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
module.exports = XMLAttribute = function () {
|
|
|
function XMLAttribute(parent, name, value) {
|
|
|
this.parent = parent;
|
|
|
if (this.parent) {
|
|
|
this.options = this.parent.options;
|
|
|
this.stringify = this.parent.stringify;
|
|
|
}
|
|
|
if (name == null) {
|
|
|
throw new Error("Missing attribute name. " + this.debugInfo(name));
|
|
|
}
|
|
|
this.name = this.stringify.name(name);
|
|
|
this.value = this.stringify.attValue(value);
|
|
|
this.type = NodeType.Attribute;
|
|
|
this.isId = false;
|
|
|
this.schemaTypeInfo = null;
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
|
|
|
get: function get() {
|
|
|
return this.type;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
|
|
|
get: function get() {
|
|
|
return this.parent;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLAttribute.prototype, 'textContent', {
|
|
|
get: function get() {
|
|
|
return this.value;
|
|
|
},
|
|
|
set: function set(value) {
|
|
|
return this.value = value || '';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
|
|
|
get: function get() {
|
|
|
return '';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLAttribute.prototype, 'prefix', {
|
|
|
get: function get() {
|
|
|
return '';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLAttribute.prototype, 'localName', {
|
|
|
get: function get() {
|
|
|
return this.name;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLAttribute.prototype, 'specified', {
|
|
|
get: function get() {
|
|
|
return true;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLAttribute.prototype.clone = function () {
|
|
|
return (0, _create2.default)(this);
|
|
|
};
|
|
|
|
|
|
XMLAttribute.prototype.toString = function (options) {
|
|
|
return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
XMLAttribute.prototype.debugInfo = function (name) {
|
|
|
name = name || this.name;
|
|
|
if (name == null) {
|
|
|
return "parent: <" + this.parent.name + ">";
|
|
|
} else {
|
|
|
return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLAttribute.prototype.isEqualNode = function (node) {
|
|
|
if (node.namespaceURI !== this.namespaceURI) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.prefix !== this.prefix) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.localName !== this.localName) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.value !== this.value) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
return XMLAttribute;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLNode":273,"babel-runtime/core-js/object/create":55}],255:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLCData,
|
|
|
XMLCharacterData,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLCharacterData = require('./XMLCharacterData');
|
|
|
|
|
|
module.exports = XMLCData = function (superClass) {
|
|
|
extend(XMLCData, superClass);
|
|
|
|
|
|
function XMLCData(parent, text) {
|
|
|
XMLCData.__super__.constructor.call(this, parent);
|
|
|
if (text == null) {
|
|
|
throw new Error("Missing CDATA text. " + this.debugInfo());
|
|
|
}
|
|
|
this.name = "#cdata-section";
|
|
|
this.type = NodeType.CData;
|
|
|
this.value = this.stringify.cdata(text);
|
|
|
}
|
|
|
|
|
|
XMLCData.prototype.clone = function () {
|
|
|
return (0, _create2.default)(this);
|
|
|
};
|
|
|
|
|
|
XMLCData.prototype.toString = function (options) {
|
|
|
return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
return XMLCData;
|
|
|
}(XMLCharacterData);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLCharacterData":256,"babel-runtime/core-js/object/create":55}],256:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLCharacterData,
|
|
|
XMLNode,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
module.exports = XMLCharacterData = function (superClass) {
|
|
|
extend(XMLCharacterData, superClass);
|
|
|
|
|
|
function XMLCharacterData(parent) {
|
|
|
XMLCharacterData.__super__.constructor.call(this, parent);
|
|
|
this.value = '';
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLCharacterData.prototype, 'data', {
|
|
|
get: function get() {
|
|
|
return this.value;
|
|
|
},
|
|
|
set: function set(value) {
|
|
|
return this.value = value || '';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLCharacterData.prototype, 'length', {
|
|
|
get: function get() {
|
|
|
return this.value.length;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
|
|
|
get: function get() {
|
|
|
return this.value;
|
|
|
},
|
|
|
set: function set(value) {
|
|
|
return this.value = value || '';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLCharacterData.prototype.clone = function () {
|
|
|
return (0, _create2.default)(this);
|
|
|
};
|
|
|
|
|
|
XMLCharacterData.prototype.substringData = function (offset, count) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLCharacterData.prototype.appendData = function (arg) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLCharacterData.prototype.insertData = function (offset, arg) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLCharacterData.prototype.deleteData = function (offset, count) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLCharacterData.prototype.replaceData = function (offset, count, arg) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLCharacterData.prototype.isEqualNode = function (node) {
|
|
|
if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.data !== this.data) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
return XMLCharacterData;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./XMLNode":273,"babel-runtime/core-js/object/create":55}],257:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLCharacterData,
|
|
|
XMLComment,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLCharacterData = require('./XMLCharacterData');
|
|
|
|
|
|
module.exports = XMLComment = function (superClass) {
|
|
|
extend(XMLComment, superClass);
|
|
|
|
|
|
function XMLComment(parent, text) {
|
|
|
XMLComment.__super__.constructor.call(this, parent);
|
|
|
if (text == null) {
|
|
|
throw new Error("Missing comment text. " + this.debugInfo());
|
|
|
}
|
|
|
this.name = "#comment";
|
|
|
this.type = NodeType.Comment;
|
|
|
this.value = this.stringify.comment(text);
|
|
|
}
|
|
|
|
|
|
XMLComment.prototype.clone = function () {
|
|
|
return (0, _create2.default)(this);
|
|
|
};
|
|
|
|
|
|
XMLComment.prototype.toString = function (options) {
|
|
|
return this.options.writer.comment(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
return XMLComment;
|
|
|
}(XMLCharacterData);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLCharacterData":256,"babel-runtime/core-js/object/create":55}],258:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
|
|
|
|
|
|
XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
|
|
|
|
|
|
XMLDOMStringList = require('./XMLDOMStringList');
|
|
|
|
|
|
module.exports = XMLDOMConfiguration = function () {
|
|
|
function XMLDOMConfiguration() {
|
|
|
var clonedSelf;
|
|
|
this.defaultParams = {
|
|
|
"canonical-form": false,
|
|
|
"cdata-sections": false,
|
|
|
"comments": false,
|
|
|
"datatype-normalization": false,
|
|
|
"element-content-whitespace": true,
|
|
|
"entities": true,
|
|
|
"error-handler": new XMLDOMErrorHandler(),
|
|
|
"infoset": true,
|
|
|
"validate-if-schema": false,
|
|
|
"namespaces": true,
|
|
|
"namespace-declarations": true,
|
|
|
"normalize-characters": false,
|
|
|
"schema-location": '',
|
|
|
"schema-type": '',
|
|
|
"split-cdata-sections": true,
|
|
|
"validate": false,
|
|
|
"well-formed": true
|
|
|
};
|
|
|
this.params = clonedSelf = (0, _create2.default)(this.defaultParams);
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
|
|
|
get: function get() {
|
|
|
return new XMLDOMStringList((0, _keys2.default)(this.defaultParams));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLDOMConfiguration.prototype.getParameter = function (name) {
|
|
|
if (this.params.hasOwnProperty(name)) {
|
|
|
return this.params[name];
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLDOMConfiguration.prototype.canSetParameter = function (name, value) {
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
XMLDOMConfiguration.prototype.setParameter = function (name, value) {
|
|
|
if (value != null) {
|
|
|
return this.params[name] = value;
|
|
|
} else {
|
|
|
return delete this.params[name];
|
|
|
}
|
|
|
};
|
|
|
|
|
|
return XMLDOMConfiguration;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./XMLDOMErrorHandler":259,"./XMLDOMStringList":261,"babel-runtime/core-js/object/create":55,"babel-runtime/core-js/object/keys":60}],259:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLDOMErrorHandler;
|
|
|
|
|
|
module.exports = XMLDOMErrorHandler = function () {
|
|
|
function XMLDOMErrorHandler() {}
|
|
|
|
|
|
XMLDOMErrorHandler.prototype.handleError = function (error) {
|
|
|
throw new Error(error);
|
|
|
};
|
|
|
|
|
|
return XMLDOMErrorHandler;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],260:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLDOMImplementation;
|
|
|
|
|
|
module.exports = XMLDOMImplementation = function () {
|
|
|
function XMLDOMImplementation() {}
|
|
|
|
|
|
XMLDOMImplementation.prototype.hasFeature = function (feature, version) {
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
XMLDOMImplementation.prototype.createDocumentType = function (qualifiedName, publicId, systemId) {
|
|
|
throw new Error("This DOM method is not implemented.");
|
|
|
};
|
|
|
|
|
|
XMLDOMImplementation.prototype.createDocument = function (namespaceURI, qualifiedName, doctype) {
|
|
|
throw new Error("This DOM method is not implemented.");
|
|
|
};
|
|
|
|
|
|
XMLDOMImplementation.prototype.createHTMLDocument = function (title) {
|
|
|
throw new Error("This DOM method is not implemented.");
|
|
|
};
|
|
|
|
|
|
XMLDOMImplementation.prototype.getFeature = function (feature, version) {
|
|
|
throw new Error("This DOM method is not implemented.");
|
|
|
};
|
|
|
|
|
|
return XMLDOMImplementation;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],261:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLDOMStringList;
|
|
|
|
|
|
module.exports = XMLDOMStringList = function () {
|
|
|
function XMLDOMStringList(arr) {
|
|
|
this.arr = arr || [];
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLDOMStringList.prototype, 'length', {
|
|
|
get: function get() {
|
|
|
return this.arr.length;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLDOMStringList.prototype.item = function (index) {
|
|
|
return this.arr[index] || null;
|
|
|
};
|
|
|
|
|
|
XMLDOMStringList.prototype.contains = function (str) {
|
|
|
return this.arr.indexOf(str) !== -1;
|
|
|
};
|
|
|
|
|
|
return XMLDOMStringList;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],262:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLDTDAttList,
|
|
|
XMLNode,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
module.exports = XMLDTDAttList = function (superClass) {
|
|
|
extend(XMLDTDAttList, superClass);
|
|
|
|
|
|
function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
|
|
XMLDTDAttList.__super__.constructor.call(this, parent);
|
|
|
if (elementName == null) {
|
|
|
throw new Error("Missing DTD element name. " + this.debugInfo());
|
|
|
}
|
|
|
if (attributeName == null) {
|
|
|
throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
|
|
|
}
|
|
|
if (!attributeType) {
|
|
|
throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
|
|
|
}
|
|
|
if (!defaultValueType) {
|
|
|
throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
|
|
|
}
|
|
|
if (defaultValueType.indexOf('#') !== 0) {
|
|
|
defaultValueType = '#' + defaultValueType;
|
|
|
}
|
|
|
if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
|
|
|
throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
|
|
|
}
|
|
|
if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
|
|
|
throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
|
|
|
}
|
|
|
this.elementName = this.stringify.name(elementName);
|
|
|
this.type = NodeType.AttributeDeclaration;
|
|
|
this.attributeName = this.stringify.name(attributeName);
|
|
|
this.attributeType = this.stringify.dtdAttType(attributeType);
|
|
|
if (defaultValue) {
|
|
|
this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
|
|
|
}
|
|
|
this.defaultValueType = defaultValueType;
|
|
|
}
|
|
|
|
|
|
XMLDTDAttList.prototype.toString = function (options) {
|
|
|
return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
return XMLDTDAttList;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLNode":273}],263:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLDTDElement,
|
|
|
XMLNode,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
module.exports = XMLDTDElement = function (superClass) {
|
|
|
extend(XMLDTDElement, superClass);
|
|
|
|
|
|
function XMLDTDElement(parent, name, value) {
|
|
|
XMLDTDElement.__super__.constructor.call(this, parent);
|
|
|
if (name == null) {
|
|
|
throw new Error("Missing DTD element name. " + this.debugInfo());
|
|
|
}
|
|
|
if (!value) {
|
|
|
value = '(#PCDATA)';
|
|
|
}
|
|
|
if (Array.isArray(value)) {
|
|
|
value = '(' + value.join(',') + ')';
|
|
|
}
|
|
|
this.name = this.stringify.name(name);
|
|
|
this.type = NodeType.ElementDeclaration;
|
|
|
this.value = this.stringify.dtdElementValue(value);
|
|
|
}
|
|
|
|
|
|
XMLDTDElement.prototype.toString = function (options) {
|
|
|
return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
return XMLDTDElement;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLNode":273}],264:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLDTDEntity,
|
|
|
XMLNode,
|
|
|
isObject,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
isObject = require('./Utility').isObject;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
module.exports = XMLDTDEntity = function (superClass) {
|
|
|
extend(XMLDTDEntity, superClass);
|
|
|
|
|
|
function XMLDTDEntity(parent, pe, name, value) {
|
|
|
XMLDTDEntity.__super__.constructor.call(this, parent);
|
|
|
if (name == null) {
|
|
|
throw new Error("Missing DTD entity name. " + this.debugInfo(name));
|
|
|
}
|
|
|
if (value == null) {
|
|
|
throw new Error("Missing DTD entity value. " + this.debugInfo(name));
|
|
|
}
|
|
|
this.pe = !!pe;
|
|
|
this.name = this.stringify.name(name);
|
|
|
this.type = NodeType.EntityDeclaration;
|
|
|
if (!isObject(value)) {
|
|
|
this.value = this.stringify.dtdEntityValue(value);
|
|
|
this.internal = true;
|
|
|
} else {
|
|
|
if (!value.pubID && !value.sysID) {
|
|
|
throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
|
|
|
}
|
|
|
if (value.pubID && !value.sysID) {
|
|
|
throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
|
|
|
}
|
|
|
this.internal = false;
|
|
|
if (value.pubID != null) {
|
|
|
this.pubID = this.stringify.dtdPubID(value.pubID);
|
|
|
}
|
|
|
if (value.sysID != null) {
|
|
|
this.sysID = this.stringify.dtdSysID(value.sysID);
|
|
|
}
|
|
|
if (value.nData != null) {
|
|
|
this.nData = this.stringify.dtdNData(value.nData);
|
|
|
}
|
|
|
if (this.pe && this.nData) {
|
|
|
throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
|
|
|
get: function get() {
|
|
|
return this.pubID;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
|
|
|
get: function get() {
|
|
|
return this.sysID;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
|
|
|
get: function get() {
|
|
|
return this.nData || null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
|
|
|
get: function get() {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
|
|
|
get: function get() {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
|
|
|
get: function get() {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLDTDEntity.prototype.toString = function (options) {
|
|
|
return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
return XMLDTDEntity;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./Utility":252,"./XMLNode":273}],265:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLDTDNotation,
|
|
|
XMLNode,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
module.exports = XMLDTDNotation = function (superClass) {
|
|
|
extend(XMLDTDNotation, superClass);
|
|
|
|
|
|
function XMLDTDNotation(parent, name, value) {
|
|
|
XMLDTDNotation.__super__.constructor.call(this, parent);
|
|
|
if (name == null) {
|
|
|
throw new Error("Missing DTD notation name. " + this.debugInfo(name));
|
|
|
}
|
|
|
if (!value.pubID && !value.sysID) {
|
|
|
throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
|
|
|
}
|
|
|
this.name = this.stringify.name(name);
|
|
|
this.type = NodeType.NotationDeclaration;
|
|
|
if (value.pubID != null) {
|
|
|
this.pubID = this.stringify.dtdPubID(value.pubID);
|
|
|
}
|
|
|
if (value.sysID != null) {
|
|
|
this.sysID = this.stringify.dtdSysID(value.sysID);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
|
|
|
get: function get() {
|
|
|
return this.pubID;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
|
|
|
get: function get() {
|
|
|
return this.sysID;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLDTDNotation.prototype.toString = function (options) {
|
|
|
return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
return XMLDTDNotation;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLNode":273}],266:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLDeclaration,
|
|
|
XMLNode,
|
|
|
isObject,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
isObject = require('./Utility').isObject;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
module.exports = XMLDeclaration = function (superClass) {
|
|
|
extend(XMLDeclaration, superClass);
|
|
|
|
|
|
function XMLDeclaration(parent, version, encoding, standalone) {
|
|
|
var ref;
|
|
|
XMLDeclaration.__super__.constructor.call(this, parent);
|
|
|
if (isObject(version)) {
|
|
|
ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
|
|
|
}
|
|
|
if (!version) {
|
|
|
version = '1.0';
|
|
|
}
|
|
|
this.type = NodeType.Declaration;
|
|
|
this.version = this.stringify.xmlVersion(version);
|
|
|
if (encoding != null) {
|
|
|
this.encoding = this.stringify.xmlEncoding(encoding);
|
|
|
}
|
|
|
if (standalone != null) {
|
|
|
this.standalone = this.stringify.xmlStandalone(standalone);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
XMLDeclaration.prototype.toString = function (options) {
|
|
|
return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
return XMLDeclaration;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./Utility":252,"./XMLNode":273}],267:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLDTDAttList,
|
|
|
XMLDTDElement,
|
|
|
XMLDTDEntity,
|
|
|
XMLDTDNotation,
|
|
|
XMLDocType,
|
|
|
XMLNamedNodeMap,
|
|
|
XMLNode,
|
|
|
isObject,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
isObject = require('./Utility').isObject;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLDTDAttList = require('./XMLDTDAttList');
|
|
|
|
|
|
XMLDTDEntity = require('./XMLDTDEntity');
|
|
|
|
|
|
XMLDTDElement = require('./XMLDTDElement');
|
|
|
|
|
|
XMLDTDNotation = require('./XMLDTDNotation');
|
|
|
|
|
|
XMLNamedNodeMap = require('./XMLNamedNodeMap');
|
|
|
|
|
|
module.exports = XMLDocType = function (superClass) {
|
|
|
extend(XMLDocType, superClass);
|
|
|
|
|
|
function XMLDocType(parent, pubID, sysID) {
|
|
|
var child, i, len, ref, ref1, ref2;
|
|
|
XMLDocType.__super__.constructor.call(this, parent);
|
|
|
this.type = NodeType.DocType;
|
|
|
if (parent.children) {
|
|
|
ref = parent.children;
|
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
|
child = ref[i];
|
|
|
if (child.type === NodeType.Element) {
|
|
|
this.name = child.name;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
this.documentObject = parent;
|
|
|
if (isObject(pubID)) {
|
|
|
ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID;
|
|
|
}
|
|
|
if (sysID == null) {
|
|
|
ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1];
|
|
|
}
|
|
|
if (pubID != null) {
|
|
|
this.pubID = this.stringify.dtdPubID(pubID);
|
|
|
}
|
|
|
if (sysID != null) {
|
|
|
this.sysID = this.stringify.dtdSysID(sysID);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLDocType.prototype, 'entities', {
|
|
|
get: function get() {
|
|
|
var child, i, len, nodes, ref;
|
|
|
nodes = {};
|
|
|
ref = this.children;
|
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
|
child = ref[i];
|
|
|
if (child.type === NodeType.EntityDeclaration && !child.pe) {
|
|
|
nodes[child.name] = child;
|
|
|
}
|
|
|
}
|
|
|
return new XMLNamedNodeMap(nodes);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocType.prototype, 'notations', {
|
|
|
get: function get() {
|
|
|
var child, i, len, nodes, ref;
|
|
|
nodes = {};
|
|
|
ref = this.children;
|
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
|
child = ref[i];
|
|
|
if (child.type === NodeType.NotationDeclaration) {
|
|
|
nodes[child.name] = child;
|
|
|
}
|
|
|
}
|
|
|
return new XMLNamedNodeMap(nodes);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocType.prototype, 'publicId', {
|
|
|
get: function get() {
|
|
|
return this.pubID;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocType.prototype, 'systemId', {
|
|
|
get: function get() {
|
|
|
return this.sysID;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
|
|
|
get: function get() {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLDocType.prototype.element = function (name, value) {
|
|
|
var child;
|
|
|
child = new XMLDTDElement(this, name, value);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.attList = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
|
|
var child;
|
|
|
child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.entity = function (name, value) {
|
|
|
var child;
|
|
|
child = new XMLDTDEntity(this, false, name, value);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.pEntity = function (name, value) {
|
|
|
var child;
|
|
|
child = new XMLDTDEntity(this, true, name, value);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.notation = function (name, value) {
|
|
|
var child;
|
|
|
child = new XMLDTDNotation(this, name, value);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.toString = function (options) {
|
|
|
return this.options.writer.docType(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.ele = function (name, value) {
|
|
|
return this.element(name, value);
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.att = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
|
|
return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.ent = function (name, value) {
|
|
|
return this.entity(name, value);
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.pent = function (name, value) {
|
|
|
return this.pEntity(name, value);
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.not = function (name, value) {
|
|
|
return this.notation(name, value);
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.up = function () {
|
|
|
return this.root() || this.documentObject;
|
|
|
};
|
|
|
|
|
|
XMLDocType.prototype.isEqualNode = function (node) {
|
|
|
if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.name !== this.name) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.publicId !== this.publicId) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.systemId !== this.systemId) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
return XMLDocType;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./Utility":252,"./XMLDTDAttList":262,"./XMLDTDElement":263,"./XMLDTDEntity":264,"./XMLDTDNotation":265,"./XMLNamedNodeMap":272,"./XMLNode":273}],268:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLDOMConfiguration,
|
|
|
XMLDOMImplementation,
|
|
|
XMLDocument,
|
|
|
XMLNode,
|
|
|
XMLStringWriter,
|
|
|
XMLStringifier,
|
|
|
isPlainObject,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
isPlainObject = require('./Utility').isPlainObject;
|
|
|
|
|
|
XMLDOMImplementation = require('./XMLDOMImplementation');
|
|
|
|
|
|
XMLDOMConfiguration = require('./XMLDOMConfiguration');
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLStringifier = require('./XMLStringifier');
|
|
|
|
|
|
XMLStringWriter = require('./XMLStringWriter');
|
|
|
|
|
|
module.exports = XMLDocument = function (superClass) {
|
|
|
extend(XMLDocument, superClass);
|
|
|
|
|
|
function XMLDocument(options) {
|
|
|
XMLDocument.__super__.constructor.call(this, null);
|
|
|
this.name = "#document";
|
|
|
this.type = NodeType.Document;
|
|
|
this.documentURI = null;
|
|
|
this.domConfig = new XMLDOMConfiguration();
|
|
|
options || (options = {});
|
|
|
if (!options.writer) {
|
|
|
options.writer = new XMLStringWriter();
|
|
|
}
|
|
|
this.options = options;
|
|
|
this.stringify = new XMLStringifier(options);
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'implementation', {
|
|
|
value: new XMLDOMImplementation()
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'doctype', {
|
|
|
get: function get() {
|
|
|
var child, i, len, ref;
|
|
|
ref = this.children;
|
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
|
child = ref[i];
|
|
|
if (child.type === NodeType.DocType) {
|
|
|
return child;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'documentElement', {
|
|
|
get: function get() {
|
|
|
return this.rootObject || null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
|
|
|
get: function get() {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
|
|
|
get: function get() {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
|
|
|
get: function get() {
|
|
|
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
|
|
|
return this.children[0].encoding;
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
|
|
|
get: function get() {
|
|
|
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
|
|
|
return this.children[0].standalone === 'yes';
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
|
|
|
get: function get() {
|
|
|
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
|
|
|
return this.children[0].version;
|
|
|
} else {
|
|
|
return "1.0";
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'URL', {
|
|
|
get: function get() {
|
|
|
return this.documentURI;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'origin', {
|
|
|
get: function get() {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'compatMode', {
|
|
|
get: function get() {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'characterSet', {
|
|
|
get: function get() {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLDocument.prototype, 'contentType', {
|
|
|
get: function get() {
|
|
|
return null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLDocument.prototype.end = function (writer) {
|
|
|
var writerOptions;
|
|
|
writerOptions = {};
|
|
|
if (!writer) {
|
|
|
writer = this.options.writer;
|
|
|
} else if (isPlainObject(writer)) {
|
|
|
writerOptions = writer;
|
|
|
writer = this.options.writer;
|
|
|
}
|
|
|
return writer.document(this, writer.filterOptions(writerOptions));
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.toString = function (options) {
|
|
|
return this.options.writer.document(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createElement = function (tagName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createDocumentFragment = function () {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createTextNode = function (data) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createComment = function (data) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createCDATASection = function (data) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createProcessingInstruction = function (target, data) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createAttribute = function (name) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createEntityReference = function (name) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.getElementsByTagName = function (tagname) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.importNode = function (importedNode, deep) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createElementNS = function (namespaceURI, qualifiedName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createAttributeNS = function (namespaceURI, qualifiedName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.getElementById = function (elementId) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.adoptNode = function (source) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.normalizeDocument = function () {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.renameNode = function (node, namespaceURI, qualifiedName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.getElementsByClassName = function (classNames) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createEvent = function (eventInterface) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createRange = function () {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createNodeIterator = function (root, whatToShow, filter) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLDocument.prototype.createTreeWalker = function (root, whatToShow, filter) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
return XMLDocument;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./Utility":252,"./XMLDOMConfiguration":258,"./XMLDOMImplementation":260,"./XMLNode":273,"./XMLStringWriter":278,"./XMLStringifier":279}],269:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
WriterState,
|
|
|
XMLAttribute,
|
|
|
XMLCData,
|
|
|
XMLComment,
|
|
|
XMLDTDAttList,
|
|
|
XMLDTDElement,
|
|
|
XMLDTDEntity,
|
|
|
XMLDTDNotation,
|
|
|
XMLDeclaration,
|
|
|
XMLDocType,
|
|
|
XMLDocument,
|
|
|
XMLDocumentCB,
|
|
|
XMLElement,
|
|
|
XMLProcessingInstruction,
|
|
|
XMLRaw,
|
|
|
XMLStringWriter,
|
|
|
XMLStringifier,
|
|
|
XMLText,
|
|
|
getValue,
|
|
|
isFunction,
|
|
|
isObject,
|
|
|
isPlainObject,
|
|
|
ref,
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLDocument = require('./XMLDocument');
|
|
|
|
|
|
XMLElement = require('./XMLElement');
|
|
|
|
|
|
XMLCData = require('./XMLCData');
|
|
|
|
|
|
XMLComment = require('./XMLComment');
|
|
|
|
|
|
XMLRaw = require('./XMLRaw');
|
|
|
|
|
|
XMLText = require('./XMLText');
|
|
|
|
|
|
XMLProcessingInstruction = require('./XMLProcessingInstruction');
|
|
|
|
|
|
XMLDeclaration = require('./XMLDeclaration');
|
|
|
|
|
|
XMLDocType = require('./XMLDocType');
|
|
|
|
|
|
XMLDTDAttList = require('./XMLDTDAttList');
|
|
|
|
|
|
XMLDTDEntity = require('./XMLDTDEntity');
|
|
|
|
|
|
XMLDTDElement = require('./XMLDTDElement');
|
|
|
|
|
|
XMLDTDNotation = require('./XMLDTDNotation');
|
|
|
|
|
|
XMLAttribute = require('./XMLAttribute');
|
|
|
|
|
|
XMLStringifier = require('./XMLStringifier');
|
|
|
|
|
|
XMLStringWriter = require('./XMLStringWriter');
|
|
|
|
|
|
WriterState = require('./WriterState');
|
|
|
|
|
|
module.exports = XMLDocumentCB = function () {
|
|
|
function XMLDocumentCB(options, onData, onEnd) {
|
|
|
var writerOptions;
|
|
|
this.name = "?xml";
|
|
|
this.type = NodeType.Document;
|
|
|
options || (options = {});
|
|
|
writerOptions = {};
|
|
|
if (!options.writer) {
|
|
|
options.writer = new XMLStringWriter();
|
|
|
} else if (isPlainObject(options.writer)) {
|
|
|
writerOptions = options.writer;
|
|
|
options.writer = new XMLStringWriter();
|
|
|
}
|
|
|
this.options = options;
|
|
|
this.writer = options.writer;
|
|
|
this.writerOptions = this.writer.filterOptions(writerOptions);
|
|
|
this.stringify = new XMLStringifier(options);
|
|
|
this.onDataCallback = onData || function () {};
|
|
|
this.onEndCallback = onEnd || function () {};
|
|
|
this.currentNode = null;
|
|
|
this.currentLevel = -1;
|
|
|
this.openTags = {};
|
|
|
this.documentStarted = false;
|
|
|
this.documentCompleted = false;
|
|
|
this.root = null;
|
|
|
}
|
|
|
|
|
|
XMLDocumentCB.prototype.createChildNode = function (node) {
|
|
|
var att, attName, attributes, child, i, len, ref1, ref2;
|
|
|
switch (node.type) {
|
|
|
case NodeType.CData:
|
|
|
this.cdata(node.value);
|
|
|
break;
|
|
|
case NodeType.Comment:
|
|
|
this.comment(node.value);
|
|
|
break;
|
|
|
case NodeType.Element:
|
|
|
attributes = {};
|
|
|
ref1 = node.attribs;
|
|
|
for (attName in ref1) {
|
|
|
if (!hasProp.call(ref1, attName)) continue;
|
|
|
att = ref1[attName];
|
|
|
attributes[attName] = att.value;
|
|
|
}
|
|
|
this.node(node.name, attributes);
|
|
|
break;
|
|
|
case NodeType.Dummy:
|
|
|
this.dummy();
|
|
|
break;
|
|
|
case NodeType.Raw:
|
|
|
this.raw(node.value);
|
|
|
break;
|
|
|
case NodeType.Text:
|
|
|
this.text(node.value);
|
|
|
break;
|
|
|
case NodeType.ProcessingInstruction:
|
|
|
this.instruction(node.target, node.value);
|
|
|
break;
|
|
|
default:
|
|
|
throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
|
|
|
}
|
|
|
ref2 = node.children;
|
|
|
for (i = 0, len = ref2.length; i < len; i++) {
|
|
|
child = ref2[i];
|
|
|
this.createChildNode(child);
|
|
|
if (child.type === NodeType.Element) {
|
|
|
this.up();
|
|
|
}
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.dummy = function () {
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.node = function (name, attributes, text) {
|
|
|
var ref1;
|
|
|
if (name == null) {
|
|
|
throw new Error("Missing node name.");
|
|
|
}
|
|
|
if (this.root && this.currentLevel === -1) {
|
|
|
throw new Error("Document can only have one root node. " + this.debugInfo(name));
|
|
|
}
|
|
|
this.openCurrent();
|
|
|
name = getValue(name);
|
|
|
if (attributes == null) {
|
|
|
attributes = {};
|
|
|
}
|
|
|
attributes = getValue(attributes);
|
|
|
if (!isObject(attributes)) {
|
|
|
ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
|
|
|
}
|
|
|
this.currentNode = new XMLElement(this, name, attributes);
|
|
|
this.currentNode.children = false;
|
|
|
this.currentLevel++;
|
|
|
this.openTags[this.currentLevel] = this.currentNode;
|
|
|
if (text != null) {
|
|
|
this.text(text);
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.element = function (name, attributes, text) {
|
|
|
var child, i, len, oldValidationFlag, ref1, root;
|
|
|
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
|
|
|
this.dtdElement.apply(this, arguments);
|
|
|
} else {
|
|
|
if (Array.isArray(name) || isObject(name) || isFunction(name)) {
|
|
|
oldValidationFlag = this.options.noValidation;
|
|
|
this.options.noValidation = true;
|
|
|
root = new XMLDocument(this.options).element('TEMP_ROOT');
|
|
|
root.element(name);
|
|
|
this.options.noValidation = oldValidationFlag;
|
|
|
ref1 = root.children;
|
|
|
for (i = 0, len = ref1.length; i < len; i++) {
|
|
|
child = ref1[i];
|
|
|
this.createChildNode(child);
|
|
|
if (child.type === NodeType.Element) {
|
|
|
this.up();
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
this.node(name, attributes, text);
|
|
|
}
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.attribute = function (name, value) {
|
|
|
var attName, attValue;
|
|
|
if (!this.currentNode || this.currentNode.children) {
|
|
|
throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
|
|
|
}
|
|
|
if (name != null) {
|
|
|
name = getValue(name);
|
|
|
}
|
|
|
if (isObject(name)) {
|
|
|
for (attName in name) {
|
|
|
if (!hasProp.call(name, attName)) continue;
|
|
|
attValue = name[attName];
|
|
|
this.attribute(attName, attValue);
|
|
|
}
|
|
|
} else {
|
|
|
if (isFunction(value)) {
|
|
|
value = value.apply();
|
|
|
}
|
|
|
if (this.options.keepNullAttributes && value == null) {
|
|
|
this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
|
|
|
} else if (value != null) {
|
|
|
this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
|
|
|
}
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.text = function (value) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLText(this, value);
|
|
|
this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.cdata = function (value) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLCData(this, value);
|
|
|
this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.comment = function (value) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLComment(this, value);
|
|
|
this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.raw = function (value) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLRaw(this, value);
|
|
|
this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.instruction = function (target, value) {
|
|
|
var i, insTarget, insValue, len, node;
|
|
|
this.openCurrent();
|
|
|
if (target != null) {
|
|
|
target = getValue(target);
|
|
|
}
|
|
|
if (value != null) {
|
|
|
value = getValue(value);
|
|
|
}
|
|
|
if (Array.isArray(target)) {
|
|
|
for (i = 0, len = target.length; i < len; i++) {
|
|
|
insTarget = target[i];
|
|
|
this.instruction(insTarget);
|
|
|
}
|
|
|
} else if (isObject(target)) {
|
|
|
for (insTarget in target) {
|
|
|
if (!hasProp.call(target, insTarget)) continue;
|
|
|
insValue = target[insTarget];
|
|
|
this.instruction(insTarget, insValue);
|
|
|
}
|
|
|
} else {
|
|
|
if (isFunction(value)) {
|
|
|
value = value.apply();
|
|
|
}
|
|
|
node = new XMLProcessingInstruction(this, target, value);
|
|
|
this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.declaration = function (version, encoding, standalone) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
if (this.documentStarted) {
|
|
|
throw new Error("declaration() must be the first node.");
|
|
|
}
|
|
|
node = new XMLDeclaration(this, version, encoding, standalone);
|
|
|
this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.doctype = function (root, pubID, sysID) {
|
|
|
this.openCurrent();
|
|
|
if (root == null) {
|
|
|
throw new Error("Missing root node name.");
|
|
|
}
|
|
|
if (this.root) {
|
|
|
throw new Error("dtd() must come before the root node.");
|
|
|
}
|
|
|
this.currentNode = new XMLDocType(this, pubID, sysID);
|
|
|
this.currentNode.rootNodeName = root;
|
|
|
this.currentNode.children = false;
|
|
|
this.currentLevel++;
|
|
|
this.openTags[this.currentLevel] = this.currentNode;
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.dtdElement = function (name, value) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLDTDElement(this, name, value);
|
|
|
this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.attList = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
|
|
|
this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.entity = function (name, value) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLDTDEntity(this, false, name, value);
|
|
|
this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.pEntity = function (name, value) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLDTDEntity(this, true, name, value);
|
|
|
this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.notation = function (name, value) {
|
|
|
var node;
|
|
|
this.openCurrent();
|
|
|
node = new XMLDTDNotation(this, name, value);
|
|
|
this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.up = function () {
|
|
|
if (this.currentLevel < 0) {
|
|
|
throw new Error("The document node has no parent.");
|
|
|
}
|
|
|
if (this.currentNode) {
|
|
|
if (this.currentNode.children) {
|
|
|
this.closeNode(this.currentNode);
|
|
|
} else {
|
|
|
this.openNode(this.currentNode);
|
|
|
}
|
|
|
this.currentNode = null;
|
|
|
} else {
|
|
|
this.closeNode(this.openTags[this.currentLevel]);
|
|
|
}
|
|
|
delete this.openTags[this.currentLevel];
|
|
|
this.currentLevel--;
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.end = function () {
|
|
|
while (this.currentLevel >= 0) {
|
|
|
this.up();
|
|
|
}
|
|
|
return this.onEnd();
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.openCurrent = function () {
|
|
|
if (this.currentNode) {
|
|
|
this.currentNode.children = true;
|
|
|
return this.openNode(this.currentNode);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.openNode = function (node) {
|
|
|
var att, chunk, name, ref1;
|
|
|
if (!node.isOpen) {
|
|
|
if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
|
|
|
this.root = node;
|
|
|
}
|
|
|
chunk = '';
|
|
|
if (node.type === NodeType.Element) {
|
|
|
this.writerOptions.state = WriterState.OpenTag;
|
|
|
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
|
|
|
ref1 = node.attribs;
|
|
|
for (name in ref1) {
|
|
|
if (!hasProp.call(ref1, name)) continue;
|
|
|
att = ref1[name];
|
|
|
chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
|
|
|
}
|
|
|
chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
|
|
|
this.writerOptions.state = WriterState.InsideTag;
|
|
|
} else {
|
|
|
this.writerOptions.state = WriterState.OpenTag;
|
|
|
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
|
|
|
if (node.pubID && node.sysID) {
|
|
|
chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
|
|
|
} else if (node.sysID) {
|
|
|
chunk += ' SYSTEM "' + node.sysID + '"';
|
|
|
}
|
|
|
if (node.children) {
|
|
|
chunk += ' [';
|
|
|
this.writerOptions.state = WriterState.InsideTag;
|
|
|
} else {
|
|
|
this.writerOptions.state = WriterState.CloseTag;
|
|
|
chunk += '>';
|
|
|
}
|
|
|
chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
|
|
|
}
|
|
|
this.onData(chunk, this.currentLevel);
|
|
|
return node.isOpen = true;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.closeNode = function (node) {
|
|
|
var chunk;
|
|
|
if (!node.isClosed) {
|
|
|
chunk = '';
|
|
|
this.writerOptions.state = WriterState.CloseTag;
|
|
|
if (node.type === NodeType.Element) {
|
|
|
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '</' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
|
|
|
} else {
|
|
|
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
|
|
|
}
|
|
|
this.writerOptions.state = WriterState.None;
|
|
|
this.onData(chunk, this.currentLevel);
|
|
|
return node.isClosed = true;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.onData = function (chunk, level) {
|
|
|
this.documentStarted = true;
|
|
|
return this.onDataCallback(chunk, level + 1);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.onEnd = function () {
|
|
|
this.documentCompleted = true;
|
|
|
return this.onEndCallback();
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.debugInfo = function (name) {
|
|
|
if (name == null) {
|
|
|
return "";
|
|
|
} else {
|
|
|
return "node: <" + name + ">";
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.ele = function () {
|
|
|
return this.element.apply(this, arguments);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.nod = function (name, attributes, text) {
|
|
|
return this.node(name, attributes, text);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.txt = function (value) {
|
|
|
return this.text(value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.dat = function (value) {
|
|
|
return this.cdata(value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.com = function (value) {
|
|
|
return this.comment(value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.ins = function (target, value) {
|
|
|
return this.instruction(target, value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.dec = function (version, encoding, standalone) {
|
|
|
return this.declaration(version, encoding, standalone);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.dtd = function (root, pubID, sysID) {
|
|
|
return this.doctype(root, pubID, sysID);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.e = function (name, attributes, text) {
|
|
|
return this.element(name, attributes, text);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.n = function (name, attributes, text) {
|
|
|
return this.node(name, attributes, text);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.t = function (value) {
|
|
|
return this.text(value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.d = function (value) {
|
|
|
return this.cdata(value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.c = function (value) {
|
|
|
return this.comment(value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.r = function (value) {
|
|
|
return this.raw(value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.i = function (target, value) {
|
|
|
return this.instruction(target, value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.att = function () {
|
|
|
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
|
|
|
return this.attList.apply(this, arguments);
|
|
|
} else {
|
|
|
return this.attribute.apply(this, arguments);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.a = function () {
|
|
|
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
|
|
|
return this.attList.apply(this, arguments);
|
|
|
} else {
|
|
|
return this.attribute.apply(this, arguments);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.ent = function (name, value) {
|
|
|
return this.entity(name, value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.pent = function (name, value) {
|
|
|
return this.pEntity(name, value);
|
|
|
};
|
|
|
|
|
|
XMLDocumentCB.prototype.not = function (name, value) {
|
|
|
return this.notation(name, value);
|
|
|
};
|
|
|
|
|
|
return XMLDocumentCB;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./Utility":252,"./WriterState":253,"./XMLAttribute":254,"./XMLCData":255,"./XMLComment":257,"./XMLDTDAttList":262,"./XMLDTDElement":263,"./XMLDTDEntity":264,"./XMLDTDNotation":265,"./XMLDeclaration":266,"./XMLDocType":267,"./XMLDocument":268,"./XMLElement":271,"./XMLProcessingInstruction":275,"./XMLRaw":276,"./XMLStringWriter":278,"./XMLStringifier":279,"./XMLText":280}],270:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLDummy,
|
|
|
XMLNode,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
module.exports = XMLDummy = function (superClass) {
|
|
|
extend(XMLDummy, superClass);
|
|
|
|
|
|
function XMLDummy(parent) {
|
|
|
XMLDummy.__super__.constructor.call(this, parent);
|
|
|
this.type = NodeType.Dummy;
|
|
|
}
|
|
|
|
|
|
XMLDummy.prototype.clone = function () {
|
|
|
return (0, _create2.default)(this);
|
|
|
};
|
|
|
|
|
|
XMLDummy.prototype.toString = function (options) {
|
|
|
return '';
|
|
|
};
|
|
|
|
|
|
return XMLDummy;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLNode":273,"babel-runtime/core-js/object/create":55}],271:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLAttribute,
|
|
|
XMLElement,
|
|
|
XMLNamedNodeMap,
|
|
|
XMLNode,
|
|
|
getValue,
|
|
|
isFunction,
|
|
|
isObject,
|
|
|
ref,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLAttribute = require('./XMLAttribute');
|
|
|
|
|
|
XMLNamedNodeMap = require('./XMLNamedNodeMap');
|
|
|
|
|
|
module.exports = XMLElement = function (superClass) {
|
|
|
extend(XMLElement, superClass);
|
|
|
|
|
|
function XMLElement(parent, name, attributes) {
|
|
|
var child, j, len, ref1;
|
|
|
XMLElement.__super__.constructor.call(this, parent);
|
|
|
if (name == null) {
|
|
|
throw new Error("Missing element name. " + this.debugInfo());
|
|
|
}
|
|
|
this.name = this.stringify.name(name);
|
|
|
this.type = NodeType.Element;
|
|
|
this.attribs = {};
|
|
|
this.schemaTypeInfo = null;
|
|
|
if (attributes != null) {
|
|
|
this.attribute(attributes);
|
|
|
}
|
|
|
if (parent.type === NodeType.Document) {
|
|
|
this.isRoot = true;
|
|
|
this.documentObject = parent;
|
|
|
parent.rootObject = this;
|
|
|
if (parent.children) {
|
|
|
ref1 = parent.children;
|
|
|
for (j = 0, len = ref1.length; j < len; j++) {
|
|
|
child = ref1[j];
|
|
|
if (child.type === NodeType.DocType) {
|
|
|
child.name = this.name;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLElement.prototype, 'tagName', {
|
|
|
get: function get() {
|
|
|
return this.name;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
|
|
|
get: function get() {
|
|
|
return '';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLElement.prototype, 'prefix', {
|
|
|
get: function get() {
|
|
|
return '';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLElement.prototype, 'localName', {
|
|
|
get: function get() {
|
|
|
return this.name;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLElement.prototype, 'id', {
|
|
|
get: function get() {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLElement.prototype, 'className', {
|
|
|
get: function get() {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLElement.prototype, 'classList', {
|
|
|
get: function get() {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLElement.prototype, 'attributes', {
|
|
|
get: function get() {
|
|
|
if (!this.attributeMap || !this.attributeMap.nodes) {
|
|
|
this.attributeMap = new XMLNamedNodeMap(this.attribs);
|
|
|
}
|
|
|
return this.attributeMap;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLElement.prototype.clone = function () {
|
|
|
var att, attName, clonedSelf, ref1;
|
|
|
clonedSelf = (0, _create2.default)(this);
|
|
|
if (clonedSelf.isRoot) {
|
|
|
clonedSelf.documentObject = null;
|
|
|
}
|
|
|
clonedSelf.attribs = {};
|
|
|
ref1 = this.attribs;
|
|
|
for (attName in ref1) {
|
|
|
if (!hasProp.call(ref1, attName)) continue;
|
|
|
att = ref1[attName];
|
|
|
clonedSelf.attribs[attName] = att.clone();
|
|
|
}
|
|
|
clonedSelf.children = [];
|
|
|
this.children.forEach(function (child) {
|
|
|
var clonedChild;
|
|
|
clonedChild = child.clone();
|
|
|
clonedChild.parent = clonedSelf;
|
|
|
return clonedSelf.children.push(clonedChild);
|
|
|
});
|
|
|
return clonedSelf;
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.attribute = function (name, value) {
|
|
|
var attName, attValue;
|
|
|
if (name != null) {
|
|
|
name = getValue(name);
|
|
|
}
|
|
|
if (isObject(name)) {
|
|
|
for (attName in name) {
|
|
|
if (!hasProp.call(name, attName)) continue;
|
|
|
attValue = name[attName];
|
|
|
this.attribute(attName, attValue);
|
|
|
}
|
|
|
} else {
|
|
|
if (isFunction(value)) {
|
|
|
value = value.apply();
|
|
|
}
|
|
|
if (this.options.keepNullAttributes && value == null) {
|
|
|
this.attribs[name] = new XMLAttribute(this, name, "");
|
|
|
} else if (value != null) {
|
|
|
this.attribs[name] = new XMLAttribute(this, name, value);
|
|
|
}
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.removeAttribute = function (name) {
|
|
|
var attName, j, len;
|
|
|
if (name == null) {
|
|
|
throw new Error("Missing attribute name. " + this.debugInfo());
|
|
|
}
|
|
|
name = getValue(name);
|
|
|
if (Array.isArray(name)) {
|
|
|
for (j = 0, len = name.length; j < len; j++) {
|
|
|
attName = name[j];
|
|
|
delete this.attribs[attName];
|
|
|
}
|
|
|
} else {
|
|
|
delete this.attribs[name];
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.toString = function (options) {
|
|
|
return this.options.writer.element(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.att = function (name, value) {
|
|
|
return this.attribute(name, value);
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.a = function (name, value) {
|
|
|
return this.attribute(name, value);
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getAttribute = function (name) {
|
|
|
if (this.attribs.hasOwnProperty(name)) {
|
|
|
return this.attribs[name].value;
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.setAttribute = function (name, value) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getAttributeNode = function (name) {
|
|
|
if (this.attribs.hasOwnProperty(name)) {
|
|
|
return this.attribs[name];
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.setAttributeNode = function (newAttr) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.removeAttributeNode = function (oldAttr) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getElementsByTagName = function (name) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getAttributeNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.setAttributeNS = function (namespaceURI, qualifiedName, value) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.removeAttributeNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getAttributeNodeNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.setAttributeNodeNS = function (newAttr) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.hasAttribute = function (name) {
|
|
|
return this.attribs.hasOwnProperty(name);
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.hasAttributeNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.setIdAttribute = function (name, isId) {
|
|
|
if (this.attribs.hasOwnProperty(name)) {
|
|
|
return this.attribs[name].isId;
|
|
|
} else {
|
|
|
return isId;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.setIdAttributeNS = function (namespaceURI, localName, isId) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.setIdAttributeNode = function (idAttr, isId) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getElementsByTagName = function (tagname) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getElementsByTagNameNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.getElementsByClassName = function (classNames) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLElement.prototype.isEqualNode = function (node) {
|
|
|
var i, j, ref1;
|
|
|
if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.namespaceURI !== this.namespaceURI) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.prefix !== this.prefix) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.localName !== this.localName) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.attribs.length !== this.attribs.length) {
|
|
|
return false;
|
|
|
}
|
|
|
for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
|
|
|
if (!this.attribs[i].isEqualNode(node.attribs[i])) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
return XMLElement;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./Utility":252,"./XMLAttribute":254,"./XMLNamedNodeMap":272,"./XMLNode":273,"babel-runtime/core-js/object/create":55}],272:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
var _keys = require("babel-runtime/core-js/object/keys");
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLNamedNodeMap;
|
|
|
|
|
|
module.exports = XMLNamedNodeMap = function () {
|
|
|
function XMLNamedNodeMap(nodes) {
|
|
|
this.nodes = nodes;
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
|
|
|
get: function get() {
|
|
|
return (0, _keys2.default)(this.nodes).length || 0;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLNamedNodeMap.prototype.clone = function () {
|
|
|
return this.nodes = null;
|
|
|
};
|
|
|
|
|
|
XMLNamedNodeMap.prototype.getNamedItem = function (name) {
|
|
|
return this.nodes[name];
|
|
|
};
|
|
|
|
|
|
XMLNamedNodeMap.prototype.setNamedItem = function (node) {
|
|
|
var oldNode;
|
|
|
oldNode = this.nodes[node.nodeName];
|
|
|
this.nodes[node.nodeName] = node;
|
|
|
return oldNode || null;
|
|
|
};
|
|
|
|
|
|
XMLNamedNodeMap.prototype.removeNamedItem = function (name) {
|
|
|
var oldNode;
|
|
|
oldNode = this.nodes[name];
|
|
|
delete this.nodes[name];
|
|
|
return oldNode || null;
|
|
|
};
|
|
|
|
|
|
XMLNamedNodeMap.prototype.item = function (index) {
|
|
|
return this.nodes[(0, _keys2.default)(this.nodes)[index]] || null;
|
|
|
};
|
|
|
|
|
|
XMLNamedNodeMap.prototype.getNamedItemNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented.");
|
|
|
};
|
|
|
|
|
|
XMLNamedNodeMap.prototype.setNamedItemNS = function (node) {
|
|
|
throw new Error("This DOM method is not implemented.");
|
|
|
};
|
|
|
|
|
|
XMLNamedNodeMap.prototype.removeNamedItemNS = function (namespaceURI, localName) {
|
|
|
throw new Error("This DOM method is not implemented.");
|
|
|
};
|
|
|
|
|
|
return XMLNamedNodeMap;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"babel-runtime/core-js/object/keys":60}],273:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var DocumentPosition,
|
|
|
NodeType,
|
|
|
XMLCData,
|
|
|
XMLComment,
|
|
|
XMLDeclaration,
|
|
|
XMLDocType,
|
|
|
XMLDummy,
|
|
|
XMLElement,
|
|
|
XMLNamedNodeMap,
|
|
|
XMLNode,
|
|
|
XMLNodeList,
|
|
|
XMLProcessingInstruction,
|
|
|
XMLRaw,
|
|
|
XMLText,
|
|
|
getValue,
|
|
|
isEmpty,
|
|
|
isFunction,
|
|
|
isObject,
|
|
|
ref1,
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
ref1 = require('./Utility'), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
|
|
|
|
|
|
XMLElement = null;
|
|
|
|
|
|
XMLCData = null;
|
|
|
|
|
|
XMLComment = null;
|
|
|
|
|
|
XMLDeclaration = null;
|
|
|
|
|
|
XMLDocType = null;
|
|
|
|
|
|
XMLRaw = null;
|
|
|
|
|
|
XMLText = null;
|
|
|
|
|
|
XMLProcessingInstruction = null;
|
|
|
|
|
|
XMLDummy = null;
|
|
|
|
|
|
NodeType = null;
|
|
|
|
|
|
XMLNodeList = null;
|
|
|
|
|
|
XMLNamedNodeMap = null;
|
|
|
|
|
|
DocumentPosition = null;
|
|
|
|
|
|
module.exports = XMLNode = function () {
|
|
|
function XMLNode(parent1) {
|
|
|
this.parent = parent1;
|
|
|
if (this.parent) {
|
|
|
this.options = this.parent.options;
|
|
|
this.stringify = this.parent.stringify;
|
|
|
}
|
|
|
this.value = null;
|
|
|
this.children = [];
|
|
|
this.baseURI = null;
|
|
|
if (!XMLElement) {
|
|
|
XMLElement = require('./XMLElement');
|
|
|
XMLCData = require('./XMLCData');
|
|
|
XMLComment = require('./XMLComment');
|
|
|
XMLDeclaration = require('./XMLDeclaration');
|
|
|
XMLDocType = require('./XMLDocType');
|
|
|
XMLRaw = require('./XMLRaw');
|
|
|
XMLText = require('./XMLText');
|
|
|
XMLProcessingInstruction = require('./XMLProcessingInstruction');
|
|
|
XMLDummy = require('./XMLDummy');
|
|
|
NodeType = require('./NodeType');
|
|
|
XMLNodeList = require('./XMLNodeList');
|
|
|
XMLNamedNodeMap = require('./XMLNamedNodeMap');
|
|
|
DocumentPosition = require('./DocumentPosition');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'nodeName', {
|
|
|
get: function get() {
|
|
|
return this.name;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'nodeType', {
|
|
|
get: function get() {
|
|
|
return this.type;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'nodeValue', {
|
|
|
get: function get() {
|
|
|
return this.value;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'parentNode', {
|
|
|
get: function get() {
|
|
|
return this.parent;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'childNodes', {
|
|
|
get: function get() {
|
|
|
if (!this.childNodeList || !this.childNodeList.nodes) {
|
|
|
this.childNodeList = new XMLNodeList(this.children);
|
|
|
}
|
|
|
return this.childNodeList;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'firstChild', {
|
|
|
get: function get() {
|
|
|
return this.children[0] || null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'lastChild', {
|
|
|
get: function get() {
|
|
|
return this.children[this.children.length - 1] || null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'previousSibling', {
|
|
|
get: function get() {
|
|
|
var i;
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
return this.parent.children[i - 1] || null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'nextSibling', {
|
|
|
get: function get() {
|
|
|
var i;
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
return this.parent.children[i + 1] || null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
|
|
|
get: function get() {
|
|
|
return this.document() || null;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLNode.prototype, 'textContent', {
|
|
|
get: function get() {
|
|
|
var child, j, len, ref2, str;
|
|
|
if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
|
|
|
str = '';
|
|
|
ref2 = this.children;
|
|
|
for (j = 0, len = ref2.length; j < len; j++) {
|
|
|
child = ref2[j];
|
|
|
if (child.textContent) {
|
|
|
str += child.textContent;
|
|
|
}
|
|
|
}
|
|
|
return str;
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
},
|
|
|
set: function set(value) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLNode.prototype.setParent = function (parent) {
|
|
|
var child, j, len, ref2, results;
|
|
|
this.parent = parent;
|
|
|
if (parent) {
|
|
|
this.options = parent.options;
|
|
|
this.stringify = parent.stringify;
|
|
|
}
|
|
|
ref2 = this.children;
|
|
|
results = [];
|
|
|
for (j = 0, len = ref2.length; j < len; j++) {
|
|
|
child = ref2[j];
|
|
|
results.push(child.setParent(this));
|
|
|
}
|
|
|
return results;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.element = function (name, attributes, text) {
|
|
|
var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val;
|
|
|
lastChild = null;
|
|
|
if (attributes === null && text == null) {
|
|
|
ref2 = [{}, null], attributes = ref2[0], text = ref2[1];
|
|
|
}
|
|
|
if (attributes == null) {
|
|
|
attributes = {};
|
|
|
}
|
|
|
attributes = getValue(attributes);
|
|
|
if (!isObject(attributes)) {
|
|
|
ref3 = [attributes, text], text = ref3[0], attributes = ref3[1];
|
|
|
}
|
|
|
if (name != null) {
|
|
|
name = getValue(name);
|
|
|
}
|
|
|
if (Array.isArray(name)) {
|
|
|
for (j = 0, len = name.length; j < len; j++) {
|
|
|
item = name[j];
|
|
|
lastChild = this.element(item);
|
|
|
}
|
|
|
} else if (isFunction(name)) {
|
|
|
lastChild = this.element(name.apply());
|
|
|
} else if (isObject(name)) {
|
|
|
for (key in name) {
|
|
|
if (!hasProp.call(name, key)) continue;
|
|
|
val = name[key];
|
|
|
if (isFunction(val)) {
|
|
|
val = val.apply();
|
|
|
}
|
|
|
if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
|
|
|
lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
|
|
|
} else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
|
|
|
lastChild = this.dummy();
|
|
|
} else if (isObject(val) && isEmpty(val)) {
|
|
|
lastChild = this.element(key);
|
|
|
} else if (!this.options.keepNullNodes && val == null) {
|
|
|
lastChild = this.dummy();
|
|
|
} else if (!this.options.separateArrayItems && Array.isArray(val)) {
|
|
|
for (k = 0, len1 = val.length; k < len1; k++) {
|
|
|
item = val[k];
|
|
|
childNode = {};
|
|
|
childNode[key] = item;
|
|
|
lastChild = this.element(childNode);
|
|
|
}
|
|
|
} else if (isObject(val)) {
|
|
|
if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
|
|
|
lastChild = this.element(val);
|
|
|
} else {
|
|
|
lastChild = this.element(key);
|
|
|
lastChild.element(val);
|
|
|
}
|
|
|
} else {
|
|
|
lastChild = this.element(key, val);
|
|
|
}
|
|
|
}
|
|
|
} else if (!this.options.keepNullNodes && text === null) {
|
|
|
lastChild = this.dummy();
|
|
|
} else {
|
|
|
if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
|
|
|
lastChild = this.text(text);
|
|
|
} else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
|
|
|
lastChild = this.cdata(text);
|
|
|
} else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
|
|
|
lastChild = this.comment(text);
|
|
|
} else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
|
|
|
lastChild = this.raw(text);
|
|
|
} else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
|
|
|
lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
|
|
|
} else {
|
|
|
lastChild = this.node(name, attributes, text);
|
|
|
}
|
|
|
}
|
|
|
if (lastChild == null) {
|
|
|
throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
|
|
|
}
|
|
|
return lastChild;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.insertBefore = function (name, attributes, text) {
|
|
|
var child, i, newChild, refChild, removed;
|
|
|
if (name != null ? name.type : void 0) {
|
|
|
newChild = name;
|
|
|
refChild = attributes;
|
|
|
newChild.setParent(this);
|
|
|
if (refChild) {
|
|
|
i = children.indexOf(refChild);
|
|
|
removed = children.splice(i);
|
|
|
children.push(newChild);
|
|
|
Array.prototype.push.apply(children, removed);
|
|
|
} else {
|
|
|
children.push(newChild);
|
|
|
}
|
|
|
return newChild;
|
|
|
} else {
|
|
|
if (this.isRoot) {
|
|
|
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
|
|
|
}
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
removed = this.parent.children.splice(i);
|
|
|
child = this.parent.element(name, attributes, text);
|
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|
|
return child;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.insertAfter = function (name, attributes, text) {
|
|
|
var child, i, removed;
|
|
|
if (this.isRoot) {
|
|
|
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
|
|
|
}
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
removed = this.parent.children.splice(i + 1);
|
|
|
child = this.parent.element(name, attributes, text);
|
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|
|
return child;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.remove = function () {
|
|
|
var i, ref2;
|
|
|
if (this.isRoot) {
|
|
|
throw new Error("Cannot remove the root element. " + this.debugInfo());
|
|
|
}
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
[].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
|
|
|
return this.parent;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.node = function (name, attributes, text) {
|
|
|
var child, ref2;
|
|
|
if (name != null) {
|
|
|
name = getValue(name);
|
|
|
}
|
|
|
attributes || (attributes = {});
|
|
|
attributes = getValue(attributes);
|
|
|
if (!isObject(attributes)) {
|
|
|
ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
|
|
|
}
|
|
|
child = new XMLElement(this, name, attributes);
|
|
|
if (text != null) {
|
|
|
child.text(text);
|
|
|
}
|
|
|
this.children.push(child);
|
|
|
return child;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.text = function (value) {
|
|
|
var child;
|
|
|
if (isObject(value)) {
|
|
|
this.element(value);
|
|
|
}
|
|
|
child = new XMLText(this, value);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.cdata = function (value) {
|
|
|
var child;
|
|
|
child = new XMLCData(this, value);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.comment = function (value) {
|
|
|
var child;
|
|
|
child = new XMLComment(this, value);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.commentBefore = function (value) {
|
|
|
var child, i, removed;
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
removed = this.parent.children.splice(i);
|
|
|
child = this.parent.comment(value);
|
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.commentAfter = function (value) {
|
|
|
var child, i, removed;
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
removed = this.parent.children.splice(i + 1);
|
|
|
child = this.parent.comment(value);
|
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.raw = function (value) {
|
|
|
var child;
|
|
|
child = new XMLRaw(this, value);
|
|
|
this.children.push(child);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.dummy = function () {
|
|
|
var child;
|
|
|
child = new XMLDummy(this);
|
|
|
return child;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.instruction = function (target, value) {
|
|
|
var insTarget, insValue, instruction, j, len;
|
|
|
if (target != null) {
|
|
|
target = getValue(target);
|
|
|
}
|
|
|
if (value != null) {
|
|
|
value = getValue(value);
|
|
|
}
|
|
|
if (Array.isArray(target)) {
|
|
|
for (j = 0, len = target.length; j < len; j++) {
|
|
|
insTarget = target[j];
|
|
|
this.instruction(insTarget);
|
|
|
}
|
|
|
} else if (isObject(target)) {
|
|
|
for (insTarget in target) {
|
|
|
if (!hasProp.call(target, insTarget)) continue;
|
|
|
insValue = target[insTarget];
|
|
|
this.instruction(insTarget, insValue);
|
|
|
}
|
|
|
} else {
|
|
|
if (isFunction(value)) {
|
|
|
value = value.apply();
|
|
|
}
|
|
|
instruction = new XMLProcessingInstruction(this, target, value);
|
|
|
this.children.push(instruction);
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.instructionBefore = function (target, value) {
|
|
|
var child, i, removed;
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
removed = this.parent.children.splice(i);
|
|
|
child = this.parent.instruction(target, value);
|
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.instructionAfter = function (target, value) {
|
|
|
var child, i, removed;
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
removed = this.parent.children.splice(i + 1);
|
|
|
child = this.parent.instruction(target, value);
|
|
|
Array.prototype.push.apply(this.parent.children, removed);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.declaration = function (version, encoding, standalone) {
|
|
|
var doc, xmldec;
|
|
|
doc = this.document();
|
|
|
xmldec = new XMLDeclaration(doc, version, encoding, standalone);
|
|
|
if (doc.children.length === 0) {
|
|
|
doc.children.unshift(xmldec);
|
|
|
} else if (doc.children[0].type === NodeType.Declaration) {
|
|
|
doc.children[0] = xmldec;
|
|
|
} else {
|
|
|
doc.children.unshift(xmldec);
|
|
|
}
|
|
|
return doc.root() || doc;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.dtd = function (pubID, sysID) {
|
|
|
var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
|
|
|
doc = this.document();
|
|
|
doctype = new XMLDocType(doc, pubID, sysID);
|
|
|
ref2 = doc.children;
|
|
|
for (i = j = 0, len = ref2.length; j < len; i = ++j) {
|
|
|
child = ref2[i];
|
|
|
if (child.type === NodeType.DocType) {
|
|
|
doc.children[i] = doctype;
|
|
|
return doctype;
|
|
|
}
|
|
|
}
|
|
|
ref3 = doc.children;
|
|
|
for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
|
|
|
child = ref3[i];
|
|
|
if (child.isRoot) {
|
|
|
doc.children.splice(i, 0, doctype);
|
|
|
return doctype;
|
|
|
}
|
|
|
}
|
|
|
doc.children.push(doctype);
|
|
|
return doctype;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.up = function () {
|
|
|
if (this.isRoot) {
|
|
|
throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
|
|
|
}
|
|
|
return this.parent;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.root = function () {
|
|
|
var node;
|
|
|
node = this;
|
|
|
while (node) {
|
|
|
if (node.type === NodeType.Document) {
|
|
|
return node.rootObject;
|
|
|
} else if (node.isRoot) {
|
|
|
return node;
|
|
|
} else {
|
|
|
node = node.parent;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.document = function () {
|
|
|
var node;
|
|
|
node = this;
|
|
|
while (node) {
|
|
|
if (node.type === NodeType.Document) {
|
|
|
return node;
|
|
|
} else {
|
|
|
node = node.parent;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.end = function (options) {
|
|
|
return this.document().end(options);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.prev = function () {
|
|
|
var i;
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
if (i < 1) {
|
|
|
throw new Error("Already at the first node. " + this.debugInfo());
|
|
|
}
|
|
|
return this.parent.children[i - 1];
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.next = function () {
|
|
|
var i;
|
|
|
i = this.parent.children.indexOf(this);
|
|
|
if (i === -1 || i === this.parent.children.length - 1) {
|
|
|
throw new Error("Already at the last node. " + this.debugInfo());
|
|
|
}
|
|
|
return this.parent.children[i + 1];
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.importDocument = function (doc) {
|
|
|
var clonedRoot;
|
|
|
clonedRoot = doc.root().clone();
|
|
|
clonedRoot.parent = this;
|
|
|
clonedRoot.isRoot = false;
|
|
|
this.children.push(clonedRoot);
|
|
|
return this;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.debugInfo = function (name) {
|
|
|
var ref2, ref3;
|
|
|
name = name || this.name;
|
|
|
if (name == null && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
|
|
|
return "";
|
|
|
} else if (name == null) {
|
|
|
return "parent: <" + this.parent.name + ">";
|
|
|
} else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
|
|
|
return "node: <" + name + ">";
|
|
|
} else {
|
|
|
return "node: <" + name + ">, parent: <" + this.parent.name + ">";
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.ele = function (name, attributes, text) {
|
|
|
return this.element(name, attributes, text);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.nod = function (name, attributes, text) {
|
|
|
return this.node(name, attributes, text);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.txt = function (value) {
|
|
|
return this.text(value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.dat = function (value) {
|
|
|
return this.cdata(value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.com = function (value) {
|
|
|
return this.comment(value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.ins = function (target, value) {
|
|
|
return this.instruction(target, value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.doc = function () {
|
|
|
return this.document();
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.dec = function (version, encoding, standalone) {
|
|
|
return this.declaration(version, encoding, standalone);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.e = function (name, attributes, text) {
|
|
|
return this.element(name, attributes, text);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.n = function (name, attributes, text) {
|
|
|
return this.node(name, attributes, text);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.t = function (value) {
|
|
|
return this.text(value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.d = function (value) {
|
|
|
return this.cdata(value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.c = function (value) {
|
|
|
return this.comment(value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.r = function (value) {
|
|
|
return this.raw(value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.i = function (target, value) {
|
|
|
return this.instruction(target, value);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.u = function () {
|
|
|
return this.up();
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.importXMLBuilder = function (doc) {
|
|
|
return this.importDocument(doc);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.replaceChild = function (newChild, oldChild) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.removeChild = function (oldChild) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.appendChild = function (newChild) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.hasChildNodes = function () {
|
|
|
return this.children.length !== 0;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.cloneNode = function (deep) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.normalize = function () {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.isSupported = function (feature, version) {
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.hasAttributes = function () {
|
|
|
return this.attribs.length !== 0;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.compareDocumentPosition = function (other) {
|
|
|
var ref, res;
|
|
|
ref = this;
|
|
|
if (ref === other) {
|
|
|
return 0;
|
|
|
} else if (this.document() !== other.document()) {
|
|
|
res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
|
|
|
if (Math.random() < 0.5) {
|
|
|
res |= DocumentPosition.Preceding;
|
|
|
} else {
|
|
|
res |= DocumentPosition.Following;
|
|
|
}
|
|
|
return res;
|
|
|
} else if (ref.isAncestor(other)) {
|
|
|
return DocumentPosition.Contains | DocumentPosition.Preceding;
|
|
|
} else if (ref.isDescendant(other)) {
|
|
|
return DocumentPosition.Contains | DocumentPosition.Following;
|
|
|
} else if (ref.isPreceding(other)) {
|
|
|
return DocumentPosition.Preceding;
|
|
|
} else {
|
|
|
return DocumentPosition.Following;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.isSameNode = function (other) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.lookupPrefix = function (namespaceURI) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.isDefaultNamespace = function (namespaceURI) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.lookupNamespaceURI = function (prefix) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.isEqualNode = function (node) {
|
|
|
var i, j, ref2;
|
|
|
if (node.nodeType !== this.nodeType) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.children.length !== this.children.length) {
|
|
|
return false;
|
|
|
}
|
|
|
for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
|
|
|
if (!this.children[i].isEqualNode(node.children[i])) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.getFeature = function (feature, version) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.setUserData = function (key, data, handler) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.getUserData = function (key) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.contains = function (other) {
|
|
|
if (!other) {
|
|
|
return false;
|
|
|
}
|
|
|
return other === this || this.isDescendant(other);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.isDescendant = function (node) {
|
|
|
var child, isDescendantChild, j, len, ref2;
|
|
|
ref2 = this.children;
|
|
|
for (j = 0, len = ref2.length; j < len; j++) {
|
|
|
child = ref2[j];
|
|
|
if (node === child) {
|
|
|
return true;
|
|
|
}
|
|
|
isDescendantChild = child.isDescendant(node);
|
|
|
if (isDescendantChild) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.isAncestor = function (node) {
|
|
|
return node.isDescendant(this);
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.isPreceding = function (node) {
|
|
|
var nodePos, thisPos;
|
|
|
nodePos = this.treePosition(node);
|
|
|
thisPos = this.treePosition(this);
|
|
|
if (nodePos === -1 || thisPos === -1) {
|
|
|
return false;
|
|
|
} else {
|
|
|
return nodePos < thisPos;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.isFollowing = function (node) {
|
|
|
var nodePos, thisPos;
|
|
|
nodePos = this.treePosition(node);
|
|
|
thisPos = this.treePosition(this);
|
|
|
if (nodePos === -1 || thisPos === -1) {
|
|
|
return false;
|
|
|
} else {
|
|
|
return nodePos > thisPos;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.treePosition = function (node) {
|
|
|
var found, pos;
|
|
|
pos = 0;
|
|
|
found = false;
|
|
|
this.foreachTreeNode(this.document(), function (childNode) {
|
|
|
pos++;
|
|
|
if (!found && childNode === node) {
|
|
|
return found = true;
|
|
|
}
|
|
|
});
|
|
|
if (found) {
|
|
|
return pos;
|
|
|
} else {
|
|
|
return -1;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLNode.prototype.foreachTreeNode = function (node, func) {
|
|
|
var child, j, len, ref2, res;
|
|
|
node || (node = this.document());
|
|
|
ref2 = node.children;
|
|
|
for (j = 0, len = ref2.length; j < len; j++) {
|
|
|
child = ref2[j];
|
|
|
if (res = func(child)) {
|
|
|
return res;
|
|
|
} else {
|
|
|
res = this.foreachTreeNode(child, func);
|
|
|
if (res) {
|
|
|
return res;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
return XMLNode;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./DocumentPosition":250,"./NodeType":251,"./Utility":252,"./XMLCData":255,"./XMLComment":257,"./XMLDeclaration":266,"./XMLDocType":267,"./XMLDummy":270,"./XMLElement":271,"./XMLNamedNodeMap":272,"./XMLNodeList":274,"./XMLProcessingInstruction":275,"./XMLRaw":276,"./XMLText":280}],274:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLNodeList;
|
|
|
|
|
|
module.exports = XMLNodeList = function () {
|
|
|
function XMLNodeList(nodes) {
|
|
|
this.nodes = nodes;
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLNodeList.prototype, 'length', {
|
|
|
get: function get() {
|
|
|
return this.nodes.length || 0;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLNodeList.prototype.clone = function () {
|
|
|
return this.nodes = null;
|
|
|
};
|
|
|
|
|
|
XMLNodeList.prototype.item = function (index) {
|
|
|
return this.nodes[index] || null;
|
|
|
};
|
|
|
|
|
|
return XMLNodeList;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],275:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLCharacterData,
|
|
|
XMLProcessingInstruction,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLCharacterData = require('./XMLCharacterData');
|
|
|
|
|
|
module.exports = XMLProcessingInstruction = function (superClass) {
|
|
|
extend(XMLProcessingInstruction, superClass);
|
|
|
|
|
|
function XMLProcessingInstruction(parent, target, value) {
|
|
|
XMLProcessingInstruction.__super__.constructor.call(this, parent);
|
|
|
if (target == null) {
|
|
|
throw new Error("Missing instruction target. " + this.debugInfo());
|
|
|
}
|
|
|
this.type = NodeType.ProcessingInstruction;
|
|
|
this.target = this.stringify.insTarget(target);
|
|
|
this.name = this.target;
|
|
|
if (value) {
|
|
|
this.value = this.stringify.insValue(value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
XMLProcessingInstruction.prototype.clone = function () {
|
|
|
return (0, _create2.default)(this);
|
|
|
};
|
|
|
|
|
|
XMLProcessingInstruction.prototype.toString = function (options) {
|
|
|
return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
XMLProcessingInstruction.prototype.isEqualNode = function (node) {
|
|
|
if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
|
|
|
return false;
|
|
|
}
|
|
|
if (node.target !== this.target) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
return XMLProcessingInstruction;
|
|
|
}(XMLCharacterData);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLCharacterData":256,"babel-runtime/core-js/object/create":55}],276:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLNode,
|
|
|
XMLRaw,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLNode = require('./XMLNode');
|
|
|
|
|
|
module.exports = XMLRaw = function (superClass) {
|
|
|
extend(XMLRaw, superClass);
|
|
|
|
|
|
function XMLRaw(parent, text) {
|
|
|
XMLRaw.__super__.constructor.call(this, parent);
|
|
|
if (text == null) {
|
|
|
throw new Error("Missing raw text. " + this.debugInfo());
|
|
|
}
|
|
|
this.type = NodeType.Raw;
|
|
|
this.value = this.stringify.raw(text);
|
|
|
}
|
|
|
|
|
|
XMLRaw.prototype.clone = function () {
|
|
|
return (0, _create2.default)(this);
|
|
|
};
|
|
|
|
|
|
XMLRaw.prototype.toString = function (options) {
|
|
|
return this.options.writer.raw(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
return XMLRaw;
|
|
|
}(XMLNode);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLNode":273,"babel-runtime/core-js/object/create":55}],277:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
WriterState,
|
|
|
XMLStreamWriter,
|
|
|
XMLWriterBase,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLWriterBase = require('./XMLWriterBase');
|
|
|
|
|
|
WriterState = require('./WriterState');
|
|
|
|
|
|
module.exports = XMLStreamWriter = function (superClass) {
|
|
|
extend(XMLStreamWriter, superClass);
|
|
|
|
|
|
function XMLStreamWriter(stream, options) {
|
|
|
this.stream = stream;
|
|
|
XMLStreamWriter.__super__.constructor.call(this, options);
|
|
|
}
|
|
|
|
|
|
XMLStreamWriter.prototype.endline = function (node, options, level) {
|
|
|
if (node.isLastRootNode && options.state === WriterState.CloseTag) {
|
|
|
return '';
|
|
|
} else {
|
|
|
return XMLStreamWriter.__super__.endline.call(this, node, options, level);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.document = function (doc, options) {
|
|
|
var child, i, j, k, len, len1, ref, ref1, results;
|
|
|
ref = doc.children;
|
|
|
for (i = j = 0, len = ref.length; j < len; i = ++j) {
|
|
|
child = ref[i];
|
|
|
child.isLastRootNode = i === doc.children.length - 1;
|
|
|
}
|
|
|
options = this.filterOptions(options);
|
|
|
ref1 = doc.children;
|
|
|
results = [];
|
|
|
for (k = 0, len1 = ref1.length; k < len1; k++) {
|
|
|
child = ref1[k];
|
|
|
results.push(this.writeChildNode(child, options, 0));
|
|
|
}
|
|
|
return results;
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.attribute = function (att, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.cdata = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.comment = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.declaration = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.docType = function (node, options, level) {
|
|
|
var child, j, len, ref;
|
|
|
level || (level = 0);
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
this.stream.write(this.indent(node, options, level));
|
|
|
this.stream.write('<!DOCTYPE ' + node.root().name);
|
|
|
if (node.pubID && node.sysID) {
|
|
|
this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
|
|
|
} else if (node.sysID) {
|
|
|
this.stream.write(' SYSTEM "' + node.sysID + '"');
|
|
|
}
|
|
|
if (node.children.length > 0) {
|
|
|
this.stream.write(' [');
|
|
|
this.stream.write(this.endline(node, options, level));
|
|
|
options.state = WriterState.InsideTag;
|
|
|
ref = node.children;
|
|
|
for (j = 0, len = ref.length; j < len; j++) {
|
|
|
child = ref[j];
|
|
|
this.writeChildNode(child, options, level + 1);
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
this.stream.write(']');
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
this.stream.write(options.spaceBeforeSlash + '>');
|
|
|
this.stream.write(this.endline(node, options, level));
|
|
|
options.state = WriterState.None;
|
|
|
return this.closeNode(node, options, level);
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.element = function (node, options, level) {
|
|
|
var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1;
|
|
|
level || (level = 0);
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
this.stream.write(this.indent(node, options, level) + '<' + node.name);
|
|
|
ref = node.attribs;
|
|
|
for (name in ref) {
|
|
|
if (!hasProp.call(ref, name)) continue;
|
|
|
att = ref[name];
|
|
|
this.attribute(att, options, level);
|
|
|
}
|
|
|
childNodeCount = node.children.length;
|
|
|
firstChildNode = childNodeCount === 0 ? null : node.children[0];
|
|
|
if (childNodeCount === 0 || node.children.every(function (e) {
|
|
|
return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
|
|
|
})) {
|
|
|
if (options.allowEmpty) {
|
|
|
this.stream.write('>');
|
|
|
options.state = WriterState.CloseTag;
|
|
|
this.stream.write('</' + node.name + '>');
|
|
|
} else {
|
|
|
options.state = WriterState.CloseTag;
|
|
|
this.stream.write(options.spaceBeforeSlash + '/>');
|
|
|
}
|
|
|
} else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) {
|
|
|
this.stream.write('>');
|
|
|
options.state = WriterState.InsideTag;
|
|
|
options.suppressPrettyCount++;
|
|
|
prettySuppressed = true;
|
|
|
this.writeChildNode(firstChildNode, options, level + 1);
|
|
|
options.suppressPrettyCount--;
|
|
|
prettySuppressed = false;
|
|
|
options.state = WriterState.CloseTag;
|
|
|
this.stream.write('</' + node.name + '>');
|
|
|
} else {
|
|
|
this.stream.write('>' + this.endline(node, options, level));
|
|
|
options.state = WriterState.InsideTag;
|
|
|
ref1 = node.children;
|
|
|
for (j = 0, len = ref1.length; j < len; j++) {
|
|
|
child = ref1[j];
|
|
|
this.writeChildNode(child, options, level + 1);
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
|
|
|
}
|
|
|
this.stream.write(this.endline(node, options, level));
|
|
|
options.state = WriterState.None;
|
|
|
return this.closeNode(node, options, level);
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.processingInstruction = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.raw = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.text = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.dtdAttList = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.dtdElement = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.dtdEntity = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
XMLStreamWriter.prototype.dtdNotation = function (node, options, level) {
|
|
|
return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level));
|
|
|
};
|
|
|
|
|
|
return XMLStreamWriter;
|
|
|
}(XMLWriterBase);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./WriterState":253,"./XMLWriterBase":281}],278:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLStringWriter,
|
|
|
XMLWriterBase,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
XMLWriterBase = require('./XMLWriterBase');
|
|
|
|
|
|
module.exports = XMLStringWriter = function (superClass) {
|
|
|
extend(XMLStringWriter, superClass);
|
|
|
|
|
|
function XMLStringWriter(options) {
|
|
|
XMLStringWriter.__super__.constructor.call(this, options);
|
|
|
}
|
|
|
|
|
|
XMLStringWriter.prototype.document = function (doc, options) {
|
|
|
var child, i, len, r, ref;
|
|
|
options = this.filterOptions(options);
|
|
|
r = '';
|
|
|
ref = doc.children;
|
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
|
child = ref[i];
|
|
|
r += this.writeChildNode(child, options, 0);
|
|
|
}
|
|
|
if (options.pretty && r.slice(-options.newline.length) === options.newline) {
|
|
|
r = r.slice(0, -options.newline.length);
|
|
|
}
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
return XMLStringWriter;
|
|
|
}(XMLWriterBase);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./XMLWriterBase":281}],279:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var XMLStringifier,
|
|
|
bind = function bind(fn, me) {
|
|
|
return function () {
|
|
|
return fn.apply(me, arguments);
|
|
|
};
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
module.exports = XMLStringifier = function () {
|
|
|
function XMLStringifier(options) {
|
|
|
this.assertLegalName = bind(this.assertLegalName, this);
|
|
|
this.assertLegalChar = bind(this.assertLegalChar, this);
|
|
|
var key, ref, value;
|
|
|
options || (options = {});
|
|
|
this.options = options;
|
|
|
if (!this.options.version) {
|
|
|
this.options.version = '1.0';
|
|
|
}
|
|
|
ref = options.stringify || {};
|
|
|
for (key in ref) {
|
|
|
if (!hasProp.call(ref, key)) continue;
|
|
|
value = ref[key];
|
|
|
this[key] = value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
XMLStringifier.prototype.name = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalName('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.text = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar(this.textEscape('' + val || ''));
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.cdata = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
val = '' + val || '';
|
|
|
val = val.replace(']]>', ']]]]><![CDATA[>');
|
|
|
return this.assertLegalChar(val);
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.comment = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
val = '' + val || '';
|
|
|
if (val.match(/--/)) {
|
|
|
throw new Error("Comment text cannot contain double-hypen: " + val);
|
|
|
}
|
|
|
return this.assertLegalChar(val);
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.raw = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return '' + val || '';
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.attValue = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar(this.attEscape(val = '' + val || ''));
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.insTarget = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.insValue = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
val = '' + val || '';
|
|
|
if (val.match(/\?>/)) {
|
|
|
throw new Error("Invalid processing instruction value: " + val);
|
|
|
}
|
|
|
return this.assertLegalChar(val);
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.xmlVersion = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
val = '' + val || '';
|
|
|
if (!val.match(/1\.[0-9]+/)) {
|
|
|
throw new Error("Invalid version number: " + val);
|
|
|
}
|
|
|
return val;
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.xmlEncoding = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
val = '' + val || '';
|
|
|
if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
|
|
|
throw new Error("Invalid encoding: " + val);
|
|
|
}
|
|
|
return this.assertLegalChar(val);
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.xmlStandalone = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
if (val) {
|
|
|
return "yes";
|
|
|
} else {
|
|
|
return "no";
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.dtdPubID = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.dtdSysID = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.dtdElementValue = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.dtdAttType = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.dtdAttDefault = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.dtdEntityValue = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.dtdNData = function (val) {
|
|
|
if (this.options.noValidation) {
|
|
|
return val;
|
|
|
}
|
|
|
return this.assertLegalChar('' + val || '');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.convertAttKey = '@';
|
|
|
|
|
|
XMLStringifier.prototype.convertPIKey = '?';
|
|
|
|
|
|
XMLStringifier.prototype.convertTextKey = '#text';
|
|
|
|
|
|
XMLStringifier.prototype.convertCDataKey = '#cdata';
|
|
|
|
|
|
XMLStringifier.prototype.convertCommentKey = '#comment';
|
|
|
|
|
|
XMLStringifier.prototype.convertRawKey = '#raw';
|
|
|
|
|
|
XMLStringifier.prototype.assertLegalChar = function (str) {
|
|
|
var regex, res;
|
|
|
if (this.options.noValidation) {
|
|
|
return str;
|
|
|
}
|
|
|
regex = '';
|
|
|
if (this.options.version === '1.0') {
|
|
|
regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
|
if (res = str.match(regex)) {
|
|
|
throw new Error("Invalid character in string: " + str + " at index " + res.index);
|
|
|
}
|
|
|
} else if (this.options.version === '1.1') {
|
|
|
regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
|
if (res = str.match(regex)) {
|
|
|
throw new Error("Invalid character in string: " + str + " at index " + res.index);
|
|
|
}
|
|
|
}
|
|
|
return str;
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.assertLegalName = function (str) {
|
|
|
var regex;
|
|
|
if (this.options.noValidation) {
|
|
|
return str;
|
|
|
}
|
|
|
this.assertLegalChar(str);
|
|
|
regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
|
|
|
if (!str.match(regex)) {
|
|
|
throw new Error("Invalid character in name");
|
|
|
}
|
|
|
return str;
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.textEscape = function (str) {
|
|
|
var ampregex;
|
|
|
if (this.options.noValidation) {
|
|
|
return str;
|
|
|
}
|
|
|
ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
|
|
|
return str.replace(ampregex, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\r/g, '
');
|
|
|
};
|
|
|
|
|
|
XMLStringifier.prototype.attEscape = function (str) {
|
|
|
var ampregex;
|
|
|
if (this.options.noValidation) {
|
|
|
return str;
|
|
|
}
|
|
|
ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
|
|
|
return str.replace(ampregex, '&').replace(/</g, '<').replace(/"/g, '"').replace(/\t/g, '	').replace(/\n/g, '
').replace(/\r/g, '
');
|
|
|
};
|
|
|
|
|
|
return XMLStringifier;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{}],280:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var _create = require('babel-runtime/core-js/object/create');
|
|
|
|
|
|
var _create2 = _interopRequireDefault(_create);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
XMLCharacterData,
|
|
|
XMLText,
|
|
|
extend = function extend(child, parent) {
|
|
|
for (var key in parent) {
|
|
|
if (hasProp.call(parent, key)) child[key] = parent[key];
|
|
|
}function ctor() {
|
|
|
this.constructor = child;
|
|
|
}ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
|
|
|
},
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLCharacterData = require('./XMLCharacterData');
|
|
|
|
|
|
module.exports = XMLText = function (superClass) {
|
|
|
extend(XMLText, superClass);
|
|
|
|
|
|
function XMLText(parent, text) {
|
|
|
XMLText.__super__.constructor.call(this, parent);
|
|
|
if (text == null) {
|
|
|
throw new Error("Missing element text. " + this.debugInfo());
|
|
|
}
|
|
|
this.name = "#text";
|
|
|
this.type = NodeType.Text;
|
|
|
this.value = this.stringify.text(text);
|
|
|
}
|
|
|
|
|
|
Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
|
|
|
get: function get() {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Object.defineProperty(XMLText.prototype, 'wholeText', {
|
|
|
get: function get() {
|
|
|
var next, prev, str;
|
|
|
str = '';
|
|
|
prev = this.previousSibling;
|
|
|
while (prev) {
|
|
|
str = prev.data + str;
|
|
|
prev = prev.previousSibling;
|
|
|
}
|
|
|
str += this.data;
|
|
|
next = this.nextSibling;
|
|
|
while (next) {
|
|
|
str = str + next.data;
|
|
|
next = next.nextSibling;
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
XMLText.prototype.clone = function () {
|
|
|
return (0, _create2.default)(this);
|
|
|
};
|
|
|
|
|
|
XMLText.prototype.toString = function (options) {
|
|
|
return this.options.writer.text(this, this.options.writer.filterOptions(options));
|
|
|
};
|
|
|
|
|
|
XMLText.prototype.splitText = function (offset) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
XMLText.prototype.replaceWholeText = function (content) {
|
|
|
throw new Error("This DOM method is not implemented." + this.debugInfo());
|
|
|
};
|
|
|
|
|
|
return XMLText;
|
|
|
}(XMLCharacterData);
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./XMLCharacterData":256,"babel-runtime/core-js/object/create":55}],281:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType,
|
|
|
WriterState,
|
|
|
XMLCData,
|
|
|
XMLComment,
|
|
|
XMLDTDAttList,
|
|
|
XMLDTDElement,
|
|
|
XMLDTDEntity,
|
|
|
XMLDTDNotation,
|
|
|
XMLDeclaration,
|
|
|
XMLDocType,
|
|
|
XMLDummy,
|
|
|
XMLElement,
|
|
|
XMLProcessingInstruction,
|
|
|
XMLRaw,
|
|
|
XMLText,
|
|
|
XMLWriterBase,
|
|
|
assign,
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
assign = require('./Utility').assign;
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
XMLDeclaration = require('./XMLDeclaration');
|
|
|
|
|
|
XMLDocType = require('./XMLDocType');
|
|
|
|
|
|
XMLCData = require('./XMLCData');
|
|
|
|
|
|
XMLComment = require('./XMLComment');
|
|
|
|
|
|
XMLElement = require('./XMLElement');
|
|
|
|
|
|
XMLRaw = require('./XMLRaw');
|
|
|
|
|
|
XMLText = require('./XMLText');
|
|
|
|
|
|
XMLProcessingInstruction = require('./XMLProcessingInstruction');
|
|
|
|
|
|
XMLDummy = require('./XMLDummy');
|
|
|
|
|
|
XMLDTDAttList = require('./XMLDTDAttList');
|
|
|
|
|
|
XMLDTDElement = require('./XMLDTDElement');
|
|
|
|
|
|
XMLDTDEntity = require('./XMLDTDEntity');
|
|
|
|
|
|
XMLDTDNotation = require('./XMLDTDNotation');
|
|
|
|
|
|
WriterState = require('./WriterState');
|
|
|
|
|
|
module.exports = XMLWriterBase = function () {
|
|
|
function XMLWriterBase(options) {
|
|
|
var key, ref, value;
|
|
|
options || (options = {});
|
|
|
this.options = options;
|
|
|
ref = options.writer || {};
|
|
|
for (key in ref) {
|
|
|
if (!hasProp.call(ref, key)) continue;
|
|
|
value = ref[key];
|
|
|
this["_" + key] = this[key];
|
|
|
this[key] = value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
XMLWriterBase.prototype.filterOptions = function (options) {
|
|
|
var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6;
|
|
|
options || (options = {});
|
|
|
options = assign({}, this.options, options);
|
|
|
filteredOptions = {
|
|
|
writer: this
|
|
|
};
|
|
|
filteredOptions.pretty = options.pretty || false;
|
|
|
filteredOptions.allowEmpty = options.allowEmpty || false;
|
|
|
filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
|
|
|
filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
|
|
|
filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
|
|
|
filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0;
|
|
|
filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : '';
|
|
|
if (filteredOptions.spaceBeforeSlash === true) {
|
|
|
filteredOptions.spaceBeforeSlash = ' ';
|
|
|
}
|
|
|
filteredOptions.suppressPrettyCount = 0;
|
|
|
filteredOptions.user = {};
|
|
|
filteredOptions.state = WriterState.None;
|
|
|
return filteredOptions;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.indent = function (node, options, level) {
|
|
|
var indentLevel;
|
|
|
if (!options.pretty || options.suppressPrettyCount) {
|
|
|
return '';
|
|
|
} else if (options.pretty) {
|
|
|
indentLevel = (level || 0) + options.offset + 1;
|
|
|
if (indentLevel > 0) {
|
|
|
return new Array(indentLevel).join(options.indent);
|
|
|
}
|
|
|
}
|
|
|
return '';
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.endline = function (node, options, level) {
|
|
|
if (!options.pretty || options.suppressPrettyCount) {
|
|
|
return '';
|
|
|
} else {
|
|
|
return options.newline;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.attribute = function (att, options, level) {
|
|
|
var r;
|
|
|
this.openAttribute(att, options, level);
|
|
|
r = ' ' + att.name + '="' + att.value + '"';
|
|
|
this.closeAttribute(att, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.cdata = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level) + '<![CDATA[';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += node.value;
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += ']]>' + this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.comment = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level) + '<!-- ';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += node.value;
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += ' -->' + this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.declaration = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level) + '<?xml';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += ' version="' + node.version + '"';
|
|
|
if (node.encoding != null) {
|
|
|
r += ' encoding="' + node.encoding + '"';
|
|
|
}
|
|
|
if (node.standalone != null) {
|
|
|
r += ' standalone="' + node.standalone + '"';
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += options.spaceBeforeSlash + '?>';
|
|
|
r += this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.docType = function (node, options, level) {
|
|
|
var child, i, len, r, ref;
|
|
|
level || (level = 0);
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level);
|
|
|
r += '<!DOCTYPE ' + node.root().name;
|
|
|
if (node.pubID && node.sysID) {
|
|
|
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
|
|
|
} else if (node.sysID) {
|
|
|
r += ' SYSTEM "' + node.sysID + '"';
|
|
|
}
|
|
|
if (node.children.length > 0) {
|
|
|
r += ' [';
|
|
|
r += this.endline(node, options, level);
|
|
|
options.state = WriterState.InsideTag;
|
|
|
ref = node.children;
|
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
|
child = ref[i];
|
|
|
r += this.writeChildNode(child, options, level + 1);
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += ']';
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += options.spaceBeforeSlash + '>';
|
|
|
r += this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.element = function (node, options, level) {
|
|
|
var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
|
|
|
level || (level = 0);
|
|
|
prettySuppressed = false;
|
|
|
r = '';
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r += this.indent(node, options, level) + '<' + node.name;
|
|
|
ref = node.attribs;
|
|
|
for (name in ref) {
|
|
|
if (!hasProp.call(ref, name)) continue;
|
|
|
att = ref[name];
|
|
|
r += this.attribute(att, options, level);
|
|
|
}
|
|
|
childNodeCount = node.children.length;
|
|
|
firstChildNode = childNodeCount === 0 ? null : node.children[0];
|
|
|
if (childNodeCount === 0 || node.children.every(function (e) {
|
|
|
return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
|
|
|
})) {
|
|
|
if (options.allowEmpty) {
|
|
|
r += '>';
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += '</' + node.name + '>' + this.endline(node, options, level);
|
|
|
} else {
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
|
|
|
}
|
|
|
} else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) {
|
|
|
r += '>';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
options.suppressPrettyCount++;
|
|
|
prettySuppressed = true;
|
|
|
r += this.writeChildNode(firstChildNode, options, level + 1);
|
|
|
options.suppressPrettyCount--;
|
|
|
prettySuppressed = false;
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += '</' + node.name + '>' + this.endline(node, options, level);
|
|
|
} else {
|
|
|
if (options.dontPrettyTextNodes) {
|
|
|
ref1 = node.children;
|
|
|
for (i = 0, len = ref1.length; i < len; i++) {
|
|
|
child = ref1[i];
|
|
|
if ((child.type === NodeType.Text || child.type === NodeType.Raw) && child.value != null) {
|
|
|
options.suppressPrettyCount++;
|
|
|
prettySuppressed = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
r += '>' + this.endline(node, options, level);
|
|
|
options.state = WriterState.InsideTag;
|
|
|
ref2 = node.children;
|
|
|
for (j = 0, len1 = ref2.length; j < len1; j++) {
|
|
|
child = ref2[j];
|
|
|
r += this.writeChildNode(child, options, level + 1);
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += this.indent(node, options, level) + '</' + node.name + '>';
|
|
|
if (prettySuppressed) {
|
|
|
options.suppressPrettyCount--;
|
|
|
}
|
|
|
r += this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
}
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.writeChildNode = function (node, options, level) {
|
|
|
switch (node.type) {
|
|
|
case NodeType.CData:
|
|
|
return this.cdata(node, options, level);
|
|
|
case NodeType.Comment:
|
|
|
return this.comment(node, options, level);
|
|
|
case NodeType.Element:
|
|
|
return this.element(node, options, level);
|
|
|
case NodeType.Raw:
|
|
|
return this.raw(node, options, level);
|
|
|
case NodeType.Text:
|
|
|
return this.text(node, options, level);
|
|
|
case NodeType.ProcessingInstruction:
|
|
|
return this.processingInstruction(node, options, level);
|
|
|
case NodeType.Dummy:
|
|
|
return '';
|
|
|
case NodeType.Declaration:
|
|
|
return this.declaration(node, options, level);
|
|
|
case NodeType.DocType:
|
|
|
return this.docType(node, options, level);
|
|
|
case NodeType.AttributeDeclaration:
|
|
|
return this.dtdAttList(node, options, level);
|
|
|
case NodeType.ElementDeclaration:
|
|
|
return this.dtdElement(node, options, level);
|
|
|
case NodeType.EntityDeclaration:
|
|
|
return this.dtdEntity(node, options, level);
|
|
|
case NodeType.NotationDeclaration:
|
|
|
return this.dtdNotation(node, options, level);
|
|
|
default:
|
|
|
throw new Error("Unknown XML node type: " + node.constructor.name);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.processingInstruction = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level) + '<?';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += node.target;
|
|
|
if (node.value) {
|
|
|
r += ' ' + node.value;
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += options.spaceBeforeSlash + '?>';
|
|
|
r += this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.raw = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level);
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += node.value;
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.text = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level);
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += node.value;
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.dtdAttList = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level) + '<!ATTLIST';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
|
|
|
if (node.defaultValueType !== '#DEFAULT') {
|
|
|
r += ' ' + node.defaultValueType;
|
|
|
}
|
|
|
if (node.defaultValue) {
|
|
|
r += ' "' + node.defaultValue + '"';
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.dtdElement = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level) + '<!ELEMENT';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += ' ' + node.name + ' ' + node.value;
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.dtdEntity = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level) + '<!ENTITY';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
if (node.pe) {
|
|
|
r += ' %';
|
|
|
}
|
|
|
r += ' ' + node.name;
|
|
|
if (node.value) {
|
|
|
r += ' "' + node.value + '"';
|
|
|
} else {
|
|
|
if (node.pubID && node.sysID) {
|
|
|
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
|
|
|
} else if (node.sysID) {
|
|
|
r += ' SYSTEM "' + node.sysID + '"';
|
|
|
}
|
|
|
if (node.nData) {
|
|
|
r += ' NDATA ' + node.nData;
|
|
|
}
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.dtdNotation = function (node, options, level) {
|
|
|
var r;
|
|
|
this.openNode(node, options, level);
|
|
|
options.state = WriterState.OpenTag;
|
|
|
r = this.indent(node, options, level) + '<!NOTATION';
|
|
|
options.state = WriterState.InsideTag;
|
|
|
r += ' ' + node.name;
|
|
|
if (node.pubID && node.sysID) {
|
|
|
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
|
|
|
} else if (node.pubID) {
|
|
|
r += ' PUBLIC "' + node.pubID + '"';
|
|
|
} else if (node.sysID) {
|
|
|
r += ' SYSTEM "' + node.sysID + '"';
|
|
|
}
|
|
|
options.state = WriterState.CloseTag;
|
|
|
r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
|
|
|
options.state = WriterState.None;
|
|
|
this.closeNode(node, options, level);
|
|
|
return r;
|
|
|
};
|
|
|
|
|
|
XMLWriterBase.prototype.openNode = function (node, options, level) {};
|
|
|
|
|
|
XMLWriterBase.prototype.closeNode = function (node, options, level) {};
|
|
|
|
|
|
XMLWriterBase.prototype.openAttribute = function (att, options, level) {};
|
|
|
|
|
|
XMLWriterBase.prototype.closeAttribute = function (att, options, level) {};
|
|
|
|
|
|
return XMLWriterBase;
|
|
|
}();
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./Utility":252,"./WriterState":253,"./XMLCData":255,"./XMLComment":257,"./XMLDTDAttList":262,"./XMLDTDElement":263,"./XMLDTDEntity":264,"./XMLDTDNotation":265,"./XMLDeclaration":266,"./XMLDocType":267,"./XMLDummy":270,"./XMLElement":271,"./XMLProcessingInstruction":275,"./XMLRaw":276,"./XMLText":280}],282:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// Generated by CoffeeScript 1.12.7
|
|
|
(function () {
|
|
|
var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
|
|
|
|
|
|
ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
|
|
|
|
|
|
XMLDOMImplementation = require('./XMLDOMImplementation');
|
|
|
|
|
|
XMLDocument = require('./XMLDocument');
|
|
|
|
|
|
XMLDocumentCB = require('./XMLDocumentCB');
|
|
|
|
|
|
XMLStringWriter = require('./XMLStringWriter');
|
|
|
|
|
|
XMLStreamWriter = require('./XMLStreamWriter');
|
|
|
|
|
|
NodeType = require('./NodeType');
|
|
|
|
|
|
WriterState = require('./WriterState');
|
|
|
|
|
|
module.exports.create = function (name, xmldec, doctype, options) {
|
|
|
var doc, root;
|
|
|
if (name == null) {
|
|
|
throw new Error("Root element needs a name.");
|
|
|
}
|
|
|
options = assign({}, xmldec, doctype, options);
|
|
|
doc = new XMLDocument(options);
|
|
|
root = doc.element(name);
|
|
|
if (!options.headless) {
|
|
|
doc.declaration(options);
|
|
|
if (options.pubID != null || options.sysID != null) {
|
|
|
doc.dtd(options);
|
|
|
}
|
|
|
}
|
|
|
return root;
|
|
|
};
|
|
|
|
|
|
module.exports.begin = function (options, onData, onEnd) {
|
|
|
var ref1;
|
|
|
if (isFunction(options)) {
|
|
|
ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
|
|
|
options = {};
|
|
|
}
|
|
|
if (onData) {
|
|
|
return new XMLDocumentCB(options, onData, onEnd);
|
|
|
} else {
|
|
|
return new XMLDocument(options);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports.stringWriter = function (options) {
|
|
|
return new XMLStringWriter(options);
|
|
|
};
|
|
|
|
|
|
module.exports.streamWriter = function (stream, options) {
|
|
|
return new XMLStreamWriter(stream, options);
|
|
|
};
|
|
|
|
|
|
module.exports.implementation = new XMLDOMImplementation();
|
|
|
|
|
|
module.exports.nodeType = NodeType;
|
|
|
|
|
|
module.exports.writerState = WriterState;
|
|
|
}).call(undefined);
|
|
|
|
|
|
},{"./NodeType":251,"./Utility":252,"./WriterState":253,"./XMLDOMImplementation":260,"./XMLDocument":268,"./XMLDocumentCB":269,"./XMLStreamWriter":277,"./XMLStringWriter":278}],283:[function(require,module,exports){
|
|
|
module.exports = extend
|
|
|
|
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
|
|
|
function extend() {
|
|
|
var target = {}
|
|
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
|
var source = arguments[i]
|
|
|
|
|
|
for (var key in source) {
|
|
|
if (hasOwnProperty.call(source, key)) {
|
|
|
target[key] = source[key]
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return target
|
|
|
}
|
|
|
|
|
|
},{}],284:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var Buffer = require('buffer').Buffer;
|
|
|
var sha = require('./sha');
|
|
|
var md5 = require('./md5');
|
|
|
|
|
|
var algorithms = {
|
|
|
sha1: sha,
|
|
|
md5: md5
|
|
|
};
|
|
|
|
|
|
var blocksize = 64;
|
|
|
var zeroBuffer = Buffer.alloc(blocksize);
|
|
|
zeroBuffer.fill(0);
|
|
|
|
|
|
function hmac(fn, key, data) {
|
|
|
if (!Buffer.isBuffer(key)) key = Buffer.from(key);
|
|
|
if (!Buffer.isBuffer(data)) data = Buffer.from(data);
|
|
|
|
|
|
if (key.length > blocksize) {
|
|
|
key = fn(key);
|
|
|
} else if (key.length < blocksize) {
|
|
|
key = Buffer.concat([key, zeroBuffer], blocksize);
|
|
|
}
|
|
|
|
|
|
var ipad = Buffer.alloc(blocksize),
|
|
|
opad = Buffer.alloc(blocksize);
|
|
|
for (var i = 0; i < blocksize; i++) {
|
|
|
ipad[i] = key[i] ^ 0x36;
|
|
|
opad[i] = key[i] ^ 0x5C;
|
|
|
}
|
|
|
|
|
|
var hash = fn(Buffer.concat([ipad, data]));
|
|
|
return fn(Buffer.concat([opad, hash]));
|
|
|
}
|
|
|
|
|
|
function hash(alg, key) {
|
|
|
alg = alg || 'sha1';
|
|
|
var fn = algorithms[alg];
|
|
|
var bufs = [];
|
|
|
var length = 0;
|
|
|
if (!fn) error('algorithm:', alg, 'is not yet supported');
|
|
|
return {
|
|
|
update: function update(data) {
|
|
|
if (!Buffer.isBuffer(data)) data = Buffer.from(data);
|
|
|
|
|
|
bufs.push(data);
|
|
|
length += data.length;
|
|
|
return this;
|
|
|
},
|
|
|
digest: function digest(enc) {
|
|
|
var buf = Buffer.concat(bufs);
|
|
|
var r = key ? hmac(fn, key, buf) : fn(buf);
|
|
|
bufs = null;
|
|
|
return enc ? r.toString(enc) : r;
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function error() {
|
|
|
var m = [].slice.call(arguments).join(' ');
|
|
|
throw new Error([m, 'we accept pull requests', 'http://github.com/dominictarr/crypto-browserify'].join('\n'));
|
|
|
}
|
|
|
|
|
|
exports.createHash = function (alg) {
|
|
|
return hash(alg);
|
|
|
};
|
|
|
exports.createHmac = function (alg, key) {
|
|
|
return hash(alg, key);
|
|
|
};
|
|
|
|
|
|
exports.createCredentials = function () {
|
|
|
error('sorry,createCredentials is not implemented yet');
|
|
|
};
|
|
|
exports.createCipher = function () {
|
|
|
error('sorry,createCipher is not implemented yet');
|
|
|
};
|
|
|
exports.createCipheriv = function () {
|
|
|
error('sorry,createCipheriv is not implemented yet');
|
|
|
};
|
|
|
exports.createDecipher = function () {
|
|
|
error('sorry,createDecipher is not implemented yet');
|
|
|
};
|
|
|
exports.createDecipheriv = function () {
|
|
|
error('sorry,createDecipheriv is not implemented yet');
|
|
|
};
|
|
|
exports.createSign = function () {
|
|
|
error('sorry,createSign is not implemented yet');
|
|
|
};
|
|
|
exports.createVerify = function () {
|
|
|
error('sorry,createVerify is not implemented yet');
|
|
|
};
|
|
|
exports.createDiffieHellman = function () {
|
|
|
error('sorry,createDiffieHellman is not implemented yet');
|
|
|
};
|
|
|
exports.pbkdf2 = function () {
|
|
|
error('sorry,pbkdf2 is not implemented yet');
|
|
|
};
|
|
|
|
|
|
},{"./md5":286,"./sha":287,"buffer":73}],285:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
var Buffer = require('buffer').Buffer;
|
|
|
var intSize = 4;
|
|
|
var zeroBuffer = Buffer.alloc(intSize);zeroBuffer.fill(0);
|
|
|
var chrsz = 8;
|
|
|
|
|
|
function toArray(buf, bigEndian) {
|
|
|
if (buf.length % intSize !== 0) {
|
|
|
var len = buf.length + (intSize - buf.length % intSize);
|
|
|
buf = Buffer.concat([buf, zeroBuffer], len);
|
|
|
}
|
|
|
|
|
|
var arr = [];
|
|
|
var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
|
|
|
for (var i = 0; i < buf.length; i += intSize) {
|
|
|
arr.push(fn.call(buf, i));
|
|
|
}
|
|
|
return arr;
|
|
|
}
|
|
|
|
|
|
function toBuffer(arr, size, bigEndian) {
|
|
|
var buf = Buffer.alloc(size);
|
|
|
var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
|
|
|
for (var i = 0; i < arr.length; i++) {
|
|
|
fn.call(buf, arr[i], i * 4, true);
|
|
|
}
|
|
|
return buf;
|
|
|
}
|
|
|
|
|
|
function hash(buf, fn, hashSize, bigEndian) {
|
|
|
if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
|
|
|
var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
|
|
|
return toBuffer(arr, hashSize, bigEndian);
|
|
|
}
|
|
|
|
|
|
module.exports = { hash: hash };
|
|
|
|
|
|
},{"buffer":73}],286:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
/*
|
|
|
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
|
|
* Digest Algorithm, as defined in RFC 1321.
|
|
|
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
|
|
|
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
|
|
* Distributed under the BSD License
|
|
|
* See http://pajhome.org.uk/crypt/md5 for more info.
|
|
|
*/
|
|
|
|
|
|
var helpers = require('./helpers');
|
|
|
|
|
|
/*
|
|
|
* Perform a simple self-test to see if the VM is working
|
|
|
*/
|
|
|
function md5_vm_test() {
|
|
|
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Calculate the MD5 of an array of little-endian words, and a bit length
|
|
|
*/
|
|
|
function core_md5(x, len) {
|
|
|
/* append padding */
|
|
|
x[len >> 5] |= 0x80 << len % 32;
|
|
|
x[(len + 64 >>> 9 << 4) + 14] = len;
|
|
|
|
|
|
var a = 1732584193;
|
|
|
var b = -271733879;
|
|
|
var c = -1732584194;
|
|
|
var d = 271733878;
|
|
|
|
|
|
for (var i = 0; i < x.length; i += 16) {
|
|
|
var olda = a;
|
|
|
var oldb = b;
|
|
|
var oldc = c;
|
|
|
var oldd = d;
|
|
|
|
|
|
a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
|
|
|
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
|
|
|
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
|
|
|
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
|
|
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
|
|
|
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
|
|
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
|
|
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
|
|
|
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
|
|
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
|
|
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
|
|
|
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
|
|
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
|
|
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
|
|
|
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
|
|
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
|
|
|
|
|
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
|
|
|
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
|
|
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
|
|
|
b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
|
|
|
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
|
|
|
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
|
|
|
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
|
|
|
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
|
|
|
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
|
|
|
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
|
|
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
|
|
|
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
|
|
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
|
|
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
|
|
|
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
|
|
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
|
|
|
|
|
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
|
|
|
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
|
|
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
|
|
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
|
|
|
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
|
|
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
|
|
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
|
|
|
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
|
|
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
|
|
|
d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
|
|
|
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
|
|
|
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
|
|
|
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
|
|
|
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
|
|
|
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
|
|
|
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
|
|
|
|
|
|
a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
|
|
|
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
|
|
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
|
|
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
|
|
|
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
|
|
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
|
|
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
|
|
|
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
|
|
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
|
|
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
|
|
|
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
|
|
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
|
|
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
|
|
|
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
|
|
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
|
|
|
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
|
|
|
|
|
|
a = safe_add(a, olda);
|
|
|
b = safe_add(b, oldb);
|
|
|
c = safe_add(c, oldc);
|
|
|
d = safe_add(d, oldd);
|
|
|
}
|
|
|
return Array(a, b, c, d);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* These functions implement the four basic operations the algorithm uses.
|
|
|
*/
|
|
|
function md5_cmn(q, a, b, x, s, t) {
|
|
|
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
|
|
|
}
|
|
|
function md5_ff(a, b, c, d, x, s, t) {
|
|
|
return md5_cmn(b & c | ~b & d, a, b, x, s, t);
|
|
|
}
|
|
|
function md5_gg(a, b, c, d, x, s, t) {
|
|
|
return md5_cmn(b & d | c & ~d, a, b, x, s, t);
|
|
|
}
|
|
|
function md5_hh(a, b, c, d, x, s, t) {
|
|
|
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
|
|
}
|
|
|
function md5_ii(a, b, c, d, x, s, t) {
|
|
|
return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
|
|
* to work around bugs in some JS interpreters.
|
|
|
*/
|
|
|
function safe_add(x, y) {
|
|
|
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
|
|
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
|
return msw << 16 | lsw & 0xFFFF;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Bitwise rotate a 32-bit number to the left.
|
|
|
*/
|
|
|
function bit_rol(num, cnt) {
|
|
|
return num << cnt | num >>> 32 - cnt;
|
|
|
}
|
|
|
|
|
|
module.exports = function md5(buf) {
|
|
|
return helpers.hash(buf, core_md5, 16);
|
|
|
};
|
|
|
|
|
|
},{"./helpers":285}],287:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
/*
|
|
|
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
|
|
|
* in FIPS PUB 180-1
|
|
|
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
|
|
|
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
|
|
* Distributed under the BSD License
|
|
|
* See http://pajhome.org.uk/crypt/md5 for details.
|
|
|
*/
|
|
|
|
|
|
var helpers = require('./helpers');
|
|
|
|
|
|
/*
|
|
|
* Calculate the SHA-1 of an array of big-endian words, and a bit length
|
|
|
*/
|
|
|
function core_sha1(x, len) {
|
|
|
/* append padding */
|
|
|
x[len >> 5] |= 0x80 << 24 - len % 32;
|
|
|
x[(len + 64 >> 9 << 4) + 15] = len;
|
|
|
|
|
|
var w = Array(80);
|
|
|
var a = 1732584193;
|
|
|
var b = -271733879;
|
|
|
var c = -1732584194;
|
|
|
var d = 271733878;
|
|
|
var e = -1009589776;
|
|
|
|
|
|
for (var i = 0; i < x.length; i += 16) {
|
|
|
var olda = a;
|
|
|
var oldb = b;
|
|
|
var oldc = c;
|
|
|
var oldd = d;
|
|
|
var olde = e;
|
|
|
|
|
|
for (var j = 0; j < 80; j++) {
|
|
|
if (j < 16) w[j] = x[i + j];else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
|
|
|
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
|
|
|
e = d;
|
|
|
d = c;
|
|
|
c = rol(b, 30);
|
|
|
b = a;
|
|
|
a = t;
|
|
|
}
|
|
|
|
|
|
a = safe_add(a, olda);
|
|
|
b = safe_add(b, oldb);
|
|
|
c = safe_add(c, oldc);
|
|
|
d = safe_add(d, oldd);
|
|
|
e = safe_add(e, olde);
|
|
|
}
|
|
|
return Array(a, b, c, d, e);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Perform the appropriate triplet combination function for the current
|
|
|
* iteration
|
|
|
*/
|
|
|
function sha1_ft(t, b, c, d) {
|
|
|
if (t < 20) return b & c | ~b & d;
|
|
|
if (t < 40) return b ^ c ^ d;
|
|
|
if (t < 60) return b & c | b & d | c & d;
|
|
|
return b ^ c ^ d;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Determine the appropriate additive constant for the current iteration
|
|
|
*/
|
|
|
function sha1_kt(t) {
|
|
|
return t < 20 ? 1518500249 : t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
|
|
* to work around bugs in some JS interpreters.
|
|
|
*/
|
|
|
function safe_add(x, y) {
|
|
|
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
|
|
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
|
return msw << 16 | lsw & 0xFFFF;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Bitwise rotate a 32-bit number to the left.
|
|
|
*/
|
|
|
function rol(num, cnt) {
|
|
|
return num << cnt | num >>> 32 - cnt;
|
|
|
}
|
|
|
|
|
|
module.exports = function sha1(buf) {
|
|
|
return helpers.hash(buf, core_sha1, 20, true);
|
|
|
};
|
|
|
|
|
|
},{"./helpers":285}],288:[function(require,module,exports){
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = function () {
|
|
|
return function () {};
|
|
|
};
|
|
|
|
|
|
},{}],289:[function(require,module,exports){
|
|
|
(function (Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var _require = require('stream'),
|
|
|
Stream = _require.Stream;
|
|
|
|
|
|
var _require2 = require('../lib/common/utils/isArray'),
|
|
|
isArray = _require2.isArray;
|
|
|
|
|
|
module.exports.string = function isString(obj) {
|
|
|
return typeof obj === 'string';
|
|
|
};
|
|
|
|
|
|
module.exports.array = isArray;
|
|
|
|
|
|
module.exports.buffer = Buffer.isBuffer;
|
|
|
|
|
|
function isStream(obj) {
|
|
|
return obj instanceof Stream;
|
|
|
}
|
|
|
|
|
|
module.exports.writableStream = function isWritableStream(obj) {
|
|
|
return isStream(obj) && typeof obj._write === 'function' && (0, _typeof3.default)(obj._writableState) === 'object';
|
|
|
};
|
|
|
|
|
|
}).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
|
|
|
},{"../lib/common/utils/isArray":42,"../node_modules/is-buffer/index.js":197,"babel-runtime/helpers/typeof":67,"stream":230}],290:[function(require,module,exports){
|
|
|
'use strict';
|
|
|
|
|
|
// copy from https://github.com/node-modules/utility for browser
|
|
|
|
|
|
exports.encodeURIComponent = function (text) {
|
|
|
try {
|
|
|
return encodeURIComponent(text);
|
|
|
} catch (e) {
|
|
|
return text;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
exports.escape = require('escape-html');
|
|
|
|
|
|
exports.timestamp = function timestamp(t) {
|
|
|
if (t) {
|
|
|
var v = t;
|
|
|
if (typeof v === 'string') {
|
|
|
v = Number(v);
|
|
|
}
|
|
|
if (String(t).length === 10) {
|
|
|
v *= 1000;
|
|
|
}
|
|
|
return new Date(v);
|
|
|
}
|
|
|
return Math.round(Date.now() / 1000);
|
|
|
};
|
|
|
|
|
|
},{"escape-html":191}],291:[function(require,module,exports){
|
|
|
(function (process,Buffer){
|
|
|
'use strict';
|
|
|
|
|
|
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
|
|
|
|
var _stringify2 = _interopRequireDefault(_stringify);
|
|
|
|
|
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
var util = require('util');
|
|
|
var urlutil = require('url');
|
|
|
var http = require('http');
|
|
|
var https = require('https');
|
|
|
var debug = require('debug')('urllib');
|
|
|
var ms = require('humanize-ms');
|
|
|
|
|
|
var _Promise;
|
|
|
|
|
|
var REQUEST_ID = 0;
|
|
|
var MAX_VALUE = Math.pow(2, 31) - 10;
|
|
|
var PROTO_RE = /^https?:\/\//i;
|
|
|
|
|
|
function getAgent(agent, defaultAgent) {
|
|
|
return agent === undefined ? defaultAgent : agent;
|
|
|
}
|
|
|
|
|
|
function makeCallback(resolve, reject) {
|
|
|
return function (err, data, res) {
|
|
|
if (err) {
|
|
|
return reject(err);
|
|
|
}
|
|
|
resolve({
|
|
|
data: data,
|
|
|
status: res.statusCode,
|
|
|
headers: res.headers,
|
|
|
res: res
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// exports.TIMEOUT = ms('5s');
|
|
|
exports.TIMEOUTS = [ms('300s'), ms('300s')];
|
|
|
|
|
|
var TEXT_DATA_TYPES = ['json', 'text'];
|
|
|
|
|
|
exports.request = function request(url, args, callback) {
|
|
|
// request(url, callback)
|
|
|
if (arguments.length === 2 && typeof args === 'function') {
|
|
|
callback = args;
|
|
|
args = null;
|
|
|
}
|
|
|
if (typeof callback === 'function') {
|
|
|
return exports.requestWithCallback(url, args, callback);
|
|
|
}
|
|
|
|
|
|
// Promise
|
|
|
if (!_Promise) {
|
|
|
_Promise = require('any-promise');
|
|
|
}
|
|
|
return new _Promise(function (resolve, reject) {
|
|
|
exports.requestWithCallback(url, args, makeCallback(resolve, reject));
|
|
|
});
|
|
|
};
|
|
|
|
|
|
exports.requestWithCallback = function requestWithCallback(url, args, callback) {
|
|
|
// requestWithCallback(url, callback)
|
|
|
if (!url || typeof url !== 'string' && (typeof url === 'undefined' ? 'undefined' : (0, _typeof3.default)(url)) !== 'object') {
|
|
|
var msg = util.format('expect request url to be a string or a http request options, but got %j', url);
|
|
|
throw new Error(msg);
|
|
|
}
|
|
|
|
|
|
if (arguments.length === 2 && typeof args === 'function') {
|
|
|
callback = args;
|
|
|
args = null;
|
|
|
}
|
|
|
|
|
|
args = args || {};
|
|
|
if (REQUEST_ID >= MAX_VALUE) {
|
|
|
REQUEST_ID = 0;
|
|
|
}
|
|
|
var reqId = ++REQUEST_ID;
|
|
|
|
|
|
args.requestUrls = args.requestUrls || [];
|
|
|
|
|
|
var reqMeta = {
|
|
|
requestId: reqId,
|
|
|
url: url,
|
|
|
args: args,
|
|
|
ctx: args.ctx
|
|
|
};
|
|
|
if (args.emitter) {
|
|
|
args.emitter.emit('request', reqMeta);
|
|
|
}
|
|
|
|
|
|
args.timeout = args.timeout || exports.TIMEOUTS;
|
|
|
args.maxRedirects = args.maxRedirects || 10;
|
|
|
args.streaming = args.streaming || args.customResponse;
|
|
|
var requestStartTime = Date.now();
|
|
|
var parsedUrl;
|
|
|
|
|
|
if (typeof url === 'string') {
|
|
|
if (!PROTO_RE.test(url)) {
|
|
|
// Support `request('www.server.com')`
|
|
|
url = 'http://' + url;
|
|
|
}
|
|
|
parsedUrl = urlutil.parse(url);
|
|
|
} else {
|
|
|
parsedUrl = url;
|
|
|
}
|
|
|
|
|
|
var method = (args.type || args.method || parsedUrl.method || 'GET').toUpperCase();
|
|
|
var port = parsedUrl.port || 80;
|
|
|
var httplib = http;
|
|
|
var agent = getAgent(args.agent, exports.agent);
|
|
|
var fixJSONCtlChars = args.fixJSONCtlChars;
|
|
|
|
|
|
if (parsedUrl.protocol === 'https:') {
|
|
|
httplib = https;
|
|
|
agent = getAgent(args.httpsAgent, exports.httpsAgent);
|
|
|
|
|
|
if (!parsedUrl.port) {
|
|
|
port = 443;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// request through proxy tunnel
|
|
|
// var proxyTunnelAgent = detectProxyAgent(parsedUrl, args);
|
|
|
// if (proxyTunnelAgent) {
|
|
|
// agent = proxyTunnelAgent;
|
|
|
// }
|
|
|
|
|
|
var options = {
|
|
|
host: parsedUrl.hostname || parsedUrl.host || 'localhost',
|
|
|
path: parsedUrl.path || '/',
|
|
|
method: method,
|
|
|
port: port,
|
|
|
agent: agent,
|
|
|
headers: args.headers || {},
|
|
|
// default is dns.lookup
|
|
|
// https://github.com/nodejs/node/blob/master/lib/net.js#L986
|
|
|
// custom dnslookup require node >= 4.0.0
|
|
|
// https://github.com/nodejs/node/blob/archived-io.js-v0.12/lib/net.js#L952
|
|
|
lookup: args.lookup
|
|
|
};
|
|
|
|
|
|
if (Array.isArray(args.timeout)) {
|
|
|
options.requestTimeout = args.timeout[args.timeout.length - 1];
|
|
|
} else if (typeof args.timeout !== 'undefined') {
|
|
|
options.requestTimeout = args.timeout;
|
|
|
}
|
|
|
|
|
|
var sslNames = ['pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers', 'rejectUnauthorized', 'secureProtocol', 'secureOptions'];
|
|
|
for (var i = 0; i < sslNames.length; i++) {
|
|
|
var name = sslNames[i];
|
|
|
if (args.hasOwnProperty(name)) {
|
|
|
options[name] = args[name];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// don't check ssl
|
|
|
if (options.rejectUnauthorized === false && !options.hasOwnProperty('secureOptions')) {
|
|
|
options.secureOptions = require('constants').SSL_OP_NO_TLSv1_2;
|
|
|
}
|
|
|
|
|
|
var auth = args.auth || parsedUrl.auth;
|
|
|
if (auth) {
|
|
|
options.auth = auth;
|
|
|
}
|
|
|
|
|
|
var body = args.content || args.data;
|
|
|
var dataAsQueryString = method === 'GET' || method === 'HEAD' || args.dataAsQueryString;
|
|
|
if (!args.content) {
|
|
|
if (body && !(typeof body === 'string' || Buffer.isBuffer(body))) {
|
|
|
if (dataAsQueryString) {
|
|
|
// read: GET, HEAD, use query string
|
|
|
body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
|
|
|
} else {
|
|
|
var contentType = options.headers['Content-Type'] || options.headers['content-type'];
|
|
|
// auto add application/x-www-form-urlencoded when using urlencode form request
|
|
|
if (!contentType) {
|
|
|
if (args.contentType === 'json') {
|
|
|
contentType = 'application/json';
|
|
|
} else {
|
|
|
contentType = 'application/x-www-form-urlencoded';
|
|
|
}
|
|
|
options.headers['Content-Type'] = contentType;
|
|
|
}
|
|
|
|
|
|
if (parseContentType(contentType).type === 'application/json') {
|
|
|
body = (0, _stringify2.default)(body);
|
|
|
} else {
|
|
|
// 'application/x-www-form-urlencoded'
|
|
|
body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if it's a GET or HEAD request, data should be sent as query string
|
|
|
if (dataAsQueryString && body) {
|
|
|
options.path += (parsedUrl.query ? '&' : '?') + body;
|
|
|
body = null;
|
|
|
}
|
|
|
|
|
|
var requestSize = 0;
|
|
|
if (body) {
|
|
|
var length = body.length;
|
|
|
if (!Buffer.isBuffer(body)) {
|
|
|
length = Buffer.byteLength(body);
|
|
|
}
|
|
|
requestSize = options.headers['Content-Length'] = length;
|
|
|
}
|
|
|
|
|
|
if (args.dataType === 'json') {
|
|
|
options.headers.Accept = 'application/json';
|
|
|
}
|
|
|
|
|
|
if (typeof args.beforeRequest === 'function') {
|
|
|
// you can use this hook to change every thing.
|
|
|
args.beforeRequest(options);
|
|
|
}
|
|
|
var connectTimer = null;
|
|
|
var responseTimer = null;
|
|
|
var __err = null;
|
|
|
var connected = false; // socket connected or not
|
|
|
var keepAliveSocket = false; // request with keepalive socket
|
|
|
var responseSize = 0;
|
|
|
var statusCode = -1;
|
|
|
var responseAborted = false;
|
|
|
var remoteAddress = '';
|
|
|
var remotePort = '';
|
|
|
var timing = null;
|
|
|
if (args.timing) {
|
|
|
timing = {
|
|
|
// socket assigned
|
|
|
queuing: 0,
|
|
|
// dns lookup time
|
|
|
dnslookup: 0,
|
|
|
// socket connected
|
|
|
connected: 0,
|
|
|
// request sent
|
|
|
requestSent: 0,
|
|
|
// Time to first byte (TTFB)
|
|
|
waiting: 0,
|
|
|
contentDownload: 0
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function cancelConnectTimer() {
|
|
|
if (connectTimer) {
|
|
|
clearTimeout(connectTimer);
|
|
|
connectTimer = null;
|
|
|
}
|
|
|
}
|
|
|
function cancelResponseTimer() {
|
|
|
if (responseTimer) {
|
|
|
clearTimeout(responseTimer);
|
|
|
responseTimer = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function done(err, data, res) {
|
|
|
cancelResponseTimer();
|
|
|
if (!callback) {
|
|
|
console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s %s callback twice!!!', Date(), reqId, process.pid, options.method, url);
|
|
|
// https://github.com/node-modules/urllib/pull/30
|
|
|
if (err) {
|
|
|
console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s: %s\nstack: %s', Date(), reqId, process.pid, err.name, err.message, err.stack);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
var cb = callback;
|
|
|
callback = null;
|
|
|
var headers = {};
|
|
|
if (res) {
|
|
|
statusCode = res.statusCode;
|
|
|
headers = res.headers;
|
|
|
}
|
|
|
|
|
|
// handle digest auth
|
|
|
if (statusCode === 401 && headers['www-authenticate'] && (!args.headers || !args.headers.Authorization) && args.digestAuth) {
|
|
|
var authenticate = headers['www-authenticate'];
|
|
|
if (authenticate.indexOf('Digest ') >= 0) {
|
|
|
debug('Request#%d %s: got digest auth header WWW-Authenticate: %s', reqId, url, authenticate);
|
|
|
args.headers = args.headers || {};
|
|
|
args.headers.Authorization = digestAuthHeader(options.method, options.path, authenticate, args.digestAuth);
|
|
|
debug('Request#%d %s: auth with digest header: %s', reqId, url, args.headers.Authorization);
|
|
|
if (res.headers['set-cookie']) {
|
|
|
args.headers.Cookie = res.headers['set-cookie'].join(';');
|
|
|
}
|
|
|
return exports.requestWithCallback(url, args, cb);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var requestUseTime = Date.now() - requestStartTime;
|
|
|
if (timing) {
|
|
|
timing.contentDownload = requestUseTime;
|
|
|
}
|
|
|
|
|
|
debug('[%sms] done, %s bytes HTTP %s %s %s %s, keepAliveSocket: %s, timing: %j', requestUseTime, responseSize, statusCode, options.method, options.host, options.path, keepAliveSocket, timing);
|
|
|
|
|
|
var response = {
|
|
|
status: statusCode,
|
|
|
statusCode: statusCode,
|
|
|
headers: headers,
|
|
|
size: responseSize,
|
|
|
aborted: responseAborted,
|
|
|
rt: requestUseTime,
|
|
|
keepAliveSocket: keepAliveSocket,
|
|
|
data: data,
|
|
|
requestUrls: args.requestUrls,
|
|
|
timing: timing,
|
|
|
remoteAddress: remoteAddress,
|
|
|
remotePort: remotePort
|
|
|
};
|
|
|
|
|
|
if (err) {
|
|
|
var agentStatus = '';
|
|
|
if (agent && typeof agent.getCurrentStatus === 'function') {
|
|
|
// add current agent status to error message for logging and debug
|
|
|
agentStatus = ', agent status: ' + (0, _stringify2.default)(agent.getCurrentStatus());
|
|
|
}
|
|
|
err.message += ', ' + options.method + ' ' + url + ' ' + statusCode + ' (connected: ' + connected + ', keepalive socket: ' + keepAliveSocket + agentStatus + ')' + '\nheaders: ' + (0, _stringify2.default)(headers);
|
|
|
err.data = data;
|
|
|
err.path = options.path;
|
|
|
err.status = statusCode;
|
|
|
err.headers = headers;
|
|
|
err.res = response;
|
|
|
}
|
|
|
|
|
|
cb(err, data, args.streaming ? res : response);
|
|
|
|
|
|
if (args.emitter) {
|
|
|
// keep to use the same reqMeta object on request event before
|
|
|
reqMeta.url = url;
|
|
|
reqMeta.socket = req && req.connection;
|
|
|
reqMeta.options = options;
|
|
|
reqMeta.size = requestSize;
|
|
|
|
|
|
args.emitter.emit('response', {
|
|
|
requestId: reqId,
|
|
|
error: err,
|
|
|
ctx: args.ctx,
|
|
|
req: reqMeta,
|
|
|
res: response
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function handleRedirect(res) {
|
|
|
var err = null;
|
|
|
if (args.followRedirect && statuses.redirect[res.statusCode]) {
|
|
|
// handle redirect
|
|
|
args._followRedirectCount = (args._followRedirectCount || 0) + 1;
|
|
|
var location = res.headers.location;
|
|
|
if (!location) {
|
|
|
err = new Error('Got statusCode ' + res.statusCode + ' but cannot resolve next location from headers');
|
|
|
err.name = 'FollowRedirectError';
|
|
|
} else if (args._followRedirectCount > args.maxRedirects) {
|
|
|
err = new Error('Exceeded maxRedirects. Probably stuck in a redirect loop ' + url);
|
|
|
err.name = 'MaxRedirectError';
|
|
|
} else {
|
|
|
var newUrl = args.formatRedirectUrl ? args.formatRedirectUrl(url, location) : urlutil.resolve(url, location);
|
|
|
debug('Request#%d %s: `redirected` from %s to %s', reqId, options.path, url, newUrl);
|
|
|
// make sure timer stop
|
|
|
cancelResponseTimer();
|
|
|
// should clean up headers.Host on `location: http://other-domain/url`
|
|
|
if (args.headers && args.headers.Host && PROTO_RE.test(location)) {
|
|
|
args.headers.Host = null;
|
|
|
}
|
|
|
// avoid done will be execute in the future change.
|
|
|
var cb = callback;
|
|
|
callback = null;
|
|
|
exports.requestWithCallback(newUrl, args, cb);
|
|
|
return {
|
|
|
redirect: true,
|
|
|
error: null
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
redirect: false,
|
|
|
error: err
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// set user-agent
|
|
|
if (!options.headers['User-Agent'] && !options.headers['user-agent']) {
|
|
|
options.headers['User-Agent'] = navigator.userAgent;
|
|
|
}
|
|
|
|
|
|
if (args.gzip) {
|
|
|
if (!options.headers['Accept-Encoding'] && !options.headers['accept-encoding']) {
|
|
|
options.headers['Accept-Encoding'] = 'gzip';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function decodeContent(res, body, cb) {
|
|
|
var encoding = res.headers['content-encoding'];
|
|
|
// if (body.length === 0) {
|
|
|
// return cb(null, body, encoding);
|
|
|
// }
|
|
|
|
|
|
// if (!encoding || encoding.toLowerCase() !== 'gzip') {
|
|
|
return cb(null, body, encoding);
|
|
|
// }
|
|
|
|
|
|
// debug('gunzip %d length body', body.length);
|
|
|
// zlib.gunzip(body, cb);
|
|
|
}
|
|
|
|
|
|
var writeStream = args.writeStream;
|
|
|
|
|
|
debug('Request#%d %s %s with headers %j, options.path: %s', reqId, method, url, options.headers, options.path);
|
|
|
|
|
|
args.requestUrls.push(url);
|
|
|
|
|
|
function onResponse(res) {
|
|
|
if (timing) {
|
|
|
timing.waiting = Date.now() - requestStartTime;
|
|
|
}
|
|
|
debug('Request#%d %s `req response` event emit: status %d, headers: %j', reqId, url, res.statusCode, res.headers);
|
|
|
|
|
|
if (args.streaming) {
|
|
|
var result = handleRedirect(res);
|
|
|
if (result.redirect) {
|
|
|
res.resume();
|
|
|
return;
|
|
|
}
|
|
|
if (result.error) {
|
|
|
res.resume();
|
|
|
return done(result.error, null, res);
|
|
|
}
|
|
|
|
|
|
return done(null, null, res);
|
|
|
}
|
|
|
|
|
|
res.on('close', function () {
|
|
|
debug('Request#%d %s: `res close` event emit, total size %d', reqId, url, responseSize);
|
|
|
});
|
|
|
|
|
|
res.on('error', function () {
|
|
|
debug('Request#%d %s: `res error` event emit, total size %d', reqId, url, responseSize);
|
|
|
});
|
|
|
|
|
|
res.on('aborted', function () {
|
|
|
responseAborted = true;
|
|
|
debug('Request#%d %s: `res aborted` event emit, total size %d', reqId, url, responseSize);
|
|
|
});
|
|
|
|
|
|
if (writeStream) {
|
|
|
// If there's a writable stream to recieve the response data, just pipe the
|
|
|
// response stream to that writable stream and call the callback when it has
|
|
|
// finished writing.
|
|
|
//
|
|
|
// NOTE that when the response stream `res` emits an 'end' event it just
|
|
|
// means that it has finished piping data to another stream. In the
|
|
|
// meanwhile that writable stream may still writing data to the disk until
|
|
|
// it emits a 'close' event.
|
|
|
//
|
|
|
// That means that we should not apply callback until the 'close' of the
|
|
|
// writable stream is emited.
|
|
|
//
|
|
|
// See also:
|
|
|
// - https://github.com/TBEDP/urllib/commit/959ac3365821e0e028c231a5e8efca6af410eabb
|
|
|
// - http://nodejs.org/api/stream.html#stream_event_end
|
|
|
// - http://nodejs.org/api/stream.html#stream_event_close_1
|
|
|
var result = handleRedirect(res);
|
|
|
if (result.redirect) {
|
|
|
res.resume();
|
|
|
return;
|
|
|
}
|
|
|
if (result.error) {
|
|
|
res.resume();
|
|
|
// end ths stream first
|
|
|
writeStream.end();
|
|
|
return done(result.error, null, res);
|
|
|
}
|
|
|
// you can set consumeWriteStream false that only wait response end
|
|
|
if (args.consumeWriteStream === false) {
|
|
|
res.on('end', done.bind(null, null, null, res));
|
|
|
} else {
|
|
|
// node 0.10, 0.12: only emit res aborted, writeStream close not fired
|
|
|
if (isNode010 || isNode012) {
|
|
|
first([[writeStream, 'close'], [res, 'aborted']], function (_, stream, event) {
|
|
|
debug('Request#%d %s: writeStream or res %s event emitted', reqId, url, event);
|
|
|
done(__err || null, null, res);
|
|
|
});
|
|
|
} else {
|
|
|
writeStream.on('close', function () {
|
|
|
debug('Request#%d %s: writeStream close event emitted', reqId, url);
|
|
|
done(__err || null, null, res);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
return res.pipe(writeStream);
|
|
|
}
|
|
|
|
|
|
// Otherwise, just concat those buffers.
|
|
|
//
|
|
|
// NOTE that the `chunk` is not a String but a Buffer. It means that if
|
|
|
// you simply concat two chunk with `+` you're actually converting both
|
|
|
// Buffers into Strings before concating them. It'll cause problems when
|
|
|
// dealing with multi-byte characters.
|
|
|
//
|
|
|
// The solution is to store each chunk in an array and concat them with
|
|
|
// 'buffer-concat' when all chunks is recieved.
|
|
|
//
|
|
|
// See also:
|
|
|
// http://cnodejs.org/topic/4faf65852e8fb5bc65113403
|
|
|
|
|
|
var chunks = [];
|
|
|
|
|
|
res.on('data', function (chunk) {
|
|
|
debug('Request#%d %s: `res data` event emit, size %d', reqId, url, chunk.length);
|
|
|
responseSize += chunk.length;
|
|
|
chunks.push(chunk);
|
|
|
});
|
|
|
|
|
|
res.on('end', function () {
|
|
|
var body = Buffer.concat(chunks, responseSize);
|
|
|
debug('Request#%d %s: `res end` event emit, total size %d, _dumped: %s', reqId, url, responseSize, res._dumped);
|
|
|
|
|
|
if (__err) {
|
|
|
// req.abort() after `res data` event emit.
|
|
|
return done(__err, body, res);
|
|
|
}
|
|
|
|
|
|
var result = handleRedirect(res);
|
|
|
if (result.error) {
|
|
|
return done(result.error, body, res);
|
|
|
}
|
|
|
if (result.redirect) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
decodeContent(res, body, function (err, data, encoding) {
|
|
|
if (err) {
|
|
|
return done(err, body, res);
|
|
|
}
|
|
|
// if body not decode, dont touch it
|
|
|
if (!encoding && TEXT_DATA_TYPES.indexOf(args.dataType) >= 0) {
|
|
|
// try to decode charset
|
|
|
try {
|
|
|
data = decodeBodyByCharset(data, res);
|
|
|
} catch (e) {
|
|
|
debug('decodeBodyByCharset error: %s', e);
|
|
|
// if error, dont touch it
|
|
|
return done(null, data, res);
|
|
|
}
|
|
|
|
|
|
if (args.dataType === 'json') {
|
|
|
if (responseSize === 0) {
|
|
|
data = null;
|
|
|
} else {
|
|
|
var r = parseJSON(data, fixJSONCtlChars);
|
|
|
if (r.error) {
|
|
|
err = r.error;
|
|
|
} else {
|
|
|
data = r.data;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (responseAborted) {
|
|
|
// err = new Error('Remote socket was terminated before `response.end()` was called');
|
|
|
// err.name = 'RemoteSocketClosedError';
|
|
|
debug('Request#%d %s: Remote socket was terminated before `response.end()` was called', reqId, url);
|
|
|
}
|
|
|
|
|
|
done(err, data, res);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
var connectTimeout, responseTimeout;
|
|
|
if (Array.isArray(args.timeout)) {
|
|
|
connectTimeout = ms(args.timeout[0]);
|
|
|
responseTimeout = ms(args.timeout[1]);
|
|
|
} else {
|
|
|
// set both timeout equal
|
|
|
connectTimeout = responseTimeout = ms(args.timeout);
|
|
|
}
|
|
|
debug('ConnectTimeout: %d, ResponseTimeout: %d', connectTimeout, responseTimeout);
|
|
|
|
|
|
function startConnectTimer() {
|
|
|
debug('Connect timer ticking, timeout: %d', connectTimeout);
|
|
|
connectTimer = setTimeout(function () {
|
|
|
connectTimer = null;
|
|
|
if (statusCode === -1) {
|
|
|
statusCode = -2;
|
|
|
}
|
|
|
var msg = 'Connect timeout for ' + connectTimeout + 'ms';
|
|
|
var errorName = 'ConnectionTimeoutError';
|
|
|
if (!req.socket) {
|
|
|
errorName = 'SocketAssignTimeoutError';
|
|
|
msg += ', working sockets is full';
|
|
|
}
|
|
|
__err = new Error(msg);
|
|
|
__err.name = errorName;
|
|
|
__err.requestId = reqId;
|
|
|
debug('ConnectTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
|
|
|
abortRequest();
|
|
|
}, connectTimeout);
|
|
|
}
|
|
|
|
|
|
function startResposneTimer() {
|
|
|
debug('Response timer ticking, timeout: %d', responseTimeout);
|
|
|
responseTimer = setTimeout(function () {
|
|
|
responseTimer = null;
|
|
|
var msg = 'Response timeout for ' + responseTimeout + 'ms';
|
|
|
var errorName = 'ResponseTimeoutError';
|
|
|
__err = new Error(msg);
|
|
|
__err.name = errorName;
|
|
|
__err.requestId = reqId;
|
|
|
debug('ResponseTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
|
|
|
abortRequest();
|
|
|
}, responseTimeout);
|
|
|
}
|
|
|
|
|
|
var req;
|
|
|
// request headers checker will throw error
|
|
|
options.mode = args.mode ? args.mode : '';
|
|
|
try {
|
|
|
req = httplib.request(options, onResponse);
|
|
|
} catch (err) {
|
|
|
return done(err);
|
|
|
}
|
|
|
|
|
|
// environment detection: browser or nodejs
|
|
|
if (typeof window === 'undefined') {
|
|
|
// start connect timer just after `request` return, and just in nodejs environment
|
|
|
startConnectTimer();
|
|
|
} else {
|
|
|
req.on('requestTimeout', function () {
|
|
|
if (statusCode === -1) {
|
|
|
statusCode = -2;
|
|
|
}
|
|
|
var msg = 'Connect timeout for ' + connectTimeout + 'ms';
|
|
|
var errorName = 'ConnectionTimeoutError';
|
|
|
__err = new Error(msg);
|
|
|
__err.name = errorName;
|
|
|
__err.requestId = reqId;
|
|
|
abortRequest();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function abortRequest() {
|
|
|
debug('Request#%d %s abort, connected: %s', reqId, url, connected);
|
|
|
// it wont case error event when req haven't been assigned a socket yet.
|
|
|
if (!req.socket) {
|
|
|
__err.noSocket = true;
|
|
|
done(__err);
|
|
|
}
|
|
|
req.abort();
|
|
|
}
|
|
|
|
|
|
if (timing) {
|
|
|
// request sent
|
|
|
req.on('finish', function () {
|
|
|
timing.requestSent = Date.now() - requestStartTime;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
req.once('socket', function (socket) {
|
|
|
if (timing) {
|
|
|
// socket queuing time
|
|
|
timing.queuing = Date.now() - requestStartTime;
|
|
|
}
|
|
|
|
|
|
// https://github.com/nodejs/node/blob/master/lib/net.js#L377
|
|
|
// https://github.com/nodejs/node/blob/v0.10.40-release/lib/net.js#L352
|
|
|
// should use socket.socket on 0.10.x
|
|
|
if (isNode010 && socket.socket) {
|
|
|
socket = socket.socket;
|
|
|
}
|
|
|
|
|
|
var readyState = socket.readyState;
|
|
|
if (readyState === 'opening') {
|
|
|
socket.once('lookup', function (err, ip, addressType) {
|
|
|
debug('Request#%d %s lookup: %s, %s, %s', reqId, url, err, ip, addressType);
|
|
|
if (timing) {
|
|
|
timing.dnslookup = Date.now() - requestStartTime;
|
|
|
}
|
|
|
if (ip) {
|
|
|
remoteAddress = ip;
|
|
|
}
|
|
|
});
|
|
|
socket.once('connect', function () {
|
|
|
if (timing) {
|
|
|
// socket connected
|
|
|
timing.connected = Date.now() - requestStartTime;
|
|
|
}
|
|
|
|
|
|
// cancel socket timer at first and start tick for TTFB
|
|
|
cancelConnectTimer();
|
|
|
startResposneTimer();
|
|
|
|
|
|
debug('Request#%d %s new socket connected', reqId, url);
|
|
|
connected = true;
|
|
|
if (!remoteAddress) {
|
|
|
remoteAddress = socket.remoteAddress;
|
|
|
}
|
|
|
remotePort = socket.remotePort;
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
debug('Request#%d %s reuse socket connected, readyState: %s', reqId, url, readyState);
|
|
|
connected = true;
|
|
|
keepAliveSocket = true;
|
|
|
if (!remoteAddress) {
|
|
|
remoteAddress = socket.remoteAddress;
|
|
|
}
|
|
|
remotePort = socket.remotePort;
|
|
|
|
|
|
// reuse socket, timer should be canceled.
|
|
|
cancelConnectTimer();
|
|
|
startResposneTimer();
|
|
|
});
|
|
|
|
|
|
req.on('error', function (err) {
|
|
|
//TypeError for browser fetch api, Error for browser xmlhttprequest api
|
|
|
if (err.name === 'Error' || err.name === 'TypeError') {
|
|
|
err.name = connected ? 'ResponseError' : 'RequestError';
|
|
|
}
|
|
|
err.message += ' (req "error")';
|
|
|
debug('Request#%d %s `req error` event emit, %s: %s', reqId, url, err.name, err.message);
|
|
|
done(__err || err);
|
|
|
});
|
|
|
|
|
|
if (writeStream) {
|
|
|
writeStream.once('error', function (err) {
|
|
|
err.message += ' (writeStream "error")';
|
|
|
__err = err;
|
|
|
debug('Request#%d %s `writeStream error` event emit, %s: %s', reqId, url, err.name, err.message);
|
|
|
abortRequest();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (args.stream) {
|
|
|
args.stream.pipe(req);
|
|
|
args.stream.once('error', function (err) {
|
|
|
err.message += ' (stream "error")';
|
|
|
__err = err;
|
|
|
debug('Request#%d %s `readStream error` event emit, %s: %s', reqId, url, err.name, err.message);
|
|
|
abortRequest();
|
|
|
});
|
|
|
} else {
|
|
|
req.end(body);
|
|
|
}
|
|
|
|
|
|
req.requestId = reqId;
|
|
|
return req;
|
|
|
};
|
|
|
|
|
|
}).call(this,require('_process'),require("buffer").Buffer)
|
|
|
},{"_process":208,"any-promise":49,"babel-runtime/core-js/json/stringify":53,"babel-runtime/helpers/typeof":67,"buffer":73,"constants":75,"debug":288,"http":231,"https":193,"humanize-ms":194,"url":238,"util":243}]},{},[1])(1)
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 40452:
|
|
|
/*!***************************************!*\
|
|
|
!*** ./node_modules/crypto-js/aes.js ***!
|
|
|
\***************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./enc-base64 */ 98269), __webpack_require__(/*! ./md5 */ 68214), __webpack_require__(/*! ./evpkdf */ 90888), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var BlockCipher = C_lib.BlockCipher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Lookup tables
|
|
|
var SBOX = [];
|
|
|
var INV_SBOX = [];
|
|
|
var SUB_MIX_0 = [];
|
|
|
var SUB_MIX_1 = [];
|
|
|
var SUB_MIX_2 = [];
|
|
|
var SUB_MIX_3 = [];
|
|
|
var INV_SUB_MIX_0 = [];
|
|
|
var INV_SUB_MIX_1 = [];
|
|
|
var INV_SUB_MIX_2 = [];
|
|
|
var INV_SUB_MIX_3 = [];
|
|
|
|
|
|
// Compute lookup tables
|
|
|
(function () {
|
|
|
// Compute double table
|
|
|
var d = [];
|
|
|
for (var i = 0; i < 256; i++) {
|
|
|
if (i < 128) {
|
|
|
d[i] = i << 1;
|
|
|
} else {
|
|
|
d[i] = (i << 1) ^ 0x11b;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Walk GF(2^8)
|
|
|
var x = 0;
|
|
|
var xi = 0;
|
|
|
for (var i = 0; i < 256; i++) {
|
|
|
// Compute sbox
|
|
|
var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
|
|
|
sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
|
|
|
SBOX[x] = sx;
|
|
|
INV_SBOX[sx] = x;
|
|
|
|
|
|
// Compute multiplication
|
|
|
var x2 = d[x];
|
|
|
var x4 = d[x2];
|
|
|
var x8 = d[x4];
|
|
|
|
|
|
// Compute sub bytes, mix columns tables
|
|
|
var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
|
|
|
SUB_MIX_0[x] = (t << 24) | (t >>> 8);
|
|
|
SUB_MIX_1[x] = (t << 16) | (t >>> 16);
|
|
|
SUB_MIX_2[x] = (t << 8) | (t >>> 24);
|
|
|
SUB_MIX_3[x] = t;
|
|
|
|
|
|
// Compute inv sub bytes, inv mix columns tables
|
|
|
var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
|
|
|
INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
|
|
|
INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
|
|
|
INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
|
|
|
INV_SUB_MIX_3[sx] = t;
|
|
|
|
|
|
// Compute next counter
|
|
|
if (!x) {
|
|
|
x = xi = 1;
|
|
|
} else {
|
|
|
x = x2 ^ d[d[d[x8 ^ x2]]];
|
|
|
xi ^= d[d[xi]];
|
|
|
}
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
// Precomputed Rcon lookup
|
|
|
var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
|
|
|
|
|
|
/**
|
|
|
* AES block cipher algorithm.
|
|
|
*/
|
|
|
var AES = C_algo.AES = BlockCipher.extend({
|
|
|
_doReset: function () {
|
|
|
var t;
|
|
|
|
|
|
// Skip reset of nRounds has been set before and key did not change
|
|
|
if (this._nRounds && this._keyPriorReset === this._key) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Shortcuts
|
|
|
var key = this._keyPriorReset = this._key;
|
|
|
var keyWords = key.words;
|
|
|
var keySize = key.sigBytes / 4;
|
|
|
|
|
|
// Compute number of rounds
|
|
|
var nRounds = this._nRounds = keySize + 6;
|
|
|
|
|
|
// Compute number of key schedule rows
|
|
|
var ksRows = (nRounds + 1) * 4;
|
|
|
|
|
|
// Compute key schedule
|
|
|
var keySchedule = this._keySchedule = [];
|
|
|
for (var ksRow = 0; ksRow < ksRows; ksRow++) {
|
|
|
if (ksRow < keySize) {
|
|
|
keySchedule[ksRow] = keyWords[ksRow];
|
|
|
} else {
|
|
|
t = keySchedule[ksRow - 1];
|
|
|
|
|
|
if (!(ksRow % keySize)) {
|
|
|
// Rot word
|
|
|
t = (t << 8) | (t >>> 24);
|
|
|
|
|
|
// Sub word
|
|
|
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
|
|
|
|
|
// Mix Rcon
|
|
|
t ^= RCON[(ksRow / keySize) | 0] << 24;
|
|
|
} else if (keySize > 6 && ksRow % keySize == 4) {
|
|
|
// Sub word
|
|
|
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
|
|
}
|
|
|
|
|
|
keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Compute inv key schedule
|
|
|
var invKeySchedule = this._invKeySchedule = [];
|
|
|
for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
|
|
|
var ksRow = ksRows - invKsRow;
|
|
|
|
|
|
if (invKsRow % 4) {
|
|
|
var t = keySchedule[ksRow];
|
|
|
} else {
|
|
|
var t = keySchedule[ksRow - 4];
|
|
|
}
|
|
|
|
|
|
if (invKsRow < 4 || ksRow <= 4) {
|
|
|
invKeySchedule[invKsRow] = t;
|
|
|
} else {
|
|
|
invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
|
|
|
INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
encryptBlock: function (M, offset) {
|
|
|
this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
|
|
|
},
|
|
|
|
|
|
decryptBlock: function (M, offset) {
|
|
|
// Swap 2nd and 4th rows
|
|
|
var t = M[offset + 1];
|
|
|
M[offset + 1] = M[offset + 3];
|
|
|
M[offset + 3] = t;
|
|
|
|
|
|
this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
|
|
|
|
|
|
// Inv swap 2nd and 4th rows
|
|
|
var t = M[offset + 1];
|
|
|
M[offset + 1] = M[offset + 3];
|
|
|
M[offset + 3] = t;
|
|
|
},
|
|
|
|
|
|
_doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
|
|
|
// Shortcut
|
|
|
var nRounds = this._nRounds;
|
|
|
|
|
|
// Get input, add round key
|
|
|
var s0 = M[offset] ^ keySchedule[0];
|
|
|
var s1 = M[offset + 1] ^ keySchedule[1];
|
|
|
var s2 = M[offset + 2] ^ keySchedule[2];
|
|
|
var s3 = M[offset + 3] ^ keySchedule[3];
|
|
|
|
|
|
// Key schedule row counter
|
|
|
var ksRow = 4;
|
|
|
|
|
|
// Rounds
|
|
|
for (var round = 1; round < nRounds; round++) {
|
|
|
// Shift rows, sub bytes, mix columns, add round key
|
|
|
var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
|
|
|
var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
|
|
|
var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
|
|
|
var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
|
|
|
|
|
|
// Update state
|
|
|
s0 = t0;
|
|
|
s1 = t1;
|
|
|
s2 = t2;
|
|
|
s3 = t3;
|
|
|
}
|
|
|
|
|
|
// Shift rows, sub bytes, add round key
|
|
|
var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
|
|
|
var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
|
|
|
var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
|
|
|
var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
|
|
|
|
|
|
// Set output
|
|
|
M[offset] = t0;
|
|
|
M[offset + 1] = t1;
|
|
|
M[offset + 2] = t2;
|
|
|
M[offset + 3] = t3;
|
|
|
},
|
|
|
|
|
|
keySize: 256/32
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut functions to the cipher's object interface.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
|
|
|
* var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
|
|
|
*/
|
|
|
C.AES = BlockCipher._createHelper(AES);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.AES;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 75109:
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/cipher-core.js ***!
|
|
|
\***********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./evpkdf */ 90888));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* Cipher core components.
|
|
|
*/
|
|
|
CryptoJS.lib.Cipher || (function (undefined) {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var Base = C_lib.Base;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
|
|
|
var C_enc = C.enc;
|
|
|
var Utf8 = C_enc.Utf8;
|
|
|
var Base64 = C_enc.Base64;
|
|
|
var C_algo = C.algo;
|
|
|
var EvpKDF = C_algo.EvpKDF;
|
|
|
|
|
|
/**
|
|
|
* Abstract base cipher template.
|
|
|
*
|
|
|
* @property {number} keySize This cipher's key size. Default: 4 (128 bits)
|
|
|
* @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
|
|
|
* @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
|
|
|
* @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
|
|
|
*/
|
|
|
var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*
|
|
|
* @property {WordArray} iv The IV to use for this operation.
|
|
|
*/
|
|
|
cfg: Base.extend(),
|
|
|
|
|
|
/**
|
|
|
* Creates this cipher in encryption mode.
|
|
|
*
|
|
|
* @param {WordArray} key The key.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
|
*
|
|
|
* @return {Cipher} A cipher instance.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
|
|
|
*/
|
|
|
createEncryptor: function (key, cfg) {
|
|
|
return this.create(this._ENC_XFORM_MODE, key, cfg);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Creates this cipher in decryption mode.
|
|
|
*
|
|
|
* @param {WordArray} key The key.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
|
*
|
|
|
* @return {Cipher} A cipher instance.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
|
|
|
*/
|
|
|
createDecryptor: function (key, cfg) {
|
|
|
return this.create(this._DEC_XFORM_MODE, key, cfg);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Initializes a newly created cipher.
|
|
|
*
|
|
|
* @param {number} xformMode Either the encryption or decryption transormation mode constant.
|
|
|
* @param {WordArray} key The key.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
|
|
|
*/
|
|
|
init: function (xformMode, key, cfg) {
|
|
|
// Apply config defaults
|
|
|
this.cfg = this.cfg.extend(cfg);
|
|
|
|
|
|
// Store transform mode and key
|
|
|
this._xformMode = xformMode;
|
|
|
this._key = key;
|
|
|
|
|
|
// Set initial values
|
|
|
this.reset();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Resets this cipher to its initial state.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* cipher.reset();
|
|
|
*/
|
|
|
reset: function () {
|
|
|
// Reset data buffer
|
|
|
BufferedBlockAlgorithm.reset.call(this);
|
|
|
|
|
|
// Perform concrete-cipher logic
|
|
|
this._doReset();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Adds data to be encrypted or decrypted.
|
|
|
*
|
|
|
* @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
|
|
|
*
|
|
|
* @return {WordArray} The data after processing.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var encrypted = cipher.process('data');
|
|
|
* var encrypted = cipher.process(wordArray);
|
|
|
*/
|
|
|
process: function (dataUpdate) {
|
|
|
// Append
|
|
|
this._append(dataUpdate);
|
|
|
|
|
|
// Process available blocks
|
|
|
return this._process();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Finalizes the encryption or decryption process.
|
|
|
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
|
*
|
|
|
* @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
|
|
|
*
|
|
|
* @return {WordArray} The data after final processing.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var encrypted = cipher.finalize();
|
|
|
* var encrypted = cipher.finalize('data');
|
|
|
* var encrypted = cipher.finalize(wordArray);
|
|
|
*/
|
|
|
finalize: function (dataUpdate) {
|
|
|
// Final data update
|
|
|
if (dataUpdate) {
|
|
|
this._append(dataUpdate);
|
|
|
}
|
|
|
|
|
|
// Perform concrete-cipher logic
|
|
|
var finalProcessedData = this._doFinalize();
|
|
|
|
|
|
return finalProcessedData;
|
|
|
},
|
|
|
|
|
|
keySize: 128/32,
|
|
|
|
|
|
ivSize: 128/32,
|
|
|
|
|
|
_ENC_XFORM_MODE: 1,
|
|
|
|
|
|
_DEC_XFORM_MODE: 2,
|
|
|
|
|
|
/**
|
|
|
* Creates shortcut functions to a cipher's object interface.
|
|
|
*
|
|
|
* @param {Cipher} cipher The cipher to create a helper for.
|
|
|
*
|
|
|
* @return {Object} An object with encrypt and decrypt shortcut functions.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
|
|
|
*/
|
|
|
_createHelper: (function () {
|
|
|
function selectCipherStrategy(key) {
|
|
|
if (typeof key == 'string') {
|
|
|
return PasswordBasedCipher;
|
|
|
} else {
|
|
|
return SerializableCipher;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return function (cipher) {
|
|
|
return {
|
|
|
encrypt: function (message, key, cfg) {
|
|
|
return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
|
|
|
},
|
|
|
|
|
|
decrypt: function (ciphertext, key, cfg) {
|
|
|
return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
|
|
|
}
|
|
|
};
|
|
|
};
|
|
|
}())
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Abstract base stream cipher template.
|
|
|
*
|
|
|
* @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
|
|
|
*/
|
|
|
var StreamCipher = C_lib.StreamCipher = Cipher.extend({
|
|
|
_doFinalize: function () {
|
|
|
// Process partial blocks
|
|
|
var finalProcessedBlocks = this._process(!!'flush');
|
|
|
|
|
|
return finalProcessedBlocks;
|
|
|
},
|
|
|
|
|
|
blockSize: 1
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Mode namespace.
|
|
|
*/
|
|
|
var C_mode = C.mode = {};
|
|
|
|
|
|
/**
|
|
|
* Abstract base block cipher mode template.
|
|
|
*/
|
|
|
var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
|
|
|
/**
|
|
|
* Creates this mode for encryption.
|
|
|
*
|
|
|
* @param {Cipher} cipher A block cipher instance.
|
|
|
* @param {Array} iv The IV words.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
|
|
|
*/
|
|
|
createEncryptor: function (cipher, iv) {
|
|
|
return this.Encryptor.create(cipher, iv);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Creates this mode for decryption.
|
|
|
*
|
|
|
* @param {Cipher} cipher A block cipher instance.
|
|
|
* @param {Array} iv The IV words.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
|
|
|
*/
|
|
|
createDecryptor: function (cipher, iv) {
|
|
|
return this.Decryptor.create(cipher, iv);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Initializes a newly created mode.
|
|
|
*
|
|
|
* @param {Cipher} cipher A block cipher instance.
|
|
|
* @param {Array} iv The IV words.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
|
|
|
*/
|
|
|
init: function (cipher, iv) {
|
|
|
this._cipher = cipher;
|
|
|
this._iv = iv;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Cipher Block Chaining mode.
|
|
|
*/
|
|
|
var CBC = C_mode.CBC = (function () {
|
|
|
/**
|
|
|
* Abstract base CBC mode.
|
|
|
*/
|
|
|
var CBC = BlockCipherMode.extend();
|
|
|
|
|
|
/**
|
|
|
* CBC encryptor.
|
|
|
*/
|
|
|
CBC.Encryptor = CBC.extend({
|
|
|
/**
|
|
|
* Processes the data block at offset.
|
|
|
*
|
|
|
* @param {Array} words The data words to operate on.
|
|
|
* @param {number} offset The offset where the block starts.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* mode.processBlock(data.words, offset);
|
|
|
*/
|
|
|
processBlock: function (words, offset) {
|
|
|
// Shortcuts
|
|
|
var cipher = this._cipher;
|
|
|
var blockSize = cipher.blockSize;
|
|
|
|
|
|
// XOR and encrypt
|
|
|
xorBlock.call(this, words, offset, blockSize);
|
|
|
cipher.encryptBlock(words, offset);
|
|
|
|
|
|
// Remember this block to use with next block
|
|
|
this._prevBlock = words.slice(offset, offset + blockSize);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* CBC decryptor.
|
|
|
*/
|
|
|
CBC.Decryptor = CBC.extend({
|
|
|
/**
|
|
|
* Processes the data block at offset.
|
|
|
*
|
|
|
* @param {Array} words The data words to operate on.
|
|
|
* @param {number} offset The offset where the block starts.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* mode.processBlock(data.words, offset);
|
|
|
*/
|
|
|
processBlock: function (words, offset) {
|
|
|
// Shortcuts
|
|
|
var cipher = this._cipher;
|
|
|
var blockSize = cipher.blockSize;
|
|
|
|
|
|
// Remember this block to use with next block
|
|
|
var thisBlock = words.slice(offset, offset + blockSize);
|
|
|
|
|
|
// Decrypt and XOR
|
|
|
cipher.decryptBlock(words, offset);
|
|
|
xorBlock.call(this, words, offset, blockSize);
|
|
|
|
|
|
// This block becomes the previous block
|
|
|
this._prevBlock = thisBlock;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function xorBlock(words, offset, blockSize) {
|
|
|
var block;
|
|
|
|
|
|
// Shortcut
|
|
|
var iv = this._iv;
|
|
|
|
|
|
// Choose mixing block
|
|
|
if (iv) {
|
|
|
block = iv;
|
|
|
|
|
|
// Remove IV for subsequent blocks
|
|
|
this._iv = undefined;
|
|
|
} else {
|
|
|
block = this._prevBlock;
|
|
|
}
|
|
|
|
|
|
// XOR blocks
|
|
|
for (var i = 0; i < blockSize; i++) {
|
|
|
words[offset + i] ^= block[i];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return CBC;
|
|
|
}());
|
|
|
|
|
|
/**
|
|
|
* Padding namespace.
|
|
|
*/
|
|
|
var C_pad = C.pad = {};
|
|
|
|
|
|
/**
|
|
|
* PKCS #5/7 padding strategy.
|
|
|
*/
|
|
|
var Pkcs7 = C_pad.Pkcs7 = {
|
|
|
/**
|
|
|
* Pads data using the algorithm defined in PKCS #5/7.
|
|
|
*
|
|
|
* @param {WordArray} data The data to pad.
|
|
|
* @param {number} blockSize The multiple that the data should be padded to.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* CryptoJS.pad.Pkcs7.pad(wordArray, 4);
|
|
|
*/
|
|
|
pad: function (data, blockSize) {
|
|
|
// Shortcut
|
|
|
var blockSizeBytes = blockSize * 4;
|
|
|
|
|
|
// Count padding bytes
|
|
|
var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
|
|
|
|
|
// Create padding word
|
|
|
var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
|
|
|
|
|
|
// Create padding
|
|
|
var paddingWords = [];
|
|
|
for (var i = 0; i < nPaddingBytes; i += 4) {
|
|
|
paddingWords.push(paddingWord);
|
|
|
}
|
|
|
var padding = WordArray.create(paddingWords, nPaddingBytes);
|
|
|
|
|
|
// Add padding
|
|
|
data.concat(padding);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Unpads data that had been padded using the algorithm defined in PKCS #5/7.
|
|
|
*
|
|
|
* @param {WordArray} data The data to unpad.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* CryptoJS.pad.Pkcs7.unpad(wordArray);
|
|
|
*/
|
|
|
unpad: function (data) {
|
|
|
// Get number of padding bytes from last byte
|
|
|
var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
|
|
|
|
|
// Remove padding
|
|
|
data.sigBytes -= nPaddingBytes;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Abstract base block cipher template.
|
|
|
*
|
|
|
* @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
|
|
|
*/
|
|
|
var BlockCipher = C_lib.BlockCipher = Cipher.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*
|
|
|
* @property {Mode} mode The block mode to use. Default: CBC
|
|
|
* @property {Padding} padding The padding strategy to use. Default: Pkcs7
|
|
|
*/
|
|
|
cfg: Cipher.cfg.extend({
|
|
|
mode: CBC,
|
|
|
padding: Pkcs7
|
|
|
}),
|
|
|
|
|
|
reset: function () {
|
|
|
var modeCreator;
|
|
|
|
|
|
// Reset cipher
|
|
|
Cipher.reset.call(this);
|
|
|
|
|
|
// Shortcuts
|
|
|
var cfg = this.cfg;
|
|
|
var iv = cfg.iv;
|
|
|
var mode = cfg.mode;
|
|
|
|
|
|
// Reset block mode
|
|
|
if (this._xformMode == this._ENC_XFORM_MODE) {
|
|
|
modeCreator = mode.createEncryptor;
|
|
|
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
|
|
|
modeCreator = mode.createDecryptor;
|
|
|
// Keep at least one block in the buffer for unpadding
|
|
|
this._minBufferSize = 1;
|
|
|
}
|
|
|
|
|
|
if (this._mode && this._mode.__creator == modeCreator) {
|
|
|
this._mode.init(this, iv && iv.words);
|
|
|
} else {
|
|
|
this._mode = modeCreator.call(mode, this, iv && iv.words);
|
|
|
this._mode.__creator = modeCreator;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (words, offset) {
|
|
|
this._mode.processBlock(words, offset);
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
var finalProcessedBlocks;
|
|
|
|
|
|
// Shortcut
|
|
|
var padding = this.cfg.padding;
|
|
|
|
|
|
// Finalize
|
|
|
if (this._xformMode == this._ENC_XFORM_MODE) {
|
|
|
// Pad data
|
|
|
padding.pad(this._data, this.blockSize);
|
|
|
|
|
|
// Process final blocks
|
|
|
finalProcessedBlocks = this._process(!!'flush');
|
|
|
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
|
|
|
// Process final blocks
|
|
|
finalProcessedBlocks = this._process(!!'flush');
|
|
|
|
|
|
// Unpad data
|
|
|
padding.unpad(finalProcessedBlocks);
|
|
|
}
|
|
|
|
|
|
return finalProcessedBlocks;
|
|
|
},
|
|
|
|
|
|
blockSize: 128/32
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* A collection of cipher parameters.
|
|
|
*
|
|
|
* @property {WordArray} ciphertext The raw ciphertext.
|
|
|
* @property {WordArray} key The key to this ciphertext.
|
|
|
* @property {WordArray} iv The IV used in the ciphering operation.
|
|
|
* @property {WordArray} salt The salt used with a key derivation function.
|
|
|
* @property {Cipher} algorithm The cipher algorithm.
|
|
|
* @property {Mode} mode The block mode used in the ciphering operation.
|
|
|
* @property {Padding} padding The padding scheme used in the ciphering operation.
|
|
|
* @property {number} blockSize The block size of the cipher.
|
|
|
* @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
|
|
|
*/
|
|
|
var CipherParams = C_lib.CipherParams = Base.extend({
|
|
|
/**
|
|
|
* Initializes a newly created cipher params object.
|
|
|
*
|
|
|
* @param {Object} cipherParams An object with any of the possible cipher parameters.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var cipherParams = CryptoJS.lib.CipherParams.create({
|
|
|
* ciphertext: ciphertextWordArray,
|
|
|
* key: keyWordArray,
|
|
|
* iv: ivWordArray,
|
|
|
* salt: saltWordArray,
|
|
|
* algorithm: CryptoJS.algo.AES,
|
|
|
* mode: CryptoJS.mode.CBC,
|
|
|
* padding: CryptoJS.pad.PKCS7,
|
|
|
* blockSize: 4,
|
|
|
* formatter: CryptoJS.format.OpenSSL
|
|
|
* });
|
|
|
*/
|
|
|
init: function (cipherParams) {
|
|
|
this.mixIn(cipherParams);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts this cipher params object to a string.
|
|
|
*
|
|
|
* @param {Format} formatter (Optional) The formatting strategy to use.
|
|
|
*
|
|
|
* @return {string} The stringified cipher params.
|
|
|
*
|
|
|
* @throws Error If neither the formatter nor the default formatter is set.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var string = cipherParams + '';
|
|
|
* var string = cipherParams.toString();
|
|
|
* var string = cipherParams.toString(CryptoJS.format.OpenSSL);
|
|
|
*/
|
|
|
toString: function (formatter) {
|
|
|
return (formatter || this.formatter).stringify(this);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Format namespace.
|
|
|
*/
|
|
|
var C_format = C.format = {};
|
|
|
|
|
|
/**
|
|
|
* OpenSSL formatting strategy.
|
|
|
*/
|
|
|
var OpenSSLFormatter = C_format.OpenSSL = {
|
|
|
/**
|
|
|
* Converts a cipher params object to an OpenSSL-compatible string.
|
|
|
*
|
|
|
* @param {CipherParams} cipherParams The cipher params object.
|
|
|
*
|
|
|
* @return {string} The OpenSSL-compatible string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
|
|
|
*/
|
|
|
stringify: function (cipherParams) {
|
|
|
var wordArray;
|
|
|
|
|
|
// Shortcuts
|
|
|
var ciphertext = cipherParams.ciphertext;
|
|
|
var salt = cipherParams.salt;
|
|
|
|
|
|
// Format
|
|
|
if (salt) {
|
|
|
wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
|
|
|
} else {
|
|
|
wordArray = ciphertext;
|
|
|
}
|
|
|
|
|
|
return wordArray.toString(Base64);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts an OpenSSL-compatible string to a cipher params object.
|
|
|
*
|
|
|
* @param {string} openSSLStr The OpenSSL-compatible string.
|
|
|
*
|
|
|
* @return {CipherParams} The cipher params object.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
|
|
|
*/
|
|
|
parse: function (openSSLStr) {
|
|
|
var salt;
|
|
|
|
|
|
// Parse base64
|
|
|
var ciphertext = Base64.parse(openSSLStr);
|
|
|
|
|
|
// Shortcut
|
|
|
var ciphertextWords = ciphertext.words;
|
|
|
|
|
|
// Test for salt
|
|
|
if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
|
|
|
// Extract salt
|
|
|
salt = WordArray.create(ciphertextWords.slice(2, 4));
|
|
|
|
|
|
// Remove salt from ciphertext
|
|
|
ciphertextWords.splice(0, 4);
|
|
|
ciphertext.sigBytes -= 16;
|
|
|
}
|
|
|
|
|
|
return CipherParams.create({ ciphertext: ciphertext, salt: salt });
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* A cipher wrapper that returns ciphertext as a serializable cipher params object.
|
|
|
*/
|
|
|
var SerializableCipher = C_lib.SerializableCipher = Base.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*
|
|
|
* @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
|
|
|
*/
|
|
|
cfg: Base.extend({
|
|
|
format: OpenSSLFormatter
|
|
|
}),
|
|
|
|
|
|
/**
|
|
|
* Encrypts a message.
|
|
|
*
|
|
|
* @param {Cipher} cipher The cipher algorithm to use.
|
|
|
* @param {WordArray|string} message The message to encrypt.
|
|
|
* @param {WordArray} key The key.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
|
*
|
|
|
* @return {CipherParams} A cipher params object.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
|
|
|
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
|
|
|
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
|
*/
|
|
|
encrypt: function (cipher, message, key, cfg) {
|
|
|
// Apply config defaults
|
|
|
cfg = this.cfg.extend(cfg);
|
|
|
|
|
|
// Encrypt
|
|
|
var encryptor = cipher.createEncryptor(key, cfg);
|
|
|
var ciphertext = encryptor.finalize(message);
|
|
|
|
|
|
// Shortcut
|
|
|
var cipherCfg = encryptor.cfg;
|
|
|
|
|
|
// Create and return serializable cipher params
|
|
|
return CipherParams.create({
|
|
|
ciphertext: ciphertext,
|
|
|
key: key,
|
|
|
iv: cipherCfg.iv,
|
|
|
algorithm: cipher,
|
|
|
mode: cipherCfg.mode,
|
|
|
padding: cipherCfg.padding,
|
|
|
blockSize: cipher.blockSize,
|
|
|
formatter: cfg.format
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Decrypts serialized ciphertext.
|
|
|
*
|
|
|
* @param {Cipher} cipher The cipher algorithm to use.
|
|
|
* @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
|
|
* @param {WordArray} key The key.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
|
*
|
|
|
* @return {WordArray} The plaintext.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
|
* var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
|
*/
|
|
|
decrypt: function (cipher, ciphertext, key, cfg) {
|
|
|
// Apply config defaults
|
|
|
cfg = this.cfg.extend(cfg);
|
|
|
|
|
|
// Convert string to CipherParams
|
|
|
ciphertext = this._parse(ciphertext, cfg.format);
|
|
|
|
|
|
// Decrypt
|
|
|
var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
|
|
|
|
|
|
return plaintext;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts serialized ciphertext to CipherParams,
|
|
|
* else assumed CipherParams already and returns ciphertext unchanged.
|
|
|
*
|
|
|
* @param {CipherParams|string} ciphertext The ciphertext.
|
|
|
* @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
|
|
|
*
|
|
|
* @return {CipherParams} The unserialized ciphertext.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
|
|
|
*/
|
|
|
_parse: function (ciphertext, format) {
|
|
|
if (typeof ciphertext == 'string') {
|
|
|
return format.parse(ciphertext, this);
|
|
|
} else {
|
|
|
return ciphertext;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Key derivation function namespace.
|
|
|
*/
|
|
|
var C_kdf = C.kdf = {};
|
|
|
|
|
|
/**
|
|
|
* OpenSSL key derivation function.
|
|
|
*/
|
|
|
var OpenSSLKdf = C_kdf.OpenSSL = {
|
|
|
/**
|
|
|
* Derives a key and IV from a password.
|
|
|
*
|
|
|
* @param {string} password The password to derive from.
|
|
|
* @param {number} keySize The size in words of the key to generate.
|
|
|
* @param {number} ivSize The size in words of the IV to generate.
|
|
|
* @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
|
|
|
*
|
|
|
* @return {CipherParams} A cipher params object with the key, IV, and salt.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
|
|
|
* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
|
|
|
*/
|
|
|
execute: function (password, keySize, ivSize, salt) {
|
|
|
// Generate random salt
|
|
|
if (!salt) {
|
|
|
salt = WordArray.random(64/8);
|
|
|
}
|
|
|
|
|
|
// Derive key and IV
|
|
|
var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
|
|
|
|
|
|
// Separate key and IV
|
|
|
var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
|
|
|
key.sigBytes = keySize * 4;
|
|
|
|
|
|
// Return params
|
|
|
return CipherParams.create({ key: key, iv: iv, salt: salt });
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* A serializable cipher wrapper that derives the key from a password,
|
|
|
* and returns ciphertext as a serializable cipher params object.
|
|
|
*/
|
|
|
var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*
|
|
|
* @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
|
|
|
*/
|
|
|
cfg: SerializableCipher.cfg.extend({
|
|
|
kdf: OpenSSLKdf
|
|
|
}),
|
|
|
|
|
|
/**
|
|
|
* Encrypts a message using a password.
|
|
|
*
|
|
|
* @param {Cipher} cipher The cipher algorithm to use.
|
|
|
* @param {WordArray|string} message The message to encrypt.
|
|
|
* @param {string} password The password.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
|
*
|
|
|
* @return {CipherParams} A cipher params object.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
|
|
|
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
|
|
|
*/
|
|
|
encrypt: function (cipher, message, password, cfg) {
|
|
|
// Apply config defaults
|
|
|
cfg = this.cfg.extend(cfg);
|
|
|
|
|
|
// Derive key and other params
|
|
|
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
|
|
|
|
|
|
// Add IV to config
|
|
|
cfg.iv = derivedParams.iv;
|
|
|
|
|
|
// Encrypt
|
|
|
var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
|
|
|
|
|
|
// Mix in derived params
|
|
|
ciphertext.mixIn(derivedParams);
|
|
|
|
|
|
return ciphertext;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Decrypts serialized ciphertext using a password.
|
|
|
*
|
|
|
* @param {Cipher} cipher The cipher algorithm to use.
|
|
|
* @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
|
|
* @param {string} password The password.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
|
*
|
|
|
* @return {WordArray} The plaintext.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
|
|
|
* var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
|
|
|
*/
|
|
|
decrypt: function (cipher, ciphertext, password, cfg) {
|
|
|
// Apply config defaults
|
|
|
cfg = this.cfg.extend(cfg);
|
|
|
|
|
|
// Convert string to CipherParams
|
|
|
ciphertext = this._parse(ciphertext, cfg.format);
|
|
|
|
|
|
// Derive key and other params
|
|
|
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
|
|
|
|
|
|
// Add IV to config
|
|
|
cfg.iv = derivedParams.iv;
|
|
|
|
|
|
// Decrypt
|
|
|
var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
|
|
|
|
|
|
return plaintext;
|
|
|
}
|
|
|
});
|
|
|
}());
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 78249:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./node_modules/crypto-js/core.js ***!
|
|
|
\****************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory();
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function () {
|
|
|
|
|
|
/*globals window, global, require*/
|
|
|
|
|
|
/**
|
|
|
* CryptoJS core components.
|
|
|
*/
|
|
|
var CryptoJS = CryptoJS || (function (Math, undefined) {
|
|
|
|
|
|
var crypto;
|
|
|
|
|
|
// Native crypto from window (Browser)
|
|
|
if (typeof window !== 'undefined' && window.crypto) {
|
|
|
crypto = window.crypto;
|
|
|
}
|
|
|
|
|
|
// Native crypto in web worker (Browser)
|
|
|
if (typeof self !== 'undefined' && self.crypto) {
|
|
|
crypto = self.crypto;
|
|
|
}
|
|
|
|
|
|
// Native crypto from worker
|
|
|
if (typeof globalThis !== 'undefined' && globalThis.crypto) {
|
|
|
crypto = globalThis.crypto;
|
|
|
}
|
|
|
|
|
|
// Native (experimental IE 11) crypto from window (Browser)
|
|
|
if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
|
|
|
crypto = window.msCrypto;
|
|
|
}
|
|
|
|
|
|
// Native crypto from global (NodeJS)
|
|
|
if (!crypto && typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.crypto) {
|
|
|
crypto = __webpack_require__.g.crypto;
|
|
|
}
|
|
|
|
|
|
// Native crypto import via require (NodeJS)
|
|
|
if (!crypto && "function" === 'function') {
|
|
|
try {
|
|
|
crypto = __webpack_require__(/*! crypto */ 42480);
|
|
|
} catch (err) {}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Cryptographically secure pseudorandom number generator
|
|
|
*
|
|
|
* As Math.random() is cryptographically not safe to use
|
|
|
*/
|
|
|
var cryptoSecureRandomInt = function () {
|
|
|
if (crypto) {
|
|
|
// Use getRandomValues method (Browser)
|
|
|
if (typeof crypto.getRandomValues === 'function') {
|
|
|
try {
|
|
|
return crypto.getRandomValues(new Uint32Array(1))[0];
|
|
|
} catch (err) {}
|
|
|
}
|
|
|
|
|
|
// Use randomBytes method (NodeJS)
|
|
|
if (typeof crypto.randomBytes === 'function') {
|
|
|
try {
|
|
|
return crypto.randomBytes(4).readInt32LE();
|
|
|
} catch (err) {}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
throw new Error('Native crypto module could not be used to get secure random number.');
|
|
|
};
|
|
|
|
|
|
/*
|
|
|
* Local polyfill of Object.create
|
|
|
|
|
|
*/
|
|
|
var create = Object.create || (function () {
|
|
|
function F() {}
|
|
|
|
|
|
return function (obj) {
|
|
|
var subtype;
|
|
|
|
|
|
F.prototype = obj;
|
|
|
|
|
|
subtype = new F();
|
|
|
|
|
|
F.prototype = null;
|
|
|
|
|
|
return subtype;
|
|
|
};
|
|
|
}());
|
|
|
|
|
|
/**
|
|
|
* CryptoJS namespace.
|
|
|
*/
|
|
|
var C = {};
|
|
|
|
|
|
/**
|
|
|
* Library namespace.
|
|
|
*/
|
|
|
var C_lib = C.lib = {};
|
|
|
|
|
|
/**
|
|
|
* Base object for prototypal inheritance.
|
|
|
*/
|
|
|
var Base = C_lib.Base = (function () {
|
|
|
|
|
|
|
|
|
return {
|
|
|
/**
|
|
|
* Creates a new object that inherits from this object.
|
|
|
*
|
|
|
* @param {Object} overrides Properties to copy into the new object.
|
|
|
*
|
|
|
* @return {Object} The new object.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var MyType = CryptoJS.lib.Base.extend({
|
|
|
* field: 'value',
|
|
|
*
|
|
|
* method: function () {
|
|
|
* }
|
|
|
* });
|
|
|
*/
|
|
|
extend: function (overrides) {
|
|
|
// Spawn
|
|
|
var subtype = create(this);
|
|
|
|
|
|
// Augment
|
|
|
if (overrides) {
|
|
|
subtype.mixIn(overrides);
|
|
|
}
|
|
|
|
|
|
// Create default initializer
|
|
|
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
|
|
|
subtype.init = function () {
|
|
|
subtype.$super.init.apply(this, arguments);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// Initializer's prototype is the subtype object
|
|
|
subtype.init.prototype = subtype;
|
|
|
|
|
|
// Reference supertype
|
|
|
subtype.$super = this;
|
|
|
|
|
|
return subtype;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Extends this object and runs the init method.
|
|
|
* Arguments to create() will be passed to init().
|
|
|
*
|
|
|
* @return {Object} The new object.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var instance = MyType.create();
|
|
|
*/
|
|
|
create: function () {
|
|
|
var instance = this.extend();
|
|
|
instance.init.apply(instance, arguments);
|
|
|
|
|
|
return instance;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Initializes a newly created object.
|
|
|
* Override this method to add some logic when your objects are created.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var MyType = CryptoJS.lib.Base.extend({
|
|
|
* init: function () {
|
|
|
* // ...
|
|
|
* }
|
|
|
* });
|
|
|
*/
|
|
|
init: function () {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Copies properties into this object.
|
|
|
*
|
|
|
* @param {Object} properties The properties to mix in.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* MyType.mixIn({
|
|
|
* field: 'value'
|
|
|
* });
|
|
|
*/
|
|
|
mixIn: function (properties) {
|
|
|
for (var propertyName in properties) {
|
|
|
if (properties.hasOwnProperty(propertyName)) {
|
|
|
this[propertyName] = properties[propertyName];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// IE won't copy toString using the loop above
|
|
|
if (properties.hasOwnProperty('toString')) {
|
|
|
this.toString = properties.toString;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Creates a copy of this object.
|
|
|
*
|
|
|
* @return {Object} The clone.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var clone = instance.clone();
|
|
|
*/
|
|
|
clone: function () {
|
|
|
return this.init.prototype.extend(this);
|
|
|
}
|
|
|
};
|
|
|
}());
|
|
|
|
|
|
/**
|
|
|
* An array of 32-bit words.
|
|
|
*
|
|
|
* @property {Array} words The array of 32-bit words.
|
|
|
* @property {number} sigBytes The number of significant bytes in this word array.
|
|
|
*/
|
|
|
var WordArray = C_lib.WordArray = Base.extend({
|
|
|
/**
|
|
|
* Initializes a newly created word array.
|
|
|
*
|
|
|
* @param {Array} words (Optional) An array of 32-bit words.
|
|
|
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.lib.WordArray.create();
|
|
|
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
|
|
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
|
|
*/
|
|
|
init: function (words, sigBytes) {
|
|
|
words = this.words = words || [];
|
|
|
|
|
|
if (sigBytes != undefined) {
|
|
|
this.sigBytes = sigBytes;
|
|
|
} else {
|
|
|
this.sigBytes = words.length * 4;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts this word array to a string.
|
|
|
*
|
|
|
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
|
|
*
|
|
|
* @return {string} The stringified word array.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var string = wordArray + '';
|
|
|
* var string = wordArray.toString();
|
|
|
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
|
|
*/
|
|
|
toString: function (encoder) {
|
|
|
return (encoder || Hex).stringify(this);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Concatenates a word array to this word array.
|
|
|
*
|
|
|
* @param {WordArray} wordArray The word array to append.
|
|
|
*
|
|
|
* @return {WordArray} This word array.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* wordArray1.concat(wordArray2);
|
|
|
*/
|
|
|
concat: function (wordArray) {
|
|
|
// Shortcuts
|
|
|
var thisWords = this.words;
|
|
|
var thatWords = wordArray.words;
|
|
|
var thisSigBytes = this.sigBytes;
|
|
|
var thatSigBytes = wordArray.sigBytes;
|
|
|
|
|
|
// Clamp excess bits
|
|
|
this.clamp();
|
|
|
|
|
|
// Concat
|
|
|
if (thisSigBytes % 4) {
|
|
|
// Copy one byte at a time
|
|
|
for (var i = 0; i < thatSigBytes; i++) {
|
|
|
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
|
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
|
|
}
|
|
|
} else {
|
|
|
// Copy one word at a time
|
|
|
for (var j = 0; j < thatSigBytes; j += 4) {
|
|
|
thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
|
|
|
}
|
|
|
}
|
|
|
this.sigBytes += thatSigBytes;
|
|
|
|
|
|
// Chainable
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Removes insignificant bits.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* wordArray.clamp();
|
|
|
*/
|
|
|
clamp: function () {
|
|
|
// Shortcuts
|
|
|
var words = this.words;
|
|
|
var sigBytes = this.sigBytes;
|
|
|
|
|
|
// Clamp
|
|
|
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
|
|
words.length = Math.ceil(sigBytes / 4);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Creates a copy of this word array.
|
|
|
*
|
|
|
* @return {WordArray} The clone.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var clone = wordArray.clone();
|
|
|
*/
|
|
|
clone: function () {
|
|
|
var clone = Base.clone.call(this);
|
|
|
clone.words = this.words.slice(0);
|
|
|
|
|
|
return clone;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Creates a word array filled with random bytes.
|
|
|
*
|
|
|
* @param {number} nBytes The number of random bytes to generate.
|
|
|
*
|
|
|
* @return {WordArray} The random word array.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
|
|
*/
|
|
|
random: function (nBytes) {
|
|
|
var words = [];
|
|
|
|
|
|
for (var i = 0; i < nBytes; i += 4) {
|
|
|
words.push(cryptoSecureRandomInt());
|
|
|
}
|
|
|
|
|
|
return new WordArray.init(words, nBytes);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Encoder namespace.
|
|
|
*/
|
|
|
var C_enc = C.enc = {};
|
|
|
|
|
|
/**
|
|
|
* Hex encoding strategy.
|
|
|
*/
|
|
|
var Hex = C_enc.Hex = {
|
|
|
/**
|
|
|
* Converts a word array to a hex string.
|
|
|
*
|
|
|
* @param {WordArray} wordArray The word array.
|
|
|
*
|
|
|
* @return {string} The hex string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
|
|
*/
|
|
|
stringify: function (wordArray) {
|
|
|
// Shortcuts
|
|
|
var words = wordArray.words;
|
|
|
var sigBytes = wordArray.sigBytes;
|
|
|
|
|
|
// Convert
|
|
|
var hexChars = [];
|
|
|
for (var i = 0; i < sigBytes; i++) {
|
|
|
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
|
hexChars.push((bite >>> 4).toString(16));
|
|
|
hexChars.push((bite & 0x0f).toString(16));
|
|
|
}
|
|
|
|
|
|
return hexChars.join('');
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts a hex string to a word array.
|
|
|
*
|
|
|
* @param {string} hexStr The hex string.
|
|
|
*
|
|
|
* @return {WordArray} The word array.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
|
|
*/
|
|
|
parse: function (hexStr) {
|
|
|
// Shortcut
|
|
|
var hexStrLength = hexStr.length;
|
|
|
|
|
|
// Convert
|
|
|
var words = [];
|
|
|
for (var i = 0; i < hexStrLength; i += 2) {
|
|
|
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
|
|
}
|
|
|
|
|
|
return new WordArray.init(words, hexStrLength / 2);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Latin1 encoding strategy.
|
|
|
*/
|
|
|
var Latin1 = C_enc.Latin1 = {
|
|
|
/**
|
|
|
* Converts a word array to a Latin1 string.
|
|
|
*
|
|
|
* @param {WordArray} wordArray The word array.
|
|
|
*
|
|
|
* @return {string} The Latin1 string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
|
|
*/
|
|
|
stringify: function (wordArray) {
|
|
|
// Shortcuts
|
|
|
var words = wordArray.words;
|
|
|
var sigBytes = wordArray.sigBytes;
|
|
|
|
|
|
// Convert
|
|
|
var latin1Chars = [];
|
|
|
for (var i = 0; i < sigBytes; i++) {
|
|
|
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
|
latin1Chars.push(String.fromCharCode(bite));
|
|
|
}
|
|
|
|
|
|
return latin1Chars.join('');
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts a Latin1 string to a word array.
|
|
|
*
|
|
|
* @param {string} latin1Str The Latin1 string.
|
|
|
*
|
|
|
* @return {WordArray} The word array.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
|
|
*/
|
|
|
parse: function (latin1Str) {
|
|
|
// Shortcut
|
|
|
var latin1StrLength = latin1Str.length;
|
|
|
|
|
|
// Convert
|
|
|
var words = [];
|
|
|
for (var i = 0; i < latin1StrLength; i++) {
|
|
|
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
|
|
}
|
|
|
|
|
|
return new WordArray.init(words, latin1StrLength);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* UTF-8 encoding strategy.
|
|
|
*/
|
|
|
var Utf8 = C_enc.Utf8 = {
|
|
|
/**
|
|
|
* Converts a word array to a UTF-8 string.
|
|
|
*
|
|
|
* @param {WordArray} wordArray The word array.
|
|
|
*
|
|
|
* @return {string} The UTF-8 string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
|
|
*/
|
|
|
stringify: function (wordArray) {
|
|
|
try {
|
|
|
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
|
|
} catch (e) {
|
|
|
throw new Error('Malformed UTF-8 data');
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts a UTF-8 string to a word array.
|
|
|
*
|
|
|
* @param {string} utf8Str The UTF-8 string.
|
|
|
*
|
|
|
* @return {WordArray} The word array.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
|
|
*/
|
|
|
parse: function (utf8Str) {
|
|
|
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Abstract buffered block algorithm template.
|
|
|
*
|
|
|
* The property blockSize must be implemented in a concrete subtype.
|
|
|
*
|
|
|
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
|
|
*/
|
|
|
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
|
|
/**
|
|
|
* Resets this block algorithm's data buffer to its initial state.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* bufferedBlockAlgorithm.reset();
|
|
|
*/
|
|
|
reset: function () {
|
|
|
// Initial values
|
|
|
this._data = new WordArray.init();
|
|
|
this._nDataBytes = 0;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Adds new data to this block algorithm's buffer.
|
|
|
*
|
|
|
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* bufferedBlockAlgorithm._append('data');
|
|
|
* bufferedBlockAlgorithm._append(wordArray);
|
|
|
*/
|
|
|
_append: function (data) {
|
|
|
// Convert string to WordArray, else assume WordArray already
|
|
|
if (typeof data == 'string') {
|
|
|
data = Utf8.parse(data);
|
|
|
}
|
|
|
|
|
|
// Append
|
|
|
this._data.concat(data);
|
|
|
this._nDataBytes += data.sigBytes;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Processes available data blocks.
|
|
|
*
|
|
|
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
|
|
*
|
|
|
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
|
|
*
|
|
|
* @return {WordArray} The processed data.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var processedData = bufferedBlockAlgorithm._process();
|
|
|
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
|
|
*/
|
|
|
_process: function (doFlush) {
|
|
|
var processedWords;
|
|
|
|
|
|
// Shortcuts
|
|
|
var data = this._data;
|
|
|
var dataWords = data.words;
|
|
|
var dataSigBytes = data.sigBytes;
|
|
|
var blockSize = this.blockSize;
|
|
|
var blockSizeBytes = blockSize * 4;
|
|
|
|
|
|
// Count blocks ready
|
|
|
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
|
|
if (doFlush) {
|
|
|
// Round up to include partial blocks
|
|
|
nBlocksReady = Math.ceil(nBlocksReady);
|
|
|
} else {
|
|
|
// Round down to include only full blocks,
|
|
|
// less the number of blocks that must remain in the buffer
|
|
|
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
|
}
|
|
|
|
|
|
// Count words ready
|
|
|
var nWordsReady = nBlocksReady * blockSize;
|
|
|
|
|
|
// Count bytes ready
|
|
|
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
|
|
|
|
|
// Process blocks
|
|
|
if (nWordsReady) {
|
|
|
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
|
|
// Perform concrete-algorithm logic
|
|
|
this._doProcessBlock(dataWords, offset);
|
|
|
}
|
|
|
|
|
|
// Remove processed words
|
|
|
processedWords = dataWords.splice(0, nWordsReady);
|
|
|
data.sigBytes -= nBytesReady;
|
|
|
}
|
|
|
|
|
|
// Return processed words
|
|
|
return new WordArray.init(processedWords, nBytesReady);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Creates a copy of this object.
|
|
|
*
|
|
|
* @return {Object} The clone.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var clone = bufferedBlockAlgorithm.clone();
|
|
|
*/
|
|
|
clone: function () {
|
|
|
var clone = Base.clone.call(this);
|
|
|
clone._data = this._data.clone();
|
|
|
|
|
|
return clone;
|
|
|
},
|
|
|
|
|
|
_minBufferSize: 0
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Abstract hasher template.
|
|
|
*
|
|
|
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
|
|
|
*/
|
|
|
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*/
|
|
|
cfg: Base.extend(),
|
|
|
|
|
|
/**
|
|
|
* Initializes a newly created hasher.
|
|
|
*
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hasher = CryptoJS.algo.SHA256.create();
|
|
|
*/
|
|
|
init: function (cfg) {
|
|
|
// Apply config defaults
|
|
|
this.cfg = this.cfg.extend(cfg);
|
|
|
|
|
|
// Set initial values
|
|
|
this.reset();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Resets this hasher to its initial state.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* hasher.reset();
|
|
|
*/
|
|
|
reset: function () {
|
|
|
// Reset data buffer
|
|
|
BufferedBlockAlgorithm.reset.call(this);
|
|
|
|
|
|
// Perform concrete-hasher logic
|
|
|
this._doReset();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Updates this hasher with a message.
|
|
|
*
|
|
|
* @param {WordArray|string} messageUpdate The message to append.
|
|
|
*
|
|
|
* @return {Hasher} This hasher.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* hasher.update('message');
|
|
|
* hasher.update(wordArray);
|
|
|
*/
|
|
|
update: function (messageUpdate) {
|
|
|
// Append
|
|
|
this._append(messageUpdate);
|
|
|
|
|
|
// Update the hash
|
|
|
this._process();
|
|
|
|
|
|
// Chainable
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Finalizes the hash computation.
|
|
|
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
|
*
|
|
|
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = hasher.finalize();
|
|
|
* var hash = hasher.finalize('message');
|
|
|
* var hash = hasher.finalize(wordArray);
|
|
|
*/
|
|
|
finalize: function (messageUpdate) {
|
|
|
// Final message update
|
|
|
if (messageUpdate) {
|
|
|
this._append(messageUpdate);
|
|
|
}
|
|
|
|
|
|
// Perform concrete-hasher logic
|
|
|
var hash = this._doFinalize();
|
|
|
|
|
|
return hash;
|
|
|
},
|
|
|
|
|
|
blockSize: 512/32,
|
|
|
|
|
|
/**
|
|
|
* Creates a shortcut function to a hasher's object interface.
|
|
|
*
|
|
|
* @param {Hasher} hasher The hasher to create a helper for.
|
|
|
*
|
|
|
* @return {Function} The shortcut function.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
|
|
*/
|
|
|
_createHelper: function (hasher) {
|
|
|
return function (message, cfg) {
|
|
|
return new hasher.init(cfg).finalize(message);
|
|
|
};
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Creates a shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
|
|
*
|
|
|
* @return {Function} The shortcut function.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
|
|
*/
|
|
|
_createHmacHelper: function (hasher) {
|
|
|
return function (message, key) {
|
|
|
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
|
|
};
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Algorithm namespace.
|
|
|
*/
|
|
|
var C_algo = C.algo = {};
|
|
|
|
|
|
return C;
|
|
|
}(Math));
|
|
|
|
|
|
|
|
|
return CryptoJS;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 98269:
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/enc-base64.js ***!
|
|
|
\**********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var C_enc = C.enc;
|
|
|
|
|
|
/**
|
|
|
* Base64 encoding strategy.
|
|
|
*/
|
|
|
var Base64 = C_enc.Base64 = {
|
|
|
/**
|
|
|
* Converts a word array to a Base64 string.
|
|
|
*
|
|
|
* @param {WordArray} wordArray The word array.
|
|
|
*
|
|
|
* @return {string} The Base64 string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var base64String = CryptoJS.enc.Base64.stringify(wordArray);
|
|
|
*/
|
|
|
stringify: function (wordArray) {
|
|
|
// Shortcuts
|
|
|
var words = wordArray.words;
|
|
|
var sigBytes = wordArray.sigBytes;
|
|
|
var map = this._map;
|
|
|
|
|
|
// Clamp excess bits
|
|
|
wordArray.clamp();
|
|
|
|
|
|
// Convert
|
|
|
var base64Chars = [];
|
|
|
for (var i = 0; i < sigBytes; i += 3) {
|
|
|
var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
|
var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
|
|
|
var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
|
|
|
|
|
|
var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
|
|
|
|
|
|
for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
|
|
|
base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Add padding
|
|
|
var paddingChar = map.charAt(64);
|
|
|
if (paddingChar) {
|
|
|
while (base64Chars.length % 4) {
|
|
|
base64Chars.push(paddingChar);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return base64Chars.join('');
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts a Base64 string to a word array.
|
|
|
*
|
|
|
* @param {string} base64Str The Base64 string.
|
|
|
*
|
|
|
* @return {WordArray} The word array.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.enc.Base64.parse(base64String);
|
|
|
*/
|
|
|
parse: function (base64Str) {
|
|
|
// Shortcuts
|
|
|
var base64StrLength = base64Str.length;
|
|
|
var map = this._map;
|
|
|
var reverseMap = this._reverseMap;
|
|
|
|
|
|
if (!reverseMap) {
|
|
|
reverseMap = this._reverseMap = [];
|
|
|
for (var j = 0; j < map.length; j++) {
|
|
|
reverseMap[map.charCodeAt(j)] = j;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Ignore padding
|
|
|
var paddingChar = map.charAt(64);
|
|
|
if (paddingChar) {
|
|
|
var paddingIndex = base64Str.indexOf(paddingChar);
|
|
|
if (paddingIndex !== -1) {
|
|
|
base64StrLength = paddingIndex;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Convert
|
|
|
return parseLoop(base64Str, base64StrLength, reverseMap);
|
|
|
|
|
|
},
|
|
|
|
|
|
_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
|
|
};
|
|
|
|
|
|
function parseLoop(base64Str, base64StrLength, reverseMap) {
|
|
|
var words = [];
|
|
|
var nBytes = 0;
|
|
|
for (var i = 0; i < base64StrLength; i++) {
|
|
|
if (i % 4) {
|
|
|
var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
|
|
|
var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
|
|
|
var bitsCombined = bits1 | bits2;
|
|
|
words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
|
|
|
nBytes++;
|
|
|
}
|
|
|
}
|
|
|
return WordArray.create(words, nBytes);
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.enc.Base64;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 43786:
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/enc-base64url.js ***!
|
|
|
\*************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var C_enc = C.enc;
|
|
|
|
|
|
/**
|
|
|
* Base64url encoding strategy.
|
|
|
*/
|
|
|
var Base64url = C_enc.Base64url = {
|
|
|
/**
|
|
|
* Converts a word array to a Base64url string.
|
|
|
*
|
|
|
* @param {WordArray} wordArray The word array.
|
|
|
*
|
|
|
* @param {boolean} urlSafe Whether to use url safe
|
|
|
*
|
|
|
* @return {string} The Base64url string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
|
|
|
*/
|
|
|
stringify: function (wordArray, urlSafe=true) {
|
|
|
// Shortcuts
|
|
|
var words = wordArray.words;
|
|
|
var sigBytes = wordArray.sigBytes;
|
|
|
var map = urlSafe ? this._safe_map : this._map;
|
|
|
|
|
|
// Clamp excess bits
|
|
|
wordArray.clamp();
|
|
|
|
|
|
// Convert
|
|
|
var base64Chars = [];
|
|
|
for (var i = 0; i < sigBytes; i += 3) {
|
|
|
var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
|
var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
|
|
|
var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
|
|
|
|
|
|
var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
|
|
|
|
|
|
for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
|
|
|
base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Add padding
|
|
|
var paddingChar = map.charAt(64);
|
|
|
if (paddingChar) {
|
|
|
while (base64Chars.length % 4) {
|
|
|
base64Chars.push(paddingChar);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return base64Chars.join('');
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts a Base64url string to a word array.
|
|
|
*
|
|
|
* @param {string} base64Str The Base64url string.
|
|
|
*
|
|
|
* @param {boolean} urlSafe Whether to use url safe
|
|
|
*
|
|
|
* @return {WordArray} The word array.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.enc.Base64url.parse(base64String);
|
|
|
*/
|
|
|
parse: function (base64Str, urlSafe=true) {
|
|
|
// Shortcuts
|
|
|
var base64StrLength = base64Str.length;
|
|
|
var map = urlSafe ? this._safe_map : this._map;
|
|
|
var reverseMap = this._reverseMap;
|
|
|
|
|
|
if (!reverseMap) {
|
|
|
reverseMap = this._reverseMap = [];
|
|
|
for (var j = 0; j < map.length; j++) {
|
|
|
reverseMap[map.charCodeAt(j)] = j;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Ignore padding
|
|
|
var paddingChar = map.charAt(64);
|
|
|
if (paddingChar) {
|
|
|
var paddingIndex = base64Str.indexOf(paddingChar);
|
|
|
if (paddingIndex !== -1) {
|
|
|
base64StrLength = paddingIndex;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Convert
|
|
|
return parseLoop(base64Str, base64StrLength, reverseMap);
|
|
|
|
|
|
},
|
|
|
|
|
|
_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
|
_safe_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
|
|
};
|
|
|
|
|
|
function parseLoop(base64Str, base64StrLength, reverseMap) {
|
|
|
var words = [];
|
|
|
var nBytes = 0;
|
|
|
for (var i = 0; i < base64StrLength; i++) {
|
|
|
if (i % 4) {
|
|
|
var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
|
|
|
var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
|
|
|
var bitsCombined = bits1 | bits2;
|
|
|
words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
|
|
|
nBytes++;
|
|
|
}
|
|
|
}
|
|
|
return WordArray.create(words, nBytes);
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
return CryptoJS.enc.Base64url;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 50298:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/enc-utf16.js ***!
|
|
|
\*********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var C_enc = C.enc;
|
|
|
|
|
|
/**
|
|
|
* UTF-16 BE encoding strategy.
|
|
|
*/
|
|
|
var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
|
|
|
/**
|
|
|
* Converts a word array to a UTF-16 BE string.
|
|
|
*
|
|
|
* @param {WordArray} wordArray The word array.
|
|
|
*
|
|
|
* @return {string} The UTF-16 BE string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
|
|
|
*/
|
|
|
stringify: function (wordArray) {
|
|
|
// Shortcuts
|
|
|
var words = wordArray.words;
|
|
|
var sigBytes = wordArray.sigBytes;
|
|
|
|
|
|
// Convert
|
|
|
var utf16Chars = [];
|
|
|
for (var i = 0; i < sigBytes; i += 2) {
|
|
|
var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
|
|
|
utf16Chars.push(String.fromCharCode(codePoint));
|
|
|
}
|
|
|
|
|
|
return utf16Chars.join('');
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts a UTF-16 BE string to a word array.
|
|
|
*
|
|
|
* @param {string} utf16Str The UTF-16 BE string.
|
|
|
*
|
|
|
* @return {WordArray} The word array.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
|
|
|
*/
|
|
|
parse: function (utf16Str) {
|
|
|
// Shortcut
|
|
|
var utf16StrLength = utf16Str.length;
|
|
|
|
|
|
// Convert
|
|
|
var words = [];
|
|
|
for (var i = 0; i < utf16StrLength; i++) {
|
|
|
words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
|
|
|
}
|
|
|
|
|
|
return WordArray.create(words, utf16StrLength * 2);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* UTF-16 LE encoding strategy.
|
|
|
*/
|
|
|
C_enc.Utf16LE = {
|
|
|
/**
|
|
|
* Converts a word array to a UTF-16 LE string.
|
|
|
*
|
|
|
* @param {WordArray} wordArray The word array.
|
|
|
*
|
|
|
* @return {string} The UTF-16 LE string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
|
|
|
*/
|
|
|
stringify: function (wordArray) {
|
|
|
// Shortcuts
|
|
|
var words = wordArray.words;
|
|
|
var sigBytes = wordArray.sigBytes;
|
|
|
|
|
|
// Convert
|
|
|
var utf16Chars = [];
|
|
|
for (var i = 0; i < sigBytes; i += 2) {
|
|
|
var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
|
|
|
utf16Chars.push(String.fromCharCode(codePoint));
|
|
|
}
|
|
|
|
|
|
return utf16Chars.join('');
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts a UTF-16 LE string to a word array.
|
|
|
*
|
|
|
* @param {string} utf16Str The UTF-16 LE string.
|
|
|
*
|
|
|
* @return {WordArray} The word array.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
|
|
|
*/
|
|
|
parse: function (utf16Str) {
|
|
|
// Shortcut
|
|
|
var utf16StrLength = utf16Str.length;
|
|
|
|
|
|
// Convert
|
|
|
var words = [];
|
|
|
for (var i = 0; i < utf16StrLength; i++) {
|
|
|
words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
|
|
|
}
|
|
|
|
|
|
return WordArray.create(words, utf16StrLength * 2);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function swapEndian(word) {
|
|
|
return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.enc.Utf16;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 90888:
|
|
|
/*!******************************************!*\
|
|
|
!*** ./node_modules/crypto-js/evpkdf.js ***!
|
|
|
\******************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./sha1 */ 62783), __webpack_require__(/*! ./hmac */ 89824));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var Base = C_lib.Base;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var C_algo = C.algo;
|
|
|
var MD5 = C_algo.MD5;
|
|
|
|
|
|
/**
|
|
|
* This key derivation function is meant to conform with EVP_BytesToKey.
|
|
|
* www.openssl.org/docs/crypto/EVP_BytesToKey.html
|
|
|
*/
|
|
|
var EvpKDF = C_algo.EvpKDF = Base.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*
|
|
|
* @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
|
|
|
* @property {Hasher} hasher The hash algorithm to use. Default: MD5
|
|
|
* @property {number} iterations The number of iterations to perform. Default: 1
|
|
|
*/
|
|
|
cfg: Base.extend({
|
|
|
keySize: 128/32,
|
|
|
hasher: MD5,
|
|
|
iterations: 1
|
|
|
}),
|
|
|
|
|
|
/**
|
|
|
* Initializes a newly created key derivation function.
|
|
|
*
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for the derivation.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var kdf = CryptoJS.algo.EvpKDF.create();
|
|
|
* var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
|
|
|
* var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
|
|
|
*/
|
|
|
init: function (cfg) {
|
|
|
this.cfg = this.cfg.extend(cfg);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Derives a key from a password.
|
|
|
*
|
|
|
* @param {WordArray|string} password The password.
|
|
|
* @param {WordArray|string} salt A salt.
|
|
|
*
|
|
|
* @return {WordArray} The derived key.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var key = kdf.compute(password, salt);
|
|
|
*/
|
|
|
compute: function (password, salt) {
|
|
|
var block;
|
|
|
|
|
|
// Shortcut
|
|
|
var cfg = this.cfg;
|
|
|
|
|
|
// Init hasher
|
|
|
var hasher = cfg.hasher.create();
|
|
|
|
|
|
// Initial values
|
|
|
var derivedKey = WordArray.create();
|
|
|
|
|
|
// Shortcuts
|
|
|
var derivedKeyWords = derivedKey.words;
|
|
|
var keySize = cfg.keySize;
|
|
|
var iterations = cfg.iterations;
|
|
|
|
|
|
// Generate key
|
|
|
while (derivedKeyWords.length < keySize) {
|
|
|
if (block) {
|
|
|
hasher.update(block);
|
|
|
}
|
|
|
block = hasher.update(password).finalize(salt);
|
|
|
hasher.reset();
|
|
|
|
|
|
// Iterations
|
|
|
for (var i = 1; i < iterations; i++) {
|
|
|
block = hasher.finalize(block);
|
|
|
hasher.reset();
|
|
|
}
|
|
|
|
|
|
derivedKey.concat(block);
|
|
|
}
|
|
|
derivedKey.sigBytes = keySize * 4;
|
|
|
|
|
|
return derivedKey;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Derives a key from a password.
|
|
|
*
|
|
|
* @param {WordArray|string} password The password.
|
|
|
* @param {WordArray|string} salt A salt.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this computation.
|
|
|
*
|
|
|
* @return {WordArray} The derived key.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var key = CryptoJS.EvpKDF(password, salt);
|
|
|
* var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
|
|
|
* var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
|
|
|
*/
|
|
|
C.EvpKDF = function (password, salt, cfg) {
|
|
|
return EvpKDF.create(cfg).compute(password, salt);
|
|
|
};
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.EvpKDF;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 42209:
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/format-hex.js ***!
|
|
|
\**********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function (undefined) {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var CipherParams = C_lib.CipherParams;
|
|
|
var C_enc = C.enc;
|
|
|
var Hex = C_enc.Hex;
|
|
|
var C_format = C.format;
|
|
|
|
|
|
var HexFormatter = C_format.Hex = {
|
|
|
/**
|
|
|
* Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
|
|
|
*
|
|
|
* @param {CipherParams} cipherParams The cipher params object.
|
|
|
*
|
|
|
* @return {string} The hexadecimally encoded string.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hexString = CryptoJS.format.Hex.stringify(cipherParams);
|
|
|
*/
|
|
|
stringify: function (cipherParams) {
|
|
|
return cipherParams.ciphertext.toString(Hex);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts a hexadecimally encoded ciphertext string to a cipher params object.
|
|
|
*
|
|
|
* @param {string} input The hexadecimally encoded string.
|
|
|
*
|
|
|
* @return {CipherParams} The cipher params object.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var cipherParams = CryptoJS.format.Hex.parse(hexString);
|
|
|
*/
|
|
|
parse: function (input) {
|
|
|
var ciphertext = Hex.parse(input);
|
|
|
return CipherParams.create({ ciphertext: ciphertext });
|
|
|
}
|
|
|
};
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.format.Hex;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 89824:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./node_modules/crypto-js/hmac.js ***!
|
|
|
\****************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var Base = C_lib.Base;
|
|
|
var C_enc = C.enc;
|
|
|
var Utf8 = C_enc.Utf8;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
/**
|
|
|
* HMAC algorithm.
|
|
|
*/
|
|
|
var HMAC = C_algo.HMAC = Base.extend({
|
|
|
/**
|
|
|
* Initializes a newly created HMAC.
|
|
|
*
|
|
|
* @param {Hasher} hasher The hash algorithm to use.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
|
|
|
*/
|
|
|
init: function (hasher, key) {
|
|
|
// Init hasher
|
|
|
hasher = this._hasher = new hasher.init();
|
|
|
|
|
|
// Convert string to WordArray, else assume WordArray already
|
|
|
if (typeof key == 'string') {
|
|
|
key = Utf8.parse(key);
|
|
|
}
|
|
|
|
|
|
// Shortcuts
|
|
|
var hasherBlockSize = hasher.blockSize;
|
|
|
var hasherBlockSizeBytes = hasherBlockSize * 4;
|
|
|
|
|
|
// Allow arbitrary length keys
|
|
|
if (key.sigBytes > hasherBlockSizeBytes) {
|
|
|
key = hasher.finalize(key);
|
|
|
}
|
|
|
|
|
|
// Clamp excess bits
|
|
|
key.clamp();
|
|
|
|
|
|
// Clone key for inner and outer pads
|
|
|
var oKey = this._oKey = key.clone();
|
|
|
var iKey = this._iKey = key.clone();
|
|
|
|
|
|
// Shortcuts
|
|
|
var oKeyWords = oKey.words;
|
|
|
var iKeyWords = iKey.words;
|
|
|
|
|
|
// XOR keys with pad constants
|
|
|
for (var i = 0; i < hasherBlockSize; i++) {
|
|
|
oKeyWords[i] ^= 0x5c5c5c5c;
|
|
|
iKeyWords[i] ^= 0x36363636;
|
|
|
}
|
|
|
oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
|
|
|
|
|
|
// Set initial values
|
|
|
this.reset();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Resets this HMAC to its initial state.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* hmacHasher.reset();
|
|
|
*/
|
|
|
reset: function () {
|
|
|
// Shortcut
|
|
|
var hasher = this._hasher;
|
|
|
|
|
|
// Reset
|
|
|
hasher.reset();
|
|
|
hasher.update(this._iKey);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Updates this HMAC with a message.
|
|
|
*
|
|
|
* @param {WordArray|string} messageUpdate The message to append.
|
|
|
*
|
|
|
* @return {HMAC} This HMAC instance.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* hmacHasher.update('message');
|
|
|
* hmacHasher.update(wordArray);
|
|
|
*/
|
|
|
update: function (messageUpdate) {
|
|
|
this._hasher.update(messageUpdate);
|
|
|
|
|
|
// Chainable
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Finalizes the HMAC computation.
|
|
|
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
|
*
|
|
|
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = hmacHasher.finalize();
|
|
|
* var hmac = hmacHasher.finalize('message');
|
|
|
* var hmac = hmacHasher.finalize(wordArray);
|
|
|
*/
|
|
|
finalize: function (messageUpdate) {
|
|
|
// Shortcut
|
|
|
var hasher = this._hasher;
|
|
|
|
|
|
// Compute HMAC
|
|
|
var innerHash = hasher.finalize(messageUpdate);
|
|
|
hasher.reset();
|
|
|
var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
|
|
|
|
|
|
return hmac;
|
|
|
}
|
|
|
});
|
|
|
}());
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 81354:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/crypto-js/index.js ***!
|
|
|
\*****************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./x64-core */ 64938), __webpack_require__(/*! ./lib-typedarrays */ 4433), __webpack_require__(/*! ./enc-utf16 */ 50298), __webpack_require__(/*! ./enc-base64 */ 98269), __webpack_require__(/*! ./enc-base64url */ 43786), __webpack_require__(/*! ./md5 */ 68214), __webpack_require__(/*! ./sha1 */ 62783), __webpack_require__(/*! ./sha256 */ 52153), __webpack_require__(/*! ./sha224 */ 87792), __webpack_require__(/*! ./sha512 */ 70034), __webpack_require__(/*! ./sha384 */ 17460), __webpack_require__(/*! ./sha3 */ 13327), __webpack_require__(/*! ./ripemd160 */ 30706), __webpack_require__(/*! ./hmac */ 89824), __webpack_require__(/*! ./pbkdf2 */ 2112), __webpack_require__(/*! ./evpkdf */ 90888), __webpack_require__(/*! ./cipher-core */ 75109), __webpack_require__(/*! ./mode-cfb */ 8568), __webpack_require__(/*! ./mode-ctr */ 74242), __webpack_require__(/*! ./mode-ctr-gladman */ 59968), __webpack_require__(/*! ./mode-ofb */ 27660), __webpack_require__(/*! ./mode-ecb */ 31148), __webpack_require__(/*! ./pad-ansix923 */ 43615), __webpack_require__(/*! ./pad-iso10126 */ 92807), __webpack_require__(/*! ./pad-iso97971 */ 71077), __webpack_require__(/*! ./pad-zeropadding */ 56475), __webpack_require__(/*! ./pad-nopadding */ 16991), __webpack_require__(/*! ./format-hex */ 42209), __webpack_require__(/*! ./aes */ 40452), __webpack_require__(/*! ./tripledes */ 94253), __webpack_require__(/*! ./rc4 */ 51857), __webpack_require__(/*! ./rabbit */ 84454), __webpack_require__(/*! ./rabbit-legacy */ 93974));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
return CryptoJS;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 4433:
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/lib-typedarrays.js ***!
|
|
|
\***************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Check if typed arrays are supported
|
|
|
if (typeof ArrayBuffer != 'function') {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
|
|
|
// Reference original init
|
|
|
var superInit = WordArray.init;
|
|
|
|
|
|
// Augment WordArray.init to handle typed arrays
|
|
|
var subInit = WordArray.init = function (typedArray) {
|
|
|
// Convert buffers to uint8
|
|
|
if (typedArray instanceof ArrayBuffer) {
|
|
|
typedArray = new Uint8Array(typedArray);
|
|
|
}
|
|
|
|
|
|
// Convert other array views to uint8
|
|
|
if (
|
|
|
typedArray instanceof Int8Array ||
|
|
|
(typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
|
|
|
typedArray instanceof Int16Array ||
|
|
|
typedArray instanceof Uint16Array ||
|
|
|
typedArray instanceof Int32Array ||
|
|
|
typedArray instanceof Uint32Array ||
|
|
|
typedArray instanceof Float32Array ||
|
|
|
typedArray instanceof Float64Array
|
|
|
) {
|
|
|
typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
|
|
|
}
|
|
|
|
|
|
// Handle Uint8Array
|
|
|
if (typedArray instanceof Uint8Array) {
|
|
|
// Shortcut
|
|
|
var typedArrayByteLength = typedArray.byteLength;
|
|
|
|
|
|
// Extract bytes
|
|
|
var words = [];
|
|
|
for (var i = 0; i < typedArrayByteLength; i++) {
|
|
|
words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
|
|
|
}
|
|
|
|
|
|
// Initialize this word array
|
|
|
superInit.call(this, words, typedArrayByteLength);
|
|
|
} else {
|
|
|
// Else call normal init
|
|
|
superInit.apply(this, arguments);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
subInit.prototype = WordArray;
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.lib.WordArray;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 68214:
|
|
|
/*!***************************************!*\
|
|
|
!*** ./node_modules/crypto-js/md5.js ***!
|
|
|
\***************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function (Math) {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var Hasher = C_lib.Hasher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Constants table
|
|
|
var T = [];
|
|
|
|
|
|
// Compute constants
|
|
|
(function () {
|
|
|
for (var i = 0; i < 64; i++) {
|
|
|
T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
/**
|
|
|
* MD5 hash algorithm.
|
|
|
*/
|
|
|
var MD5 = C_algo.MD5 = Hasher.extend({
|
|
|
_doReset: function () {
|
|
|
this._hash = new WordArray.init([
|
|
|
0x67452301, 0xefcdab89,
|
|
|
0x98badcfe, 0x10325476
|
|
|
]);
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
// Swap endian
|
|
|
for (var i = 0; i < 16; i++) {
|
|
|
// Shortcuts
|
|
|
var offset_i = offset + i;
|
|
|
var M_offset_i = M[offset_i];
|
|
|
|
|
|
M[offset_i] = (
|
|
|
(((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
|
|
|
(((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
}
|
|
|
|
|
|
// Shortcuts
|
|
|
var H = this._hash.words;
|
|
|
|
|
|
var M_offset_0 = M[offset + 0];
|
|
|
var M_offset_1 = M[offset + 1];
|
|
|
var M_offset_2 = M[offset + 2];
|
|
|
var M_offset_3 = M[offset + 3];
|
|
|
var M_offset_4 = M[offset + 4];
|
|
|
var M_offset_5 = M[offset + 5];
|
|
|
var M_offset_6 = M[offset + 6];
|
|
|
var M_offset_7 = M[offset + 7];
|
|
|
var M_offset_8 = M[offset + 8];
|
|
|
var M_offset_9 = M[offset + 9];
|
|
|
var M_offset_10 = M[offset + 10];
|
|
|
var M_offset_11 = M[offset + 11];
|
|
|
var M_offset_12 = M[offset + 12];
|
|
|
var M_offset_13 = M[offset + 13];
|
|
|
var M_offset_14 = M[offset + 14];
|
|
|
var M_offset_15 = M[offset + 15];
|
|
|
|
|
|
// Working varialbes
|
|
|
var a = H[0];
|
|
|
var b = H[1];
|
|
|
var c = H[2];
|
|
|
var d = H[3];
|
|
|
|
|
|
// Computation
|
|
|
a = FF(a, b, c, d, M_offset_0, 7, T[0]);
|
|
|
d = FF(d, a, b, c, M_offset_1, 12, T[1]);
|
|
|
c = FF(c, d, a, b, M_offset_2, 17, T[2]);
|
|
|
b = FF(b, c, d, a, M_offset_3, 22, T[3]);
|
|
|
a = FF(a, b, c, d, M_offset_4, 7, T[4]);
|
|
|
d = FF(d, a, b, c, M_offset_5, 12, T[5]);
|
|
|
c = FF(c, d, a, b, M_offset_6, 17, T[6]);
|
|
|
b = FF(b, c, d, a, M_offset_7, 22, T[7]);
|
|
|
a = FF(a, b, c, d, M_offset_8, 7, T[8]);
|
|
|
d = FF(d, a, b, c, M_offset_9, 12, T[9]);
|
|
|
c = FF(c, d, a, b, M_offset_10, 17, T[10]);
|
|
|
b = FF(b, c, d, a, M_offset_11, 22, T[11]);
|
|
|
a = FF(a, b, c, d, M_offset_12, 7, T[12]);
|
|
|
d = FF(d, a, b, c, M_offset_13, 12, T[13]);
|
|
|
c = FF(c, d, a, b, M_offset_14, 17, T[14]);
|
|
|
b = FF(b, c, d, a, M_offset_15, 22, T[15]);
|
|
|
|
|
|
a = GG(a, b, c, d, M_offset_1, 5, T[16]);
|
|
|
d = GG(d, a, b, c, M_offset_6, 9, T[17]);
|
|
|
c = GG(c, d, a, b, M_offset_11, 14, T[18]);
|
|
|
b = GG(b, c, d, a, M_offset_0, 20, T[19]);
|
|
|
a = GG(a, b, c, d, M_offset_5, 5, T[20]);
|
|
|
d = GG(d, a, b, c, M_offset_10, 9, T[21]);
|
|
|
c = GG(c, d, a, b, M_offset_15, 14, T[22]);
|
|
|
b = GG(b, c, d, a, M_offset_4, 20, T[23]);
|
|
|
a = GG(a, b, c, d, M_offset_9, 5, T[24]);
|
|
|
d = GG(d, a, b, c, M_offset_14, 9, T[25]);
|
|
|
c = GG(c, d, a, b, M_offset_3, 14, T[26]);
|
|
|
b = GG(b, c, d, a, M_offset_8, 20, T[27]);
|
|
|
a = GG(a, b, c, d, M_offset_13, 5, T[28]);
|
|
|
d = GG(d, a, b, c, M_offset_2, 9, T[29]);
|
|
|
c = GG(c, d, a, b, M_offset_7, 14, T[30]);
|
|
|
b = GG(b, c, d, a, M_offset_12, 20, T[31]);
|
|
|
|
|
|
a = HH(a, b, c, d, M_offset_5, 4, T[32]);
|
|
|
d = HH(d, a, b, c, M_offset_8, 11, T[33]);
|
|
|
c = HH(c, d, a, b, M_offset_11, 16, T[34]);
|
|
|
b = HH(b, c, d, a, M_offset_14, 23, T[35]);
|
|
|
a = HH(a, b, c, d, M_offset_1, 4, T[36]);
|
|
|
d = HH(d, a, b, c, M_offset_4, 11, T[37]);
|
|
|
c = HH(c, d, a, b, M_offset_7, 16, T[38]);
|
|
|
b = HH(b, c, d, a, M_offset_10, 23, T[39]);
|
|
|
a = HH(a, b, c, d, M_offset_13, 4, T[40]);
|
|
|
d = HH(d, a, b, c, M_offset_0, 11, T[41]);
|
|
|
c = HH(c, d, a, b, M_offset_3, 16, T[42]);
|
|
|
b = HH(b, c, d, a, M_offset_6, 23, T[43]);
|
|
|
a = HH(a, b, c, d, M_offset_9, 4, T[44]);
|
|
|
d = HH(d, a, b, c, M_offset_12, 11, T[45]);
|
|
|
c = HH(c, d, a, b, M_offset_15, 16, T[46]);
|
|
|
b = HH(b, c, d, a, M_offset_2, 23, T[47]);
|
|
|
|
|
|
a = II(a, b, c, d, M_offset_0, 6, T[48]);
|
|
|
d = II(d, a, b, c, M_offset_7, 10, T[49]);
|
|
|
c = II(c, d, a, b, M_offset_14, 15, T[50]);
|
|
|
b = II(b, c, d, a, M_offset_5, 21, T[51]);
|
|
|
a = II(a, b, c, d, M_offset_12, 6, T[52]);
|
|
|
d = II(d, a, b, c, M_offset_3, 10, T[53]);
|
|
|
c = II(c, d, a, b, M_offset_10, 15, T[54]);
|
|
|
b = II(b, c, d, a, M_offset_1, 21, T[55]);
|
|
|
a = II(a, b, c, d, M_offset_8, 6, T[56]);
|
|
|
d = II(d, a, b, c, M_offset_15, 10, T[57]);
|
|
|
c = II(c, d, a, b, M_offset_6, 15, T[58]);
|
|
|
b = II(b, c, d, a, M_offset_13, 21, T[59]);
|
|
|
a = II(a, b, c, d, M_offset_4, 6, T[60]);
|
|
|
d = II(d, a, b, c, M_offset_11, 10, T[61]);
|
|
|
c = II(c, d, a, b, M_offset_2, 15, T[62]);
|
|
|
b = II(b, c, d, a, M_offset_9, 21, T[63]);
|
|
|
|
|
|
// Intermediate hash value
|
|
|
H[0] = (H[0] + a) | 0;
|
|
|
H[1] = (H[1] + b) | 0;
|
|
|
H[2] = (H[2] + c) | 0;
|
|
|
H[3] = (H[3] + d) | 0;
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
// Shortcuts
|
|
|
var data = this._data;
|
|
|
var dataWords = data.words;
|
|
|
|
|
|
var nBitsTotal = this._nDataBytes * 8;
|
|
|
var nBitsLeft = data.sigBytes * 8;
|
|
|
|
|
|
// Add padding
|
|
|
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
|
|
|
|
|
var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
|
|
|
var nBitsTotalL = nBitsTotal;
|
|
|
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
|
|
|
(((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
|
|
|
(((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
|
|
|
(((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
|
|
|
(((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
|
|
|
data.sigBytes = (dataWords.length + 1) * 4;
|
|
|
|
|
|
// Hash final blocks
|
|
|
this._process();
|
|
|
|
|
|
// Shortcuts
|
|
|
var hash = this._hash;
|
|
|
var H = hash.words;
|
|
|
|
|
|
// Swap endian
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
// Shortcut
|
|
|
var H_i = H[i];
|
|
|
|
|
|
H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
|
|
|
(((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
|
|
|
}
|
|
|
|
|
|
// Return final computed hash
|
|
|
return hash;
|
|
|
},
|
|
|
|
|
|
clone: function () {
|
|
|
var clone = Hasher.clone.call(this);
|
|
|
clone._hash = this._hash.clone();
|
|
|
|
|
|
return clone;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function FF(a, b, c, d, x, s, t) {
|
|
|
var n = a + ((b & c) | (~b & d)) + x + t;
|
|
|
return ((n << s) | (n >>> (32 - s))) + b;
|
|
|
}
|
|
|
|
|
|
function GG(a, b, c, d, x, s, t) {
|
|
|
var n = a + ((b & d) | (c & ~d)) + x + t;
|
|
|
return ((n << s) | (n >>> (32 - s))) + b;
|
|
|
}
|
|
|
|
|
|
function HH(a, b, c, d, x, s, t) {
|
|
|
var n = a + (b ^ c ^ d) + x + t;
|
|
|
return ((n << s) | (n >>> (32 - s))) + b;
|
|
|
}
|
|
|
|
|
|
function II(a, b, c, d, x, s, t) {
|
|
|
var n = a + (c ^ (b | ~d)) + x + t;
|
|
|
return ((n << s) | (n >>> (32 - s))) + b;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the hasher's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = CryptoJS.MD5('message');
|
|
|
* var hash = CryptoJS.MD5(wordArray);
|
|
|
*/
|
|
|
C.MD5 = Hasher._createHelper(MD5);
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = CryptoJS.HmacMD5(message, key);
|
|
|
*/
|
|
|
C.HmacMD5 = Hasher._createHmacHelper(MD5);
|
|
|
}(Math));
|
|
|
|
|
|
|
|
|
return CryptoJS.MD5;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 8568:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/mode-cfb.js ***!
|
|
|
\********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* Cipher Feedback block mode.
|
|
|
*/
|
|
|
CryptoJS.mode.CFB = (function () {
|
|
|
var CFB = CryptoJS.lib.BlockCipherMode.extend();
|
|
|
|
|
|
CFB.Encryptor = CFB.extend({
|
|
|
processBlock: function (words, offset) {
|
|
|
// Shortcuts
|
|
|
var cipher = this._cipher;
|
|
|
var blockSize = cipher.blockSize;
|
|
|
|
|
|
generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
|
|
|
|
|
|
// Remember this block to use with next block
|
|
|
this._prevBlock = words.slice(offset, offset + blockSize);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
CFB.Decryptor = CFB.extend({
|
|
|
processBlock: function (words, offset) {
|
|
|
// Shortcuts
|
|
|
var cipher = this._cipher;
|
|
|
var blockSize = cipher.blockSize;
|
|
|
|
|
|
// Remember this block to use with next block
|
|
|
var thisBlock = words.slice(offset, offset + blockSize);
|
|
|
|
|
|
generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
|
|
|
|
|
|
// This block becomes the previous block
|
|
|
this._prevBlock = thisBlock;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
|
|
|
var keystream;
|
|
|
|
|
|
// Shortcut
|
|
|
var iv = this._iv;
|
|
|
|
|
|
// Generate keystream
|
|
|
if (iv) {
|
|
|
keystream = iv.slice(0);
|
|
|
|
|
|
// Remove IV for subsequent blocks
|
|
|
this._iv = undefined;
|
|
|
} else {
|
|
|
keystream = this._prevBlock;
|
|
|
}
|
|
|
cipher.encryptBlock(keystream, 0);
|
|
|
|
|
|
// Encrypt
|
|
|
for (var i = 0; i < blockSize; i++) {
|
|
|
words[offset + i] ^= keystream[i];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return CFB;
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.mode.CFB;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 59968:
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/mode-ctr-gladman.js ***!
|
|
|
\****************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/** @preserve
|
|
|
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
|
|
* derived from CryptoJS.mode.CTR
|
|
|
* Jan Hruby jhruby.web@gmail.com
|
|
|
*/
|
|
|
CryptoJS.mode.CTRGladman = (function () {
|
|
|
var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
|
|
|
|
|
|
function incWord(word)
|
|
|
{
|
|
|
if (((word >> 24) & 0xff) === 0xff) { //overflow
|
|
|
var b1 = (word >> 16)&0xff;
|
|
|
var b2 = (word >> 8)&0xff;
|
|
|
var b3 = word & 0xff;
|
|
|
|
|
|
if (b1 === 0xff) // overflow b1
|
|
|
{
|
|
|
b1 = 0;
|
|
|
if (b2 === 0xff)
|
|
|
{
|
|
|
b2 = 0;
|
|
|
if (b3 === 0xff)
|
|
|
{
|
|
|
b3 = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
++b3;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
++b2;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
++b1;
|
|
|
}
|
|
|
|
|
|
word = 0;
|
|
|
word += (b1 << 16);
|
|
|
word += (b2 << 8);
|
|
|
word += b3;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
word += (0x01 << 24);
|
|
|
}
|
|
|
return word;
|
|
|
}
|
|
|
|
|
|
function incCounter(counter)
|
|
|
{
|
|
|
if ((counter[0] = incWord(counter[0])) === 0)
|
|
|
{
|
|
|
// encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
|
|
|
counter[1] = incWord(counter[1]);
|
|
|
}
|
|
|
return counter;
|
|
|
}
|
|
|
|
|
|
var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
|
|
|
processBlock: function (words, offset) {
|
|
|
// Shortcuts
|
|
|
var cipher = this._cipher
|
|
|
var blockSize = cipher.blockSize;
|
|
|
var iv = this._iv;
|
|
|
var counter = this._counter;
|
|
|
|
|
|
// Generate keystream
|
|
|
if (iv) {
|
|
|
counter = this._counter = iv.slice(0);
|
|
|
|
|
|
// Remove IV for subsequent blocks
|
|
|
this._iv = undefined;
|
|
|
}
|
|
|
|
|
|
incCounter(counter);
|
|
|
|
|
|
var keystream = counter.slice(0);
|
|
|
cipher.encryptBlock(keystream, 0);
|
|
|
|
|
|
// Encrypt
|
|
|
for (var i = 0; i < blockSize; i++) {
|
|
|
words[offset + i] ^= keystream[i];
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
CTRGladman.Decryptor = Encryptor;
|
|
|
|
|
|
return CTRGladman;
|
|
|
}());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CryptoJS.mode.CTRGladman;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 74242:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/mode-ctr.js ***!
|
|
|
\********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* Counter block mode.
|
|
|
*/
|
|
|
CryptoJS.mode.CTR = (function () {
|
|
|
var CTR = CryptoJS.lib.BlockCipherMode.extend();
|
|
|
|
|
|
var Encryptor = CTR.Encryptor = CTR.extend({
|
|
|
processBlock: function (words, offset) {
|
|
|
// Shortcuts
|
|
|
var cipher = this._cipher
|
|
|
var blockSize = cipher.blockSize;
|
|
|
var iv = this._iv;
|
|
|
var counter = this._counter;
|
|
|
|
|
|
// Generate keystream
|
|
|
if (iv) {
|
|
|
counter = this._counter = iv.slice(0);
|
|
|
|
|
|
// Remove IV for subsequent blocks
|
|
|
this._iv = undefined;
|
|
|
}
|
|
|
var keystream = counter.slice(0);
|
|
|
cipher.encryptBlock(keystream, 0);
|
|
|
|
|
|
// Increment counter
|
|
|
counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
|
|
|
|
|
|
// Encrypt
|
|
|
for (var i = 0; i < blockSize; i++) {
|
|
|
words[offset + i] ^= keystream[i];
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
CTR.Decryptor = Encryptor;
|
|
|
|
|
|
return CTR;
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.mode.CTR;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 31148:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/mode-ecb.js ***!
|
|
|
\********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* Electronic Codebook block mode.
|
|
|
*/
|
|
|
CryptoJS.mode.ECB = (function () {
|
|
|
var ECB = CryptoJS.lib.BlockCipherMode.extend();
|
|
|
|
|
|
ECB.Encryptor = ECB.extend({
|
|
|
processBlock: function (words, offset) {
|
|
|
this._cipher.encryptBlock(words, offset);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
ECB.Decryptor = ECB.extend({
|
|
|
processBlock: function (words, offset) {
|
|
|
this._cipher.decryptBlock(words, offset);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return ECB;
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.mode.ECB;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 27660:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/mode-ofb.js ***!
|
|
|
\********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* Output Feedback block mode.
|
|
|
*/
|
|
|
CryptoJS.mode.OFB = (function () {
|
|
|
var OFB = CryptoJS.lib.BlockCipherMode.extend();
|
|
|
|
|
|
var Encryptor = OFB.Encryptor = OFB.extend({
|
|
|
processBlock: function (words, offset) {
|
|
|
// Shortcuts
|
|
|
var cipher = this._cipher
|
|
|
var blockSize = cipher.blockSize;
|
|
|
var iv = this._iv;
|
|
|
var keystream = this._keystream;
|
|
|
|
|
|
// Generate keystream
|
|
|
if (iv) {
|
|
|
keystream = this._keystream = iv.slice(0);
|
|
|
|
|
|
// Remove IV for subsequent blocks
|
|
|
this._iv = undefined;
|
|
|
}
|
|
|
cipher.encryptBlock(keystream, 0);
|
|
|
|
|
|
// Encrypt
|
|
|
for (var i = 0; i < blockSize; i++) {
|
|
|
words[offset + i] ^= keystream[i];
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
OFB.Decryptor = Encryptor;
|
|
|
|
|
|
return OFB;
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.mode.OFB;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 43615:
|
|
|
/*!************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/pad-ansix923.js ***!
|
|
|
\************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* ANSI X.923 padding strategy.
|
|
|
*/
|
|
|
CryptoJS.pad.AnsiX923 = {
|
|
|
pad: function (data, blockSize) {
|
|
|
// Shortcuts
|
|
|
var dataSigBytes = data.sigBytes;
|
|
|
var blockSizeBytes = blockSize * 4;
|
|
|
|
|
|
// Count padding bytes
|
|
|
var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
|
|
|
|
|
|
// Compute last byte position
|
|
|
var lastBytePos = dataSigBytes + nPaddingBytes - 1;
|
|
|
|
|
|
// Pad
|
|
|
data.clamp();
|
|
|
data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
|
|
|
data.sigBytes += nPaddingBytes;
|
|
|
},
|
|
|
|
|
|
unpad: function (data) {
|
|
|
// Get number of padding bytes from last byte
|
|
|
var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
|
|
|
|
|
// Remove padding
|
|
|
data.sigBytes -= nPaddingBytes;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
return CryptoJS.pad.Ansix923;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 92807:
|
|
|
/*!************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/pad-iso10126.js ***!
|
|
|
\************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* ISO 10126 padding strategy.
|
|
|
*/
|
|
|
CryptoJS.pad.Iso10126 = {
|
|
|
pad: function (data, blockSize) {
|
|
|
// Shortcut
|
|
|
var blockSizeBytes = blockSize * 4;
|
|
|
|
|
|
// Count padding bytes
|
|
|
var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
|
|
|
|
|
// Pad
|
|
|
data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
|
|
|
concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
|
|
|
},
|
|
|
|
|
|
unpad: function (data) {
|
|
|
// Get number of padding bytes from last byte
|
|
|
var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
|
|
|
|
|
// Remove padding
|
|
|
data.sigBytes -= nPaddingBytes;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
return CryptoJS.pad.Iso10126;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 71077:
|
|
|
/*!************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/pad-iso97971.js ***!
|
|
|
\************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* ISO/IEC 9797-1 Padding Method 2.
|
|
|
*/
|
|
|
CryptoJS.pad.Iso97971 = {
|
|
|
pad: function (data, blockSize) {
|
|
|
// Add 0x80 byte
|
|
|
data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
|
|
|
|
|
|
// Zero pad the rest
|
|
|
CryptoJS.pad.ZeroPadding.pad(data, blockSize);
|
|
|
},
|
|
|
|
|
|
unpad: function (data) {
|
|
|
// Remove zero padding
|
|
|
CryptoJS.pad.ZeroPadding.unpad(data);
|
|
|
|
|
|
// Remove one more byte -- the 0x80 byte
|
|
|
data.sigBytes--;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
return CryptoJS.pad.Iso97971;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 16991:
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/pad-nopadding.js ***!
|
|
|
\*************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* A noop padding strategy.
|
|
|
*/
|
|
|
CryptoJS.pad.NoPadding = {
|
|
|
pad: function () {
|
|
|
},
|
|
|
|
|
|
unpad: function () {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
return CryptoJS.pad.NoPadding;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 56475:
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/pad-zeropadding.js ***!
|
|
|
\***************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/**
|
|
|
* Zero padding strategy.
|
|
|
*/
|
|
|
CryptoJS.pad.ZeroPadding = {
|
|
|
pad: function (data, blockSize) {
|
|
|
// Shortcut
|
|
|
var blockSizeBytes = blockSize * 4;
|
|
|
|
|
|
// Pad
|
|
|
data.clamp();
|
|
|
data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
|
|
|
},
|
|
|
|
|
|
unpad: function (data) {
|
|
|
// Shortcut
|
|
|
var dataWords = data.words;
|
|
|
|
|
|
// Unpad
|
|
|
var i = data.sigBytes - 1;
|
|
|
for (var i = data.sigBytes - 1; i >= 0; i--) {
|
|
|
if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
|
|
|
data.sigBytes = i + 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
return CryptoJS.pad.ZeroPadding;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 2112:
|
|
|
/*!******************************************!*\
|
|
|
!*** ./node_modules/crypto-js/pbkdf2.js ***!
|
|
|
\******************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./sha1 */ 62783), __webpack_require__(/*! ./hmac */ 89824));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var Base = C_lib.Base;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var C_algo = C.algo;
|
|
|
var SHA1 = C_algo.SHA1;
|
|
|
var HMAC = C_algo.HMAC;
|
|
|
|
|
|
/**
|
|
|
* Password-Based Key Derivation Function 2 algorithm.
|
|
|
*/
|
|
|
var PBKDF2 = C_algo.PBKDF2 = Base.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*
|
|
|
* @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
|
|
|
* @property {Hasher} hasher The hasher to use. Default: SHA1
|
|
|
* @property {number} iterations The number of iterations to perform. Default: 1
|
|
|
*/
|
|
|
cfg: Base.extend({
|
|
|
keySize: 128/32,
|
|
|
hasher: SHA1,
|
|
|
iterations: 1
|
|
|
}),
|
|
|
|
|
|
/**
|
|
|
* Initializes a newly created key derivation function.
|
|
|
*
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for the derivation.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var kdf = CryptoJS.algo.PBKDF2.create();
|
|
|
* var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
|
|
|
* var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
|
|
|
*/
|
|
|
init: function (cfg) {
|
|
|
this.cfg = this.cfg.extend(cfg);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Computes the Password-Based Key Derivation Function 2.
|
|
|
*
|
|
|
* @param {WordArray|string} password The password.
|
|
|
* @param {WordArray|string} salt A salt.
|
|
|
*
|
|
|
* @return {WordArray} The derived key.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var key = kdf.compute(password, salt);
|
|
|
*/
|
|
|
compute: function (password, salt) {
|
|
|
// Shortcut
|
|
|
var cfg = this.cfg;
|
|
|
|
|
|
// Init HMAC
|
|
|
var hmac = HMAC.create(cfg.hasher, password);
|
|
|
|
|
|
// Initial values
|
|
|
var derivedKey = WordArray.create();
|
|
|
var blockIndex = WordArray.create([0x00000001]);
|
|
|
|
|
|
// Shortcuts
|
|
|
var derivedKeyWords = derivedKey.words;
|
|
|
var blockIndexWords = blockIndex.words;
|
|
|
var keySize = cfg.keySize;
|
|
|
var iterations = cfg.iterations;
|
|
|
|
|
|
// Generate key
|
|
|
while (derivedKeyWords.length < keySize) {
|
|
|
var block = hmac.update(salt).finalize(blockIndex);
|
|
|
hmac.reset();
|
|
|
|
|
|
// Shortcuts
|
|
|
var blockWords = block.words;
|
|
|
var blockWordsLength = blockWords.length;
|
|
|
|
|
|
// Iterations
|
|
|
var intermediate = block;
|
|
|
for (var i = 1; i < iterations; i++) {
|
|
|
intermediate = hmac.finalize(intermediate);
|
|
|
hmac.reset();
|
|
|
|
|
|
// Shortcut
|
|
|
var intermediateWords = intermediate.words;
|
|
|
|
|
|
// XOR intermediate with block
|
|
|
for (var j = 0; j < blockWordsLength; j++) {
|
|
|
blockWords[j] ^= intermediateWords[j];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
derivedKey.concat(block);
|
|
|
blockIndexWords[0]++;
|
|
|
}
|
|
|
derivedKey.sigBytes = keySize * 4;
|
|
|
|
|
|
return derivedKey;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Computes the Password-Based Key Derivation Function 2.
|
|
|
*
|
|
|
* @param {WordArray|string} password The password.
|
|
|
* @param {WordArray|string} salt A salt.
|
|
|
* @param {Object} cfg (Optional) The configuration options to use for this computation.
|
|
|
*
|
|
|
* @return {WordArray} The derived key.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var key = CryptoJS.PBKDF2(password, salt);
|
|
|
* var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
|
|
|
* var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
|
|
|
*/
|
|
|
C.PBKDF2 = function (password, salt, cfg) {
|
|
|
return PBKDF2.create(cfg).compute(password, salt);
|
|
|
};
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.PBKDF2;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 93974:
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./node_modules/crypto-js/rabbit-legacy.js ***!
|
|
|
\*************************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./enc-base64 */ 98269), __webpack_require__(/*! ./md5 */ 68214), __webpack_require__(/*! ./evpkdf */ 90888), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var StreamCipher = C_lib.StreamCipher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Reusable objects
|
|
|
var S = [];
|
|
|
var C_ = [];
|
|
|
var G = [];
|
|
|
|
|
|
/**
|
|
|
* Rabbit stream cipher algorithm.
|
|
|
*
|
|
|
* This is a legacy version that neglected to convert the key to little-endian.
|
|
|
* This error doesn't affect the cipher's security,
|
|
|
* but it does affect its compatibility with other implementations.
|
|
|
*/
|
|
|
var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
|
|
|
_doReset: function () {
|
|
|
// Shortcuts
|
|
|
var K = this._key.words;
|
|
|
var iv = this.cfg.iv;
|
|
|
|
|
|
// Generate initial state values
|
|
|
var X = this._X = [
|
|
|
K[0], (K[3] << 16) | (K[2] >>> 16),
|
|
|
K[1], (K[0] << 16) | (K[3] >>> 16),
|
|
|
K[2], (K[1] << 16) | (K[0] >>> 16),
|
|
|
K[3], (K[2] << 16) | (K[1] >>> 16)
|
|
|
];
|
|
|
|
|
|
// Generate initial counter values
|
|
|
var C = this._C = [
|
|
|
(K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
|
|
|
(K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
|
|
|
(K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
|
|
|
(K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
|
|
|
];
|
|
|
|
|
|
// Carry bit
|
|
|
this._b = 0;
|
|
|
|
|
|
// Iterate the system four times
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
nextState.call(this);
|
|
|
}
|
|
|
|
|
|
// Modify the counters
|
|
|
for (var i = 0; i < 8; i++) {
|
|
|
C[i] ^= X[(i + 4) & 7];
|
|
|
}
|
|
|
|
|
|
// IV setup
|
|
|
if (iv) {
|
|
|
// Shortcuts
|
|
|
var IV = iv.words;
|
|
|
var IV_0 = IV[0];
|
|
|
var IV_1 = IV[1];
|
|
|
|
|
|
// Generate four subvectors
|
|
|
var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
|
|
|
var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
|
|
|
var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
|
|
|
var i3 = (i2 << 16) | (i0 & 0x0000ffff);
|
|
|
|
|
|
// Modify counter values
|
|
|
C[0] ^= i0;
|
|
|
C[1] ^= i1;
|
|
|
C[2] ^= i2;
|
|
|
C[3] ^= i3;
|
|
|
C[4] ^= i0;
|
|
|
C[5] ^= i1;
|
|
|
C[6] ^= i2;
|
|
|
C[7] ^= i3;
|
|
|
|
|
|
// Iterate the system four times
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
nextState.call(this);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
// Shortcut
|
|
|
var X = this._X;
|
|
|
|
|
|
// Iterate the system
|
|
|
nextState.call(this);
|
|
|
|
|
|
// Generate four keystream words
|
|
|
S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
|
|
|
S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
|
|
|
S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
|
|
|
S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
|
|
|
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
// Swap endian
|
|
|
S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
|
|
|
(((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
|
|
|
|
|
|
// Encrypt
|
|
|
M[offset + i] ^= S[i];
|
|
|
}
|
|
|
},
|
|
|
|
|
|
blockSize: 128/32,
|
|
|
|
|
|
ivSize: 64/32
|
|
|
});
|
|
|
|
|
|
function nextState() {
|
|
|
// Shortcuts
|
|
|
var X = this._X;
|
|
|
var C = this._C;
|
|
|
|
|
|
// Save old counter values
|
|
|
for (var i = 0; i < 8; i++) {
|
|
|
C_[i] = C[i];
|
|
|
}
|
|
|
|
|
|
// Calculate new counter values
|
|
|
C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
|
|
|
C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
|
|
|
this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
|
|
|
|
|
|
// Calculate the g-values
|
|
|
for (var i = 0; i < 8; i++) {
|
|
|
var gx = X[i] + C[i];
|
|
|
|
|
|
// Construct high and low argument for squaring
|
|
|
var ga = gx & 0xffff;
|
|
|
var gb = gx >>> 16;
|
|
|
|
|
|
// Calculate high and low result of squaring
|
|
|
var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
|
|
|
var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
|
|
|
|
|
|
// High XOR low
|
|
|
G[i] = gh ^ gl;
|
|
|
}
|
|
|
|
|
|
// Calculate new state values
|
|
|
X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
|
|
|
X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
|
|
|
X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
|
|
|
X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
|
|
|
X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
|
|
|
X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
|
|
|
X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
|
|
|
X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Shortcut functions to the cipher's object interface.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
|
|
|
* var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
|
|
|
*/
|
|
|
C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.RabbitLegacy;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 84454:
|
|
|
/*!******************************************!*\
|
|
|
!*** ./node_modules/crypto-js/rabbit.js ***!
|
|
|
\******************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./enc-base64 */ 98269), __webpack_require__(/*! ./md5 */ 68214), __webpack_require__(/*! ./evpkdf */ 90888), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var StreamCipher = C_lib.StreamCipher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Reusable objects
|
|
|
var S = [];
|
|
|
var C_ = [];
|
|
|
var G = [];
|
|
|
|
|
|
/**
|
|
|
* Rabbit stream cipher algorithm
|
|
|
*/
|
|
|
var Rabbit = C_algo.Rabbit = StreamCipher.extend({
|
|
|
_doReset: function () {
|
|
|
// Shortcuts
|
|
|
var K = this._key.words;
|
|
|
var iv = this.cfg.iv;
|
|
|
|
|
|
// Swap endian
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
|
|
|
(((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
|
|
|
}
|
|
|
|
|
|
// Generate initial state values
|
|
|
var X = this._X = [
|
|
|
K[0], (K[3] << 16) | (K[2] >>> 16),
|
|
|
K[1], (K[0] << 16) | (K[3] >>> 16),
|
|
|
K[2], (K[1] << 16) | (K[0] >>> 16),
|
|
|
K[3], (K[2] << 16) | (K[1] >>> 16)
|
|
|
];
|
|
|
|
|
|
// Generate initial counter values
|
|
|
var C = this._C = [
|
|
|
(K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
|
|
|
(K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
|
|
|
(K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
|
|
|
(K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
|
|
|
];
|
|
|
|
|
|
// Carry bit
|
|
|
this._b = 0;
|
|
|
|
|
|
// Iterate the system four times
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
nextState.call(this);
|
|
|
}
|
|
|
|
|
|
// Modify the counters
|
|
|
for (var i = 0; i < 8; i++) {
|
|
|
C[i] ^= X[(i + 4) & 7];
|
|
|
}
|
|
|
|
|
|
// IV setup
|
|
|
if (iv) {
|
|
|
// Shortcuts
|
|
|
var IV = iv.words;
|
|
|
var IV_0 = IV[0];
|
|
|
var IV_1 = IV[1];
|
|
|
|
|
|
// Generate four subvectors
|
|
|
var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
|
|
|
var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
|
|
|
var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
|
|
|
var i3 = (i2 << 16) | (i0 & 0x0000ffff);
|
|
|
|
|
|
// Modify counter values
|
|
|
C[0] ^= i0;
|
|
|
C[1] ^= i1;
|
|
|
C[2] ^= i2;
|
|
|
C[3] ^= i3;
|
|
|
C[4] ^= i0;
|
|
|
C[5] ^= i1;
|
|
|
C[6] ^= i2;
|
|
|
C[7] ^= i3;
|
|
|
|
|
|
// Iterate the system four times
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
nextState.call(this);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
// Shortcut
|
|
|
var X = this._X;
|
|
|
|
|
|
// Iterate the system
|
|
|
nextState.call(this);
|
|
|
|
|
|
// Generate four keystream words
|
|
|
S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
|
|
|
S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
|
|
|
S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
|
|
|
S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
|
|
|
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
// Swap endian
|
|
|
S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
|
|
|
(((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
|
|
|
|
|
|
// Encrypt
|
|
|
M[offset + i] ^= S[i];
|
|
|
}
|
|
|
},
|
|
|
|
|
|
blockSize: 128/32,
|
|
|
|
|
|
ivSize: 64/32
|
|
|
});
|
|
|
|
|
|
function nextState() {
|
|
|
// Shortcuts
|
|
|
var X = this._X;
|
|
|
var C = this._C;
|
|
|
|
|
|
// Save old counter values
|
|
|
for (var i = 0; i < 8; i++) {
|
|
|
C_[i] = C[i];
|
|
|
}
|
|
|
|
|
|
// Calculate new counter values
|
|
|
C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
|
|
|
C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
|
|
|
C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
|
|
|
this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
|
|
|
|
|
|
// Calculate the g-values
|
|
|
for (var i = 0; i < 8; i++) {
|
|
|
var gx = X[i] + C[i];
|
|
|
|
|
|
// Construct high and low argument for squaring
|
|
|
var ga = gx & 0xffff;
|
|
|
var gb = gx >>> 16;
|
|
|
|
|
|
// Calculate high and low result of squaring
|
|
|
var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
|
|
|
var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
|
|
|
|
|
|
// High XOR low
|
|
|
G[i] = gh ^ gl;
|
|
|
}
|
|
|
|
|
|
// Calculate new state values
|
|
|
X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
|
|
|
X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
|
|
|
X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
|
|
|
X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
|
|
|
X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
|
|
|
X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
|
|
|
X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
|
|
|
X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Shortcut functions to the cipher's object interface.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
|
|
|
* var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
|
|
|
*/
|
|
|
C.Rabbit = StreamCipher._createHelper(Rabbit);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.Rabbit;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 51857:
|
|
|
/*!***************************************!*\
|
|
|
!*** ./node_modules/crypto-js/rc4.js ***!
|
|
|
\***************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./enc-base64 */ 98269), __webpack_require__(/*! ./md5 */ 68214), __webpack_require__(/*! ./evpkdf */ 90888), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var StreamCipher = C_lib.StreamCipher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
/**
|
|
|
* RC4 stream cipher algorithm.
|
|
|
*/
|
|
|
var RC4 = C_algo.RC4 = StreamCipher.extend({
|
|
|
_doReset: function () {
|
|
|
// Shortcuts
|
|
|
var key = this._key;
|
|
|
var keyWords = key.words;
|
|
|
var keySigBytes = key.sigBytes;
|
|
|
|
|
|
// Init sbox
|
|
|
var S = this._S = [];
|
|
|
for (var i = 0; i < 256; i++) {
|
|
|
S[i] = i;
|
|
|
}
|
|
|
|
|
|
// Key setup
|
|
|
for (var i = 0, j = 0; i < 256; i++) {
|
|
|
var keyByteIndex = i % keySigBytes;
|
|
|
var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
|
|
|
|
|
|
j = (j + S[i] + keyByte) % 256;
|
|
|
|
|
|
// Swap
|
|
|
var t = S[i];
|
|
|
S[i] = S[j];
|
|
|
S[j] = t;
|
|
|
}
|
|
|
|
|
|
// Counters
|
|
|
this._i = this._j = 0;
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
M[offset] ^= generateKeystreamWord.call(this);
|
|
|
},
|
|
|
|
|
|
keySize: 256/32,
|
|
|
|
|
|
ivSize: 0
|
|
|
});
|
|
|
|
|
|
function generateKeystreamWord() {
|
|
|
// Shortcuts
|
|
|
var S = this._S;
|
|
|
var i = this._i;
|
|
|
var j = this._j;
|
|
|
|
|
|
// Generate keystream word
|
|
|
var keystreamWord = 0;
|
|
|
for (var n = 0; n < 4; n++) {
|
|
|
i = (i + 1) % 256;
|
|
|
j = (j + S[i]) % 256;
|
|
|
|
|
|
// Swap
|
|
|
var t = S[i];
|
|
|
S[i] = S[j];
|
|
|
S[j] = t;
|
|
|
|
|
|
keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
|
|
|
}
|
|
|
|
|
|
// Update counters
|
|
|
this._i = i;
|
|
|
this._j = j;
|
|
|
|
|
|
return keystreamWord;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Shortcut functions to the cipher's object interface.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
|
|
|
* var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
|
|
|
*/
|
|
|
C.RC4 = StreamCipher._createHelper(RC4);
|
|
|
|
|
|
/**
|
|
|
* Modified RC4 stream cipher algorithm.
|
|
|
*/
|
|
|
var RC4Drop = C_algo.RC4Drop = RC4.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*
|
|
|
* @property {number} drop The number of keystream words to drop. Default 192
|
|
|
*/
|
|
|
cfg: RC4.cfg.extend({
|
|
|
drop: 192
|
|
|
}),
|
|
|
|
|
|
_doReset: function () {
|
|
|
RC4._doReset.call(this);
|
|
|
|
|
|
// Drop
|
|
|
for (var i = this.cfg.drop; i > 0; i--) {
|
|
|
generateKeystreamWord.call(this);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut functions to the cipher's object interface.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
|
|
|
* var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
|
|
|
*/
|
|
|
C.RC4Drop = StreamCipher._createHelper(RC4Drop);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.RC4;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 30706:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/ripemd160.js ***!
|
|
|
\*********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
/** @preserve
|
|
|
(c) 2012 by Cédric Mesnil. All rights reserved.
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
|
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
*/
|
|
|
|
|
|
(function (Math) {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var Hasher = C_lib.Hasher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Constants table
|
|
|
var _zl = WordArray.create([
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
|
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
|
|
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
|
|
|
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
|
|
|
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
|
|
|
var _zr = WordArray.create([
|
|
|
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
|
|
|
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
|
|
|
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
|
|
|
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
|
|
|
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
|
|
|
var _sl = WordArray.create([
|
|
|
11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
|
|
|
7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
|
|
|
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
|
|
|
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
|
|
|
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
|
|
|
var _sr = WordArray.create([
|
|
|
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
|
|
|
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
|
|
|
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
|
|
|
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
|
|
|
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
|
|
|
|
|
|
var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
|
|
|
var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
|
|
|
|
|
|
/**
|
|
|
* RIPEMD160 hash algorithm.
|
|
|
*/
|
|
|
var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
|
|
|
_doReset: function () {
|
|
|
this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
|
|
|
// Swap endian
|
|
|
for (var i = 0; i < 16; i++) {
|
|
|
// Shortcuts
|
|
|
var offset_i = offset + i;
|
|
|
var M_offset_i = M[offset_i];
|
|
|
|
|
|
// Swap
|
|
|
M[offset_i] = (
|
|
|
(((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
|
|
|
(((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
}
|
|
|
// Shortcut
|
|
|
var H = this._hash.words;
|
|
|
var hl = _hl.words;
|
|
|
var hr = _hr.words;
|
|
|
var zl = _zl.words;
|
|
|
var zr = _zr.words;
|
|
|
var sl = _sl.words;
|
|
|
var sr = _sr.words;
|
|
|
|
|
|
// Working variables
|
|
|
var al, bl, cl, dl, el;
|
|
|
var ar, br, cr, dr, er;
|
|
|
|
|
|
ar = al = H[0];
|
|
|
br = bl = H[1];
|
|
|
cr = cl = H[2];
|
|
|
dr = dl = H[3];
|
|
|
er = el = H[4];
|
|
|
// Computation
|
|
|
var t;
|
|
|
for (var i = 0; i < 80; i += 1) {
|
|
|
t = (al + M[offset+zl[i]])|0;
|
|
|
if (i<16){
|
|
|
t += f1(bl,cl,dl) + hl[0];
|
|
|
} else if (i<32) {
|
|
|
t += f2(bl,cl,dl) + hl[1];
|
|
|
} else if (i<48) {
|
|
|
t += f3(bl,cl,dl) + hl[2];
|
|
|
} else if (i<64) {
|
|
|
t += f4(bl,cl,dl) + hl[3];
|
|
|
} else {// if (i<80) {
|
|
|
t += f5(bl,cl,dl) + hl[4];
|
|
|
}
|
|
|
t = t|0;
|
|
|
t = rotl(t,sl[i]);
|
|
|
t = (t+el)|0;
|
|
|
al = el;
|
|
|
el = dl;
|
|
|
dl = rotl(cl, 10);
|
|
|
cl = bl;
|
|
|
bl = t;
|
|
|
|
|
|
t = (ar + M[offset+zr[i]])|0;
|
|
|
if (i<16){
|
|
|
t += f5(br,cr,dr) + hr[0];
|
|
|
} else if (i<32) {
|
|
|
t += f4(br,cr,dr) + hr[1];
|
|
|
} else if (i<48) {
|
|
|
t += f3(br,cr,dr) + hr[2];
|
|
|
} else if (i<64) {
|
|
|
t += f2(br,cr,dr) + hr[3];
|
|
|
} else {// if (i<80) {
|
|
|
t += f1(br,cr,dr) + hr[4];
|
|
|
}
|
|
|
t = t|0;
|
|
|
t = rotl(t,sr[i]) ;
|
|
|
t = (t+er)|0;
|
|
|
ar = er;
|
|
|
er = dr;
|
|
|
dr = rotl(cr, 10);
|
|
|
cr = br;
|
|
|
br = t;
|
|
|
}
|
|
|
// Intermediate hash value
|
|
|
t = (H[1] + cl + dr)|0;
|
|
|
H[1] = (H[2] + dl + er)|0;
|
|
|
H[2] = (H[3] + el + ar)|0;
|
|
|
H[3] = (H[4] + al + br)|0;
|
|
|
H[4] = (H[0] + bl + cr)|0;
|
|
|
H[0] = t;
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
// Shortcuts
|
|
|
var data = this._data;
|
|
|
var dataWords = data.words;
|
|
|
|
|
|
var nBitsTotal = this._nDataBytes * 8;
|
|
|
var nBitsLeft = data.sigBytes * 8;
|
|
|
|
|
|
// Add padding
|
|
|
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
|
|
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
|
|
|
(((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
|
|
|
(((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
data.sigBytes = (dataWords.length + 1) * 4;
|
|
|
|
|
|
// Hash final blocks
|
|
|
this._process();
|
|
|
|
|
|
// Shortcuts
|
|
|
var hash = this._hash;
|
|
|
var H = hash.words;
|
|
|
|
|
|
// Swap endian
|
|
|
for (var i = 0; i < 5; i++) {
|
|
|
// Shortcut
|
|
|
var H_i = H[i];
|
|
|
|
|
|
// Swap
|
|
|
H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
|
|
|
(((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
|
|
|
}
|
|
|
|
|
|
// Return final computed hash
|
|
|
return hash;
|
|
|
},
|
|
|
|
|
|
clone: function () {
|
|
|
var clone = Hasher.clone.call(this);
|
|
|
clone._hash = this._hash.clone();
|
|
|
|
|
|
return clone;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
function f1(x, y, z) {
|
|
|
return ((x) ^ (y) ^ (z));
|
|
|
|
|
|
}
|
|
|
|
|
|
function f2(x, y, z) {
|
|
|
return (((x)&(y)) | ((~x)&(z)));
|
|
|
}
|
|
|
|
|
|
function f3(x, y, z) {
|
|
|
return (((x) | (~(y))) ^ (z));
|
|
|
}
|
|
|
|
|
|
function f4(x, y, z) {
|
|
|
return (((x) & (z)) | ((y)&(~(z))));
|
|
|
}
|
|
|
|
|
|
function f5(x, y, z) {
|
|
|
return ((x) ^ ((y) |(~(z))));
|
|
|
|
|
|
}
|
|
|
|
|
|
function rotl(x,n) {
|
|
|
return (x<<n) | (x>>>(32-n));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the hasher's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = CryptoJS.RIPEMD160('message');
|
|
|
* var hash = CryptoJS.RIPEMD160(wordArray);
|
|
|
*/
|
|
|
C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = CryptoJS.HmacRIPEMD160(message, key);
|
|
|
*/
|
|
|
C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
|
|
|
}(Math));
|
|
|
|
|
|
|
|
|
return CryptoJS.RIPEMD160;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 62783:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./node_modules/crypto-js/sha1.js ***!
|
|
|
\****************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var Hasher = C_lib.Hasher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Reusable object
|
|
|
var W = [];
|
|
|
|
|
|
/**
|
|
|
* SHA-1 hash algorithm.
|
|
|
*/
|
|
|
var SHA1 = C_algo.SHA1 = Hasher.extend({
|
|
|
_doReset: function () {
|
|
|
this._hash = new WordArray.init([
|
|
|
0x67452301, 0xefcdab89,
|
|
|
0x98badcfe, 0x10325476,
|
|
|
0xc3d2e1f0
|
|
|
]);
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
// Shortcut
|
|
|
var H = this._hash.words;
|
|
|
|
|
|
// Working variables
|
|
|
var a = H[0];
|
|
|
var b = H[1];
|
|
|
var c = H[2];
|
|
|
var d = H[3];
|
|
|
var e = H[4];
|
|
|
|
|
|
// Computation
|
|
|
for (var i = 0; i < 80; i++) {
|
|
|
if (i < 16) {
|
|
|
W[i] = M[offset + i] | 0;
|
|
|
} else {
|
|
|
var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
|
|
|
W[i] = (n << 1) | (n >>> 31);
|
|
|
}
|
|
|
|
|
|
var t = ((a << 5) | (a >>> 27)) + e + W[i];
|
|
|
if (i < 20) {
|
|
|
t += ((b & c) | (~b & d)) + 0x5a827999;
|
|
|
} else if (i < 40) {
|
|
|
t += (b ^ c ^ d) + 0x6ed9eba1;
|
|
|
} else if (i < 60) {
|
|
|
t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
|
|
|
} else /* if (i < 80) */ {
|
|
|
t += (b ^ c ^ d) - 0x359d3e2a;
|
|
|
}
|
|
|
|
|
|
e = d;
|
|
|
d = c;
|
|
|
c = (b << 30) | (b >>> 2);
|
|
|
b = a;
|
|
|
a = t;
|
|
|
}
|
|
|
|
|
|
// Intermediate hash value
|
|
|
H[0] = (H[0] + a) | 0;
|
|
|
H[1] = (H[1] + b) | 0;
|
|
|
H[2] = (H[2] + c) | 0;
|
|
|
H[3] = (H[3] + d) | 0;
|
|
|
H[4] = (H[4] + e) | 0;
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
// Shortcuts
|
|
|
var data = this._data;
|
|
|
var dataWords = data.words;
|
|
|
|
|
|
var nBitsTotal = this._nDataBytes * 8;
|
|
|
var nBitsLeft = data.sigBytes * 8;
|
|
|
|
|
|
// Add padding
|
|
|
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
|
|
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
|
|
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
|
|
data.sigBytes = dataWords.length * 4;
|
|
|
|
|
|
// Hash final blocks
|
|
|
this._process();
|
|
|
|
|
|
// Return final computed hash
|
|
|
return this._hash;
|
|
|
},
|
|
|
|
|
|
clone: function () {
|
|
|
var clone = Hasher.clone.call(this);
|
|
|
clone._hash = this._hash.clone();
|
|
|
|
|
|
return clone;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the hasher's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = CryptoJS.SHA1('message');
|
|
|
* var hash = CryptoJS.SHA1(wordArray);
|
|
|
*/
|
|
|
C.SHA1 = Hasher._createHelper(SHA1);
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = CryptoJS.HmacSHA1(message, key);
|
|
|
*/
|
|
|
C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.SHA1;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 87792:
|
|
|
/*!******************************************!*\
|
|
|
!*** ./node_modules/crypto-js/sha224.js ***!
|
|
|
\******************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./sha256 */ 52153));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var C_algo = C.algo;
|
|
|
var SHA256 = C_algo.SHA256;
|
|
|
|
|
|
/**
|
|
|
* SHA-224 hash algorithm.
|
|
|
*/
|
|
|
var SHA224 = C_algo.SHA224 = SHA256.extend({
|
|
|
_doReset: function () {
|
|
|
this._hash = new WordArray.init([
|
|
|
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
|
|
|
0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
|
|
|
]);
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
var hash = SHA256._doFinalize.call(this);
|
|
|
|
|
|
hash.sigBytes -= 4;
|
|
|
|
|
|
return hash;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the hasher's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = CryptoJS.SHA224('message');
|
|
|
* var hash = CryptoJS.SHA224(wordArray);
|
|
|
*/
|
|
|
C.SHA224 = SHA256._createHelper(SHA224);
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = CryptoJS.HmacSHA224(message, key);
|
|
|
*/
|
|
|
C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.SHA224;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 52153:
|
|
|
/*!******************************************!*\
|
|
|
!*** ./node_modules/crypto-js/sha256.js ***!
|
|
|
\******************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function (Math) {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var Hasher = C_lib.Hasher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Initialization and round constants tables
|
|
|
var H = [];
|
|
|
var K = [];
|
|
|
|
|
|
// Compute constants
|
|
|
(function () {
|
|
|
function isPrime(n) {
|
|
|
var sqrtN = Math.sqrt(n);
|
|
|
for (var factor = 2; factor <= sqrtN; factor++) {
|
|
|
if (!(n % factor)) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
function getFractionalBits(n) {
|
|
|
return ((n - (n | 0)) * 0x100000000) | 0;
|
|
|
}
|
|
|
|
|
|
var n = 2;
|
|
|
var nPrime = 0;
|
|
|
while (nPrime < 64) {
|
|
|
if (isPrime(n)) {
|
|
|
if (nPrime < 8) {
|
|
|
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
|
|
|
}
|
|
|
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
|
|
|
|
|
|
nPrime++;
|
|
|
}
|
|
|
|
|
|
n++;
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
// Reusable object
|
|
|
var W = [];
|
|
|
|
|
|
/**
|
|
|
* SHA-256 hash algorithm.
|
|
|
*/
|
|
|
var SHA256 = C_algo.SHA256 = Hasher.extend({
|
|
|
_doReset: function () {
|
|
|
this._hash = new WordArray.init(H.slice(0));
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
// Shortcut
|
|
|
var H = this._hash.words;
|
|
|
|
|
|
// Working variables
|
|
|
var a = H[0];
|
|
|
var b = H[1];
|
|
|
var c = H[2];
|
|
|
var d = H[3];
|
|
|
var e = H[4];
|
|
|
var f = H[5];
|
|
|
var g = H[6];
|
|
|
var h = H[7];
|
|
|
|
|
|
// Computation
|
|
|
for (var i = 0; i < 64; i++) {
|
|
|
if (i < 16) {
|
|
|
W[i] = M[offset + i] | 0;
|
|
|
} else {
|
|
|
var gamma0x = W[i - 15];
|
|
|
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
|
|
|
((gamma0x << 14) | (gamma0x >>> 18)) ^
|
|
|
(gamma0x >>> 3);
|
|
|
|
|
|
var gamma1x = W[i - 2];
|
|
|
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
|
|
|
((gamma1x << 13) | (gamma1x >>> 19)) ^
|
|
|
(gamma1x >>> 10);
|
|
|
|
|
|
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
|
|
}
|
|
|
|
|
|
var ch = (e & f) ^ (~e & g);
|
|
|
var maj = (a & b) ^ (a & c) ^ (b & c);
|
|
|
|
|
|
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
|
|
|
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
|
|
|
|
|
|
var t1 = h + sigma1 + ch + K[i] + W[i];
|
|
|
var t2 = sigma0 + maj;
|
|
|
|
|
|
h = g;
|
|
|
g = f;
|
|
|
f = e;
|
|
|
e = (d + t1) | 0;
|
|
|
d = c;
|
|
|
c = b;
|
|
|
b = a;
|
|
|
a = (t1 + t2) | 0;
|
|
|
}
|
|
|
|
|
|
// Intermediate hash value
|
|
|
H[0] = (H[0] + a) | 0;
|
|
|
H[1] = (H[1] + b) | 0;
|
|
|
H[2] = (H[2] + c) | 0;
|
|
|
H[3] = (H[3] + d) | 0;
|
|
|
H[4] = (H[4] + e) | 0;
|
|
|
H[5] = (H[5] + f) | 0;
|
|
|
H[6] = (H[6] + g) | 0;
|
|
|
H[7] = (H[7] + h) | 0;
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
// Shortcuts
|
|
|
var data = this._data;
|
|
|
var dataWords = data.words;
|
|
|
|
|
|
var nBitsTotal = this._nDataBytes * 8;
|
|
|
var nBitsLeft = data.sigBytes * 8;
|
|
|
|
|
|
// Add padding
|
|
|
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
|
|
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
|
|
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
|
|
data.sigBytes = dataWords.length * 4;
|
|
|
|
|
|
// Hash final blocks
|
|
|
this._process();
|
|
|
|
|
|
// Return final computed hash
|
|
|
return this._hash;
|
|
|
},
|
|
|
|
|
|
clone: function () {
|
|
|
var clone = Hasher.clone.call(this);
|
|
|
clone._hash = this._hash.clone();
|
|
|
|
|
|
return clone;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the hasher's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = CryptoJS.SHA256('message');
|
|
|
* var hash = CryptoJS.SHA256(wordArray);
|
|
|
*/
|
|
|
C.SHA256 = Hasher._createHelper(SHA256);
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = CryptoJS.HmacSHA256(message, key);
|
|
|
*/
|
|
|
C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
|
|
|
}(Math));
|
|
|
|
|
|
|
|
|
return CryptoJS.SHA256;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 13327:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./node_modules/crypto-js/sha3.js ***!
|
|
|
\****************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./x64-core */ 64938));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function (Math) {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var Hasher = C_lib.Hasher;
|
|
|
var C_x64 = C.x64;
|
|
|
var X64Word = C_x64.Word;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Constants tables
|
|
|
var RHO_OFFSETS = [];
|
|
|
var PI_INDEXES = [];
|
|
|
var ROUND_CONSTANTS = [];
|
|
|
|
|
|
// Compute Constants
|
|
|
(function () {
|
|
|
// Compute rho offset constants
|
|
|
var x = 1, y = 0;
|
|
|
for (var t = 0; t < 24; t++) {
|
|
|
RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
|
|
|
|
|
|
var newX = y % 5;
|
|
|
var newY = (2 * x + 3 * y) % 5;
|
|
|
x = newX;
|
|
|
y = newY;
|
|
|
}
|
|
|
|
|
|
// Compute pi index constants
|
|
|
for (var x = 0; x < 5; x++) {
|
|
|
for (var y = 0; y < 5; y++) {
|
|
|
PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Compute round constants
|
|
|
var LFSR = 0x01;
|
|
|
for (var i = 0; i < 24; i++) {
|
|
|
var roundConstantMsw = 0;
|
|
|
var roundConstantLsw = 0;
|
|
|
|
|
|
for (var j = 0; j < 7; j++) {
|
|
|
if (LFSR & 0x01) {
|
|
|
var bitPosition = (1 << j) - 1;
|
|
|
if (bitPosition < 32) {
|
|
|
roundConstantLsw ^= 1 << bitPosition;
|
|
|
} else /* if (bitPosition >= 32) */ {
|
|
|
roundConstantMsw ^= 1 << (bitPosition - 32);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Compute next LFSR
|
|
|
if (LFSR & 0x80) {
|
|
|
// Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
|
|
|
LFSR = (LFSR << 1) ^ 0x71;
|
|
|
} else {
|
|
|
LFSR <<= 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
// Reusable objects for temporary values
|
|
|
var T = [];
|
|
|
(function () {
|
|
|
for (var i = 0; i < 25; i++) {
|
|
|
T[i] = X64Word.create();
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
/**
|
|
|
* SHA-3 hash algorithm.
|
|
|
*/
|
|
|
var SHA3 = C_algo.SHA3 = Hasher.extend({
|
|
|
/**
|
|
|
* Configuration options.
|
|
|
*
|
|
|
* @property {number} outputLength
|
|
|
* The desired number of bits in the output hash.
|
|
|
* Only values permitted are: 224, 256, 384, 512.
|
|
|
* Default: 512
|
|
|
*/
|
|
|
cfg: Hasher.cfg.extend({
|
|
|
outputLength: 512
|
|
|
}),
|
|
|
|
|
|
_doReset: function () {
|
|
|
var state = this._state = []
|
|
|
for (var i = 0; i < 25; i++) {
|
|
|
state[i] = new X64Word.init();
|
|
|
}
|
|
|
|
|
|
this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
// Shortcuts
|
|
|
var state = this._state;
|
|
|
var nBlockSizeLanes = this.blockSize / 2;
|
|
|
|
|
|
// Absorb
|
|
|
for (var i = 0; i < nBlockSizeLanes; i++) {
|
|
|
// Shortcuts
|
|
|
var M2i = M[offset + 2 * i];
|
|
|
var M2i1 = M[offset + 2 * i + 1];
|
|
|
|
|
|
// Swap endian
|
|
|
M2i = (
|
|
|
(((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
|
|
|
(((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
M2i1 = (
|
|
|
(((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
|
|
|
(((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
|
|
|
// Absorb message into state
|
|
|
var lane = state[i];
|
|
|
lane.high ^= M2i1;
|
|
|
lane.low ^= M2i;
|
|
|
}
|
|
|
|
|
|
// Rounds
|
|
|
for (var round = 0; round < 24; round++) {
|
|
|
// Theta
|
|
|
for (var x = 0; x < 5; x++) {
|
|
|
// Mix column lanes
|
|
|
var tMsw = 0, tLsw = 0;
|
|
|
for (var y = 0; y < 5; y++) {
|
|
|
var lane = state[x + 5 * y];
|
|
|
tMsw ^= lane.high;
|
|
|
tLsw ^= lane.low;
|
|
|
}
|
|
|
|
|
|
// Temporary values
|
|
|
var Tx = T[x];
|
|
|
Tx.high = tMsw;
|
|
|
Tx.low = tLsw;
|
|
|
}
|
|
|
for (var x = 0; x < 5; x++) {
|
|
|
// Shortcuts
|
|
|
var Tx4 = T[(x + 4) % 5];
|
|
|
var Tx1 = T[(x + 1) % 5];
|
|
|
var Tx1Msw = Tx1.high;
|
|
|
var Tx1Lsw = Tx1.low;
|
|
|
|
|
|
// Mix surrounding columns
|
|
|
var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
|
|
|
var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
|
|
|
for (var y = 0; y < 5; y++) {
|
|
|
var lane = state[x + 5 * y];
|
|
|
lane.high ^= tMsw;
|
|
|
lane.low ^= tLsw;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Rho Pi
|
|
|
for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
|
|
|
var tMsw;
|
|
|
var tLsw;
|
|
|
|
|
|
// Shortcuts
|
|
|
var lane = state[laneIndex];
|
|
|
var laneMsw = lane.high;
|
|
|
var laneLsw = lane.low;
|
|
|
var rhoOffset = RHO_OFFSETS[laneIndex];
|
|
|
|
|
|
// Rotate lanes
|
|
|
if (rhoOffset < 32) {
|
|
|
tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
|
|
|
tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
|
|
|
} else /* if (rhoOffset >= 32) */ {
|
|
|
tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
|
|
|
tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
|
|
|
}
|
|
|
|
|
|
// Transpose lanes
|
|
|
var TPiLane = T[PI_INDEXES[laneIndex]];
|
|
|
TPiLane.high = tMsw;
|
|
|
TPiLane.low = tLsw;
|
|
|
}
|
|
|
|
|
|
// Rho pi at x = y = 0
|
|
|
var T0 = T[0];
|
|
|
var state0 = state[0];
|
|
|
T0.high = state0.high;
|
|
|
T0.low = state0.low;
|
|
|
|
|
|
// Chi
|
|
|
for (var x = 0; x < 5; x++) {
|
|
|
for (var y = 0; y < 5; y++) {
|
|
|
// Shortcuts
|
|
|
var laneIndex = x + 5 * y;
|
|
|
var lane = state[laneIndex];
|
|
|
var TLane = T[laneIndex];
|
|
|
var Tx1Lane = T[((x + 1) % 5) + 5 * y];
|
|
|
var Tx2Lane = T[((x + 2) % 5) + 5 * y];
|
|
|
|
|
|
// Mix rows
|
|
|
lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
|
|
|
lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Iota
|
|
|
var lane = state[0];
|
|
|
var roundConstant = ROUND_CONSTANTS[round];
|
|
|
lane.high ^= roundConstant.high;
|
|
|
lane.low ^= roundConstant.low;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
// Shortcuts
|
|
|
var data = this._data;
|
|
|
var dataWords = data.words;
|
|
|
var nBitsTotal = this._nDataBytes * 8;
|
|
|
var nBitsLeft = data.sigBytes * 8;
|
|
|
var blockSizeBits = this.blockSize * 32;
|
|
|
|
|
|
// Add padding
|
|
|
dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
|
|
|
dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
|
|
|
data.sigBytes = dataWords.length * 4;
|
|
|
|
|
|
// Hash final blocks
|
|
|
this._process();
|
|
|
|
|
|
// Shortcuts
|
|
|
var state = this._state;
|
|
|
var outputLengthBytes = this.cfg.outputLength / 8;
|
|
|
var outputLengthLanes = outputLengthBytes / 8;
|
|
|
|
|
|
// Squeeze
|
|
|
var hashWords = [];
|
|
|
for (var i = 0; i < outputLengthLanes; i++) {
|
|
|
// Shortcuts
|
|
|
var lane = state[i];
|
|
|
var laneMsw = lane.high;
|
|
|
var laneLsw = lane.low;
|
|
|
|
|
|
// Swap endian
|
|
|
laneMsw = (
|
|
|
(((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
|
|
|
(((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
laneLsw = (
|
|
|
(((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
|
|
|
(((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
|
|
|
);
|
|
|
|
|
|
// Squeeze state to retrieve hash
|
|
|
hashWords.push(laneLsw);
|
|
|
hashWords.push(laneMsw);
|
|
|
}
|
|
|
|
|
|
// Return final computed hash
|
|
|
return new WordArray.init(hashWords, outputLengthBytes);
|
|
|
},
|
|
|
|
|
|
clone: function () {
|
|
|
var clone = Hasher.clone.call(this);
|
|
|
|
|
|
var state = clone._state = this._state.slice(0);
|
|
|
for (var i = 0; i < 25; i++) {
|
|
|
state[i] = state[i].clone();
|
|
|
}
|
|
|
|
|
|
return clone;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the hasher's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = CryptoJS.SHA3('message');
|
|
|
* var hash = CryptoJS.SHA3(wordArray);
|
|
|
*/
|
|
|
C.SHA3 = Hasher._createHelper(SHA3);
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = CryptoJS.HmacSHA3(message, key);
|
|
|
*/
|
|
|
C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
|
|
|
}(Math));
|
|
|
|
|
|
|
|
|
return CryptoJS.SHA3;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 17460:
|
|
|
/*!******************************************!*\
|
|
|
!*** ./node_modules/crypto-js/sha384.js ***!
|
|
|
\******************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./x64-core */ 64938), __webpack_require__(/*! ./sha512 */ 70034));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_x64 = C.x64;
|
|
|
var X64Word = C_x64.Word;
|
|
|
var X64WordArray = C_x64.WordArray;
|
|
|
var C_algo = C.algo;
|
|
|
var SHA512 = C_algo.SHA512;
|
|
|
|
|
|
/**
|
|
|
* SHA-384 hash algorithm.
|
|
|
*/
|
|
|
var SHA384 = C_algo.SHA384 = SHA512.extend({
|
|
|
_doReset: function () {
|
|
|
this._hash = new X64WordArray.init([
|
|
|
new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
|
|
|
new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
|
|
|
new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
|
|
|
new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
|
|
|
]);
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
var hash = SHA512._doFinalize.call(this);
|
|
|
|
|
|
hash.sigBytes -= 16;
|
|
|
|
|
|
return hash;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the hasher's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = CryptoJS.SHA384('message');
|
|
|
* var hash = CryptoJS.SHA384(wordArray);
|
|
|
*/
|
|
|
C.SHA384 = SHA512._createHelper(SHA384);
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = CryptoJS.HmacSHA384(message, key);
|
|
|
*/
|
|
|
C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.SHA384;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 70034:
|
|
|
/*!******************************************!*\
|
|
|
!*** ./node_modules/crypto-js/sha512.js ***!
|
|
|
\******************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./x64-core */ 64938));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var Hasher = C_lib.Hasher;
|
|
|
var C_x64 = C.x64;
|
|
|
var X64Word = C_x64.Word;
|
|
|
var X64WordArray = C_x64.WordArray;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
function X64Word_create() {
|
|
|
return X64Word.create.apply(X64Word, arguments);
|
|
|
}
|
|
|
|
|
|
// Constants
|
|
|
var K = [
|
|
|
X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
|
|
|
X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
|
|
|
X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
|
|
|
X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
|
|
|
X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
|
|
|
X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
|
|
|
X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
|
|
|
X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
|
|
|
X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
|
|
|
X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
|
|
|
X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
|
|
|
X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
|
|
|
X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
|
|
|
X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
|
|
|
X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
|
|
|
X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
|
|
|
X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
|
|
|
X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
|
|
|
X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
|
|
|
X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
|
|
|
X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
|
|
|
X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
|
|
|
X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
|
|
|
X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
|
|
|
X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
|
|
|
X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
|
|
|
X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
|
|
|
X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
|
|
|
X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
|
|
|
X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
|
|
|
X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
|
|
|
X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
|
|
|
X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
|
|
|
X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
|
|
|
X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
|
|
|
X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
|
|
|
X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
|
|
|
X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
|
|
|
X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
|
|
|
X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
|
|
|
];
|
|
|
|
|
|
// Reusable objects
|
|
|
var W = [];
|
|
|
(function () {
|
|
|
for (var i = 0; i < 80; i++) {
|
|
|
W[i] = X64Word_create();
|
|
|
}
|
|
|
}());
|
|
|
|
|
|
/**
|
|
|
* SHA-512 hash algorithm.
|
|
|
*/
|
|
|
var SHA512 = C_algo.SHA512 = Hasher.extend({
|
|
|
_doReset: function () {
|
|
|
this._hash = new X64WordArray.init([
|
|
|
new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
|
|
|
new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
|
|
|
new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
|
|
|
new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
|
|
|
]);
|
|
|
},
|
|
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
|
// Shortcuts
|
|
|
var H = this._hash.words;
|
|
|
|
|
|
var H0 = H[0];
|
|
|
var H1 = H[1];
|
|
|
var H2 = H[2];
|
|
|
var H3 = H[3];
|
|
|
var H4 = H[4];
|
|
|
var H5 = H[5];
|
|
|
var H6 = H[6];
|
|
|
var H7 = H[7];
|
|
|
|
|
|
var H0h = H0.high;
|
|
|
var H0l = H0.low;
|
|
|
var H1h = H1.high;
|
|
|
var H1l = H1.low;
|
|
|
var H2h = H2.high;
|
|
|
var H2l = H2.low;
|
|
|
var H3h = H3.high;
|
|
|
var H3l = H3.low;
|
|
|
var H4h = H4.high;
|
|
|
var H4l = H4.low;
|
|
|
var H5h = H5.high;
|
|
|
var H5l = H5.low;
|
|
|
var H6h = H6.high;
|
|
|
var H6l = H6.low;
|
|
|
var H7h = H7.high;
|
|
|
var H7l = H7.low;
|
|
|
|
|
|
// Working variables
|
|
|
var ah = H0h;
|
|
|
var al = H0l;
|
|
|
var bh = H1h;
|
|
|
var bl = H1l;
|
|
|
var ch = H2h;
|
|
|
var cl = H2l;
|
|
|
var dh = H3h;
|
|
|
var dl = H3l;
|
|
|
var eh = H4h;
|
|
|
var el = H4l;
|
|
|
var fh = H5h;
|
|
|
var fl = H5l;
|
|
|
var gh = H6h;
|
|
|
var gl = H6l;
|
|
|
var hh = H7h;
|
|
|
var hl = H7l;
|
|
|
|
|
|
// Rounds
|
|
|
for (var i = 0; i < 80; i++) {
|
|
|
var Wil;
|
|
|
var Wih;
|
|
|
|
|
|
// Shortcut
|
|
|
var Wi = W[i];
|
|
|
|
|
|
// Extend message
|
|
|
if (i < 16) {
|
|
|
Wih = Wi.high = M[offset + i * 2] | 0;
|
|
|
Wil = Wi.low = M[offset + i * 2 + 1] | 0;
|
|
|
} else {
|
|
|
// Gamma0
|
|
|
var gamma0x = W[i - 15];
|
|
|
var gamma0xh = gamma0x.high;
|
|
|
var gamma0xl = gamma0x.low;
|
|
|
var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
|
|
|
var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
|
|
|
|
|
|
// Gamma1
|
|
|
var gamma1x = W[i - 2];
|
|
|
var gamma1xh = gamma1x.high;
|
|
|
var gamma1xl = gamma1x.low;
|
|
|
var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
|
|
|
var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
|
|
|
|
|
|
// W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
|
|
|
var Wi7 = W[i - 7];
|
|
|
var Wi7h = Wi7.high;
|
|
|
var Wi7l = Wi7.low;
|
|
|
|
|
|
var Wi16 = W[i - 16];
|
|
|
var Wi16h = Wi16.high;
|
|
|
var Wi16l = Wi16.low;
|
|
|
|
|
|
Wil = gamma0l + Wi7l;
|
|
|
Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
|
|
|
Wil = Wil + gamma1l;
|
|
|
Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
|
|
|
Wil = Wil + Wi16l;
|
|
|
Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
|
|
|
|
|
|
Wi.high = Wih;
|
|
|
Wi.low = Wil;
|
|
|
}
|
|
|
|
|
|
var chh = (eh & fh) ^ (~eh & gh);
|
|
|
var chl = (el & fl) ^ (~el & gl);
|
|
|
var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
|
|
|
var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
|
|
|
|
|
|
var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
|
|
|
var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
|
|
|
var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
|
|
|
var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
|
|
|
|
|
|
// t1 = h + sigma1 + ch + K[i] + W[i]
|
|
|
var Ki = K[i];
|
|
|
var Kih = Ki.high;
|
|
|
var Kil = Ki.low;
|
|
|
|
|
|
var t1l = hl + sigma1l;
|
|
|
var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
|
|
|
var t1l = t1l + chl;
|
|
|
var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
|
|
|
var t1l = t1l + Kil;
|
|
|
var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
|
|
|
var t1l = t1l + Wil;
|
|
|
var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
|
|
|
|
|
|
// t2 = sigma0 + maj
|
|
|
var t2l = sigma0l + majl;
|
|
|
var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
|
|
|
|
|
|
// Update working variables
|
|
|
hh = gh;
|
|
|
hl = gl;
|
|
|
gh = fh;
|
|
|
gl = fl;
|
|
|
fh = eh;
|
|
|
fl = el;
|
|
|
el = (dl + t1l) | 0;
|
|
|
eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
|
|
|
dh = ch;
|
|
|
dl = cl;
|
|
|
ch = bh;
|
|
|
cl = bl;
|
|
|
bh = ah;
|
|
|
bl = al;
|
|
|
al = (t1l + t2l) | 0;
|
|
|
ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
|
|
|
}
|
|
|
|
|
|
// Intermediate hash value
|
|
|
H0l = H0.low = (H0l + al);
|
|
|
H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
|
|
|
H1l = H1.low = (H1l + bl);
|
|
|
H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
|
|
|
H2l = H2.low = (H2l + cl);
|
|
|
H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
|
|
|
H3l = H3.low = (H3l + dl);
|
|
|
H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
|
|
|
H4l = H4.low = (H4l + el);
|
|
|
H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
|
|
|
H5l = H5.low = (H5l + fl);
|
|
|
H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
|
|
|
H6l = H6.low = (H6l + gl);
|
|
|
H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
|
|
|
H7l = H7.low = (H7l + hl);
|
|
|
H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
|
|
|
},
|
|
|
|
|
|
_doFinalize: function () {
|
|
|
// Shortcuts
|
|
|
var data = this._data;
|
|
|
var dataWords = data.words;
|
|
|
|
|
|
var nBitsTotal = this._nDataBytes * 8;
|
|
|
var nBitsLeft = data.sigBytes * 8;
|
|
|
|
|
|
// Add padding
|
|
|
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
|
|
dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
|
|
|
dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
|
|
|
data.sigBytes = dataWords.length * 4;
|
|
|
|
|
|
// Hash final blocks
|
|
|
this._process();
|
|
|
|
|
|
// Convert hash to 32-bit word array before returning
|
|
|
var hash = this._hash.toX32();
|
|
|
|
|
|
// Return final computed hash
|
|
|
return hash;
|
|
|
},
|
|
|
|
|
|
clone: function () {
|
|
|
var clone = Hasher.clone.call(this);
|
|
|
clone._hash = this._hash.clone();
|
|
|
|
|
|
return clone;
|
|
|
},
|
|
|
|
|
|
blockSize: 1024/32
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the hasher's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
*
|
|
|
* @return {WordArray} The hash.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hash = CryptoJS.SHA512('message');
|
|
|
* var hash = CryptoJS.SHA512(wordArray);
|
|
|
*/
|
|
|
C.SHA512 = Hasher._createHelper(SHA512);
|
|
|
|
|
|
/**
|
|
|
* Shortcut function to the HMAC's object interface.
|
|
|
*
|
|
|
* @param {WordArray|string} message The message to hash.
|
|
|
* @param {WordArray|string} key The secret key.
|
|
|
*
|
|
|
* @return {WordArray} The HMAC.
|
|
|
*
|
|
|
* @static
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var hmac = CryptoJS.HmacSHA512(message, key);
|
|
|
*/
|
|
|
C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.SHA512;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 94253:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/tripledes.js ***!
|
|
|
\*********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory, undef) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249), __webpack_require__(/*! ./enc-base64 */ 98269), __webpack_require__(/*! ./md5 */ 68214), __webpack_require__(/*! ./evpkdf */ 90888), __webpack_require__(/*! ./cipher-core */ 75109));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function () {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var WordArray = C_lib.WordArray;
|
|
|
var BlockCipher = C_lib.BlockCipher;
|
|
|
var C_algo = C.algo;
|
|
|
|
|
|
// Permuted Choice 1 constants
|
|
|
var PC1 = [
|
|
|
57, 49, 41, 33, 25, 17, 9, 1,
|
|
|
58, 50, 42, 34, 26, 18, 10, 2,
|
|
|
59, 51, 43, 35, 27, 19, 11, 3,
|
|
|
60, 52, 44, 36, 63, 55, 47, 39,
|
|
|
31, 23, 15, 7, 62, 54, 46, 38,
|
|
|
30, 22, 14, 6, 61, 53, 45, 37,
|
|
|
29, 21, 13, 5, 28, 20, 12, 4
|
|
|
];
|
|
|
|
|
|
// Permuted Choice 2 constants
|
|
|
var PC2 = [
|
|
|
14, 17, 11, 24, 1, 5,
|
|
|
3, 28, 15, 6, 21, 10,
|
|
|
23, 19, 12, 4, 26, 8,
|
|
|
16, 7, 27, 20, 13, 2,
|
|
|
41, 52, 31, 37, 47, 55,
|
|
|
30, 40, 51, 45, 33, 48,
|
|
|
44, 49, 39, 56, 34, 53,
|
|
|
46, 42, 50, 36, 29, 32
|
|
|
];
|
|
|
|
|
|
// Cumulative bit shift constants
|
|
|
var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
|
|
|
|
|
|
// SBOXes and round permutation constants
|
|
|
var SBOX_P = [
|
|
|
{
|
|
|
0x0: 0x808200,
|
|
|
0x10000000: 0x8000,
|
|
|
0x20000000: 0x808002,
|
|
|
0x30000000: 0x2,
|
|
|
0x40000000: 0x200,
|
|
|
0x50000000: 0x808202,
|
|
|
0x60000000: 0x800202,
|
|
|
0x70000000: 0x800000,
|
|
|
0x80000000: 0x202,
|
|
|
0x90000000: 0x800200,
|
|
|
0xa0000000: 0x8200,
|
|
|
0xb0000000: 0x808000,
|
|
|
0xc0000000: 0x8002,
|
|
|
0xd0000000: 0x800002,
|
|
|
0xe0000000: 0x0,
|
|
|
0xf0000000: 0x8202,
|
|
|
0x8000000: 0x0,
|
|
|
0x18000000: 0x808202,
|
|
|
0x28000000: 0x8202,
|
|
|
0x38000000: 0x8000,
|
|
|
0x48000000: 0x808200,
|
|
|
0x58000000: 0x200,
|
|
|
0x68000000: 0x808002,
|
|
|
0x78000000: 0x2,
|
|
|
0x88000000: 0x800200,
|
|
|
0x98000000: 0x8200,
|
|
|
0xa8000000: 0x808000,
|
|
|
0xb8000000: 0x800202,
|
|
|
0xc8000000: 0x800002,
|
|
|
0xd8000000: 0x8002,
|
|
|
0xe8000000: 0x202,
|
|
|
0xf8000000: 0x800000,
|
|
|
0x1: 0x8000,
|
|
|
0x10000001: 0x2,
|
|
|
0x20000001: 0x808200,
|
|
|
0x30000001: 0x800000,
|
|
|
0x40000001: 0x808002,
|
|
|
0x50000001: 0x8200,
|
|
|
0x60000001: 0x200,
|
|
|
0x70000001: 0x800202,
|
|
|
0x80000001: 0x808202,
|
|
|
0x90000001: 0x808000,
|
|
|
0xa0000001: 0x800002,
|
|
|
0xb0000001: 0x8202,
|
|
|
0xc0000001: 0x202,
|
|
|
0xd0000001: 0x800200,
|
|
|
0xe0000001: 0x8002,
|
|
|
0xf0000001: 0x0,
|
|
|
0x8000001: 0x808202,
|
|
|
0x18000001: 0x808000,
|
|
|
0x28000001: 0x800000,
|
|
|
0x38000001: 0x200,
|
|
|
0x48000001: 0x8000,
|
|
|
0x58000001: 0x800002,
|
|
|
0x68000001: 0x2,
|
|
|
0x78000001: 0x8202,
|
|
|
0x88000001: 0x8002,
|
|
|
0x98000001: 0x800202,
|
|
|
0xa8000001: 0x202,
|
|
|
0xb8000001: 0x808200,
|
|
|
0xc8000001: 0x800200,
|
|
|
0xd8000001: 0x0,
|
|
|
0xe8000001: 0x8200,
|
|
|
0xf8000001: 0x808002
|
|
|
},
|
|
|
{
|
|
|
0x0: 0x40084010,
|
|
|
0x1000000: 0x4000,
|
|
|
0x2000000: 0x80000,
|
|
|
0x3000000: 0x40080010,
|
|
|
0x4000000: 0x40000010,
|
|
|
0x5000000: 0x40084000,
|
|
|
0x6000000: 0x40004000,
|
|
|
0x7000000: 0x10,
|
|
|
0x8000000: 0x84000,
|
|
|
0x9000000: 0x40004010,
|
|
|
0xa000000: 0x40000000,
|
|
|
0xb000000: 0x84010,
|
|
|
0xc000000: 0x80010,
|
|
|
0xd000000: 0x0,
|
|
|
0xe000000: 0x4010,
|
|
|
0xf000000: 0x40080000,
|
|
|
0x800000: 0x40004000,
|
|
|
0x1800000: 0x84010,
|
|
|
0x2800000: 0x10,
|
|
|
0x3800000: 0x40004010,
|
|
|
0x4800000: 0x40084010,
|
|
|
0x5800000: 0x40000000,
|
|
|
0x6800000: 0x80000,
|
|
|
0x7800000: 0x40080010,
|
|
|
0x8800000: 0x80010,
|
|
|
0x9800000: 0x0,
|
|
|
0xa800000: 0x4000,
|
|
|
0xb800000: 0x40080000,
|
|
|
0xc800000: 0x40000010,
|
|
|
0xd800000: 0x84000,
|
|
|
0xe800000: 0x40084000,
|
|
|
0xf800000: 0x4010,
|
|
|
0x10000000: 0x0,
|
|
|
0x11000000: 0x40080010,
|
|
|
0x12000000: 0x40004010,
|
|
|
0x13000000: 0x40084000,
|
|
|
0x14000000: 0x40080000,
|
|
|
0x15000000: 0x10,
|
|
|
0x16000000: 0x84010,
|
|
|
0x17000000: 0x4000,
|
|
|
0x18000000: 0x4010,
|
|
|
0x19000000: 0x80000,
|
|
|
0x1a000000: 0x80010,
|
|
|
0x1b000000: 0x40000010,
|
|
|
0x1c000000: 0x84000,
|
|
|
0x1d000000: 0x40004000,
|
|
|
0x1e000000: 0x40000000,
|
|
|
0x1f000000: 0x40084010,
|
|
|
0x10800000: 0x84010,
|
|
|
0x11800000: 0x80000,
|
|
|
0x12800000: 0x40080000,
|
|
|
0x13800000: 0x4000,
|
|
|
0x14800000: 0x40004000,
|
|
|
0x15800000: 0x40084010,
|
|
|
0x16800000: 0x10,
|
|
|
0x17800000: 0x40000000,
|
|
|
0x18800000: 0x40084000,
|
|
|
0x19800000: 0x40000010,
|
|
|
0x1a800000: 0x40004010,
|
|
|
0x1b800000: 0x80010,
|
|
|
0x1c800000: 0x0,
|
|
|
0x1d800000: 0x4010,
|
|
|
0x1e800000: 0x40080010,
|
|
|
0x1f800000: 0x84000
|
|
|
},
|
|
|
{
|
|
|
0x0: 0x104,
|
|
|
0x100000: 0x0,
|
|
|
0x200000: 0x4000100,
|
|
|
0x300000: 0x10104,
|
|
|
0x400000: 0x10004,
|
|
|
0x500000: 0x4000004,
|
|
|
0x600000: 0x4010104,
|
|
|
0x700000: 0x4010000,
|
|
|
0x800000: 0x4000000,
|
|
|
0x900000: 0x4010100,
|
|
|
0xa00000: 0x10100,
|
|
|
0xb00000: 0x4010004,
|
|
|
0xc00000: 0x4000104,
|
|
|
0xd00000: 0x10000,
|
|
|
0xe00000: 0x4,
|
|
|
0xf00000: 0x100,
|
|
|
0x80000: 0x4010100,
|
|
|
0x180000: 0x4010004,
|
|
|
0x280000: 0x0,
|
|
|
0x380000: 0x4000100,
|
|
|
0x480000: 0x4000004,
|
|
|
0x580000: 0x10000,
|
|
|
0x680000: 0x10004,
|
|
|
0x780000: 0x104,
|
|
|
0x880000: 0x4,
|
|
|
0x980000: 0x100,
|
|
|
0xa80000: 0x4010000,
|
|
|
0xb80000: 0x10104,
|
|
|
0xc80000: 0x10100,
|
|
|
0xd80000: 0x4000104,
|
|
|
0xe80000: 0x4010104,
|
|
|
0xf80000: 0x4000000,
|
|
|
0x1000000: 0x4010100,
|
|
|
0x1100000: 0x10004,
|
|
|
0x1200000: 0x10000,
|
|
|
0x1300000: 0x4000100,
|
|
|
0x1400000: 0x100,
|
|
|
0x1500000: 0x4010104,
|
|
|
0x1600000: 0x4000004,
|
|
|
0x1700000: 0x0,
|
|
|
0x1800000: 0x4000104,
|
|
|
0x1900000: 0x4000000,
|
|
|
0x1a00000: 0x4,
|
|
|
0x1b00000: 0x10100,
|
|
|
0x1c00000: 0x4010000,
|
|
|
0x1d00000: 0x104,
|
|
|
0x1e00000: 0x10104,
|
|
|
0x1f00000: 0x4010004,
|
|
|
0x1080000: 0x4000000,
|
|
|
0x1180000: 0x104,
|
|
|
0x1280000: 0x4010100,
|
|
|
0x1380000: 0x0,
|
|
|
0x1480000: 0x10004,
|
|
|
0x1580000: 0x4000100,
|
|
|
0x1680000: 0x100,
|
|
|
0x1780000: 0x4010004,
|
|
|
0x1880000: 0x10000,
|
|
|
0x1980000: 0x4010104,
|
|
|
0x1a80000: 0x10104,
|
|
|
0x1b80000: 0x4000004,
|
|
|
0x1c80000: 0x4000104,
|
|
|
0x1d80000: 0x4010000,
|
|
|
0x1e80000: 0x4,
|
|
|
0x1f80000: 0x10100
|
|
|
},
|
|
|
{
|
|
|
0x0: 0x80401000,
|
|
|
0x10000: 0x80001040,
|
|
|
0x20000: 0x401040,
|
|
|
0x30000: 0x80400000,
|
|
|
0x40000: 0x0,
|
|
|
0x50000: 0x401000,
|
|
|
0x60000: 0x80000040,
|
|
|
0x70000: 0x400040,
|
|
|
0x80000: 0x80000000,
|
|
|
0x90000: 0x400000,
|
|
|
0xa0000: 0x40,
|
|
|
0xb0000: 0x80001000,
|
|
|
0xc0000: 0x80400040,
|
|
|
0xd0000: 0x1040,
|
|
|
0xe0000: 0x1000,
|
|
|
0xf0000: 0x80401040,
|
|
|
0x8000: 0x80001040,
|
|
|
0x18000: 0x40,
|
|
|
0x28000: 0x80400040,
|
|
|
0x38000: 0x80001000,
|
|
|
0x48000: 0x401000,
|
|
|
0x58000: 0x80401040,
|
|
|
0x68000: 0x0,
|
|
|
0x78000: 0x80400000,
|
|
|
0x88000: 0x1000,
|
|
|
0x98000: 0x80401000,
|
|
|
0xa8000: 0x400000,
|
|
|
0xb8000: 0x1040,
|
|
|
0xc8000: 0x80000000,
|
|
|
0xd8000: 0x400040,
|
|
|
0xe8000: 0x401040,
|
|
|
0xf8000: 0x80000040,
|
|
|
0x100000: 0x400040,
|
|
|
0x110000: 0x401000,
|
|
|
0x120000: 0x80000040,
|
|
|
0x130000: 0x0,
|
|
|
0x140000: 0x1040,
|
|
|
0x150000: 0x80400040,
|
|
|
0x160000: 0x80401000,
|
|
|
0x170000: 0x80001040,
|
|
|
0x180000: 0x80401040,
|
|
|
0x190000: 0x80000000,
|
|
|
0x1a0000: 0x80400000,
|
|
|
0x1b0000: 0x401040,
|
|
|
0x1c0000: 0x80001000,
|
|
|
0x1d0000: 0x400000,
|
|
|
0x1e0000: 0x40,
|
|
|
0x1f0000: 0x1000,
|
|
|
0x108000: 0x80400000,
|
|
|
0x118000: 0x80401040,
|
|
|
0x128000: 0x0,
|
|
|
0x138000: 0x401000,
|
|
|
0x148000: 0x400040,
|
|
|
0x158000: 0x80000000,
|
|
|
0x168000: 0x80001040,
|
|
|
0x178000: 0x40,
|
|
|
0x188000: 0x80000040,
|
|
|
0x198000: 0x1000,
|
|
|
0x1a8000: 0x80001000,
|
|
|
0x1b8000: 0x80400040,
|
|
|
0x1c8000: 0x1040,
|
|
|
0x1d8000: 0x80401000,
|
|
|
0x1e8000: 0x400000,
|
|
|
0x1f8000: 0x401040
|
|
|
},
|
|
|
{
|
|
|
0x0: 0x80,
|
|
|
0x1000: 0x1040000,
|
|
|
0x2000: 0x40000,
|
|
|
0x3000: 0x20000000,
|
|
|
0x4000: 0x20040080,
|
|
|
0x5000: 0x1000080,
|
|
|
0x6000: 0x21000080,
|
|
|
0x7000: 0x40080,
|
|
|
0x8000: 0x1000000,
|
|
|
0x9000: 0x20040000,
|
|
|
0xa000: 0x20000080,
|
|
|
0xb000: 0x21040080,
|
|
|
0xc000: 0x21040000,
|
|
|
0xd000: 0x0,
|
|
|
0xe000: 0x1040080,
|
|
|
0xf000: 0x21000000,
|
|
|
0x800: 0x1040080,
|
|
|
0x1800: 0x21000080,
|
|
|
0x2800: 0x80,
|
|
|
0x3800: 0x1040000,
|
|
|
0x4800: 0x40000,
|
|
|
0x5800: 0x20040080,
|
|
|
0x6800: 0x21040000,
|
|
|
0x7800: 0x20000000,
|
|
|
0x8800: 0x20040000,
|
|
|
0x9800: 0x0,
|
|
|
0xa800: 0x21040080,
|
|
|
0xb800: 0x1000080,
|
|
|
0xc800: 0x20000080,
|
|
|
0xd800: 0x21000000,
|
|
|
0xe800: 0x1000000,
|
|
|
0xf800: 0x40080,
|
|
|
0x10000: 0x40000,
|
|
|
0x11000: 0x80,
|
|
|
0x12000: 0x20000000,
|
|
|
0x13000: 0x21000080,
|
|
|
0x14000: 0x1000080,
|
|
|
0x15000: 0x21040000,
|
|
|
0x16000: 0x20040080,
|
|
|
0x17000: 0x1000000,
|
|
|
0x18000: 0x21040080,
|
|
|
0x19000: 0x21000000,
|
|
|
0x1a000: 0x1040000,
|
|
|
0x1b000: 0x20040000,
|
|
|
0x1c000: 0x40080,
|
|
|
0x1d000: 0x20000080,
|
|
|
0x1e000: 0x0,
|
|
|
0x1f000: 0x1040080,
|
|
|
0x10800: 0x21000080,
|
|
|
0x11800: 0x1000000,
|
|
|
0x12800: 0x1040000,
|
|
|
0x13800: 0x20040080,
|
|
|
0x14800: 0x20000000,
|
|
|
0x15800: 0x1040080,
|
|
|
0x16800: 0x80,
|
|
|
0x17800: 0x21040000,
|
|
|
0x18800: 0x40080,
|
|
|
0x19800: 0x21040080,
|
|
|
0x1a800: 0x0,
|
|
|
0x1b800: 0x21000000,
|
|
|
0x1c800: 0x1000080,
|
|
|
0x1d800: 0x40000,
|
|
|
0x1e800: 0x20040000,
|
|
|
0x1f800: 0x20000080
|
|
|
},
|
|
|
{
|
|
|
0x0: 0x10000008,
|
|
|
0x100: 0x2000,
|
|
|
0x200: 0x10200000,
|
|
|
0x300: 0x10202008,
|
|
|
0x400: 0x10002000,
|
|
|
0x500: 0x200000,
|
|
|
0x600: 0x200008,
|
|
|
0x700: 0x10000000,
|
|
|
0x800: 0x0,
|
|
|
0x900: 0x10002008,
|
|
|
0xa00: 0x202000,
|
|
|
0xb00: 0x8,
|
|
|
0xc00: 0x10200008,
|
|
|
0xd00: 0x202008,
|
|
|
0xe00: 0x2008,
|
|
|
0xf00: 0x10202000,
|
|
|
0x80: 0x10200000,
|
|
|
0x180: 0x10202008,
|
|
|
0x280: 0x8,
|
|
|
0x380: 0x200000,
|
|
|
0x480: 0x202008,
|
|
|
0x580: 0x10000008,
|
|
|
0x680: 0x10002000,
|
|
|
0x780: 0x2008,
|
|
|
0x880: 0x200008,
|
|
|
0x980: 0x2000,
|
|
|
0xa80: 0x10002008,
|
|
|
0xb80: 0x10200008,
|
|
|
0xc80: 0x0,
|
|
|
0xd80: 0x10202000,
|
|
|
0xe80: 0x202000,
|
|
|
0xf80: 0x10000000,
|
|
|
0x1000: 0x10002000,
|
|
|
0x1100: 0x10200008,
|
|
|
0x1200: 0x10202008,
|
|
|
0x1300: 0x2008,
|
|
|
0x1400: 0x200000,
|
|
|
0x1500: 0x10000000,
|
|
|
0x1600: 0x10000008,
|
|
|
0x1700: 0x202000,
|
|
|
0x1800: 0x202008,
|
|
|
0x1900: 0x0,
|
|
|
0x1a00: 0x8,
|
|
|
0x1b00: 0x10200000,
|
|
|
0x1c00: 0x2000,
|
|
|
0x1d00: 0x10002008,
|
|
|
0x1e00: 0x10202000,
|
|
|
0x1f00: 0x200008,
|
|
|
0x1080: 0x8,
|
|
|
0x1180: 0x202000,
|
|
|
0x1280: 0x200000,
|
|
|
0x1380: 0x10000008,
|
|
|
0x1480: 0x10002000,
|
|
|
0x1580: 0x2008,
|
|
|
0x1680: 0x10202008,
|
|
|
0x1780: 0x10200000,
|
|
|
0x1880: 0x10202000,
|
|
|
0x1980: 0x10200008,
|
|
|
0x1a80: 0x2000,
|
|
|
0x1b80: 0x202008,
|
|
|
0x1c80: 0x200008,
|
|
|
0x1d80: 0x0,
|
|
|
0x1e80: 0x10000000,
|
|
|
0x1f80: 0x10002008
|
|
|
},
|
|
|
{
|
|
|
0x0: 0x100000,
|
|
|
0x10: 0x2000401,
|
|
|
0x20: 0x400,
|
|
|
0x30: 0x100401,
|
|
|
0x40: 0x2100401,
|
|
|
0x50: 0x0,
|
|
|
0x60: 0x1,
|
|
|
0x70: 0x2100001,
|
|
|
0x80: 0x2000400,
|
|
|
0x90: 0x100001,
|
|
|
0xa0: 0x2000001,
|
|
|
0xb0: 0x2100400,
|
|
|
0xc0: 0x2100000,
|
|
|
0xd0: 0x401,
|
|
|
0xe0: 0x100400,
|
|
|
0xf0: 0x2000000,
|
|
|
0x8: 0x2100001,
|
|
|
0x18: 0x0,
|
|
|
0x28: 0x2000401,
|
|
|
0x38: 0x2100400,
|
|
|
0x48: 0x100000,
|
|
|
0x58: 0x2000001,
|
|
|
0x68: 0x2000000,
|
|
|
0x78: 0x401,
|
|
|
0x88: 0x100401,
|
|
|
0x98: 0x2000400,
|
|
|
0xa8: 0x2100000,
|
|
|
0xb8: 0x100001,
|
|
|
0xc8: 0x400,
|
|
|
0xd8: 0x2100401,
|
|
|
0xe8: 0x1,
|
|
|
0xf8: 0x100400,
|
|
|
0x100: 0x2000000,
|
|
|
0x110: 0x100000,
|
|
|
0x120: 0x2000401,
|
|
|
0x130: 0x2100001,
|
|
|
0x140: 0x100001,
|
|
|
0x150: 0x2000400,
|
|
|
0x160: 0x2100400,
|
|
|
0x170: 0x100401,
|
|
|
0x180: 0x401,
|
|
|
0x190: 0x2100401,
|
|
|
0x1a0: 0x100400,
|
|
|
0x1b0: 0x1,
|
|
|
0x1c0: 0x0,
|
|
|
0x1d0: 0x2100000,
|
|
|
0x1e0: 0x2000001,
|
|
|
0x1f0: 0x400,
|
|
|
0x108: 0x100400,
|
|
|
0x118: 0x2000401,
|
|
|
0x128: 0x2100001,
|
|
|
0x138: 0x1,
|
|
|
0x148: 0x2000000,
|
|
|
0x158: 0x100000,
|
|
|
0x168: 0x401,
|
|
|
0x178: 0x2100400,
|
|
|
0x188: 0x2000001,
|
|
|
0x198: 0x2100000,
|
|
|
0x1a8: 0x0,
|
|
|
0x1b8: 0x2100401,
|
|
|
0x1c8: 0x100401,
|
|
|
0x1d8: 0x400,
|
|
|
0x1e8: 0x2000400,
|
|
|
0x1f8: 0x100001
|
|
|
},
|
|
|
{
|
|
|
0x0: 0x8000820,
|
|
|
0x1: 0x20000,
|
|
|
0x2: 0x8000000,
|
|
|
0x3: 0x20,
|
|
|
0x4: 0x20020,
|
|
|
0x5: 0x8020820,
|
|
|
0x6: 0x8020800,
|
|
|
0x7: 0x800,
|
|
|
0x8: 0x8020000,
|
|
|
0x9: 0x8000800,
|
|
|
0xa: 0x20800,
|
|
|
0xb: 0x8020020,
|
|
|
0xc: 0x820,
|
|
|
0xd: 0x0,
|
|
|
0xe: 0x8000020,
|
|
|
0xf: 0x20820,
|
|
|
0x80000000: 0x800,
|
|
|
0x80000001: 0x8020820,
|
|
|
0x80000002: 0x8000820,
|
|
|
0x80000003: 0x8000000,
|
|
|
0x80000004: 0x8020000,
|
|
|
0x80000005: 0x20800,
|
|
|
0x80000006: 0x20820,
|
|
|
0x80000007: 0x20,
|
|
|
0x80000008: 0x8000020,
|
|
|
0x80000009: 0x820,
|
|
|
0x8000000a: 0x20020,
|
|
|
0x8000000b: 0x8020800,
|
|
|
0x8000000c: 0x0,
|
|
|
0x8000000d: 0x8020020,
|
|
|
0x8000000e: 0x8000800,
|
|
|
0x8000000f: 0x20000,
|
|
|
0x10: 0x20820,
|
|
|
0x11: 0x8020800,
|
|
|
0x12: 0x20,
|
|
|
0x13: 0x800,
|
|
|
0x14: 0x8000800,
|
|
|
0x15: 0x8000020,
|
|
|
0x16: 0x8020020,
|
|
|
0x17: 0x20000,
|
|
|
0x18: 0x0,
|
|
|
0x19: 0x20020,
|
|
|
0x1a: 0x8020000,
|
|
|
0x1b: 0x8000820,
|
|
|
0x1c: 0x8020820,
|
|
|
0x1d: 0x20800,
|
|
|
0x1e: 0x820,
|
|
|
0x1f: 0x8000000,
|
|
|
0x80000010: 0x20000,
|
|
|
0x80000011: 0x800,
|
|
|
0x80000012: 0x8020020,
|
|
|
0x80000013: 0x20820,
|
|
|
0x80000014: 0x20,
|
|
|
0x80000015: 0x8020000,
|
|
|
0x80000016: 0x8000000,
|
|
|
0x80000017: 0x8000820,
|
|
|
0x80000018: 0x8020820,
|
|
|
0x80000019: 0x8000020,
|
|
|
0x8000001a: 0x8000800,
|
|
|
0x8000001b: 0x0,
|
|
|
0x8000001c: 0x20800,
|
|
|
0x8000001d: 0x820,
|
|
|
0x8000001e: 0x20020,
|
|
|
0x8000001f: 0x8020800
|
|
|
}
|
|
|
];
|
|
|
|
|
|
// Masks that select the SBOX input
|
|
|
var SBOX_MASK = [
|
|
|
0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
|
|
|
0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
|
|
|
];
|
|
|
|
|
|
/**
|
|
|
* DES block cipher algorithm.
|
|
|
*/
|
|
|
var DES = C_algo.DES = BlockCipher.extend({
|
|
|
_doReset: function () {
|
|
|
// Shortcuts
|
|
|
var key = this._key;
|
|
|
var keyWords = key.words;
|
|
|
|
|
|
// Select 56 bits according to PC1
|
|
|
var keyBits = [];
|
|
|
for (var i = 0; i < 56; i++) {
|
|
|
var keyBitPos = PC1[i] - 1;
|
|
|
keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
|
|
|
}
|
|
|
|
|
|
// Assemble 16 subkeys
|
|
|
var subKeys = this._subKeys = [];
|
|
|
for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
|
|
|
// Create subkey
|
|
|
var subKey = subKeys[nSubKey] = [];
|
|
|
|
|
|
// Shortcut
|
|
|
var bitShift = BIT_SHIFTS[nSubKey];
|
|
|
|
|
|
// Select 48 bits according to PC2
|
|
|
for (var i = 0; i < 24; i++) {
|
|
|
// Select from the left 28 key bits
|
|
|
subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
|
|
|
|
|
|
// Select from the right 28 key bits
|
|
|
subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
|
|
|
}
|
|
|
|
|
|
// Since each subkey is applied to an expanded 32-bit input,
|
|
|
// the subkey can be broken into 8 values scaled to 32-bits,
|
|
|
// which allows the key to be used without expansion
|
|
|
subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
|
|
|
for (var i = 1; i < 7; i++) {
|
|
|
subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
|
|
|
}
|
|
|
subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
|
|
|
}
|
|
|
|
|
|
// Compute inverse subkeys
|
|
|
var invSubKeys = this._invSubKeys = [];
|
|
|
for (var i = 0; i < 16; i++) {
|
|
|
invSubKeys[i] = subKeys[15 - i];
|
|
|
}
|
|
|
},
|
|
|
|
|
|
encryptBlock: function (M, offset) {
|
|
|
this._doCryptBlock(M, offset, this._subKeys);
|
|
|
},
|
|
|
|
|
|
decryptBlock: function (M, offset) {
|
|
|
this._doCryptBlock(M, offset, this._invSubKeys);
|
|
|
},
|
|
|
|
|
|
_doCryptBlock: function (M, offset, subKeys) {
|
|
|
// Get input
|
|
|
this._lBlock = M[offset];
|
|
|
this._rBlock = M[offset + 1];
|
|
|
|
|
|
// Initial permutation
|
|
|
exchangeLR.call(this, 4, 0x0f0f0f0f);
|
|
|
exchangeLR.call(this, 16, 0x0000ffff);
|
|
|
exchangeRL.call(this, 2, 0x33333333);
|
|
|
exchangeRL.call(this, 8, 0x00ff00ff);
|
|
|
exchangeLR.call(this, 1, 0x55555555);
|
|
|
|
|
|
// Rounds
|
|
|
for (var round = 0; round < 16; round++) {
|
|
|
// Shortcuts
|
|
|
var subKey = subKeys[round];
|
|
|
var lBlock = this._lBlock;
|
|
|
var rBlock = this._rBlock;
|
|
|
|
|
|
// Feistel function
|
|
|
var f = 0;
|
|
|
for (var i = 0; i < 8; i++) {
|
|
|
f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
|
|
|
}
|
|
|
this._lBlock = rBlock;
|
|
|
this._rBlock = lBlock ^ f;
|
|
|
}
|
|
|
|
|
|
// Undo swap from last round
|
|
|
var t = this._lBlock;
|
|
|
this._lBlock = this._rBlock;
|
|
|
this._rBlock = t;
|
|
|
|
|
|
// Final permutation
|
|
|
exchangeLR.call(this, 1, 0x55555555);
|
|
|
exchangeRL.call(this, 8, 0x00ff00ff);
|
|
|
exchangeRL.call(this, 2, 0x33333333);
|
|
|
exchangeLR.call(this, 16, 0x0000ffff);
|
|
|
exchangeLR.call(this, 4, 0x0f0f0f0f);
|
|
|
|
|
|
// Set output
|
|
|
M[offset] = this._lBlock;
|
|
|
M[offset + 1] = this._rBlock;
|
|
|
},
|
|
|
|
|
|
keySize: 64/32,
|
|
|
|
|
|
ivSize: 64/32,
|
|
|
|
|
|
blockSize: 64/32
|
|
|
});
|
|
|
|
|
|
// Swap bits across the left and right words
|
|
|
function exchangeLR(offset, mask) {
|
|
|
var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
|
|
|
this._rBlock ^= t;
|
|
|
this._lBlock ^= t << offset;
|
|
|
}
|
|
|
|
|
|
function exchangeRL(offset, mask) {
|
|
|
var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
|
|
|
this._lBlock ^= t;
|
|
|
this._rBlock ^= t << offset;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Shortcut functions to the cipher's object interface.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
|
|
|
* var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
|
|
|
*/
|
|
|
C.DES = BlockCipher._createHelper(DES);
|
|
|
|
|
|
/**
|
|
|
* Triple-DES block cipher algorithm.
|
|
|
*/
|
|
|
var TripleDES = C_algo.TripleDES = BlockCipher.extend({
|
|
|
_doReset: function () {
|
|
|
// Shortcuts
|
|
|
var key = this._key;
|
|
|
var keyWords = key.words;
|
|
|
// Make sure the key length is valid (64, 128 or >= 192 bit)
|
|
|
if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
|
|
|
throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
|
|
|
}
|
|
|
|
|
|
// Extend the key according to the keying options defined in 3DES standard
|
|
|
var key1 = keyWords.slice(0, 2);
|
|
|
var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
|
|
|
var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);
|
|
|
|
|
|
// Create DES instances
|
|
|
this._des1 = DES.createEncryptor(WordArray.create(key1));
|
|
|
this._des2 = DES.createEncryptor(WordArray.create(key2));
|
|
|
this._des3 = DES.createEncryptor(WordArray.create(key3));
|
|
|
},
|
|
|
|
|
|
encryptBlock: function (M, offset) {
|
|
|
this._des1.encryptBlock(M, offset);
|
|
|
this._des2.decryptBlock(M, offset);
|
|
|
this._des3.encryptBlock(M, offset);
|
|
|
},
|
|
|
|
|
|
decryptBlock: function (M, offset) {
|
|
|
this._des3.decryptBlock(M, offset);
|
|
|
this._des2.encryptBlock(M, offset);
|
|
|
this._des1.decryptBlock(M, offset);
|
|
|
},
|
|
|
|
|
|
keySize: 192/32,
|
|
|
|
|
|
ivSize: 64/32,
|
|
|
|
|
|
blockSize: 64/32
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Shortcut functions to the cipher's object interface.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
|
|
|
* var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
|
|
|
*/
|
|
|
C.TripleDES = BlockCipher._createHelper(TripleDES);
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS.TripleDES;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 64938:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/crypto-js/x64-core.js ***!
|
|
|
\********************************************/
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
;(function (root, factory) {
|
|
|
if (true) {
|
|
|
// CommonJS
|
|
|
module.exports = exports = factory(__webpack_require__(/*! ./core */ 78249));
|
|
|
}
|
|
|
else {}
|
|
|
}(this, function (CryptoJS) {
|
|
|
|
|
|
(function (undefined) {
|
|
|
// Shortcuts
|
|
|
var C = CryptoJS;
|
|
|
var C_lib = C.lib;
|
|
|
var Base = C_lib.Base;
|
|
|
var X32WordArray = C_lib.WordArray;
|
|
|
|
|
|
/**
|
|
|
* x64 namespace.
|
|
|
*/
|
|
|
var C_x64 = C.x64 = {};
|
|
|
|
|
|
/**
|
|
|
* A 64-bit word.
|
|
|
*/
|
|
|
var X64Word = C_x64.Word = Base.extend({
|
|
|
/**
|
|
|
* Initializes a newly created 64-bit word.
|
|
|
*
|
|
|
* @param {number} high The high 32 bits.
|
|
|
* @param {number} low The low 32 bits.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
|
|
|
*/
|
|
|
init: function (high, low) {
|
|
|
this.high = high;
|
|
|
this.low = low;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Bitwise NOTs this word.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after negating.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var negated = x64Word.not();
|
|
|
*/
|
|
|
// not: function () {
|
|
|
// var high = ~this.high;
|
|
|
// var low = ~this.low;
|
|
|
|
|
|
// return X64Word.create(high, low);
|
|
|
// },
|
|
|
|
|
|
/**
|
|
|
* Bitwise ANDs this word with the passed word.
|
|
|
*
|
|
|
* @param {X64Word} word The x64-Word to AND with this word.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after ANDing.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var anded = x64Word.and(anotherX64Word);
|
|
|
*/
|
|
|
// and: function (word) {
|
|
|
// var high = this.high & word.high;
|
|
|
// var low = this.low & word.low;
|
|
|
|
|
|
// return X64Word.create(high, low);
|
|
|
// },
|
|
|
|
|
|
/**
|
|
|
* Bitwise ORs this word with the passed word.
|
|
|
*
|
|
|
* @param {X64Word} word The x64-Word to OR with this word.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after ORing.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var ored = x64Word.or(anotherX64Word);
|
|
|
*/
|
|
|
// or: function (word) {
|
|
|
// var high = this.high | word.high;
|
|
|
// var low = this.low | word.low;
|
|
|
|
|
|
// return X64Word.create(high, low);
|
|
|
// },
|
|
|
|
|
|
/**
|
|
|
* Bitwise XORs this word with the passed word.
|
|
|
*
|
|
|
* @param {X64Word} word The x64-Word to XOR with this word.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after XORing.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var xored = x64Word.xor(anotherX64Word);
|
|
|
*/
|
|
|
// xor: function (word) {
|
|
|
// var high = this.high ^ word.high;
|
|
|
// var low = this.low ^ word.low;
|
|
|
|
|
|
// return X64Word.create(high, low);
|
|
|
// },
|
|
|
|
|
|
/**
|
|
|
* Shifts this word n bits to the left.
|
|
|
*
|
|
|
* @param {number} n The number of bits to shift.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after shifting.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var shifted = x64Word.shiftL(25);
|
|
|
*/
|
|
|
// shiftL: function (n) {
|
|
|
// if (n < 32) {
|
|
|
// var high = (this.high << n) | (this.low >>> (32 - n));
|
|
|
// var low = this.low << n;
|
|
|
// } else {
|
|
|
// var high = this.low << (n - 32);
|
|
|
// var low = 0;
|
|
|
// }
|
|
|
|
|
|
// return X64Word.create(high, low);
|
|
|
// },
|
|
|
|
|
|
/**
|
|
|
* Shifts this word n bits to the right.
|
|
|
*
|
|
|
* @param {number} n The number of bits to shift.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after shifting.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var shifted = x64Word.shiftR(7);
|
|
|
*/
|
|
|
// shiftR: function (n) {
|
|
|
// if (n < 32) {
|
|
|
// var low = (this.low >>> n) | (this.high << (32 - n));
|
|
|
// var high = this.high >>> n;
|
|
|
// } else {
|
|
|
// var low = this.high >>> (n - 32);
|
|
|
// var high = 0;
|
|
|
// }
|
|
|
|
|
|
// return X64Word.create(high, low);
|
|
|
// },
|
|
|
|
|
|
/**
|
|
|
* Rotates this word n bits to the left.
|
|
|
*
|
|
|
* @param {number} n The number of bits to rotate.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after rotating.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var rotated = x64Word.rotL(25);
|
|
|
*/
|
|
|
// rotL: function (n) {
|
|
|
// return this.shiftL(n).or(this.shiftR(64 - n));
|
|
|
// },
|
|
|
|
|
|
/**
|
|
|
* Rotates this word n bits to the right.
|
|
|
*
|
|
|
* @param {number} n The number of bits to rotate.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after rotating.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var rotated = x64Word.rotR(7);
|
|
|
*/
|
|
|
// rotR: function (n) {
|
|
|
// return this.shiftR(n).or(this.shiftL(64 - n));
|
|
|
// },
|
|
|
|
|
|
/**
|
|
|
* Adds this word with the passed word.
|
|
|
*
|
|
|
* @param {X64Word} word The x64-Word to add with this word.
|
|
|
*
|
|
|
* @return {X64Word} A new x64-Word object after adding.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var added = x64Word.add(anotherX64Word);
|
|
|
*/
|
|
|
// add: function (word) {
|
|
|
// var low = (this.low + word.low) | 0;
|
|
|
// var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
|
|
|
// var high = (this.high + word.high + carry) | 0;
|
|
|
|
|
|
// return X64Word.create(high, low);
|
|
|
// }
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* An array of 64-bit words.
|
|
|
*
|
|
|
* @property {Array} words The array of CryptoJS.x64.Word objects.
|
|
|
* @property {number} sigBytes The number of significant bytes in this word array.
|
|
|
*/
|
|
|
var X64WordArray = C_x64.WordArray = Base.extend({
|
|
|
/**
|
|
|
* Initializes a newly created word array.
|
|
|
*
|
|
|
* @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
|
|
|
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var wordArray = CryptoJS.x64.WordArray.create();
|
|
|
*
|
|
|
* var wordArray = CryptoJS.x64.WordArray.create([
|
|
|
* CryptoJS.x64.Word.create(0x00010203, 0x04050607),
|
|
|
* CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
|
|
|
* ]);
|
|
|
*
|
|
|
* var wordArray = CryptoJS.x64.WordArray.create([
|
|
|
* CryptoJS.x64.Word.create(0x00010203, 0x04050607),
|
|
|
* CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
|
|
|
* ], 10);
|
|
|
*/
|
|
|
init: function (words, sigBytes) {
|
|
|
words = this.words = words || [];
|
|
|
|
|
|
if (sigBytes != undefined) {
|
|
|
this.sigBytes = sigBytes;
|
|
|
} else {
|
|
|
this.sigBytes = words.length * 8;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Converts this 64-bit word array to a 32-bit word array.
|
|
|
*
|
|
|
* @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var x32WordArray = x64WordArray.toX32();
|
|
|
*/
|
|
|
toX32: function () {
|
|
|
// Shortcuts
|
|
|
var x64Words = this.words;
|
|
|
var x64WordsLength = x64Words.length;
|
|
|
|
|
|
// Convert
|
|
|
var x32Words = [];
|
|
|
for (var i = 0; i < x64WordsLength; i++) {
|
|
|
var x64Word = x64Words[i];
|
|
|
x32Words.push(x64Word.high);
|
|
|
x32Words.push(x64Word.low);
|
|
|
}
|
|
|
|
|
|
return X32WordArray.create(x32Words, this.sigBytes);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* Creates a copy of this word array.
|
|
|
*
|
|
|
* @return {X64WordArray} The clone.
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* var clone = x64WordArray.clone();
|
|
|
*/
|
|
|
clone: function () {
|
|
|
var clone = Base.clone.call(this);
|
|
|
|
|
|
// Clone "words" array
|
|
|
var words = clone.words = this.words.slice(0);
|
|
|
|
|
|
// Clone each X64Word object
|
|
|
var wordsLength = words.length;
|
|
|
for (var i = 0; i < wordsLength; i++) {
|
|
|
words[i] = words[i].clone();
|
|
|
}
|
|
|
|
|
|
return clone;
|
|
|
}
|
|
|
});
|
|
|
}());
|
|
|
|
|
|
|
|
|
return CryptoJS;
|
|
|
|
|
|
}));
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
}]); |