@cardanowall/sdk-ts 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/client/index.cjs +1146 -365
  2. package/dist/client/index.cjs.map +1 -1
  3. package/dist/client/index.d.cts +48 -7
  4. package/dist/client/index.d.ts +48 -7
  5. package/dist/client/index.js +1144 -367
  6. package/dist/client/index.js.map +1 -1
  7. package/dist/conformance/cli.cjs +4400 -2121
  8. package/dist/conformance/cli.cjs.map +1 -1
  9. package/dist/conformance/cli.js +4401 -2122
  10. package/dist/conformance/cli.js.map +1 -1
  11. package/dist/fetch/index.cjs +33 -14
  12. package/dist/fetch/index.cjs.map +1 -1
  13. package/dist/fetch/index.d.cts +2 -2
  14. package/dist/fetch/index.d.ts +2 -2
  15. package/dist/fetch/index.js +32 -15
  16. package/dist/fetch/index.js.map +1 -1
  17. package/dist/{fetch-outbound-BT5-NiYN.d.cts → fetch-outbound-dOK3ZxYa.d.cts} +7 -3
  18. package/dist/{fetch-outbound-BT5-NiYN.d.ts → fetch-outbound-dOK3ZxYa.d.ts} +7 -3
  19. package/dist/hash/index.cjs +1 -1
  20. package/dist/hash/index.cjs.map +1 -1
  21. package/dist/hash/index.js +1 -1
  22. package/dist/hash/index.js.map +1 -1
  23. package/dist/identity/index.cjs +356 -230
  24. package/dist/identity/index.cjs.map +1 -1
  25. package/dist/identity/index.d.cts +3 -2
  26. package/dist/identity/index.d.ts +3 -2
  27. package/dist/identity/index.js +356 -230
  28. package/dist/identity/index.js.map +1 -1
  29. package/dist/index.cjs +5480 -2520
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +7 -7
  32. package/dist/index.d.ts +7 -7
  33. package/dist/index.js +5460 -2516
  34. package/dist/index.js.map +1 -1
  35. package/dist/merkle/index.cjs +1 -1
  36. package/dist/merkle/index.js +1 -1
  37. package/dist/types-Cexm4VH9.d.cts +119 -0
  38. package/dist/types-CgoBub9J.d.ts +119 -0
  39. package/dist/{types-DGsZTMuZ.d.cts → types-DNu_IrWZ.d.cts} +236 -7
  40. package/dist/{types-DGsZTMuZ.d.ts → types-DNu_IrWZ.d.ts} +236 -7
  41. package/dist/verifier/index.cjs +4419 -2147
  42. package/dist/verifier/index.cjs.map +1 -1
  43. package/dist/verifier/index.d.cts +159 -111
  44. package/dist/verifier/index.d.ts +159 -111
  45. package/dist/verifier/index.js +4407 -2143
  46. package/dist/verifier/index.js.map +1 -1
  47. package/package.json +3 -3
  48. package/dist/types-B8Q3gW54.d.ts +0 -123
  49. package/dist/types-CLXdbjqr.d.cts +0 -123
@@ -1,71 +1,43 @@
1
- import { g as VerifyReport, E as ExitCode, h as VerifyTxInput, a as Profile, f as VerifyRecordSignature, l as VerifyUriCheck, d as VerifyItemDecryption, e as VerifyMerkleCheck, j as VerifyTxSummary, k as VerifyTxWitness } from '../types-CLXdbjqr.cjs';
2
- export { D as DecryptionVerdict, I as ItemHashCheck, M as MerkleVerdict, N as Network, P as PROFILE_RANK, S as SignatureFailureReason, b as SignatureVerdict, c as SignerType, V as Verdict, i as VerifyTxOutput } from '../types-CLXdbjqr.cjs';
3
- import { F as FetchOutbound, H as HttpCallRecord } from '../fetch-outbound-BT5-NiYN.cjs';
4
- export { B as BodyTooLargeError, D as DEFAULT_OUTBOUND_MAX_BYTES, a as DENY_HOSTS_DEFAULT, b as DenyHostError, c as FetchOutboundOptions, d as FetchOutboundResult, O as OutboundExhaustedError, R as RetryConfig, U as UnsupportedMethodError, g as UnsupportedProtocolError, W as WrapFetchOutboundConfig, h as defaultFetchOutbound, i as fetchOutbound, w as wrapFetchOutbound } from '../fetch-outbound-BT5-NiYN.cjs';
5
- import { PoeRecord, ValidationIssue } from '@cardanowall/poe-standard';
1
+ import { g as VerifyReport, b as ExitCode, h as VerifyResolvedInput, i as VerifyTxInput, f as VerifyRecordSignature, c as Profile, k as VerifyTxSummary, l as VerifyTxWitness } from '../types-Cexm4VH9.cjs';
2
+ export { C as ContentCheck, D as DecryptionCredential, a as DecryptionOutcome, E as EXIT_CODE_FOR_VERDICT, I as ItemReportEntry, M as MerkleReportEntry, P as PROFILE_RANK, S as SignatureFailureReason, d as SignatureVerdict, e as SignerType, V as Verdict, j as VerifyTxOutput } from '../types-Cexm4VH9.cjs';
3
+ import { ValidationIssue, ErrorCode, Severity, PoeRecord } from '@cardanowall/poe-standard';
6
4
  export { ValidationIssue } from '@cardanowall/poe-standard';
5
+ import { F as FetchOutbound } from '../fetch-outbound-dOK3ZxYa.cjs';
6
+ export { B as BodyTooLargeError, D as DEFAULT_OUTBOUND_MAX_BYTES, a as DENY_HOSTS_DEFAULT, b as DenyHostError, c as FetchOutboundOptions, d as FetchOutboundResult, H as HttpCallRecord, O as OutboundExhaustedError, R as RetryConfig, U as UnsupportedMethodError, g as UnsupportedProtocolError, W as WrapFetchOutboundConfig, h as defaultFetchOutbound, i as fetchOutbound, j as isBodyTooLargeError, k as isDenyHostError, w as wrapFetchOutbound } from '../fetch-outbound-dOK3ZxYa.cjs';
7
7
 
