pusher-js
Version:
Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers
1,669 lines (1,441 loc) • 308 kB
JavaScript
/*!
* Pusher JavaScript Library v8.5.0
* https://pusher.com/
*
* Copyright 2020, Pusher
* Released under the MIT licence.
*/
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 594
(__unused_webpack_module, exports) {
"use strict";
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", ({ value: true }));
/**
* Package base64 implements Base64 encoding and decoding.
*/
// Invalid character used in decoding to indicate
// that the character to decode is out of range of
// alphabet and cannot be decoded.
var INVALID_BYTE = 256;
/**
* Implements standard Base64 encoding.
*
* Operates in constant time.
*/
var Coder = /** @class */ (function () {
// TODO(dchest): methods to encode chunk-by-chunk.
function Coder(_paddingCharacter) {
if (_paddingCharacter === void 0) { _paddingCharacter = "="; }
this._paddingCharacter = _paddingCharacter;
}
Coder.prototype.encodedLength = function (length) {
if (!this._paddingCharacter) {
return (length * 8 + 5) / 6 | 0;
}
return (length + 2) / 3 * 4 | 0;
};
Coder.prototype.encode = function (data) {
var out = "";
var i = 0;
for (; i < data.length - 2; i += 3) {
var c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);
out += this._encodeByte((c >>> 3 * 6) & 63);
out += this._encodeByte((c >>> 2 * 6) & 63);
out += this._encodeByte((c >>> 1 * 6) & 63);
out += this._encodeByte((c >>> 0 * 6) & 63);
}
var left = data.length - i;
if (left > 0) {
var c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);
out += this._encodeByte((c >>> 3 * 6) & 63);
out += this._encodeByte((c >>> 2 * 6) & 63);
if (left === 2) {
out += this._encodeByte((c >>> 1 * 6) & 63);
}
else {
out += this._paddingCharacter || "";
}
out += this._paddingCharacter || "";
}
return out;
};
Coder.prototype.maxDecodedLength = function (length) {
if (!this._paddingCharacter) {
return (length * 6 + 7) / 8 | 0;
}
return length / 4 * 3 | 0;
};
Coder.prototype.decodedLength = function (s) {
return this.maxDecodedLength(s.length - this._getPaddingLength(s));
};
Coder.prototype.decode = function (s) {
if (s.length === 0) {
return new Uint8Array(0);
}
var paddingLength = this._getPaddingLength(s);
var length = s.length - paddingLength;
var out = new Uint8Array(this.maxDecodedLength(length));
var op = 0;
var i = 0;
var haveBad = 0;
var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
for (; i < length - 4; i += 4) {
v0 = this._decodeChar(s.charCodeAt(i + 0));
v1 = this._decodeChar(s.charCodeAt(i + 1));
v2 = this._decodeChar(s.charCodeAt(i + 2));
v3 = this._decodeChar(s.charCodeAt(i + 3));
out[op++] = (v0 << 2) | (v1 >>> 4);
out[op++] = (v1 << 4) | (v2 >>> 2);
out[op++] = (v2 << 6) | v3;
haveBad |= v0 & INVALID_BYTE;
haveBad |= v1 & INVALID_BYTE;
haveBad |= v2 & INVALID_BYTE;
haveBad |= v3 & INVALID_BYTE;
}
if (i < length - 1) {
v0 = this._decodeChar(s.charCodeAt(i));
v1 = this._decodeChar(s.charCodeAt(i + 1));
out[op++] = (v0 << 2) | (v1 >>> 4);
haveBad |= v0 & INVALID_BYTE;
haveBad |= v1 & INVALID_BYTE;
}
if (i < length - 2) {
v2 = this._decodeChar(s.charCodeAt(i + 2));
out[op++] = (v1 << 4) | (v2 >>> 2);
haveBad |= v2 & INVALID_BYTE;
}
if (i < length - 3) {
v3 = this._decodeChar(s.charCodeAt(i + 3));
out[op++] = (v2 << 6) | v3;
haveBad |= v3 & INVALID_BYTE;
}
if (haveBad !== 0) {
throw new Error("Base64Coder: incorrect characters for decoding");
}
return out;
};
// Standard encoding have the following encoded/decoded ranges,
// which we need to convert between.
//
// ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /
// Index: 0 - 25 26 - 51 52 - 61 62 63
// ASCII: 65 - 90 97 - 122 48 - 57 43 47
//
// Encode 6 bits in b into a new character.
Coder.prototype._encodeByte = function (b) {
// Encoding uses constant time operations as follows:
//
// 1. Define comparison of A with B using (A - B) >>> 8:
// if A > B, then result is positive integer
// if A <= B, then result is 0
//
// 2. Define selection of C or 0 using bitwise AND: X & C:
// if X == 0, then result is 0
// if X != 0, then result is C
//
// 3. Start with the smallest comparison (b >= 0), which is always
// true, so set the result to the starting ASCII value (65).
//
// 4. Continue comparing b to higher ASCII values, and selecting
// zero if comparison isn't true, otherwise selecting a value
// to add to result, which:
//
// a) undoes the previous addition
// b) provides new value to add
//
var result = b;
// b >= 0
result += 65;
// b > 25
result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);
// b > 51
result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);
// b > 61
result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);
// b > 62
result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);
return String.fromCharCode(result);
};
// Decode a character code into a byte.
// Must return 256 if character is out of alphabet range.
Coder.prototype._decodeChar = function (c) {
// Decoding works similar to encoding: using the same comparison
// function, but now it works on ranges: result is always incremented
// by value, but this value becomes zero if the range is not
// satisfied.
//
// Decoding starts with invalid value, 256, which is then
// subtracted when the range is satisfied. If none of the ranges
// apply, the function returns 256, which is then checked by
// the caller to throw error.
var result = INVALID_BYTE; // start with invalid character
// c == 43 (c > 42 and c < 44)
result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);
// c == 47 (c > 46 and c < 48)
result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);
// c > 47 and c < 58
result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);
// c > 64 and c < 91
result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);
// c > 96 and c < 123
result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);
return result;
};
Coder.prototype._getPaddingLength = function (s) {
var paddingLength = 0;
if (this._paddingCharacter) {
for (var i = s.length - 1; i >= 0; i--) {
if (s[i] !== this._paddingCharacter) {
break;
}
paddingLength++;
}
if (s.length < 4 || paddingLength > 2) {
throw new Error("Base64Coder: incorrect padding");
}
}
return paddingLength;
};
return Coder;
}());
exports.Coder = Coder;
var stdCoder = new Coder();
function encode(data) {
return stdCoder.encode(data);
}
exports.encode = encode;
function decode(s) {
return stdCoder.decode(s);
}
exports.decode = decode;
/**
* Implements URL-safe Base64 encoding.
* (Same as Base64, but '+' is replaced with '-', and '/' with '_').
*
* Operates in constant time.
*/
var URLSafeCoder = /** @class */ (function (_super) {
__extends(URLSafeCoder, _super);
function URLSafeCoder() {
return _super !== null && _super.apply(this, arguments) || this;
}
// URL-safe encoding have the following encoded/decoded ranges:
//
// ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _
// Index: 0 - 25 26 - 51 52 - 61 62 63
// ASCII: 65 - 90 97 - 122 48 - 57 45 95
//
URLSafeCoder.prototype._encodeByte = function (b) {
var result = b;
// b >= 0
result += 65;
// b > 25
result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);
// b > 51
result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);
// b > 61
result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);
// b > 62
result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);
return String.fromCharCode(result);
};
URLSafeCoder.prototype._decodeChar = function (c) {
var result = INVALID_BYTE;
// c == 45 (c > 44 and c < 46)
result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);
// c == 95 (c > 94 and c < 96)
result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);
// c > 47 and c < 58
result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);
// c > 64 and c < 91
result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);
// c > 96 and c < 123
result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);
return result;
};
return URLSafeCoder;
}(Coder));
exports.URLSafeCoder = URLSafeCoder;
var urlSafeCoder = new URLSafeCoder();
function encodeURLSafe(data) {
return urlSafeCoder.encode(data);
}
exports.encodeURLSafe = encodeURLSafe;
function decodeURLSafe(s) {
return urlSafeCoder.decode(s);
}
exports.decodeURLSafe = decodeURLSafe;
exports.encodedLength = function (length) {
return stdCoder.encodedLength(length);
};
exports.maxDecodedLength = function (length) {
return stdCoder.maxDecodedLength(length);
};
exports.decodedLength = function (s) {
return stdCoder.decodedLength(s);
};
/***/ },
/***/ 978
(__unused_webpack_module, exports) {
"use strict";
var __webpack_unused_export__;
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.
__webpack_unused_export__ = ({ value: true });
/**
* Package utf8 implements UTF-8 encoding and decoding.
*/
var INVALID_UTF16 = "utf8: invalid string";
var INVALID_UTF8 = "utf8: invalid source encoding";
/**
* Encodes the given string into UTF-8 byte array.
* Throws if the source string has invalid UTF-16 encoding.
*/
function encode(s) {
// Calculate result length and allocate output array.
// encodedLength() also validates string and throws errors,
// so we don't need repeat validation here.
var arr = new Uint8Array(encodedLength(s));
var pos = 0;
for (var i = 0; i < s.length; i++) {
var c = s.charCodeAt(i);
if (c < 0x80) {
arr[pos++] = c;
}
else if (c < 0x800) {
arr[pos++] = 0xc0 | c >> 6;
arr[pos++] = 0x80 | c & 0x3f;
}
else if (c < 0xd800) {
arr[pos++] = 0xe0 | c >> 12;
arr[pos++] = 0x80 | (c >> 6) & 0x3f;
arr[pos++] = 0x80 | c & 0x3f;
}
else {
i++; // get one more character
c = (c & 0x3ff) << 10;
c |= s.charCodeAt(i) & 0x3ff;
c += 0x10000;
arr[pos++] = 0xf0 | c >> 18;
arr[pos++] = 0x80 | (c >> 12) & 0x3f;
arr[pos++] = 0x80 | (c >> 6) & 0x3f;
arr[pos++] = 0x80 | c & 0x3f;
}
}
return arr;
}
__webpack_unused_export__ = encode;
/**
* Returns the number of bytes required to encode the given string into UTF-8.
* Throws if the source string has invalid UTF-16 encoding.
*/
function encodedLength(s) {
var result = 0;
for (var i = 0; i < s.length; i++) {
var c = s.charCodeAt(i);
if (c < 0x80) {
result += 1;
}
else if (c < 0x800) {
result += 2;
}
else if (c < 0xd800) {
result += 3;
}
else if (c <= 0xdfff) {
if (i >= s.length - 1) {
throw new Error(INVALID_UTF16);
}
i++; // "eat" next character
result += 4;
}
else {
throw new Error(INVALID_UTF16);
}
}
return result;
}
__webpack_unused_export__ = encodedLength;
/**
* Decodes the given byte array from UTF-8 into a string.
* Throws if encoding is invalid.
*/
function decode(arr) {
var chars = [];
for (var i = 0; i < arr.length; i++) {
var b = arr[i];
if (b & 0x80) {
var min = void 0;
if (b < 0xe0) {
// Need 1 more byte.
if (i >= arr.length) {
throw new Error(INVALID_UTF8);
}
var n1 = arr[++i];
if ((n1 & 0xc0) !== 0x80) {
throw new Error(INVALID_UTF8);
}
b = (b & 0x1f) << 6 | (n1 & 0x3f);
min = 0x80;
}
else if (b < 0xf0) {
// Need 2 more bytes.
if (i >= arr.length - 1) {
throw new Error(INVALID_UTF8);
}
var n1 = arr[++i];
var n2 = arr[++i];
if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {
throw new Error(INVALID_UTF8);
}
b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);
min = 0x800;
}
else if (b < 0xf8) {
// Need 3 more bytes.
if (i >= arr.length - 2) {
throw new Error(INVALID_UTF8);
}
var n1 = arr[++i];
var n2 = arr[++i];
var n3 = arr[++i];
if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {
throw new Error(INVALID_UTF8);
}
b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);
min = 0x10000;
}
else {
throw new Error(INVALID_UTF8);
}
if (b < min || (b >= 0xd800 && b <= 0xdfff)) {
throw new Error(INVALID_UTF8);
}
if (b >= 0x10000) {
// Surrogate pair.
if (b > 0x10ffff) {
throw new Error(INVALID_UTF8);
}
b -= 0x10000;
chars.push(String.fromCharCode(0xd800 | (b >> 10)));
b = 0xdc00 | (b & 0x3ff);
}
}
chars.push(String.fromCharCode(b));
}
return chars.join("");
}
exports.D4 = decode;
/***/ },
/***/ 945
(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Stream = (__webpack_require__(203).Stream),
util = __webpack_require__(23),
driver = __webpack_require__(41),
Headers = __webpack_require__(160),
API = __webpack_require__(720),
EventTarget = __webpack_require__(667),
Event = __webpack_require__(859);
var EventSource = function(request, response, options) {
this.writable = true;
options = options || {};
this._stream = response.socket;
this._ping = options.ping || this.DEFAULT_PING;
this._retry = options.retry || this.DEFAULT_RETRY;
var scheme = driver.isSecureRequest(request) ? 'https:' : 'http:';
this.url = scheme + '//' + request.headers.host + request.url;
this.lastEventId = request.headers['last-event-id'] || '';
this.readyState = API.CONNECTING;
var headers = new Headers(),
self = this;
if (options.headers) {
for (var key in options.headers) headers.set(key, options.headers[key]);
}
if (!this._stream || !this._stream.writable) return;
process.nextTick(function() { self._open() });
this._stream.setTimeout(0);
this._stream.setNoDelay(true);
var handshake = 'HTTP/1.1 200 OK\r\n' +
'Content-Type: text/event-stream\r\n' +
'Cache-Control: no-cache, no-store\r\n' +
'Connection: close\r\n' +
headers.toString() +
'\r\n' +
'retry: ' + Math.floor(this._retry * 1000) + '\r\n\r\n';
this._write(handshake);
this._stream.on('drain', function() { self.emit('drain') });
if (this._ping)
this._pingTimer = setInterval(function() { self.ping() }, this._ping * 1000);
['error', 'end'].forEach(function(event) {
self._stream.on(event, function() { self.close() });
});
};
util.inherits(EventSource, Stream);
EventSource.isEventSource = function(request) {
if (request.method !== 'GET') return false;
var accept = (request.headers.accept || '').split(/\s*,\s*/);
return accept.indexOf('text/event-stream') >= 0;
};
var instance = {
DEFAULT_PING: 10,
DEFAULT_RETRY: 5,
_write: function(chunk) {
if (!this.writable) return false;
try {
return this._stream.write(chunk, 'utf8');
} catch (e) {
return false;
}
},
_open: function() {
if (this.readyState !== API.CONNECTING) return;
this.readyState = API.OPEN;
var event = new Event('open');
event.initEvent('open', false, false);
this.dispatchEvent(event);
},
write: function(message) {
return this.send(message);
},
end: function(message) {
if (message !== undefined) this.write(message);
this.close();
},
send: function(message, options) {
if (this.readyState > API.OPEN) return false;
message = String(message).replace(/(\r\n|\r|\n)/g, '$1data: ');
options = options || {};
var frame = '';
if (options.event) frame += 'event: ' + options.event + '\r\n';
if (options.id) frame += 'id: ' + options.id + '\r\n';
frame += 'data: ' + message + '\r\n\r\n';
return this._write(frame);
},
ping: function() {
return this._write(':\r\n\r\n');
},
close: function() {
if (this.readyState > API.OPEN) return false;
this.readyState = API.CLOSED;
this.writable = false;
if (this._pingTimer) clearInterval(this._pingTimer);
if (this._stream) this._stream.end();
var event = new Event('close');
event.initEvent('close', false, false);
this.dispatchEvent(event);
return true;
}
};
for (var method in instance) EventSource.prototype[method] = instance[method];
for (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];
module.exports = EventSource;
/***/ },
/***/ 555
(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
// API references:
//
// * https://html.spec.whatwg.org/multipage/comms.html#network
// * https://dom.spec.whatwg.org/#interface-eventtarget
// * https://dom.spec.whatwg.org/#interface-event
var util = __webpack_require__(23),
driver = __webpack_require__(41),
API = __webpack_require__(720);
var WebSocket = function(request, socket, body, protocols, options) {
options = options || {};
this._stream = socket;
this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});
var self = this;
if (!this._stream || !this._stream.writable) return;
if (!this._stream.readable) return this._stream.end();
var catchup = function() { self._stream.removeListener('data', catchup) };
this._stream.on('data', catchup);
API.call(this, options);
process.nextTick(function() {
self._driver.start();
self._driver.io.write(body);
});
};
util.inherits(WebSocket, API);
WebSocket.isWebSocket = function(request) {
return driver.isWebSocket(request);
};
WebSocket.validateOptions = function(options, validKeys) {
driver.validateOptions(options, validKeys);
};
WebSocket.WebSocket = WebSocket;
WebSocket.Client = __webpack_require__(333);
WebSocket.EventSource = __webpack_require__(945);
module.exports = WebSocket;
/***/ },
/***/ 720
(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Stream = (__webpack_require__(203).Stream),
util = __webpack_require__(23),
driver = __webpack_require__(41),
EventTarget = __webpack_require__(667),
Event = __webpack_require__(859);
var API = function(options) {
options = options || {};
driver.validateOptions(options, ['headers', 'extensions', 'maxLength', 'ping', 'proxy', 'tls', 'ca']);
this.readable = this.writable = true;
var headers = options.headers;
if (headers) {
for (var name in headers) this._driver.setHeader(name, headers[name]);
}
var extensions = options.extensions;
if (extensions) {
[].concat(extensions).forEach(this._driver.addExtension, this._driver);
}
this._ping = options.ping;
this._pingId = 0;
this.readyState = API.CONNECTING;
this.bufferedAmount = 0;
this.protocol = '';
this.url = this._driver.url;
this.version = this._driver.version;
var self = this;
this._driver.on('open', function(e) { self._open() });
this._driver.on('message', function(e) { self._receiveMessage(e.data) });
this._driver.on('close', function(e) { self._beginClose(e.reason, e.code) });
this._driver.on('error', function(error) {
self._emitError(error.message);
});
this.on('error', function() {});
this._driver.messages.on('drain', function() {
self.emit('drain');
});
if (this._ping)
this._pingTimer = setInterval(function() {
self._pingId += 1;
self.ping(self._pingId.toString());
}, this._ping * 1000);
this._configureStream();
if (!this._proxy) {
this._stream.pipe(this._driver.io);
this._driver.io.pipe(this._stream);
}
};
util.inherits(API, Stream);
API.CONNECTING = 0;
API.OPEN = 1;
API.CLOSING = 2;
API.CLOSED = 3;
API.CLOSE_TIMEOUT = 30000;
var instance = {
write: function(data) {
return this.send(data);
},
end: function(data) {
if (data !== undefined) this.send(data);
this.close();
},
pause: function() {
return this._driver.messages.pause();
},
resume: function() {
return this._driver.messages.resume();
},
send: function(data) {
if (this.readyState > API.OPEN) return false;
if (!(data instanceof Buffer)) data = String(data);
return this._driver.messages.write(data);
},
ping: function(message, callback) {
if (this.readyState > API.OPEN) return false;
return this._driver.ping(message, callback);
},
close: function(code, reason) {
if (code === undefined) code = 1000;
if (reason === undefined) reason = '';
if (code !== 1000 && (code < 3000 || code > 4999))
throw new Error("Failed to execute 'close' on WebSocket: " +
"The code must be either 1000, or between 3000 and 4999. " +
code + " is neither.");
if (this.readyState !== API.CLOSED) this.readyState = API.CLOSING;
var self = this;
this._closeTimer = setTimeout(function() {
self._beginClose('', 1006);
}, API.CLOSE_TIMEOUT);
this._driver.close(reason, code);
},
_configureStream: function() {
var self = this;
this._stream.setTimeout(0);
this._stream.setNoDelay(true);
['close', 'end'].forEach(function(event) {
this._stream.on(event, function() { self._finalizeClose() });
}, this);
this._stream.on('error', function(error) {
self._emitError('Network error: ' + self.url + ': ' + error.message);
self._finalizeClose();
});
},
_open: function() {
if (this.readyState !== API.CONNECTING) return;
this.readyState = API.OPEN;
this.protocol = this._driver.protocol || '';
var event = new Event('open');
event.initEvent('open', false, false);
this.dispatchEvent(event);
},
_receiveMessage: function(data) {
if (this.readyState > API.OPEN) return false;
if (this.readable) this.emit('data', data);
var event = new Event('message', {data: data});
event.initEvent('message', false, false);
this.dispatchEvent(event);
},
_emitError: function(message) {
if (this.readyState >= API.CLOSING) return;
var event = new Event('error', {message: message});
event.initEvent('error', false, false);
this.dispatchEvent(event);
},
_beginClose: function(reason, code) {
if (this.readyState === API.CLOSED) return;
this.readyState = API.CLOSING;
this._closeParams = [reason, code];
if (this._stream) {
this._stream.destroy();
if (!this._stream.readable) this._finalizeClose();
}
},
_finalizeClose: function() {
if (this.readyState === API.CLOSED) return;
this.readyState = API.CLOSED;
if (this._closeTimer) clearTimeout(this._closeTimer);
if (this._pingTimer) clearInterval(this._pingTimer);
if (this._stream) this._stream.end();
if (this.readable) this.emit('end');
this.readable = this.writable = false;
var reason = this._closeParams ? this._closeParams[0] : '',
code = this._closeParams ? this._closeParams[1] : 1006;
var event = new Event('close', {code: code, reason: reason});
event.initEvent('close', false, false);
this.dispatchEvent(event);
}
};
for (var method in instance) API.prototype[method] = instance[method];
for (var key in EventTarget) API.prototype[key] = EventTarget[key];
module.exports = API;
/***/ },
/***/ 859
(module) {
"use strict";
var Event = function(eventType, options) {
this.type = eventType;
for (var key in options)
this[key] = options[key];
};
Event.prototype.initEvent = function(eventType, canBubble, cancelable) {
this.type = eventType;
this.bubbles = canBubble;
this.cancelable = cancelable;
};
Event.prototype.stopPropagation = function() {};
Event.prototype.preventDefault = function() {};
Event.CAPTURING_PHASE = 1;
Event.AT_TARGET = 2;
Event.BUBBLING_PHASE = 3;
module.exports = Event;
/***/ },
/***/ 667
(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Event = __webpack_require__(859);
var EventTarget = {
onopen: null,
onmessage: null,
onerror: null,
onclose: null,
addEventListener: function(eventType, listener, useCapture) {
this.on(eventType, listener);
},
removeEventListener: function(eventType, listener, useCapture) {
this.removeListener(eventType, listener);
},
dispatchEvent: function(event) {
event.target = event.currentTarget = this;
event.eventPhase = Event.AT_TARGET;
if (this['on' + event.type])
this['on' + event.type](event);
this.emit(event.type, event);
}
};
module.exports = EventTarget;
/***/ },
/***/ 333
(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var util = __webpack_require__(23),
net = __webpack_require__(278),
tls = __webpack_require__(756),
url = __webpack_require__(16),
driver = __webpack_require__(41),
API = __webpack_require__(720),
Event = __webpack_require__(859);
var DEFAULT_PORTS = {'http:': 80, 'https:': 443, 'ws:':80, 'wss:': 443},
SECURE_PROTOCOLS = ['https:', 'wss:'];
var Client = function(_url, protocols, options) {
options = options || {};
this.url = _url;
this._driver = driver.client(this.url, {maxLength: options.maxLength, protocols: protocols});
['open', 'error'].forEach(function(event) {
this._driver.on(event, function() {
self.headers = self._driver.headers;
self.statusCode = self._driver.statusCode;
});
}, this);
var proxy = options.proxy || {},
endpoint = url.parse(proxy.origin || this.url),
port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],
secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,
onConnect = function() { self._onConnect() },
netOptions = options.net || {},
originTLS = options.tls || {},
socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,
self = this;
netOptions.host = socketTLS.host = endpoint.hostname;
netOptions.port = socketTLS.port = port;
originTLS.ca = originTLS.ca || options.ca;
socketTLS.servername = socketTLS.servername || endpoint.hostname;
this._stream = secure
? tls.connect(socketTLS, onConnect)
: net.connect(netOptions, onConnect);
if (proxy.origin) this._configureProxy(proxy, originTLS);
API.call(this, options);
};
util.inherits(Client, API);
Client.prototype._onConnect = function() {
var worker = this._proxy || this._driver;
worker.start();
};
Client.prototype._configureProxy = function(proxy, originTLS) {
var uri = url.parse(this.url),
secure = SECURE_PROTOCOLS.indexOf(uri.protocol) >= 0,
self = this,
name;
this._proxy = this._driver.proxy(proxy.origin);
if (proxy.headers) {
for (name in proxy.headers) this._proxy.setHeader(name, proxy.headers[name]);
}
this._proxy.pipe(this._stream, {end: false});
this._stream.pipe(this._proxy);
this._proxy.on('connect', function() {
if (secure) {
var options = {socket: self._stream, servername: uri.hostname};
for (name in originTLS) options[name] = originTLS[name];
self._stream = tls.connect(options);
self._configureStream();
}
self._driver.io.pipe(self._stream);
self._stream.pipe(self._driver.io);
self._driver.start();
});
this._proxy.on('error', function(error) {
self._driver.emit('error', error);
});
};
module.exports = Client;
/***/ },
/***/ 895
(__unused_webpack_module, exports, __webpack_require__) {
var __webpack_unused_export__;
/*jshint node:true */
var assert = __webpack_require__(613);
exports.e = HTTPParser;
function HTTPParser(type) {
assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);
if (type === undefined) {
// Node v12+
} else {
this.initialize(type);
}
this.maxHeaderSize=HTTPParser.maxHeaderSize
}
HTTPParser.prototype.initialize = function (type, async_resource) {
assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);
this.type = type;
this.state = type + '_LINE';
this.info = {
headers: [],
upgrade: false
};
this.trailers = [];
this.line = '';
this.isChunked = false;
this.connection = '';
this.headerSize = 0; // for preventing too big headers
this.body_bytes = null;
this.isUserCall = false;
this.hadError = false;
};
HTTPParser.encoding = 'ascii';
HTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;
HTTPParser.REQUEST = 'REQUEST';
HTTPParser.RESPONSE = 'RESPONSE';
// Note: *not* starting with kOnHeaders=0 line the Node parser, because any
// newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0!
var kOnHeaders = HTTPParser.kOnHeaders = 1;
var kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2;
var kOnBody = HTTPParser.kOnBody = 3;
var kOnMessageComplete = HTTPParser.kOnMessageComplete = 4;
// Some handler stubs, needed for compatibility
HTTPParser.prototype[kOnHeaders] =
HTTPParser.prototype[kOnHeadersComplete] =
HTTPParser.prototype[kOnBody] =
HTTPParser.prototype[kOnMessageComplete] = function () {};
var compatMode0_12 = true;
Object.defineProperty(HTTPParser, 'kOnExecute', {
get: function () {
// hack for backward compatibility
compatMode0_12 = false;
return 99;
}
});
var methods = __webpack_unused_export__ = HTTPParser.methods = [
'DELETE',
'GET',
'HEAD',
'POST',
'PUT',
'CONNECT',
'OPTIONS',
'TRACE',
'COPY',
'LOCK',
'MKCOL',
'MOVE',
'PROPFIND',
'PROPPATCH',
'SEARCH',
'UNLOCK',
'BIND',
'REBIND',
'UNBIND',
'ACL',
'REPORT',
'MKACTIVITY',
'CHECKOUT',
'MERGE',
'M-SEARCH',
'NOTIFY',
'SUBSCRIBE',
'UNSUBSCRIBE',
'PATCH',
'PURGE',
'MKCALENDAR',
'LINK',
'UNLINK',
'SOURCE',
];
var method_connect = methods.indexOf('CONNECT');
HTTPParser.prototype.reinitialize = HTTPParser;
HTTPParser.prototype.close =
HTTPParser.prototype.pause =
HTTPParser.prototype.resume =
HTTPParser.prototype.free = function () {};
HTTPParser.prototype._compatMode0_11 = false;
HTTPParser.prototype.getAsyncId = function() { return 0; };
var headerState = {
REQUEST_LINE: true,
RESPONSE_LINE: true,
HEADER: true
};
HTTPParser.prototype.execute = function (chunk, start, length) {
if (!(this instanceof HTTPParser)) {
throw new TypeError('not a HTTPParser');
}
// backward compat to node < 0.11.4
// Note: the start and length params were removed in newer version
start = start || 0;
length = typeof length === 'number' ? length : chunk.length;
this.chunk = chunk;
this.offset = start;
var end = this.end = start + length;
try {
while (this.offset < end) {
if (this[this.state]()) {
break;
}
}
} catch (err) {
if (this.isUserCall) {
throw err;
}
this.hadError = true;
return err;
}
this.chunk = null;
length = this.offset - start;
if (headerState[this.state]) {
this.headerSize += length;
if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {
return new Error('max header size exceeded');
}
}
return length;
};
var stateFinishAllowed = {
REQUEST_LINE: true,
RESPONSE_LINE: true,
BODY_RAW: true
};
HTTPParser.prototype.finish = function () {
if (this.hadError) {
return;
}
if (!stateFinishAllowed[this.state]) {
return new Error('invalid state for EOF');
}
if (this.state === 'BODY_RAW') {
this.userCall()(this[kOnMessageComplete]());
}
};
// These three methods are used for an internal speed optimization, and it also
// works if theses are noops. Basically consume() asks us to read the bytes
// ourselves, but if we don't do it we get them through execute().
HTTPParser.prototype.consume =
HTTPParser.prototype.unconsume =
HTTPParser.prototype.getCurrentBuffer = function () {};
//For correct error handling - see HTTPParser#execute
//Usage: this.userCall()(userFunction('arg'));
HTTPParser.prototype.userCall = function () {
this.isUserCall = true;
var self = this;
return function (ret) {
self.isUserCall = false;
return ret;
};
};
HTTPParser.prototype.nextRequest = function () {
this.userCall()(this[kOnMessageComplete]());
this.reinitialize(this.type);
};
HTTPParser.prototype.consumeLine = function () {
var end = this.end,
chunk = this.chunk;
for (var i = this.offset; i < end; i++) {
if (chunk[i] === 0x0a) { // \n
var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i);
if (line.charAt(line.length - 1) === '\r') {
line = line.substr(0, line.length - 1);
}
this.line = '';
this.offset = i + 1;
return line;
}
}
//line split over multiple chunks
this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end);
this.offset = this.end;
};
var headerExp = /^([^: \t]+):[ \t]*((?:.*[^ \t])|)/;
var headerContinueExp = /^[ \t]+(.*[^ \t])/;
HTTPParser.prototype.parseHeader = function (line, headers) {
if (line.indexOf('\r') !== -1) {
throw parseErrorCode('HPE_LF_EXPECTED');
}
var match = headerExp.exec(line);
var k = match && match[1];
if (k) { // skip empty string (malformed header)
headers.push(k);
headers.push(match[2]);
} else {
var matchContinue = headerContinueExp.exec(line);
if (matchContinue && headers.length) {
if (headers[headers.length - 1]) {
headers[headers.length - 1] += ' ';
}
headers[headers.length - 1] += matchContinue[1];
}
}
};
var requestExp = /^([A-Z-]+) ([^ ]+) HTTP\/(\d)\.(\d)$/;
HTTPParser.prototype.REQUEST_LINE = function () {
var line = this.consumeLine();
if (!line) {
return;
}
var match = requestExp.exec(line);
if (match === null) {
throw parseErrorCode('HPE_INVALID_CONSTANT');
}
this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]);
if (this.info.method === -1) {
throw new Error('invalid request method');
}
this.info.url = match[2];
this.info.versionMajor = +match[3];
this.info.versionMinor = +match[4];
this.body_bytes = 0;
this.state = 'HEADER';
};
var responseExp = /^HTTP\/(\d)\.(\d) (\d{3}) ?(.*)$/;
HTTPParser.prototype.RESPONSE_LINE = function () {
var line = this.consumeLine();
if (!line) {
return;
}
var match = responseExp.exec(line);
if (match === null) {
throw parseErrorCode('HPE_INVALID_CONSTANT');
}
this.info.versionMajor = +match[1];
this.info.versionMinor = +match[2];
var statusCode = this.info.statusCode = +match[3];
this.info.statusMessage = match[4];
// Implied zero length.
if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) {
this.body_bytes = 0;
}
this.state = 'HEADER';
};
HTTPParser.prototype.shouldKeepAlive = function () {
if (this.info.versionMajor > 0 && this.info.versionMinor > 0) {
if (this.connection.indexOf('close') !== -1) {
return false;
}
} else if (this.connection.indexOf('keep-alive') === -1) {
return false;
}
if (this.body_bytes !== null || this.isChunked) { // || skipBody
return true;
}
return false;
};
HTTPParser.prototype.HEADER = function () {
var line = this.consumeLine();
if (line === undefined) {
return;
}
var info = this.info;
if (line) {
this.parseHeader(line, info.headers);
} else {
var headers = info.headers;
var hasContentLength = false;
var currentContentLengthValue;
var hasUpgradeHeader = false;
for (var i = 0; i < headers.length; i += 2) {
switch (headers[i].toLowerCase()) {
case 'transfer-encoding':
this.isChunked = headers[i + 1].toLowerCase() === 'chunked';
break;
case 'content-length':
currentContentLengthValue = +headers[i + 1];
if (hasContentLength) {
// Fix duplicate Content-Length header with same values.
// Throw error only if values are different.
// Known issues:
// https://github.com/request/request/issues/2091#issuecomment-328715113
// https://github.com/nodejs/node/issues/6517#issuecomment-216263771
if (currentContentLengthValue !== this.body_bytes) {
throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH');
}
} else {
hasContentLength = true;
this.body_bytes = currentContentLengthValue;
}
break;
case 'connection':
this.connection += headers[i + 1].toLowerCase();
break;
case 'upgrade':
hasUpgradeHeader = true;
break;
}
}
// if both isChunked and hasContentLength, isChunked wins
// This is required so the body is parsed using the chunked method, and matches
// Chrome's behavior. We could, maybe, ignore them both (would get chunked
// encoding into the body), and/or disable shouldKeepAlive to be more
// resilient.
if (this.isChunked && hasContentLength) {
hasContentLength = false;
this.body_bytes = null;
}
// Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737
// "For responses, "Upgrade: foo" and "Connection: upgrade" are
// mandatory only when it is a 101 Switching Protocols response,
// otherwise it is purely informational, to announce support.
if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) {
info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101;
} else {
info.upgrade = info.method === method_connect;
}
if (this.isChunked && info.upgrade) {
this.isChunked = false;
}
info.shouldKeepAlive = this.shouldKeepAlive();
//problem which also exists in original node: we should know skipBody before calling onHeadersComplete
var skipBody;
if (compatMode0_12) {
skipBody = this.userCall()(this[kOnHeadersComplete](info));
} else {
skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor,
info.versionMinor, info.headers, info.method, info.url, info.statusCode,
info.statusMessage, info.upgrade, info.shouldKeepAlive));
}
if (skipBody === 2) {
this.nextRequest();
return true;
} else if (this.isChunked && !skipBody) {
this.state = 'BODY_CHUNKHEAD';
} else if (skipBody || this.body_bytes === 0) {
this.nextRequest();
// For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true,
// need this "return true;" if it's an upgrade request.
return info.upgrade;
} else if (this.body_bytes === null) {
this.state = 'BODY_RAW';
} else {
this.state = 'BODY_SIZED';
}
}
};
HTTPParser.prototype.BODY_CHUNKHEAD = function () {
var line = this.consumeLine();
if (line === undefined) {
return;
}
this.body_bytes = parseInt(line, 16);
if (!this.body_bytes) {
this.state = 'BODY_CHUNKTRAILERS';
} else {
this.state = 'BODY_CHUNK';
}
};
HTTPParser.prototype.BODY_CHUNK = function () {
var length = Math.min(this.end - this.offset, this.body_bytes);
this.userCall()(this[kOnBody](this.chunk, this.offset, length));
this.offset += length;
this.body_bytes -= length;
if (!this.body_bytes) {
this.state = 'BODY_CHUNKEMPTYLINE';
}
};
HTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {
var line = this.consumeLine();
if (line === undefined) {
return;
}
assert.equal(line, '');
this.state = 'BODY_CHUNKHEAD';
};
HTTPParser.prototype.BODY_CHUNKTRAILERS = function () {
var line = this.consumeLine();
if (line === undefined) {
return;
}
if (line) {
this.parseHeader(line, this.trailers);
} else {
if (this.trailers.length) {
this.userCall()(this[kOnHeaders](this.trailers, ''));
}
this.nextRequest();
}
};
HTTPParser.prototype.BODY_RAW = function () {
var length = this.end - this.offset;
this.userCall()(this[kOnBody](this.chunk, this.offset, length));
this.offset = this.end;
};
HTTPParser.prototype.BODY_SIZED = function () {
var length = Math.min(this.end - this.offset, this.body_bytes);
this.userCall()(this[kOnBody](this.chunk, this.offset, length));
this.offset += length;
this.body_bytes -= length;
if (!this.body_bytes) {
this.nextRequest();
}
};
// backward compat to node < 0.11.6
['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) {
var k = HTTPParser['kOn' + name];
Object.defineProperty(HTTPParser.prototype, 'on' + name, {
get: function () {
return this[k];
},
set: function (to) {
// hack for backward compatibility
this._compatMode0_11 = true;
method_connect = 'CONNECT';
return (this[k] = to);
}
});
});
function parseErrorCode(code) {
var err = new Error('Parse Error');
err.code = code;
return err;
}
/***/ },
/***/ 891
(module, exports, __webpack_require__) {
/* eslint-disable node/no-deprecated-api */
var buffer = __webpack_require__(181)
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)
}
/***/ },
/***/ 601
(module, __unused_webpack_exports, __webpack_require__) {
(function(nacl) {
'use strict';
// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
// Public domain.
//
// Implementation derived from TweetNaCl version 20140427.
// See for details: http://tweetnacl.cr.yp.to/
var gf = function(init) {
var i, r = new Float64Array(16);
if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
return r;
};
// Pluggable, initialized in high-level API below.
var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
var _0 = new Uint8Array(16);
var _9 = new Uint8Array(32); _9[0] = 9;
var gf0 = gf(),
gf1 = gf([1]),
_121665 = gf([0xdb41, 1]),
D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
function ts64(x, i, h, l) {
x[i] = (h >> 24) & 0xff;
x[i+1] = (h >> 16) & 0xff;
x[i+2] = (h >> 8) & 0xff;
x[i+3] = h & 0xff;
x[i+4] = (l >> 24) & 0xff;
x[i+5] = (l >> 16) & 0xff;
x[i+6] = (l >> 8) & 0xff;
x[i+7] = l & 0xff;
}
function vn(x, xi, y, yi, n) {
var i,d = 0;
for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
return (1 & ((d - 1) >>> 8)) - 1;
}
function crypto_verify_16(x, xi, y, yi) {
return vn(x,xi,y,yi,16);
}
function crypto_verify_32(x, xi, y, yi) {
return vn(x,xi,y,yi,32);
}
function core_salsa20(o, p, k, c) {
var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
x15 = j15, u;
for (var i = 0; i < 20; i += 2) {
u = x0 + x12 | 0;
x4 ^= u<<7 | u>>>(32-7);
u = x4 + x0 | 0;
x8 ^= u<<9 | u>>>(32-9);
u = x8 + x4 | 0;
x12 ^= u<<13 | u>>>(32-13);
u = x12 + x8 | 0;
x0 ^= u<<18 | u>>>(32-18);
u = x5 + x1 | 0;
x9 ^= u<<7 | u>>>(32-7);
u = x9 + x5 | 0;
x13 ^= u<<9 | u>>>(32-9);
u = x13 + x9 | 0;
x1 ^= u<<13 | u>>>(32-13);
u = x1 + x13 | 0;
x5 ^= u<<18 | u>>>(32-18);
u = x10 + x6 | 0;
x14 ^= u<<7 | u>>>(32-7);
u = x14 + x10 | 0;
x2 ^= u<<9 | u>>>(32-9);
u = x2 + x14 | 0;
x6 ^= u<<13 |