wire-mesh-core 3.8.0 → 3.10.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 +4 -4
- package/dist/domain/capability-grant.d.cts +3 -3
- package/dist/domain/capability-grant.d.mts +3 -3
- package/dist/domain/capability-grant.mjs +2 -2
- package/dist/domain/capability-request.cjs +18 -6
- package/dist/domain/capability-request.d.cts +10 -3
- package/dist/domain/capability-request.d.mts +10 -3
- package/dist/domain/capability-request.mjs +15 -4
- 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.cjs +2 -2
- package/dist/domain/grant-candidates.d.cts +1 -1
- package/dist/domain/grant-candidates.d.mts +1 -1
- package/dist/domain/grant-candidates.mjs +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 +2 -2
- 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.cjs +2 -2
- package/dist/domain/peer-advert.d.cts +2 -2
- package/dist/domain/peer-advert.d.mts +2 -2
- package/dist/domain/peer-advert.mjs +1 -1
- package/dist/domain/relay-advert.d.cts +1 -1
- package/dist/domain/relay-advert.d.mts +1 -1
- package/dist/domain/relay-hub.cjs +72 -15
- package/dist/domain/relay-hub.d.cts +6 -2
- package/dist/domain/relay-hub.d.mts +6 -2
- package/dist/domain/relay-hub.mjs +72 -15
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/domain/threshold-subject.mjs +1 -1
- package/dist/domain/token-predicates.cjs +184 -0
- package/dist/domain/token-predicates.d.cts +2 -0
- package/dist/domain/token-predicates.d.mts +2 -0
- package/dist/domain/token-predicates.mjs +173 -0
- package/dist/{token-scope-CxHXTT3u.cjs → domain/token-scope.cjs} +3 -12
- package/dist/domain/token-scope.d.cts +11 -0
- package/dist/domain/token-scope.d.mts +11 -0
- package/dist/{token-scope-Z4bmci4M.mjs → domain/token-scope.mjs} +1 -1
- package/dist/domain/tokens.cjs +466 -9
- package/dist/domain/tokens.d.cts +131 -2
- package/dist/domain/tokens.d.mts +131 -2
- package/dist/domain/tokens.mjs +458 -1
- 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 +2 -2
- 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 -2
- package/dist/generated/protocol.d.cts +1 -1
- package/dist/generated/protocol.d.mts +1 -1
- package/dist/generated/protocol.mjs +4 -2
- package/dist/{identity-DJbr96J3.d.cts → identity-B6nhlSOT.d.cts} +1 -1
- package/dist/{identity-ViYdZrIU.d.mts → identity-EV-HHv_D.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-BgR1e_NI.d.cts → protocol-DzmpxxUr.d.cts} +6 -0
- package/dist/{protocol-BgR1e_NI.d.mts → protocol-DzmpxxUr.d.mts} +6 -0
- package/dist/{room-token-verification-7zD4ib-A.d.mts → room-token-verification-Dh7SGJfK.d.cts} +2 -2
- package/dist/{room-token-verification-hFtBDZPO.d.cts → room-token-verification-Hb1LkpFh.d.mts} +2 -2
- package/dist/token-predicates-D4NNPLnp.d.cts +72 -0
- package/dist/token-predicates-DqpG8VZZ.d.mts +72 -0
- package/dist/{transport-Dv_LTCsF.d.mts → transport-bD3p_TO_.d.mts} +1 -1
- package/dist/{transport-DP3hdehk.d.cts → transport-gDbSHO-r.d.cts} +1 -1
- package/package.json +9 -1
- package/dist/tokens-BMWCnQEF.d.cts +0 -158
- package/dist/tokens-D8JlTJNA.mjs +0 -617
- package/dist/tokens-DRkm_QOR.d.mts +0 -158
- package/dist/tokens-tPJQ7Vzt.cjs +0 -664
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { B as IdentityKey, D as DeviceId, bt as RevocationEntry, en as TokenClaims, p as CapabilityToken, yt as RevocationClaims } from "./protocol-BgR1e_NI.cjs";
|
|
2
|
-
import { t as IdentityPort } from "./identity-DJbr96J3.cjs";
|
|
3
|
-
import { t as Clock } from "./clock-DiSx-WKM.cjs";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { JsonValue, PredicateNode, Resolution } from "trilean";
|
|
6
|
-
//#region src/domain/token-predicates.d.ts
|
|
7
|
-
/** Everything needed to check candidate against parent, restated from tokens.ts's own NarrowingCandidate/checkNarrowing shape rather than requiring a full TokenClaims for the not-yet-minted child -- the same reasoning mintCapabilityToken's own checkNarrowing already applies (a delegation candidate has no token-id/issuer-key/bearer of its own yet). camelCase field names, matching NarrowingCandidate's own convention, deliberately distinct from TokenClaims' hyphenated wire field names. */
|
|
8
|
-
interface NarrowingCandidate {
|
|
9
|
-
capability: TokenClaims["capability"];
|
|
10
|
-
scope: TokenClaims["scope"];
|
|
11
|
-
expires: number;
|
|
12
|
-
delegationsRemaining?: number;
|
|
13
|
-
}
|
|
14
|
-
/** A `conditions` entry's own generic evaluation context: no parent/candidate distinction, since a domain-specific condition (a message TTL, a future revoke-authorization check) reasons about the presented token's own claims directly, not a not-yet-minted delegation candidate. */
|
|
15
|
-
interface ConditionsContext {
|
|
16
|
-
readonly clock: Clock;
|
|
17
|
-
readonly claims: Readonly<TokenClaims>;
|
|
18
|
-
/** The minted child a grant-capability's conditions are being evaluated against (wire-mesh#323 subject mode): present only inside an authorised-by verification walk or a mint-time authorisation check, never when a token's conditions are evaluated against its own claims. */
|
|
19
|
-
readonly subject?: Readonly<GrantSubject>;
|
|
20
|
-
}
|
|
21
|
-
/** The child half of a subject-mode conditions evaluation: the claims of the token a grant-capability authorises, structurally what NarrowingCandidate already is plus the bearer the mint named. Satisfied by a full TokenClaims, so the verifier passes the child's decoded claims directly. */
|
|
22
|
-
interface GrantSubject {
|
|
23
|
-
capability: TokenClaims["capability"];
|
|
24
|
-
scope: TokenClaims["scope"];
|
|
25
|
-
bearer: DeviceId;
|
|
26
|
-
expires: number;
|
|
27
|
-
delegationsRemaining?: number;
|
|
28
|
-
}
|
|
29
|
-
/** One delegate system's own handler: given the delegate node's payload and the concrete context it was invoked with, resolves to a boolean-valued Resolution. Handlers never throw for a data-quality problem -- an op that cannot make sense of its own payload/context returns `{found: false}`, which the evaluator turns into a fail-closed `indeterminate`. */
|
|
30
|
-
type TokenDelegateHandler<TContext> = (payload: JsonValue, context: TContext) => Resolution | Promise<Resolution>;
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/domain/tokens.d.ts
|
|
33
|
-
/** The capability verb of a grant-capability (wire-mesh#323): authority to mint other capability tokens, the same register manage:revoke already established for authority over tokens. */
|
|
34
|
-
declare const MANAGE_GRANT_CAPABILITY = "manage:grant";
|
|
35
|
-
/**
|
|
36
|
-
* The revocation view a verifier consults. Returns every recorded, already-signature-verified revocation-claims for tokenId, across every issuer that has ever submitted one -- unfiltered by the store itself. The actual verifier obligation (an entry counts against a token when its own issuer matches the token's own issuer, OR its optional `authorization` grants delegated revoke authority -- management.cddl) is checked by the caller (verifyTokenChain), not here, since that check needs the target token's own scope plus identity/clock to verify a nested authorization token, none of which a store constructed ahead of time has access to. Implementations ingest gossiped revocation-announce frames via verifyRevocationEntry (which enforces each entry's own signature and self-certification) and key the resulting claims by token-id alone -- a token-id can legitimately carry multiple recorded entries from different issuers.
|
|
37
|
-
*/
|
|
38
|
-
interface RevocationCheck {
|
|
39
|
-
entriesFor: (tokenId: Uint8Array) => Promise<readonly RevocationClaims[]>;
|
|
40
|
-
}
|
|
41
|
-
type TokenVerdictReason = "malformed" | "bad_signature" | "wrong_issuer" | "bearer_mismatch" | "expired" | "not_yet_valid" | "content_expired" | "revoked" | "delegation_exceeds_parent" | "parent_invalid" |
|
|
42
|
-
/** The authorised-by link's own obligations failed: the cited grant-capability did not decode or fully verify, its bearer is not this token's issuer, its capability is not manage:grant, its grants-capability does not match, the scope or expiry widened, the depth bound was exceeded, or its conditions (evaluated against THIS token's claims) did not hold. Collapsed to one reason the same way every narrowing failure already collapses to delegation_exceeds_parent. */
|
|
43
|
-
"authorisation_invalid" |
|
|
44
|
-
/** The parent/authorised-by walk exceeded MAX_CHAIN_DEPTH. */
|
|
45
|
-
"chain_too_deep" |
|
|
46
|
-
/** The walk revisited a payload already on the current path: a cycle two colluding issuers constructed. */
|
|
47
|
-
"chain_cycle" |
|
|
48
|
-
/** claims.conditions is present but its bstr fails CBOR decode, or decodes to something that is not a JSON array of valid trilean PredicateNodes -- fail-closed per CONVENTIONS.md's verifier-obligations glossary, the same treatment "malformed" already gives an undecodable payload. */
|
|
49
|
-
"conditions_invalid" |
|
|
50
|
-
/** claims.conditions decoded and validated, but at least one entry did not evaluate to a definite `true` (indeterminate or false) -- the issuer's own additional restriction was not met. */
|
|
51
|
-
"conditions_not_satisfied";
|
|
52
|
-
type TokenVerdict = {
|
|
53
|
-
ok: true;
|
|
54
|
-
claims: TokenClaims;
|
|
55
|
-
/** The device-id at the root of this token's delegation chain: its own issuer when it carries no parent, otherwise the root of its parent's chain. Lets a caller (e.g. core/room's obligation that a chain must terminate at the path's own owner, or the verifier itself for a DM) check the chain's root with one equality comparison instead of re-walking the parent chain a second time. */
|
|
56
|
-
rootIssuer: DeviceId;
|
|
57
|
-
/** The root ancestor's own self-certifying issuer-key -- already decoded during the walk (every TokenClaims carries its own issuer-key), just threaded up rather than re-derived. Lets a caller compute an ECDH shared secret against the chain's root (e.g. room.rekey's own sender, for a named room whose token chain terminates at the owner) without a separate, out-of-band way to learn that issuer's public key. */
|
|
58
|
-
rootIssuerKey: IdentityKey;
|
|
59
|
-
/** How many delegation hops this token is from its own root -- 0 for a root grant. Costs nothing extra once rootIssuer is being tracked, and makes the delegation bound observable for diagnostics. */
|
|
60
|
-
depth: number;
|
|
61
|
-
} | {
|
|
62
|
-
ok: false;
|
|
63
|
-
reason: TokenVerdictReason;
|
|
64
|
-
};
|
|
65
|
-
interface VerifyCapabilityTokenOptions {
|
|
66
|
-
identity: IdentityPort;
|
|
67
|
-
clock: Clock;
|
|
68
|
-
revocation: RevocationCheck;
|
|
69
|
-
/** When given, the token must bear this device -- the caller presenting a token to authorise itself, not someone else. */
|
|
70
|
-
expectedBearer?: DeviceId;
|
|
71
|
-
/** Registers domain-specific delegate systems a presented token's own `conditions` entries may name, beyond the five mandatory narrowing ops (which are never reachable from `conditions` -- see evaluateConditions's own doc comment). None are registered by wire-mesh-core itself; a domain (a message TTL, #84's future revoke-authorization check) supplies its own here. A `conditions` entry naming a system absent from this map is indeterminate, and therefore fails the whole token -- fail-closed, not a silent no-op. */
|
|
72
|
-
extraPredicateResolvers?: Readonly<Record<string, TokenDelegateHandler<ConditionsContext>>>;
|
|
73
|
-
}
|
|
74
|
-
/** RFC 9052 §4.4 Sig_structure for a COSE_Sign1 with no external AAD: ["Signature1", protected, external_aad, payload]. Exported (not just used internally by verifyTokenChain) so any other self-certifying COSE_Sign1 construction in this codebase -- e.g. threshold-subject.ts's own to-be-signed bytes for a FROST-signed capability-token/revocation-entry/handle-record/room-notice -- reuses this single construction rather than a second hand-rolled one. */
|
|
75
|
-
declare function sig1ToBeSigned(protectedHeader: Uint8Array, payload: Uint8Array): Uint8Array;
|
|
76
|
-
/**
|
|
77
|
-
* Verifies one capability token per tokens.cddl's own documented rules: the token is a well-formed COSE_Sign1 whose signature actually verifies against its own embedded issuer-key, that issuer-key is self-certifying (sha256(issuer-key.public-key) equals the claimed issuer device-id -- no shared secret needed to check this), the token is currently valid (not expired, not before not-before, not revoked by its own issuer), and -- recursively -- any parent delegation narrows rather than widens across all three axes of authority: the parent's bearer must be this token's issuer (the delegation chain is unbroken), this token's expiry must not exceed its parent's, and this token's scope must narrow its parent's (same kind; equal-or-descendant path when the parent carries one) with an identical capability verb (the capability-verb grammar has no sub-verb relation, so a different verb is a different authority, not a narrower one). Undecodable payload bytes return "malformed" and undecodable parent bytes return "parent_invalid" -- hostile input produces a verdict, never a throw.
|
|
78
|
-
*/
|
|
79
|
-
declare function verifyCapabilityToken(token: CapabilityToken, options: VerifyCapabilityTokenOptions): Promise<TokenVerdict>;
|
|
80
|
-
type RevocationEntryVerdictReason = "malformed" | "bad_signature" | "wrong_issuer";
|
|
81
|
-
type RevocationEntryVerdict = {
|
|
82
|
-
ok: true;
|
|
83
|
-
claims: RevocationClaims;
|
|
84
|
-
} | {
|
|
85
|
-
ok: false;
|
|
86
|
-
reason: RevocationEntryVerdictReason;
|
|
87
|
-
};
|
|
88
|
-
interface VerifyRevocationEntryOptions {
|
|
89
|
-
/** Crypto primitives only -- any IdentityPort instance can verify any entry, since everything needed to check one travels inside the entry itself. */
|
|
90
|
-
identity: IdentityPort;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Verifies one gossiped revocation-entry (management.cddl): a well-formed COSE_Sign1 whose signature verifies against its own embedded issuer-key, where that issuer-key is self-certifying (sha256(issuer-key.public-key) equals the claimed issuer device-id). A verifier that ingests a revocation-announce frame runs each entry through this before recording it in its revocation view; entries failing here are dropped, not stored. The issuer-match against a specific token's own issuer (only a token's own issuer may revoke it) is deliberately NOT checked here -- it happens at lookup time in RevocationCheck, against whichever token is being verified.
|
|
94
|
-
*/
|
|
95
|
-
declare function verifyRevocationEntry(entry: RevocationEntry, options: VerifyRevocationEntryOptions): Promise<RevocationEntryVerdict>;
|
|
96
|
-
type MintRefusalReason = "already_expired" | "parent_malformed" | "parent_bearer_mismatch" | "expires_exceeds_parent" | "scope_does_not_narrow" | "capability_mismatch" | "delegation_exceeds_parent" |
|
|
97
|
-
/** parent and authorised-by are mutually exclusive link kinds; a manage:grant capability must be minted through authorised-by only. */
|
|
98
|
-
"links_exclusive" |
|
|
99
|
-
/** The cited grant-capability did not decode, or its own conditions bytes did not. */
|
|
100
|
-
"authorisation_malformed" | "authorisation_parent_forbidden" | "authorisation_bearer_mismatch" | "authorisation_capability_mismatch" | "authorisation_scope_does_not_narrow" | "authorisation_exceeds_authoriser" | "authorisation_delegation_exceeds" |
|
|
101
|
-
/** The authoriser's conditions, evaluated against the candidate being minted, did not all hold (wire-mesh#323 subject mode). */
|
|
102
|
-
"authorisation_conditions_not_satisfied";
|
|
103
|
-
type MintVerdict = {
|
|
104
|
-
ok: true;
|
|
105
|
-
token: CapabilityToken;
|
|
106
|
-
} | {
|
|
107
|
-
ok: false;
|
|
108
|
-
reason: MintRefusalReason;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* A pure query: could deviceId, presenting heldToken as its own delegation authority," successfully mint a delegation matching candidate right now -- without attempting (and potentially failing) a real mint just to find out. Reuses mintCapabilityToken's own narrowing arithmetic via checkNarrowing, so the two can never silently drift into different ideas of what "narrows" means.
|
|
112
|
-
*
|
|
113
|
-
* Deliberately narrower than a full mint attempt in one respect: this checks only the narrowing rules tokens.cddl's own delegation obligations require (bearer match, expiry, scope, capability, delegations-remaining), the same scope mintCapabilityToken itself checks a *parent* against -- it does not verify heldToken's own signature or revocation status, exactly as mintCapabilityToken never re-verifies its own parent's signature either. A caller that also needs heldToken's cryptographic validity confirmed calls verifyCapabilityToken separately.
|
|
114
|
-
*
|
|
115
|
-
* Async as of the predicate-list evaluator (issue #85): checkNarrowing now routes through trilean's own evaluatePredicate, which is asynchronous throughout -- there is no synchronous path through a real evaluator call, so this is a genuine, deliberate breaking change to what was previously a synchronous pure function. No existing consumer of wire-mesh-core calls canGrant (confirmed against agent-comms, the only other repo depending on this package), so there is nothing to migrate.
|
|
116
|
-
*/
|
|
117
|
-
declare function canGrant(heldToken: CapabilityToken, deviceId: DeviceId, candidate: Readonly<NarrowingCandidate>, now: number): Promise<boolean>;
|
|
118
|
-
/** A pure query: could deviceId, presenting heldGrantCapability as its minting authority, mint a token matching candidate right now (wire-mesh#323) -- canGrant's authorised-by analogue, with the same deliberately-narrower-than-verify caveat canGrant's own doc comment states: the held token's signature and revocation status are not checked here; a caller needing those confirmed calls verifyCapabilityToken separately. The candidate carries a bearer because the authoriser's subject-mode conditions read it (the no-self-grant bar). */
|
|
119
|
-
declare function canGrantVia(heldGrantCapability: CapabilityToken, deviceId: DeviceId, candidate: Readonly<GrantSubject>, now: number): Promise<boolean>;
|
|
120
|
-
interface MintCapabilityTokenOptions {
|
|
121
|
-
/** The issuer -- signs the token, and supplies the self-certifying issuer/issuer-key claims. */
|
|
122
|
-
identity: IdentityPort;
|
|
123
|
-
clock: Clock;
|
|
124
|
-
tokenId: Uint8Array<ArrayBuffer>;
|
|
125
|
-
bearer: DeviceId;
|
|
126
|
-
capability: TokenClaims["capability"];
|
|
127
|
-
scope: TokenClaims["scope"];
|
|
128
|
-
expires: number;
|
|
129
|
-
notBefore?: number;
|
|
130
|
-
/** How many further delegation hops the *resulting* token itself permits below it -- unrelated to, and never a bound on, whether `identity` may mint further tokens of its own at the root level for other bearers. Those are two different facts: a token minted with `delegationsRemaining: 0` genuinely cannot itself be re-delegated (correct -- e.g. a room owner's own self-signed root grant, which should never be handed onward), but that same `0` says nothing about the issuer's own separate, ordinary authority to mint additional independent root-level grants (naming no `parent` at all) for other bearers. Root-level minting for a second bearer is never blocked by any existing token's own `delegationsRemaining`, because it uses no `parent` in the first place -- there is no narrowing check to run. Confirmed live in agent-comms' own room-membership implementation (`ExaDev/agent-comms` PR #72): each member's own join/invite grant is minted as its own independent, parent-less, root-level token precisely because the room owner's `delegationsRemaining: 0` self-grant cannot parent anything -- correct by this same reasoning, not a workaround. */
|
|
131
|
-
delegationsRemaining?: number;
|
|
132
|
-
/** The issuer's own token, when this is a delegation rather than a root grant. Its claims are checked against every narrowing rule below -- mint refuses rather than producing a token verifyCapabilityToken would reject anyway. Omit entirely for a root-level grant (including a second, independent root-level grant for a different bearer under the same capability/scope this issuer already grants elsewhere) -- there is no bound on how many such root grants an issuer may mint, since none of them narrows any other. */
|
|
133
|
-
parent?: CapabilityToken;
|
|
134
|
-
/** Additional, issuer-chosen restrictions beyond the five mandatory narrowing checks (issue #85) -- CBOR-encoded into claims.conditions verbatim, evaluated by every verifier via evaluateConditions. Strictly additive: has no bearing on narrowing, which mint enforces separately above regardless of what's given here. Not re-validated against trilean's own schema before encoding -- the TS type already guarantees a well-formed PredicateNode[] at this call site, unlike the bytes a verifier decodes from an untrusted wire token, which always are. */
|
|
135
|
-
conditions?: PredicateNode[];
|
|
136
|
-
/** The grant-capability authorising this mint (wire-mesh#323): the resulting token carries it as authorised-by, and every link obligation (bearer match, manage:grant verb, grants-capability match, scope and expiry narrowing, depth consumption, and the authoriser's subject-mode conditions against this very candidate) is enforced here, at issuance, rather than left for the far end as a bare authorisation_invalid. Mutually exclusive with parent. */
|
|
137
|
-
authorisedBy?: CapabilityToken;
|
|
138
|
-
/** On a manage:grant token: the single verb it authorises minting. Absent means any verb within scope. */
|
|
139
|
-
grantsCapability?: TokenClaims["capability"];
|
|
140
|
-
/** On a manage:request token (wire-mesh#324): the single verb it authorises requesting. Absent means any verb within scope. */
|
|
141
|
-
requestsCapability?: TokenClaims["capability"];
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Mints one capability token: builds token-claims from the given fields, signs it as a COSE_Sign1 under `identity`'s own key, with a protected header matching what the frozen conformance vectors actually encode (`{1: alg, 4: issuer device-id}`, not the empty header a token merely needs to verify against itself).
|
|
145
|
-
*
|
|
146
|
-
* When `parent` is given, every one of `tokens.cddl`'s own narrowing obligations is enforced here, at issuance, rather than left for the far end to discover minutes or hours later as a bare `delegation_exceeds_parent` from `verifyCapabilityToken` -- the same "fail loudly, fail early" reasoning that governs every other boundary in this codebase. An issuer minting an invalid delegation is a bug in the caller; this function refuses rather than producing a token indistinguishable from a valid one until someone else verifies it.
|
|
147
|
-
*/
|
|
148
|
-
declare function mintCapabilityToken(options: MintCapabilityTokenOptions): Promise<MintVerdict>;
|
|
149
|
-
interface MintRevocationEntryOptions {
|
|
150
|
-
/** The token's own issuer -- only a token's own issuer may revoke it (management.cddl), so this must be the same identity that minted the token being revoked. */
|
|
151
|
-
identity: IdentityPort;
|
|
152
|
-
tokenId: Uint8Array<ArrayBuffer>;
|
|
153
|
-
revokedAt: number;
|
|
154
|
-
}
|
|
155
|
-
/** Mints one revocation-entry (management.cddl): a COSE_Sign1 over revocation-claims, signed the same way mintCapabilityToken signs a token. No narrowing chain to check -- a revocation entry has no parent and cannot fail to be issuable the way a delegated token can, so this returns the entry directly rather than a verdict. */
|
|
156
|
-
declare function mintRevocationEntry(options: MintRevocationEntryOptions): Promise<RevocationEntry>;
|
|
157
|
-
//#endregion
|
|
158
|
-
export { sig1ToBeSigned as _, MintVerdict as a, ConditionsContext as b, RevocationEntryVerdictReason as c, VerifyCapabilityTokenOptions as d, VerifyRevocationEntryOptions as f, mintRevocationEntry as g, mintCapabilityToken as h, MintRevocationEntryOptions as i, TokenVerdict as l, canGrantVia as m, MintCapabilityTokenOptions as n, RevocationCheck as o, canGrant as p, MintRefusalReason as r, RevocationEntryVerdict as s, MANAGE_GRANT_CAPABILITY as t, TokenVerdictReason as u, verifyCapabilityToken as v, TokenDelegateHandler as x, verifyRevocationEntry as y };
|