socket-function 0.9.3 → 0.9.5

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.
Files changed (45) hide show
  1. package/.eslintrc.js +50 -50
  2. package/SocketFunction.ts +280 -280
  3. package/SocketFunctionTypes.ts +90 -90
  4. package/hot/HotReloadController.ts +105 -105
  5. package/mobx/UrlParam.ts +39 -39
  6. package/mobx/observer.tsx +49 -49
  7. package/mobx/promiseToObservable.tsx +41 -41
  8. package/package.json +1 -1
  9. package/require/CSSShim.ts +19 -19
  10. package/require/RequireController.ts +252 -252
  11. package/require/buffer.js +2368 -2368
  12. package/require/compileFlags.ts +44 -44
  13. package/require/require.html +13 -13
  14. package/require/require.js +464 -462
  15. package/spec.txt +115 -115
  16. package/src/CallFactory.ts +389 -389
  17. package/src/JSONLACKS/JSONLACKS.generated.js +17 -17
  18. package/src/JSONLACKS/JSONLACKS.pegjs +247 -247
  19. package/src/JSONLACKS/JSONLACKS.ts +441 -429
  20. package/src/args.ts +21 -21
  21. package/src/batching.ts +177 -170
  22. package/src/caching.ts +359 -318
  23. package/src/callHTTPHandler.ts +203 -203
  24. package/src/callManager.ts +134 -134
  25. package/src/certStore.ts +29 -29
  26. package/src/fixLargeNetworkCalls.ts +8 -8
  27. package/src/formatting/colors.ts +78 -78
  28. package/src/formatting/format.ts +160 -160
  29. package/src/formatting/logColors.ts +17 -17
  30. package/src/misc.ts +315 -302
  31. package/src/nodeCache.ts +92 -92
  32. package/src/nodeProxy.ts +54 -54
  33. package/src/profiling/getOwnTime.ts +107 -142
  34. package/src/profiling/measure.ts +289 -273
  35. package/src/profiling/stats.ts +212 -212
  36. package/src/profiling/tcpLagProxy.ts +63 -63
  37. package/src/storagePath.ts +10 -10
  38. package/src/tlsParsing.ts +96 -96
  39. package/src/types.ts +8 -8
  40. package/src/webSocketServer.ts +254 -250
  41. package/test/client.css +2 -2
  42. package/test/client.ts +46 -46
  43. package/test/server.ts +43 -43
  44. package/test/shared.ts +52 -52
  45. package/tsconfig.json +26 -26
