@agledger/verify-core 1.5.0 → 2.1.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/README.md +333 -14
- package/dist/audit-export.d.ts +156 -24
- package/dist/audit-export.js +197 -37
- package/dist/chain.d.ts +239 -24
- package/dist/chain.js +367 -57
- package/dist/failures.d.ts +36 -2
- package/dist/failures.js +56 -6
- package/dist/federation-wire.d.ts +152 -0
- package/dist/federation-wire.js +447 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +6 -2
- package/dist/instant.d.ts +23 -0
- package/dist/instant.js +50 -0
- package/dist/key-statements.d.ts +429 -0
- package/dist/key-statements.js +1325 -0
- package/dist/options.d.ts +7 -0
- package/dist/options.js +29 -0
- package/dist/primitives.d.ts +28 -6
- package/dist/primitives.js +86 -42
- package/package.json +3 -3
package/dist/failures.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* CHAIN_* per-record (and per-org schema-event) hash-chain entry checks
|
|
10
10
|
* CHECKPOINT_* vault checkpoint cross-check against the live chain
|
|
11
11
|
* TENANT_* org_admin_reads Merkle log + signed tree heads
|
|
12
|
+
* KEY_* the vault key statements themselves (the key registry)
|
|
12
13
|
* <bare> input/format-level failures that precede any chain walk
|
|
13
14
|
*
|
|
14
15
|
* Every code carries an actionable next step (`suggestion`) so a result is a
|
|
@@ -30,7 +31,8 @@
|
|
|
30
31
|
* a retired/wrong-key policy hit is alertable apart
|
|
31
32
|
* from a benign missing key.
|
|
32
33
|
* - CHAIN_KEY_EXPIRED (new) temporal key-validity: entry written after the
|
|
33
|
-
* signing key's retired_at
|
|
34
|
+
* signing key's retired_at, or after its
|
|
35
|
+
* distrustedKeys cutoff.
|
|
34
36
|
* - CHAIN_KEY_NOT_YET_ACTIVE entry written before the key's activated_at.
|
|
35
37
|
* Split from CHAIN_KEY_EXPIRED so a consumer is
|
|
36
38
|
* not told "expired" about a key that had not
|
|
@@ -38,6 +40,38 @@
|
|
|
38
40
|
* - CHAIN_EMPTY (new) a chain/vault with nothing to verify is a non-clean
|
|
39
41
|
* verdict, never a silent pass.
|
|
40
42
|
*
|
|
43
|
+
* Later additions:
|
|
44
|
+
* - CHAIN_ENTRY_UNSIGNED engine mirror of `signature_missing`: an entry with
|
|
45
|
+
* no signing key id after a signed entry in its
|
|
46
|
+
* chain, or written at or after the earliest
|
|
47
|
+
* activatedAt in the key set. Earlier unsigned
|
|
48
|
+
* entries stay reduced coverage.
|
|
49
|
+
* - CHECKPOINT_UNSIGNED engine mirror of `checkpoint_unsigned`: the same
|
|
50
|
+
* instant, applied to an unsigned checkpoint.
|
|
51
|
+
* - TENANT_READ_LEAF_UNSIGNED and TENANT_CHECKPOINT_UNSIGNED the same two
|
|
52
|
+
* rules on the org_admin_reads log (engine
|
|
53
|
+
* `leaf_signature_missing`, `checkpoint_unsigned`).
|
|
54
|
+
* - CHAIN_SIGNING_KEY_UNANCHORED engine mirror of `signing_key_unanchored`:
|
|
55
|
+
* the entry's key is not linked by signed key
|
|
56
|
+
* statements to a pinned trust anchor. With
|
|
57
|
+
* CHECKPOINT_KEY_UNANCHORED,
|
|
58
|
+
* TENANT_READ_KEY_UNANCHORED and
|
|
59
|
+
* TENANT_CHECKPOINT_KEY_UNANCHORED for the
|
|
60
|
+
* engine's `checkpoint_key_unanchored` and
|
|
61
|
+
* `leaf_key_unanchored`.
|
|
62
|
+
* - KEY_STATEMENT_INVALID, KEY_CLOSURE_INVALID, CHAIN_KEY_WINDOW_DRIFT
|
|
63
|
+
* engine mirrors of the key registry findings
|
|
64
|
+
* `key_statement_invalid`, `key_closure_invalid`
|
|
65
|
+
* and `key_window_drift`. They are about the
|
|
66
|
+
* registry, not about any one entry.
|
|
67
|
+
* - CHECKPOINT_CLAIM_MISMATCH, TENANT_READ_CLAIM_MISMATCH,
|
|
68
|
+
* TENANT_CHECKPOINT_CLAIM_MISMATCH engine mirrors of the vault's
|
|
69
|
+
* `checkpoint_claim_mismatch` and the read log's
|
|
70
|
+
* `leaf_claim_mismatch` and
|
|
71
|
+
* `checkpoint_claim_mismatch`: the claim signed
|
|
72
|
+
* inside the envelope does not decode, or says
|
|
73
|
+
* something the row's columns do not.
|
|
74
|
+
*
|
|
41
75
|
* Server-side cert re-checks are not mirrored here. The engine's chain
|
|
42
76
|
* verification also reports `cert_missing`, `cert_actor_drift`,
|
|
43
77
|
* `cert_window_drift`, `cert_expired` and `agent_signature_invalid`, by
|
|
@@ -60,31 +94,47 @@ const SUGGESTIONS = {
|
|
|
60
94
|
CHAIN_GENESIS_INVALID: 'The first entry must carry previousHash = null. A non-null genesis link means the head of the chain was removed. Request the full chain from position 1.',
|
|
61
95
|
CHAIN_LINK_BROKEN: 'An entry\'s previousHash does not match the prior entry\'s payloadHash. The chain was edited between these two entries. Treat every entry from this position on as untrusted.',
|
|
62
96
|
CHAIN_HASH_MISMATCH: 'sha256(cose_sign1) does not equal the stored payloadHash. The envelope bytes or the stored hash were altered. The signed bytes are authoritative; the row was tampered with.',
|
|
63
|
-
CHAIN_MALFORMED_ENTRY: 'An entry is missing a
|
|
97
|
+
CHAIN_MALFORMED_ENTRY: 'An entry is missing a field the engine writes on every entry (coseSign1, payloadHash, or a parseable createdAt where a key window or the start of signing needs one), or carries it as another type. The export/dump is incomplete or was edited, and an entry the verifier cannot place is never read as early unsigned history. Regenerate the export/dump from the operator and re-run.',
|
|
64
98
|
CHAIN_COSE_DECODE_FAILED: 'The COSE_Sign1 envelope did not decode as a tagged 4-element structure. The signed bytes are corrupt. Regenerate the export/dump.',
|
|
65
99
|
CHAIN_COSE_HEADER_MISMATCH: 'The position/previousHash signed in the COSE protected header disagree with the row columns. The visible columns were renumbered after signing. Trust the signed header, not the columns.',
|
|
66
100
|
CHAIN_PAYLOAD_BINDING_MISMATCH: 'The signed payload\'s structure no longer matches the canonical projection of the row columns it is bound to: the visible (denormalised) payload was altered after signing. This is a binding-integrity failure, not a judgement on content.',
|
|
67
101
|
CHAIN_OIDC_ACTOR_MISMATCH: 'The denormalised actor OIDC issuer/subject columns disagree with the identity signed in predicate.on_behalf_of. The actor columns were tampered with after signing.',
|
|
68
102
|
CHAIN_SIGNATURE_INVALID: 'The COSE_Sign1 signature did not verify against the entry\'s signing key, under the algorithm that key commits to. The entry was forged or altered: obtain the verification keys out of band and re-run.',
|
|
69
103
|
CHAIN_SIGNATURE_MISSING_KEY: 'No public key was available for the entry\'s signingKeyId. Supply the key out of band (GET /v1/verification-keys or /.well-known/scitt-keys) and re-run.',
|
|
70
|
-
CHAIN_KEY_POLICY_VIOLATION: 'The entry\'s signing key violates the caller\'s
|
|
71
|
-
CHAIN_KEY_EXPIRED: 'The entry was written AFTER its signing key was retired. Possible use of a compromised
|
|
104
|
+
CHAIN_KEY_POLICY_VIOLATION: 'The entry\'s signing key violates the caller\'s key policy (requireKeyId, or requireSuppliedKeys refusing a key the artifact embeds). Re-run with the expected key id, or supply the keys yourself. Where a key came from does not make it trusted: pin a trust anchor (trustAnchors) for that.',
|
|
105
|
+
CHAIN_KEY_EXPIRED: 'The entry was written AFTER its signing key was retired, or after the instant distrustedKeys (VAULT_DISTRUSTED_KEYS on the Server) gives for that key; the detail says which. Possible use of a compromised key: check the key rotation and retention record for that key id.',
|
|
72
106
|
CHAIN_KEY_NOT_YET_ACTIVE: 'The entry was written BEFORE its signing key was activated. Not a rotation problem: the usual causes are a backdated entry or clock skew between the signer and the key registry. Compare the entry write time against the key activation time before treating this as tamper.',
|
|
73
107
|
CHAIN_ALG_MISMATCH: 'The algorithm in the signed protected header (label 1) is not one the entry\'s trusted verification key can produce, or the key registry\'s declared algorithm contradicts the key material itself. Tamper class: the header alg or the key registry was rewritten. Treat the entry as forged; obtain the verification keys out of band and re-run.',
|
|
74
108
|
CHAIN_UNSUPPORTED_ALGORITHM: 'The entry\'s trusted verification key commits to a signature algorithm that could not be computed, either because this verifier build does not implement it or because the host runtime refused it (an active OpenSSL FIPS provider carries no EdDSA). The chain is NOT verified, and this is NOT tamper evidence: the signature was never checked. Upgrade the verifier, or re-run on a host without the restriction. Never treat this result as a pass.',
|
|
75
109
|
CHAIN_SIGNING_KEY_DRIFT: 'The entry\'s signingKeyId column names a different key than the signature-covered kid in the COSE protected header. The column is a denormalized convenience and was rewritten after signing (possibly to point verification at another key). Trust the signed kid; treat the row as tampered.',
|
|
76
110
|
CHAIN_ACTOR_ATTRIBUTION_MISMATCH: 'The entry\'s actorId / actorOwnerId columns name a different actor than the signature-covered actor claim in the COSE protected header (CWT_Claims label 15, private label -65539). The columns are the projection a report displays and they were rewritten after signing, re-attributing the action to another actor. Trust the signed claim; treat the row as tampered and re-obtain the export from the operator.',
|
|
77
111
|
CHAIN_AGENT_SIGNATURE_INVALID: 'The agent signature sealed in predicate.on_behalf_of.agent_signature does not verify under the supplied key whose RFC 7638 thumbprint the entry itself names, or is sealed in a shape nothing can verify. The engine checks this signature at intake and the envelope signature says the engine wrote it, so this is not a caller mistake: treat the agent attribution of this entry as unproven and escalate to the operator.',
|
|
112
|
+
CHAIN_FEDERATION_WIRE_INVALID: 'The federation message sealed in payload.wire does not hold: its body no longer hashes to the bodyHash the sender signed, the entry asserts a state, type, recommendation or dispute the sealed body does not carry, or (under the sender\'s federation key you supplied) the signature does not verify or the sealed senderPublicKey is not that key. The receiving Server verified the message at intake and signed this entry, so this is not a caller mistake: treat what the entry says the peer asserted as unproven and escalate to both operators.',
|
|
113
|
+
CHAIN_EVIDENCE_BINDING_MISMATCH: 'An evidence body inlined in the export (entries[].evidence, from ?evidence=true) does not hash to the payload.evidenceHash or payload.payloadHash its entry signs, or sits on an entry that signs no such hash. The body is an unsigned projection whose only authority is that hash, so it was edited after export or attached where it does not belong. Trust the signed hash, not the body: re-obtain the evidence from the operator and re-bind it (SHA-256 over its RFC 8785 form).',
|
|
114
|
+
CHAIN_ENTRY_UNSIGNED: 'The entry carries no signing key id where the install could not have written an unsigned entry: after a signed entry in the same chain, or at or after the earliest activation time in the signing key set (retired keys included). From that instant every writer holds a registered key, so this is what a writer without one leaves on the chain, or a signed row whose key id was nulled. Treat the entry as forged and escalate to the operator. Unsigned entries from before the first key activation stay reduced signature coverage, not a break.',
|
|
115
|
+
CHAIN_SIGNING_KEY_UNANCHORED: 'The entry is signed by a key that no signed key statement links to a trust anchor you pinned. Anything with write access to the Server\'s database can register a key and sign entries with it; what it cannot write is a statement signed by a key you trust. Treat the entry as forged. If the key is one you vouch for, pin it (trustAnchors) from a source outside the Server, never from the document that served it.',
|
|
116
|
+
CHAIN_KEY_WINDOW_DRIFT: 'A key registry column (activatedAt, retiredAt or status in a dump row or key document) differs from the value its signed key statements carry. The signed value is the one entries are graded against; the column was rewritten, or the retirement was written without its closure statement. Treat the registry as tampered and compare it with the Server\'s own scan (key_window_drift). Where the detail names a distrust entry the listing says the Server applies (distrustedFrom, VAULT_DISTRUSTED_KEYS), the listed retirement may be that entry\'s cut, which the verifier was not given or was given at another instant; the listing\'s word is unsigned, so it stays tampering until the Server\'s operator confirms the entry.',
|
|
78
117
|
CHECKPOINT_ROW_MISSING: 'A signed checkpoint anchors a position that has no matching chain row. The chain was truncated below a checkpoint (out-of-band DELETE/TRUNCATE). The checkpoint is proof of the missing rows.',
|
|
79
118
|
CHECKPOINT_HASH_MISMATCH: 'A checkpoint\'s payloadHash does not match the chain row at its position. The chain diverged from what was checkpointed. Treat the chain as tampered.',
|
|
80
119
|
CHECKPOINT_SIGNATURE_INVALID: 'A checkpoint\'s COSE_Sign1 signature did not verify. The checkpoint was forged or altered. Re-run with out-of-band verification keys.',
|
|
81
|
-
|
|
120
|
+
CHECKPOINT_UNSIGNED: 'A checkpoint carries no signing key id but was written at or after the earliest activation time in the signing key set (retired keys included), when every writer holds a registered key. The checkpoint was forged or its key id nulled, and nothing it anchors can be trusted. Escalate to the operator.',
|
|
121
|
+
CHECKPOINT_KEY_UNANCHORED: 'A vault checkpoint is signed by a key that no signed key statement links to a trust anchor you pinned. Nothing it anchors can be trusted; treat it as forged (see CHAIN_SIGNING_KEY_UNANCHORED).',
|
|
122
|
+
CHECKPOINT_CLAIM_MISMATCH: 'The claim signed inside a vault checkpoint envelope does not decode, or says something the checkpoint row\'s columns do not (chain position, chain tip hash, subject digest or signed kid). A column was rewritten beside an intact envelope. Trust the signed claim, treat the checkpoint row as tampered, and obtain the dump from the operator again.',
|
|
123
|
+
TENANT_READ_LEAF_HASH_MISMATCH: 'An org_admin_reads leaf_hash does not match the RFC 9162 leaf hash of its envelope, sha256(0x00 || cose_sign1). The read-log leaf was altered after recording.',
|
|
82
124
|
TENANT_READ_LEAF_INDEX_GAP: 'org_admin_reads leaf indices are not gap-free for this org. A read-log entry was removed. Obtain the complete log.',
|
|
83
125
|
TENANT_READ_SIGNATURE_INVALID: 'An org_admin_reads leaf\'s COSE_Sign1 signature did not verify. The read-log leaf was forged or altered.',
|
|
126
|
+
TENANT_READ_LEAF_UNSIGNED: 'An org_admin_reads leaf carries the unsigned kid where the install could not have written one: after a signed leaf in the same org log, or at or after the earliest activation time in the signing key set. Treat the leaf as forged and escalate to the operator.',
|
|
127
|
+
TENANT_READ_KEY_UNANCHORED: 'An org_admin_reads leaf is signed by a key that no signed key statement links to a trust anchor you pinned. Treat the leaf as forged (see CHAIN_SIGNING_KEY_UNANCHORED).',
|
|
128
|
+
TENANT_READ_CLAIM_MISMATCH: 'The claim signed inside an org_admin_reads leaf envelope does not decode, or says something the leaf row\'s columns do not (position, previous_hash, record_id or subject digest). A column was rewritten beside an intact envelope. Trust the signed claim and treat the read-log leaf as tampered.',
|
|
84
129
|
TENANT_CHECKPOINT_LEAF_COUNT_MISMATCH: 'A signed tree head commits to more leaves than the dump contains. The read log was truncated below a checkpoint.',
|
|
85
|
-
TENANT_CHECKPOINT_ROOT_MISMATCH: 'The
|
|
130
|
+
TENANT_CHECKPOINT_ROOT_MISMATCH: 'The RFC 9162 Merkle root recomputed over the leaves does not match the signed root_hash. The read log diverged from what was checkpointed.',
|
|
86
131
|
TENANT_CHECKPOINT_SIGNATURE_INVALID: 'A signed-tree-head COSE_Sign1 signature did not verify. The STH was forged or altered.',
|
|
132
|
+
TENANT_CHECKPOINT_UNSIGNED: 'An org_admin_reads signed tree head carries no signing key id but was written at or after the earliest activation time in the signing key set. The tree head was forged or its key id nulled; escalate to the operator.',
|
|
133
|
+
TENANT_CHECKPOINT_KEY_UNANCHORED: 'An org_admin_reads signed tree head is signed by a key that no signed key statement links to a trust anchor you pinned. Treat it as forged (see CHAIN_SIGNING_KEY_UNANCHORED).',
|
|
134
|
+
TENANT_CHECKPOINT_CLAIM_MISMATCH: 'The claim signed inside an org_admin_reads tree-head envelope does not decode, or says something the tree-head row\'s columns do not (position, chain_tip_hash, leaf count, subject digest or signed kid). A column was rewritten beside an intact envelope. Trust the signed claim and treat the tree-head row as tampered.',
|
|
87
135
|
TENANT_CHECKPOINT_FORK: 'Two signed tree heads at the same tree_size carry different roots. This is an engine fork or signing-key compromise. Escalate immediately.',
|
|
136
|
+
KEY_STATEMENT_INVALID: 'A key statement does not verify, disagrees with the columns it was stored under, touches no anchored key, or was signed by a key after its closure or after the key was already admitted. It admits nothing. One that does not verify, or that a key signed after its closure, is what a writer with database access or a leaked retired key produces: have the operator retire that key with force and add it to VAULT_DISTRUSTED_KEYS, and pass the same entry as distrustedKeys.',
|
|
137
|
+
KEY_CLOSURE_INVALID: 'A key is retired with no closure that counts for it, or a closure is signed by a key the walk does not anchor, by a key after its own retirement, or dates a retirement before its subject was activated, or is signed by a key the walk reaches but does not anchor and retires an anchored key earlier, or with force, than any closure a published key signed (so a walk over the published key documents reads that key differently). A closure that still counts ends its subject\'s window whoever wrote it; if its signer leaked, have the operator add it to VAULT_DISTRUSTED_KEYS and pass the same entry as distrustedKeys.',
|
|
88
138
|
};
|
|
89
139
|
/** The actionable next step for a failure code. */
|
|
90
140
|
export function suggestion(code) {
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export declare const FEDERATION_WIRE_SCHEME = "agledger.federation.v2";
|
|
2
|
+
/** The sealed message as the receiver stores it under `payload.wire`. */
|
|
3
|
+
export interface FederationWire {
|
|
4
|
+
scheme: string;
|
|
5
|
+
senderHubId: string;
|
|
6
|
+
/** The sender's Ed25519 key as registered at handshake: base64 SPKI DER, or base64 of the raw 32 bytes. */
|
|
7
|
+
senderPublicKey: string;
|
|
8
|
+
recipientHubId: string;
|
|
9
|
+
method: string;
|
|
10
|
+
path: string;
|
|
11
|
+
/** SHA-256 hex over the RFC 8785 canonical JSON of `body`. */
|
|
12
|
+
bodyHash: string;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
nonce: string;
|
|
15
|
+
/** Hex Ed25519 signature over the sign-input. */
|
|
16
|
+
signature: string;
|
|
17
|
+
/** The request body as received, the bytes `bodyHash` covers. */
|
|
18
|
+
body: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** The domain a federation key statement's signatures sign under. */
|
|
21
|
+
export declare const FEDERATION_KEY_STATEMENT_DOMAIN = "agledger.federation.key-statement.v1";
|
|
22
|
+
/** One statement of a {@link FederationKeyHistoryDocument}, as served. */
|
|
23
|
+
export interface FederationKeyHistoryStatement {
|
|
24
|
+
id: string;
|
|
25
|
+
kind: string;
|
|
26
|
+
/** The RFC 8785 (JCS) bytes both signatures cover, after the domain and a colon. */
|
|
27
|
+
payload: string;
|
|
28
|
+
subjectSignature: string;
|
|
29
|
+
predecessorSignature: string | null;
|
|
30
|
+
createdAt?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A publisher's `GET /.well-known/agledger-federation-keys.json`, as served.
|
|
34
|
+
* Only `hubId`, `statementDomain` and the signed `statements` are read: the
|
|
35
|
+
* `keys` summary is the publisher's own unsigned reading of them, so the
|
|
36
|
+
* windows are taken from the statements instead.
|
|
37
|
+
*/
|
|
38
|
+
export interface FederationKeyHistoryDocument {
|
|
39
|
+
hubId: string | null;
|
|
40
|
+
statementDomain: string;
|
|
41
|
+
statements: ReadonlyArray<FederationKeyHistoryStatement>;
|
|
42
|
+
anchoredFrom?: string | null;
|
|
43
|
+
keys?: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One federation key a sender hub is trusted under, base64 SPKI DER, with the
|
|
47
|
+
* window its signed statements give it. Both bounds are null for a key given
|
|
48
|
+
* without a history: it is trusted at any time, as before histories existed.
|
|
49
|
+
*/
|
|
50
|
+
export interface FederationTrustedKey {
|
|
51
|
+
publicKey: string;
|
|
52
|
+
/** When the key took over; null when no signed statement bounds it from below. */
|
|
53
|
+
activatedAt: string | null;
|
|
54
|
+
/** When the next key took over; null while no succession signed by this key and its successor ends it. */
|
|
55
|
+
retiredAt: string | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Sender hub id to the federation keys its messages are trusted under, as
|
|
59
|
+
* `buildFederationKeyRegistry` builds it: each pinned key, and with a history
|
|
60
|
+
* every key linked to a pin by successions both keys signed.
|
|
61
|
+
*/
|
|
62
|
+
export type FederationKeyRegistry = ReadonlyMap<string, ReadonlyArray<FederationTrustedKey>>;
|
|
63
|
+
/**
|
|
64
|
+
* One sender's federation key, the list shape `buildFederationKeyRegistry`
|
|
65
|
+
* takes. `publicKey` is a key you hold for the hub by other means (the
|
|
66
|
+
* `signingPublicKey` your peer row holds, or one its operator confirmed);
|
|
67
|
+
* with `history`, the publisher's key-history document, every earlier or later
|
|
68
|
+
* key a chain of successions links to it is trusted too, inside its window. A
|
|
69
|
+
* hub may be named more than once, to pin keys no succession links: a key
|
|
70
|
+
* listed `linked: false`, or a key the history does not list at all (one in
|
|
71
|
+
* use before a change made with neither predecessor setting), which is then
|
|
72
|
+
* trusted on its own at any time. At least one pin for a hub with a history
|
|
73
|
+
* must be a key that history lists.
|
|
74
|
+
*/
|
|
75
|
+
export interface FederationKeyEntry {
|
|
76
|
+
hubId: string;
|
|
77
|
+
publicKey: string;
|
|
78
|
+
history?: FederationKeyHistoryDocument;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A federation key as base64 SPKI DER, from either form the Server's peer
|
|
82
|
+
* table holds: SPKI DER, or the raw 32-byte key. Returns null for anything
|
|
83
|
+
* that is neither (so a caller refuses it by name rather than verifying
|
|
84
|
+
* nothing under it).
|
|
85
|
+
*/
|
|
86
|
+
export declare function normalizeFederationKey(publicKeyBase64: string): string | null;
|
|
87
|
+
/**
|
|
88
|
+
* Build the registry from `{ [hubId]: publicKey }` or
|
|
89
|
+
* `[{ hubId, publicKey, history? }]`. Throws `TypeError` naming the entry on
|
|
90
|
+
* any key that is not an Ed25519 key in one of the two forms, and on a history
|
|
91
|
+
* that is another hub's, carries a statement that does not verify, or lists
|
|
92
|
+
* none of the keys pinned for its hub, so a bad input is refused before any verification
|
|
93
|
+
* runs rather than reported as a signature failure.
|
|
94
|
+
*/
|
|
95
|
+
export declare function buildFederationKeyRegistry(input: Readonly<Record<string, string>> | ReadonlyArray<FederationKeyEntry>): FederationKeyRegistry;
|
|
96
|
+
/**
|
|
97
|
+
* RFC 8785 (JCS) canonical JSON, as the Server's `canonicalize` writes it:
|
|
98
|
+
* object keys sorted by code unit, no whitespace, `undefined` members dropped
|
|
99
|
+
* (an array element that is `undefined` serializes as `null`), `-0` as `0`,
|
|
100
|
+
* non-finite numbers as `null`. Numbers take JavaScript's own shortest form,
|
|
101
|
+
* which is what RFC 8785 specifies.
|
|
102
|
+
*/
|
|
103
|
+
export declare function canonicalizeJson(value: unknown): string;
|
|
104
|
+
/** The sign-input the Server builds, a colon-joined line under the scheme. */
|
|
105
|
+
export declare function federationSignInput(wire: FederationWire): string;
|
|
106
|
+
/**
|
|
107
|
+
* The `wire` a row payload carries, or null when it carries none. A `wire`
|
|
108
|
+
* that is present but is not an object is returned as `malformed`, so the
|
|
109
|
+
* caller fails it rather than reading an edited row as one with no message.
|
|
110
|
+
*/
|
|
111
|
+
export declare function extractFederationWire(payload: Record<string, unknown>): FederationWire | 'malformed' | null;
|
|
112
|
+
export type FederationWireOutcome =
|
|
113
|
+
/**
|
|
114
|
+
* The hash, the entry's fields and, under a supplied key, the signature all
|
|
115
|
+
* hold. `afterRetirement`: the key the message is sealed under was retired,
|
|
116
|
+
* by a succession it signed, before the sender signed the message. The
|
|
117
|
+
* receiver accepts the old key until it revokes the peer, so a publisher
|
|
118
|
+
* process not yet restarted onto the new key sends exactly this; it is in
|
|
119
|
+
* order when the receiver's `federation.peer_revoked` audit row for the
|
|
120
|
+
* publisher comes after the entry.
|
|
121
|
+
*/
|
|
122
|
+
{
|
|
123
|
+
outcome: 'ok';
|
|
124
|
+
signatureChecked: boolean;
|
|
125
|
+
afterRetirement: boolean;
|
|
126
|
+
}
|
|
127
|
+
/** No key was supplied for `senderHubId`; the hash and the entry's fields hold, the signature was not checked. */
|
|
128
|
+
| {
|
|
129
|
+
outcome: 'unchecked';
|
|
130
|
+
} | {
|
|
131
|
+
outcome: 'invalid';
|
|
132
|
+
detail: string;
|
|
133
|
+
}
|
|
134
|
+
/** A key was supplied but this host cannot compute Ed25519. */
|
|
135
|
+
| {
|
|
136
|
+
outcome: 'unsupported';
|
|
137
|
+
detail: string;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Check one sealed message against the entry that carries it, and under the
|
|
141
|
+
* sender's key when `keys` has one for `wire.senderHubId`.
|
|
142
|
+
*
|
|
143
|
+
* Runs on an entry that already passed every other check, so `payload` is
|
|
144
|
+
* what the receiver signed. `recordId` is the entry's record; the body names
|
|
145
|
+
* the same record on every message type that carries one. When the sender's
|
|
146
|
+
* keys came with a history, the message is placed in a key's window by
|
|
147
|
+
* `wire.timestamp`: the sender signed it, the receiver sealed it under its own
|
|
148
|
+
* signature after holding it to its clock-skew allowance, and it is read from
|
|
149
|
+
* the sender's clock, the clock the history's windows are written by. The
|
|
150
|
+
* entry's `createdAt` is a column no signature covers, so it places nothing.
|
|
151
|
+
*/
|
|
152
|
+
export declare function checkFederationWire(entryType: string, recordId: string | null, payload: Record<string, unknown>, wire: FederationWire, keys: FederationKeyRegistry | undefined): FederationWireOutcome;
|