@claxedo/workspace-relay-protocol 0.10.0 → 0.10.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.d.ts +13 -0
- package/dist/index.mjs +26 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,19 @@ export declare const SESSION_TURN_LEASE_TTL_MS = 60000;
|
|
|
9
9
|
* admits only this number, and a lower one is never promoted.
|
|
10
10
|
*/
|
|
11
11
|
export declare const CURRENT_CHANNEL_IDENTITY_VERSION = 1;
|
|
12
|
+
/**
|
|
13
|
+
* A close code a server may send: 1000–4999 except 1004, 1005 and 1006, which
|
|
14
|
+
* only ever describe a close and which workerd's `close()` refuses; anything
|
|
15
|
+
* else becomes `fallback`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function closeCode(code: number | undefined, fallback?: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* A WebSocket close reason cut to the 123 UTF-8 bytes a close frame carries,
|
|
20
|
+
* at a character boundary. A WHATWG or Node `ws` socket's `close()` throws past
|
|
21
|
+
* it, and workerd's does from compatibility date 2026-03-03
|
|
22
|
+
* (`websocket_close_reason_byte_limit`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function closeReason(reason: unknown): string;
|
|
12
25
|
/**
|
|
13
26
|
* What a Runtime Access Token's scope reaches, asked of the runtime path a
|
|
14
27
|
* request names. A token with no session is the workspace owner's and reaches
|
package/dist/index.mjs
CHANGED
|
@@ -245,6 +245,30 @@ var TUNNEL_PROTOCOL_VERSION = 1;
|
|
|
245
245
|
var SESSION_STREAM_LEASE_TTL_MS = 15000;
|
|
246
246
|
var SESSION_TURN_LEASE_TTL_MS = 60000;
|
|
247
247
|
var CURRENT_CHANNEL_IDENTITY_VERSION = 1;
|
|
248
|
+
function closeCode(code, fallback = 1011) {
|
|
249
|
+
if (code === undefined)
|
|
250
|
+
return fallback;
|
|
251
|
+
if (code >= 1000 && code <= 4999 && ![1004, 1005, 1006].includes(code))
|
|
252
|
+
return code;
|
|
253
|
+
return fallback;
|
|
254
|
+
}
|
|
255
|
+
var CLOSE_REASON_MAX_BYTES = 123;
|
|
256
|
+
function closeReason(reason) {
|
|
257
|
+
if (typeof reason !== "string")
|
|
258
|
+
return "";
|
|
259
|
+
const encoder = new TextEncoder;
|
|
260
|
+
if (encoder.encode(reason).byteLength <= CLOSE_REASON_MAX_BYTES)
|
|
261
|
+
return reason;
|
|
262
|
+
let cut = "";
|
|
263
|
+
let bytes = 0;
|
|
264
|
+
for (const char of reason) {
|
|
265
|
+
bytes += encoder.encode(char).byteLength;
|
|
266
|
+
if (bytes > CLOSE_REASON_MAX_BYTES)
|
|
267
|
+
return cut;
|
|
268
|
+
cut += char;
|
|
269
|
+
}
|
|
270
|
+
return cut;
|
|
271
|
+
}
|
|
248
272
|
function sessionScopeReaches(sessionScope, path, search) {
|
|
249
273
|
if (sessionScope === undefined)
|
|
250
274
|
return true;
|
|
@@ -372,6 +396,8 @@ export {
|
|
|
372
396
|
createStaticTokenVerifier,
|
|
373
397
|
createOidcTokenVerifier,
|
|
374
398
|
createHttpTokenVerifier,
|
|
399
|
+
closeReason,
|
|
400
|
+
closeCode,
|
|
375
401
|
TokenVerifierError,
|
|
376
402
|
TUNNEL_PROTOCOL_VERSION,
|
|
377
403
|
SESSION_TURN_LEASE_TTL_MS,
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"name": "@claxedo/workspace-relay-protocol",
|
|
36
|
-
"version": "0.10.
|
|
36
|
+
"version": "0.10.1",
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "bun scripts/build.ts",
|
|
39
39
|
"prepublishOnly": "npm run build",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"test": "mkdir -p .artifacts/unit && node ../../script/test-deadline.mjs bun test src --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@claxedo/helpers": "0.2.
|
|
44
|
+
"@claxedo/helpers": "0.2.1",
|
|
45
45
|
"jose": "6.0.11"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|