@cardanowall/sdk-ts 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.cjs +2566 -1706
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +42 -5
- package/dist/client/index.d.ts +42 -5
- package/dist/client/index.js +2564 -1708
- package/dist/client/index.js.map +1 -1
- package/dist/conformance/cli.cjs +5978 -3438
- package/dist/conformance/cli.cjs.map +1 -1
- package/dist/conformance/cli.js +5978 -3438
- package/dist/conformance/cli.js.map +1 -1
- package/dist/fetch/index.cjs +33 -14
- package/dist/fetch/index.cjs.map +1 -1
- package/dist/fetch/index.d.cts +2 -2
- package/dist/fetch/index.d.ts +2 -2
- package/dist/fetch/index.js +32 -15
- package/dist/fetch/index.js.map +1 -1
- package/dist/{fetch-outbound-BT5-NiYN.d.cts → fetch-outbound-dOK3ZxYa.d.cts} +7 -3
- package/dist/{fetch-outbound-BT5-NiYN.d.ts → fetch-outbound-dOK3ZxYa.d.ts} +7 -3
- package/dist/hash/index.cjs +1 -1
- package/dist/hash/index.cjs.map +1 -1
- package/dist/hash/index.js +1 -1
- package/dist/hash/index.js.map +1 -1
- package/dist/identity/index.cjs +460 -219
- package/dist/identity/index.cjs.map +1 -1
- package/dist/identity/index.d.cts +3 -2
- package/dist/identity/index.d.ts +3 -2
- package/dist/identity/index.js +460 -219
- package/dist/identity/index.js.map +1 -1
- package/dist/index.cjs +6912 -3678
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +6890 -3672
- package/dist/index.js.map +1 -1
- package/dist/merkle/index.cjs +1 -1
- package/dist/merkle/index.js +1 -1
- package/dist/types-Cexm4VH9.d.cts +119 -0
- package/dist/types-CgoBub9J.d.ts +119 -0
- package/dist/{types-DGsZTMuZ.d.cts → types-Dp4wUSFI.d.cts} +220 -1
- package/dist/{types-DGsZTMuZ.d.ts → types-Dp4wUSFI.d.ts} +220 -1
- package/dist/verifier/index.cjs +5738 -3205
- package/dist/verifier/index.cjs.map +1 -1
- package/dist/verifier/index.d.cts +159 -111
- package/dist/verifier/index.d.ts +159 -111
- package/dist/verifier/index.js +5726 -3201
- package/dist/verifier/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/types-B8Q3gW54.d.ts +0 -123
- package/dist/types-CLXdbjqr.d.cts +0 -123
|
@@ -1,71 +1,43 @@
|
|
|
1
|
-
import { g as VerifyReport,
|
|
2
|
-
export { D as
|
|
3
|
-
import {
|
|
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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
declare
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
35
|
+
interface VerifyRecordSignaturesArgs {
|
|
60
36
|
readonly record: PoeRecord;
|
|
61
|
-
readonly
|
|
62
|
-
readonly
|
|
63
|
-
readonly uriChecksOut: VerifyUriCheck[];
|
|
37
|
+
readonly cardanoNetwork: 'mainnet' | 'preprod';
|
|
38
|
+
readonly issues: IssueSink;
|
|
64
39
|
}
|
|
65
|
-
|
|
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
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
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
|
|
82
|
+
readonly auxiliaryData: Uint8Array | null;
|
|
119
83
|
}
|
|
120
84
|
/**
|
|
121
85
|
* Walk the transaction CBOR once and return its byte-faithful components.
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
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
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
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
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
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
|
|
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
|
|
165
|
-
readonly
|
|
166
|
-
readonly
|
|
167
|
-
readonly
|
|
168
|
-
readonly
|
|
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
|
-
|
|
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,
|
|
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 };
|
package/dist/verifier/index.d.ts
CHANGED
|
@@ -1,71 +1,43 @@
|
|
|
1
|
-
import { g as VerifyReport,
|
|
2
|
-
export { D as
|
|
3
|
-
import {
|
|
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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
declare
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
35
|
+
interface VerifyRecordSignaturesArgs {
|
|
60
36
|
readonly record: PoeRecord;
|
|
61
|
-
readonly
|
|
62
|
-
readonly
|
|
63
|
-
readonly uriChecksOut: VerifyUriCheck[];
|
|
37
|
+
readonly cardanoNetwork: 'mainnet' | 'preprod';
|
|
38
|
+
readonly issues: IssueSink;
|
|
64
39
|
}
|
|
65
|
-
|
|
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
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
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
|
|
82
|
+
readonly auxiliaryData: Uint8Array | null;
|
|
119
83
|
}
|
|
120
84
|
/**
|
|
121
85
|
* Walk the transaction CBOR once and return its byte-faithful components.
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
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
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
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
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
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
|
|
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
|
|
165
|
-
readonly
|
|
166
|
-
readonly
|
|
167
|
-
readonly
|
|
168
|
-
readonly
|
|
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
|
-
|
|
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,
|
|
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 };
|