@attestplane/attestplane 0.0.1 → 0.0.3-alpha
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 +23 -9
- package/dist/adapter_conformance.d.ts +46 -0
- package/dist/adapter_conformance.d.ts.map +1 -0
- package/dist/adapter_conformance.js +160 -0
- package/dist/adapter_conformance.js.map +1 -0
- package/dist/adapters/langfuse.d.ts +51 -0
- package/dist/adapters/langfuse.d.ts.map +1 -0
- package/dist/adapters/langfuse.js +157 -0
- package/dist/adapters/langfuse.js.map +1 -0
- package/dist/adapters/langsmith.d.ts +53 -0
- package/dist/adapters/langsmith.d.ts.map +1 -0
- package/dist/adapters/langsmith.js +173 -0
- package/dist/adapters/langsmith.js.map +1 -0
- package/dist/adapters.d.ts +88 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +109 -0
- package/dist/adapters.js.map +1 -0
- package/dist/anchoring.d.ts +119 -0
- package/dist/anchoring.d.ts.map +1 -0
- package/dist/anchoring.js +340 -0
- package/dist/anchoring.js.map +1 -0
- package/dist/canonical.d.ts +11 -2
- package/dist/canonical.d.ts.map +1 -1
- package/dist/canonical.js +44 -31
- package/dist/canonical.js.map +1 -1
- package/dist/canonical_text.d.ts +30 -0
- package/dist/canonical_text.d.ts.map +1 -0
- package/dist/canonical_text.js +100 -0
- package/dist/canonical_text.js.map +1 -0
- package/dist/der.d.ts +55 -0
- package/dist/der.d.ts.map +1 -0
- package/dist/der.js +200 -0
- package/dist/der.js.map +1 -0
- package/dist/event_payloads.d.ts +118 -0
- package/dist/event_payloads.d.ts.map +1 -0
- package/dist/event_payloads.js +348 -0
- package/dist/event_payloads.js.map +1 -0
- package/dist/event_types.d.ts +47 -0
- package/dist/event_types.d.ts.map +1 -0
- package/dist/event_types.js +63 -0
- package/dist/event_types.js.map +1 -0
- package/dist/hashchain.d.ts +1 -0
- package/dist/hashchain.d.ts.map +1 -1
- package/dist/hashchain.js +25 -1
- package/dist/hashchain.js.map +1 -1
- package/dist/index.d.ts +23 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -2
- package/dist/index.js.map +1 -1
- package/dist/index_version.d.ts +9 -0
- package/dist/index_version.d.ts.map +1 -0
- package/dist/index_version.js +11 -0
- package/dist/index_version.js.map +1 -0
- package/dist/intoto.d.ts +48 -0
- package/dist/intoto.d.ts.map +1 -0
- package/dist/intoto.js +106 -0
- package/dist/intoto.js.map +1 -0
- package/dist/obligations.d.ts +41 -0
- package/dist/obligations.d.ts.map +1 -0
- package/dist/obligations.js +312 -0
- package/dist/obligations.js.map +1 -0
- package/dist/proof_bundle.d.ts +186 -0
- package/dist/proof_bundle.d.ts.map +1 -0
- package/dist/proof_bundle.js +299 -0
- package/dist/proof_bundle.js.map +1 -0
- package/dist/reason_codes.d.ts +38 -0
- package/dist/reason_codes.d.ts.map +1 -0
- package/dist/reason_codes.js +97 -0
- package/dist/reason_codes.js.map +1 -0
- package/dist/replay_verifier.d.ts +43 -0
- package/dist/replay_verifier.d.ts.map +1 -0
- package/dist/replay_verifier.js +98 -0
- package/dist/replay_verifier.js.map +1 -0
- package/dist/rfc3161.d.ts +52 -0
- package/dist/rfc3161.d.ts.map +1 -0
- package/dist/rfc3161.js +480 -0
- package/dist/rfc3161.js.map +1 -0
- package/dist/settlement_verifier.d.ts +34 -0
- package/dist/settlement_verifier.d.ts.map +1 -0
- package/dist/settlement_verifier.js +139 -0
- package/dist/settlement_verifier.js.map +1 -0
- package/dist/signing/base.d.ts +101 -0
- package/dist/signing/base.d.ts.map +1 -0
- package/dist/signing/base.js +144 -0
- package/dist/signing/base.js.map +1 -0
- package/dist/signing/providers.d.ts +113 -0
- package/dist/signing/providers.d.ts.map +1 -0
- package/dist/signing/providers.js +230 -0
- package/dist/signing/providers.js.map +1 -0
- package/dist/signing/signer.d.ts +66 -0
- package/dist/signing/signer.d.ts.map +1 -0
- package/dist/signing/signer.js +146 -0
- package/dist/signing/signer.js.map +1 -0
- package/dist/signing/trust_roots.d.ts +71 -0
- package/dist/signing/trust_roots.d.ts.map +1 -0
- package/dist/signing/trust_roots.js +267 -0
- package/dist/signing/trust_roots.js.map +1 -0
- package/dist/signing/verifier_ext.d.ts +77 -0
- package/dist/signing/verifier_ext.d.ts.map +1 -0
- package/dist/signing/verifier_ext.js +340 -0
- package/dist/signing/verifier_ext.js.map +1 -0
- package/dist/verifier.d.ts +39 -0
- package/dist/verifier.d.ts.map +1 -0
- package/dist/verifier.js +374 -0
- package/dist/verifier.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proof-bundle export and auditor-export builders (TypeScript port of
|
|
3
|
+
* `sdk/python/src/attestplane/proof_bundle.py`).
|
|
4
|
+
*
|
|
5
|
+
* The bundle shape matches `schemas/v1/proof_bundle.schema.json` exactly,
|
|
6
|
+
* and the auditor export matches `schemas/v1/auditor_export.schema.json`.
|
|
7
|
+
* Cross-language byte-stable: a chain produced by the Python SDK and a
|
|
8
|
+
* chain produced by the TypeScript SDK that go through the same builder
|
|
9
|
+
* inputs produce the same proof-bundle dict.
|
|
10
|
+
*/
|
|
11
|
+
import { type SignatureRecord } from './signing/base.js';
|
|
12
|
+
import type { ChainedEvent } from './types.js';
|
|
13
|
+
export declare const DEFAULT_FORBIDDEN_FIELDS: readonly string[];
|
|
14
|
+
export type ImplementationStatus = 'mapping_target' | 'designed_toward' | 'field_supported' | 'verified_in_test';
|
|
15
|
+
export interface FrameworkMapping {
|
|
16
|
+
readonly obligation_id: string;
|
|
17
|
+
readonly evidence_event_indexes: readonly number[];
|
|
18
|
+
readonly implementation_status_at_bundle_time: ImplementationStatus;
|
|
19
|
+
}
|
|
20
|
+
export interface ProofBundleBuilderInput {
|
|
21
|
+
readonly chain_id: string;
|
|
22
|
+
readonly producer_runtime: string;
|
|
23
|
+
readonly forbidden_fields?: readonly string[];
|
|
24
|
+
readonly anchor_ref?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ProofBundle {
|
|
27
|
+
readonly bundle_version: 1;
|
|
28
|
+
readonly chain_metadata: {
|
|
29
|
+
readonly chain_id: string;
|
|
30
|
+
readonly schema_version: number;
|
|
31
|
+
readonly genesis_hash_hex: string;
|
|
32
|
+
readonly head_hash_hex: string;
|
|
33
|
+
readonly head_seq: number;
|
|
34
|
+
readonly producer_runtime: string;
|
|
35
|
+
readonly evidence_taxonomy_version: 1;
|
|
36
|
+
readonly anchor_ref?: string;
|
|
37
|
+
};
|
|
38
|
+
readonly events: readonly SerializedChainedEvent[];
|
|
39
|
+
readonly verification_report: {
|
|
40
|
+
readonly ok: boolean;
|
|
41
|
+
readonly first_bad_index: number | null;
|
|
42
|
+
readonly reason: string | null;
|
|
43
|
+
readonly verified_at: string;
|
|
44
|
+
readonly verifier_version: string;
|
|
45
|
+
readonly verification_method: 'canonical-bytes-walk' | 'canonical-bytes-walk+anchor';
|
|
46
|
+
};
|
|
47
|
+
readonly framework_mappings: readonly FrameworkMapping[];
|
|
48
|
+
readonly forbidden_fields: readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* Additive `policy_trace_refs` field per ADR-0012 P1.2. Flat list of
|
|
51
|
+
* `event_hash_hex` for every ChainedEvent whose `event_type ==
|
|
52
|
+
* 'policy_check_event'`. Chain-seq-ascending order; deduplicated;
|
|
53
|
+
* absent when empty (preserves byte identity with bundles that have
|
|
54
|
+
* no policy_check_event rows).
|
|
55
|
+
*/
|
|
56
|
+
readonly policy_trace_refs?: readonly string[];
|
|
57
|
+
/**
|
|
58
|
+
* Additive `signatures` field per ADR-0005 T5. Absent when no
|
|
59
|
+
* SignatureRecord has been added (preserves byte equality with
|
|
60
|
+
* v0.0.1-alpha bundles).
|
|
61
|
+
*/
|
|
62
|
+
readonly signatures?: readonly SerializedSignatureRecord[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Wire-format `SignatureRecord` per `_serialize_signature_record` in
|
|
66
|
+
* `sdk/python/src/attestplane/proof_bundle.py`. Field-by-field
|
|
67
|
+
* byte-stable copy of Python's encoding.
|
|
68
|
+
*/
|
|
69
|
+
export interface SerializedSignatureRecord {
|
|
70
|
+
readonly signature_schema_version: number;
|
|
71
|
+
readonly signed_seq: number;
|
|
72
|
+
readonly signed_event_hash_hex: string;
|
|
73
|
+
readonly signature_hex: string;
|
|
74
|
+
readonly key_id: string;
|
|
75
|
+
readonly public_key_der_b64: string;
|
|
76
|
+
readonly signing_cert_chain_b64: readonly string[];
|
|
77
|
+
readonly signed_at: string;
|
|
78
|
+
readonly signature_mode: 'segment_head' | 'per_event';
|
|
79
|
+
readonly signed_payload_b64: string;
|
|
80
|
+
}
|
|
81
|
+
export interface SerializedSubjectRef {
|
|
82
|
+
readonly scheme: 'sha256_salted' | 'opaque' | 'none';
|
|
83
|
+
readonly value: string;
|
|
84
|
+
}
|
|
85
|
+
export interface SerializedAuditEvent {
|
|
86
|
+
readonly schema_version: number;
|
|
87
|
+
readonly event_id: string;
|
|
88
|
+
readonly timestamp: string;
|
|
89
|
+
readonly event_type: string;
|
|
90
|
+
readonly actor: string;
|
|
91
|
+
readonly payload: Record<string, unknown>;
|
|
92
|
+
readonly subject_ref: SerializedSubjectRef | null;
|
|
93
|
+
readonly session_id: string | null;
|
|
94
|
+
readonly reference_db_ref: string | null;
|
|
95
|
+
readonly matched_input_ref: string | null;
|
|
96
|
+
readonly human_verifier: SerializedSubjectRef | null;
|
|
97
|
+
}
|
|
98
|
+
export interface SerializedChainedEvent {
|
|
99
|
+
readonly seq: number;
|
|
100
|
+
readonly prev_hash_hex: string;
|
|
101
|
+
readonly event_hash_hex: string;
|
|
102
|
+
readonly event: SerializedAuditEvent;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Encode a `SignatureRecord` as the wire-format dict per Python's
|
|
106
|
+
* `_serialize_signature_record`. Hex for fixed-length crypto values
|
|
107
|
+
* (event_hash, signature); base64 for variable blobs (public_key_der,
|
|
108
|
+
* cert_chain, signed_payload); RFC-3339 µs-Z for the datetime.
|
|
109
|
+
*/
|
|
110
|
+
export declare function serializeSignatureRecord(record: SignatureRecord): SerializedSignatureRecord;
|
|
111
|
+
/**
|
|
112
|
+
* Inverse of `serializeSignatureRecord`. Validates the result via
|
|
113
|
+
* `validateSignatureRecord` so malformed records surface as a
|
|
114
|
+
* `SigningError`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function deserializeSignatureRecord(raw: SerializedSignatureRecord): SignatureRecord;
|
|
117
|
+
export declare function serializeChainedEvent(event: ChainedEvent): SerializedChainedEvent;
|
|
118
|
+
/**
|
|
119
|
+
* Accumulator for one proof-bundle build.
|
|
120
|
+
*
|
|
121
|
+
* Not thread-safe — create one per bundle.
|
|
122
|
+
*/
|
|
123
|
+
export declare class ProofBundleBuilder {
|
|
124
|
+
private readonly _chain_id;
|
|
125
|
+
private readonly _producer_runtime;
|
|
126
|
+
private readonly _forbidden_fields;
|
|
127
|
+
private readonly _anchor_ref;
|
|
128
|
+
private readonly _events;
|
|
129
|
+
private readonly _framework_mappings;
|
|
130
|
+
private readonly _signatures;
|
|
131
|
+
constructor(input: ProofBundleBuilderInput);
|
|
132
|
+
extend(events: readonly ChainedEvent[]): void;
|
|
133
|
+
addFrameworkMapping(mapping: FrameworkMapping): void;
|
|
134
|
+
/**
|
|
135
|
+
* Add `SignatureRecord` instances per ADR-0005 T5. Each entry is
|
|
136
|
+
* validated immediately via `validateSignatureRecord`; the bundle's
|
|
137
|
+
* `signatures` field is emitted only when at least one record has
|
|
138
|
+
* been added (preserves byte equality with v0.0.1-alpha bundles).
|
|
139
|
+
*/
|
|
140
|
+
extendSignatures(records: readonly SignatureRecord[]): void;
|
|
141
|
+
build(options?: {
|
|
142
|
+
readonly now?: Date;
|
|
143
|
+
}): ProofBundle;
|
|
144
|
+
}
|
|
145
|
+
export interface AuditorExport {
|
|
146
|
+
readonly export_version: 1;
|
|
147
|
+
readonly chain_summary: {
|
|
148
|
+
readonly chain_id: string;
|
|
149
|
+
readonly head_hash_hex: string;
|
|
150
|
+
readonly event_count: number;
|
|
151
|
+
readonly time_range: {
|
|
152
|
+
readonly earliest: string;
|
|
153
|
+
readonly latest: string;
|
|
154
|
+
};
|
|
155
|
+
readonly producer_runtime: string;
|
|
156
|
+
readonly event_type_histogram: Record<string, number>;
|
|
157
|
+
readonly anchor_status: 'unanchored' | 'anchored_partial' | 'anchored_full';
|
|
158
|
+
};
|
|
159
|
+
readonly verification_status: {
|
|
160
|
+
readonly ok: boolean;
|
|
161
|
+
readonly first_bad_index: number | null;
|
|
162
|
+
readonly reason: string | null;
|
|
163
|
+
readonly verified_at: string;
|
|
164
|
+
readonly verifier_version: string;
|
|
165
|
+
readonly verification_method: 'canonical-bytes-walk' | 'canonical-bytes-walk+anchor';
|
|
166
|
+
};
|
|
167
|
+
readonly framework_coverage: readonly {
|
|
168
|
+
readonly framework: string;
|
|
169
|
+
readonly article: string;
|
|
170
|
+
readonly obligation_ids_with_evidence: readonly string[];
|
|
171
|
+
readonly obligation_ids_without_evidence: readonly string[];
|
|
172
|
+
}[];
|
|
173
|
+
readonly redaction_policy: {
|
|
174
|
+
readonly forbidden_fields: readonly string[];
|
|
175
|
+
readonly redaction_status: 'enforced_by_adapter' | 'enforced_by_producer' | 'unenforced';
|
|
176
|
+
readonly consent_status?: 'consent_present' | 'consent_absent' | 'consent_not_applicable';
|
|
177
|
+
};
|
|
178
|
+
readonly legal_disclaimer: string;
|
|
179
|
+
}
|
|
180
|
+
export interface AuditorExportOptions {
|
|
181
|
+
readonly redaction_status?: AuditorExport['redaction_policy']['redaction_status'];
|
|
182
|
+
readonly consent_status?: 'consent_present' | 'consent_absent' | 'consent_not_applicable';
|
|
183
|
+
readonly legal_disclaimer?: string;
|
|
184
|
+
}
|
|
185
|
+
export declare function buildAuditorExport(bundle: ProofBundle, options?: AuditorExportOptions): AuditorExport;
|
|
186
|
+
//# sourceMappingURL=proof_bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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MAAM,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,aAAa,CAmDf"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 The Attestplane Authors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* Proof-bundle export and auditor-export builders (TypeScript port of
|
|
5
|
+
* `sdk/python/src/attestplane/proof_bundle.py`).
|
|
6
|
+
*
|
|
7
|
+
* The bundle shape matches `schemas/v1/proof_bundle.schema.json` exactly,
|
|
8
|
+
* and the auditor export matches `schemas/v1/auditor_export.schema.json`.
|
|
9
|
+
* Cross-language byte-stable: a chain produced by the Python SDK and a
|
|
10
|
+
* chain produced by the TypeScript SDK that go through the same builder
|
|
11
|
+
* inputs produce the same proof-bundle dict.
|
|
12
|
+
*/
|
|
13
|
+
import { SCHEMA_VERSION, headOf, verifyChain } from './hashchain.js';
|
|
14
|
+
import { VERSION as _SDK_VERSION } from './index_version.js';
|
|
15
|
+
import { SIGNATURE_SCHEMA_VERSION, validateSignatureRecord, } from './signing/base.js';
|
|
16
|
+
export const DEFAULT_FORBIDDEN_FIELDS = [
|
|
17
|
+
'customer_names',
|
|
18
|
+
'person_names',
|
|
19
|
+
'pii',
|
|
20
|
+
'raw_documents',
|
|
21
|
+
'contracts',
|
|
22
|
+
'scripts',
|
|
23
|
+
'tickets',
|
|
24
|
+
'emails',
|
|
25
|
+
'secrets',
|
|
26
|
+
'tokens',
|
|
27
|
+
'jwts',
|
|
28
|
+
'private_keys',
|
|
29
|
+
'raw_audit_payloads',
|
|
30
|
+
];
|
|
31
|
+
function bytesToHex(bytes) {
|
|
32
|
+
let out = '';
|
|
33
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
34
|
+
const v = bytes[i].toString(16).padStart(2, '0');
|
|
35
|
+
out += v;
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function hexToBytes(hex) {
|
|
40
|
+
if (hex.length % 2 !== 0) {
|
|
41
|
+
throw new Error(`hex string has odd length: ${hex.length}`);
|
|
42
|
+
}
|
|
43
|
+
const out = new Uint8Array(hex.length / 2);
|
|
44
|
+
for (let i = 0; i < out.length; i++) {
|
|
45
|
+
const byte = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
46
|
+
if (Number.isNaN(byte)) {
|
|
47
|
+
throw new Error(`invalid hex at offset ${i * 2}: ${hex.slice(i * 2, i * 2 + 2)}`);
|
|
48
|
+
}
|
|
49
|
+
out[i] = byte;
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
function b64encode(bytes) {
|
|
54
|
+
return Buffer.from(bytes).toString('base64');
|
|
55
|
+
}
|
|
56
|
+
function b64decode(b64) {
|
|
57
|
+
return new Uint8Array(Buffer.from(b64, 'base64'));
|
|
58
|
+
}
|
|
59
|
+
function parseSignedAtTimestamp(ts) {
|
|
60
|
+
// Python emits "YYYY-MM-DDTHH:MM:SS.ffffffZ" (microsecond precision +
|
|
61
|
+
// literal Z). Date.parse accepts trailing-Z ISO; sub-millisecond
|
|
62
|
+
// digits are silently truncated to ms precision, which is acceptable
|
|
63
|
+
// because we only compare ISO-form on re-emit — never round-trip Date
|
|
64
|
+
// back to bytes.
|
|
65
|
+
const t = Date.parse(ts);
|
|
66
|
+
if (Number.isNaN(t)) {
|
|
67
|
+
throw new Error(`invalid signed_at timestamp: ${JSON.stringify(ts)}`);
|
|
68
|
+
}
|
|
69
|
+
return new Date(t);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Encode a `SignatureRecord` as the wire-format dict per Python's
|
|
73
|
+
* `_serialize_signature_record`. Hex for fixed-length crypto values
|
|
74
|
+
* (event_hash, signature); base64 for variable blobs (public_key_der,
|
|
75
|
+
* cert_chain, signed_payload); RFC-3339 µs-Z for the datetime.
|
|
76
|
+
*/
|
|
77
|
+
export function serializeSignatureRecord(record) {
|
|
78
|
+
return {
|
|
79
|
+
signature_schema_version: record.signature_schema_version,
|
|
80
|
+
signed_seq: record.signed_seq,
|
|
81
|
+
signed_event_hash_hex: bytesToHex(record.signed_event_hash),
|
|
82
|
+
signature_hex: bytesToHex(record.signature),
|
|
83
|
+
key_id: record.key_id,
|
|
84
|
+
public_key_der_b64: b64encode(record.public_key_der),
|
|
85
|
+
signing_cert_chain_b64: record.signing_cert_chain.map((c) => b64encode(c)),
|
|
86
|
+
signed_at: formatTimestampMicros(record.signed_at),
|
|
87
|
+
signature_mode: record.signature_mode,
|
|
88
|
+
signed_payload_b64: b64encode(record.signed_payload),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Inverse of `serializeSignatureRecord`. Validates the result via
|
|
93
|
+
* `validateSignatureRecord` so malformed records surface as a
|
|
94
|
+
* `SigningError`.
|
|
95
|
+
*/
|
|
96
|
+
export function deserializeSignatureRecord(raw) {
|
|
97
|
+
const required = [
|
|
98
|
+
'signature_schema_version',
|
|
99
|
+
'signed_seq',
|
|
100
|
+
'signed_event_hash_hex',
|
|
101
|
+
'signature_hex',
|
|
102
|
+
'key_id',
|
|
103
|
+
'public_key_der_b64',
|
|
104
|
+
'signing_cert_chain_b64',
|
|
105
|
+
'signed_at',
|
|
106
|
+
'signature_mode',
|
|
107
|
+
'signed_payload_b64',
|
|
108
|
+
];
|
|
109
|
+
const obj = raw;
|
|
110
|
+
for (const k of required) {
|
|
111
|
+
if (!(k in obj)) {
|
|
112
|
+
throw new Error(`deserializeSignatureRecord: missing field ${k}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const record = {
|
|
116
|
+
signature_schema_version: Number(raw.signature_schema_version),
|
|
117
|
+
signed_seq: Number(raw.signed_seq),
|
|
118
|
+
signed_event_hash: hexToBytes(raw.signed_event_hash_hex),
|
|
119
|
+
signature: hexToBytes(raw.signature_hex),
|
|
120
|
+
key_id: String(raw.key_id),
|
|
121
|
+
public_key_der: b64decode(raw.public_key_der_b64),
|
|
122
|
+
signing_cert_chain: raw.signing_cert_chain_b64.map((c) => b64decode(c)),
|
|
123
|
+
signed_at: parseSignedAtTimestamp(raw.signed_at),
|
|
124
|
+
signature_mode: raw.signature_mode,
|
|
125
|
+
signed_payload: b64decode(raw.signed_payload_b64),
|
|
126
|
+
};
|
|
127
|
+
validateSignatureRecord(record);
|
|
128
|
+
return record;
|
|
129
|
+
}
|
|
130
|
+
function formatTimestampMicros(d) {
|
|
131
|
+
// ISO date with 6-digit microsecond precision and literal Z.
|
|
132
|
+
// JavaScript Date is millisecond-precision; we right-pad three zeros.
|
|
133
|
+
const isoMs = d.toISOString(); // "YYYY-MM-DDThh:mm:ss.sssZ"
|
|
134
|
+
// Replace ".sssZ" with ".sss000Z" to widen to microseconds.
|
|
135
|
+
return isoMs.replace(/\.(\d{3})Z$/, '.$1000Z');
|
|
136
|
+
}
|
|
137
|
+
function serializeSubject(ref) {
|
|
138
|
+
if (ref == null)
|
|
139
|
+
return null;
|
|
140
|
+
return { scheme: ref.scheme, value: ref.value };
|
|
141
|
+
}
|
|
142
|
+
export function serializeChainedEvent(event) {
|
|
143
|
+
return {
|
|
144
|
+
seq: event.seq,
|
|
145
|
+
prev_hash_hex: bytesToHex(event.prev_hash),
|
|
146
|
+
event_hash_hex: bytesToHex(event.event_hash),
|
|
147
|
+
event: {
|
|
148
|
+
schema_version: event.event.schema_version,
|
|
149
|
+
event_id: event.event.event_id,
|
|
150
|
+
timestamp: formatTimestampMicros(event.event.timestamp),
|
|
151
|
+
event_type: event.event.event_type,
|
|
152
|
+
actor: event.event.actor,
|
|
153
|
+
payload: event.event.payload,
|
|
154
|
+
subject_ref: serializeSubject(event.event.subject_ref),
|
|
155
|
+
session_id: event.event.session_id,
|
|
156
|
+
reference_db_ref: event.event.reference_db_ref,
|
|
157
|
+
matched_input_ref: event.event.matched_input_ref,
|
|
158
|
+
human_verifier: serializeSubject(event.event.human_verifier),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Accumulator for one proof-bundle build.
|
|
164
|
+
*
|
|
165
|
+
* Not thread-safe — create one per bundle.
|
|
166
|
+
*/
|
|
167
|
+
export class ProofBundleBuilder {
|
|
168
|
+
_chain_id;
|
|
169
|
+
_producer_runtime;
|
|
170
|
+
_forbidden_fields;
|
|
171
|
+
_anchor_ref;
|
|
172
|
+
_events = [];
|
|
173
|
+
_framework_mappings = [];
|
|
174
|
+
_signatures = [];
|
|
175
|
+
constructor(input) {
|
|
176
|
+
this._chain_id = input.chain_id;
|
|
177
|
+
this._producer_runtime = input.producer_runtime;
|
|
178
|
+
this._forbidden_fields = input.forbidden_fields ?? DEFAULT_FORBIDDEN_FIELDS;
|
|
179
|
+
this._anchor_ref = input.anchor_ref ?? null;
|
|
180
|
+
}
|
|
181
|
+
extend(events) {
|
|
182
|
+
for (const e of events)
|
|
183
|
+
this._events.push(e);
|
|
184
|
+
}
|
|
185
|
+
addFrameworkMapping(mapping) {
|
|
186
|
+
for (const idx of mapping.evidence_event_indexes) {
|
|
187
|
+
if (idx < 0 || idx >= this._events.length) {
|
|
188
|
+
throw new Error(`framework_mapping for ${mapping.obligation_id} references event index ${idx} ` +
|
|
189
|
+
`but bundle has only ${this._events.length} events`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this._framework_mappings.push(mapping);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Add `SignatureRecord` instances per ADR-0005 T5. Each entry is
|
|
196
|
+
* validated immediately via `validateSignatureRecord`; the bundle's
|
|
197
|
+
* `signatures` field is emitted only when at least one record has
|
|
198
|
+
* been added (preserves byte equality with v0.0.1-alpha bundles).
|
|
199
|
+
*/
|
|
200
|
+
extendSignatures(records) {
|
|
201
|
+
for (const r of records) {
|
|
202
|
+
validateSignatureRecord(r);
|
|
203
|
+
if (r.signature_schema_version !== SIGNATURE_SCHEMA_VERSION) {
|
|
204
|
+
throw new Error(`extendSignatures: signature_schema_version must be ${SIGNATURE_SCHEMA_VERSION}, got ${r.signature_schema_version}`);
|
|
205
|
+
}
|
|
206
|
+
this._signatures.push(r);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
build(options) {
|
|
210
|
+
const actualNow = options?.now ?? new Date();
|
|
211
|
+
const result = verifyChain(this._events);
|
|
212
|
+
const head = headOf(this._events);
|
|
213
|
+
const verifiedAt = formatTimestampMicros(actualNow);
|
|
214
|
+
const chainMetadata = {
|
|
215
|
+
chain_id: this._chain_id,
|
|
216
|
+
schema_version: SCHEMA_VERSION,
|
|
217
|
+
genesis_hash_hex: '0'.repeat(64),
|
|
218
|
+
head_hash_hex: bytesToHex(head.event_hash),
|
|
219
|
+
head_seq: head.seq,
|
|
220
|
+
producer_runtime: this._producer_runtime,
|
|
221
|
+
evidence_taxonomy_version: 1,
|
|
222
|
+
...(this._anchor_ref != null ? { anchor_ref: this._anchor_ref } : {}),
|
|
223
|
+
};
|
|
224
|
+
const bundle = {
|
|
225
|
+
bundle_version: 1,
|
|
226
|
+
chain_metadata: chainMetadata,
|
|
227
|
+
events: this._events.map(serializeChainedEvent),
|
|
228
|
+
verification_report: {
|
|
229
|
+
ok: result.ok,
|
|
230
|
+
first_bad_index: result.first_bad_index,
|
|
231
|
+
reason: result.reason,
|
|
232
|
+
verified_at: verifiedAt,
|
|
233
|
+
verifier_version: _SDK_VERSION,
|
|
234
|
+
verification_method: 'canonical-bytes-walk',
|
|
235
|
+
},
|
|
236
|
+
framework_mappings: [...this._framework_mappings],
|
|
237
|
+
forbidden_fields: [...this._forbidden_fields],
|
|
238
|
+
// ADR-0012 P1.2: auto-derive policy_trace_refs (absent when empty).
|
|
239
|
+
...(() => {
|
|
240
|
+
const refs = this._events
|
|
241
|
+
.filter((ev) => ev.event.event_type === 'policy_check_event')
|
|
242
|
+
.map((ev) => bytesToHex(ev.event_hash));
|
|
243
|
+
return refs.length > 0 ? { policy_trace_refs: refs } : {};
|
|
244
|
+
})(),
|
|
245
|
+
...(this._signatures.length > 0
|
|
246
|
+
? { signatures: this._signatures.map(serializeSignatureRecord) }
|
|
247
|
+
: {}),
|
|
248
|
+
};
|
|
249
|
+
return bundle;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const DEFAULT_DISCLAIMER = 'This export is a technical chain-integrity and framework-coverage summary. ' +
|
|
253
|
+
'It is not a compliance opinion. Consult qualified counsel for any regulatory determination.';
|
|
254
|
+
export function buildAuditorExport(bundle, options) {
|
|
255
|
+
const histogram = {};
|
|
256
|
+
for (const ev of bundle.events) {
|
|
257
|
+
const key = ev.event.event_type;
|
|
258
|
+
histogram[key] = (histogram[key] ?? 0) + 1;
|
|
259
|
+
}
|
|
260
|
+
let earliest;
|
|
261
|
+
let latest;
|
|
262
|
+
const firstEvent = bundle.events[0];
|
|
263
|
+
if (firstEvent !== undefined) {
|
|
264
|
+
earliest = bundle.events.reduce((acc, ev) => (ev.event.timestamp < acc ? ev.event.timestamp : acc), firstEvent.event.timestamp);
|
|
265
|
+
latest = bundle.events.reduce((acc, ev) => (ev.event.timestamp > acc ? ev.event.timestamp : acc), firstEvent.event.timestamp);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
earliest = bundle.verification_report.verified_at;
|
|
269
|
+
latest = earliest;
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
export_version: 1,
|
|
273
|
+
chain_summary: {
|
|
274
|
+
chain_id: bundle.chain_metadata.chain_id,
|
|
275
|
+
head_hash_hex: bundle.chain_metadata.head_hash_hex,
|
|
276
|
+
event_count: bundle.events.length,
|
|
277
|
+
time_range: { earliest, latest },
|
|
278
|
+
producer_runtime: bundle.chain_metadata.producer_runtime,
|
|
279
|
+
event_type_histogram: histogram,
|
|
280
|
+
anchor_status: 'unanchored',
|
|
281
|
+
},
|
|
282
|
+
verification_status: {
|
|
283
|
+
ok: bundle.verification_report.ok,
|
|
284
|
+
first_bad_index: bundle.verification_report.first_bad_index,
|
|
285
|
+
reason: bundle.verification_report.reason,
|
|
286
|
+
verified_at: bundle.verification_report.verified_at,
|
|
287
|
+
verifier_version: bundle.verification_report.verifier_version,
|
|
288
|
+
verification_method: bundle.verification_report.verification_method,
|
|
289
|
+
},
|
|
290
|
+
framework_coverage: [],
|
|
291
|
+
redaction_policy: {
|
|
292
|
+
forbidden_fields: bundle.forbidden_fields,
|
|
293
|
+
redaction_status: options?.redaction_status ?? 'enforced_by_producer',
|
|
294
|
+
consent_status: options?.consent_status ?? 'consent_not_applicable',
|
|
295
|
+
},
|
|
296
|
+
legal_disclaimer: options?.legal_disclaimer ?? DEFAULT_DISCLAIMER,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=proof_bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof_bundle.js","sourceRoot":"","sources":["../src/proof_bundle.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,sCAAsC;AACtC;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,wBAAwB,EAExB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IACzD,gBAAgB;IAChB,cAAc;IACd,KAAK;IACL,eAAe;IACf,WAAW;IACX,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,cAAc;IACd,oBAAoB;CACrB,CAAC;AAwGF,SAAS,UAAU,CAAC,KAAiB;IACnC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,CAAC,GAAI,KAAK,CAAC,CAAC,CAAY,C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WAAW,EAAE,MAAM,CAAC,mBAAmB,CAAC,WAAW;YACnD,gBAAgB,EAAE,MAAM,CAAC,mBAAmB,CAAC,gBAAgB;YAC7D,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC,mBAAmB;SACpE;QACD,kBAAkB,EAAE,EAAE;QACtB,gBAAgB,EAAE;YAChB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,IAAI,sBAAsB;YACrE,cAAc,EAAE,OAAO,EAAE,cAAc,IAAI,wBAAwB;SACpE;QACD,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,IAAI,kBAAkB;KAClE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReasonCodeV1 enum — machine-readable verification findings (ADR-0010).
|
|
3
|
+
*
|
|
4
|
+
* Stable string enum for downstream tooling (audit reports, EU AI Act
|
|
5
|
+
* Article 12 evidence packs, regulator dashboards) to branch on the
|
|
6
|
+
* *kind* of verification finding instead of regex-matching free-text
|
|
7
|
+
* strings.
|
|
8
|
+
*
|
|
9
|
+
* The enum value set is frozen for v1 alongside
|
|
10
|
+
* `REASON_CODE_SCHEMA_VERSION`. Adding new values requires a new ADR
|
|
11
|
+
* amending ADR-0010 + a bump to schema version 2.
|
|
12
|
+
*
|
|
13
|
+
* Cross-language byte stability: the Python SDK exposes the same value
|
|
14
|
+
* set via `reason_codes.py`. A conformance vector pins Py/TS equality
|
|
15
|
+
* in CI.
|
|
16
|
+
*
|
|
17
|
+
* This module ships ONLY the enum primitive + helpers; it does NOT
|
|
18
|
+
* modify `VerificationResult` or any verifier path's return shape.
|
|
19
|
+
* Threading is sequenced into a follow-up ADR (anticipated ADR-0015)
|
|
20
|
+
* so this ADR can ship as additive-only.
|
|
21
|
+
*/
|
|
22
|
+
export declare const REASON_CODE_SCHEMA_VERSION: 1;
|
|
23
|
+
export type ReasonCodeV1 = 'CHAIN_OK' | 'CHAIN_SEQ_MISMATCH' | 'CHAIN_PREV_HASH_MISMATCH' | 'CHAIN_EVENT_HASH_MISMATCH' | 'SIGNATURE_OK' | 'SIGNATURE_INVALID' | 'SIGNATURE_UNKNOWN_KEY' | 'SIGNATURE_EXPIRED_KEY' | 'SIGNATURE_SCHEMA_MISMATCH' | 'SIGNATURE_PAYLOAD_MISMATCH' | 'ANCHOR_OK' | 'ANCHOR_INVALID' | 'ANCHOR_CERT_EXPIRED' | 'ANCHOR_OCSP_FAILED' | 'ANCHOR_MISSING_LTV_ARTIFACTS' | 'PAYLOAD_OK' | 'PAYLOAD_MISSING_REQUIRED_FIELD' | 'PAYLOAD_FIELD_TYPE_MISMATCH' | 'PAYLOAD_FIELD_VALUE_OUT_OF_RANGE' | 'PAYLOAD_FORBIDDEN_FIELD_PRESENT' | 'PAYLOAD_SCHEMA_VERSION_MISMATCH' | 'UNSIGNED_SEGMENT' | 'UNANCHORED_SEGMENT' | 'BUNDLE_MISSING_REQUIRED_FIELD' | 'INTERNAL_ERROR';
|
|
24
|
+
export declare const ALL_REASON_CODES_V1: ReadonlySet<ReasonCodeV1>;
|
|
25
|
+
export declare const REASON_CODE_DESCRIPTIONS: Readonly<Record<ReasonCodeV1, string>>;
|
|
26
|
+
/**
|
|
27
|
+
* Return `true` if `code` is in `ALL_REASON_CODES_V1`. Use this in
|
|
28
|
+
* tests to catch typos at the emit site, and in downstream consumers
|
|
29
|
+
* for forward-compatible fallback ("treat unknown codes as INTERNAL_ERROR").
|
|
30
|
+
*/
|
|
31
|
+
export declare function isKnownReasonCode(code: string): code is ReasonCodeV1;
|
|
32
|
+
/**
|
|
33
|
+
* Return `true` if `code` matches the documented uppercase regex.
|
|
34
|
+
* Useful for validating caller-supplied codes in payload `reason_code`
|
|
35
|
+
* fields where domain-specific codes are also permitted.
|
|
36
|
+
*/
|
|
37
|
+
export declare function reasonCodeMatchesFormat(code: string): boolean;
|
|
38
|
+
//# sourceMappingURL=reason_codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reason_codes.d.ts","sourceRoot":"","sources":["../src/reason_codes.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,0BAA0B,EAAG,CAAU,CAAC;AAKrD,MAAM,MAAM,YAAY,GAEpB,UAAU,GACV,oBAAoB,GACpB,0BAA0B,GAC1B,2BAA2B,GAE3B,cAAc,GACd,mBAAmB,GACnB,uBAAuB,GACvB,uBAAuB,GACvB,2BAA2B,GAC3B,4BAA4B,GAE5B,WAAW,GACX,gBAAgB,GAChB,qBAAqB,GACrB,oBAAoB,GACpB,8BAA8B,GAE9B,YAAY,GACZ,gCAAgC,GAChC,6BAA6B,GAC7B,kCAAkC,GAClC,iCAAiC,GACjC,iCAAiC,GAEjC,kBAAkB,GAClB,oBAAoB,GACpB,+BAA+B,GAC/B,gBAAgB,CAAC;AAErB,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,YAAY,CA0BxD,CAAC;AAEH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CA+B3E,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,YAAY,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 The Attestplane Authors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* ReasonCodeV1 enum — machine-readable verification findings (ADR-0010).
|
|
5
|
+
*
|
|
6
|
+
* Stable string enum for downstream tooling (audit reports, EU AI Act
|
|
7
|
+
* Article 12 evidence packs, regulator dashboards) to branch on the
|
|
8
|
+
* *kind* of verification finding instead of regex-matching free-text
|
|
9
|
+
* strings.
|
|
10
|
+
*
|
|
11
|
+
* The enum value set is frozen for v1 alongside
|
|
12
|
+
* `REASON_CODE_SCHEMA_VERSION`. Adding new values requires a new ADR
|
|
13
|
+
* amending ADR-0010 + a bump to schema version 2.
|
|
14
|
+
*
|
|
15
|
+
* Cross-language byte stability: the Python SDK exposes the same value
|
|
16
|
+
* set via `reason_codes.py`. A conformance vector pins Py/TS equality
|
|
17
|
+
* in CI.
|
|
18
|
+
*
|
|
19
|
+
* This module ships ONLY the enum primitive + helpers; it does NOT
|
|
20
|
+
* modify `VerificationResult` or any verifier path's return shape.
|
|
21
|
+
* Threading is sequenced into a follow-up ADR (anticipated ADR-0015)
|
|
22
|
+
* so this ADR can ship as additive-only.
|
|
23
|
+
*/
|
|
24
|
+
export const REASON_CODE_SCHEMA_VERSION = 1;
|
|
25
|
+
// Regex from ADR-0010 § 1: uppercase ASCII underscored, 2-64 chars.
|
|
26
|
+
const REASON_CODE_PATTERN = /^[A-Z][A-Z0-9_]{1,63}$/;
|
|
27
|
+
export const ALL_REASON_CODES_V1 = new Set([
|
|
28
|
+
'CHAIN_OK',
|
|
29
|
+
'CHAIN_SEQ_MISMATCH',
|
|
30
|
+
'CHAIN_PREV_HASH_MISMATCH',
|
|
31
|
+
'CHAIN_EVENT_HASH_MISMATCH',
|
|
32
|
+
'SIGNATURE_OK',
|
|
33
|
+
'SIGNATURE_INVALID',
|
|
34
|
+
'SIGNATURE_UNKNOWN_KEY',
|
|
35
|
+
'SIGNATURE_EXPIRED_KEY',
|
|
36
|
+
'SIGNATURE_SCHEMA_MISMATCH',
|
|
37
|
+
'SIGNATURE_PAYLOAD_MISMATCH',
|
|
38
|
+
'ANCHOR_OK',
|
|
39
|
+
'ANCHOR_INVALID',
|
|
40
|
+
'ANCHOR_CERT_EXPIRED',
|
|
41
|
+
'ANCHOR_OCSP_FAILED',
|
|
42
|
+
'ANCHOR_MISSING_LTV_ARTIFACTS',
|
|
43
|
+
'PAYLOAD_OK',
|
|
44
|
+
'PAYLOAD_MISSING_REQUIRED_FIELD',
|
|
45
|
+
'PAYLOAD_FIELD_TYPE_MISMATCH',
|
|
46
|
+
'PAYLOAD_FIELD_VALUE_OUT_OF_RANGE',
|
|
47
|
+
'PAYLOAD_FORBIDDEN_FIELD_PRESENT',
|
|
48
|
+
'PAYLOAD_SCHEMA_VERSION_MISMATCH',
|
|
49
|
+
'UNSIGNED_SEGMENT',
|
|
50
|
+
'UNANCHORED_SEGMENT',
|
|
51
|
+
'BUNDLE_MISSING_REQUIRED_FIELD',
|
|
52
|
+
'INTERNAL_ERROR',
|
|
53
|
+
]);
|
|
54
|
+
export const REASON_CODE_DESCRIPTIONS = {
|
|
55
|
+
CHAIN_OK: 'Chain integrity verified end-to-end.',
|
|
56
|
+
CHAIN_SEQ_MISMATCH: 'ChainedEvent.seq does not equal expected position in chain.',
|
|
57
|
+
CHAIN_PREV_HASH_MISMATCH: "ChainedEvent.prev_hash does not equal previous event's event_hash.",
|
|
58
|
+
CHAIN_EVENT_HASH_MISMATCH: 'ChainedEvent.event_hash does not equal hash_event(audit_event); canonicalize bytes have drifted.',
|
|
59
|
+
SIGNATURE_OK: 'Ed25519 signature verified.',
|
|
60
|
+
SIGNATURE_INVALID: 'Ed25519 verification failed (cryptographic mismatch).',
|
|
61
|
+
SIGNATURE_UNKNOWN_KEY: 'key_id is not present in the configured trust roots.',
|
|
62
|
+
SIGNATURE_EXPIRED_KEY: "verification_time falls outside the trust-root entry's validity window.",
|
|
63
|
+
SIGNATURE_SCHEMA_MISMATCH: 'signature_schema_version is unsupported by this verifier.',
|
|
64
|
+
SIGNATURE_PAYLOAD_MISMATCH: 'signed_payload bytes do not match the re-canonicalised expected payload.',
|
|
65
|
+
ANCHOR_OK: 'Anchor record verified including LTV (long-term validation) artifacts.',
|
|
66
|
+
ANCHOR_INVALID: "Anchor record's signature, hash, or format check failed.",
|
|
67
|
+
ANCHOR_CERT_EXPIRED: 'TSA certificate chain expired at verification_time.',
|
|
68
|
+
ANCHOR_OCSP_FAILED: 'OCSP response invalid, revoked, or missing for the TSA certificate.',
|
|
69
|
+
ANCHOR_MISSING_LTV_ARTIFACTS: 'tsa_cert_chain or ocsp_responses is empty; CAdES-A long-term validation unsupported.',
|
|
70
|
+
PAYLOAD_OK: 'Payload validates against its declared event schema.',
|
|
71
|
+
PAYLOAD_MISSING_REQUIRED_FIELD: 'A required payload field is absent.',
|
|
72
|
+
PAYLOAD_FIELD_TYPE_MISMATCH: 'A payload field is present but has the wrong type.',
|
|
73
|
+
PAYLOAD_FIELD_VALUE_OUT_OF_RANGE: 'A payload field has a value outside the declared enum/regex/numeric range.',
|
|
74
|
+
PAYLOAD_FORBIDDEN_FIELD_PRESENT: 'Payload contains a field name forbidden by ADR-0004 § 2 redaction policy.',
|
|
75
|
+
PAYLOAD_SCHEMA_VERSION_MISMATCH: "Payload's declared <event>_schema_version is unsupported.",
|
|
76
|
+
UNSIGNED_SEGMENT: 'Bundle contains no signature records covering this chain segment.',
|
|
77
|
+
UNANCHORED_SEGMENT: 'Bundle contains no anchor records covering this chain segment.',
|
|
78
|
+
BUNDLE_MISSING_REQUIRED_FIELD: 'A top-level proof-bundle field is absent.',
|
|
79
|
+
INTERNAL_ERROR: 'Verifier hit an unexpected condition; should not occur in conformant input.',
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Return `true` if `code` is in `ALL_REASON_CODES_V1`. Use this in
|
|
83
|
+
* tests to catch typos at the emit site, and in downstream consumers
|
|
84
|
+
* for forward-compatible fallback ("treat unknown codes as INTERNAL_ERROR").
|
|
85
|
+
*/
|
|
86
|
+
export function isKnownReasonCode(code) {
|
|
87
|
+
return ALL_REASON_CODES_V1.has(code);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Return `true` if `code` matches the documented uppercase regex.
|
|
91
|
+
* Useful for validating caller-supplied codes in payload `reason_code`
|
|
92
|
+
* fields where domain-specific codes are also permitted.
|
|
93
|
+
*/
|
|
94
|
+
export function reasonCodeMatchesFormat(code) {
|
|
95
|
+
return REASON_CODE_PATTERN.test(code);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=reason_codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reason_codes.js","sourceRoot":"","sources":["../src/reason_codes.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,sCAAsC;AACtC;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAU,CAAC;AAErD,oEAAoE;AACpE,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAkCrD,MAAM,CAAC,MAAM,mBAAmB,GAA8B,IAAI,GAAG,CAAe;IAClF,UAAU;IACV,oBAAoB;IACpB,0BAA0B;IAC1B,2BAA2B;IAC3B,cAAc;IACd,mBAAmB;IACnB,uBAAuB;IACvB,uBAAuB;IACvB,2BAA2B;IAC3B,4BAA4B;IAC5B,WAAW;IACX,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,8BAA8B;IAC9B,YAAY;IACZ,gCAAgC;IAChC,6BAA6B;IAC7B,kCAAkC;IAClC,iCAAiC;IACjC,iCAAiC;IACjC,kBAAkB;IAClB,oBAAoB;IACpB,+BAA+B;IAC/B,gBAAgB;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAA2C;IAC9E,QAAQ,EAAE,sCAAsC;IAChD,kBAAkB,EAAE,6DAA6D;IACjF,wBAAwB,EAAE,oEAAoE;IAC9F,yBAAyB,EACvB,kGAAkG;IACpG,YAAY,EAAE,6BAA6B;IAC3C,iBAAiB,EAAE,uDAAuD;IAC1E,qBAAqB,EAAE,sDAAsD;IAC7E,qBAAqB,EAAE,yEAAyE;IAChG,yBAAyB,EAAE,2DAA2D;IACtF,0BAA0B,EACxB,0EAA0E;IAC5E,SAAS,EAAE,wEAAwE;IACnF,cAAc,EAAE,0DAA0D;IAC1E,mBAAmB,EAAE,qDAAqD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