jsflow-sdk 0.0.3 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -0
- package/LICENSE +101 -0
- package/README.md +29 -4
- package/jsflow.d.ts +297 -0
- package/jsflow.js +610 -0
- package/package.json +30 -36
- package/sri.json +6 -0
- package/worker.js +2567 -0
- package/.npmignore +0 -3
- package/index.html +0 -7
- package/lib/auth.js +0 -32
- package/lib/config.js +0 -4
- package/lib/connect.js +0 -13
- package/lib/jsflow.js +0 -48
- package/lib/log.js +0 -43
- package/lib/main.js +0 -52
- package/lib/token.js +0 -34
- package/lib/ws.js +0 -1
- package/lib/xmlhttprequest.js +0 -1
- package/logTest.js +0 -49
- package/plan.txt +0 -60
- package/src/main.js +0 -43
- package/src/main_ws.js +0 -81
- package/ssl/GandiStandardSSLCA.pem +0 -27
- package/test.js +0 -18
- package/web.js +0 -8295
- package/web2.js +0 -1297
- package/web3.js +0 -6984
- package/web4.js +0 -11488
- package/web5.js +0 -28222
- package/web_min.js.gz +0 -0
package/web2.js
DELETED
|
@@ -1,1297 +0,0 @@
|
|
|
1
|
-
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var bops = require('bops');
|
|
5
|
-
|
|
6
|
-
exports.encode = function (value) {
|
|
7
|
-
var toJSONed = []
|
|
8
|
-
var size = sizeof(value)
|
|
9
|
-
if(size == 0)
|
|
10
|
-
return undefined
|
|
11
|
-
var buffer = bops.create(size);
|
|
12
|
-
encode(value, buffer, 0);
|
|
13
|
-
return buffer;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.decode = decode;
|
|
17
|
-
|
|
18
|
-
// http://wiki.msgpack.org/display/MSGPACK/Format+specification
|
|
19
|
-
// I've extended the protocol to have two new types that were previously reserved.
|
|
20
|
-
// buffer 16 11011000 0xd8
|
|
21
|
-
// buffer 32 11011001 0xd9
|
|
22
|
-
// These work just like raw16 and raw32 except they are node buffers instead of strings.
|
|
23
|
-
//
|
|
24
|
-
// Also I've added a type for `undefined`
|
|
25
|
-
// undefined 11000100 0xc4
|
|
26
|
-
|
|
27
|
-
function Decoder(buffer, offset) {
|
|
28
|
-
this.offset = offset || 0;
|
|
29
|
-
this.buffer = buffer;
|
|
30
|
-
}
|
|
31
|
-
Decoder.prototype.map = function (length) {
|
|
32
|
-
var value = {};
|
|
33
|
-
for (var i = 0; i < length; i++) {
|
|
34
|
-
var key = this.parse();
|
|
35
|
-
value[key] = this.parse();
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
};
|
|
39
|
-
Decoder.prototype.buf = function (length) {
|
|
40
|
-
var value = bops.subarray(this.buffer, this.offset, this.offset + length);
|
|
41
|
-
this.offset += length;
|
|
42
|
-
return value;
|
|
43
|
-
};
|
|
44
|
-
Decoder.prototype.raw = function (length) {
|
|
45
|
-
var value = bops.to(bops.subarray(this.buffer, this.offset, this.offset + length));
|
|
46
|
-
this.offset += length;
|
|
47
|
-
return value;
|
|
48
|
-
};
|
|
49
|
-
Decoder.prototype.array = function (length) {
|
|
50
|
-
var value = new Array(length);
|
|
51
|
-
for (var i = 0; i < length; i++) {
|
|
52
|
-
value[i] = this.parse();
|
|
53
|
-
}
|
|
54
|
-
return value;
|
|
55
|
-
};
|
|
56
|
-
Decoder.prototype.parse = function () {
|
|
57
|
-
var type = this.buffer[this.offset];
|
|
58
|
-
var value, length;
|
|
59
|
-
// FixRaw
|
|
60
|
-
if ((type & 0xe0) === 0xa0) {
|
|
61
|
-
length = type & 0x1f;
|
|
62
|
-
this.offset++;
|
|
63
|
-
return this.raw(length);
|
|
64
|
-
}
|
|
65
|
-
// FixMap
|
|
66
|
-
if ((type & 0xf0) === 0x80) {
|
|
67
|
-
length = type & 0x0f;
|
|
68
|
-
this.offset++;
|
|
69
|
-
return this.map(length);
|
|
70
|
-
}
|
|
71
|
-
// FixArray
|
|
72
|
-
if ((type & 0xf0) === 0x90) {
|
|
73
|
-
length = type & 0x0f;
|
|
74
|
-
this.offset++;
|
|
75
|
-
return this.array(length);
|
|
76
|
-
}
|
|
77
|
-
// Positive FixNum
|
|
78
|
-
if ((type & 0x80) === 0x00) {
|
|
79
|
-
this.offset++;
|
|
80
|
-
return type;
|
|
81
|
-
}
|
|
82
|
-
// Negative Fixnum
|
|
83
|
-
if ((type & 0xe0) === 0xe0) {
|
|
84
|
-
value = bops.readInt8(this.buffer, this.offset);
|
|
85
|
-
this.offset++;
|
|
86
|
-
return value;
|
|
87
|
-
}
|
|
88
|
-
switch (type) {
|
|
89
|
-
// raw 16
|
|
90
|
-
case 0xda:
|
|
91
|
-
length = bops.readUInt16BE(this.buffer, this.offset + 1);
|
|
92
|
-
this.offset += 3;
|
|
93
|
-
return this.raw(length);
|
|
94
|
-
// raw 32
|
|
95
|
-
case 0xdb:
|
|
96
|
-
length = bops.readUInt32BE(this.buffer, this.offset + 1);
|
|
97
|
-
this.offset += 5;
|
|
98
|
-
return this.raw(length);
|
|
99
|
-
// nil
|
|
100
|
-
case 0xc0:
|
|
101
|
-
this.offset++;
|
|
102
|
-
return null;
|
|
103
|
-
// false
|
|
104
|
-
case 0xc2:
|
|
105
|
-
this.offset++;
|
|
106
|
-
return false;
|
|
107
|
-
// true
|
|
108
|
-
case 0xc3:
|
|
109
|
-
this.offset++;
|
|
110
|
-
return true;
|
|
111
|
-
// undefined
|
|
112
|
-
case 0xc4:
|
|
113
|
-
this.offset++;
|
|
114
|
-
return undefined;
|
|
115
|
-
// uint8
|
|
116
|
-
case 0xcc:
|
|
117
|
-
value = this.buffer[this.offset + 1];
|
|
118
|
-
this.offset += 2;
|
|
119
|
-
return value;
|
|
120
|
-
// uint 16
|
|
121
|
-
case 0xcd:
|
|
122
|
-
value = bops.readUInt16BE(this.buffer, this.offset + 1);
|
|
123
|
-
this.offset += 3;
|
|
124
|
-
return value;
|
|
125
|
-
// uint 32
|
|
126
|
-
case 0xce:
|
|
127
|
-
value = bops.readUInt32BE(this.buffer, this.offset + 1);
|
|
128
|
-
this.offset += 5;
|
|
129
|
-
return value;
|
|
130
|
-
// uint64
|
|
131
|
-
case 0xcf:
|
|
132
|
-
value = bops.readUInt64BE(this.buffer, this.offset + 1);
|
|
133
|
-
this.offset += 9;
|
|
134
|
-
return value;
|
|
135
|
-
// int 8
|
|
136
|
-
case 0xd0:
|
|
137
|
-
value = bops.readInt8(this.buffer, this.offset + 1);
|
|
138
|
-
this.offset += 2;
|
|
139
|
-
return value;
|
|
140
|
-
// int 16
|
|
141
|
-
case 0xd1:
|
|
142
|
-
value = bops.readInt16BE(this.buffer, this.offset + 1);
|
|
143
|
-
this.offset += 3;
|
|
144
|
-
return value;
|
|
145
|
-
// int 32
|
|
146
|
-
case 0xd2:
|
|
147
|
-
value = bops.readInt32BE(this.buffer, this.offset + 1);
|
|
148
|
-
this.offset += 5;
|
|
149
|
-
return value;
|
|
150
|
-
// int 64
|
|
151
|
-
case 0xd3:
|
|
152
|
-
value = bops.readInt64BE(this.buffer, this.offset + 1);
|
|
153
|
-
this.offset += 9;
|
|
154
|
-
return value;
|
|
155
|
-
// map 16
|
|
156
|
-
case 0xde:
|
|
157
|
-
length = bops.readUInt16BE(this.buffer, this.offset + 1);
|
|
158
|
-
this.offset += 3;
|
|
159
|
-
return this.map(length);
|
|
160
|
-
// map 32
|
|
161
|
-
case 0xdf:
|
|
162
|
-
length = bops.readUInt32BE(this.buffer, this.offset + 1);
|
|
163
|
-
this.offset += 5;
|
|
164
|
-
return this.map(length);
|
|
165
|
-
// array 16
|
|
166
|
-
case 0xdc:
|
|
167
|
-
length = bops.readUInt16BE(this.buffer, this.offset + 1);
|
|
168
|
-
this.offset += 3;
|
|
169
|
-
return this.array(length);
|
|
170
|
-
// array 32
|
|
171
|
-
case 0xdd:
|
|
172
|
-
length = bops.readUInt32BE(this.buffer, this.offset + 1);
|
|
173
|
-
this.offset += 5;
|
|
174
|
-
return this.array(length);
|
|
175
|
-
// buffer 16
|
|
176
|
-
case 0xd8:
|
|
177
|
-
length = bops.readUInt16BE(this.buffer, this.offset + 1);
|
|
178
|
-
this.offset += 3;
|
|
179
|
-
return this.buf(length);
|
|
180
|
-
// buffer 32
|
|
181
|
-
case 0xd9:
|
|
182
|
-
length = bops.readUInt32BE(this.buffer, this.offset + 1);
|
|
183
|
-
this.offset += 5;
|
|
184
|
-
return this.buf(length);
|
|
185
|
-
// float
|
|
186
|
-
case 0xca:
|
|
187
|
-
value = bops.readFloatBE(this.buffer, this.offset + 1);
|
|
188
|
-
this.offset += 5;
|
|
189
|
-
return value;
|
|
190
|
-
// double
|
|
191
|
-
case 0xcb:
|
|
192
|
-
value = bops.readDoubleBE(this.buffer, this.offset + 1);
|
|
193
|
-
this.offset += 9;
|
|
194
|
-
return value;
|
|
195
|
-
}
|
|
196
|
-
throw new Error("Unknown type 0x" + type.toString(16));
|
|
197
|
-
};
|
|
198
|
-
function decode(buffer) {
|
|
199
|
-
var decoder = new Decoder(buffer);
|
|
200
|
-
var value = decoder.parse();
|
|
201
|
-
if (decoder.offset !== buffer.length) throw new Error((buffer.length - decoder.offset) + " trailing bytes");
|
|
202
|
-
return value;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function encodeableKeys (value) {
|
|
206
|
-
return Object.keys(value).filter(function (e) {
|
|
207
|
-
return 'function' !== typeof value[e] || !!value[e].toJSON
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function encode(value, buffer, offset) {
|
|
212
|
-
var type = typeof value;
|
|
213
|
-
var length, size;
|
|
214
|
-
|
|
215
|
-
// Strings Bytes
|
|
216
|
-
if (type === "string") {
|
|
217
|
-
value = bops.from(value);
|
|
218
|
-
length = value.length;
|
|
219
|
-
// fix raw
|
|
220
|
-
if (length < 0x20) {
|
|
221
|
-
buffer[offset] = length | 0xa0;
|
|
222
|
-
bops.copy(value, buffer, offset + 1);
|
|
223
|
-
return 1 + length;
|
|
224
|
-
}
|
|
225
|
-
// raw 16
|
|
226
|
-
if (length < 0x10000) {
|
|
227
|
-
buffer[offset] = 0xda;
|
|
228
|
-
bops.writeUInt16BE(buffer, length, offset + 1);
|
|
229
|
-
bops.copy(value, buffer, offset + 3);
|
|
230
|
-
return 3 + length;
|
|
231
|
-
}
|
|
232
|
-
// raw 32
|
|
233
|
-
if (length < 0x100000000) {
|
|
234
|
-
buffer[offset] = 0xdb;
|
|
235
|
-
bops.writeUInt32BE(buffer, length, offset + 1);
|
|
236
|
-
bops.copy(value, buffer, offset + 5);
|
|
237
|
-
return 5 + length;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (bops.is(value)) {
|
|
242
|
-
length = value.length;
|
|
243
|
-
// buffer 16
|
|
244
|
-
if (length < 0x10000) {
|
|
245
|
-
buffer[offset] = 0xd8;
|
|
246
|
-
bops.writeUInt16BE(buffer, length, offset + 1);
|
|
247
|
-
bops.copy(value, buffer, offset + 3);
|
|
248
|
-
return 3 + length;
|
|
249
|
-
}
|
|
250
|
-
// buffer 32
|
|
251
|
-
if (length < 0x100000000) {
|
|
252
|
-
buffer[offset] = 0xd9;
|
|
253
|
-
bops.writeUInt32BE(buffer, length, offset + 1);
|
|
254
|
-
bops.copy(value, buffer, offset + 5);
|
|
255
|
-
return 5 + length;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (type === "number") {
|
|
260
|
-
// Floating Point
|
|
261
|
-
if ((value << 0) !== value) {
|
|
262
|
-
buffer[offset] = 0xcb;
|
|
263
|
-
bops.writeDoubleBE(buffer, value, offset + 1);
|
|
264
|
-
return 9;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Integers
|
|
268
|
-
if (value >=0) {
|
|
269
|
-
// positive fixnum
|
|
270
|
-
if (value < 0x80) {
|
|
271
|
-
buffer[offset] = value;
|
|
272
|
-
return 1;
|
|
273
|
-
}
|
|
274
|
-
// uint 8
|
|
275
|
-
if (value < 0x100) {
|
|
276
|
-
buffer[offset] = 0xcc;
|
|
277
|
-
buffer[offset + 1] = value;
|
|
278
|
-
return 2;
|
|
279
|
-
}
|
|
280
|
-
// uint 16
|
|
281
|
-
if (value < 0x10000) {
|
|
282
|
-
buffer[offset] = 0xcd;
|
|
283
|
-
bops.writeUInt16BE(buffer, value, offset + 1);
|
|
284
|
-
return 3;
|
|
285
|
-
}
|
|
286
|
-
// uint 32
|
|
287
|
-
if (value < 0x100000000) {
|
|
288
|
-
buffer[offset] = 0xce;
|
|
289
|
-
bops.writeUInt32BE(buffer, value, offset + 1);
|
|
290
|
-
return 5;
|
|
291
|
-
}
|
|
292
|
-
// uint 64
|
|
293
|
-
if (value < 0x10000000000000000) {
|
|
294
|
-
buffer[offset] = 0xcf;
|
|
295
|
-
bops.writeUInt64BE(buffer, value, offset + 1);
|
|
296
|
-
return 9;
|
|
297
|
-
}
|
|
298
|
-
throw new Error("Number too big 0x" + value.toString(16));
|
|
299
|
-
}
|
|
300
|
-
// negative fixnum
|
|
301
|
-
if (value >= -0x20) {
|
|
302
|
-
bops.writeInt8(buffer, value, offset);
|
|
303
|
-
return 1;
|
|
304
|
-
}
|
|
305
|
-
// int 8
|
|
306
|
-
if (value >= -0x80) {
|
|
307
|
-
buffer[offset] = 0xd0;
|
|
308
|
-
bops.writeInt8(buffer, value, offset + 1);
|
|
309
|
-
return 2;
|
|
310
|
-
}
|
|
311
|
-
// int 16
|
|
312
|
-
if (value >= -0x8000) {
|
|
313
|
-
buffer[offset] = 0xd1;
|
|
314
|
-
bops.writeInt16BE(buffer, value, offset + 1);
|
|
315
|
-
return 3;
|
|
316
|
-
}
|
|
317
|
-
// int 32
|
|
318
|
-
if (value >= -0x80000000) {
|
|
319
|
-
buffer[offset] = 0xd2;
|
|
320
|
-
bops.writeInt32BE(buffer, value, offset + 1);
|
|
321
|
-
return 5;
|
|
322
|
-
}
|
|
323
|
-
// int 64
|
|
324
|
-
if (value >= -0x8000000000000000) {
|
|
325
|
-
buffer[offset] = 0xd3;
|
|
326
|
-
bops.writeInt64BE(buffer, value, offset + 1);
|
|
327
|
-
return 9;
|
|
328
|
-
}
|
|
329
|
-
throw new Error("Number too small -0x" + value.toString(16).substr(1));
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// undefined
|
|
333
|
-
if (type === "undefined") {
|
|
334
|
-
buffer[offset] = 0xc4;
|
|
335
|
-
return 1;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// null
|
|
339
|
-
if (value === null) {
|
|
340
|
-
buffer[offset] = 0xc0;
|
|
341
|
-
return 1;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// Boolean
|
|
345
|
-
if (type === "boolean") {
|
|
346
|
-
buffer[offset] = value ? 0xc3 : 0xc2;
|
|
347
|
-
return 1;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if('function' === typeof value.toJSON)
|
|
351
|
-
return encode(value.toJSON(), buffer, offset)
|
|
352
|
-
|
|
353
|
-
// Container Types
|
|
354
|
-
if (type === "object") {
|
|
355
|
-
|
|
356
|
-
size = 0;
|
|
357
|
-
var isArray = Array.isArray(value);
|
|
358
|
-
|
|
359
|
-
if (isArray) {
|
|
360
|
-
length = value.length;
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
var keys = encodeableKeys(value)
|
|
364
|
-
length = keys.length;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (length < 0x10) {
|
|
368
|
-
buffer[offset] = length | (isArray ? 0x90 : 0x80);
|
|
369
|
-
size = 1;
|
|
370
|
-
}
|
|
371
|
-
else if (length < 0x10000) {
|
|
372
|
-
buffer[offset] = isArray ? 0xdc : 0xde;
|
|
373
|
-
bops.writeUInt16BE(buffer, length, offset + 1);
|
|
374
|
-
size = 3;
|
|
375
|
-
}
|
|
376
|
-
else if (length < 0x100000000) {
|
|
377
|
-
buffer[offset] = isArray ? 0xdd : 0xdf;
|
|
378
|
-
bops.writeUInt32BE(buffer, length, offset + 1);
|
|
379
|
-
size = 5;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
if (isArray) {
|
|
383
|
-
for (var i = 0; i < length; i++) {
|
|
384
|
-
size += encode(value[i], buffer, offset + size);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
for (var i = 0; i < length; i++) {
|
|
389
|
-
var key = keys[i];
|
|
390
|
-
size += encode(key, buffer, offset + size);
|
|
391
|
-
size += encode(value[key], buffer, offset + size);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return size;
|
|
396
|
-
}
|
|
397
|
-
if(type === "function")
|
|
398
|
-
return undefined
|
|
399
|
-
throw new Error("Unknown type " + type);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function sizeof(value) {
|
|
403
|
-
var type = typeof value;
|
|
404
|
-
var length, size;
|
|
405
|
-
|
|
406
|
-
// Raw Bytes
|
|
407
|
-
if (type === "string") {
|
|
408
|
-
// TODO: this creates a throw-away buffer which is probably expensive on browsers.
|
|
409
|
-
length = bops.from(value).length;
|
|
410
|
-
if (length < 0x20) {
|
|
411
|
-
return 1 + length;
|
|
412
|
-
}
|
|
413
|
-
if (length < 0x10000) {
|
|
414
|
-
return 3 + length;
|
|
415
|
-
}
|
|
416
|
-
if (length < 0x100000000) {
|
|
417
|
-
return 5 + length;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if (bops.is(value)) {
|
|
422
|
-
length = value.length;
|
|
423
|
-
if (length < 0x10000) {
|
|
424
|
-
return 3 + length;
|
|
425
|
-
}
|
|
426
|
-
if (length < 0x100000000) {
|
|
427
|
-
return 5 + length;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (type === "number") {
|
|
432
|
-
// Floating Point
|
|
433
|
-
// double
|
|
434
|
-
if (value << 0 !== value) return 9;
|
|
435
|
-
|
|
436
|
-
// Integers
|
|
437
|
-
if (value >=0) {
|
|
438
|
-
// positive fixnum
|
|
439
|
-
if (value < 0x80) return 1;
|
|
440
|
-
// uint 8
|
|
441
|
-
if (value < 0x100) return 2;
|
|
442
|
-
// uint 16
|
|
443
|
-
if (value < 0x10000) return 3;
|
|
444
|
-
// uint 32
|
|
445
|
-
if (value < 0x100000000) return 5;
|
|
446
|
-
// uint 64
|
|
447
|
-
if (value < 0x10000000000000000) return 9;
|
|
448
|
-
throw new Error("Number too big 0x" + value.toString(16));
|
|
449
|
-
}
|
|
450
|
-
// negative fixnum
|
|
451
|
-
if (value >= -0x20) return 1;
|
|
452
|
-
// int 8
|
|
453
|
-
if (value >= -0x80) return 2;
|
|
454
|
-
// int 16
|
|
455
|
-
if (value >= -0x8000) return 3;
|
|
456
|
-
// int 32
|
|
457
|
-
if (value >= -0x80000000) return 5;
|
|
458
|
-
// int 64
|
|
459
|
-
if (value >= -0x8000000000000000) return 9;
|
|
460
|
-
throw new Error("Number too small -0x" + value.toString(16).substr(1));
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// Boolean, null, undefined
|
|
464
|
-
if (type === "boolean" || type === "undefined" || value === null) return 1;
|
|
465
|
-
|
|
466
|
-
if('function' === typeof value.toJSON)
|
|
467
|
-
return sizeof(value.toJSON())
|
|
468
|
-
|
|
469
|
-
// Container Types
|
|
470
|
-
if (type === "object") {
|
|
471
|
-
if('function' === typeof value.toJSON)
|
|
472
|
-
value = value.toJSON()
|
|
473
|
-
|
|
474
|
-
size = 0;
|
|
475
|
-
if (Array.isArray(value)) {
|
|
476
|
-
length = value.length;
|
|
477
|
-
for (var i = 0; i < length; i++) {
|
|
478
|
-
size += sizeof(value[i]);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
var keys = encodeableKeys(value)
|
|
483
|
-
length = keys.length;
|
|
484
|
-
for (var i = 0; i < length; i++) {
|
|
485
|
-
var key = keys[i];
|
|
486
|
-
size += sizeof(key) + sizeof(value[key]);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
if (length < 0x10) {
|
|
490
|
-
return 1 + size;
|
|
491
|
-
}
|
|
492
|
-
if (length < 0x10000) {
|
|
493
|
-
return 3 + size;
|
|
494
|
-
}
|
|
495
|
-
if (length < 0x100000000) {
|
|
496
|
-
return 5 + size;
|
|
497
|
-
}
|
|
498
|
-
throw new Error("Array or object too long 0x" + length.toString(16));
|
|
499
|
-
}
|
|
500
|
-
if(type === "function")
|
|
501
|
-
return 0
|
|
502
|
-
throw new Error("Unknown type " + type);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
},{"bops":2}],2:[function(require,module,exports){
|
|
508
|
-
var proto = {}
|
|
509
|
-
module.exports = proto
|
|
510
|
-
|
|
511
|
-
proto.from = require('./from.js')
|
|
512
|
-
proto.to = require('./to.js')
|
|
513
|
-
proto.is = require('./is.js')
|
|
514
|
-
proto.subarray = require('./subarray.js')
|
|
515
|
-
proto.join = require('./join.js')
|
|
516
|
-
proto.copy = require('./copy.js')
|
|
517
|
-
proto.create = require('./create.js')
|
|
518
|
-
|
|
519
|
-
mix(require('./read.js'), proto)
|
|
520
|
-
mix(require('./write.js'), proto)
|
|
521
|
-
|
|
522
|
-
function mix(from, into) {
|
|
523
|
-
for(var key in from) {
|
|
524
|
-
into[key] = from[key]
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
},{"./copy.js":5,"./create.js":6,"./from.js":7,"./is.js":8,"./join.js":9,"./read.js":11,"./subarray.js":12,"./to.js":13,"./write.js":14}],3:[function(require,module,exports){
|
|
529
|
-
(function (exports) {
|
|
530
|
-
'use strict';
|
|
531
|
-
|
|
532
|
-
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
533
|
-
|
|
534
|
-
function b64ToByteArray(b64) {
|
|
535
|
-
var i, j, l, tmp, placeHolders, arr;
|
|
536
|
-
|
|
537
|
-
if (b64.length % 4 > 0) {
|
|
538
|
-
throw 'Invalid string. Length must be a multiple of 4';
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// the number of equal signs (place holders)
|
|
542
|
-
// if there are two placeholders, than the two characters before it
|
|
543
|
-
// represent one byte
|
|
544
|
-
// if there is only one, then the three characters before it represent 2 bytes
|
|
545
|
-
// this is just a cheap hack to not do indexOf twice
|
|
546
|
-
placeHolders = b64.indexOf('=');
|
|
547
|
-
placeHolders = placeHolders > 0 ? b64.length - placeHolders : 0;
|
|
548
|
-
|
|
549
|
-
// base64 is 4/3 + up to two characters of the original data
|
|
550
|
-
arr = [];//new Uint8Array(b64.length * 3 / 4 - placeHolders);
|
|
551
|
-
|
|
552
|
-
// if there are placeholders, only get up to the last complete 4 chars
|
|
553
|
-
l = placeHolders > 0 ? b64.length - 4 : b64.length;
|
|
554
|
-
|
|
555
|
-
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
|
556
|
-
tmp = (lookup.indexOf(b64[i]) << 18) | (lookup.indexOf(b64[i + 1]) << 12) | (lookup.indexOf(b64[i + 2]) << 6) | lookup.indexOf(b64[i + 3]);
|
|
557
|
-
arr.push((tmp & 0xFF0000) >> 16);
|
|
558
|
-
arr.push((tmp & 0xFF00) >> 8);
|
|
559
|
-
arr.push(tmp & 0xFF);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
if (placeHolders === 2) {
|
|
563
|
-
tmp = (lookup.indexOf(b64[i]) << 2) | (lookup.indexOf(b64[i + 1]) >> 4);
|
|
564
|
-
arr.push(tmp & 0xFF);
|
|
565
|
-
} else if (placeHolders === 1) {
|
|
566
|
-
tmp = (lookup.indexOf(b64[i]) << 10) | (lookup.indexOf(b64[i + 1]) << 4) | (lookup.indexOf(b64[i + 2]) >> 2);
|
|
567
|
-
arr.push((tmp >> 8) & 0xFF);
|
|
568
|
-
arr.push(tmp & 0xFF);
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
return arr;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
function uint8ToBase64(uint8) {
|
|
575
|
-
var i,
|
|
576
|
-
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
|
577
|
-
output = "",
|
|
578
|
-
temp, length;
|
|
579
|
-
|
|
580
|
-
function tripletToBase64 (num) {
|
|
581
|
-
return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
585
|
-
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
|
586
|
-
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
|
|
587
|
-
output += tripletToBase64(temp);
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
591
|
-
switch (extraBytes) {
|
|
592
|
-
case 1:
|
|
593
|
-
temp = uint8[uint8.length - 1];
|
|
594
|
-
output += lookup[temp >> 2];
|
|
595
|
-
output += lookup[(temp << 4) & 0x3F];
|
|
596
|
-
output += '==';
|
|
597
|
-
break;
|
|
598
|
-
case 2:
|
|
599
|
-
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]);
|
|
600
|
-
output += lookup[temp >> 10];
|
|
601
|
-
output += lookup[(temp >> 4) & 0x3F];
|
|
602
|
-
output += lookup[(temp << 2) & 0x3F];
|
|
603
|
-
output += '=';
|
|
604
|
-
break;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
return output;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
module.exports.toByteArray = b64ToByteArray;
|
|
611
|
-
module.exports.fromByteArray = uint8ToBase64;
|
|
612
|
-
}());
|
|
613
|
-
|
|
614
|
-
},{}],4:[function(require,module,exports){
|
|
615
|
-
module.exports = to_utf8
|
|
616
|
-
|
|
617
|
-
var out = []
|
|
618
|
-
, col = []
|
|
619
|
-
, fcc = String.fromCharCode
|
|
620
|
-
, mask = [0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01]
|
|
621
|
-
, unmask = [
|
|
622
|
-
0x00
|
|
623
|
-
, 0x01
|
|
624
|
-
, 0x02 | 0x01
|
|
625
|
-
, 0x04 | 0x02 | 0x01
|
|
626
|
-
, 0x08 | 0x04 | 0x02 | 0x01
|
|
627
|
-
, 0x10 | 0x08 | 0x04 | 0x02 | 0x01
|
|
628
|
-
, 0x20 | 0x10 | 0x08 | 0x04 | 0x02 | 0x01
|
|
629
|
-
, 0x40 | 0x20 | 0x10 | 0x08 | 0x04 | 0x02 | 0x01
|
|
630
|
-
]
|
|
631
|
-
|
|
632
|
-
function to_utf8(bytes, start, end) {
|
|
633
|
-
start = start === undefined ? 0 : start
|
|
634
|
-
end = end === undefined ? bytes.length : end
|
|
635
|
-
|
|
636
|
-
var idx = 0
|
|
637
|
-
, hi = 0x80
|
|
638
|
-
, collecting = 0
|
|
639
|
-
, pos
|
|
640
|
-
, by
|
|
641
|
-
|
|
642
|
-
col.length =
|
|
643
|
-
out.length = 0
|
|
644
|
-
|
|
645
|
-
while(idx < bytes.length) {
|
|
646
|
-
by = bytes[idx]
|
|
647
|
-
if(!collecting && by & hi) {
|
|
648
|
-
pos = find_pad_position(by)
|
|
649
|
-
collecting += pos
|
|
650
|
-
if(pos < 8) {
|
|
651
|
-
col[col.length] = by & unmask[6 - pos]
|
|
652
|
-
}
|
|
653
|
-
} else if(collecting) {
|
|
654
|
-
col[col.length] = by & unmask[6]
|
|
655
|
-
--collecting
|
|
656
|
-
if(!collecting && col.length) {
|
|
657
|
-
out[out.length] = fcc(reduced(col, pos))
|
|
658
|
-
col.length = 0
|
|
659
|
-
}
|
|
660
|
-
} else {
|
|
661
|
-
out[out.length] = fcc(by)
|
|
662
|
-
}
|
|
663
|
-
++idx
|
|
664
|
-
}
|
|
665
|
-
if(col.length && !collecting) {
|
|
666
|
-
out[out.length] = fcc(reduced(col, pos))
|
|
667
|
-
col.length = 0
|
|
668
|
-
}
|
|
669
|
-
return out.join('')
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
function find_pad_position(byt) {
|
|
673
|
-
for(var i = 0; i < 7; ++i) {
|
|
674
|
-
if(!(byt & mask[i])) {
|
|
675
|
-
break
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
return i
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
function reduced(list) {
|
|
682
|
-
var out = 0
|
|
683
|
-
for(var i = 0, len = list.length; i < len; ++i) {
|
|
684
|
-
out |= list[i] << ((len - i - 1) * 6)
|
|
685
|
-
}
|
|
686
|
-
return out
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
},{}],5:[function(require,module,exports){
|
|
690
|
-
module.exports = copy
|
|
691
|
-
|
|
692
|
-
var slice = [].slice
|
|
693
|
-
|
|
694
|
-
function copy(source, target, target_start, source_start, source_end) {
|
|
695
|
-
target_start = arguments.length < 3 ? 0 : target_start
|
|
696
|
-
source_start = arguments.length < 4 ? 0 : source_start
|
|
697
|
-
source_end = arguments.length < 5 ? source.length : source_end
|
|
698
|
-
|
|
699
|
-
if(source_end === source_start) {
|
|
700
|
-
return
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
if(target.length === 0 || source.length === 0) {
|
|
704
|
-
return
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
if(source_end > source.length) {
|
|
708
|
-
source_end = source.length
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
if(target.length - target_start < source_end - source_start) {
|
|
712
|
-
source_end = target.length - target_start + source_start
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
if(source.buffer !== target.buffer) {
|
|
716
|
-
return fast_copy(source, target, target_start, source_start, source_end)
|
|
717
|
-
}
|
|
718
|
-
return slow_copy(source, target, target_start, source_start, source_end)
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
function fast_copy(source, target, target_start, source_start, source_end) {
|
|
722
|
-
var len = (source_end - source_start) + target_start
|
|
723
|
-
|
|
724
|
-
for(var i = target_start, j = source_start;
|
|
725
|
-
i < len;
|
|
726
|
-
++i,
|
|
727
|
-
++j) {
|
|
728
|
-
target[i] = source[j]
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
function slow_copy(from, to, j, i, jend) {
|
|
733
|
-
// the buffers could overlap.
|
|
734
|
-
var iend = jend + i
|
|
735
|
-
, tmp = new Uint8Array(slice.call(from, i, iend))
|
|
736
|
-
, x = 0
|
|
737
|
-
|
|
738
|
-
for(; i < iend; ++i, ++x) {
|
|
739
|
-
to[j++] = tmp[x]
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
},{}],6:[function(require,module,exports){
|
|
744
|
-
module.exports = function(size) {
|
|
745
|
-
return new Uint8Array(size)
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
},{}],7:[function(require,module,exports){
|
|
749
|
-
module.exports = from
|
|
750
|
-
|
|
751
|
-
var base64 = require('base64-js')
|
|
752
|
-
|
|
753
|
-
var decoders = {
|
|
754
|
-
hex: from_hex
|
|
755
|
-
, utf8: from_utf
|
|
756
|
-
, base64: from_base64
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
function from(source, encoding) {
|
|
760
|
-
if(Array.isArray(source)) {
|
|
761
|
-
return new Uint8Array(source)
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
return decoders[encoding || 'utf8'](source)
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
function from_hex(str) {
|
|
768
|
-
var size = str.length / 2
|
|
769
|
-
, buf = new Uint8Array(size)
|
|
770
|
-
, character = ''
|
|
771
|
-
|
|
772
|
-
for(var i = 0, len = str.length; i < len; ++i) {
|
|
773
|
-
character += str.charAt(i)
|
|
774
|
-
|
|
775
|
-
if(i > 0 && (i % 2) === 1) {
|
|
776
|
-
buf[i>>>1] = parseInt(character, 16)
|
|
777
|
-
character = ''
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
return buf
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
function from_utf(str) {
|
|
785
|
-
var bytes = []
|
|
786
|
-
, tmp
|
|
787
|
-
, ch
|
|
788
|
-
|
|
789
|
-
for(var i = 0, len = str.length; i < len; ++i) {
|
|
790
|
-
ch = str.charCodeAt(i)
|
|
791
|
-
if(ch & 0x80) {
|
|
792
|
-
tmp = encodeURIComponent(str.charAt(i)).substr(1).split('%')
|
|
793
|
-
for(var j = 0, jlen = tmp.length; j < jlen; ++j) {
|
|
794
|
-
bytes[bytes.length] = parseInt(tmp[j], 16)
|
|
795
|
-
}
|
|
796
|
-
} else {
|
|
797
|
-
bytes[bytes.length] = ch
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
return new Uint8Array(bytes)
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
function from_base64(str) {
|
|
805
|
-
return new Uint8Array(base64.toByteArray(str))
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
},{"base64-js":3}],8:[function(require,module,exports){
|
|
809
|
-
|
|
810
|
-
module.exports = function(buffer) {
|
|
811
|
-
return buffer instanceof Uint8Array;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
},{}],9:[function(require,module,exports){
|
|
815
|
-
module.exports = join
|
|
816
|
-
|
|
817
|
-
function join(targets, hint) {
|
|
818
|
-
if(!targets.length) {
|
|
819
|
-
return new Uint8Array(0)
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
var len = hint !== undefined ? hint : get_length(targets)
|
|
823
|
-
, out = new Uint8Array(len)
|
|
824
|
-
, cur = targets[0]
|
|
825
|
-
, curlen = cur.length
|
|
826
|
-
, curidx = 0
|
|
827
|
-
, curoff = 0
|
|
828
|
-
, i = 0
|
|
829
|
-
|
|
830
|
-
while(i < len) {
|
|
831
|
-
if(curoff === curlen) {
|
|
832
|
-
curoff = 0
|
|
833
|
-
++curidx
|
|
834
|
-
cur = targets[curidx]
|
|
835
|
-
curlen = cur && cur.length
|
|
836
|
-
continue
|
|
837
|
-
}
|
|
838
|
-
out[i++] = cur[curoff++]
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
return out
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
function get_length(targets) {
|
|
845
|
-
var size = 0
|
|
846
|
-
for(var i = 0, len = targets.length; i < len; ++i) {
|
|
847
|
-
size += targets[i].byteLength
|
|
848
|
-
}
|
|
849
|
-
return size
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
},{}],10:[function(require,module,exports){
|
|
853
|
-
var proto
|
|
854
|
-
, map
|
|
855
|
-
|
|
856
|
-
module.exports = proto = {}
|
|
857
|
-
|
|
858
|
-
map = typeof WeakMap === 'undefined' ? null : new WeakMap
|
|
859
|
-
|
|
860
|
-
proto.get = !map ? no_weakmap_get : get
|
|
861
|
-
|
|
862
|
-
function no_weakmap_get(target) {
|
|
863
|
-
return new DataView(target.buffer, 0)
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
function get(target) {
|
|
867
|
-
var out = map.get(target.buffer)
|
|
868
|
-
if(!out) {
|
|
869
|
-
map.set(target.buffer, out = new DataView(target.buffer, 0))
|
|
870
|
-
}
|
|
871
|
-
return out
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
},{}],11:[function(require,module,exports){
|
|
875
|
-
module.exports = {
|
|
876
|
-
readUInt8: read_uint8
|
|
877
|
-
, readInt8: read_int8
|
|
878
|
-
, readUInt16LE: read_uint16_le
|
|
879
|
-
, readUInt32LE: read_uint32_le
|
|
880
|
-
, readInt16LE: read_int16_le
|
|
881
|
-
, readInt32LE: read_int32_le
|
|
882
|
-
, readFloatLE: read_float_le
|
|
883
|
-
, readDoubleLE: read_double_le
|
|
884
|
-
, readUInt16BE: read_uint16_be
|
|
885
|
-
, readUInt32BE: read_uint32_be
|
|
886
|
-
, readInt16BE: read_int16_be
|
|
887
|
-
, readInt32BE: read_int32_be
|
|
888
|
-
, readFloatBE: read_float_be
|
|
889
|
-
, readDoubleBE: read_double_be
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
var map = require('./mapped.js')
|
|
893
|
-
|
|
894
|
-
function read_uint8(target, at) {
|
|
895
|
-
return target[at]
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
function read_int8(target, at) {
|
|
899
|
-
var v = target[at];
|
|
900
|
-
return v < 0x80 ? v : v - 0x100
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
function read_uint16_le(target, at) {
|
|
904
|
-
var dv = map.get(target);
|
|
905
|
-
return dv.getUint16(at + target.byteOffset, true)
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
function read_uint32_le(target, at) {
|
|
909
|
-
var dv = map.get(target);
|
|
910
|
-
return dv.getUint32(at + target.byteOffset, true)
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
function read_int16_le(target, at) {
|
|
914
|
-
var dv = map.get(target);
|
|
915
|
-
return dv.getInt16(at + target.byteOffset, true)
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
function read_int32_le(target, at) {
|
|
919
|
-
var dv = map.get(target);
|
|
920
|
-
return dv.getInt32(at + target.byteOffset, true)
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
function read_float_le(target, at) {
|
|
924
|
-
var dv = map.get(target);
|
|
925
|
-
return dv.getFloat32(at + target.byteOffset, true)
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
function read_double_le(target, at) {
|
|
929
|
-
var dv = map.get(target);
|
|
930
|
-
return dv.getFloat64(at + target.byteOffset, true)
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
function read_uint16_be(target, at) {
|
|
934
|
-
var dv = map.get(target);
|
|
935
|
-
return dv.getUint16(at + target.byteOffset, false)
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
function read_uint32_be(target, at) {
|
|
939
|
-
var dv = map.get(target);
|
|
940
|
-
return dv.getUint32(at + target.byteOffset, false)
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
function read_int16_be(target, at) {
|
|
944
|
-
var dv = map.get(target);
|
|
945
|
-
return dv.getInt16(at + target.byteOffset, false)
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
function read_int32_be(target, at) {
|
|
949
|
-
var dv = map.get(target);
|
|
950
|
-
return dv.getInt32(at + target.byteOffset, false)
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
function read_float_be(target, at) {
|
|
954
|
-
var dv = map.get(target);
|
|
955
|
-
return dv.getFloat32(at + target.byteOffset, false)
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
function read_double_be(target, at) {
|
|
959
|
-
var dv = map.get(target);
|
|
960
|
-
return dv.getFloat64(at + target.byteOffset, false)
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
},{"./mapped.js":10}],12:[function(require,module,exports){
|
|
964
|
-
module.exports = subarray
|
|
965
|
-
|
|
966
|
-
function subarray(buf, from, to) {
|
|
967
|
-
return buf.subarray(from || 0, to || buf.length)
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
},{}],13:[function(require,module,exports){
|
|
971
|
-
module.exports = to
|
|
972
|
-
|
|
973
|
-
var base64 = require('base64-js')
|
|
974
|
-
, toutf8 = require('to-utf8')
|
|
975
|
-
|
|
976
|
-
var encoders = {
|
|
977
|
-
hex: to_hex
|
|
978
|
-
, utf8: to_utf
|
|
979
|
-
, base64: to_base64
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
function to(buf, encoding) {
|
|
983
|
-
return encoders[encoding || 'utf8'](buf)
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
function to_hex(buf) {
|
|
987
|
-
var str = ''
|
|
988
|
-
, byt
|
|
989
|
-
|
|
990
|
-
for(var i = 0, len = buf.length; i < len; ++i) {
|
|
991
|
-
byt = buf[i]
|
|
992
|
-
str += ((byt & 0xF0) >>> 4).toString(16)
|
|
993
|
-
str += (byt & 0x0F).toString(16)
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
return str
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
function to_utf(buf) {
|
|
1000
|
-
return toutf8(buf)
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
function to_base64(buf) {
|
|
1004
|
-
return base64.fromByteArray(buf)
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
},{"base64-js":3,"to-utf8":4}],14:[function(require,module,exports){
|
|
1009
|
-
module.exports = {
|
|
1010
|
-
writeUInt8: write_uint8
|
|
1011
|
-
, writeInt8: write_int8
|
|
1012
|
-
, writeUInt16LE: write_uint16_le
|
|
1013
|
-
, writeUInt32LE: write_uint32_le
|
|
1014
|
-
, writeInt16LE: write_int16_le
|
|
1015
|
-
, writeInt32LE: write_int32_le
|
|
1016
|
-
, writeFloatLE: write_float_le
|
|
1017
|
-
, writeDoubleLE: write_double_le
|
|
1018
|
-
, writeUInt16BE: write_uint16_be
|
|
1019
|
-
, writeUInt32BE: write_uint32_be
|
|
1020
|
-
, writeInt16BE: write_int16_be
|
|
1021
|
-
, writeInt32BE: write_int32_be
|
|
1022
|
-
, writeFloatBE: write_float_be
|
|
1023
|
-
, writeDoubleBE: write_double_be
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
var map = require('./mapped.js')
|
|
1027
|
-
|
|
1028
|
-
function write_uint8(target, value, at) {
|
|
1029
|
-
return target[at] = value
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
function write_int8(target, value, at) {
|
|
1033
|
-
return target[at] = value < 0 ? value + 0x100 : value
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
function write_uint16_le(target, value, at) {
|
|
1037
|
-
var dv = map.get(target);
|
|
1038
|
-
return dv.setUint16(at + target.byteOffset, value, true)
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
function write_uint32_le(target, value, at) {
|
|
1042
|
-
var dv = map.get(target);
|
|
1043
|
-
return dv.setUint32(at + target.byteOffset, value, true)
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
function write_int16_le(target, value, at) {
|
|
1047
|
-
var dv = map.get(target);
|
|
1048
|
-
return dv.setInt16(at + target.byteOffset, value, true)
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
function write_int32_le(target, value, at) {
|
|
1052
|
-
var dv = map.get(target);
|
|
1053
|
-
return dv.setInt32(at + target.byteOffset, value, true)
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
function write_float_le(target, value, at) {
|
|
1057
|
-
var dv = map.get(target);
|
|
1058
|
-
return dv.setFloat32(at + target.byteOffset, value, true)
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
function write_double_le(target, value, at) {
|
|
1062
|
-
var dv = map.get(target);
|
|
1063
|
-
return dv.setFloat64(at + target.byteOffset, value, true)
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
function write_uint16_be(target, value, at) {
|
|
1067
|
-
var dv = map.get(target);
|
|
1068
|
-
return dv.setUint16(at + target.byteOffset, value, false)
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
function write_uint32_be(target, value, at) {
|
|
1072
|
-
var dv = map.get(target);
|
|
1073
|
-
return dv.setUint32(at + target.byteOffset, value, false)
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function write_int16_be(target, value, at) {
|
|
1077
|
-
var dv = map.get(target);
|
|
1078
|
-
return dv.setInt16(at + target.byteOffset, value, false)
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
function write_int32_be(target, value, at) {
|
|
1082
|
-
var dv = map.get(target);
|
|
1083
|
-
return dv.setInt32(at + target.byteOffset, value, false)
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
function write_float_be(target, value, at) {
|
|
1087
|
-
var dv = map.get(target);
|
|
1088
|
-
return dv.setFloat32(at + target.byteOffset, value, false)
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
function write_double_be(target, value, at) {
|
|
1092
|
-
var dv = map.get(target);
|
|
1093
|
-
return dv.setFloat64(at + target.byteOffset, value, false)
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
},{"./mapped.js":10}],15:[function(require,module,exports){
|
|
1097
|
-
|
|
1098
|
-
/**
|
|
1099
|
-
* Module dependencies.
|
|
1100
|
-
*/
|
|
1101
|
-
|
|
1102
|
-
var global = (function() { return this; })();
|
|
1103
|
-
|
|
1104
|
-
/**
|
|
1105
|
-
* WebSocket constructor.
|
|
1106
|
-
*/
|
|
1107
|
-
|
|
1108
|
-
var WebSocket = global.WebSocket || global.MozWebSocket;
|
|
1109
|
-
|
|
1110
|
-
/**
|
|
1111
|
-
* Module exports.
|
|
1112
|
-
*/
|
|
1113
|
-
|
|
1114
|
-
module.exports = WebSocket ? ws : null;
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* WebSocket constructor.
|
|
1118
|
-
*
|
|
1119
|
-
* The third `opts` options object gets ignored in web browsers, since it's
|
|
1120
|
-
* non-standard, and throws a TypeError if passed to the constructor.
|
|
1121
|
-
* See: https://github.com/einaros/ws/issues/227
|
|
1122
|
-
*
|
|
1123
|
-
* @param {String} uri
|
|
1124
|
-
* @param {Array} protocols (optional)
|
|
1125
|
-
* @param {Object) opts (optional)
|
|
1126
|
-
* @api public
|
|
1127
|
-
*/
|
|
1128
|
-
|
|
1129
|
-
function ws(uri, protocols, opts) {
|
|
1130
|
-
var instance;
|
|
1131
|
-
if (protocols) {
|
|
1132
|
-
instance = new WebSocket(uri, protocols);
|
|
1133
|
-
} else {
|
|
1134
|
-
instance = new WebSocket(uri);
|
|
1135
|
-
}
|
|
1136
|
-
return instance;
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
if (WebSocket) ws.prototype = WebSocket.prototype;
|
|
1140
|
-
|
|
1141
|
-
},{}],16:[function(require,module,exports){
|
|
1142
|
-
(function (process){
|
|
1143
|
-
|
|
1144
|
-
node_ws = require('ws');
|
|
1145
|
-
var msgpack = require('msgpack-js');
|
|
1146
|
-
//var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
|
1147
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
|
|
1148
|
-
//Only in a NODE environment !?!?
|
|
1149
|
-
//require('ssl-root-cas/latest').inject().addFile(__dirname + '/../ssl/GandiStandardSSLCA.pem');
|
|
1150
|
-
|
|
1151
|
-
var jsflow = function() {
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
jsflow.prototype.connect = function() { //'wss://dev.jsflow.com:443/wsTest'
|
|
1155
|
-
|
|
1156
|
-
var xhr = new XMLHttpRequest();
|
|
1157
|
-
xhr.open("POST", "https://local.jsflow.com/auth/asd", true);
|
|
1158
|
-
xhr.onreadystatechange = function() {//Call a function when the state changes.
|
|
1159
|
-
console.log('State', this.readyState);
|
|
1160
|
-
console.log('Status', this.status);
|
|
1161
|
-
console.log('StatusText', this.statusText);
|
|
1162
|
-
if(this.readyState == 4 && this.status == 200) {
|
|
1163
|
-
openSocket();
|
|
1164
|
-
}
|
|
1165
|
-
else {
|
|
1166
|
-
console.log('Did nothing');
|
|
1167
|
-
}
|
|
1168
|
-
};
|
|
1169
|
-
|
|
1170
|
-
xhr.send(JSON.stringify({token: 'ASKMDalsdkmdaskmadslMALSDMKA)SDua90sd09asd09ad=AS)=A=)SD'}));
|
|
1171
|
-
|
|
1172
|
-
var openSocket = function() {
|
|
1173
|
-
var ws = new node_ws('wss://local.jsflow.com:443/ws/ninja_loot', ['v0.jsflow', 'v1.jsflow'], {protocolVersion: 13, protocol: 'v0.jsflow,v1.jsflow'});
|
|
1174
|
-
|
|
1175
|
-
var recv = 0;
|
|
1176
|
-
var totTime = 0;
|
|
1177
|
-
ws.onopen = function() {
|
|
1178
|
-
console.log('connected');
|
|
1179
|
-
var msg = msgpack.encode(Date.now().toString());
|
|
1180
|
-
//var msg = JSON.stringify(Date.now().toString());
|
|
1181
|
-
//var msg = Date.now().toString();
|
|
1182
|
-
ws.send(msg, {mask: true});
|
|
1183
|
-
};
|
|
1184
|
-
|
|
1185
|
-
ws.onclose = function() {
|
|
1186
|
-
console.log('disconnected');
|
|
1187
|
-
};
|
|
1188
|
-
|
|
1189
|
-
ws.onmessage = function(message) {
|
|
1190
|
-
var data = msgpack.decode(message.data);
|
|
1191
|
-
//var data = JSON.parse(message.data);
|
|
1192
|
-
//var data = message.data;
|
|
1193
|
-
var time = (Date.now() - parseInt(data));
|
|
1194
|
-
recv += 1;
|
|
1195
|
-
totTime += time
|
|
1196
|
-
console.log('Roundtrip time: ' + time + 'ms. Avg: ' + (totTime/recv)+ ' '+recv);
|
|
1197
|
-
setTimeout(function() {
|
|
1198
|
-
var msg = msgpack.encode(Date.now().toString());
|
|
1199
|
-
//var msg = JSON.stringify(Date.now().toString());
|
|
1200
|
-
//var msg = Date.now().toString();
|
|
1201
|
-
ws.send(msg, {mask: true});
|
|
1202
|
-
}, 500);
|
|
1203
|
-
};
|
|
1204
|
-
}
|
|
1205
|
-
/*
|
|
1206
|
-
ws.on('open', function() {
|
|
1207
|
-
console.log('connected');
|
|
1208
|
-
ws.send(Date.now().toString(), {mask: true});
|
|
1209
|
-
});
|
|
1210
|
-
ws.on('close', function() {
|
|
1211
|
-
console.log('disconnected');
|
|
1212
|
-
});
|
|
1213
|
-
ws.on('message', function(data, flags) {
|
|
1214
|
-
console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags);
|
|
1215
|
-
setTimeout(function() {
|
|
1216
|
-
ws.send(Date.now().toString(), {mask: true});
|
|
1217
|
-
}, 500);
|
|
1218
|
-
});
|
|
1219
|
-
*/
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
//TODO: Pass parameters
|
|
1223
|
-
module.exports = new jsflow();
|
|
1224
|
-
|
|
1225
|
-
}).call(this,require('_process'))
|
|
1226
|
-
},{"_process":18,"msgpack-js":1,"ws":15}],17:[function(require,module,exports){
|
|
1227
|
-
var jsFlow = require('./src/main_ws');
|
|
1228
|
-
|
|
1229
|
-
jsFlow.connect();
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
},{"./src/main_ws":16}],18:[function(require,module,exports){
|
|
1233
|
-
// shim for using process in browser
|
|
1234
|
-
|
|
1235
|
-
var process = module.exports = {};
|
|
1236
|
-
|
|
1237
|
-
process.nextTick = (function () {
|
|
1238
|
-
var canSetImmediate = typeof window !== 'undefined'
|
|
1239
|
-
&& window.setImmediate;
|
|
1240
|
-
var canPost = typeof window !== 'undefined'
|
|
1241
|
-
&& window.postMessage && window.addEventListener
|
|
1242
|
-
;
|
|
1243
|
-
|
|
1244
|
-
if (canSetImmediate) {
|
|
1245
|
-
return function (f) { return window.setImmediate(f) };
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
if (canPost) {
|
|
1249
|
-
var queue = [];
|
|
1250
|
-
window.addEventListener('message', function (ev) {
|
|
1251
|
-
var source = ev.source;
|
|
1252
|
-
if ((source === window || source === null) && ev.data === 'process-tick') {
|
|
1253
|
-
ev.stopPropagation();
|
|
1254
|
-
if (queue.length > 0) {
|
|
1255
|
-
var fn = queue.shift();
|
|
1256
|
-
fn();
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
}, true);
|
|
1260
|
-
|
|
1261
|
-
return function nextTick(fn) {
|
|
1262
|
-
queue.push(fn);
|
|
1263
|
-
window.postMessage('process-tick', '*');
|
|
1264
|
-
};
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
return function nextTick(fn) {
|
|
1268
|
-
setTimeout(fn, 0);
|
|
1269
|
-
};
|
|
1270
|
-
})();
|
|
1271
|
-
|
|
1272
|
-
process.title = 'browser';
|
|
1273
|
-
process.browser = true;
|
|
1274
|
-
process.env = {};
|
|
1275
|
-
process.argv = [];
|
|
1276
|
-
|
|
1277
|
-
function noop() {}
|
|
1278
|
-
|
|
1279
|
-
process.on = noop;
|
|
1280
|
-
process.addListener = noop;
|
|
1281
|
-
process.once = noop;
|
|
1282
|
-
process.off = noop;
|
|
1283
|
-
process.removeListener = noop;
|
|
1284
|
-
process.removeAllListeners = noop;
|
|
1285
|
-
process.emit = noop;
|
|
1286
|
-
|
|
1287
|
-
process.binding = function (name) {
|
|
1288
|
-
throw new Error('process.binding is not supported');
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
// TODO(shtylman)
|
|
1292
|
-
process.cwd = function () { return '/' };
|
|
1293
|
-
process.chdir = function (dir) {
|
|
1294
|
-
throw new Error('process.chdir is not supported');
|
|
1295
|
-
};
|
|
1296
|
-
|
|
1297
|
-
},{}]},{},[17]);
|