wire-mesh-core 1.45.2 → 1.47.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.
Files changed (93) hide show
  1. package/dist/adapters/frame-codec.d.cts +1 -1
  2. package/dist/adapters/frame-codec.d.mts +1 -1
  3. package/dist/adapters/node-fs-storage.cjs +3 -24
  4. package/dist/adapters/node-identity.d.cts +2 -2
  5. package/dist/adapters/node-identity.d.mts +2 -2
  6. package/dist/adapters/tcp-transport.d.cts +1 -1
  7. package/dist/adapters/tcp-transport.d.mts +1 -1
  8. package/dist/adapters/threshold-identity.cjs +42 -0
  9. package/dist/adapters/threshold-identity.d.cts +33 -0
  10. package/dist/adapters/threshold-identity.d.mts +33 -0
  11. package/dist/adapters/threshold-identity.mjs +41 -0
  12. package/dist/adapters/threshold-wasm.cjs +139 -0
  13. package/dist/adapters/threshold-wasm.d.cts +63 -0
  14. package/dist/adapters/threshold-wasm.d.mts +63 -0
  15. package/dist/adapters/threshold-wasm.mjs +123 -0
  16. package/dist/adapters/tls-transport.d.cts +1 -1
  17. package/dist/adapters/tls-transport.d.mts +1 -1
  18. package/dist/domain/bulk.cjs +26 -0
  19. package/dist/domain/bulk.d.cts +10 -2
  20. package/dist/domain/bulk.d.mts +10 -2
  21. package/dist/domain/bulk.mjs +26 -1
  22. package/dist/domain/capability-grant.cjs +1 -1
  23. package/dist/domain/capability-grant.d.cts +3 -3
  24. package/dist/domain/capability-grant.d.mts +3 -3
  25. package/dist/domain/capability-grant.mjs +1 -1
  26. package/dist/domain/capability-request.cjs +1 -1
  27. package/dist/domain/capability-request.d.cts +2 -2
  28. package/dist/domain/capability-request.d.mts +2 -2
  29. package/dist/domain/capability-request.mjs +1 -1
  30. package/dist/domain/data-sync.d.cts +2 -2
  31. package/dist/domain/data-sync.d.mts +2 -2
  32. package/dist/domain/device-id.d.cts +1 -1
  33. package/dist/domain/device-id.d.mts +1 -1
  34. package/dist/domain/grant-candidates.d.cts +1 -1
  35. package/dist/domain/grant-candidates.d.mts +1 -1
  36. package/dist/domain/handshake.d.cts +1 -1
  37. package/dist/domain/handshake.d.mts +1 -1
  38. package/dist/domain/mesh-session.d.cts +3 -3
  39. package/dist/domain/mesh-session.d.mts +3 -3
  40. package/dist/domain/notice-board.d.cts +3 -3
  41. package/dist/domain/notice-board.d.mts +3 -3
  42. package/dist/domain/relay-hub.d.cts +2 -2
  43. package/dist/domain/relay-hub.d.mts +2 -2
  44. package/dist/domain/relay-use-gate.d.cts +2 -2
  45. package/dist/domain/relay-use-gate.d.mts +2 -2
  46. package/dist/domain/revocation-view.cjs +1 -1
  47. package/dist/domain/revocation-view.d.cts +2 -2
  48. package/dist/domain/revocation-view.d.mts +2 -2
  49. package/dist/domain/revocation-view.mjs +1 -1
  50. package/dist/domain/room-rekey.d.cts +3 -3
  51. package/dist/domain/room-rekey.d.mts +3 -3
  52. package/dist/domain/room-token-verification.cjs +1 -1
  53. package/dist/domain/room-token-verification.d.cts +1 -1
  54. package/dist/domain/room-token-verification.d.mts +1 -1
  55. package/dist/domain/room-token-verification.mjs +1 -1
  56. package/dist/domain/room.d.cts +4 -4
  57. package/dist/domain/room.d.mts +4 -4
  58. package/dist/domain/shard-manifest.d.cts +1 -1
  59. package/dist/domain/shard-manifest.d.mts +1 -1
  60. package/dist/domain/threshold-subject.cjs +35 -0
  61. package/dist/domain/threshold-subject.d.cts +33 -0
  62. package/dist/domain/threshold-subject.d.mts +33 -0
  63. package/dist/domain/threshold-subject.mjs +32 -0
  64. package/dist/domain/tokens.cjs +2 -1
  65. package/dist/domain/tokens.d.cts +2 -2
  66. package/dist/domain/tokens.d.mts +2 -2
  67. package/dist/domain/tokens.mjs +2 -2
  68. package/dist/domain/webrtc-signaling.cjs +107 -0
  69. package/dist/domain/webrtc-signaling.d.cts +38 -0
  70. package/dist/domain/webrtc-signaling.d.mts +38 -0
  71. package/dist/domain/webrtc-signaling.mjs +93 -0
  72. package/dist/generated/protocol.cjs +97 -1
  73. package/dist/generated/protocol.d.cts +2 -2
  74. package/dist/generated/protocol.d.mts +2 -2
  75. package/dist/generated/protocol.mjs +85 -2
  76. package/dist/{identity-B4XBWkqg.d.cts → identity-9TmmK7vP.d.mts} +1 -1
  77. package/dist/{identity-CIb9dGkJ.d.mts → identity-CUkDHCRK.d.cts} +1 -1
  78. package/dist/ports/identity.d.cts +1 -1
  79. package/dist/ports/identity.d.mts +1 -1
  80. package/dist/ports/transport.d.cts +1 -1
  81. package/dist/ports/transport.d.mts +1 -1
  82. package/dist/{protocol-gbXtNeOc.d.cts → protocol-CNFRVx9w.d.cts} +333 -1
  83. package/dist/{protocol-gbXtNeOc.d.mts → protocol-CNFRVx9w.d.mts} +333 -1
  84. package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
  85. package/dist/{room-token-verification-BggPfYr8.d.mts → room-token-verification-BdtM1rQ4.d.mts} +2 -2
  86. package/dist/{room-token-verification-CkQV0Iq7.d.cts → room-token-verification-DpOfZOdl.d.cts} +2 -2
  87. package/dist/{tokens-CdQwzCyJ.mjs → tokens-B0dpTLhS.mjs} +2 -2
  88. package/dist/{tokens-k172l0Iy.d.mts → tokens-CVyPoJ6l.d.mts} +5 -3
  89. package/dist/{tokens-C9Kwy0Gk.d.cts → tokens-Cl8sQo7o.d.cts} +5 -3
  90. package/dist/{tokens-DxGVURpB.cjs → tokens-Dh6mG6p_.cjs} +7 -1
  91. package/dist/{transport-DAsFqDDS.d.cts → transport-C7KVkhgb.d.mts} +1 -1
  92. package/dist/{transport-Dy4h2eNY.d.mts → transport-De0zHlaA.d.cts} +1 -1
  93. package/package.json +50 -34
