transport-io 0.12.0 → 0.12.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/dist/index.js CHANGED
@@ -15,5 +15,5 @@ export { createServer, Server, } from './server.js';
15
15
  * `changeset version` moves the manifest, so this moves in the same commit - which the test
16
16
  * enforces rather than trusting anyone to remember.
17
17
  */
18
- export const VERSION = '0.12.0';
18
+ export const VERSION = '0.12.1';
19
19
  //# sourceMappingURL=index.js.map
@@ -39,5 +39,12 @@ export declare function probe(target: string, budgetMs?: number): Promise<ProbeO
39
39
  * that listens only on UDP looks exactly like this and is healthy. `skipped` is the message
40
40
  * as it always was.
41
41
  */
42
+ /**
43
+ * A URL as an error may print it: the origin and the path, never the query. The query is
44
+ * where a browser puts a token for `authorize`, since a WebTransport request carries nothing
45
+ * else, and an error's message ends up in logs, in error trackers, and now and then on a
46
+ * page. It named the whole URL until an application printed `lastError.message` in a header.
47
+ */
48
+ export declare function printable(url: string): string;
42
49
  export declare function handshakeFailure(url: string, target: string | undefined, outcome: ProbeOutcome, cause: unknown): TransportError;
43
50
  //# sourceMappingURL=probe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/transport/probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,UAAU,8BAA8B,CAAA;AAErD,qEAAqE;AACrE,eAAO,MAAM,eAAe,OAAO,CAAA;AAEnC,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,CAAA;AAEhE,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM3D;AAED;;;;;;GAMG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAwB,GACjC,OAAO,CAAC,YAAY,CAAC,CAevB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,OAAO,GACb,cAAc,CA2BhB"}