package/src/tlsParsing.ts CHANGED
@@ -1,97 +1,97 @@
1
- export function parseTLSHello(buffer: Buffer): {
2
- extensions: {
3
- type: number;
4
- data: Buffer;
5
- }[];
6
- } {
7
- let output: {
8
- extensions: {
9
- type: number;
10
- data: Buffer;
11
- }[];
12
- } = {
13
- extensions: []
14
- };
15
-
16
- try {
17
- let pos = 0;
18
-
19
- function readShort() {
20
- let high = buffer[pos++];
21
- let low = buffer[pos++];
22
- return high * 256 + low;
23
- }
24
-
25
- let type = buffer[pos++];
26
- let version = readShort();
27
-
28
- var contentLength = readShort();
29
-
30
- let clientMessageType = buffer[pos++];
31
- // High length byte (how would this be used if contentLength is only 2 bytes?)
32
- pos++;
33
- let clientMessageLength = readShort();
34
-
35
- // Client version
36
- let clientVersion = readShort();
37
-
38
- // Client random
39
- pos += 32;
40
-
41
- // Session id
42
- let sessionIdLength = buffer[pos++];
43
- pos += sessionIdLength;
44
-
45
-
46
- let cipherSuiteLength = readShort();
47
- pos += cipherSuiteLength;
48
-
49
- let compressionLength = buffer[pos++];
50
- pos += compressionLength;
51
-
52
- let extensionsLength = readShort();
53
- let extensionsEnd = pos + extensionsLength;
54
- while (pos < extensionsEnd) {
55
- let extensionType = readShort();
56
- let length = readShort();
57
-
58
- output.extensions.push({
59
- type: extensionType, data: viewSliceBuffer(buffer, pos, length)
60
- });
61
-
62
- pos += length;
63
- }
64
- } catch { }
65
-
66
- return output;
67
- }
68
-
69
- export const SNIType = 0x0;
70
- export function parseSNIExtension(data: Buffer): string[] {
71
- let pos = 0;
72
- function readShort() {
73
- let high = data[pos++];
74
- let low = data[pos++];
75
- return high * 256 + low;
76
- }
77
-
78
- let snis: string[] = [];
79
-
80
- try {
81
- while (pos < data.length) {
82
- let len = readShort();
83
- let end = pos + len;
84
- let type = data[pos++];
85
- let len2 = readShort();
86
- snis.push(viewSliceBuffer(data, pos, len2).toString());
87
- pos = end;
88
- }
89
- } catch { }
90
-
91
- return snis;
92
- }
93
-
94
- function viewSliceBuffer(data: Buffer, index: number, count?: number) {
95
- count = count ?? (data.length - index);
96
- return Buffer.from(data.buffer, data.byteOffset + index, count);
1
+ export function parseTLSHello(buffer: Buffer): {
2
+ extensions: {
3
+ type: number;
4
+ data: Buffer;
5
+ }[];
6
+ } {
7
+ let output: {
8
+ extensions: {
9
+ type: number;
10
+ data: Buffer;
11
+ }[];
12
+ } = {
13
+ extensions: []
14
+ };
15
+
16
+ try {
17
+ let pos = 0;
18
+
19
+ function readShort() {
20
+ let high = buffer[pos++];
21
+ let low = buffer[pos++];
22
+ return high * 256 + low;
23
+ }
24
+
25
+ let type = buffer[pos++];
26
+ let version = readShort();
27
+
28
+ var contentLength = readShort();
29
+
30
+ let clientMessageType = buffer[pos++];
31
+ // High length byte (how would this be used if contentLength is only 2 bytes?)
32
+ pos++;
33
+ let clientMessageLength = readShort();
34
+
35
+ // Client version
36
+ let clientVersion = readShort();
37
+
38
+ // Client random
39
+ pos += 32;
40
+
41
+ // Session id
42
+ let sessionIdLength = buffer[pos++];
43
+ pos += sessionIdLength;
44
+
45
+
46
+ let cipherSuiteLength = readShort();
47
+ pos += cipherSuiteLength;
48
+
49
+ let compressionLength = buffer[pos++];
50
+ pos += compressionLength;
51
+
52
+ let extensionsLength = readShort();
53
+ let extensionsEnd = pos + extensionsLength;
54
+ while (pos < extensionsEnd) {
55
+ let extensionType = readShort();
56
+ let length = readShort();
57
+
58
+ output.extensions.push({
59
+ type: extensionType, data: viewSliceBuffer(buffer, pos, length)
60
+ });
61
+
62
+ pos += length;
63
+ }
64
+ } catch { }
65
+
66
+ return output;
67
+ }
68
+
69
+ export const SNIType = 0x0;
70
+ export function parseSNIExtension(data: Buffer): string[] {
71
+ let pos = 0;
72
+ function readShort() {
73
+ let high = data[pos++];
74
+ let low = data[pos++];
75
+ return high * 256 + low;
76
+ }
77
+
78
+ let snis: string[] = [];
79
+
80
+ try {
81
+ while (pos < data.length) {
82
+ let len = readShort();
83
+ let end = pos + len;
84
+ let type = data[pos++];
85
+ let len2 = readShort();
86
+ snis.push(viewSliceBuffer(data, pos, len2).toString());
87
+ pos = end;
88
+ }
89
+ } catch { }
90
+
91
+ return snis;
92
+ }
93
+
94
+ function viewSliceBuffer(data: Buffer, index: number, count?: number) {
95
+ count = count ?? (data.length - index);
96
+ return Buffer.from(data.buffer, data.byteOffset + index, count);
97
97
  }
package/src/types.ts CHANGED
@@ -1,9 +1,9 @@
1
- export type MaybePromise<T> = T | Promise<T>;
2
-
3
- export type Args<T> = T extends (...args: infer V) => any ? V : never;
4
-
5
- export type AnyFunction = (...args: any) => any;
6
-
7
- export function canHaveChildren(value: unknown): value is { [key in PropertyKey]: unknown } {
8
- return typeof value === "object" && value !== null || typeof value === "function";
1
+ export type MaybePromise<T> = T | Promise<T>;
2
+
3
+ export type Args<T> = T extends (...args: infer V) => any ? V : never;
4
+
5
+ export type AnyFunction = (...args: any) => any;
6
+
7
+ export function canHaveChildren(value: unknown): value is { [key in PropertyKey]: unknown } {
8
+ return typeof value === "object" && value !== null || typeof value === "function";
9
9
  }