@@ -1,5 +1,5 @@
1
1
  import { deviceIdToHex } from "./device-id.mjs";
2
- import { i as verifyCapabilityToken } from "../tokens-CdQwzCyJ.mjs";
2
+ import { a as verifyCapabilityToken } from "../tokens-B0dpTLhS.mjs";
3
3
  import { parseRoomPath } from "./room-path.mjs";
4
4
  //#region src/domain/room-token-verification.ts
5
5
  /**
@@ -1,8 +1,8 @@
1
- import { Dt as RoomPath, Et as RoomNoticeClaims, Tt as RoomNotice, p as CapabilityToken, q as MessageRef } from "../protocol-gbXtNeOc.cjs";
2
- import { t as IdentityPort } from "../identity-B4XBWkqg.cjs";
1
+ import { Dt as RoomPath, Et as RoomNoticeClaims, Tt as RoomNotice, p as CapabilityToken, q as MessageRef } from "../protocol-CNFRVx9w.cjs";
2
+ import { t as IdentityPort } from "../identity-CUkDHCRK.cjs";
3
3
  import { t as Clock } from "../clock-DiSx-WKM.cjs";
4
- import { a as RevocationCheck } from "../tokens-C9Kwy0Gk.cjs";
5
- import { r as RoomTokenVerdictReason } from "../room-token-verification-CkQV0Iq7.cjs";
4
+ import { a as RevocationCheck } from "../tokens-Cl8sQo7o.cjs";
5
+ import { r as RoomTokenVerdictReason } from "../room-token-verification-DpOfZOdl.cjs";
6
6
  //#region src/domain/room.d.ts
7
7
  export type RoomNoticeVerdictReason = "malformed" | "wrong_room" | "bad_signature" | "wrong_poster" | "content_expired" | "key_epoch_mismatch" | RoomTokenVerdictReason;
8
8
  export type RoomNoticeVerdict = {
@@ -1,8 +1,8 @@
1
- import { Dt as RoomPath, Et as RoomNoticeClaims, Tt as RoomNotice, p as CapabilityToken, q as MessageRef } from "../protocol-gbXtNeOc.mjs";
2
- import { t as IdentityPort } from "../identity-CIb9dGkJ.mjs";
1
+ import { Dt as RoomPath, Et as RoomNoticeClaims, Tt as RoomNotice, p as CapabilityToken, q as MessageRef } from "../protocol-CNFRVx9w.mjs";
2
+ import { t as IdentityPort } from "../identity-9TmmK7vP.mjs";
3
3
  import { t as Clock } from "../clock-DiSx-WKM.mjs";
4
- import { a as RevocationCheck } from "../tokens-k172l0Iy.mjs";
5
- import { r as RoomTokenVerdictReason } from "../room-token-verification-BggPfYr8.mjs";
4
+ import { a as RevocationCheck } from "../tokens-CVyPoJ6l.mjs";
5
+ import { r as RoomTokenVerdictReason } from "../room-token-verification-BdtM1rQ4.mjs";
6
6
  //#region src/domain/room.d.ts
7
7
  export type RoomNoticeVerdictReason = "malformed" | "wrong_room" | "bad_signature" | "wrong_poster" | "content_expired" | "key_epoch_mismatch" | RoomTokenVerdictReason;
8
8
  export type RoomNoticeVerdict = {
@@ -1,4 +1,4 @@
1
- import { D as DeviceId } from "../protocol-gbXtNeOc.cjs";
1
+ import { D as DeviceId } from "../protocol-CNFRVx9w.cjs";
2
2
  import { PresentedShard, ShardConfig } from "./erasure-coding.cjs";
3
3
  //#region src/domain/shard-manifest.d.ts
4
4
  /** The content-type a core/data entry carrying a shard manifest declares. */
@@ -1,4 +1,4 @@
1
- import { D as DeviceId } from "../protocol-gbXtNeOc.mjs";
1
+ import { D as DeviceId } from "../protocol-CNFRVx9w.mjs";
2
2
  import { PresentedShard, ShardConfig } from "./erasure-coding.mjs";
3
3
  //#region src/domain/shard-manifest.d.ts
4
4
  /** The content-type a core/data entry carrying a shard manifest declares. */