1
+ {"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/transport/probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,UAAU,8BAA8B,CAAA;AAErD,qEAAqE;AACrE,eAAO,MAAM,eAAe,OAAO,CAAA;AAEnC,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,CAAA;AAEhE,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM3D;AAED;;;;;;GAMG;AACH,wBAAsB,KAAK,CACzB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAwB,GACjC,OAAO,CAAC,YAAY,CAAC,CAevB;AAED;;;;;;;GAOG;AACH;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7C;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,OAAO,GACb,cAAc,CA2BhB"}
@@ -62,18 +62,33 @@ export async function probe(target, budgetMs = PROBE_BUDGET_MS) {
62
62
  * that listens only on UDP looks exactly like this and is healthy. `skipped` is the message
63
63
  * as it always was.
64
64
  */
65
+ /**
66
+ * A URL as an error may print it: the origin and the path, never the query. The query is
67
+ * where a browser puts a token for `authorize`, since a WebTransport request carries nothing
68
+ * else, and an error's message ends up in logs, in error trackers, and now and then on a
69
+ * page. It named the whole URL until an application printed `lastError.message` in a header.
70
+ */
71
+ export function printable(url) {
72
+ try {
73
+ const parsed = new URL(url);
74
+ return `${parsed.origin}${parsed.pathname}`;
75
+ }
76
+ catch {
77
+ return url.split(/[?#]/)[0] ?? url;
78
+ }
79
+ }
65
80
  export function handshakeFailure(url, target, outcome, cause) {
66
81
  if (outcome === 'answered' && target !== undefined) {
67
- return new TransportError('WT_UDP_UNREACHABLE', `the server at ${new URL(target).origin} answers over HTTPS but the WebTransport handshake to ${url} failed`, 'The server is running and its certificate is trusted, so only the QUIC path is failing. ' +
82
+ return new TransportError('WT_UDP_UNREACHABLE', `the server at ${new URL(target).origin} answers over HTTPS but the WebTransport handshake to ${printable(url)} failed`, 'The server is running and its certificate is trusted, so only the QUIC path is failing. ' +
68
83
  'Usually UDP to it is blocked: a firewall or VPN on this network, or a platform in front ' +
69
84
  'of the server with no UDP ingress. The site works over TCP and nothing in this library ' +
70
85
  'routes around that. If you pin a certificate, a wrong or expired hash fails the same ' +
71
86
  'way, so rule that out on a network where it worked before.', cause);
72
87
  }
73
88
  const unanswered = outcome === 'unanswered' && target !== undefined
74
- ? `, and ${target} did not answer over HTTPS within ${PROBE_BUDGET_MS} ms`
89
+ ? `, and ${printable(target)} did not answer over HTTPS within ${PROBE_BUDGET_MS} ms`
75
90
  : '';
76
- return new TransportError('WT_HANDSHAKE_FAILED', `the WebTransport handshake to ${url} failed${unanswered}`, 'The browser reports one error for every cause here, so check in this order: (1) the ' +
91
+ return new TransportError('WT_HANDSHAKE_FAILED', `the WebTransport handshake to ${printable(url)} failed${unanswered}`, 'The browser reports one error for every cause here, so check in this order: (1) the ' +
77
92
  'server is running and its UDP port is reachable; (2) if you pinned a certificate, ' +
78
93
  'that it has not passed its 14-day limit; (3) that the hash matches the certificate ' +
79
94
  'the server is serving - it is SHA-256 over the DER, not over cert.pem. ' +
@@ -1 +1 @@
1
- {"version":3,"file":"probe.js","sourceRoot":"","sources":["../../src/transport/probe.ts"],"names":[],"m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oF;QACpF,qFAAqF;QACrF,yEAAyE;QACzE,iEAAiE,EACnE,KAAK,CACN,CAAA;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/transport/websocket.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C,MAAM,WAAW,uBAAuB;IACtC,sFAAsF;IACtF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2BzF"}
1
+ {"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/transport/websocket.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C,MAAM,WAAW,uBAAuB;IACtC,sFAAsF;IACtF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2BzF"}
@@ -6,6 +6,7 @@
6
6
  * exported from the package, as the transport seam is not (D21, D127).
7
7
  */
8
8
  import { TransportError } from '../errors.js';
9
+ import { printable } from './probe.js';
9
10
  import { WebSocketConnection } from './websocket-connection.js';
10
11
  /**
11
12
  * The fallback connector, for `withFallback`. Runtime-neutral: it reads the global
@@ -21,7 +22,7 @@ export async function connectWebSocket(opts) {
21
22
  await new Promise((resolve, reject) => {
22
23
  socket.addEventListener('open', () => resolve());
23
24
  socket.addEventListener('close', (ev) => {
24
- reject(new TransportError('WT_HANDSHAKE_FAILED', `the WebSocket handshake to ${opts.url} failed, close code ${ev.code}`, 'Check that the server is running, that its WebSocket listener is reachable over TCP, and that a wss:// certificate is one this platform trusts.'));
25
+ reject(new TransportError('WT_HANDSHAKE_FAILED', `the WebSocket handshake to ${printable(opts.url)} failed, close code ${ev.code}`, 'Check that the server is running, that its WebSocket listener is reachable over TCP, and that a wss:// certificate is one this platform trusts.'));
25
26
  });
26
27
  socket.addEventListener('error', () => {
27
28
  // The close event that follows carries the code; rejecting here would report twice.
@@ -1 +1 @@
1
- {"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../src/transport/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAmB,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAOhF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAA6B;IAClE,MAAM,EAAE,GAAI,UAA8D,CAAC,SAAS,CAAA;IACpF,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,MAAM,IAAI,cAAc,CACtB,eAAe,EACf,+BAA+B,EAC/B,0CAA0C,CAC3C,CAAA;IACH,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,CAAC,UAAU,GAAG,aAAa,CAAA;IACjC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;QAChD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE;YACtC,MAAM,CACJ,IAAI,cAAc,CAChB,qBAAqB,EACrB,8BAA8B,IAAI,CAAC,GAAG,uBAAuB,EAAE,CAAC,IAAI,EAAE,EACtE,iJAAiJ,CAClJ,CACF,CAAA;QACH,CAAC,CAAC,CAAA;QACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACpC,oFAAoF;QACtF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;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,CAAA;AACxC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "transport-io",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Real-time apps over WebTransport. Two lanes, one contract, no fallback.",
5
5
  "license": "MIT",
6
6
  "type": "module",