8
8
  declare const CONFIRMATION_DEPTH_THRESHOLD_DEFAULT = 15;
9
9
  declare function verifyTx(input: VerifyTxInput): Promise<VerifyReport>;
10
10
  /**
11
- * `verifyResolved` same pipeline as `verifyTx` starting from step 3
12
- * (structural validator). The caller has already resolved the label-309
13
- * metadata bytes + block-info tuple from somewhere other than a live chain
14
- * fetch (typically an indexer database mirror).
15
- *
16
- * Use this when you trust an upstream indexer for the (metadataCbor,
17
- * blockTime, blockSlot, numConfirmations) tuple and want to skip the
18
- * /tx_cbor + /tx_info round-trip. The caller is responsible for the
19
- * confidence that the supplied bytes actually came from the label-309
20
- * metadata field of a confirmed Cardano transaction.
11
+ * Sibling entry point: run the pipeline from the structural-validator step
12
+ * onward over caller-supplied label-309 record-body bytes plus an
13
+ * explorer-asserted block-info tuple the path a server-rendered viewer uses
14
+ * to display on-chain data without a render-time chain fetch. The caller is
15
+ * responsible for the confidence that the bytes came from the label-309
16
+ * metadata of a real Cardano transaction.
21
17
  */
22
- declare function verifyResolved(input: {
23
- txHash: string;
24
- metadataCbor: Uint8Array;
25
- txCbor?: Uint8Array;
26
- numConfirmations: number;
27
- blockTime?: number;
28
- blockSlot?: number;
29
- network?: VerifyReport['network'];
30
- cardanoNetwork?: VerifyTxInput['cardanoNetwork'];
31
- profile?: Profile;
32
- confirmationDepthThreshold?: number;
33
- fetchOutbound?: FetchOutbound;
34
- denyHosts?: ReadonlyArray<string>;
35
- decryption?: VerifyTxInput['decryption'];
36
- verifyMerkle?: boolean;
37
- }): Promise<VerifyReport>;
18
+ declare function verifyResolved(input: VerifyResolvedInput): Promise<VerifyReport>;
38
19
  declare function exitCodeForVerdict(report: VerifyReport): ExitCode;
39
20
 