@@ -0,0 +1,35 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_tokens = require("../tokens-Dh6mG6p_.cjs");
3
+ //#region src/domain/threshold-subject.ts
4
+ /**
5
+ * `threshold-subject` -- what a signing session actually asks a group to sign, and the single most important design decision in the whole protocol: it carries the FULL decoded content, never a bare hash. A participant that commits to an opaque digest is a blind signer, and the entire security value of T-of-N is that each participant independently reviews and authorises the content -- returning a round-1 commitment IS that act of authorisation. This module builds exactly the bytes a participant signs its round-1 commitment over: the RFC 9052 §4.4 `Sig_structure`, reusing `tokens.ts`'s own `sig1ToBeSigned` rather than a second hand-rolled construction, and NEVER accepting a pre-assembled to-be-signed blob from a coordinator. Mirrors `wire_mesh_threshold::subject` on the Rust side exactly.
6
+ */
7
+ /**
8
+ * The kinds this participant recognises out of the box -- `capability-token`, `revocation-entry`, `handle-record`, and `room-notice` are the self-certifying payload shapes this codebase already defines. A caller extending recognised kinds (e.g. an application-defined one) supplies its own recogniser rather than this module growing a closed list.
9
+ */
10
+ const KNOWN_KINDS = [
11
+ "capability-token",
12
+ "revocation-entry",
13
+ "handle-record",
14
+ "room-notice"
15
+ ];
16
+ /**
17
+ * The verifier obligation `spec/threshold.cddl` states directly: an unrecognised `kind` MUST be refused, never signed blindly. This is the fail-closed default every content policy is checked against BEFORE any kind-specific review runs; a caller's own policy closure only ever gets a chance to run for a kind it (or `KNOWN_KINDS`) actually recognises.
18
+ */
19
+ function refuseUnrecognisedKind(subject, known = KNOWN_KINDS) {
20
+ if (known.includes(subject.kind)) return;
21
+ return {
22
+ authorise: false,
23
+ reason: `unrecognised threshold-subject.kind ${JSON.stringify(subject.kind)} -- refusing to sign`
24
+ };
25
+ }
26
+ /**
27
+ * Reconstructs the exact bytes this participant signs its round-1 commitment (and, transitively, its round-2 share) over -- the Sig_structure built from THIS participant's own decoding of `protected`/`payload`, never a coordinator-supplied to-be-signed blob.
28
+ */
29
+ function toBeSigned(subject) {
30
+ return Uint8Array.from(require_tokens.sig1ToBeSigned(subject.protected, subject.payload));
31
+ }
32
+ //#endregion
33
+ exports.KNOWN_KINDS = KNOWN_KINDS;
34
+ exports.refuseUnrecognisedKind = refuseUnrecognisedKind;
35
+ exports.toBeSigned = toBeSigned;
@@ -0,0 +1,33 @@
1
+ //#region src/domain/threshold-subject.d.ts
2
+ /**
3
+ * The `kind` discriminator on `threshold-subject` -- an open `tstr` per `spec/CONVENTIONS.md`'s own open-tstr-over-closed-enum convention, since future content a group signs is not limited to what wire-mesh itself already defines self-certifying payloads for.
4
+ */
5
+ export interface ThresholdSubject {
6
+ kind: string;
7
+ /** `bstr .cbor cose-token-headers` -- the protected header the aggregate signature will carry. */
8
+ protected: Uint8Array;
9
+ /** `bstr .cbor` of the claims structure `kind` names. */
10
+ payload: Uint8Array;
11
+ }
12
+ /**
13
+ * The kinds this participant recognises out of the box -- `capability-token`, `revocation-entry`, `handle-record`, and `room-notice` are the self-certifying payload shapes this codebase already defines. A caller extending recognised kinds (e.g. an application-defined one) supplies its own recogniser rather than this module growing a closed list.
14
+ */
15
+ export declare const KNOWN_KINDS: readonly string[];
16
+ /**
17
+ * A participant's decision on whether to authorise a `threshold-subject`. Deliberately not a bare `boolean`: a refusal MUST carry a reason so the coordinator (and, ideally, a human reviewing a denied session) can understand why, matching this spec's own fail-closed-with-a-reason idiom elsewhere (`manage-error.message`, `threshold-abort.reason`).
18
+ */
19
+ export type SubjectDecision = {
20
+ authorise: true;
21
+ } | {
22
+ authorise: false;
23
+ reason: string;
24
+ };
25
+ /**
26
+ * The verifier obligation `spec/threshold.cddl` states directly: an unrecognised `kind` MUST be refused, never signed blindly. This is the fail-closed default every content policy is checked against BEFORE any kind-specific review runs; a caller's own policy closure only ever gets a chance to run for a kind it (or `KNOWN_KINDS`) actually recognises.
27
+ */
28
+ export declare function refuseUnrecognisedKind(subject: ThresholdSubject, known?: readonly string[]): SubjectDecision | undefined;
29
+ /**
30
+ * Reconstructs the exact bytes this participant signs its round-1 commitment (and, transitively, its round-2 share) over -- the Sig_structure built from THIS participant's own decoding of `protected`/`payload`, never a coordinator-supplied to-be-signed blob.
31
+ */
32
+ export declare function toBeSigned(subject: ThresholdSubject): Uint8Array<ArrayBuffer>;
33
+ //#endregion
@@ -0,0 +1,33 @@
1
+ //#region src/domain/threshold-subject.d.ts
2
+ /**
3
+ * The `kind` discriminator on `threshold-subject` -- an open `tstr` per `spec/CONVENTIONS.md`'s own open-tstr-over-closed-enum convention, since future content a group signs is not limited to what wire-mesh itself already defines self-certifying payloads for.
4
+ */
5
+ export interface ThresholdSubject {
6
+ kind: string;
7
+ /** `bstr .cbor cose-token-headers` -- the protected header the aggregate signature will carry. */
8
+ protected: Uint8Array;
9
+ /** `bstr .cbor` of the claims structure `kind` names. */
10
+ payload: Uint8Array;
11
+ }
12
+ /**
13
+ * The kinds this participant recognises out of the box -- `capability-token`, `revocation-entry`, `handle-record`, and `room-notice` are the self-certifying payload shapes this codebase already defines. A caller extending recognised kinds (e.g. an application-defined one) supplies its own recogniser rather than this module growing a closed list.
14
+ */
15
+ export declare const KNOWN_KINDS: readonly string[];
16
+ /**
17
+ * A participant's decision on whether to authorise a `threshold-subject`. Deliberately not a bare `boolean`: a refusal MUST carry a reason so the coordinator (and, ideally, a human reviewing a denied session) can understand why, matching this spec's own fail-closed-with-a-reason idiom elsewhere (`manage-error.message`, `threshold-abort.reason`).
18
+ */
19
+ export type SubjectDecision = {
20
+ authorise: true;
21
+ } | {
22
+ authorise: false;
23
+ reason: string;
24
+ };
25
+ /**
26
+ * The verifier obligation `spec/threshold.cddl` states directly: an unrecognised `kind` MUST be refused, never signed blindly. This is the fail-closed default every content policy is checked against BEFORE any kind-specific review runs; a caller's own policy closure only ever gets a chance to run for a kind it (or `KNOWN_KINDS`) actually recognises.
27
+ */
28
+ export declare function refuseUnrecognisedKind(subject: ThresholdSubject, known?: readonly string[]): SubjectDecision | undefined;
29
+ /**
30
+ * Reconstructs the exact bytes this participant signs its round-1 commitment (and, transitively, its round-2 share) over -- the Sig_structure built from THIS participant's own decoding of `protected`/`payload`, never a coordinator-supplied to-be-signed blob.
31
+ */
32
+ export declare function toBeSigned(subject: ThresholdSubject): Uint8Array<ArrayBuffer>;
33
+ //#endregion
@@ -0,0 +1,32 @@
1
+ import { i as sig1ToBeSigned } from "../tokens-B0dpTLhS.mjs";
2
+ //#region src/domain/threshold-subject.ts
3
+ /**
4
+ * `threshold-subject` -- what a signing session actually asks a group to sign, and the single most important design decision in the whole protocol: it carries the FULL decoded content, never a bare hash. A participant that commits to an opaque digest is a blind signer, and the entire security value of T-of-N is that each participant independently reviews and authorises the content -- returning a round-1 commitment IS that act of authorisation. This module builds exactly the bytes a participant signs its round-1 commitment over: the RFC 9052 §4.4 `Sig_structure`, reusing `tokens.ts`'s own `sig1ToBeSigned` rather than a second hand-rolled construction, and NEVER accepting a pre-assembled to-be-signed blob from a coordinator. Mirrors `wire_mesh_threshold::subject` on the Rust side exactly.
5
+ */
6
+ /**
7
+ * The kinds this participant recognises out of the box -- `capability-token`, `revocation-entry`, `handle-record`, and `room-notice` are the self-certifying payload shapes this codebase already defines. A caller extending recognised kinds (e.g. an application-defined one) supplies its own recogniser rather than this module growing a closed list.
8
+ */
9
+ const KNOWN_KINDS = [
10
+ "capability-token",
11
+ "revocation-entry",
12
+ "handle-record",
13
+ "room-notice"
14
+ ];
15
+ /**
16
+ * The verifier obligation `spec/threshold.cddl` states directly: an unrecognised `kind` MUST be refused, never signed blindly. This is the fail-closed default every content policy is checked against BEFORE any kind-specific review runs; a caller's own policy closure only ever gets a chance to run for a kind it (or `KNOWN_KINDS`) actually recognises.
17
+ */
18
+ function refuseUnrecognisedKind(subject, known = KNOWN_KINDS) {
19
+ if (known.includes(subject.kind)) return;
20
+ return {
21
+ authorise: false,
22
+ reason: `unrecognised threshold-subject.kind ${JSON.stringify(subject.kind)} -- refusing to sign`
23
+ };
24
+ }
25
+ /**
26
+ * Reconstructs the exact bytes this participant signs its round-1 commitment (and, transitively, its round-2 share) over -- the Sig_structure built from THIS participant's own decoding of `protected`/`payload`, never a coordinator-supplied to-be-signed blob.
27
+ */
28
+ function toBeSigned(subject) {
29
+ return Uint8Array.from(sig1ToBeSigned(subject.protected, subject.payload));
30
+ }
31
+ //#endregion
32
+ export { KNOWN_KINDS, refuseUnrecognisedKind, toBeSigned };
@@ -1,7 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_tokens = require("../tokens-DxGVURpB.cjs");
2
+ const require_tokens = require("../tokens-Dh6mG6p_.cjs");
3
3
  exports.canGrant = require_tokens.canGrant;
