wire-mesh-core 2.0.1 → 2.0.2
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.
|
@@ -13,6 +13,10 @@ function randomTokenId() {
|
|
|
13
13
|
crypto.getRandomValues(bytes);
|
|
14
14
|
return bytes;
|
|
15
15
|
}
|
|
16
|
+
/** Stops a pending timer from keeping the process alive, where the runtime has that notion. Node's setTimeout returns an object with unref(); a browser's or a Worker's returns a number, which has nothing to unref and must not be called as if it did. */
|
|
17
|
+
function unrefIfSupported(handle) {
|
|
18
|
+
if (typeof handle === "object" && handle !== null && "unref" in handle && typeof handle.unref === "function") Reflect.apply(handle.unref, handle, []);
|
|
19
|
+
}
|
|
16
20
|
/**
|
|
17
21
|
* Builds a capability-request command per management.cddl. The outer `manage-command.verb` is the capability string itself -- the same value as this map's own `params.capability` field -- never a generic literal: capability-verb's own CDDL grammar is a closed alternation of colon-delimited `domain:noun` regexes (spec/tokens.cddl), so a bare literal like "capability" could never satisfy it, and routing by capability (the same way room.send/room.join already share the ROOM_MEMBER_CAPABILITY outer verb) is how a receiver's own per-capability handler knows which grant this ask is even for. `params.verb` is the fixed "capability.request" marker that distinguishes this ask from any other verb sharing the same outer capability (mirroring room.send/room.join's own inner `params.verb` split under one shared outer verb). `valid-until`, when given, bounds how long this ask is worth granting (wire-mesh#82) -- a receiver refuses outright once its own clock has passed it, rather than presenting a stale ask to a human for approval.
|
|
18
22
|
*/
|
|
@@ -69,7 +73,7 @@ function createCapabilityRequestHandler(options) {
|
|
|
69
73
|
message: "no decision within the capability-request timeout"
|
|
70
74
|
}).catch(() => void 0);
|
|
71
75
|
}, options.timeoutMs);
|
|
72
|
-
timeoutHandle
|
|
76
|
+
unrefIfSupported(timeoutHandle);
|
|
73
77
|
options.onRequest({
|
|
74
78
|
scope: incoming.scope,
|
|
75
79
|
requesterDevice: options.bearerDevice,
|
|
@@ -12,6 +12,10 @@ function randomTokenId() {
|
|
|
12
12
|
crypto.getRandomValues(bytes);
|
|
13
13
|
return bytes;
|
|
14
14
|
}
|
|
15
|
+
/** Stops a pending timer from keeping the process alive, where the runtime has that notion. Node's setTimeout returns an object with unref(); a browser's or a Worker's returns a number, which has nothing to unref and must not be called as if it did. */
|
|
16
|
+
function unrefIfSupported(handle) {
|
|
17
|
+
if (typeof handle === "object" && handle !== null && "unref" in handle && typeof handle.unref === "function") Reflect.apply(handle.unref, handle, []);
|
|
18
|
+
}
|
|
15
19
|
/**
|
|
16
20
|
* Builds a capability-request command per management.cddl. The outer `manage-command.verb` is the capability string itself -- the same value as this map's own `params.capability` field -- never a generic literal: capability-verb's own CDDL grammar is a closed alternation of colon-delimited `domain:noun` regexes (spec/tokens.cddl), so a bare literal like "capability" could never satisfy it, and routing by capability (the same way room.send/room.join already share the ROOM_MEMBER_CAPABILITY outer verb) is how a receiver's own per-capability handler knows which grant this ask is even for. `params.verb` is the fixed "capability.request" marker that distinguishes this ask from any other verb sharing the same outer capability (mirroring room.send/room.join's own inner `params.verb` split under one shared outer verb). `valid-until`, when given, bounds how long this ask is worth granting (wire-mesh#82) -- a receiver refuses outright once its own clock has passed it, rather than presenting a stale ask to a human for approval.
|
|
17
21
|
*/
|
|
@@ -68,7 +72,7 @@ function createCapabilityRequestHandler(options) {
|
|
|
68
72
|
message: "no decision within the capability-request timeout"
|
|
69
73
|
}).catch(() => void 0);
|
|
70
74
|
}, options.timeoutMs);
|
|
71
|
-
timeoutHandle
|
|
75
|
+
unrefIfSupported(timeoutHandle);
|
|
72
76
|
options.onRequest({
|
|
73
77
|
scope: incoming.scope,
|
|
74
78
|
requesterDevice: options.bearerDevice,
|