wire-mesh-core 3.7.1 → 3.8.0
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/adapters/byte-stream-connection.d.cts +2 -2
- package/dist/adapters/byte-stream-connection.d.mts +2 -2
- package/dist/adapters/frame-codec.d.cts +1 -1
- package/dist/adapters/frame-codec.d.mts +1 -1
- package/dist/adapters/node-identity.d.cts +2 -2
- package/dist/adapters/node-identity.d.mts +2 -2
- package/dist/adapters/tcp-transport.d.cts +1 -1
- package/dist/adapters/tcp-transport.d.mts +1 -1
- package/dist/adapters/threshold-identity.d.cts +2 -2
- package/dist/adapters/threshold-identity.d.mts +2 -2
- package/dist/adapters/threshold-wasm.d.cts +1 -1
- package/dist/adapters/threshold-wasm.d.mts +1 -1
- package/dist/adapters/tls-transport.d.cts +1 -1
- package/dist/adapters/tls-transport.d.mts +1 -1
- package/dist/domain/advert-extension-policy.d.cts +1 -1
- package/dist/domain/advert-extension-policy.d.mts +1 -1
- package/dist/domain/bulk.d.cts +2 -2
- package/dist/domain/bulk.d.mts +2 -2
- package/dist/domain/capability-grant.cjs +1 -1
- package/dist/domain/capability-grant.d.cts +3 -3
- package/dist/domain/capability-grant.d.mts +3 -3
- package/dist/domain/capability-grant.mjs +1 -1
- package/dist/domain/capability-request.cjs +52 -4
- package/dist/domain/capability-request.d.cts +14 -3
- package/dist/domain/capability-request.d.mts +14 -3
- package/dist/domain/capability-request.mjs +52 -5
- package/dist/domain/coordinator-election.d.cts +1 -1
- package/dist/domain/coordinator-election.d.mts +1 -1
- package/dist/domain/data-sync.d.cts +2 -2
- package/dist/domain/data-sync.d.mts +2 -2
- package/dist/domain/device-id.d.cts +1 -1
- package/dist/domain/device-id.d.mts +1 -1
- package/dist/domain/direct-manage-request.d.cts +2 -2
- package/dist/domain/direct-manage-request.d.mts +2 -2
- package/dist/domain/gossip-expansion.d.cts +1 -1
- package/dist/domain/gossip-expansion.d.mts +1 -1
- package/dist/domain/grant-candidates.d.cts +1 -1
- package/dist/domain/grant-candidates.d.mts +1 -1
- package/dist/domain/handshake.d.cts +1 -1
- package/dist/domain/handshake.d.mts +1 -1
- package/dist/domain/hub-mailbox.d.cts +1 -1
- package/dist/domain/hub-mailbox.d.mts +1 -1
- package/dist/domain/mesh-session.cjs +1 -1
- package/dist/domain/mesh-session.d.cts +3 -3
- package/dist/domain/mesh-session.d.mts +3 -3
- package/dist/domain/mesh-session.mjs +1 -1
- package/dist/domain/notice-board.d.cts +3 -3
- package/dist/domain/notice-board.d.mts +3 -3
- package/dist/domain/path-trace.d.cts +1 -1
- package/dist/domain/path-trace.d.mts +1 -1
- package/dist/domain/peer-advert.d.cts +2 -2
- package/dist/domain/peer-advert.d.mts +2 -2
- package/dist/domain/relay-advert.d.cts +1 -1
- package/dist/domain/relay-advert.d.mts +1 -1
- package/dist/domain/relay-hub.d.cts +2 -2
- package/dist/domain/relay-hub.d.mts +2 -2
- package/dist/domain/relay-use-gate.d.cts +2 -2
- package/dist/domain/relay-use-gate.d.mts +2 -2
- package/dist/domain/revocation-view.cjs +1 -1
- package/dist/domain/revocation-view.d.cts +2 -2
- package/dist/domain/revocation-view.d.mts +2 -2
- package/dist/domain/revocation-view.mjs +1 -1
- package/dist/domain/room-rekey.d.cts +3 -3
- package/dist/domain/room-rekey.d.mts +3 -3
- package/dist/domain/room-token-verification.cjs +1 -1
- package/dist/domain/room-token-verification.d.cts +1 -1
- package/dist/domain/room-token-verification.d.mts +1 -1
- package/dist/domain/room-token-verification.mjs +1 -1
- package/dist/domain/room.d.cts +4 -4
- package/dist/domain/room.d.mts +4 -4
- package/dist/domain/shard-manifest.d.cts +1 -1
- package/dist/domain/shard-manifest.d.mts +1 -1
- package/dist/domain/threshold-subject.cjs +1 -1
- package/dist/domain/threshold-subject.mjs +1 -1
- package/dist/domain/tokens.cjs +3 -1
- package/dist/domain/tokens.d.cts +2 -2
- package/dist/domain/tokens.d.mts +2 -2
- package/dist/domain/tokens.mjs +2 -2
- package/dist/domain/topology-snapshot.d.cts +1 -1
- package/dist/domain/topology-snapshot.d.mts +1 -1
- package/dist/domain/topology.d.cts +1 -1
- package/dist/domain/topology.d.mts +1 -1
- package/dist/domain/webrtc-signaling.cjs +1 -1
- package/dist/domain/webrtc-signaling.d.cts +2 -2
- package/dist/domain/webrtc-signaling.d.mts +2 -2
- package/dist/domain/webrtc-signaling.mjs +1 -1
- package/dist/generated/protocol.cjs +4 -1
- package/dist/generated/protocol.d.cts +1 -1
- package/dist/generated/protocol.d.mts +1 -1
- package/dist/generated/protocol.mjs +4 -1
- package/dist/{identity-DVCNuFLG.d.cts → identity-DJbr96J3.d.cts} +1 -1
- package/dist/{identity-DcaYgjXT.d.mts → identity-ViYdZrIU.d.mts} +1 -1
- package/dist/ports/identity.d.cts +1 -1
- package/dist/ports/identity.d.mts +1 -1
- package/dist/ports/transport.d.cts +1 -1
- package/dist/ports/transport.d.mts +1 -1
- package/dist/{protocol-DCDae3z4.d.cts → protocol-BgR1e_NI.d.cts} +3 -0
- package/dist/{protocol-DCDae3z4.d.mts → protocol-BgR1e_NI.d.mts} +3 -0
- package/dist/{room-token-verification-CkGnFuQc.d.mts → room-token-verification-7zD4ib-A.d.mts} +2 -2
- package/dist/{room-token-verification-PSv4eQ1x.d.cts → room-token-verification-hFtBDZPO.d.cts} +2 -2
- package/dist/{tokens-DqFu7iMX.d.cts → tokens-BMWCnQEF.d.cts} +37 -5
- package/dist/{tokens-CMdWiRBb.mjs → tokens-D8JlTJNA.mjs} +175 -17
- package/dist/{tokens-CBiSYuzp.d.mts → tokens-DRkm_QOR.d.mts} +37 -5
- package/dist/{tokens-DSG3SDr8.cjs → tokens-tPJQ7Vzt.cjs} +186 -16
- package/dist/{transport-B0GywEzG.d.mts → transport-DP3hdehk.d.cts} +1 -1
- package/dist/{transport-DIXjoQKn.d.cts → transport-Dv_LTCsF.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Frame } from "../protocol-
|
|
2
|
-
import { t as Connection } from "../transport-
|
|
1
|
+
import { N as Frame } from "../protocol-BgR1e_NI.cjs";
|
|
2
|
+
import { t as Connection } from "../transport-DP3hdehk.cjs";
|
|
3
3
|
//#region src/adapters/byte-stream-connection.d.ts
|
|
4
4
|
/** The largest frame body a peer may announce in a length prefix, matching the 100 MiB the `ws` package applies to one message on the same hub, so a WebSocket peer and a byte-stream peer are bounded alike. Without a bound a peer-controlled 4 GiB prefix makes the reader buffer until memory runs out. */
|
|
5
5
|
export declare const MAX_FRAME_BYTES: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Frame } from "../protocol-
|
|
2
|
-
import { t as Connection } from "../transport-
|
|
1
|
+
import { N as Frame } from "../protocol-BgR1e_NI.mjs";
|
|
2
|
+
import { t as Connection } from "../transport-Dv_LTCsF.mjs";
|
|
3
3
|
//#region src/adapters/byte-stream-connection.d.ts
|
|
4
4
|
/** The largest frame body a peer may announce in a length prefix, matching the 100 MiB the `ws` package applies to one message on the same hub, so a WebSocket peer and a byte-stream peer are bounded alike. Without a bound a peer-controlled 4 GiB prefix makes the reader buffer until memory runs out. */
|
|
5
5
|
export declare const MAX_FRAME_BYTES: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, N as Frame, ht as RelayDataFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, N as Frame, ht as RelayDataFrame } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
//#region src/adapters/frame-codec.d.ts
|
|
3
3
|
export declare function messageFromFrame(frame: Frame): Uint8Array<ArrayBuffer>;
|
|
4
4
|
/** Wraps frame as a relay-data-frame's own opaque payload, stamping to-device when the caller knows which established pairing to address it to (wire-mesh#30) -- the outbound counterpart to tryDecodeFrame's own doc comment below, which describes the inbound side of the same relay-data envelope. Omitting toDevice leaves the frame unaddressed, which the receiving hub then routes via its own most-recently-established-pairing fallback. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, N as Frame, ht as RelayDataFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, N as Frame, ht as RelayDataFrame } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
//#region src/adapters/frame-codec.d.ts
|
|
3
3
|
export declare function messageFromFrame(frame: Frame): Uint8Array<ArrayBuffer>;
|
|
4
4
|
/** Wraps frame as a relay-data-frame's own opaque payload, stamping to-device when the caller knows which established pairing to address it to (wire-mesh#30) -- the outbound counterpart to tryDecodeFrame's own doc comment below, which describes the inbound side of the same relay-data envelope. Omitting toDevice leaves the frame unaddressed, which the receiving hub then routes via its own most-recently-established-pairing fallback. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as IdentityKey, D as DeviceId } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { B as IdentityKey, D as DeviceId } from "../protocol-BgR1e_NI.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-DJbr96J3.cjs";
|
|
3
3
|
import { webcrypto } from "node:crypto";
|
|
4
4
|
//#region src/adapters/node-identity.d.ts
|
|
5
5
|
export declare function deriveDeviceId(publicKey: Uint8Array): Promise<DeviceId>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as IdentityKey, D as DeviceId } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { B as IdentityKey, D as DeviceId } from "../protocol-BgR1e_NI.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-ViYdZrIU.mjs";
|
|
3
3
|
import { webcrypto } from "node:crypto";
|
|
4
4
|
//#region src/adapters/node-identity.d.ts
|
|
5
5
|
export declare function deriveDeviceId(publicKey: Uint8Array): Promise<DeviceId>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as Transport } from "../transport-
|
|
1
|
+
import { r as Transport } from "../transport-DP3hdehk.cjs";
|
|
2
2
|
//#region src/adapters/tcp-transport.d.ts
|
|
3
3
|
/** A Node net.Socket-based Transport: length-prefixed, CBOR-encoded frames over plain TCP -- matching Cascade's own transport shape, since interop with Cascade nodes is wire-mesh's stated goal. Framing (not TLS) is this adapter's own concern; a TLS-terminated variant is a separate adapter behind the same Transport contract. */
|
|
4
4
|
export declare function createTcpTransport(): Transport;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as Transport } from "../transport-
|
|
1
|
+
import { r as Transport } from "../transport-Dv_LTCsF.mjs";
|
|
2
2
|
//#region src/adapters/tcp-transport.d.ts
|
|
3
3
|
/** A Node net.Socket-based Transport: length-prefixed, CBOR-encoded frames over plain TCP -- matching Cascade's own transport shape, since interop with Cascade nodes is wire-mesh's stated goal. Framing (not TLS) is this adapter's own concern; a TLS-terminated variant is a separate adapter behind the same Transport contract. */
|
|
4
4
|
export declare function createTcpTransport(): Transport;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId } from "../protocol-BgR1e_NI.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-DJbr96J3.cjs";
|
|
3
3
|
import { DeviceKeyed } from "./threshold-wasm.cjs";
|
|
4
4
|
import { ThresholdSubject } from "../domain/threshold-subject.cjs";
|
|
5
5
|
//#region src/adapters/threshold-identity.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId } from "../protocol-BgR1e_NI.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-ViYdZrIU.mjs";
|
|
3
3
|
import { DeviceKeyed } from "./threshold-wasm.mjs";
|
|
4
4
|
import { ThresholdSubject } from "../domain/threshold-subject.mjs";
|
|
5
5
|
//#region src/adapters/threshold-identity.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
1
|
+
import { D as DeviceId } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
//#region src/adapters/threshold-wasm.d.ts
|
|
3
3
|
/** One `(deviceId, bytes)` pair -- the wasm boundary's own encoding of a map keyed by participant, since wasm-bindgen has no built-in `Map<Uint8Array, Uint8Array>` marshalling. */
|
|
4
4
|
export interface DeviceKeyed<T extends Uint8Array = Uint8Array<ArrayBuffer>> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
1
|
+
import { D as DeviceId } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
//#region src/adapters/threshold-wasm.d.ts
|
|
3
3
|
/** One `(deviceId, bytes)` pair -- the wasm boundary's own encoding of a map keyed by participant, since wasm-bindgen has no built-in `Map<Uint8Array, Uint8Array>` marshalling. */
|
|
4
4
|
export interface DeviceKeyed<T extends Uint8Array = Uint8Array<ArrayBuffer>> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { et as PeerAdvert } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
//#region src/domain/advert-extension-policy.d.ts
|
|
3
3
|
/** Whether one extension entry's value is one the hub will carry. Must be strict: a value with a field the validator did not expect is refused, since the point is that nothing unexpected is published. */
|
|
4
4
|
export type ExtensionValidator = (value: unknown) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { et as PeerAdvert } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
//#region src/domain/advert-extension-policy.d.ts
|
|
3
3
|
/** Whether one extension entry's value is one the hub will carry. Must be strict: a value with a field the validator did not expect is refused, since the point is that nothing unexpected is published. */
|
|
4
4
|
export type ExtensionValidator = (value: unknown) => boolean;
|
package/dist/domain/bulk.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, N as Frame, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { t as Connection } from "../transport-
|
|
1
|
+
import { D as DeviceId, N as Frame, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-BgR1e_NI.cjs";
|
|
2
|
+
import { t as Connection } from "../transport-DP3hdehk.cjs";
|
|
3
3
|
import { t as KeyValueStorage } from "../storage-B403CRyu.cjs";
|
|
4
4
|
import { IncomingManageRequest, MeshSession } from "./mesh-session.cjs";
|
|
5
5
|
//#region src/domain/bulk.d.ts
|
package/dist/domain/bulk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, N as Frame, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { t as Connection } from "../transport-
|
|
1
|
+
import { D as DeviceId, N as Frame, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-BgR1e_NI.mjs";
|
|
2
|
+
import { t as Connection } from "../transport-Dv_LTCsF.mjs";
|
|
3
3
|
import { t as KeyValueStorage } from "../storage-B403CRyu.mjs";
|
|
4
4
|
import { IncomingManageRequest, MeshSession } from "./mesh-session.mjs";
|
|
5
5
|
//#region src/domain/bulk.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_generated_protocol = require("../generated/protocol.cjs");
|
|
3
3
|
const require_token_scope = require("../token-scope-CxHXTT3u.cjs");
|
|
4
|
-
const require_tokens = require("../tokens-
|
|
4
|
+
const require_tokens = require("../tokens-tPJQ7Vzt.cjs");
|
|
5
5
|
//#region src/domain/capability-grant.ts
|
|
6
6
|
/**
|
|
7
7
|
* The generic, capability-agnostic capability-grant primitive (wire-mesh#117, spec/management.cddl) -- the unsolicited push counterpart to capability-request.ts's own ask/response primitive. Where capability-request lifts core/room's room.join shape (a pull: the requester asks, the owner mints and returns a grant on the same response) out of that one domain, capability-grant lifts room.invite's own shape (a push: the owner mints unprompted and delivers the grant in the request itself, since there is no approval round-trip to carry it back) the same way. core/room's own room-client.ts is the reference consumer: it builds sendRoomInvite as a thin wrapper over sendCapabilityGrant below, and wires createRoomRouter's dispatch onto createCapabilityGrantHandler for the receiving side.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-BgR1e_NI.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-DJbr96J3.cjs";
|
|
3
3
|
import { t as Clock } from "../clock-DiSx-WKM.cjs";
|
|
4
4
|
import { IncomingManageRequest, ManageOutcome, MeshSession } from "./mesh-session.cjs";
|
|
5
|
-
import {
|
|
5
|
+
import { o as RevocationCheck } from "../tokens-BMWCnQEF.cjs";
|
|
6
6
|
//#region src/domain/capability-grant.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Builds a capability-grant command per management.cddl. The outer `manage-command.verb` is the capability string itself, the identical convention capability-request.ts's own buildCapabilityRequestCommand already establishes -- a receiver's per-capability handler is how it knows which grant this push is even for. `params.verb` is the fixed "capability.grant" marker. No scope or invitee field: manage-request-frame's own top-level scope already carries the former, and the request's own destination already carries the latter -- naming either a second time inside params could only ever disagree with the fact it duplicates.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-BgR1e_NI.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-ViYdZrIU.mjs";
|
|
3
3
|
import { t as Clock } from "../clock-DiSx-WKM.mjs";
|
|
4
4
|
import { IncomingManageRequest, ManageOutcome, MeshSession } from "./mesh-session.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { o as RevocationCheck } from "../tokens-DRkm_QOR.mjs";
|
|
6
6
|
//#region src/domain/capability-grant.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Builds a capability-grant command per management.cddl. The outer `manage-command.verb` is the capability string itself, the identical convention capability-request.ts's own buildCapabilityRequestCommand already establishes -- a receiver's per-capability handler is how it knows which grant this push is even for. `params.verb` is the fixed "capability.grant" marker. No scope or invitee field: manage-request-frame's own top-level scope already carries the former, and the request's own destination already carries the latter -- naming either a second time inside params could only ever disagree with the fact it duplicates.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { capabilityGrantSchema } from "../generated/protocol.mjs";
|
|
2
2
|
import { n as scopeNarrows } from "../token-scope-Z4bmci4M.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { s as verifyCapabilityToken } from "../tokens-D8JlTJNA.mjs";
|
|
4
4
|
//#region src/domain/capability-grant.ts
|
|
5
5
|
/**
|
|
6
6
|
* The generic, capability-agnostic capability-grant primitive (wire-mesh#117, spec/management.cddl) -- the unsolicited push counterpart to capability-request.ts's own ask/response primitive. Where capability-request lifts core/room's room.join shape (a pull: the requester asks, the owner mints and returns a grant on the same response) out of that one domain, capability-grant lifts room.invite's own shape (a push: the owner mints unprompted and delivers the grant in the request itself, since there is no approval round-trip to carry it back) the same way. core/room's own room-client.ts is the reference consumer: it builds sendRoomInvite as a thin wrapper over sendCapabilityGrant below, and wires createRoomRouter's dispatch onto createCapabilityGrantHandler for the receiving side.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_generated_protocol = require("../generated/protocol.cjs");
|
|
3
|
-
const
|
|
3
|
+
const require_token_scope = require("../token-scope-CxHXTT3u.cjs");
|
|
4
|
+
const require_tokens = require("../tokens-tPJQ7Vzt.cjs");
|
|
4
5
|
//#region src/domain/capability-request.ts
|
|
5
6
|
/**
|
|
6
7
|
* The generic, capability-agnostic capability-request / capability-grant-ok primitive (wire-mesh#78, spec/management.cddl). Lifts core/room's own room.join shape -- an ungated ask, held open, a human (or any other domain-supplied decision) accepts or refuses, acceptance mints and returns a token on the same response -- out of that one domain so any capability can reuse it, not just room:member. core/room's own room-client.ts is the reference consumer: it rewires requestToJoin/createRoomRouter's room.join handling onto requestCapability/createCapabilityRequestHandler below, supplying room-specific extension fields (its member list) through this module's own extensions mechanism rather than this module knowing anything about rooms.
|
|
@@ -35,13 +36,48 @@ function buildCapabilityRequestCommand(capability, validUntil) {
|
|
|
35
36
|
*
|
|
36
37
|
* targetDevice and timeoutMs forward directly to MeshSession.sendManageRequest's own identically-named parameters (relay routing and a requester-side give-up bound respectively -- wire-mesh#80 is already implemented there, not duplicated here). validUntil, when given, is attached to the request itself (wire-mesh#82) so a slow-to-answer receiver -- or a relay/facilitator forwarding this request on the caller's behalf -- can refuse or drop a now-stale ask outright rather than holding or forwarding it.
|
|
37
38
|
*/
|
|
38
|
-
async function requestCapability(session, capability, scope, targetDevice, timeoutMs, validUntil) {
|
|
39
|
-
const outcome = await session.sendManageRequest(buildCapabilityRequestCommand(capability, validUntil), scope, targetDevice,
|
|
39
|
+
async function requestCapability(session, capability, scope, targetDevice, timeoutMs, validUntil, requestToken) {
|
|
40
|
+
const outcome = await session.sendManageRequest(buildCapabilityRequestCommand(capability, validUntil), scope, targetDevice, requestToken, timeoutMs);
|
|
40
41
|
if (outcome.result !== "ok") throw new Error(`capability request for "${capability}" was refused (${outcome.code})`);
|
|
41
42
|
const parsed = require_generated_protocol.capabilityGrantOkSchema.safeParse(outcome);
|
|
42
43
|
if (!parsed.success) throw new Error(`capability request for "${capability}" response was malformed`);
|
|
43
44
|
return parsed.data;
|
|
44
45
|
}
|
|
46
|
+
/** The capability verb of a request-permission (wire-mesh#324): the right to ask for a capability, grantable and delegable like any other. */
|
|
47
|
+
const MANAGE_REQUEST_CAPABILITY = "manage:request";
|
|
48
|
+
/** The request-permission gate (wire-mesh#324): the incoming request must present a manage:request token naming this requester as bearer, matching this capability when the token names one, and covering the request's own scope. A wrong token is an ordinary manage-error, never an exception -- the same convention every other refusal here already follows. */
|
|
49
|
+
async function checkRequestPermission(incoming, options) {
|
|
50
|
+
if (incoming.token === void 0) return {
|
|
51
|
+
ok: false,
|
|
52
|
+
code: "token_required"
|
|
53
|
+
};
|
|
54
|
+
if (options.revocation === void 0) throw new Error("requireRequestToken needs a revocation view on the handler options");
|
|
55
|
+
const verdict = await require_tokens.verifyCapabilityToken(incoming.token, {
|
|
56
|
+
identity: options.identity,
|
|
57
|
+
clock: options.clock,
|
|
58
|
+
revocation: options.revocation,
|
|
59
|
+
expectedBearer: options.bearerDevice,
|
|
60
|
+
...options.extraPredicateResolvers !== void 0 ? { extraPredicateResolvers: options.extraPredicateResolvers } : {}
|
|
61
|
+
});
|
|
62
|
+
if (!verdict.ok) return {
|
|
63
|
+
ok: false,
|
|
64
|
+
code: verdict.reason
|
|
65
|
+
};
|
|
66
|
+
if (verdict.claims.capability !== "manage:request") return {
|
|
67
|
+
ok: false,
|
|
68
|
+
code: "capability_mismatch"
|
|
69
|
+
};
|
|
70
|
+
const requestsCapability = verdict.claims["requests-capability"];
|
|
71
|
+
if (requestsCapability !== void 0 && requestsCapability !== options.capability) return {
|
|
72
|
+
ok: false,
|
|
73
|
+
code: "capability_mismatch"
|
|
74
|
+
};
|
|
75
|
+
if (!require_token_scope.scopeNarrows(verdict.claims.scope, incoming.scope)) return {
|
|
76
|
+
ok: false,
|
|
77
|
+
code: "scope_mismatch"
|
|
78
|
+
};
|
|
79
|
+
return { ok: true };
|
|
80
|
+
}
|
|
45
81
|
/**
|
|
46
82
|
* Builds a reusable handler for one capability's incoming capability-requests. The returned function is the generic counterpart to room-client.ts's own (now capability-specific) handleRoomJoin: given one IncomingManageRequest, it refuses a request for the wrong capability or a malformed payload as `{result:"error", code:"malformed"}`, refuses an already-expired request (per its own `valid-until`, wire-mesh#82) as `{result:"error", code:"expired"}` without ever invoking onRequest, otherwise arms the receiver-side timeout described on CreateCapabilityRequestHandlerOptions.timeoutMs and calls onRequest so the domain can accept (minting a fresh token via mintCapabilityToken and responding `{result:"ok", "granted-token": token, ...extensions}`) or reject (an ordinary manage-error) via the event's own decide().
|
|
47
83
|
*/
|
|
@@ -55,7 +91,18 @@ function createCapabilityRequestHandler(options) {
|
|
|
55
91
|
});
|
|
56
92
|
return;
|
|
57
93
|
}
|
|
58
|
-
const
|
|
94
|
+
const params = parsed.data;
|
|
95
|
+
if (options.requireRequestToken === true) {
|
|
96
|
+
const verdict = await checkRequestPermission(incoming, options);
|
|
97
|
+
if (!verdict.ok) {
|
|
98
|
+
await incoming.respond({
|
|
99
|
+
result: "error",
|
|
100
|
+
code: verdict.code
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const validUntil = params["valid-until"];
|
|
59
106
|
if (validUntil !== void 0 && validUntil <= options.clock.now()) {
|
|
60
107
|
await incoming.respond({
|
|
61
108
|
result: "error",
|
|
@@ -117,6 +164,7 @@ function createCapabilityRequestHandler(options) {
|
|
|
117
164
|
};
|
|
118
165
|
}
|
|
119
166
|
//#endregion
|
|
167
|
+
exports.MANAGE_REQUEST_CAPABILITY = MANAGE_REQUEST_CAPABILITY;
|
|
120
168
|
exports.buildCapabilityRequestCommand = buildCapabilityRequestCommand;
|
|
121
169
|
exports.createCapabilityRequestHandler = createCapabilityRequestHandler;
|
|
122
170
|
exports.requestCapability = requestCapability;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, u as CapabilityGrantOk } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken, u as CapabilityGrantOk } from "../protocol-BgR1e_NI.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-DJbr96J3.cjs";
|
|
3
3
|
import { t as Clock } from "../clock-DiSx-WKM.cjs";
|
|
4
4
|
import { IncomingManageRequest, MeshSession } from "./mesh-session.cjs";
|
|
5
|
+
import { b as ConditionsContext, o as RevocationCheck, x as TokenDelegateHandler } from "../tokens-BMWCnQEF.cjs";
|
|
5
6
|
//#region src/domain/capability-request.d.ts
|
|
6
7
|
/**
|
|
7
8
|
* 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.
|
|
@@ -12,7 +13,9 @@ export declare function buildCapabilityRequestCommand(capability: string, validU
|
|
|
12
13
|
*
|
|
13
14
|
* targetDevice and timeoutMs forward directly to MeshSession.sendManageRequest's own identically-named parameters (relay routing and a requester-side give-up bound respectively -- wire-mesh#80 is already implemented there, not duplicated here). validUntil, when given, is attached to the request itself (wire-mesh#82) so a slow-to-answer receiver -- or a relay/facilitator forwarding this request on the caller's behalf -- can refuse or drop a now-stale ask outright rather than holding or forwarding it.
|
|
14
15
|
*/
|
|
15
|
-
export declare function requestCapability(session: Readonly<Pick<MeshSession, "sendManageRequest">>, capability: string, scope: Readonly<CapabilityScope>, targetDevice?: DeviceId, timeoutMs?: number, validUntil?: number
|
|
16
|
+
export declare function requestCapability(session: Readonly<Pick<MeshSession, "sendManageRequest">>, capability: string, scope: Readonly<CapabilityScope>, targetDevice?: DeviceId, timeoutMs?: number, validUntil?: number,
|
|
17
|
+
/** A manage:request token to present with the ask, for a receiver that gates requesting (wire-mesh#324). Absent keeps the request ungated, which is what a stranger's first contact must remain able to send. */
|
|
18
|
+
requestToken?: CapabilityToken): Promise<CapabilityGrantOk>;
|
|
16
19
|
/**
|
|
17
20
|
* A receiver's decision on one incoming capability-request, mirroring room-client.ts's own (now capability-specific) RoomJoinDecision, generalized to any capability: "accept" mints and returns a fresh token; "reject" sends an ordinary manage-error carrying an optional human-readable reason.
|
|
18
21
|
*/
|
|
@@ -37,11 +40,19 @@ export interface CapabilityGrantRequestEvent {
|
|
|
37
40
|
/** Resolves this request with the domain's decision. Settles the request's response exactly once: whichever of a real decide() call or the handler's own receiver-side timeout comes first wins, and the other is a no-op -- the same single-settle guarantee agent-comms' own PendingConnection timer/accept/reject/disconnect race already established (ported here, not reinvented). */
|
|
38
41
|
decide: (decision: Readonly<CapabilityGrantDecision>) => Promise<void>;
|
|
39
42
|
}
|
|
43
|
+
/** The capability verb of a request-permission (wire-mesh#324): the right to ask for a capability, grantable and delegable like any other. */
|
|
44
|
+
export declare const MANAGE_REQUEST_CAPABILITY = "manage:request";
|
|
40
45
|
export interface CreateCapabilityRequestHandlerOptions {
|
|
41
46
|
/** The capability this handler grants. Checked against both the incoming request's own `params.capability` field (a mismatch is refused as malformed rather than trusted -- nothing about manage-command.verb structurally guarantees params.capability agrees with it) and used as the scope this handler is willing to act on at all; a caller wanting to grant several distinct capabilities over one session constructs one handler per capability, the same way core/room constructs one handler for `room:member` and nothing else. */
|
|
42
47
|
capability: string;
|
|
43
48
|
identity: IdentityPort;
|
|
44
49
|
clock: Clock;
|
|
50
|
+
/** The revocation view the request-permission gate (requireRequestToken) verifies a presented manage:request token against -- the same plumbing every other token verification here already takes. Required only when the gate is on. */
|
|
51
|
+
revocation?: RevocationCheck;
|
|
52
|
+
/** Opt the receiver into the request-permission gate (wire-mesh#324): when on, a request must present a valid manage:request token whose bearer is the authenticated requester, whose requests-capability (when present) matches this handler's capability, and whose scope covers the request's own scope. Off by default so a stranger's first contact still reaches the domain's own decision. */
|
|
53
|
+
requireRequestToken?: boolean;
|
|
54
|
+
/** Domain-specific delegate systems a presented request-permission's own conditions entries may name, forwarded verbatim to verifyCapabilityToken. */
|
|
55
|
+
extraPredicateResolvers?: Readonly<Record<string, TokenDelegateHandler<ConditionsContext>>>;
|
|
45
56
|
/** The peer device-id authenticated on this session's own connection -- the requester, and so the future bearer of any token this handler mints. One handler is constructed per session for the same reason one RoomRouter is (RoomRouterOptions.peerDevice): MeshSession exposes no way for domain code to learn the authenticated peer independently. */
|
|
46
57
|
bearerDevice: DeviceId;
|
|
47
58
|
/** Receiver-side auto-reject window (wire-mesh#81): how long an incoming request may sit awaiting the domain's decision before this side responds with a real manage-error timeout rather than leaving the requester's own sendManageRequest hanging indefinitely. Ported from agent-comms' PendingConnection pattern (`wire-mesh-transport.ts`'s `pendingConnectionTimeoutMs` / `expirePendingConnection`): an unref'd timer so a stray one can never by itself keep the process alive, cleared the instant decide() is actually called so it can never fire after the request has already been answered. IncomingManageRequest exposes no requester-disconnect signal at this layer (unlike agent-comms' own transport, which owns the raw connection), so only the timeout half of that pattern is implemented here -- there is nothing to detect the requester giving up early honestly, so this module does not pretend to. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, u as CapabilityGrantOk } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken, u as CapabilityGrantOk } from "../protocol-BgR1e_NI.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-ViYdZrIU.mjs";
|
|
3
3
|
import { t as Clock } from "../clock-DiSx-WKM.mjs";
|
|
4
4
|
import { IncomingManageRequest, MeshSession } from "./mesh-session.mjs";
|
|
5
|
+
import { b as ConditionsContext, o as RevocationCheck, x as TokenDelegateHandler } from "../tokens-DRkm_QOR.mjs";
|
|
5
6
|
//#region src/domain/capability-request.d.ts
|
|
6
7
|
/**
|
|
7
8
|
* 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.
|
|
@@ -12,7 +13,9 @@ export declare function buildCapabilityRequestCommand(capability: string, validU
|
|
|
12
13
|
*
|
|
13
14
|
* targetDevice and timeoutMs forward directly to MeshSession.sendManageRequest's own identically-named parameters (relay routing and a requester-side give-up bound respectively -- wire-mesh#80 is already implemented there, not duplicated here). validUntil, when given, is attached to the request itself (wire-mesh#82) so a slow-to-answer receiver -- or a relay/facilitator forwarding this request on the caller's behalf -- can refuse or drop a now-stale ask outright rather than holding or forwarding it.
|
|
14
15
|
*/
|
|
15
|
-
export declare function requestCapability(session: Readonly<Pick<MeshSession, "sendManageRequest">>, capability: string, scope: Readonly<CapabilityScope>, targetDevice?: DeviceId, timeoutMs?: number, validUntil?: number
|
|
16
|
+
export declare function requestCapability(session: Readonly<Pick<MeshSession, "sendManageRequest">>, capability: string, scope: Readonly<CapabilityScope>, targetDevice?: DeviceId, timeoutMs?: number, validUntil?: number,
|
|
17
|
+
/** A manage:request token to present with the ask, for a receiver that gates requesting (wire-mesh#324). Absent keeps the request ungated, which is what a stranger's first contact must remain able to send. */
|
|
18
|
+
requestToken?: CapabilityToken): Promise<CapabilityGrantOk>;
|
|
16
19
|
/**
|
|
17
20
|
* A receiver's decision on one incoming capability-request, mirroring room-client.ts's own (now capability-specific) RoomJoinDecision, generalized to any capability: "accept" mints and returns a fresh token; "reject" sends an ordinary manage-error carrying an optional human-readable reason.
|
|
18
21
|
*/
|
|
@@ -37,11 +40,19 @@ export interface CapabilityGrantRequestEvent {
|
|
|
37
40
|
/** Resolves this request with the domain's decision. Settles the request's response exactly once: whichever of a real decide() call or the handler's own receiver-side timeout comes first wins, and the other is a no-op -- the same single-settle guarantee agent-comms' own PendingConnection timer/accept/reject/disconnect race already established (ported here, not reinvented). */
|
|
38
41
|
decide: (decision: Readonly<CapabilityGrantDecision>) => Promise<void>;
|
|
39
42
|
}
|
|
43
|
+
/** The capability verb of a request-permission (wire-mesh#324): the right to ask for a capability, grantable and delegable like any other. */
|
|
44
|
+
export declare const MANAGE_REQUEST_CAPABILITY = "manage:request";
|
|
40
45
|
export interface CreateCapabilityRequestHandlerOptions {
|
|
41
46
|
/** The capability this handler grants. Checked against both the incoming request's own `params.capability` field (a mismatch is refused as malformed rather than trusted -- nothing about manage-command.verb structurally guarantees params.capability agrees with it) and used as the scope this handler is willing to act on at all; a caller wanting to grant several distinct capabilities over one session constructs one handler per capability, the same way core/room constructs one handler for `room:member` and nothing else. */
|
|
42
47
|
capability: string;
|
|
43
48
|
identity: IdentityPort;
|
|
44
49
|
clock: Clock;
|
|
50
|
+
/** The revocation view the request-permission gate (requireRequestToken) verifies a presented manage:request token against -- the same plumbing every other token verification here already takes. Required only when the gate is on. */
|
|
51
|
+
revocation?: RevocationCheck;
|
|
52
|
+
/** Opt the receiver into the request-permission gate (wire-mesh#324): when on, a request must present a valid manage:request token whose bearer is the authenticated requester, whose requests-capability (when present) matches this handler's capability, and whose scope covers the request's own scope. Off by default so a stranger's first contact still reaches the domain's own decision. */
|
|
53
|
+
requireRequestToken?: boolean;
|
|
54
|
+
/** Domain-specific delegate systems a presented request-permission's own conditions entries may name, forwarded verbatim to verifyCapabilityToken. */
|
|
55
|
+
extraPredicateResolvers?: Readonly<Record<string, TokenDelegateHandler<ConditionsContext>>>;
|
|
45
56
|
/** The peer device-id authenticated on this session's own connection -- the requester, and so the future bearer of any token this handler mints. One handler is constructed per session for the same reason one RoomRouter is (RoomRouterOptions.peerDevice): MeshSession exposes no way for domain code to learn the authenticated peer independently. */
|
|
46
57
|
bearerDevice: DeviceId;
|
|
47
58
|
/** Receiver-side auto-reject window (wire-mesh#81): how long an incoming request may sit awaiting the domain's decision before this side responds with a real manage-error timeout rather than leaving the requester's own sendManageRequest hanging indefinitely. Ported from agent-comms' PendingConnection pattern (`wire-mesh-transport.ts`'s `pendingConnectionTimeoutMs` / `expirePendingConnection`): an unref'd timer so a stray one can never by itself keep the process alive, cleared the instant decide() is actually called so it can never fire after the request has already been answered. IncomingManageRequest exposes no requester-disconnect signal at this layer (unlike agent-comms' own transport, which owns the raw connection), so only the timeout half of that pattern is implemented here -- there is nothing to detect the requester giving up early honestly, so this module does not pretend to. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { capabilityGrantOkSchema, capabilityRequestSchema } from "../generated/protocol.mjs";
|
|
2
|
-
import { n as
|
|
2
|
+
import { n as scopeNarrows } from "../token-scope-Z4bmci4M.mjs";
|
|
3
|
+
import { i as mintCapabilityToken, s as verifyCapabilityToken } from "../tokens-D8JlTJNA.mjs";
|
|
3
4
|
//#region src/domain/capability-request.ts
|
|
4
5
|
/**
|
|
5
6
|
* The generic, capability-agnostic capability-request / capability-grant-ok primitive (wire-mesh#78, spec/management.cddl). Lifts core/room's own room.join shape -- an ungated ask, held open, a human (or any other domain-supplied decision) accepts or refuses, acceptance mints and returns a token on the same response -- out of that one domain so any capability can reuse it, not just room:member. core/room's own room-client.ts is the reference consumer: it rewires requestToJoin/createRoomRouter's room.join handling onto requestCapability/createCapabilityRequestHandler below, supplying room-specific extension fields (its member list) through this module's own extensions mechanism rather than this module knowing anything about rooms.
|
|
@@ -34,13 +35,48 @@ function buildCapabilityRequestCommand(capability, validUntil) {
|
|
|
34
35
|
*
|
|
35
36
|
* targetDevice and timeoutMs forward directly to MeshSession.sendManageRequest's own identically-named parameters (relay routing and a requester-side give-up bound respectively -- wire-mesh#80 is already implemented there, not duplicated here). validUntil, when given, is attached to the request itself (wire-mesh#82) so a slow-to-answer receiver -- or a relay/facilitator forwarding this request on the caller's behalf -- can refuse or drop a now-stale ask outright rather than holding or forwarding it.
|
|
36
37
|
*/
|
|
37
|
-
async function requestCapability(session, capability, scope, targetDevice, timeoutMs, validUntil) {
|
|
38
|
-
const outcome = await session.sendManageRequest(buildCapabilityRequestCommand(capability, validUntil), scope, targetDevice,
|
|
38
|
+
async function requestCapability(session, capability, scope, targetDevice, timeoutMs, validUntil, requestToken) {
|
|
39
|
+
const outcome = await session.sendManageRequest(buildCapabilityRequestCommand(capability, validUntil), scope, targetDevice, requestToken, timeoutMs);
|
|
39
40
|
if (outcome.result !== "ok") throw new Error(`capability request for "${capability}" was refused (${outcome.code})`);
|
|
40
41
|
const parsed = capabilityGrantOkSchema.safeParse(outcome);
|
|
41
42
|
if (!parsed.success) throw new Error(`capability request for "${capability}" response was malformed`);
|
|
42
43
|
return parsed.data;
|
|
43
44
|
}
|
|
45
|
+
/** The capability verb of a request-permission (wire-mesh#324): the right to ask for a capability, grantable and delegable like any other. */
|
|
46
|
+
const MANAGE_REQUEST_CAPABILITY = "manage:request";
|
|
47
|
+
/** The request-permission gate (wire-mesh#324): the incoming request must present a manage:request token naming this requester as bearer, matching this capability when the token names one, and covering the request's own scope. A wrong token is an ordinary manage-error, never an exception -- the same convention every other refusal here already follows. */
|
|
48
|
+
async function checkRequestPermission(incoming, options) {
|
|
49
|
+
if (incoming.token === void 0) return {
|
|
50
|
+
ok: false,
|
|
51
|
+
code: "token_required"
|
|
52
|
+
};
|
|
53
|
+
if (options.revocation === void 0) throw new Error("requireRequestToken needs a revocation view on the handler options");
|
|
54
|
+
const verdict = await verifyCapabilityToken(incoming.token, {
|
|
55
|
+
identity: options.identity,
|
|
56
|
+
clock: options.clock,
|
|
57
|
+
revocation: options.revocation,
|
|
58
|
+
expectedBearer: options.bearerDevice,
|
|
59
|
+
...options.extraPredicateResolvers !== void 0 ? { extraPredicateResolvers: options.extraPredicateResolvers } : {}
|
|
60
|
+
});
|
|
61
|
+
if (!verdict.ok) return {
|
|
62
|
+
ok: false,
|
|
63
|
+
code: verdict.reason
|
|
64
|
+
};
|
|
65
|
+
if (verdict.claims.capability !== "manage:request") return {
|
|
66
|
+
ok: false,
|
|
67
|
+
code: "capability_mismatch"
|
|
68
|
+
};
|
|
69
|
+
const requestsCapability = verdict.claims["requests-capability"];
|
|
70
|
+
if (requestsCapability !== void 0 && requestsCapability !== options.capability) return {
|
|
71
|
+
ok: false,
|
|
72
|
+
code: "capability_mismatch"
|
|
73
|
+
};
|
|
74
|
+
if (!scopeNarrows(verdict.claims.scope, incoming.scope)) return {
|
|
75
|
+
ok: false,
|
|
76
|
+
code: "scope_mismatch"
|
|
77
|
+
};
|
|
78
|
+
return { ok: true };
|
|
79
|
+
}
|
|
44
80
|
/**
|
|
45
81
|
* Builds a reusable handler for one capability's incoming capability-requests. The returned function is the generic counterpart to room-client.ts's own (now capability-specific) handleRoomJoin: given one IncomingManageRequest, it refuses a request for the wrong capability or a malformed payload as `{result:"error", code:"malformed"}`, refuses an already-expired request (per its own `valid-until`, wire-mesh#82) as `{result:"error", code:"expired"}` without ever invoking onRequest, otherwise arms the receiver-side timeout described on CreateCapabilityRequestHandlerOptions.timeoutMs and calls onRequest so the domain can accept (minting a fresh token via mintCapabilityToken and responding `{result:"ok", "granted-token": token, ...extensions}`) or reject (an ordinary manage-error) via the event's own decide().
|
|
46
82
|
*/
|
|
@@ -54,7 +90,18 @@ function createCapabilityRequestHandler(options) {
|
|
|
54
90
|
});
|
|
55
91
|
return;
|
|
56
92
|
}
|
|
57
|
-
const
|
|
93
|
+
const params = parsed.data;
|
|
94
|
+
if (options.requireRequestToken === true) {
|
|
95
|
+
const verdict = await checkRequestPermission(incoming, options);
|
|
96
|
+
if (!verdict.ok) {
|
|
97
|
+
await incoming.respond({
|
|
98
|
+
result: "error",
|
|
99
|
+
code: verdict.code
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const validUntil = params["valid-until"];
|
|
58
105
|
if (validUntil !== void 0 && validUntil <= options.clock.now()) {
|
|
59
106
|
await incoming.respond({
|
|
60
107
|
result: "error",
|
|
@@ -116,4 +163,4 @@ function createCapabilityRequestHandler(options) {
|
|
|
116
163
|
};
|
|
117
164
|
}
|
|
118
165
|
//#endregion
|
|
119
|
-
export { buildCapabilityRequestCommand, createCapabilityRequestHandler, requestCapability };
|
|
166
|
+
export { MANAGE_REQUEST_CAPABILITY, buildCapabilityRequestCommand, createCapabilityRequestHandler, requestCapability };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, g as CoordinatorFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, g as CoordinatorFrame } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
//#region src/domain/coordinator-election.d.ts
|
|
3
3
|
/** The claim this side currently accepts: one coordinator, at the term that put it there. */
|
|
4
4
|
export interface CoordinatorClaim {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, g as CoordinatorFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, g as CoordinatorFrame } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
//#region src/domain/coordinator-election.d.ts
|
|
3
3
|
/** The claim this side currently accepts: one coordinator, at the term that put it there. */
|
|
4
4
|
export interface CoordinatorClaim {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceId, E as DataRequestFrame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, E as DataRequestFrame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
import { t as KeyValueStorage } from "../storage-B403CRyu.cjs";
|
|
3
|
-
import { t as IdentityPort } from "../identity-
|
|
3
|
+
import { t as IdentityPort } from "../identity-DJbr96J3.cjs";
|
|
4
4
|
//#region src/domain/data-sync.d.ts
|
|
5
5
|
export interface DataSyncOptions {
|
|
6
6
|
identity: IdentityPort;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceId, E as DataRequestFrame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, E as DataRequestFrame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
import { t as KeyValueStorage } from "../storage-B403CRyu.mjs";
|
|
3
|
-
import { t as IdentityPort } from "../identity-
|
|
3
|
+
import { t as IdentityPort } from "../identity-ViYdZrIU.mjs";
|
|
4
4
|
//#region src/domain/data-sync.d.ts
|
|
5
5
|
export interface DataSyncOptions {
|
|
6
6
|
identity: IdentityPort;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
1
|
+
import { D as DeviceId } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
//#region src/domain/device-id.d.ts
|
|
3
3
|
/** Lowercase, byte-exact hex for an arbitrary-length byte string -- the same encoding convention deviceIdToHex uses for the fixed-length device-id case, extracted so any other byte string needing a stable, displayable, map-keyable text form (e.g. a token-id, which tokens.cddl defines as an arbitrary-length bstr rather than a 32-byte device-id) can use the identical convention without going through a device-id-shaped function. */
|
|
4
4
|
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
1
|
+
import { D as DeviceId } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
//#region src/domain/device-id.d.ts
|
|
3
3
|
/** Lowercase, byte-exact hex for an arbitrary-length byte string -- the same encoding convention deviceIdToHex uses for the fixed-length device-id case, extracted so any other byte string needing a stable, displayable, map-keyable text form (e.g. a token-id, which tokens.cddl defines as an arbitrary-length bstr rather than a 32-byte device-id) can use the identical convention without going through a device-id-shaped function. */
|
|
4
4
|
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { r as Transport, t as Connection } from "../transport-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-BgR1e_NI.cjs";
|
|
2
|
+
import { r as Transport, t as Connection } from "../transport-DP3hdehk.cjs";
|
|
3
3
|
import { IncomingManageRequest, ManageOutcome } from "./mesh-session.cjs";
|
|
4
4
|
//#region src/domain/direct-manage-request.d.ts
|
|
5
5
|
/** Reads exactly one frame off a freshly-accepted, bare connection and, if it's a manage-request, returns an IncomingManageRequest ready to hand to the same application-level dispatch logic session.incomingManageRequests already feeds elsewhere -- no handshake or gossip is ever read or sent on this connection (wire-mesh#38: the manage-request/manage-response exchange has no dependency on handshake state at the dispatch layer, confirmed against mesh-session.ts's own applyManageRequest/applyFrame). respond() sends the manage-response directly and closes the connection, since a one-off request/response is this connection's entire purpose -- unlike a real MeshSession, there is nothing further to do with it afterwards. Resolves null, without closing the connection (that's the caller's call), for any other first frame or if the connection ends before one arrives: interpreting either case is a Transport.listen() caller's own business, e.g. peeking the first frame to route between this path and acceptMeshSession's own handshake path. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { r as Transport, t as Connection } from "../transport-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-BgR1e_NI.mjs";
|
|
2
|
+
import { r as Transport, t as Connection } from "../transport-Dv_LTCsF.mjs";
|
|
3
3
|
import { IncomingManageRequest, ManageOutcome } from "./mesh-session.mjs";
|
|
4
4
|
//#region src/domain/direct-manage-request.d.ts
|
|
5
5
|
/** Reads exactly one frame off a freshly-accepted, bare connection and, if it's a manage-request, returns an IncomingManageRequest ready to hand to the same application-level dispatch logic session.incomingManageRequests already feeds elsewhere -- no handshake or gossip is ever read or sent on this connection (wire-mesh#38: the manage-request/manage-response exchange has no dependency on handshake state at the dispatch layer, confirmed against mesh-session.ts's own applyManageRequest/applyFrame). respond() sends the manage-response directly and closes the connection, since a one-off request/response is this connection's entire purpose -- unlike a real MeshSession, there is nothing further to do with it afterwards. Resolves null, without closing the connection (that's the caller's call), for any other first frame or if the connection ends before one arrives: interpreting either case is a Transport.listen() caller's own business, e.g. peeking the first frame to route between this path and acceptMeshSession's own handshake path. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { D as DeviceId, et as PeerAdvert } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
import { MeshSession } from "./mesh-session.cjs";
|
|
3
3
|
//#region src/domain/gossip-expansion.d.ts
|
|
4
4
|
/** One not-yet-considered device this session's gossip directory has surfaced, carrying only what a dial/trust decision needs: the device-id to decide identity, and the "host:port" addresses its own peer-advert claims are directly reachable at, in the order it advertised them. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { D as DeviceId, et as PeerAdvert } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
import { MeshSession } from "./mesh-session.mjs";
|
|
3
3
|
//#region src/domain/gossip-expansion.d.ts
|
|
4
4
|
/** One not-yet-considered device this session's gossip directory has surfaced, carrying only what a dial/trust decision needs: the device-id to decide identity, and the "host:port" addresses its own peer-advert claims are directly reachable at, in the order it advertised them. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, f as CapabilityScope } from "../protocol-
|
|
1
|
+
import { D as DeviceId, f as CapabilityScope } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
import { DirectoryEntry, MeshSession } from "./mesh-session.cjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/domain/grant-candidates.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, f as CapabilityScope } from "../protocol-
|
|
1
|
+
import { D as DeviceId, f as CapabilityScope } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
import { DirectoryEntry, MeshSession } from "./mesh-session.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/domain/grant-candidates.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as DomainId, R as HandshakeFrame, lt as ProtocolVersion } from "../protocol-
|
|
1
|
+
import { A as DomainId, R as HandshakeFrame, lt as ProtocolVersion } from "../protocol-BgR1e_NI.cjs";
|
|
2
2
|
//#region src/domain/handshake.d.ts
|
|
3
3
|
/** The highest protocol version this build of core understands. */
|
|
4
4
|
export declare const SUPPORTED_PROTOCOL_VERSION: ProtocolVersion;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as DomainId, R as HandshakeFrame, lt as ProtocolVersion } from "../protocol-
|
|
1
|
+
import { A as DomainId, R as HandshakeFrame, lt as ProtocolVersion } from "../protocol-BgR1e_NI.mjs";
|
|
2
2
|
//#region src/domain/handshake.d.ts
|
|
3
3
|
/** The highest protocol version this build of core understands. */
|
|
4
4
|
export declare const SUPPORTED_PROTOCOL_VERSION: ProtocolVersion;
|