@celljs/ta-relay 0.0.0-stage → 4.6.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.
Files changed (106) hide show
  1. package/README.md +34 -2
  2. package/esm/common/index.d.ts +6 -0
  3. package/esm/common/index.js +7 -0
  4. package/esm/common/index.js.map +1 -0
  5. package/esm/common/relay-bytes.d.ts +8 -0
  6. package/esm/common/relay-bytes.js +40 -0
  7. package/esm/common/relay-bytes.js.map +1 -0
  8. package/esm/common/relay-cipher.d.ts +22 -0
  9. package/esm/common/relay-cipher.js +55 -0
  10. package/esm/common/relay-cipher.js.map +1 -0
  11. package/esm/common/relay-pairing.d.ts +18 -0
  12. package/esm/common/relay-pairing.js +35 -0
  13. package/esm/common/relay-pairing.js.map +1 -0
  14. package/esm/common/relay-protocol.d.ts +56 -0
  15. package/esm/common/relay-protocol.js +29 -0
  16. package/esm/common/relay-protocol.js.map +1 -0
  17. package/esm/common/relay-room.d.ts +31 -0
  18. package/esm/common/relay-room.js +63 -0
  19. package/esm/common/relay-room.js.map +1 -0
  20. package/esm/common/relay-socket.d.ts +38 -0
  21. package/esm/common/relay-socket.js +98 -0
  22. package/esm/common/relay-socket.js.map +1 -0
  23. package/esm/node/index.d.ts +4 -0
  24. package/esm/node/index.js +5 -0
  25. package/esm/node/index.js.map +1 -0
  26. package/esm/node/relay-host.d.ts +61 -0
  27. package/esm/node/relay-host.js +208 -0
  28. package/esm/node/relay-host.js.map +1 -0
  29. package/esm/node/relay-server.d.ts +33 -0
  30. package/esm/node/relay-server.js +127 -0
  31. package/esm/node/relay-server.js.map +1 -0
  32. package/esm/node/relay-store.d.ts +35 -0
  33. package/esm/node/relay-store.js +59 -0
  34. package/esm/node/relay-store.js.map +1 -0
  35. package/esm/package.json +3 -0
  36. package/lib/common/index.d.ts +7 -0
  37. package/lib/common/index.d.ts.map +1 -0
  38. package/lib/common/index.js +23 -0
  39. package/lib/common/index.js.map +1 -0
  40. package/lib/common/relay-bytes.d.ts +9 -0
  41. package/lib/common/relay-bytes.d.ts.map +1 -0
  42. package/lib/common/relay-bytes.js +43 -0
  43. package/lib/common/relay-bytes.js.map +1 -0
  44. package/lib/common/relay-cipher.d.ts +23 -0
  45. package/lib/common/relay-cipher.d.ts.map +1 -0
  46. package/lib/common/relay-cipher.js +59 -0
  47. package/lib/common/relay-cipher.js.map +1 -0
  48. package/lib/common/relay-cipher.spec.d.ts +2 -0
  49. package/lib/common/relay-cipher.spec.d.ts.map +1 -0
  50. package/lib/common/relay-cipher.spec.js +43 -0
  51. package/lib/common/relay-cipher.spec.js.map +1 -0
  52. package/lib/common/relay-pairing.d.ts +19 -0
  53. package/lib/common/relay-pairing.d.ts.map +1 -0
  54. package/lib/common/relay-pairing.js +38 -0
  55. package/lib/common/relay-pairing.js.map +1 -0
  56. package/lib/common/relay-pairing.spec.d.ts +2 -0
  57. package/lib/common/relay-pairing.spec.d.ts.map +1 -0
  58. package/lib/common/relay-pairing.spec.js +25 -0
  59. package/lib/common/relay-pairing.spec.js.map +1 -0
  60. package/lib/common/relay-protocol.d.ts +57 -0
  61. package/lib/common/relay-protocol.d.ts.map +1 -0
  62. package/lib/common/relay-protocol.js +32 -0
  63. package/lib/common/relay-protocol.js.map +1 -0
  64. package/lib/common/relay-room.d.ts +32 -0
  65. package/lib/common/relay-room.d.ts.map +1 -0
  66. package/lib/common/relay-room.js +67 -0
  67. package/lib/common/relay-room.js.map +1 -0
  68. package/lib/common/relay-socket.d.ts +39 -0
  69. package/lib/common/relay-socket.d.ts.map +1 -0
  70. package/lib/common/relay-socket.js +102 -0
  71. package/lib/common/relay-socket.js.map +1 -0
  72. package/lib/node/index.d.ts +5 -0
  73. package/lib/node/index.d.ts.map +1 -0
  74. package/lib/node/index.js +21 -0
  75. package/lib/node/index.js.map +1 -0
  76. package/lib/node/relay-host.d.ts +62 -0
  77. package/lib/node/relay-host.d.ts.map +1 -0
  78. package/lib/node/relay-host.js +212 -0
  79. package/lib/node/relay-host.js.map +1 -0
  80. package/lib/node/relay-server.d.ts +34 -0
  81. package/lib/node/relay-server.d.ts.map +1 -0
  82. package/lib/node/relay-server.js +131 -0
  83. package/lib/node/relay-server.js.map +1 -0
  84. package/lib/node/relay-store.d.ts +36 -0
  85. package/lib/node/relay-store.d.ts.map +1 -0
  86. package/lib/node/relay-store.js +63 -0
  87. package/lib/node/relay-store.js.map +1 -0
  88. package/lib/node/relay.spec.d.ts +2 -0
  89. package/lib/node/relay.spec.d.ts.map +1 -0
  90. package/lib/node/relay.spec.js +141 -0
  91. package/lib/node/relay.spec.js.map +1 -0
  92. package/package.json +58 -4
  93. package/src/common/index.ts +6 -0
  94. package/src/common/relay-bytes.ts +37 -0
  95. package/src/common/relay-cipher.spec.ts +45 -0
  96. package/src/common/relay-cipher.ts +74 -0
  97. package/src/common/relay-pairing.spec.ts +26 -0
  98. package/src/common/relay-pairing.ts +46 -0
  99. package/src/common/relay-protocol.ts +50 -0
  100. package/src/common/relay-room.ts +79 -0
  101. package/src/common/relay-socket.ts +106 -0
  102. package/src/node/index.ts +4 -0
  103. package/src/node/relay-host.ts +230 -0
  104. package/src/node/relay-server.ts +143 -0
  105. package/src/node/relay-store.ts +84 -0
  106. package/src/node/relay.spec.ts +151 -0
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayBytes = void 0;
4
+ /** Bytes as text and back, in base64url, with what every platform has (no Buffer in a browser). */
5
+ var RelayBytes;
6
+ (function (RelayBytes) {
7
+ function random(length) {
8
+ return globalThis.crypto.getRandomValues(new Uint8Array(length));
9
+ }
10
+ RelayBytes.random = random;
11
+ function toBase64(bytes) {
12
+ let binary = '';
13
+ for (const byte of bytes) {
14
+ binary += String.fromCharCode(byte);
15
+ }
16
+ return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
17
+ }
18
+ RelayBytes.toBase64 = toBase64;
19
+ /** Throws on what is not base64url. */
20
+ function fromBase64(text) {
21
+ if (!/^[A-Za-z0-9_-]*$/.test(text)) {
22
+ throw new Error('Not base64url.');
23
+ }
24
+ const binary = atob(text.replace(/-/g, '+').replace(/_/g, '/'));
25
+ const bytes = new Uint8Array(binary.length);
26
+ for (let i = 0; i < binary.length; i++) {
27
+ bytes[i] = binary.charCodeAt(i);
28
+ }
29
+ return bytes;
30
+ }
31
+ RelayBytes.fromBase64 = fromBase64;
32
+ function concat(...parts) {
33
+ const bytes = new Uint8Array(parts.reduce((length, part) => length + part.length, 0));
34
+ let offset = 0;
35
+ for (const part of parts) {
36
+ bytes.set(part, offset);
37
+ offset += part.length;
38
+ }
39
+ return bytes;
40
+ }
41
+ RelayBytes.concat = concat;
42
+ })(RelayBytes || (exports.RelayBytes = RelayBytes = {}));
43
+ //# sourceMappingURL=relay-bytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-bytes.js","sourceRoot":"","sources":["../../src/common/relay-bytes.ts"],"names":[],"mappings":";;;AAAA,mGAAmG;AACnG,IAAiB,UAAU,CAmC1B;AAnCD,WAAiB,UAAU;IACvB,SAAgB,MAAM,CAAC,MAAc;QACjC,OAAO,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IAFe,WAAA,MAAM,SAErB,CAAA;IAED,SAAgB,QAAQ,CAAC,KAAiB;QACtC,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnF,CAAC;IANe,WAAA,QAAQ,WAMvB,CAAA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+ * The encryption of one connection between a paired device and ta serve: AES-256-GCM with a key for
4
+ * each direction, derived (HKDF-SHA-256) from the device's key and a nonce of each side, so that every
5
+ * connection has keys of its own. The IV is the number of the message, which must arrive in order: a
6
+ * message replayed, dropped or reordered by the relay fails to open.
7
+ */
8
+ export declare class RelayCipher {
9
+ protected readonly sendKey: CryptoKey;
10
+ protected readonly receiveKey: CryptoKey;
11
+ protected sent: number;
12
+ protected received: number;
13
+ protected sealing: Promise<unknown>;
14
+ protected opening: Promise<unknown>;
15
+ protected constructor(sendKey: CryptoKey, receiveKey: CryptoKey);
16
+ static derive(deviceKey: Uint8Array, clientNonce: Uint8Array, hostNonce: Uint8Array, side: RelaySide): Promise<RelayCipher>;
17
+ /** Resolves in the order of the calls, so that sending in `then` sends in order. */
18
+ seal(text: string): Promise<string>;
19
+ /** Rejects what this side's peer did not seal, or not as the next message. */
20
+ open(frame: string): Promise<string>;
21
+ protected static iv(counter: number): Uint8Array;
22
+ }
23
+ //# sourceMappingURL=relay-cipher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-cipher.d.ts","sourceRoot":"","sources":["../../src/common/relay-cipher.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1C;;;;;GAKG;AACH,qBAAa,WAAW;IAOhB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS;IACrC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,SAAS;IAP5C,SAAS,CAAC,IAAI,SAAK;IACnB,SAAS,CAAC,QAAQ,SAAK;IACvB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAqB;IACxD,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAqB;IAExD,SAAS,aACc,OAAO,EAAE,SAAS,EAClB,UAAU,EAAE,SAAS,EACxC;IAEJ,OAAa,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAchI;IAED,oFAAoF;IACpF,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlC;IAED,8EAA8E;IAC9E,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYnC;IAED,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAK/C;CACJ"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayCipher = void 0;
4
+ const relay_bytes_1 = require("./relay-bytes");
5
+ const encoder = new TextEncoder();
6
+ const decoder = new TextDecoder();
7
+ const IV_LENGTH = 12;
8
+ /**
9
+ * The encryption of one connection between a paired device and ta serve: AES-256-GCM with a key for
10
+ * each direction, derived (HKDF-SHA-256) from the device's key and a nonce of each side, so that every
11
+ * connection has keys of its own. The IV is the number of the message, which must arrive in order: a
12
+ * message replayed, dropped or reordered by the relay fails to open.
13
+ */
14
+ class RelayCipher {
15
+ constructor(sendKey, receiveKey) {
16
+ this.sendKey = sendKey;
17
+ this.receiveKey = receiveKey;
18
+ this.sent = 0;
19
+ this.received = 0;
20
+ this.sealing = Promise.resolve();
21
+ this.opening = Promise.resolve();
22
+ }
23
+ static async derive(deviceKey, clientNonce, hostNonce, side) {
24
+ const subtle = globalThis.crypto.subtle;
25
+ const secret = await subtle.importKey('raw', deviceKey, 'HKDF', false, ['deriveKey']);
26
+ const salt = relay_bytes_1.RelayBytes.concat(clientNonce, hostNonce);
27
+ const key = (direction) => subtle.deriveKey({ name: 'HKDF', hash: 'SHA-256', salt: salt, info: encoder.encode(`ta-relay/1 ${direction}`) }, secret, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
28
+ const [toHost, toClient] = await Promise.all([key('client-to-host'), key('host-to-client')]);
29
+ return side === 'client' ? new RelayCipher(toHost, toClient) : new RelayCipher(toClient, toHost);
30
+ }
31
+ /** Resolves in the order of the calls, so that sending in `then` sends in order. */
32
+ seal(text) {
33
+ const iv = RelayCipher.iv(this.sent++);
34
+ const sealed = this.sealing.then(async () => {
35
+ const data = await globalThis.crypto.subtle.encrypt({ name: 'AES-GCM', iv: iv }, this.sendKey, encoder.encode(text));
36
+ return relay_bytes_1.RelayBytes.toBase64(new Uint8Array(data));
37
+ });
38
+ this.sealing = sealed.catch(() => undefined);
39
+ return sealed;
40
+ }
41
+ /** Rejects what this side's peer did not seal, or not as the next message. */
42
+ open(frame) {
43
+ const iv = RelayCipher.iv(this.received++);
44
+ const opened = this.opening.then(async () => {
45
+ const data = await globalThis.crypto.subtle.decrypt({ name: 'AES-GCM', iv: iv }, this.receiveKey, relay_bytes_1.RelayBytes.fromBase64(frame));
46
+ return decoder.decode(data);
47
+ });
48
+ this.opening = opened.catch(() => undefined);
49
+ return opened;
50
+ }
51
+ static iv(counter) {
52
+ const iv = new Uint8Array(IV_LENGTH);
53
+ new DataView(iv.buffer).setUint32(IV_LENGTH - 8, Math.floor(counter / 2 ** 32));
54
+ new DataView(iv.buffer).setUint32(IV_LENGTH - 4, counter >>> 0);
55
+ return iv;
56
+ }
57
+ }
58
+ exports.RelayCipher = RelayCipher;
59
+ //# sourceMappingURL=relay-cipher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-cipher.js","sourceRoot":"","sources":["../../src/common/relay-cipher.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,SAAS,GAAG,EAAE,CAAC;AAIrB;;;;;GAKG;AACH;IAMI,YACuB,OAAkB,EAClB,UAAqB;QADrB,YAAO,GAAP,OAAO,CAAW;QAClB,eAAU,GAAV,UAAU,CAAW;Q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,MAAM,CAAC;IAClB,CAAC;IAES,MAAM,CAAC,EAAE,CAAC,OAAe;QAC/B,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,SAAS,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAChF,IAAI,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,SAAS,GAAG,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC;QAChE,OAAO,EAAE,CAAC;IACd,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=relay-cipher.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-cipher.spec.d.ts","sourceRoot":"","sources":["../../src/common/relay-cipher.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bun_test_1 = require("bun:test");
4
+ const relay_bytes_1 = require("./relay-bytes");
5
+ const relay_cipher_1 = require("./relay-cipher");
6
+ async function pair(key = relay_bytes_1.RelayBytes.random(32)) {
7
+ const [client, host] = [relay_bytes_1.RelayBytes.random(16), relay_bytes_1.RelayBytes.random(16)];
8
+ return { client: await relay_cipher_1.RelayCipher.derive(key, client, host, 'client'), host: await relay_cipher_1.RelayCipher.derive(key, client, host, 'host') };
9
+ }
10
+ (0, bun_test_1.describe)('RelayCipher', () => {
11
+ (0, bun_test_1.it)('opens on one side what the other sealed, both ways, in order', async () => {
12
+ const { client, host } = await pair();
13
+ const frames = await Promise.all(['a', 'b', 'c'].map(text => client.seal(text)));
14
+ (0, bun_test_1.expect)(await Promise.all(frames.map(frame => host.open(frame)))).toEqual(['a', 'b', 'c']);
15
+ (0, bun_test_1.expect)(await client.open(await host.seal('back'))).toBe('back');
16
+ });
17
+ (0, bun_test_1.it)('does not open a message replayed, skipped or changed', async () => {
18
+ const { client, host } = await pair();
19
+ const first = await client.seal('first');
20
+ const second = await client.seal('second');
21
+ (0, bun_test_1.expect)(await host.open(first)).toBe('first');
22
+ await (0, bun_test_1.expect)(host.open(first)).rejects.toThrow();
23
+ const other = await pair();
24
+ await other.client.seal('skipped');
25
+ await (0, bun_test_1.expect)(other.host.open(await other.client.seal('second'))).rejects.toThrow();
26
+ const bytes = relay_bytes_1.RelayBytes.fromBase64(second);
27
+ bytes[0] ^= 1;
28
+ await (0, bun_test_1.expect)(host.open(relay_bytes_1.RelayBytes.toBase64(bytes))).rejects.toThrow();
29
+ });
30
+ (0, bun_test_1.it)('does not open what a side sealed for the other direction, or with another key', async () => {
31
+ const { client } = await pair();
32
+ const frame = await client.seal('x');
33
+ await (0, bun_test_1.expect)(client.open(frame)).rejects.toThrow();
34
+ const other = await pair();
35
+ await (0, bun_test_1.expect)(other.host.open(frame)).rejects.toThrow();
36
+ });
37
+ (0, bun_test_1.it)('keeps base64url as it was', () => {
38
+ const bytes = relay_bytes_1.RelayBytes.random(33);
39
+ (0, bun_test_1.expect)(relay_bytes_1.RelayBytes.fromBase64(relay_bytes_1.RelayBytes.toBase64(bytes))).toEqual(bytes);
40
+ (0, bun_test_1.expect)(() => relay_bytes_1.RelayBytes.fromBase64('a+b')).toThrow();
41
+ });
42
+ });
43
+ //# sourceMappingURL=relay-cipher.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-cipher.spec.js","sourceRoot":"","sources":["../../src/common/relay-cipher.spec.ts"],"names":[],"mappings":";;AAAA,uCAAgD;AAChD,+CAA2C;AAC3C,iDAA6C;AAE7C,KAAK,UAAU,IAAI,CAAC,GAAG,GAAG,wBAAU,CAAC,MAAM,CAAC,EAAE,CAAC;IAC3C,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,wBAAU,CAAC,MAAM,CAAC,EA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IAAI,EAAE,CAAC;QAC3B,MAAM,IAAA,iBAAM,EAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,IAAA,aAAE,EAAC,2BAA2B,EAAE,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG,wBAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpC,IAAA,iBAAM,EAAC,wBAAU,CAAC,UAAU,CAAC,wBAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACzE,IAAA,iBAAM,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** What a device needs to reach a ta serve through a relay. The key never goes to the relay. */
2
+ export interface RelayPairing {
3
+ /** The relay, https or http, without a trailing slash. */
4
+ relay: string;
5
+ host: string;
6
+ device: string;
7
+ /** base64url, 32 bytes. */
8
+ key: string;
9
+ /** What the host is called, for the device to show. */
10
+ name?: string;
11
+ }
12
+ export declare namespace RelayPairingUtil {
13
+ /** A link to open on the device: all but the relay's address is in the fragment, which is not sent to it. */
14
+ function link(pairing: RelayPairing): string;
15
+ /** Throws on a link that is not one of {@link link}. */
16
+ function parse(link: string): RelayPairing;
17
+ function websocketUrl(relay: string, path: string): string;
18
+ }
19
+ //# sourceMappingURL=relay-pairing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-pairing.d.ts","sourceRoot":"","sources":["../../src/common/relay-pairing.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,MAAM,WAAW,YAAY;IACzB,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,yBAAiB,gBAAgB,CAAC;IAC9B,6GAA6G;IAC7G,SAAgB,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAMlD;IAED,wDAAwD;IACxD,SAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAehD;IAED,SAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE;CACJ"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayPairingUtil = void 0;
4
+ const relay_protocol_1 = require("./relay-protocol");
5
+ var RelayPairingUtil;
6
+ (function (RelayPairingUtil) {
7
+ /** A link to open on the device: all but the relay's address is in the fragment, which is not sent to it. */
8
+ function link(pairing) {
9
+ const fragment = new URLSearchParams({ v: '1', h: pairing.host, d: pairing.device, k: pairing.key });
10
+ if (pairing.name) {
11
+ fragment.set('n', pairing.name);
12
+ }
13
+ return `${pairing.relay}${relay_protocol_1.RELAY_PAIR_PATH}#${fragment}`;
14
+ }
15
+ RelayPairingUtil.link = link;
16
+ /** Throws on a link that is not one of {@link link}. */
17
+ function parse(link) {
18
+ var _a;
19
+ const url = new URL(link.trim());
20
+ const fragment = new URLSearchParams(url.hash.slice(1));
21
+ const [host, device, key] = ['h', 'd', 'k'].map(name => { var _a; return (_a = fragment.get(name)) !== null && _a !== void 0 ? _a : ''; });
22
+ if (!/^https?:$/.test(url.protocol) ||
23
+ url.pathname !== relay_protocol_1.RELAY_PAIR_PATH ||
24
+ fragment.get('v') !== '1' ||
25
+ !relay_protocol_1.RELAY_ID.test(host) ||
26
+ !relay_protocol_1.RELAY_ID.test(device) ||
27
+ !/^[A-Za-z0-9_-]{43}$/.test(key)) {
28
+ throw new Error('Not a pairing link of Ta.');
29
+ }
30
+ return { relay: url.origin, host, device, key, name: (_a = fragment.get('n')) !== null && _a !== void 0 ? _a : undefined };
31
+ }
32
+ RelayPairingUtil.parse = parse;
33
+ function websocketUrl(relay, path) {
34
+ return relay.replace(/^http/, 'ws') + path;
35
+ }
36
+ RelayPairingUtil.websocketUrl = websocketUrl;
37
+ })(RelayPairingUtil || (exports.RelayPairingUtil = RelayPairingUtil = {}));
38
+ //# sourceMappingURL=relay-pairing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-pairing.js","sourceRoot":"","sources":["../../src/common/relay-pairing.ts"],"names":[],"mappings":";;;AAAA,qDAA6D;AAc7D,IAAiB,gBAAgB,CA+BhC;AA/BD,WAAiB,gBAAgB;IAC7B,6GAA6G;IAC7G,SAAgB,IAAI,CAAC,OAAqB;QACtC,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrG,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,KAAK,GAAG,gCAAe,IAAI,QAAQ,EAAE,CAAC;IAC5D,CAAC;IANe,iBAAA,IAAI,OAMnB,CAAA;IAED,wDAAwD;IACxD,SAAgB,KAAK,CAAC,IAAY;;QAC9B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACjC,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,wBAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAI,EAAE,GAAA,CAAC,CAAC;QAClF,IACI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;YAC/B,GAAG,CAAC,QAAQ,KAAK,gCAAe;YAChC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG;YACzB,CAAC,yBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YACpB,CAAC,yBAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;YACtB,CAAC,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,EAClC,CAAC;YACC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,QAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,SAAS,EAAE,CAAC;IAC1F,CAAC;IAfe,iBAAA,KAAK,QAepB,CAAA;IAED,SAAgB,YAAY,CAAC,KAAa,EAAE,IAAY;QACpD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;IAC/C,CAAC;IAFe,iBAAA,YAAY,eAE3B,CAAA;AACL,CAAC,EA/BgB,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QA+BhC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=relay-pairing.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-pairing.spec.d.ts","sourceRoot":"","sources":["../../src/common/relay-pairing.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bun_test_1 = require("bun:test");
4
+ const relay_bytes_1 = require("./relay-bytes");
5
+ const relay_pairing_1 = require("./relay-pairing");
6
+ const pairing = { relay: 'https://relay.example', host: 'h'.repeat(22), device: 'd'.repeat(22), key: relay_bytes_1.RelayBytes.toBase64(relay_bytes_1.RelayBytes.random(32)), name: 'Mac' };
7
+ (0, bun_test_1.describe)('RelayPairingUtil', () => {
8
+ (0, bun_test_1.it)('keeps everything but the relay in the fragment, and reads it back', () => {
9
+ const link = relay_pairing_1.RelayPairingUtil.link(pairing);
10
+ const url = new URL(link);
11
+ (0, bun_test_1.expect)(url.origin + url.pathname + url.search).toBe('https://relay.example/pair');
12
+ (0, bun_test_1.expect)(url.hash).toContain(pairing.key);
13
+ (0, bun_test_1.expect)(relay_pairing_1.RelayPairingUtil.parse(link)).toEqual(pairing);
14
+ });
15
+ (0, bun_test_1.it)('refuses what is not a pairing link', () => {
16
+ (0, bun_test_1.expect)(() => relay_pairing_1.RelayPairingUtil.parse('https://relay.example/pair#v=1')).toThrow();
17
+ (0, bun_test_1.expect)(() => relay_pairing_1.RelayPairingUtil.parse(relay_pairing_1.RelayPairingUtil.link({ ...pairing, key: 'short' }))).toThrow();
18
+ (0, bun_test_1.expect)(() => relay_pairing_1.RelayPairingUtil.parse(relay_pairing_1.RelayPairingUtil.link(pairing).replace('https:', 'javascript:'))).toThrow();
19
+ });
20
+ (0, bun_test_1.it)('turns the relay into its WebSocket address', () => {
21
+ (0, bun_test_1.expect)(relay_pairing_1.RelayPairingUtil.websocketUrl('https://r.example', '/v1/connect/x')).toBe('wss://r.example/v1/connect/x');
22
+ (0, bun_test_1.expect)(relay_pairing_1.RelayPairingUtil.websocketUrl('http://127.0.0.1:9', '/x')).toBe('ws://127.0.0.1:9/x');
23
+ });
24
+ });
25
+ //# sourceMappingURL=relay-pairing.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-pairing.spec.js","sourceRoot":"","sources":["../../src/common/relay-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,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACpG,IAAA,iBAAM,EAAC,GAAG,EAAE,CAAC,gCAAgB,CAAC,KAAK,CAAC,gCAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACpH,CAAC,CAAC,CAAC;IAEH,IAAA,aAAE,EAAC,4CAA4C,EAAE,GAAG,EAAE;QAClD,IAAA,iBAAM,EAAC,gCAAgB,CAAC,YAAY,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QACjH,IAAA,iBAAM,EAAC,gCAAgB,CAAC,YAAY,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,57 @@
1
+ /** The relay of Ta, on Cloudflare Workers (apps/ta-relay), when the user names none. */
2
+ export declare const RELAY_DEFAULT_URL = "https://relay.cellbang.com";
3
+ /** What the relay serves: hosts connect to the first, devices to the second. */
4
+ export declare const RELAY_HOST_PATH = "/v1/host/";
5
+ export declare const RELAY_CONNECT_PATH = "/v1/connect/";
6
+ export declare const RELAY_PAIR_PATH = "/pair";
7
+ /** The page a pairing link opens in a browser: the link is for the app, and the key in it stays in the fragment. */
8
+ export declare const RELAY_PAIR_PAGE = "<!doctype html><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><title>Ta</title>\n<body style=\"font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em\">\n<h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>\n<p>\u6253\u5F00 Ta \u5E94\u7528\uFF0C\u7C98\u8D34\u8FD9\u4E2A\u94FE\u63A5\uFF0C\u5C31\u80FD\u4ECE\u8FD9\u53F0\u8BBE\u5907\u8FDE\u5230\u4F60\u7684 Ta\u3002</p></body>";
9
+ /** Hosts and devices: what the relay knows of them, and nothing it could read from. */
10
+ export declare const RELAY_ID: RegExp;
11
+ /** Close codes of the relay. */
12
+ export declare enum RelayCloseCode {
13
+ /** The host is not connected. */
14
+ HOST_OFFLINE = 4404,
15
+ /** Another host holds this id, or the secret is wrong. */
16
+ REFUSED = 4401,
17
+ /** The same host connected again; the older connection goes. */
18
+ REPLACED = 4409,
19
+ /** The host closed this channel, or refused the device. */
20
+ CLOSED_BY_HOST = 4410,
21
+ /** Too many devices are connected to this host. */
22
+ FULL = 4429
23
+ }
24
+ /**
25
+ * Between the relay and a host, which takes the connections of many devices over one WebSocket: each
26
+ * device connection is a channel. What a device sends goes to the host as `data`, and back; the relay
27
+ * cannot read it (RelayCipher).
28
+ */
29
+ export type RelayHostMessage = {
30
+ t: 'open';
31
+ ch: string;
32
+ } | {
33
+ t: 'data';
34
+ ch: string;
35
+ d: string;
36
+ } | {
37
+ t: 'close';
38
+ ch: string;
39
+ };
40
+ /** The first message of a device on a channel, in the clear; after it every message is sealed. */
41
+ export interface RelayHello {
42
+ t: 'hello';
43
+ v: 1;
44
+ device: string;
45
+ nonce: string;
46
+ }
47
+ /** The host's answer: its nonce, and a first sealed message that shows it has the device's key. */
48
+ export type RelayWelcome = {
49
+ t: 'ready';
50
+ nonce: string;
51
+ proof: string;
52
+ } | {
53
+ t: 'refused';
54
+ reason: string;
55
+ };
56
+ export declare const RELAY_PROOF = "ta-relay ready";
57
+ //# sourceMappingURL=relay-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-protocol.d.ts","sourceRoot":"","sources":["../../src/common/relay-protocol.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAE9D,gFAAgF;AAChF,eAAO,MAAM,eAAe,cAAc,CAAC;AAC3C,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AACjD,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,oHAAoH;AACpH,eAAO,MAAM,eAAe,qdAGkB,CAAC;AAE/C,uFAAuF;AACvF,eAAO,MAAM,QAAQ,QAA2B,CAAC;AAEjD,gCAAgC;AAChC,oBAAY,cAAc;IACtB,iCAAiC;IACjC,YAAY,OAAO;IACnB,0DAA0D;IAC1D,OAAO,OAAO;IACd,gEAAgE;IAChE,QAAQ,OAAO;IACf,2DAA2D;IAC3D,cAAc,OAAO;IACrB,mDAAmD;IACnD,IAAI,OAAO;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7H,kGAAkG;AAClG,MAAM,WAAW,UAAU;IACvB,CAAC,EAAE,OAAO,CAAC;IACX,CAAC,EAAE,CAAC,CAAC;IACL,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,mGAAmG;AACnG,MAAM,MAAM,YAAY,GAAG;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,CAAC,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3G,eAAO,MAAM,WAAW,mBAAmB,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RELAY_PROOF = exports.RelayCloseCode = exports.RELAY_ID = exports.RELAY_PAIR_PAGE = exports.RELAY_PAIR_PATH = exports.RELAY_CONNECT_PATH = exports.RELAY_HOST_PATH = exports.RELAY_DEFAULT_URL = void 0;
4
+ /** The relay of Ta, on Cloudflare Workers (apps/ta-relay), when the user names none. */
5
+ exports.RELAY_DEFAULT_URL = 'https://relay.cellbang.com';
6
+ /** What the relay serves: hosts connect to the first, devices to the second. */
7
+ exports.RELAY_HOST_PATH = '/v1/host/';
8
+ exports.RELAY_CONNECT_PATH = '/v1/connect/';
9
+ exports.RELAY_PAIR_PATH = '/pair';
10
+ /** The page a pairing link opens in a browser: the link is for the app, and the key in it stays in the fragment. */
11
+ exports.RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
12
+ <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
13
+ <h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
14
+ <p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p></body>`;
15
+ /** Hosts and devices: what the relay knows of them, and nothing it could read from. */
16
+ exports.RELAY_ID = /^[A-Za-z0-9_-]{16,64}$/;
17
+ /** Close codes of the relay. */
18
+ var RelayCloseCode;
19
+ (function (RelayCloseCode) {
20
+ /** The host is not connected. */
21
+ RelayCloseCode[RelayCloseCode["HOST_OFFLINE"] = 4404] = "HOST_OFFLINE";
22
+ /** Another host holds this id, or the secret is wrong. */
23
+ RelayCloseCode[RelayCloseCode["REFUSED"] = 4401] = "REFUSED";
24
+ /** The same host connected again; the older connection goes. */
25
+ RelayCloseCode[RelayCloseCode["REPLACED"] = 4409] = "REPLACED";
26
+ /** The host closed this channel, or refused the device. */
27
+ RelayCloseCode[RelayCloseCode["CLOSED_BY_HOST"] = 4410] = "CLOSED_BY_HOST";
28
+ /** Too many devices are connected to this host. */
29
+ RelayCloseCode[RelayCloseCode["FULL"] = 4429] = "FULL";
30
+ })(RelayCloseCode || (exports.RelayCloseCode = RelayCloseCode = {}));
31
+ exports.RELAY_PROOF = 'ta-relay ready';
32
+ //# sourceMappingURL=relay-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-protocol.js","sourceRoot":"","sources":["../../src/common/relay-protocol.ts"],"names":[],"mappings":";;;AAAA,wFAAwF;AAC3E,QAAA,iBAAiB,GAAG,4BAA4B,CAAC;AAE9D,gFAAgF;AACnE,QAAA,eAAe,GAAG,WAAW,CAAC;AAC9B,QAAA,kBAAkB,GAAG,cAAc,CAAC;AACpC,QAAA,eAAe,GAAG,OAAO,CAAC;AAEvC,oHAAoH;AACvG,QAAA,eAAe,GAAG;;;8CAGe,CAAC;AAE/C,uFAAuF;AAC1E,QAAA,QAAQ,GAAG,wBAAwB,CAAC;AAEjD,gCAAgC;AAChC,IAAY,cAWX;AAXD,WAAY,cAAc;IACtB,iCAAiC;IACjC,sEAAmB,CAAA;IACnB,0DAA0D;IAC1D,4DAAc,CAAA;IACd,gEAAgE;IAChE,8DAAe,CAAA;IACf,2DAA2D;IAC3D,0EAAqB,CAAA;IACrB,mDAAmD;IACnD,sDAAW,CAAA;AACf,CAAC,EAXW,cAAc,aAAd,cAAc,GAAd,cAAc,QAWzB;AAoBY,QAAA,WAAW,GAAG,gBAAgB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { RelayCloseCode, type RelayHostMessage } from './relay-protocol';
2
+ /** One end of a WebSocket at the relay. */
3
+ export interface RelayPeer {
4
+ send(text: string): void;
5
+ close(code: number, reason: string): void;
6
+ }
7
+ /** Where the room finds its connections: kept in memory, or in a Durable Object that sleeps between messages. */
8
+ export interface RelayPeers {
9
+ host(): RelayPeer | undefined;
10
+ client(channel: string): RelayPeer | undefined;
11
+ clients(): RelayPeer[];
12
+ }
13
+ /** Devices at once on one host. */
14
+ export declare const RELAY_MAX_CLIENTS = 16;
15
+ /**
16
+ * The relay's whole job for one host: pass what a device sends to the host on the device's channel, and
17
+ * what the host sends on a channel to that device. It holds no state of its own, so that it runs the same
18
+ * in `ta relay` and in a Durable Object.
19
+ */
20
+ export declare class RelayRoom {
21
+ protected readonly peers: RelayPeers;
22
+ constructor(peers: RelayPeers);
23
+ /** False when the device cannot stay: the host is away or has too many devices; close it with the code. */
24
+ clientOpened(channel: string): RelayCloseCode | undefined;
25
+ fromClient(channel: string, text: string): void;
26
+ clientClosed(channel: string): void;
27
+ /** What the host sends that is not a message of the protocol is dropped. */
28
+ fromHost(text: string): void;
29
+ hostClosed(): void;
30
+ protected toHost(host: RelayPeer, message: RelayHostMessage): void;
31
+ }
32
+ //# sourceMappingURL=relay-room.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-room.d.ts","sourceRoot":"","sources":["../../src/common/relay-room.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACtB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C;AAED,iHAAiH;AACjH,MAAM,WAAW,UAAU;IACvB,IAAI,IAAI,SAAS,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IAC/C,OAAO,IAAI,SAAS,EAAE,CAAC;CAC1B;AAED,mCAAmC;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;GAIG;AACH,qBAAa,SAAS;IACN,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU;IAAhD,YAA+B,KAAK,EAAE,UAAU,EAAI;IAEpD,2GAA2G;IAC3G,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAUxD;IAED,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAK9C;IAED,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAKlC;IAED,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAa3B;IAED,UAAU,IAAI,IAAI,CAIjB;IAED,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAEjE;CACJ"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayRoom = exports.RELAY_MAX_CLIENTS = void 0;
4
+ const relay_protocol_1 = require("./relay-protocol");
5
+ /** Devices at once on one host. */
6
+ exports.RELAY_MAX_CLIENTS = 16;
7
+ /**
8
+ * The relay's whole job for one host: pass what a device sends to the host on the device's channel, and
9
+ * what the host sends on a channel to that device. It holds no state of its own, so that it runs the same
10
+ * in `ta relay` and in a Durable Object.
11
+ */
12
+ class RelayRoom {
13
+ constructor(peers) {
14
+ this.peers = peers;
15
+ }
16
+ /** False when the device cannot stay: the host is away or has too many devices; close it with the code. */
17
+ clientOpened(channel) {
18
+ const host = this.peers.host();
19
+ if (!host) {
20
+ return relay_protocol_1.RelayCloseCode.HOST_OFFLINE;
21
+ }
22
+ if (this.peers.clients().length > exports.RELAY_MAX_CLIENTS) {
23
+ return relay_protocol_1.RelayCloseCode.FULL;
24
+ }
25
+ this.toHost(host, { t: 'open', ch: channel });
26
+ return undefined;
27
+ }
28
+ fromClient(channel, text) {
29
+ const host = this.peers.host();
30
+ if (host) {
31
+ this.toHost(host, { t: 'data', ch: channel, d: text });
32
+ }
33
+ }
34
+ clientClosed(channel) {
35
+ const host = this.peers.host();
36
+ if (host) {
37
+ this.toHost(host, { t: 'close', ch: channel });
38
+ }
39
+ }
40
+ /** What the host sends that is not a message of the protocol is dropped. */
41
+ fromHost(text) {
42
+ let message;
43
+ try {
44
+ message = JSON.parse(text);
45
+ }
46
+ catch (_a) {
47
+ return;
48
+ }
49
+ const client = typeof message.ch === 'string' ? this.peers.client(message.ch) : undefined;
50
+ if (message.t === 'data' && typeof message.d === 'string') {
51
+ client === null || client === void 0 ? void 0 : client.send(message.d);
52
+ }
53
+ else if (message.t === 'close') {
54
+ client === null || client === void 0 ? void 0 : client.close(relay_protocol_1.RelayCloseCode.CLOSED_BY_HOST, 'Closed by the host.');
55
+ }
56
+ }
57
+ hostClosed() {
58
+ for (const client of this.peers.clients()) {
59
+ client.close(relay_protocol_1.RelayCloseCode.HOST_OFFLINE, 'The host went offline.');
60
+ }
61
+ }
62
+ toHost(host, message) {
63
+ host.send(JSON.stringify(message));
64
+ }
65
+ }
66
+ exports.RelayRoom = RelayRoom;
67
+ //# sourceMappingURL=relay-room.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-room.js","sourceRoot":"","sources":["../../src/common/relay-room.ts"],"names":[],"mappings":";;;AAAA,qDAAyE;AAezE,mCAAmC;AACtB,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;GAIG;AACH;IACI,YAA+B,KAAiB;qBAAjB,KAAK;IAAe,CAAC;IAEpD,2GAA2G;IAC3G,YAAY,CAAC,OAAe;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,OAAO,+BAAc,CAAC,YAAY,CAAC;QACvC,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,QAAA,iBAAiB,EAAE,CAAC;YAClD,OAAO,+BAAc,CAAC,IAAI,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9C,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,UAAU,CAAC,OAAe,EAAE,IAAY;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI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CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YACxC,MAAM,CAAC,KAAK,CAAC,+BAAc,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAC;QACxE,CAAC;IACL,CAAC;IAES,MAAM,CAAC,IAAe,EAAE,OAAyB;QACvD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACvC,CAAC;CACJ"}
@@ -0,0 +1,39 @@
1
+ import { RelayCipher } from './relay-cipher';
2
+ import { type RelayPairing } from './relay-pairing';
3
+ /**
4
+ * A WebSocket to ta serve through a relay, for a paired device: it says hello, checks that the host has
5
+ * the device's key, and then seals and opens every message. It behaves as much like a WebSocket as
6
+ * TaConnection needs: `readyState`, `send`, `close` and the four handlers.
7
+ */
8
+ export declare class RelaySocket {
9
+ protected readonly pairing: RelayPairing;
10
+ static readonly CONNECTING = 0;
11
+ static readonly OPEN = 1;
12
+ static readonly CLOSING = 2;
13
+ static readonly CLOSED = 3;
14
+ /** The close code when the host does not know the device, or does not show its key. */
15
+ static readonly REFUSED = 4403;
16
+ onopen: (() => void) | null;
17
+ onmessage: ((message: {
18
+ data: string;
19
+ }) => void) | null;
20
+ onclose: ((event: {
21
+ code: number;
22
+ reason: string;
23
+ }) => void) | null;
24
+ onerror: ((event: unknown) => void) | null;
25
+ protected state: number;
26
+ protected code?: number;
27
+ protected cipher?: RelayCipher;
28
+ protected readonly socket: WebSocket;
29
+ protected readonly nonce: Uint8Array<ArrayBufferLike>;
30
+ constructor(pairing: RelayPairing);
31
+ get readyState(): number;
32
+ /** Why it closed, once it has. */
33
+ get closeCode(): number | undefined;
34
+ send(text: string): void;
35
+ close(code?: number, reason?: string): void;
36
+ protected receive(text: string): Promise<void>;
37
+ protected finish(code: number, reason: string): void;
38
+ }
39
+ //# sourceMappingURL=relay-socket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-socket.d.ts","sourceRoot":"","sources":["../../src/common/relay-soc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