wire-mesh-core 3.8.0 → 3.9.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 (55) hide show
  1. package/dist/domain/capability-grant.cjs +4 -4
  2. package/dist/domain/capability-grant.d.cts +1 -1
  3. package/dist/domain/capability-grant.d.mts +1 -1
  4. package/dist/domain/capability-grant.mjs +2 -2
  5. package/dist/domain/capability-request.cjs +18 -6
  6. package/dist/domain/capability-request.d.cts +8 -1
  7. package/dist/domain/capability-request.d.mts +8 -1
  8. package/dist/domain/capability-request.mjs +15 -4
  9. package/dist/domain/grant-candidates.cjs +2 -2
  10. package/dist/domain/grant-candidates.mjs +1 -1
  11. package/dist/domain/mesh-session.cjs +2 -2
  12. package/dist/domain/mesh-session.mjs +1 -1
  13. package/dist/domain/notice-board.d.cts +1 -1
  14. package/dist/domain/notice-board.d.mts +1 -1
  15. package/dist/domain/peer-advert.cjs +2 -2
  16. package/dist/domain/peer-advert.mjs +1 -1
  17. package/dist/domain/revocation-view.cjs +2 -2
  18. package/dist/domain/revocation-view.d.cts +1 -1
  19. package/dist/domain/revocation-view.d.mts +1 -1
  20. package/dist/domain/revocation-view.mjs +1 -1
  21. package/dist/domain/room-rekey.d.cts +1 -1
  22. package/dist/domain/room-rekey.d.mts +1 -1
  23. package/dist/domain/room-token-verification.cjs +2 -2
  24. package/dist/domain/room-token-verification.d.cts +1 -1
  25. package/dist/domain/room-token-verification.d.mts +1 -1
  26. package/dist/domain/room-token-verification.mjs +1 -1
  27. package/dist/domain/room.d.cts +2 -2
  28. package/dist/domain/room.d.mts +2 -2
  29. package/dist/domain/threshold-subject.cjs +2 -2
  30. package/dist/domain/threshold-subject.mjs +1 -1
  31. package/dist/domain/token-predicates.cjs +184 -0
  32. package/dist/domain/token-predicates.d.cts +2 -0
  33. package/dist/domain/token-predicates.d.mts +2 -0
  34. package/dist/domain/token-predicates.mjs +173 -0
  35. package/dist/{token-scope-CxHXTT3u.cjs → domain/token-scope.cjs} +3 -12
  36. package/dist/domain/token-scope.d.cts +11 -0
  37. package/dist/domain/token-scope.d.mts +11 -0
  38. package/dist/{token-scope-Z4bmci4M.mjs → domain/token-scope.mjs} +1 -1
  39. package/dist/domain/tokens.cjs +466 -9
  40. package/dist/domain/tokens.d.cts +131 -2
  41. package/dist/domain/tokens.d.mts +131 -2
  42. package/dist/domain/tokens.mjs +458 -1
  43. package/dist/domain/webrtc-signaling.cjs +2 -2
  44. package/dist/domain/webrtc-signaling.d.cts +1 -1
  45. package/dist/domain/webrtc-signaling.d.mts +1 -1
  46. package/dist/domain/webrtc-signaling.mjs +1 -1
  47. package/dist/{room-token-verification-hFtBDZPO.d.cts → room-token-verification-BpQ6yJtj.d.cts} +1 -1
  48. package/dist/{room-token-verification-7zD4ib-A.d.mts → room-token-verification-CTQSihUO.d.mts} +1 -1
  49. package/dist/token-predicates-C-aIe1DT.d.cts +72 -0
  50. package/dist/token-predicates-DqvyS7Y8.d.mts +72 -0
  51. package/package.json +9 -1
  52. package/dist/tokens-BMWCnQEF.d.cts +0 -158
  53. package/dist/tokens-D8JlTJNA.mjs +0 -617
  54. package/dist/tokens-DRkm_QOR.d.mts +0 -158
  55. package/dist/tokens-tPJQ7Vzt.cjs +0 -664
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_generated_protocol = require("../generated/protocol.cjs");
3
- const require_token_scope = require("../token-scope-CxHXTT3u.cjs");
4
- const require_tokens = require("../tokens-tPJQ7Vzt.cjs");
3
+ const require_domain_token_scope = require("./token-scope.cjs");
4
+ const require_domain_tokens = require("./tokens.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.
@@ -49,7 +49,7 @@ function createCapabilityGrantHandler(options) {
49
49
  return;
50
50
  }
51
51
  const grantedToken = parsed.data["granted-token"];
52
- const verdict = await require_tokens.verifyCapabilityToken(grantedToken, {
52
+ const verdict = await require_domain_tokens.verifyCapabilityToken(grantedToken, {
53
53
  identity: options.identity,
54
54
  clock: options.clock,
55
55
  revocation: options.revocation,
@@ -69,7 +69,7 @@ function createCapabilityGrantHandler(options) {
69
69
  });
70
70
  return;
71
71
  }
72
- if (!require_token_scope.scopeNarrows(verdict.claims.scope, incoming.scope)) {
72
+ if (!require_domain_token_scope.scopeNarrows(verdict.claims.scope, incoming.scope)) {
73
73
  await incoming.respond({
74
74
  result: "error",
75
75
  code: "scope_mismatch"
@@ -2,7 +2,7 @@ import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as Capabilit
2
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 { o as RevocationCheck } from "../tokens-BMWCnQEF.cjs";
5
+ import { RevocationCheck } from "./tokens.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.
@@ -2,7 +2,7 @@ import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as Capabilit
2
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 { o as RevocationCheck } from "../tokens-DRkm_QOR.mjs";
5
+ import { RevocationCheck } from "./tokens.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
- import { n as scopeNarrows } from "../token-scope-Z4bmci4M.mjs";
3
- import { s as verifyCapabilityToken } from "../tokens-D8JlTJNA.mjs";
2
+ import { scopeNarrows } from "./token-scope.mjs";
3
+ import { verifyCapabilityToken } from "./tokens.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,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_generated_protocol = require("../generated/protocol.cjs");
3
- const require_token_scope = require("../token-scope-CxHXTT3u.cjs");
4
- const require_tokens = require("../tokens-tPJQ7Vzt.cjs");
3
+ const require_domain_token_scope = require("./token-scope.cjs");
4
+ const require_domain_tokens = require("./tokens.cjs");
5
5
  //#region src/domain/capability-request.ts
6
6
  /**
7
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.
@@ -31,6 +31,17 @@ function buildCapabilityRequestCommand(capability, validUntil) {
31
31
  }
32
32
  };
33
33
  }
34
+ /** A capability request the other side answered with a manage-error. The code is the receiver's own (`denied` for a human's no, `token_required`, `capability_mismatch` or `scope_mismatch` from the request-permission gate, or a verifier reason for a presented token it did not accept), kept as a field so a caller can tell a policy refusal from a person's decision without parsing the message. */
35
+ var CapabilityRequestRefusedError = class extends Error {
36
+ capability;
37
+ code;
38
+ constructor(capability, code) {
39
+ super(`capability request for "${capability}" was refused (${code})`);
40
+ this.name = "CapabilityRequestRefusedError";
41
+ this.capability = capability;
42
+ this.code = code;
43
+ }
44
+ };
34
45
  /**
35
46
  * Sends a deliberately ungated capability-request (no token field at all -- per management.cddl's own header comment, this primitive puts access control entirely in the receiving side's own decision, not a capability check on the request itself, the same design room.join already established). Resolves with the freshly granted capability-grant-ok on approval (its own open `* tstr => any` tail may carry domain-specific extension fields, e.g. core/room's member list -- a caller that needs those parses the raw result itself, the same way room-client.ts's own requestToJoin wrapper does); rejects on denial (an ordinary manage-error) or a malformed response.
36
47
  *
@@ -38,7 +49,7 @@ function buildCapabilityRequestCommand(capability, validUntil) {
38
49
  */
39
50
  async function requestCapability(session, capability, scope, targetDevice, timeoutMs, validUntil, requestToken) {
40
51
  const outcome = await session.sendManageRequest(buildCapabilityRequestCommand(capability, validUntil), scope, targetDevice, requestToken, timeoutMs);
41
- if (outcome.result !== "ok") throw new Error(`capability request for "${capability}" was refused (${outcome.code})`);
52
+ if (outcome.result !== "ok") throw new CapabilityRequestRefusedError(capability, outcome.code);
42
53
  const parsed = require_generated_protocol.capabilityGrantOkSchema.safeParse(outcome);
43
54
  if (!parsed.success) throw new Error(`capability request for "${capability}" response was malformed`);
44
55
  return parsed.data;
@@ -52,7 +63,7 @@ async function checkRequestPermission(incoming, options) {
52
63
  code: "token_required"
53
64
  };
54
65
  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, {
66
+ const verdict = await require_domain_tokens.verifyCapabilityToken(incoming.token, {
56
67
  identity: options.identity,
57
68
  clock: options.clock,
58
69
  revocation: options.revocation,
@@ -72,7 +83,7 @@ async function checkRequestPermission(incoming, options) {
72
83
  ok: false,
73
84
  code: "capability_mismatch"
74
85
  };
75
- if (!require_token_scope.scopeNarrows(verdict.claims.scope, incoming.scope)) return {
86
+ if (!require_domain_token_scope.scopeNarrows(verdict.claims.scope, incoming.scope)) return {
76
87
  ok: false,
77
88
  code: "scope_mismatch"
78
89
  };
@@ -136,7 +147,7 @@ function createCapabilityRequestHandler(options) {
136
147
  });
137
148
  return;
138
149
  }
139
- const verdict = await require_tokens.mintCapabilityToken({
150
+ const verdict = await require_domain_tokens.mintCapabilityToken({
140
151
  identity: options.identity,
141
152
  clock: options.clock,
142
153
  tokenId: randomTokenId(),
@@ -164,6 +175,7 @@ function createCapabilityRequestHandler(options) {
164
175
  };
165
176
  }
166
177
  //#endregion
178
+ exports.CapabilityRequestRefusedError = CapabilityRequestRefusedError;
167
179
  exports.MANAGE_REQUEST_CAPABILITY = MANAGE_REQUEST_CAPABILITY;
168
180
  exports.buildCapabilityRequestCommand = buildCapabilityRequestCommand;
169
181
  exports.createCapabilityRequestHandler = createCapabilityRequestHandler;
@@ -2,12 +2,19 @@ import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as Capabilit
2
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
+ import { m as TokenDelegateHandler, r as ConditionsContext } from "../token-predicates-C-aIe1DT.cjs";
6
+ import { RevocationCheck } from "./tokens.cjs";
6
7
  //#region src/domain/capability-request.d.ts
7
8
  /**
8
9
  * 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.
9
10
  */
10
11
  export declare function buildCapabilityRequestCommand(capability: string, validUntil?: number): ManageCommand;
12
+ /** A capability request the other side answered with a manage-error. The code is the receiver's own (`denied` for a human's no, `token_required`, `capability_mismatch` or `scope_mismatch` from the request-permission gate, or a verifier reason for a presented token it did not accept), kept as a field so a caller can tell a policy refusal from a person's decision without parsing the message. */
13
+ export declare class CapabilityRequestRefusedError extends Error {
14
+ readonly capability: string;
15
+ readonly code: string;
16
+ constructor(capability: string, code: string);
17
+ }
11
18
  /**
12
19
  * Sends a deliberately ungated capability-request (no token field at all -- per management.cddl's own header comment, this primitive puts access control entirely in the receiving side's own decision, not a capability check on the request itself, the same design room.join already established). Resolves with the freshly granted capability-grant-ok on approval (its own open `* tstr => any` tail may carry domain-specific extension fields, e.g. core/room's member list -- a caller that needs those parses the raw result itself, the same way room-client.ts's own requestToJoin wrapper does); rejects on denial (an ordinary manage-error) or a malformed response.
13
20
  *
@@ -2,12 +2,19 @@ import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as Capabilit
2
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
+ import { m as TokenDelegateHandler, r as ConditionsContext } from "../token-predicates-DqvyS7Y8.mjs";
6
+ import { RevocationCheck } from "./tokens.mjs";
6
7
  //#region src/domain/capability-request.d.ts
7
8
  /**
8
9
  * 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.
9
10
  */
10
11
  export declare function buildCapabilityRequestCommand(capability: string, validUntil?: number): ManageCommand;
12
+ /** A capability request the other side answered with a manage-error. The code is the receiver's own (`denied` for a human's no, `token_required`, `capability_mismatch` or `scope_mismatch` from the request-permission gate, or a verifier reason for a presented token it did not accept), kept as a field so a caller can tell a policy refusal from a person's decision without parsing the message. */
13
+ export declare class CapabilityRequestRefusedError extends Error {
14
+ readonly capability: string;
15
+ readonly code: string;
16
+ constructor(capability: string, code: string);
17
+ }
11
18
  /**
12
19
  * Sends a deliberately ungated capability-request (no token field at all -- per management.cddl's own header comment, this primitive puts access control entirely in the receiving side's own decision, not a capability check on the request itself, the same design room.join already established). Resolves with the freshly granted capability-grant-ok on approval (its own open `* tstr => any` tail may carry domain-specific extension fields, e.g. core/room's member list -- a caller that needs those parses the raw result itself, the same way room-client.ts's own requestToJoin wrapper does); rejects on denial (an ordinary manage-error) or a malformed response.
13
20
  *
@@ -1,6 +1,6 @@
1
1
  import { capabilityGrantOkSchema, capabilityRequestSchema } from "../generated/protocol.mjs";
2
- import { n as scopeNarrows } from "../token-scope-Z4bmci4M.mjs";
3
- import { i as mintCapabilityToken, s as verifyCapabilityToken } from "../tokens-D8JlTJNA.mjs";
2
+ import { scopeNarrows } from "./token-scope.mjs";
3
+ import { mintCapabilityToken, verifyCapabilityToken } from "./tokens.mjs";
4
4
  //#region src/domain/capability-request.ts
5
5
  /**
6
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.
@@ -30,6 +30,17 @@ function buildCapabilityRequestCommand(capability, validUntil) {
30
30
  }
31
31
  };
32
32
  }
33
+ /** A capability request the other side answered with a manage-error. The code is the receiver's own (`denied` for a human's no, `token_required`, `capability_mismatch` or `scope_mismatch` from the request-permission gate, or a verifier reason for a presented token it did not accept), kept as a field so a caller can tell a policy refusal from a person's decision without parsing the message. */
34
+ var CapabilityRequestRefusedError = class extends Error {
35
+ capability;
36
+ code;
37
+ constructor(capability, code) {
38
+ super(`capability request for "${capability}" was refused (${code})`);
39
+ this.name = "CapabilityRequestRefusedError";
40
+ this.capability = capability;
41
+ this.code = code;
42
+ }
43
+ };
33
44
  /**
34
45
  * Sends a deliberately ungated capability-request (no token field at all -- per management.cddl's own header comment, this primitive puts access control entirely in the receiving side's own decision, not a capability check on the request itself, the same design room.join already established). Resolves with the freshly granted capability-grant-ok on approval (its own open `* tstr => any` tail may carry domain-specific extension fields, e.g. core/room's member list -- a caller that needs those parses the raw result itself, the same way room-client.ts's own requestToJoin wrapper does); rejects on denial (an ordinary manage-error) or a malformed response.
35
46
  *
@@ -37,7 +48,7 @@ function buildCapabilityRequestCommand(capability, validUntil) {
37
48
  */
38
49
  async function requestCapability(session, capability, scope, targetDevice, timeoutMs, validUntil, requestToken) {
39
50
  const outcome = await session.sendManageRequest(buildCapabilityRequestCommand(capability, validUntil), scope, targetDevice, requestToken, timeoutMs);
40
- if (outcome.result !== "ok") throw new Error(`capability request for "${capability}" was refused (${outcome.code})`);
51
+ if (outcome.result !== "ok") throw new CapabilityRequestRefusedError(capability, outcome.code);
41
52
  const parsed = capabilityGrantOkSchema.safeParse(outcome);
42
53
  if (!parsed.success) throw new Error(`capability request for "${capability}" response was malformed`);
43
54
  return parsed.data;
@@ -163,4 +174,4 @@ function createCapabilityRequestHandler(options) {
163
174
  };
164
175
  }
165
176
  //#endregion
166
- export { MANAGE_REQUEST_CAPABILITY, buildCapabilityRequestCommand, createCapabilityRequestHandler, requestCapability };
177
+ export { CapabilityRequestRefusedError, MANAGE_REQUEST_CAPABILITY, buildCapabilityRequestCommand, createCapabilityRequestHandler, requestCapability };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_generated_protocol = require("../generated/protocol.cjs");
3
- const require_token_scope = require("../token-scope-CxHXTT3u.cjs");
3
+ const require_domain_token_scope = require("./token-scope.cjs");
4
4
  let zod = require("zod");
5
5
  //#region src/domain/grant-candidates.ts
6
6
  /**
@@ -38,7 +38,7 @@ function findGrantCandidate(directory, capability, scope) {
38
38
  if (candidate.capability !== capability) continue;
39
39
  const remaining = candidate["delegations-remaining"];
40
40
  if (remaining !== void 0 && remaining <= 0) continue;
41
- if (require_token_scope.scopeNarrows(candidate.scope, scope)) return entry.device;
41
+ if (require_domain_token_scope.scopeNarrows(candidate.scope, scope)) return entry.device;
42
42
  }
43
43
  }
44
44
  }
@@ -1,5 +1,5 @@
1
1
  import { capabilityScopeSchema } from "../generated/protocol.mjs";
2
- import { n as scopeNarrows } from "../token-scope-Z4bmci4M.mjs";
2
+ import { scopeNarrows } from "./token-scope.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/domain/grant-candidates.ts
5
5
  /**
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_adapters_frame_codec = require("../adapters/frame-codec.cjs");
3
3
  const require_domain_device_id = require("./device-id.cjs");
4
- const require_token_scope = require("../token-scope-CxHXTT3u.cjs");
4
+ const require_domain_token_scope = require("./token-scope.cjs");
5
5
  const require_gossip_extensions = require("../gossip-extensions-BBYgMZ2N.cjs");
6
6
  const require_domain_peer_advert = require("./peer-advert.cjs");
7
7
  const require_domain_async_queue = require("./async-queue.cjs");
@@ -101,7 +101,7 @@ async function verifyHello(identity, hello) {
101
101
  const key = hello["identity-key"];
102
102
  try {
103
103
  const sender = await identity.deriveDeviceId(key["public-key"]);
104
- if (!require_token_scope.bytesEqual(hello["to-device"], identity.deviceId)) return {
104
+ if (!require_domain_token_scope.bytesEqual(hello["to-device"], identity.deviceId)) return {
105
105
  ok: false,
106
106
  reason: "wrong_recipient"
107
107
  };
@@ -1,6 +1,6 @@
1
1
  import { messageFromFrame, tryDecodeFrame, wrapRelayData } from "../adapters/frame-codec.mjs";
2
2
  import { deviceIdToHex } from "./device-id.mjs";
3
- import { t as bytesEqual } from "../token-scope-Z4bmci4M.mjs";
3
+ import { bytesEqual } from "./token-scope.mjs";
4
4
  import { a as OWN_VERSION, i as CORE_VERSION_GOSSIP_KEY, n as TOPOLOGY_PEERS_GOSSIP_KEY, o as isVersionGetCommand, r as validateGossipExtensions, s as versionGetOutcome } from "../gossip-extensions-B6WJjkAr.mjs";
5
5
  import { signPeerAdvert, verifyPeerAdvert } from "./peer-advert.mjs";
6
6
  import { createAsyncQueue } from "./async-queue.mjs";
@@ -2,7 +2,7 @@ import { D as DeviceId, Ot as RoomNotice, T as DataHaveFrame, kt as RoomNoticeCl
2
2
  import { t as KeyValueStorage } from "../storage-B403CRyu.cjs";
3
3
  import { t as IdentityPort } from "../identity-DJbr96J3.cjs";
4
4
  import { t as Clock } from "../clock-DiSx-WKM.cjs";
5
- import { o as RevocationCheck } from "../tokens-BMWCnQEF.cjs";
5
+ import { RevocationCheck } from "./tokens.cjs";
6
6
  import { RoomNoticeVerdictReason } from "./room.cjs";
7
7
  //#region src/domain/notice-board.d.ts
8
8
  /**
@@ -2,7 +2,7 @@ import { D as DeviceId, Ot as RoomNotice, T as DataHaveFrame, kt as RoomNoticeCl
2
2
  import { t as KeyValueStorage } from "../storage-B403CRyu.mjs";
3
3
  import { t as IdentityPort } from "../identity-ViYdZrIU.mjs";
4
4
  import { t as Clock } from "../clock-DiSx-WKM.mjs";
5
- import { o as RevocationCheck } from "../tokens-DRkm_QOR.mjs";
5
+ import { RevocationCheck } from "./tokens.mjs";
6
6
  import { RoomNoticeVerdictReason } from "./room.mjs";
7
7
  //#region src/domain/notice-board.d.ts
8
8
  /**
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_token_scope = require("../token-scope-CxHXTT3u.cjs");
2
+ const require_domain_token_scope = require("./token-scope.cjs");
3
3
  let cbor2 = require("cbor2");
4
4
  //#region src/domain/peer-advert.ts
5
5
  /** peer-advert's own signature field, the one entry the signature does not cover, named once here so the signing input and the reserved-extension-key guard cannot drift apart. */
@@ -46,7 +46,7 @@ async function verifyPeerAdvert(identity, advert) {
46
46
  const key = advert[PEER_ADVERT_IDENTITY_KEY_KEY];
47
47
  try {
48
48
  const derived = await identity.deriveDeviceId(key["public-key"]);
49
- if (!require_token_scope.bytesEqual(derived, advert.device)) return false;
49
+ if (!require_domain_token_scope.bytesEqual(derived, advert.device)) return false;
50
50
  return await identity.verify(key, peerAdvertSigningInput(advert), advert[PEER_ADVERT_SIGNATURE_KEY]);
51
51
  } catch {
52
52
  return false;
@@ -1,4 +1,4 @@
1
- import { t as bytesEqual } from "../token-scope-Z4bmci4M.mjs";
1
+ import { bytesEqual } from "./token-scope.mjs";
2
2
  import { cdeEncodeOptions, encode } from "cbor2";
3
3
  //#region src/domain/peer-advert.ts
4
4
  /** peer-advert's own signature field, the one entry the signature does not cover, named once here so the signing input and the reserved-extension-key guard cannot drift apart. */
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_domain_device_id = require("./device-id.cjs");
3
- const require_tokens = require("../tokens-tPJQ7Vzt.cjs");
3
+ const require_domain_tokens = require("./tokens.cjs");
4
4
  //#region src/domain/revocation-view.ts
5
5
  function revocationKey(tokenId) {
6
6
  return require_domain_device_id.bytesToHex(tokenId);
@@ -12,7 +12,7 @@ function createRevocationView() {
12
12
  return Promise.resolve(entriesByTokenId.get(revocationKey(tokenId)) ?? []);
13
13
  },
14
14
  async record(entry, options) {
15
- const verdict = await require_tokens.verifyRevocationEntry(entry, options);
15
+ const verdict = await require_domain_tokens.verifyRevocationEntry(entry, options);
16
16
  if (verdict.ok) {
17
17
  const key = revocationKey(verdict.claims["token-id"]);
18
18
  const existing = entriesByTokenId.get(key);
@@ -1,5 +1,5 @@
1
1
  import { bt as RevocationEntry } from "../protocol-BgR1e_NI.cjs";
2
- import { f as VerifyRevocationEntryOptions, o as RevocationCheck, s as RevocationEntryVerdict } from "../tokens-BMWCnQEF.cjs";
2
+ import { RevocationCheck, RevocationEntryVerdict, VerifyRevocationEntryOptions } from "./tokens.cjs";
3
3
  //#region src/domain/revocation-view.d.ts
4
4
  /**
5
5
  * An in-memory RevocationCheck fed by ingested revocation-announce frames. Keyed by token-id alone, per management.cddl's contract: a token-id can legitimately carry multiple recorded entries from different issuers (the token's own issuer, and/or any number of parties holding a delegated manage:revoke authorization over it) -- entriesFor returns every one of them unfiltered, since checking which actually apply (issuer-match, or a verified authorization) is verifyTokenChain's own obligation, not this store's.
@@ -1,5 +1,5 @@
1
1
  import { bt as RevocationEntry } from "../protocol-BgR1e_NI.mjs";
2
- import { f as VerifyRevocationEntryOptions, o as RevocationCheck, s as RevocationEntryVerdict } from "../tokens-DRkm_QOR.mjs";
2
+ import { RevocationCheck, RevocationEntryVerdict, VerifyRevocationEntryOptions } from "./tokens.mjs";
3
3
  //#region src/domain/revocation-view.d.ts
4
4
  /**
5
5
  * An in-memory RevocationCheck fed by ingested revocation-announce frames. Keyed by token-id alone, per management.cddl's contract: a token-id can legitimately carry multiple recorded entries from different issuers (the token's own issuer, and/or any number of parties holding a delegated manage:revoke authorization over it) -- entriesFor returns every one of them unfiltered, since checking which actually apply (issuer-match, or a verified authorization) is verifyTokenChain's own obligation, not this store's.
@@ -1,5 +1,5 @@
1
1
  import { bytesToHex } from "./device-id.mjs";
2
- import { c as verifyRevocationEntry } from "../tokens-D8JlTJNA.mjs";
2
+ import { verifyRevocationEntry } from "./tokens.mjs";
3
3
  //#region src/domain/revocation-view.ts
4
4
  function revocationKey(tokenId) {
5
5
  return bytesToHex(tokenId);
@@ -2,7 +2,7 @@ import { D as DeviceId, V as ManageCommand, p as CapabilityToken } from "../prot
2
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 { o as RevocationCheck } from "../tokens-BMWCnQEF.cjs";
5
+ import { RevocationCheck } from "./tokens.cjs";
6
6
  //#region src/domain/room-rekey.d.ts
7
7
  /**
8
8
  * Builds a room.rekey command per room.cddl. The outer verb is room:member, the same "one resource, several inner verbs" pattern room.send/room.leave/room.members already establish -- not a new capability of its own.
@@ -2,7 +2,7 @@ import { D as DeviceId, V as ManageCommand, p as CapabilityToken } from "../prot
2
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 { o as RevocationCheck } from "../tokens-DRkm_QOR.mjs";
5
+ import { RevocationCheck } from "./tokens.mjs";
6
6
  //#region src/domain/room-rekey.d.ts
7
7
  /**
8
8
  * Builds a room.rekey command per room.cddl. The outer verb is room:member, the same "one resource, several inner verbs" pattern room.send/room.leave/room.members already establish -- not a new capability of its own.
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_domain_device_id = require("./device-id.cjs");
3
- const require_tokens = require("../tokens-tPJQ7Vzt.cjs");
3
+ const require_domain_tokens = require("./tokens.cjs");
4
4
  const require_domain_room_path = require("./room-path.cjs");
5
5
  //#region src/domain/room-token-verification.ts
6
6
  /**
@@ -12,7 +12,7 @@ const ROOM_MEMBER_CAPABILITY = "room:member";
12
12
  * Verifies a `room:member` capability token against all six of core/room's verifier obligations. Delegates obligations 2/4/5 to verifyCapabilityToken directly; adds obligation 3 (scope.kind/scope.path must match the room being acted on) and obligation 1 (the chain's root must be the room's own owner for a named room, or the verifying identity itself for a DM -- never either named participant directly, since a DM token minted by anyone other than the verifier would let a sender self-issue authority to message a stranger unsolicited).
13
13
  */
14
14
  async function verifyRoomToken(token, options) {
15
- const verdict = await require_tokens.verifyCapabilityToken(token, {
15
+ const verdict = await require_domain_tokens.verifyCapabilityToken(token, {
16
16
  identity: options.identity,
17
17
  clock: options.clock,
18
18
  revocation: options.revocation,
@@ -1,2 +1,2 @@
1
- import { a as verifyRoomToken, i as VerifyRoomTokenOptions, n as RoomTokenVerdict, r as RoomTokenVerdictReason, t as ROOM_MEMBER_CAPABILITY } from "../room-token-verification-hFtBDZPO.cjs";
1
+ import { a as verifyRoomToken, i as VerifyRoomTokenOptions, n as RoomTokenVerdict, r as RoomTokenVerdictReason, t as ROOM_MEMBER_CAPABILITY } from "../room-token-verification-BpQ6yJtj.cjs";
2
2
  export { ROOM_MEMBER_CAPABILITY, RoomTokenVerdict, RoomTokenVerdictReason, VerifyRoomTokenOptions, verifyRoomToken };
@@ -1,2 +1,2 @@
1
- import { a as verifyRoomToken, i as VerifyRoomTokenOptions, n as RoomTokenVerdict, r as RoomTokenVerdictReason, t as ROOM_MEMBER_CAPABILITY } from "../room-token-verification-7zD4ib-A.mjs";
1
+ import { a as verifyRoomToken, i as VerifyRoomTokenOptions, n as RoomTokenVerdict, r as RoomTokenVerdictReason, t as ROOM_MEMBER_CAPABILITY } from "../room-token-verification-CTQSihUO.mjs";
2
2
  export { ROOM_MEMBER_CAPABILITY, RoomTokenVerdict, RoomTokenVerdictReason, VerifyRoomTokenOptions, verifyRoomToken };
@@ -1,5 +1,5 @@
1
1
  import { deviceIdToHex } from "./device-id.mjs";
2
- import { s as verifyCapabilityToken } from "../tokens-D8JlTJNA.mjs";
2
+ import { verifyCapabilityToken } from "./tokens.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
1
  import { At as RoomPath, Ot as RoomNotice, kt as RoomNoticeClaims, p as CapabilityToken, q as MessageRef } from "../protocol-BgR1e_NI.cjs";
2
2
  import { t as IdentityPort } from "../identity-DJbr96J3.cjs";
3
3
  import { t as Clock } from "../clock-DiSx-WKM.cjs";
4
- import { o as RevocationCheck } from "../tokens-BMWCnQEF.cjs";
5
- import { r as RoomTokenVerdictReason } from "../room-token-verification-hFtBDZPO.cjs";
4
+ import { RevocationCheck } from "./tokens.cjs";
5
+ import { r as RoomTokenVerdictReason } from "../room-token-verification-BpQ6yJtj.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
1
  import { At as RoomPath, Ot as RoomNotice, kt as RoomNoticeClaims, p as CapabilityToken, q as MessageRef } from "../protocol-BgR1e_NI.mjs";
2
2
  import { t as IdentityPort } from "../identity-ViYdZrIU.mjs";
3
3
  import { t as Clock } from "../clock-DiSx-WKM.mjs";
4
- import { o as RevocationCheck } from "../tokens-DRkm_QOR.mjs";
5
- import { r as RoomTokenVerdictReason } from "../room-token-verification-7zD4ib-A.mjs";
4
+ import { RevocationCheck } from "./tokens.mjs";
5
+ import { r as RoomTokenVerdictReason } from "../room-token-verification-CTQSihUO.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,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_tokens = require("../tokens-tPJQ7Vzt.cjs");
2
+ const require_domain_tokens = require("./tokens.cjs");
3
3
  //#region src/domain/threshold-subject.ts
4
4
  /**
5
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.
@@ -27,7 +27,7 @@ function refuseUnrecognisedKind(subject, known = KNOWN_KINDS) {
27
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
28
  */
29
29
  function toBeSigned(subject) {
30
- return Uint8Array.from(require_tokens.sig1ToBeSigned(subject.protected, subject.payload));
30
+ return Uint8Array.from(require_domain_tokens.sig1ToBeSigned(subject.protected, subject.payload));
31
31
  }
32
32
  //#endregion
33
33
  exports.KNOWN_KINDS = KNOWN_KINDS;
@@ -1,4 +1,4 @@
1
- import { o as sig1ToBeSigned } from "../tokens-D8JlTJNA.mjs";
1
+ import { sig1ToBeSigned } from "./tokens.mjs";
2
2
  //#region src/domain/threshold-subject.ts
3
3
  /**
4
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.