4
4
  exports.mintCapabilityToken = require_tokens.mintCapabilityToken;
5
5
  exports.mintRevocationEntry = require_tokens.mintRevocationEntry;
6
+ exports.sig1ToBeSigned = require_tokens.sig1ToBeSigned;
6
7
  exports.verifyCapabilityToken = require_tokens.verifyCapabilityToken;
7
8
  exports.verifyRevocationEntry = require_tokens.verifyRevocationEntry;
@@ -1,2 +1,2 @@
1
- import { a as RevocationCheck, c as TokenVerdict, d as VerifyRevocationEntryOptions, f as canGrant, g as verifyRevocationEntry, h as verifyCapabilityToken, i as MintVerdict, l as TokenVerdictReason, m as mintRevocationEntry, n as MintRefusalReason, o as RevocationEntryVerdict, p as mintCapabilityToken, r as MintRevocationEntryOptions, s as RevocationEntryVerdictReason, t as MintCapabilityTokenOptions, u as VerifyCapabilityTokenOptions } from "../tokens-C9Kwy0Gk.cjs";
2
- export { MintCapabilityTokenOptions, MintRefusalReason, MintRevocationEntryOptions, MintVerdict, RevocationCheck, RevocationEntryVerdict, RevocationEntryVerdictReason, TokenVerdict, TokenVerdictReason, VerifyCapabilityTokenOptions, VerifyRevocationEntryOptions, canGrant, mintCapabilityToken, mintRevocationEntry, verifyCapabilityToken, verifyRevocationEntry };
1
+ import { _ as verifyRevocationEntry, a as RevocationCheck, c as TokenVerdict, d as VerifyRevocationEntryOptions, f as canGrant, g as verifyCapabilityToken, h as sig1ToBeSigned, i as MintVerdict, l as TokenVerdictReason, m as mintRevocationEntry, n as MintRefusalReason, o as RevocationEntryVerdict, p as mintCapabilityToken, r as MintRevocationEntryOptions, s as RevocationEntryVerdictReason, t as MintCapabilityTokenOptions, u as VerifyCapabilityTokenOptions } from "../tokens-Cl8sQo7o.cjs";
2
+ export { MintCapabilityTokenOptions, MintRefusalReason, MintRevocationEntryOptions, MintVerdict, RevocationCheck, RevocationEntryVerdict, RevocationEntryVerdictReason, TokenVerdict, TokenVerdictReason, VerifyCapabilityTokenOptions, VerifyRevocationEntryOptions, canGrant, mintCapabilityToken, mintRevocationEntry, sig1ToBeSigned, verifyCapabilityToken, verifyRevocationEntry };
@@ -1,2 +1,2 @@
1
- import { a as RevocationCheck, c as TokenVerdict, d as VerifyRevocationEntryOptions, f as canGrant, g as verifyRevocationEntry, h as verifyCapabilityToken, i as MintVerdict, l as TokenVerdictReason, m as mintRevocationEntry, n as MintRefusalReason, o as RevocationEntryVerdict, p as mintCapabilityToken, r as MintRevocationEntryOptions, s as RevocationEntryVerdictReason, t as MintCapabilityTokenOptions, u as VerifyCapabilityTokenOptions } from "../tokens-k172l0Iy.mjs";
2
- export { MintCapabilityTokenOptions, MintRefusalReason, MintRevocationEntryOptions, MintVerdict, RevocationCheck, RevocationEntryVerdict, RevocationEntryVerdictReason, TokenVerdict, TokenVerdictReason, VerifyCapabilityTokenOptions, VerifyRevocationEntryOptions, canGrant, mintCapabilityToken, mintRevocationEntry, verifyCapabilityToken, verifyRevocationEntry };
1
+ import { _ as verifyRevocationEntry, a as RevocationCheck, c as TokenVerdict, d as VerifyRevocationEntryOptions, f as canGrant, g as verifyCapabilityToken, h as sig1ToBeSigned, i as MintVerdict, l as TokenVerdictReason, m as mintRevocationEntry, n as MintRefusalReason, o as RevocationEntryVerdict, p as mintCapabilityToken, r as MintRevocationEntryOptions, s as RevocationEntryVerdictReason, t as MintCapabilityTokenOptions, u as VerifyCapabilityTokenOptions } from "../tokens-CVyPoJ6l.mjs";
2
+ export { MintCapabilityTokenOptions, MintRefusalReason, MintRevocationEntryOptions, MintVerdict, RevocationCheck, RevocationEntryVerdict, RevocationEntryVerdictReason, TokenVerdict, TokenVerdictReason, VerifyCapabilityTokenOptions, VerifyRevocationEntryOptions, canGrant, mintCapabilityToken, mintRevocationEntry, sig1ToBeSigned, verifyCapabilityToken, verifyRevocationEntry };
@@ -1,2 +1,2 @@
1
- import { a as verifyRevocationEntry, i as verifyCapabilityToken, n as mintCapabilityToken, r as mintRevocationEntry, t as canGrant } from "../tokens-CdQwzCyJ.mjs";
2
- export { canGrant, mintCapabilityToken, mintRevocationEntry, verifyCapabilityToken, verifyRevocationEntry };
1
+ import { a as verifyCapabilityToken, i as sig1ToBeSigned, n as mintCapabilityToken, o as verifyRevocationEntry, r as mintRevocationEntry, t as canGrant } from "../tokens-B0dpTLhS.mjs";
2
+ export { canGrant, mintCapabilityToken, mintRevocationEntry, sig1ToBeSigned, verifyCapabilityToken, verifyRevocationEntry };
@@ -0,0 +1,107 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_tokens = require("../tokens-Dh6mG6p_.cjs");
3
+ //#region src/domain/webrtc-signaling.ts
4
+ /** The one capability verb gating every core/webrtc message shape: an authority over this node's own signaling as a whole, not three separate resources, mirroring how core/exec's exec:pty gates all of its own inner verbs. webrtc.sfu-track-map is gated by this same verb (see spec/webrtc.cddl's own comment): an SFU able to shape a negotiation can already misreport whose media is on which mid, so a separate capability over the track-map itself would guard nothing a client doesn't already have to trust the SFU for. */
5
+ const WEBRTC_SIGNAL_VERB = "webrtc:signal";
6
+ /** No path: there is no filesystem subtree involved in signaling, only the node itself. */
7
+ const WEBRTC_SIGNAL_SCOPE = { kind: "node" };
8
+ function isWebrtcOffer(params) {
9
+ return typeof params === "object" && "verb" in params && params.verb === "webrtc.offer";
10
+ }
11
+ function isWebrtcAnswer(params) {
12
+ return typeof params === "object" && "verb" in params && params.verb === "webrtc.answer";
13
+ }
14
+ function isWebrtcIceCandidate(params) {
15
+ return typeof params === "object" && "verb" in params && params.verb === "webrtc.ice-candidate";
16
+ }
17
+ function isSfuTrackMap(params) {
18
+ return typeof params === "object" && "verb" in params && params.verb === "webrtc.sfu-track-map";
19
+ }
20
+ function buildOfferCommand(negotiationId, sdp) {
21
+ return {
22
+ verb: WEBRTC_SIGNAL_VERB,
23
+ params: {
24
+ verb: "webrtc.offer",
25
+ "negotiation-id": negotiationId,
26
+ sdp
27
+ }
28
+ };
29
+ }
30
+ function buildAnswerCommand(negotiationId, sdp) {
31
+ return {
32
+ verb: WEBRTC_SIGNAL_VERB,
33
+ params: {
34
+ verb: "webrtc.answer",
35
+ "negotiation-id": negotiationId,
36
+ sdp
37
+ }
38
+ };
39
+ }
40
+ function buildIceCandidateCommand(negotiationId, candidate) {
41
+ return {
42
+ verb: WEBRTC_SIGNAL_VERB,
43
+ params: {
44
+ verb: "webrtc.ice-candidate",
45
+ "negotiation-id": negotiationId,
46
+ ...candidate !== void 0 ? { candidate } : {}
47
+ }
48
+ };
49
+ }
50
+ /** Builds the manage-command an SFU sends to report which room member each SDP mid on a negotiation belongs to: sent once a negotiation completes (the initial track set) and again, as a full resend rather than an incremental diff, on every membership change. An empty tracks array is itself a valid, meaningful message (the call is now empty), not a degenerate case. */
51
+ function buildSfuTrackMapCommand(negotiationId, tracks) {
52
+ return {
53
+ verb: WEBRTC_SIGNAL_VERB,
54
+ params: {
55
+ verb: "webrtc.sfu-track-map",
56
+ "negotiation-id": negotiationId,
57
+ tracks: [...tracks]
58
+ }
59
+ };
60
+ }
61
+ function wireIceCandidateFromRtc(candidate) {
62
+ return {
63
+ candidate: candidate.candidate,
64
+ ...candidate.sdpMid !== null ? { "sdp-mid": candidate.sdpMid } : {},
65
+ ...candidate.sdpMLineIndex !== null ? { "sdp-m-line-index": candidate.sdpMLineIndex } : {},
66
+ ...candidate.usernameFragment !== null ? { "username-fragment": candidate.usernameFragment } : {}
67
+ };
68
+ }
69
+ function rtcIceCandidateInitFromWire(wire) {
70
+ return {
71
+ candidate: wire.candidate,
72
+ ...wire["sdp-mid"] !== void 0 ? { sdpMid: wire["sdp-mid"] } : {},
73
+ ...wire["sdp-m-line-index"] !== void 0 ? { sdpMLineIndex: wire["sdp-m-line-index"] } : {},
74
+ ...wire["username-fragment"] !== void 0 ? { usernameFragment: wire["username-fragment"] } : {}
75
+ };
76
+ }
77
+ /** A fresh, independent, monotonically increasing negotiation-id source starting at 0, extracted as its own pure function so id allocation is testable without an RTCPeerConnection or any transport. */
78
+ function createNegotiationIdAllocator() {
79
+ let next = 0;
80
+ return () => {
81
+ const id = next;
82
+ next += 1;
83
+ return id;
84
+ };
85
+ }
86
+ /** True when an incoming offer's own token authorizes webrtc:signal against this node's scope: verifyCapabilityToken checks the token's own internal validity and delegation chain; the capability/scope match against what is actually being invoked here is this caller's own responsibility, same as any other domain's request handler. expectedBearer is deliberately not checked: neither a browser client's MeshSession nor an SFU's own connection handling exposes a way to learn a peer's device-id independently of the token itself, unlike a scope with a path that constrains a specific resource. */
87
+ async function authorizeIncomingOffer(incoming, options) {
88
+ if (incoming.token === void 0) return false;
89
+ const verdict = await require_tokens.verifyCapabilityToken(incoming.token, options);
90
+ if (!verdict.ok) return false;
91
+ return verdict.claims.capability === "webrtc:signal" && verdict.claims.scope.kind === WEBRTC_SIGNAL_SCOPE.kind;
92
+ }
93
+ //#endregion
94
+ exports.WEBRTC_SIGNAL_SCOPE = WEBRTC_SIGNAL_SCOPE;
95
+ exports.WEBRTC_SIGNAL_VERB = WEBRTC_SIGNAL_VERB;
96
+ exports.authorizeIncomingOffer = authorizeIncomingOffer;
97
+ exports.buildAnswerCommand = buildAnswerCommand;
98
+ exports.buildIceCandidateCommand = buildIceCandidateCommand;
99
+ exports.buildOfferCommand = buildOfferCommand;
100
+ exports.buildSfuTrackMapCommand = buildSfuTrackMapCommand;
101
+ exports.createNegotiationIdAllocator = createNegotiationIdAllocator;
102
+ exports.isSfuTrackMap = isSfuTrackMap;
103
+ exports.isWebrtcAnswer = isWebrtcAnswer;
104
+ exports.isWebrtcIceCandidate = isWebrtcIceCandidate;
105
+ exports.isWebrtcOffer = isWebrtcOffer;
106
+ exports.rtcIceCandidateInitFromWire = rtcIceCandidateInitFromWire;
107
+ exports.wireIceCandidateFromRtc = wireIceCandidateFromRtc;
@@ -0,0 +1,38 @@
1
+ import { $t as WebrtcOffer, H as ManageCommandParams, Mt as SfuTrackEntry, Nt as SfuTrackMap, Qt as WebrtcIceCandidate, V as ManageCommand, Zt as WebrtcAnswer, f as CapabilityScope, z as IceCandidateInit } from "../protocol-CNFRVx9w.cjs";
2
+ import { IncomingManageRequest } from "./mesh-session.cjs";
3
+ import { u as VerifyCapabilityTokenOptions } from "../tokens-Cl8sQo7o.cjs";
4
+ //#region src/domain/webrtc-signaling.d.ts
5
+ /** The one capability verb gating every core/webrtc message shape: an authority over this node's own signaling as a whole, not three separate resources, mirroring how core/exec's exec:pty gates all of its own inner verbs. webrtc.sfu-track-map is gated by this same verb (see spec/webrtc.cddl's own comment): an SFU able to shape a negotiation can already misreport whose media is on which mid, so a separate capability over the track-map itself would guard nothing a client doesn't already have to trust the SFU for. */
6
+ export declare const WEBRTC_SIGNAL_VERB = "webrtc:signal";
7
+ /** No path: there is no filesystem subtree involved in signaling, only the node itself. */
8
+ export declare const WEBRTC_SIGNAL_SCOPE: CapabilityScope;
9
+ export declare function isWebrtcOffer(params: ManageCommandParams): params is WebrtcOffer;
10
+ export declare function isWebrtcAnswer(params: ManageCommandParams): params is WebrtcAnswer;
11
+ export declare function isWebrtcIceCandidate(params: ManageCommandParams): params is WebrtcIceCandidate;
12
+ export declare function isSfuTrackMap(params: ManageCommandParams): params is SfuTrackMap;
13
+ export declare function buildOfferCommand(negotiationId: number, sdp: string): ManageCommand;
14
+ export declare function buildAnswerCommand(negotiationId: number, sdp: string): ManageCommand;
15
+ export declare function buildIceCandidateCommand(negotiationId: number, candidate?: Readonly<IceCandidateInit>): ManageCommand;
16
+ /** Builds the manage-command an SFU sends to report which room member each SDP mid on a negotiation belongs to: sent once a negotiation completes (the initial track set) and again, as a full resend rather than an incremental diff, on every membership change. An empty tracks array is itself a valid, meaningful message (the call is now empty), not a degenerate case. */
17
+ export declare function buildSfuTrackMapCommand(negotiationId: number, tracks: readonly SfuTrackEntry[]): ManageCommand;
18
+ /** The subset of RTCIceCandidate's own fields this module actually reads: a real RTCIceCandidate satisfies this structurally, and so does a plain test object or a server-side candidate description, with no cast needed either way. */
19
+ export type MinimalRtcIceCandidate = Readonly<{
20
+ candidate: string;
21
+ sdpMid: string | null;
22
+ sdpMLineIndex: number | null;
23
+ usernameFragment: string | null;
24
+ }>;
25
+ export declare function wireIceCandidateFromRtc(candidate: MinimalRtcIceCandidate): IceCandidateInit;
26
+ /** The subset of RTCIceCandidateInit's own shape this module produces: structurally identical to the DOM lib's own type (candidate, sdpMid, sdpMLineIndex, usernameFragment, each optional), so a caller in an environment with the DOM lib available (web-console) can pass this straight to RTCPeerConnection.addIceCandidate() with no cast, while core itself stays free of any DOM lib dependency. */
27
+ export interface WireRtcIceCandidateInit {
28
+ candidate?: string;
29
+ sdpMid?: string;
30
+ sdpMLineIndex?: number;
31
+ usernameFragment?: string;
32
+ }
33
+ export declare function rtcIceCandidateInitFromWire(wire: Readonly<IceCandidateInit>): WireRtcIceCandidateInit;
34
+ /** A fresh, independent, monotonically increasing negotiation-id source starting at 0, extracted as its own pure function so id allocation is testable without an RTCPeerConnection or any transport. */
35
+ export declare function createNegotiationIdAllocator(): () => number;
36
+ /** True when an incoming offer's own token authorizes webrtc:signal against this node's scope: verifyCapabilityToken checks the token's own internal validity and delegation chain; the capability/scope match against what is actually being invoked here is this caller's own responsibility, same as any other domain's request handler. expectedBearer is deliberately not checked: neither a browser client's MeshSession nor an SFU's own connection handling exposes a way to learn a peer's device-id independently of the token itself, unlike a scope with a path that constrains a specific resource. */
37
+ export declare function authorizeIncomingOffer(incoming: Readonly<IncomingManageRequest>, options: Readonly<VerifyCapabilityTokenOptions>): Promise<boolean>;
38
+ //#endregion
@@ -0,0 +1,38 @@
1
+ import { $t as WebrtcOffer, H as ManageCommandParams, Mt as SfuTrackEntry, Nt as SfuTrackMap, Qt as WebrtcIceCandidate, V as ManageCommand, Zt as WebrtcAnswer, f as CapabilityScope, z as IceCandidateInit } from "../protocol-CNFRVx9w.mjs";
2
+ import { IncomingManageRequest } from "./mesh-session.mjs";
3
+ import { u as VerifyCapabilityTokenOptions } from "../tokens-CVyPoJ6l.mjs";
4
+ //#region src/domain/webrtc-signaling.d.ts
5
+ /** The one capability verb gating every core/webrtc message shape: an authority over this node's own signaling as a whole, not three separate resources, mirroring how core/exec's exec:pty gates all of its own inner verbs. webrtc.sfu-track-map is gated by this same verb (see spec/webrtc.cddl's own comment): an SFU able to shape a negotiation can already misreport whose media is on which mid, so a separate capability over the track-map itself would guard nothing a client doesn't already have to trust the SFU for. */
6
+ export declare const WEBRTC_SIGNAL_VERB = "webrtc:signal";
7
+ /** No path: there is no filesystem subtree involved in signaling, only the node itself. */
8
+ export declare const WEBRTC_SIGNAL_SCOPE: CapabilityScope;
9
+ export declare function isWebrtcOffer(params: ManageCommandParams): params is WebrtcOffer;
10
+ export declare function isWebrtcAnswer(params: ManageCommandParams): params is WebrtcAnswer;
11
+ export declare function isWebrtcIceCandidate(params: ManageCommandParams): params is WebrtcIceCandidate;
12
+ export declare function isSfuTrackMap(params: ManageCommandParams): params is SfuTrackMap;
13
+ export declare function buildOfferCommand(negotiationId: number, sdp: string): ManageCommand;
14
+ export declare function buildAnswerCommand(negotiationId: number, sdp: string): ManageCommand;
15
+ export declare function buildIceCandidateCommand(negotiationId: number, candidate?: Readonly<IceCandidateInit>): ManageCommand;
16
+ /** Builds the manage-command an SFU sends to report which room member each SDP mid on a negotiation belongs to: sent once a negotiation completes (the initial track set) and again, as a full resend rather than an incremental diff, on every membership change. An empty tracks array is itself a valid, meaningful message (the call is now empty), not a degenerate case. */
17
+ export declare function buildSfuTrackMapCommand(negotiationId: number, tracks: readonly SfuTrackEntry[]): ManageCommand;
18
+ /** The subset of RTCIceCandidate's own fields this module actually reads: a real RTCIceCandidate satisfies this structurally, and so does a plain test object or a server-side candidate description, with no cast needed either way. */
19
+ export type MinimalRtcIceCandidate = Readonly<{
20
+ candidate: string;
21
+ sdpMid: string | null;
22
+ sdpMLineIndex: number | null;
23
+ usernameFragment: string | null;
24
+ }>;
25
+ export declare function wireIceCandidateFromRtc(candidate: MinimalRtcIceCandidate): IceCandidateInit;
26
+ /** The subset of RTCIceCandidateInit's own shape this module produces: structurally identical to the DOM lib's own type (candidate, sdpMid, sdpMLineIndex, usernameFragment, each optional), so a caller in an environment with the DOM lib available (web-console) can pass this straight to RTCPeerConnection.addIceCandidate() with no cast, while core itself stays free of any DOM lib dependency. */
27
+ export interface WireRtcIceCandidateInit {
28
+ candidate?: string;
29
+ sdpMid?: string;
30
+ sdpMLineIndex?: number;
31
+ usernameFragment?: string;
32
+ }
33
+ export declare function rtcIceCandidateInitFromWire(wire: Readonly<IceCandidateInit>): WireRtcIceCandidateInit;
34
+ /** A fresh, independent, monotonically increasing negotiation-id source starting at 0, extracted as its own pure function so id allocation is testable without an RTCPeerConnection or any transport. */
35
+ export declare function createNegotiationIdAllocator(): () => number;
36
+ /** True when an incoming offer's own token authorizes webrtc:signal against this node's scope: verifyCapabilityToken checks the token's own internal validity and delegation chain; the capability/scope match against what is actually being invoked here is this caller's own responsibility, same as any other domain's request handler. expectedBearer is deliberately not checked: neither a browser client's MeshSession nor an SFU's own connection handling exposes a way to learn a peer's device-id independently of the token itself, unlike a scope with a path that constrains a specific resource. */
37
+ export declare function authorizeIncomingOffer(incoming: Readonly<IncomingManageRequest>, options: Readonly<VerifyCapabilityTokenOptions>): Promise<boolean>;
38
+ //#endregion
@@ -0,0 +1,93 @@
1
+ import { a as verifyCapabilityToken } from "../tokens-B0dpTLhS.mjs";
2
+ //#region src/domain/webrtc-signaling.ts
3
+ /** The one capability verb gating every core/webrtc message shape: an authority over this node's own signaling as a whole, not three separate resources, mirroring how core/exec's exec:pty gates all of its own inner verbs. webrtc.sfu-track-map is gated by this same verb (see spec/webrtc.cddl's own comment): an SFU able to shape a negotiation can already misreport whose media is on which mid, so a separate capability over the track-map itself would guard nothing a client doesn't already have to trust the SFU for. */
4
+ const WEBRTC_SIGNAL_VERB = "webrtc:signal";
5
+ /** No path: there is no filesystem subtree involved in signaling, only the node itself. */
6
+ const WEBRTC_SIGNAL_SCOPE = { kind: "node" };
7
+ function isWebrtcOffer(params) {
8
+ return typeof params === "object" && "verb" in params && params.verb === "webrtc.offer";
9
+ }
10
+ function isWebrtcAnswer(params) {
11
+ return typeof params === "object" && "verb" in params && params.verb === "webrtc.answer";
12
+ }
13
+ function isWebrtcIceCandidate(params) {
14
+ return typeof params === "object" && "verb" in params && params.verb === "webrtc.ice-candidate";
15
+ }
16
+ function isSfuTrackMap(params) {
17
+ return typeof params === "object" && "verb" in params && params.verb === "webrtc.sfu-track-map";
18
+ }
19
+ function buildOfferCommand(negotiationId, sdp) {
20
+ return {
21
+ verb: WEBRTC_SIGNAL_VERB,
22
+ params: {
23
+ verb: "webrtc.offer",
24
+ "negotiation-id": negotiationId,
25
+ sdp
26
+ }
27
+ };
28
+ }
29
+ function buildAnswerCommand(negotiationId, sdp) {
30
+ return {
31
+ verb: WEBRTC_SIGNAL_VERB,
32
+ params: {
33
+ verb: "webrtc.answer",
34
+ "negotiation-id": negotiationId,
35
+ sdp
36
+ }
37
+ };
38
+ }
39
+ function buildIceCandidateCommand(negotiationId, candidate) {
40
+ return {
41
+ verb: WEBRTC_SIGNAL_VERB,
42
+ params: {
43
+ verb: "webrtc.ice-candidate",
44
+ "negotiation-id": negotiationId,
45
+ ...candidate !== void 0 ? { candidate } : {}
46
+ }
47
+ };
48
+ }
49
+ /** Builds the manage-command an SFU sends to report which room member each SDP mid on a negotiation belongs to: sent once a negotiation completes (the initial track set) and again, as a full resend rather than an incremental diff, on every membership change. An empty tracks array is itself a valid, meaningful message (the call is now empty), not a degenerate case. */
50
+ function buildSfuTrackMapCommand(negotiationId, tracks) {
51
+ return {
52
+ verb: WEBRTC_SIGNAL_VERB,
53
+ params: {
54
+ verb: "webrtc.sfu-track-map",
55
+ "negotiation-id": negotiationId,
56
+ tracks: [...tracks]
57
+ }
58
+ };
59
+ }
60
+ function wireIceCandidateFromRtc(candidate) {
61
+ return {
62
+ candidate: candidate.candidate,
63
+ ...candidate.sdpMid !== null ? { "sdp-mid": candidate.sdpMid } : {},
64
+ ...candidate.sdpMLineIndex !== null ? { "sdp-m-line-index": candidate.sdpMLineIndex } : {},
65
+ ...candidate.usernameFragment !== null ? { "username-fragment": candidate.usernameFragment } : {}
66
+ };
67
+ }
68
+ function rtcIceCandidateInitFromWire(wire) {
69
+ return {
70
+ candidate: wire.candidate,
71
+ ...wire["sdp-mid"] !== void 0 ? { sdpMid: wire["sdp-mid"] } : {},
72
+ ...wire["sdp-m-line-index"] !== void 0 ? { sdpMLineIndex: wire["sdp-m-line-index"] } : {},
73
+ ...wire["username-fragment"] !== void 0 ? { usernameFragment: wire["username-fragment"] } : {}
74
+ };
75
+ }
76
+ /** A fresh, independent, monotonically increasing negotiation-id source starting at 0, extracted as its own pure function so id allocation is testable without an RTCPeerConnection or any transport. */
77
+ function createNegotiationIdAllocator() {
78
+ let next = 0;
79
+ return () => {
80
+ const id = next;
81
+ next += 1;
82
+ return id;
83
+ };
84
+ }
85
+ /** True when an incoming offer's own token authorizes webrtc:signal against this node's scope: verifyCapabilityToken checks the token's own internal validity and delegation chain; the capability/scope match against what is actually being invoked here is this caller's own responsibility, same as any other domain's request handler. expectedBearer is deliberately not checked: neither a browser client's MeshSession nor an SFU's own connection handling exposes a way to learn a peer's device-id independently of the token itself, unlike a scope with a path that constrains a specific resource. */
86
+ async function authorizeIncomingOffer(incoming, options) {
87
+ if (incoming.token === void 0) return false;
88
+ const verdict = await verifyCapabilityToken(incoming.token, options);
89
+ if (!verdict.ok) return false;
90
+ return verdict.claims.capability === "webrtc:signal" && verdict.claims.scope.kind === WEBRTC_SIGNAL_SCOPE.kind;
91
+ }
92
+ //#endregion
93
+ export { WEBRTC_SIGNAL_SCOPE, WEBRTC_SIGNAL_VERB, authorizeIncomingOffer, buildAnswerCommand, buildIceCandidateCommand, buildOfferCommand, buildSfuTrackMapCommand, createNegotiationIdAllocator, isSfuTrackMap, isWebrtcAnswer, isWebrtcIceCandidate, isWebrtcOffer, rtcIceCandidateInitFromWire, wireIceCandidateFromRtc };