40
- interface VerifyRecordSignaturesArgs {
41
- readonly record: PoeRecord;
42
- readonly input: VerifyTxInput;
43
- }
44
- declare function verifyRecordSignatures(args: VerifyRecordSignaturesArgs): Promise<VerifyRecordSignature[]>;
45
-
46
- interface TryDecryptionsArgs {
47
- readonly record: PoeRecord;
48
- readonly input: VerifyTxInput;
49
- readonly fetchFn: FetchOutbound;
50
- readonly httpCalls: HttpCallRecord[];
51
- readonly uriChecksOut: VerifyUriCheck[];
52
- readonly allowUriFetch: boolean;
53
- }
54
- interface TryDecryptionsResult {
55
- readonly results: VerifyItemDecryption[];
21
+ type IssuePath = ReadonlyArray<string | number>;
22
+ declare function issueOf(code: ErrorCode, path: IssuePath, message: string, severity?: Severity): ValidationIssue;
23
+ declare function compareIssuePaths(a: IssuePath, b: IssuePath): number;
24
+ declare function sortIssues(issues: ReadonlyArray<ValidationIssue>): ValidationIssue[];
25
+ declare class IssueSink {
26
+ private readonly issues;
27
+ push(issue: ValidationIssue): void;
28
+ add(code: ErrorCode, path: IssuePath, message: string, severity?: Severity): void;
29
+ addOnce(code: ErrorCode, path: IssuePath, message: string, severity?: Severity): void;
30
+ pushAll(issues: ReadonlyArray<ValidationIssue>): void;
31
+ has(code: ErrorCode): boolean;
32
+ sorted(): ValidationIssue[];
56
33
  }
57
- declare function tryDecryptions(args: TryDecryptionsArgs): Promise<TryDecryptionsResult>;
58
34
 
59
- interface VerifyMerkleArgs {
35
+ interface VerifyRecordSignaturesArgs {
60
36
  readonly record: PoeRecord;
61
- readonly input: VerifyTxInput;
62
- readonly fetchFn: FetchOutbound;
63
- readonly uriChecksOut: VerifyUriCheck[];
37
+ readonly cardanoNetwork: 'mainnet' | 'preprod';
38
+ readonly issues: IssueSink;
64
39
  }
65
- interface VerifyMerkleResult {
66
- readonly checks: VerifyMerkleCheck[];
67
- }
68
- declare function verifyMerkleCommitments(args: VerifyMerkleArgs): Promise<VerifyMerkleResult>;
40
+ declare function verifyRecordSignatures(args: VerifyRecordSignaturesArgs): VerifyRecordSignature[];
69
41
 
70
42
  declare const DEFAULT_PROFILE: Profile;
71
43
  declare function profileImplements(actual: Profile, required: Profile): boolean;
@@ -74,70 +46,127 @@ interface ProfileSkipsResult {
74
46
  readonly verifySignatures: boolean;
75
47
  readonly verifyDecrypt: boolean;
76
48
  }
49
+ /**
50
+ * Emit the minimum conformance profile a verifier MUST implement
51
+ * to read this record end-to-end. The profiles form a strict superset chain
52
+ * `core ⊂ signed ⊂ sealed ⊂ recipient-sealed`.
53
+ *
54
+ * The function classifies based on RECORD CONTENT only:
55
+ * - `'core'` — no signatures, no sealed items.
56
+ * - `'signed'` — `record.sigs[]` is present, no sealed items.
57
+ * - `'sealed'` — any `record.items[i].enc` is present (with or without sigs).
58
+ *
59
+ * The function does NOT return `'recipient-sealed'`: that profile is about
60
+ * VERIFIER CAPABILITY (whether the verifier decrypts with a recipient X25519
61
+ * key), not about record content. A separate helper is required if a caller
62
+ * needs to test whether a particular recipient key can unwrap any slot — see
63
+ * `@cardanowall/crypto-core/sealed-poe` for that pathway.
64
+ */
65
+ declare function detectConformanceProfile(record: PoeRecord): 'core' | 'signed' | 'sealed';
77
66
  declare function planProfileSkips(profile: Profile, record: PoeRecord): ProfileSkipsResult;
78
67
 
79
- interface ResolvedTx {
80
- readonly txCbor: Uint8Array;
81
- readonly numConfirmations: number;
82
- readonly blockTime: number;
83
- readonly blockSlot: number;
84
- readonly provider: 'koios' | 'blockfrost';
85
- readonly providerUrl: string;
86
- }
87
- declare const KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
88
- declare const BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
89
- declare class NotALabel309RecordError extends Error {
90
- readonly code: "METADATA_NOT_FOUND";
91
- constructor(message: string);
92
- }
93
- declare function resolveCardanoTx(args: {
94
- readonly input: VerifyTxInput;
95
- readonly fetchFn: FetchOutbound;
96
- }): Promise<ResolvedTx>;
97
- declare function extractLabel309Metadata(txCbor: Uint8Array): Uint8Array | null;
98
-
99
68
  /**
100
69
  * Byte-faithful components of a Cardano transaction, located by walking the
101
70
  * tx CBOR without a decode-then-re-encode pass.
102
71
  *
103
- * `txBody` and `witnessSet` are EXACT on-chain byte slices: `blake2b256(txBody)`
104
- * equals the transaction hash, and the witness set decodes to the vkey
105
- * witnesses that authorised the transaction. The slices are produced by the
106
- * same position-aware walk that finds label 309, so they never round-trip
107
- * through a CBOR re-encoder.
108
- *
109
- * `label309` is the reassembled label-309 value (chunked-bytes concatenated;
110
- * see `reassembleLabel309Value`), `null` when auxiliary_data is null/undefined
111
- * or label 309 is absent. `auxMetadataLabels` is the ascending-sorted list of
112
- * every integer key in the auxiliary metadata map (`[]` when aux is null).
72
+ * Every field is an EXACT on-chain byte slice: `blake2b256(txBody)` equals the
73
+ * transaction id, `blake2b256(auxiliaryData)` equals the body's
74
+ * `auxiliary_data_hash`, and the witness set decodes to the vkey witnesses
75
+ * that authorised the transaction. `auxiliaryData` is `null` when the
76
+ * transaction carries none (CBOR null/undefined at the auxiliary-data
77
+ * position).
113
78
  */
114
79
  interface TxComponents {
115
- readonly label309: Uint8Array | null;
116
80
  readonly txBody: Uint8Array;
117
81
  readonly witnessSet: Uint8Array;
118
- readonly auxMetadataLabels: number[];
82
+ readonly auxiliaryData: Uint8Array | null;
119
83
  }
120
84
  /**
121
85
  * Walk the transaction CBOR once and return its byte-faithful components.
122
- *
123
- * Throws `RangeError("MALFORMED_CBOR: …")` on structural violations. The body
124
- * and witness-set slices are the producer's ORIGINAL bytes; `label309` carries
125
- * the same byte-faithful guarantee `sliceLabel309Value` documents (no
126
- * decode-then-re-encode, so non-canonical encodings reach the structural
127
- * validator unchanged).
86
+ * Accepts the four-element post-Alonzo shape `[body, witness_set, is_valid,
87
+ * auxiliary_data]` and the three-element pre-Alonzo shape
88
+ * `[body, witness_set, auxiliary_data]`. Throws
89
+ * `RangeError("MALFORMED_CBOR: …")` on structural violations.
128
90
  */
129
91
  declare function sliceTxComponents(txCbor: Uint8Array): TxComponents;
130
92
  /**
131
- * Extract the byte slice corresponding to the value under metadata label 309.
132
- * Returns `null` when auxiliary_data is null/undefined or when label 309 is
133
- * absent. Throws `RangeError("MALFORMED_CBOR: …")` on structural violations.
93
+ * The unwrapped view of one auxiliary-data value: the raw label-309 value
94
+ * bytes (the transport chunk array exactly as carried; `null` when the
95
+ * metadata carries no label-309 entry) plus the ascending-sorted list of
96
+ * every metadata label present.
97
+ */
98
+ interface UnwrappedAuxiliaryData {
99
+ readonly label309: Uint8Array | null;
100
+ readonly metadataLabels: ReadonlyArray<number>;
101
+ }
102
+ /**
103
+ * Unwrap auxiliary-data bytes down to the label-309 value. All three
104
+ * Conway-era envelope forms are accepted, dispatching PURELY on the top-level
105
+ * CBOR type and tag:
106
+ *
107
+ * * tag 259 → keyed map; the metadata map sits under integer key 0;
108
+ * * untagged array → the two-element `[ transaction_metadata,
109
+ * auxiliary_scripts ]` form; the metadata map is
110
+ * element 0;
111
+ * * untagged map → ALWAYS the metadata map itself.
134
112
  *
135
- * Returns the producer's ORIGINAL on-chain bytesno decode-then-re-encode
136
- * pass. The structural validator MUST receive these bytes verbatim so
137
- * non-canonical encodings surface as `MALFORMED_CBOR` rather than being
138
- * silently laundered.
113
+ * Map keys are never inspected to guess the shape a metadata map is keyed
114
+ * by integer labels, so any key-sniffing heuristic would silently mis-parse
115
+ * legitimate metadata (e.g. a metadata map whose only label is 0). Any other
116
+ * top-level shape, and any tag other than 259, throws
117
+ * `RangeError("MALFORMED_CBOR: …")`.
118
+ *
119
+ * A tag-259 map with no key 0, and a metadata map with no entry under label
120
+ * 309, are well-formed auxiliary data that simply carry no PoE record —
121
+ * `label309` is `null` and the caller emits METADATA_NOT_FOUND.
139
122
  */
140
- declare function sliceLabel309Value(txCbor: Uint8Array): Uint8Array | null;
123
+ declare function unwrapAuxiliaryData(auxBytes: Uint8Array): UnwrappedAuxiliaryData;
124
+ /**
125
+ * Read the transaction body's `auxiliary_data_hash` (body-map key 7) as an
126
+ * exact byte slice; `null` when the body carries no key 7. Throws
127
+ * `RangeError("MALFORMED_CBOR: …")` when the body is not a CBOR map.
128
+ */
129
+ declare function auxiliaryDataHashFromTxBody(txBody: Uint8Array): Uint8Array | null;
130
+
131
+ declare const KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
132
+ declare const BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
133
+ interface ResolvedTx {
134
+ readonly txCbor: Uint8Array;
135
+ readonly components: TxComponents;
136
+ readonly confirmationDepth: number;
137
+ readonly blockTime: number;
138
+ readonly blockSlot: number;
139
+ readonly provider: 'koios' | 'blockfrost';
140
+ readonly providerUrl: string;
141
+ }
142
+ type ResolveFailureCode = 'TX_NOT_FOUND' | 'PROVIDER_UNAVAILABLE' | 'TX_INTEGRITY_MISMATCH';
143
+ type ResolveOutcome = {
144
+ readonly ok: true;
145
+ readonly resolved: ResolvedTx;
146
+ } | {
147
+ readonly ok: false;
148
+ readonly code: ResolveFailureCode;
149
+ readonly message: string;
150
+ };
151
+ declare function resolveCardanoTx(args: {
152
+ readonly txHash: string;
153
+ readonly cardanoGatewayChain?: ReadonlyArray<string> | undefined;
154
+ readonly blockfrostProjectId?: string | undefined;
155
+ readonly fetchFn: FetchOutbound;
156
+ }): Promise<ResolveOutcome>;
157
+
158
+ type TxBindingResult = {
159
+ readonly ok: true;
160
+ } | {
161
+ readonly ok: false;
162
+ readonly check: 'tx_hash' | 'auxiliary_data_hash';
163
+ readonly message: string;
164
+ };
165
+ declare function bindTransactionBytes(args: {
166
+ readonly requestedTxHashHex: string;
167
+ readonly txBody: Uint8Array;
168
+ readonly auxiliaryData: Uint8Array | null;
169
+ }): TxBindingResult;
141
170
 
142
171
  /**
143
172
  * Decode the vkey witnesses of a transaction and verify each signature against
@@ -161,16 +190,35 @@ declare function decodeTxWitnesses(witnessSetBytes: Uint8Array, txBodyBytes: Uin
161
190
  */
162
191
  declare function decodeTxSummary(txBodyBytes: Uint8Array, witnessSetBytes: Uint8Array, network: 'mainnet' | 'preprod'): VerifyTxSummary;
163
192
 
164
- interface FetchItemCiphertextArgs {
165
- readonly uris: ReadonlyArray<ReadonlyArray<string>>;
166
- readonly arweaveGateways?: ReadonlyArray<string> | undefined;
167
- readonly ipfsGateways?: ReadonlyArray<string> | undefined;
168
- readonly fetchFn: FetchOutbound;
169
- readonly uriChecksOut: VerifyUriCheck[];
170
- readonly itemIndex: number;
193
+ interface ParsedCid {
194
+ readonly version: 0 | 1;
195
+ readonly codec: number;
196
+ readonly multihashCode: number;
197
+ readonly digest: Uint8Array;
171
198
  }
172
- declare function fetchItemCiphertext(args: FetchItemCiphertextArgs): Promise<Uint8Array>;
199
+ /**
200
+ * Decode the authority component of an `ipfs://` URI into its CID fields.
201
+ * Returns `null` for anything outside the profile's multibase set or for
202
+ * undecodable input — callers treat that exactly like an unsupported binding.
203
+ */
204
+ declare function parseCid(cid: string): ParsedCid | null;
205
+ type CidBindingOutcome = 'verified' | 'failed' | 'unsupported';
206
+ /**
207
+ * The minimum binding check: for a raw-codec CIDv1 with no path component,
208
+ * recompute the multihash directly over the fetched bytes and compare it to
209
+ * the CID's digest. Everything else — CIDv0, DAG codecs, a path component
210
+ * (which navigates a DAG the raw recompute cannot reproduce), an
211
+ * out-of-profile multihash — is `unsupported`: the bytes stay unattributed
212
+ * and a mismatch indicts the provider, never the record.
213
+ */
214
+ declare function verifyIpfsCidBinding(args: {
215
+ readonly cid: string;
216
+ readonly path: string;
217
+ readonly bytes: Uint8Array;
218
+ }): CidBindingOutcome;
219
+
220
+ declare const ARWEAVE_GATEWAY_DEFAULTS: ReadonlyArray<string>;
173
221
 
174
222
  declare function verifyReportToDict(report: VerifyReport): Record<string, unknown>;
175
223
 
176
- export { BLOCKFROST_MAINNET_HOST, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, DEFAULT_PROFILE, ExitCode, FetchOutbound, HttpCallRecord, KOIOS_MAINNET_URL, NotALabel309RecordError, Profile, type ResolvedTx, type TxComponents, VerifyItemDecryption, VerifyMerkleCheck, VerifyRecordSignature, VerifyReport, VerifyTxInput, VerifyTxSummary, VerifyTxWitness, VerifyUriCheck, decodeTxSummary, decodeTxWitnesses, exitCodeForVerdict, extractLabel309Metadata, fetchItemCiphertext, planProfileSkips, profileImplements, resolveCardanoTx, sliceLabel309Value, sliceTxComponents, tryDecryptions, verifyMerkleCommitments, verifyRecordSignatures, verifyReportToDict, verifyResolved, verifyTx };
224
+ export { ARWEAVE_GATEWAY_DEFAULTS, BLOCKFROST_MAINNET_HOST, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, type CidBindingOutcome, DEFAULT_PROFILE, ExitCode, FetchOutbound, type IssuePath, IssueSink, KOIOS_MAINNET_URL, type ParsedCid, Profile, type ResolveFailureCode, type ResolveOutcome, type ResolvedTx, type TxBindingResult, type TxComponents, type UnwrappedAuxiliaryData, VerifyRecordSignature, VerifyReport, VerifyResolvedInput, VerifyTxInput, VerifyTxSummary, VerifyTxWitness, auxiliaryDataHashFromTxBody, bindTransactionBytes, compareIssuePaths, decodeTxSummary, decodeTxWitnesses, detectConformanceProfile, exitCodeForVerdict, issueOf, parseCid, planProfileSkips, profileImplements, resolveCardanoTx, sliceTxComponents, sortIssues, unwrapAuxiliaryData, verifyIpfsCidBinding, verifyRecordSignatures, verifyReportToDict, verifyResolved, verifyTx };
@@ -1,71 +1,43 @@
1
- import { g as VerifyReport, E as ExitCode, h as VerifyTxInput, a as Profile, f as VerifyRecordSignature, l as VerifyUriCheck, d as VerifyItemDecryption, e as VerifyMerkleCheck, j as VerifyTxSummary, k as VerifyTxWitness } from '../types-B8Q3gW54.js';
2
- export { D as DecryptionVerdict, I as ItemHashCheck, M as MerkleVerdict, N as Network, P as PROFILE_RANK, S as SignatureFailureReason, b as SignatureVerdict, c as SignerType, V as Verdict, i as VerifyTxOutput } from '../types-B8Q3gW54.js';
3
- import { F as FetchOutbound, H as HttpCallRecord } from '../fetch-outbound-BT5-NiYN.js';
4
- export { B as BodyTooLargeError, D as DEFAULT_OUTBOUND_MAX_BYTES, a as DENY_HOSTS_DEFAULT, b as DenyHostError, c as FetchOutboundOptions, d as FetchOutboundResult, O as OutboundExhaustedError, R as RetryConfig, U as UnsupportedMethodError, g as UnsupportedProtocolError, W as WrapFetchOutboundConfig, h as defaultFetchOutbound, i as fetchOutbound, w as wrapFetchOutbound } from '../fetch-outbound-BT5-NiYN.js';
5
- import { PoeRecord, ValidationIssue } from '@cardanowall/poe-standard';
1
+ import { g as VerifyReport, b as ExitCode, h as VerifyResolvedInput, i as VerifyTxInput, f as VerifyRecordSignature, c as Profile, k as VerifyTxSummary, l as VerifyTxWitness } from '../types-CgoBub9J.js';
2
+ export { C as ContentCheck, D as DecryptionCredential, a as DecryptionOutcome, E as EXIT_CODE_FOR_VERDICT, I as ItemReportEntry, M as MerkleReportEntry, P as PROFILE_RANK, S as SignatureFailureReason, d as SignatureVerdict, e as SignerType, V as Verdict, j as VerifyTxOutput } from '../types-CgoBub9J.js';
3
+ import { ValidationIssue, ErrorCode, Severity, PoeRecord } from '@cardanowall/poe-standard';
6
4
  export { ValidationIssue } from '@cardanowall/poe-standard';
5
+ import { F as FetchOutbound } from '../fetch-outbound-dOK3ZxYa.js';
6
+ export { B as BodyTooLargeError, D as DEFAULT_OUTBOUND_MAX_BYTES, a as DENY_HOSTS_DEFAULT, b as DenyHostError, c as FetchOutboundOptions, d as FetchOutboundResult, H as HttpCallRecord, O as OutboundExhaustedError, R as RetryConfig, U as UnsupportedMethodError, g as UnsupportedProtocolError, W as WrapFetchOutboundConfig, h as defaultFetchOutbound, i as fetchOutbound, j as isBodyTooLargeError, k as isDenyHostError, w as wrapFetchOutbound } from '../fetch-outbound-dOK3ZxYa.js';
7
7
 
8
8
  declare const CONFIRMATION_DEPTH_THRESHOLD_DEFAULT = 15;
9
9
  declare function verifyTx(input: VerifyTxInput): Promise<VerifyReport>;
10
10
  /**
11
- * `verifyResolved` same pipeline as `verifyTx` starting from step 3
12
- * (structural validator). The caller has already resolved the label-309
13
- * metadata bytes + block-info tuple from somewhere other than a live chain
14
- * fetch (typically an indexer database mirror).
15
- *
16
- * Use this when you trust an upstream indexer for the (metadataCbor,
17
- * blockTime, blockSlot, numConfirmations) tuple and want to skip the
18
- * /tx_cbor + /tx_info round-trip. The caller is responsible for the
19
- * confidence that the supplied bytes actually came from the label-309
20
- * metadata field of a confirmed Cardano transaction.
11
+ * Sibling entry point: run the pipeline from the structural-validator step
12
+ * onward over caller-supplied label-309 record-body bytes plus an
13
+ * explorer-asserted block-info tuple the path a server-rendered viewer uses
14
+ * to display on-chain data without a render-time chain fetch. The caller is
15
+ * responsible for the confidence that the bytes came from the label-309
16
+ * metadata of a real Cardano transaction.
21
17
  */
22
- declare function verifyResolved(input: {
23
- txHash: string;
24
- metadataCbor: Uint8Array;
25
- txCbor?: Uint8Array;
26
- numConfirmations: number;
27
- blockTime?: number;
28
- blockSlot?: number;
29
- network?: VerifyReport['network'];
30
- cardanoNetwork?: VerifyTxInput['cardanoNetwork'];
31
- profile?: Profile;
32
- confirmationDepthThreshold?: number;
33
- fetchOutbound?: FetchOutbound;
34
- denyHosts?: ReadonlyArray<string>;
35
- decryption?: VerifyTxInput['decryption'];
36
- verifyMerkle?: boolean;
37
- }): Promise<VerifyReport>;
18
+ declare function verifyResolved(input: VerifyResolvedInput): Promise<VerifyReport>;
38
19
  declare function exitCodeForVerdict(report: VerifyReport): ExitCode;
39
20
 
40
- interface VerifyRecordSignaturesArgs {
41
- readonly record: PoeRecord;
42
- readonly input: VerifyTxInput;
43
- }
44
- declare function verifyRecordSignatures(args: VerifyRecordSignaturesArgs): Promise<VerifyRecordSignature[]>;
45
-
46
- interface TryDecryptionsArgs {
47
- readonly record: PoeRecord;
48
- readonly input: VerifyTxInput;
49
- readonly fetchFn: FetchOutbound;
50
- readonly httpCalls: HttpCallRecord[];
51
- readonly uriChecksOut: VerifyUriCheck[];
52
- readonly allowUriFetch: boolean;
53
- }
54
- interface TryDecryptionsResult {
55
- readonly results: VerifyItemDecryption[];
21
+ type IssuePath = ReadonlyArray<string | number>;
22
+ declare function issueOf(code: ErrorCode, path: IssuePath, message: string, severity?: Severity): ValidationIssue;
23
+ declare function compareIssuePaths(a: IssuePath, b: IssuePath): number;
24
+ declare function sortIssues(issues: ReadonlyArray<ValidationIssue>): ValidationIssue[];
25
+ declare class IssueSink {
26
+ private readonly issues;
27
+ push(issue: ValidationIssue): void;
28
+ add(code: ErrorCode, path: IssuePath, message: string, severity?: Severity): void;
29
+ addOnce(code: ErrorCode, path: IssuePath, message: string, severity?: Severity): void;
30
+ pushAll(issues: ReadonlyArray<ValidationIssue>): void;
31
+ has(code: ErrorCode): boolean;
32
+ sorted(): ValidationIssue[];
56
33
  }
57
- declare function tryDecryptions(args: TryDecryptionsArgs): Promise<TryDecryptionsResult>;
58
34
 
59
- interface VerifyMerkleArgs {
35
+ interface VerifyRecordSignaturesArgs {
60
36
  readonly record: PoeRecord;
61
- readonly input: VerifyTxInput;
62
- readonly fetchFn: FetchOutbound;
63
- readonly uriChecksOut: VerifyUriCheck[];
37
+ readonly cardanoNetwork: 'mainnet' | 'preprod';
38
+ readonly issues: IssueSink;
64
39
  }
65
- interface VerifyMerkleResult {
66
- readonly checks: VerifyMerkleCheck[];
67
- }
68
- declare function verifyMerkleCommitments(args: VerifyMerkleArgs): Promise<VerifyMerkleResult>;
40
+ declare function verifyRecordSignatures(args: VerifyRecordSignaturesArgs): VerifyRecordSignature[];
69
41
 
70
42
  declare const DEFAULT_PROFILE: Profile;
71
43
  declare function profileImplements(actual: Profile, required: Profile): boolean;
@@ -74,70 +46,127 @@ interface ProfileSkipsResult {
74
46
  readonly verifySignatures: boolean;
75
47
  readonly verifyDecrypt: boolean;
76
48
  }
49
+ /**
50
+ * Emit the minimum conformance profile a verifier MUST implement
51
+ * to read this record end-to-end. The profiles form a strict superset chain
52
+ * `core ⊂ signed ⊂ sealed ⊂ recipient-sealed`.
53
+ *
54
+ * The function classifies based on RECORD CONTENT only:
55
+ * - `'core'` — no signatures, no sealed items.
56
+ * - `'signed'` — `record.sigs[]` is present, no sealed items.
57
+ * - `'sealed'` — any `record.items[i].enc` is present (with or without sigs).
58
+ *
59
+ * The function does NOT return `'recipient-sealed'`: that profile is about
60
+ * VERIFIER CAPABILITY (whether the verifier decrypts with a recipient X25519
61
+ * key), not about record content. A separate helper is required if a caller
62
+ * needs to test whether a particular recipient key can unwrap any slot — see
63
+ * `@cardanowall/crypto-core/sealed-poe` for that pathway.
64
+ */
65
+ declare function detectConformanceProfile(record: PoeRecord): 'core' | 'signed' | 'sealed';
77
66
  declare function planProfileSkips(profile: Profile, record: PoeRecord): ProfileSkipsResult;
78
67
 
79
- interface ResolvedTx {
80
- readonly txCbor: Uint8Array;
81
- readonly numConfirmations: number;
82
- readonly blockTime: number;
83
- readonly blockSlot: number;
84
- readonly provider: 'koios' | 'blockfrost';
85
- readonly providerUrl: string;
86
- }
87
- declare const KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
88
- declare const BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
89
- declare class NotALabel309RecordError extends Error {
90
- readonly code: "METADATA_NOT_FOUND";
91
- constructor(message: string);
92
- }
93
- declare function resolveCardanoTx(args: {
94
- readonly input: VerifyTxInput;
95
- readonly fetchFn: FetchOutbound;
96
- }): Promise<ResolvedTx>;
97
- declare function extractLabel309Metadata(txCbor: Uint8Array): Uint8Array | null;
98
-
99
68
  /**
100
69
  * Byte-faithful components of a Cardano transaction, located by walking the
101
70
  * tx CBOR without a decode-then-re-encode pass.
102
71
  *
103
- * `txBody` and `witnessSet` are EXACT on-chain byte slices: `blake2b256(txBody)`
104
- * equals the transaction hash, and the witness set decodes to the vkey
105
- * witnesses that authorised the transaction. The slices are produced by the
106
- * same position-aware walk that finds label 309, so they never round-trip
107
- * through a CBOR re-encoder.
108
- *
109
- * `label309` is the reassembled label-309 value (chunked-bytes concatenated;
110
- * see `reassembleLabel309Value`), `null` when auxiliary_data is null/undefined
111
- * or label 309 is absent. `auxMetadataLabels` is the ascending-sorted list of
112
- * every integer key in the auxiliary metadata map (`[]` when aux is null).
72
+ * Every field is an EXACT on-chain byte slice: `blake2b256(txBody)` equals the
73
+ * transaction id, `blake2b256(auxiliaryData)` equals the body's
74
+ * `auxiliary_data_hash`, and the witness set decodes to the vkey witnesses
75
+ * that authorised the transaction. `auxiliaryData` is `null` when the
76
+ * transaction carries none (CBOR null/undefined at the auxiliary-data
77
+ * position).
113
78
  */
114
79
  interface TxComponents {
115
- readonly label309: Uint8Array | null;
116
80
  readonly txBody: Uint8Array;
117
81
  readonly witnessSet: Uint8Array;
118
- readonly auxMetadataLabels: number[];
82
+ readonly auxiliaryData: Uint8Array | null;
119
83
  }
120
84
  /**
121
85
  * Walk the transaction CBOR once and return its byte-faithful components.
122
- *
123
- * Throws `RangeError("MALFORMED_CBOR: …")` on structural violations. The body
124
- * and witness-set slices are the producer's ORIGINAL bytes; `label309` carries
125
- * the same byte-faithful guarantee `sliceLabel309Value` documents (no
126
- * decode-then-re-encode, so non-canonical encodings reach the structural
127
- * validator unchanged).
86
+ * Accepts the four-element post-Alonzo shape `[body, witness_set, is_valid,
87
+ * auxiliary_data]` and the three-element pre-Alonzo shape
88
+ * `[body, witness_set, auxiliary_data]`. Throws
89
+ * `RangeError("MALFORMED_CBOR: …")` on structural violations.
128
90
  */
129
91
  declare function sliceTxComponents(txCbor: Uint8Array): TxComponents;
130
92
  /**
131
- * Extract the byte slice corresponding to the value under metadata label 309.
132
- * Returns `null` when auxiliary_data is null/undefined or when label 309 is
133
- * absent. Throws `RangeError("MALFORMED_CBOR: …")` on structural violations.
93
+ * The unwrapped view of one auxiliary-data value: the raw label-309 value
94
+ * bytes (the transport chunk array exactly as carried; `null` when the
95
+ * metadata carries no label-309 entry) plus the ascending-sorted list of
96
+ * every metadata label present.
97
+ */
98
+ interface UnwrappedAuxiliaryData {
99
+ readonly label309: Uint8Array | null;
100
+ readonly metadataLabels: ReadonlyArray<number>;
101
+ }
102
+ /**
103
+ * Unwrap auxiliary-data bytes down to the label-309 value. All three
104
+ * Conway-era envelope forms are accepted, dispatching PURELY on the top-level
105
+ * CBOR type and tag:
106
+ *
107
+ * * tag 259 → keyed map; the metadata map sits under integer key 0;
108
+ * * untagged array → the two-element `[ transaction_metadata,
109
+ * auxiliary_scripts ]` form; the metadata map is
110
+ * element 0;
111
+ * * untagged map → ALWAYS the metadata map itself.
134
112
  *
135
- * Returns the producer's ORIGINAL on-chain bytesno decode-then-re-encode
136
- * pass. The structural validator MUST receive these bytes verbatim so
137
- * non-canonical encodings surface as `MALFORMED_CBOR` rather than being
138
- * silently laundered.
113
+ * Map keys are never inspected to guess the shape a metadata map is keyed
114
+ * by integer labels, so any key-sniffing heuristic would silently mis-parse
115
+ * legitimate metadata (e.g. a metadata map whose only label is 0). Any other
116
+ * top-level shape, and any tag other than 259, throws
117
+ * `RangeError("MALFORMED_CBOR: …")`.
118
+ *
119
+ * A tag-259 map with no key 0, and a metadata map with no entry under label
120
+ * 309, are well-formed auxiliary data that simply carry no PoE record —
121
+ * `label309` is `null` and the caller emits METADATA_NOT_FOUND.
139
122
  */
140
- declare function sliceLabel309Value(txCbor: Uint8Array): Uint8Array | null;
123
+ declare function unwrapAuxiliaryData(auxBytes: Uint8Array): UnwrappedAuxiliaryData;
124
+ /**
125
+ * Read the transaction body's `auxiliary_data_hash` (body-map key 7) as an
126
+ * exact byte slice; `null` when the body carries no key 7. Throws
127
+ * `RangeError("MALFORMED_CBOR: …")` when the body is not a CBOR map.
128
+ */
129
+ declare function auxiliaryDataHashFromTxBody(txBody: Uint8Array): Uint8Array | null;
130
+
131
+ declare const KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
132
+ declare const BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
133
+ interface ResolvedTx {
134
+ readonly txCbor: Uint8Array;
135
+ readonly components: TxComponents;
136
+ readonly confirmationDepth: number;
137
+ readonly blockTime: number;
138
+ readonly blockSlot: number;
139
+ readonly provider: 'koios' | 'blockfrost';
140
+ readonly providerUrl: string;
141
+ }
142
+ type ResolveFailureCode = 'TX_NOT_FOUND' | 'PROVIDER_UNAVAILABLE' | 'TX_INTEGRITY_MISMATCH';
143
+ type ResolveOutcome = {
144
+ readonly ok: true;
145
+ readonly resolved: ResolvedTx;
146
+ } | {
147
+ readonly ok: false;
148
+ readonly code: ResolveFailureCode;
149
+ readonly message: string;
150
+ };
151
+ declare function resolveCardanoTx(args: {
152
+ readonly txHash: string;
153
+ readonly cardanoGatewayChain?: ReadonlyArray<string> | undefined;
154
+ readonly blockfrostProjectId?: string | undefined;
155
+ readonly fetchFn: FetchOutbound;
156
+ }): Promise<ResolveOutcome>;
157
+
158
+ type TxBindingResult = {
159
+ readonly ok: true;
160
+ } | {
161
+ readonly ok: false;
162
+ readonly check: 'tx_hash' | 'auxiliary_data_hash';
163
+ readonly message: string;
164
+ };
165
+ declare function bindTransactionBytes(args: {
166
+ readonly requestedTxHashHex: string;
167
+ readonly txBody: Uint8Array;
168
+ readonly auxiliaryData: Uint8Array | null;
169
+ }): TxBindingResult;
141
170
 
142
171
  /**
143
172
  * Decode the vkey witnesses of a transaction and verify each signature against
@@ -161,16 +190,35 @@ declare function decodeTxWitnesses(witnessSetBytes: Uint8Array, txBodyBytes: Uin
161
190
  */
162
191
  declare function decodeTxSummary(txBodyBytes: Uint8Array, witnessSetBytes: Uint8Array, network: 'mainnet' | 'preprod'): VerifyTxSummary;
163
192
 
164
- interface FetchItemCiphertextArgs {
165
- readonly uris: ReadonlyArray<ReadonlyArray<string>>;
166
- readonly arweaveGateways?: ReadonlyArray<string> | undefined;
167
- readonly ipfsGateways?: ReadonlyArray<string> | undefined;
168
- readonly fetchFn: FetchOutbound;
169
- readonly uriChecksOut: VerifyUriCheck[];
170
- readonly itemIndex: number;
193
+ interface ParsedCid {
194
+ readonly version: 0 | 1;
195
+ readonly codec: number;
196
+ readonly multihashCode: number;
197
+ readonly digest: Uint8Array;
171
198
  }
172
- declare function fetchItemCiphertext(args: FetchItemCiphertextArgs): Promise<Uint8Array>;
199
+ /**
200
+ * Decode the authority component of an `ipfs://` URI into its CID fields.
201
+ * Returns `null` for anything outside the profile's multibase set or for
202
+ * undecodable input — callers treat that exactly like an unsupported binding.
203
+ */
204
+ declare function parseCid(cid: string): ParsedCid | null;
205
+ type CidBindingOutcome = 'verified' | 'failed' | 'unsupported';
206
+ /**
207
+ * The minimum binding check: for a raw-codec CIDv1 with no path component,
208
+ * recompute the multihash directly over the fetched bytes and compare it to
209
+ * the CID's digest. Everything else — CIDv0, DAG codecs, a path component
210
+ * (which navigates a DAG the raw recompute cannot reproduce), an
211
+ * out-of-profile multihash — is `unsupported`: the bytes stay unattributed
212
+ * and a mismatch indicts the provider, never the record.
213
+ */
214
+ declare function verifyIpfsCidBinding(args: {
215
+ readonly cid: string;
216
+ readonly path: string;
217
+ readonly bytes: Uint8Array;
218
+ }): CidBindingOutcome;
219
+
220
+ declare const ARWEAVE_GATEWAY_DEFAULTS: ReadonlyArray<string>;
173
221
 
174
222
  declare function verifyReportToDict(report: VerifyReport): Record<string, unknown>;
175
223
 
176
- export { BLOCKFROST_MAINNET_HOST, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, DEFAULT_PROFILE, ExitCode, FetchOutbound, HttpCallRecord, KOIOS_MAINNET_URL, NotALabel309RecordError, Profile, type ResolvedTx, type TxComponents, VerifyItemDecryption, VerifyMerkleCheck, VerifyRecordSignature, VerifyReport, VerifyTxInput, VerifyTxSummary, VerifyTxWitness, VerifyUriCheck, decodeTxSummary, decodeTxWitnesses, exitCodeForVerdict, extractLabel309Metadata, fetchItemCiphertext, planProfileSkips, profileImplements, resolveCardanoTx, sliceLabel309Value, sliceTxComponents, tryDecryptions, verifyMerkleCommitments, verifyRecordSignatures, verifyReportToDict, verifyResolved, verifyTx };
224
+ export { ARWEAVE_GATEWAY_DEFAULTS, BLOCKFROST_MAINNET_HOST, CONFIRMATION_DEPTH_THRESHOLD_DEFAULT, type CidBindingOutcome, DEFAULT_PROFILE, ExitCode, FetchOutbound, type IssuePath, IssueSink, KOIOS_MAINNET_URL, type ParsedCid, Profile, type ResolveFailureCode, type ResolveOutcome, type ResolvedTx, type TxBindingResult, type TxComponents, type UnwrappedAuxiliaryData, VerifyRecordSignature, VerifyReport, VerifyResolvedInput, VerifyTxInput, VerifyTxSummary, VerifyTxWitness, auxiliaryDataHashFromTxBody, bindTransactionBytes, compareIssuePaths, decodeTxSummary, decodeTxWitnesses, detectConformanceProfile, exitCodeForVerdict, issueOf, parseCid, planProfileSkips, profileImplements, resolveCardanoTx, sliceTxComponents, sortIssues, unwrapAuxiliaryData, verifyIpfsCidBinding, verifyRecordSignatures, verifyReportToDict, verifyResolved, verifyTx };