@atep/core 0.0.1 → 0.1.0-alpha.3
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 +257 -3
- package/THIRD-PARTY-NOTICES.md +557 -0
- package/dist/index.d.ts +455 -0
- package/dist/index.js +374 -0
- package/dist/wasm/atep_wasm.d.ts +312 -0
- package/dist/wasm/atep_wasm.js +1491 -0
- package/dist/wasm/atep_wasm_bg.wasm +0 -0
- package/dist/wasm/atep_wasm_bg.wasm.d.ts +49 -0
- package/package.json +57 -6
- /package/{LICENSE-APACHE → LICENSE} +0 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/** Bytes as hex text (lowercase) or a Uint8Array. */
|
|
2
|
+
export type HexOrBytes = string | Uint8Array;
|
|
3
|
+
/** A rejection: the verifier refused at `step` (spec section 10) with `error`. */
|
|
4
|
+
export interface Rejected {
|
|
5
|
+
ok: false;
|
|
6
|
+
step: number;
|
|
7
|
+
error: string;
|
|
8
|
+
cause?: {
|
|
9
|
+
step: number;
|
|
10
|
+
error: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface CheckpointInfo {
|
|
14
|
+
log: string;
|
|
15
|
+
tree_size: number;
|
|
16
|
+
root_hash: string;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ChainLink {
|
|
20
|
+
id: string;
|
|
21
|
+
claim: string;
|
|
22
|
+
subject: string;
|
|
23
|
+
issuer: string;
|
|
24
|
+
issued_at: number;
|
|
25
|
+
expires_at: number;
|
|
26
|
+
}
|
|
27
|
+
export interface VerifiedClaim {
|
|
28
|
+
claim: string;
|
|
29
|
+
issuer: string;
|
|
30
|
+
root: string;
|
|
31
|
+
expires_at: number;
|
|
32
|
+
chain: ChainLink[];
|
|
33
|
+
}
|
|
34
|
+
export interface Accepted {
|
|
35
|
+
ok: true;
|
|
36
|
+
signer: string;
|
|
37
|
+
content_type: string;
|
|
38
|
+
issued_at: number;
|
|
39
|
+
expires_at: number | null;
|
|
40
|
+
nonce_hex: string;
|
|
41
|
+
encrypted: boolean;
|
|
42
|
+
claims: VerifiedClaim[];
|
|
43
|
+
checkpoint: CheckpointInfo | null;
|
|
44
|
+
command_class?: string;
|
|
45
|
+
warnings?: string[];
|
|
46
|
+
payload_hex: string;
|
|
47
|
+
}
|
|
48
|
+
export type VerifyResult = Accepted | Rejected;
|
|
49
|
+
/** Trust policy (step 9), the policy file format of the Rust CLI. */
|
|
50
|
+
export interface TrustPolicy {
|
|
51
|
+
roots?: string[];
|
|
52
|
+
trusted_logs?: string[];
|
|
53
|
+
max_depth?: number;
|
|
54
|
+
/** Draft 04: when a rule fails with claim_missing, accept a one-hop `successor` attestation. Default false. */
|
|
55
|
+
follow_succession?: boolean;
|
|
56
|
+
require_inclusion?: boolean;
|
|
57
|
+
atep_r?: boolean;
|
|
58
|
+
srl?: {
|
|
59
|
+
on_stale?: "fail-closed" | "fail-open";
|
|
60
|
+
on_missing?: "fail-closed" | "fail-open";
|
|
61
|
+
};
|
|
62
|
+
rules?: {
|
|
63
|
+
claim: string;
|
|
64
|
+
root?: string;
|
|
65
|
+
max_age_days?: number;
|
|
66
|
+
}[];
|
|
67
|
+
}
|
|
68
|
+
export interface SeedsHex {
|
|
69
|
+
ed25519: string;
|
|
70
|
+
mldsa65: string;
|
|
71
|
+
x25519?: string;
|
|
72
|
+
mlkem768?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Verifier inputs besides the envelope and the clock. Same shape as the
|
|
76
|
+
* `policy` object in the test vectors. Byte fields accept hex or Uint8Array.
|
|
77
|
+
*/
|
|
78
|
+
export interface VerifyPolicy {
|
|
79
|
+
max_skew_secs?: number;
|
|
80
|
+
known_bundles?: HexOrBytes[];
|
|
81
|
+
seen_nonces?: HexOrBytes[];
|
|
82
|
+
revocations?: {
|
|
83
|
+
id: string;
|
|
84
|
+
reason: "retired" | "compromised";
|
|
85
|
+
revoked_at: number;
|
|
86
|
+
}[];
|
|
87
|
+
detached_payload_hex?: HexOrBytes;
|
|
88
|
+
trust?: TrustPolicy;
|
|
89
|
+
attestations?: HexOrBytes[];
|
|
90
|
+
srls?: HexOrBytes[];
|
|
91
|
+
/** Recipient seeds as JSON. Prefer passing `recipient` (an Identity) in the options. */
|
|
92
|
+
recipient_seeds?: SeedsHex;
|
|
93
|
+
}
|
|
94
|
+
export interface VerifyOptions {
|
|
95
|
+
/** Verification time, Unix seconds. Default: the current time. */
|
|
96
|
+
now?: number;
|
|
97
|
+
/** Identity that opens tag 96 envelopes. */
|
|
98
|
+
recipient?: Identity;
|
|
99
|
+
}
|
|
100
|
+
export interface SignOptions {
|
|
101
|
+
/** Default `application/atep+cbor`. */
|
|
102
|
+
contentType?: string;
|
|
103
|
+
/** Unix seconds. Default: now. */
|
|
104
|
+
issuedAt?: number;
|
|
105
|
+
expiresAt?: number | null;
|
|
106
|
+
/** Payload travels out of band (nil in the envelope). */
|
|
107
|
+
detached?: boolean;
|
|
108
|
+
/** Embed the signer's public bundle. Default true. */
|
|
109
|
+
includeBundle?: boolean;
|
|
110
|
+
/** 16 bytes. Default: random. */
|
|
111
|
+
nonce?: Uint8Array;
|
|
112
|
+
/** FIPS 204 deterministic ML-DSA (reproducible, used for test vectors). Default: hedged. */
|
|
113
|
+
deterministic?: boolean;
|
|
114
|
+
/** ATEP-R command class. */
|
|
115
|
+
commandClass?: string;
|
|
116
|
+
}
|
|
117
|
+
export interface AttestationOptions {
|
|
118
|
+
/** Agent ID of the subject. */
|
|
119
|
+
subject: string;
|
|
120
|
+
/** Claim type, a full URI or a short name such as `operator-of`. */
|
|
121
|
+
claim: string;
|
|
122
|
+
issuedAt: number;
|
|
123
|
+
expiresAt: number;
|
|
124
|
+
/** Claim data as a JSON object; `{"$hex": "..."}` becomes a byte string. */
|
|
125
|
+
data?: unknown;
|
|
126
|
+
/** Claim data already CBOR encoded. */
|
|
127
|
+
dataCbor?: Uint8Array;
|
|
128
|
+
evidence?: Uint8Array;
|
|
129
|
+
evidenceUri?: string;
|
|
130
|
+
/** 16 byte attestation id. Default: random. */
|
|
131
|
+
id?: Uint8Array;
|
|
132
|
+
nonce?: Uint8Array;
|
|
133
|
+
deterministic?: boolean;
|
|
134
|
+
includeBundle?: boolean;
|
|
135
|
+
allowLongDefault?: boolean;
|
|
136
|
+
}
|
|
137
|
+
export interface CheckpointOptions {
|
|
138
|
+
treeSize: number;
|
|
139
|
+
/** 32 byte root hash. */
|
|
140
|
+
rootHash: Uint8Array;
|
|
141
|
+
timestamp: number;
|
|
142
|
+
nonce?: Uint8Array;
|
|
143
|
+
deterministic?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface SrlResult {
|
|
146
|
+
ok: true;
|
|
147
|
+
issuer: string;
|
|
148
|
+
sequence: number;
|
|
149
|
+
issued_at: number;
|
|
150
|
+
next_update: number;
|
|
151
|
+
stale: boolean;
|
|
152
|
+
revoked: ({
|
|
153
|
+
kind: "attestation";
|
|
154
|
+
id_hex: string;
|
|
155
|
+
reason: string;
|
|
156
|
+
revoked_at: number;
|
|
157
|
+
} | {
|
|
158
|
+
kind: "identity";
|
|
159
|
+
id: string;
|
|
160
|
+
reason: string;
|
|
161
|
+
revoked_at: number;
|
|
162
|
+
})[];
|
|
163
|
+
warnings?: string[];
|
|
164
|
+
}
|
|
165
|
+
export type CheckpointResult = {
|
|
166
|
+
ok: true;
|
|
167
|
+
checkpoint: CheckpointInfo;
|
|
168
|
+
} | Rejected;
|
|
169
|
+
export type OldNewResult = {
|
|
170
|
+
ok: true;
|
|
171
|
+
old: CheckpointInfo;
|
|
172
|
+
new: CheckpointInfo;
|
|
173
|
+
} | Rejected;
|
|
174
|
+
export type PairResult = {
|
|
175
|
+
ok: true;
|
|
176
|
+
a: CheckpointInfo;
|
|
177
|
+
b: CheckpointInfo;
|
|
178
|
+
} | Rejected;
|
|
179
|
+
export type WasmSource = Uint8Array | ArrayBuffer | WebAssembly.Module | URL | string | Response | Promise<Response>;
|
|
180
|
+
/**
|
|
181
|
+
* Load the wasm module. Without an argument the binary is found next to this
|
|
182
|
+
* file: read from disk for `file:` URLs (Node, Bun, Deno), fetched otherwise
|
|
183
|
+
* (browsers, bundlers that rewrite `import.meta.url`). Pass bytes, a URL or a
|
|
184
|
+
* `Response` to override. Safe to call more than once.
|
|
185
|
+
*/
|
|
186
|
+
export declare function init(source?: WasmSource): Promise<void>;
|
|
187
|
+
/** Synchronous initialisation from wasm bytes or a compiled module. */
|
|
188
|
+
export declare function initSync(source: Uint8Array | ArrayBuffer | WebAssembly.Module): void;
|
|
189
|
+
export declare function hexToBytes(hex: string): Uint8Array;
|
|
190
|
+
export declare function bytesToHex(b: Uint8Array): string;
|
|
191
|
+
export interface SeedBytes {
|
|
192
|
+
ed25519: Uint8Array;
|
|
193
|
+
mldsa65: Uint8Array;
|
|
194
|
+
x25519?: Uint8Array;
|
|
195
|
+
mlkem768?: Uint8Array;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* An agent identity. Its secret seeds live in wasm linear memory and are
|
|
199
|
+
* zeroized when the object is freed. Call `free()` (or use `using`) when done.
|
|
200
|
+
*/
|
|
201
|
+
export declare class Identity {
|
|
202
|
+
#private;
|
|
203
|
+
private constructor();
|
|
204
|
+
/** Generate a new identity. `encryption` adds X25519 and ML-KEM-768 keys (needed to receive encrypted envelopes). */
|
|
205
|
+
static generate(encryption?: boolean): Identity;
|
|
206
|
+
/** From raw seeds (the same values the test vectors list). */
|
|
207
|
+
static fromSeeds(seeds: SeedBytes): Identity;
|
|
208
|
+
/** From seeds given as hex (the format of the vector `inputs`). */
|
|
209
|
+
static fromSeedsHex(s: SeedsHex): Identity;
|
|
210
|
+
/** From the CBOR secret key file written by `exportSecret` or the Rust CLI. */
|
|
211
|
+
static fromSecret(secret: Uint8Array): Identity;
|
|
212
|
+
/** The secret key file. The returned array holds secrets: `fill(0)` it when done. */
|
|
213
|
+
exportSecret(): Uint8Array;
|
|
214
|
+
/** Agent ID, `atep:...`. */
|
|
215
|
+
get agentId(): string;
|
|
216
|
+
get agentIdBytes(): Uint8Array;
|
|
217
|
+
get did(): string;
|
|
218
|
+
get publicBundle(): Uint8Array;
|
|
219
|
+
get hasEncryption(): boolean;
|
|
220
|
+
/** Sign a payload into a tag 98 envelope (Ed25519 plus ML-DSA-65). */
|
|
221
|
+
sign(payload: Uint8Array, options?: SignOptions): Uint8Array;
|
|
222
|
+
/** Open a tag 96 envelope addressed to this identity. Returns the inner signed envelope, unverified. */
|
|
223
|
+
decrypt(data: Uint8Array): Uint8Array;
|
|
224
|
+
/** Issue an attestation (spec section 7) about `options.subject`. */
|
|
225
|
+
issueAttestation(o: AttestationOptions): Uint8Array;
|
|
226
|
+
/** Create a signed revocation list with this identity as issuer (spec section 8). */
|
|
227
|
+
createSrl(o: {
|
|
228
|
+
sequence: number;
|
|
229
|
+
issuedAt: number;
|
|
230
|
+
nextUpdate: number;
|
|
231
|
+
revoked: Array<({
|
|
232
|
+
attestationId: Uint8Array;
|
|
233
|
+
} | {
|
|
234
|
+
identity: string;
|
|
235
|
+
}) & {
|
|
236
|
+
reason: string;
|
|
237
|
+
revokedAt: number;
|
|
238
|
+
}>;
|
|
239
|
+
nonce?: Uint8Array;
|
|
240
|
+
deterministic?: boolean;
|
|
241
|
+
includeBundle?: boolean;
|
|
242
|
+
}): Uint8Array;
|
|
243
|
+
/** Sign a log checkpoint with this identity as the log. */
|
|
244
|
+
createCheckpoint(o: CheckpointOptions): Uint8Array;
|
|
245
|
+
/** Verify with this identity as the recipient (opens tag 96 envelopes). */
|
|
246
|
+
verify(data: Uint8Array, policy?: VerifyPolicy, now?: number): VerifyResult;
|
|
247
|
+
/** Zeroize and release the secret seeds. */
|
|
248
|
+
free(): void;
|
|
249
|
+
[Symbol.dispose](): void;
|
|
250
|
+
}
|
|
251
|
+
/** Generate an identity (alias of `Identity.generate`). */
|
|
252
|
+
export declare function keygen(encryption?: boolean): Identity;
|
|
253
|
+
/** Agent ID of a public bundle (or of an Identity). */
|
|
254
|
+
export declare function agentId(bundleOrIdentity: Uint8Array | Identity): string;
|
|
255
|
+
/** Parse an Agent ID in `atep:` or `did:atep:` form. */
|
|
256
|
+
export declare function parseAgentId(s: string): {
|
|
257
|
+
text: string;
|
|
258
|
+
did: string;
|
|
259
|
+
hex: string;
|
|
260
|
+
};
|
|
261
|
+
export declare function sign(identity: Identity, payload: Uint8Array, options?: SignOptions): Uint8Array;
|
|
262
|
+
/** Encrypt a signed envelope to a recipient's public bundle (hybrid X25519 + ML-KEM-768, AES-256-GCM). */
|
|
263
|
+
export declare function encrypt(signedEnvelope: Uint8Array, recipientBundle: Uint8Array): Uint8Array;
|
|
264
|
+
/** Encrypt with explicit randomness. Only for reproducing test vectors. */
|
|
265
|
+
export declare function encryptDeterministic(signedEnvelope: Uint8Array, recipientBundle: Uint8Array, rnd: {
|
|
266
|
+
x25519Ephemeral: Uint8Array;
|
|
267
|
+
mlkemM: Uint8Array;
|
|
268
|
+
iv: Uint8Array;
|
|
269
|
+
}): Uint8Array;
|
|
270
|
+
export declare function decrypt(identity: Identity, data: Uint8Array): Uint8Array;
|
|
271
|
+
/**
|
|
272
|
+
* Verify an envelope, spec section 10 steps 1 to 10. A rejection is returned
|
|
273
|
+
* as `{ok: false, step, error}`, not thrown. Malformed arguments throw.
|
|
274
|
+
*/
|
|
275
|
+
export declare function verify(data: Uint8Array, policy?: VerifyPolicy, options?: VerifyOptions): VerifyResult;
|
|
276
|
+
/** JSON debug rendering of any ATEP CBOR object (envelope, bundle, ...). Not canonical. */
|
|
277
|
+
export declare function view(data: Uint8Array): unknown;
|
|
278
|
+
export declare function sha256(data: Uint8Array): Uint8Array;
|
|
279
|
+
/** Put inline attestations into the (unsigned) unprotected header of an envelope. */
|
|
280
|
+
export declare function withAttestations(envelope: Uint8Array, attestations: Uint8Array[]): Uint8Array;
|
|
281
|
+
/** Attach a log inclusion proof to an attestation. */
|
|
282
|
+
export declare function withInclusionProof(attestation: Uint8Array, proof: {
|
|
283
|
+
leafIndex: number;
|
|
284
|
+
auditPath: Uint8Array[];
|
|
285
|
+
checkpoint: Uint8Array;
|
|
286
|
+
}): Uint8Array;
|
|
287
|
+
/** The attestation as submitted to a log: its inclusion proof header removed. This is the Merkle leaf. */
|
|
288
|
+
export declare function submittedFormOf(attestation: Uint8Array): Uint8Array;
|
|
289
|
+
/** RFC 9162 Merkle root over leaves. */
|
|
290
|
+
export declare function merkleRoot(leaves: Uint8Array[]): Uint8Array;
|
|
291
|
+
/** RFC 9162 audit path of leaf `index`. */
|
|
292
|
+
export declare function auditPath(index: number, leaves: Uint8Array[]): Uint8Array[];
|
|
293
|
+
/** Verify a checkpoint envelope: steps 1 to 8, content type, trusted log, schema. */
|
|
294
|
+
export declare function verifyCheckpoint(cbor: Uint8Array, trustedLogs: string[], now?: number): CheckpointResult;
|
|
295
|
+
/** Verify the inclusion proof an attestation carries (offline, against trusted logs). */
|
|
296
|
+
export declare function verifyInclusion(attestation: Uint8Array, trustedLogs: string[], now?: number): CheckpointResult;
|
|
297
|
+
/** Check a consistency proof document `{old, new, proof}` (CBOR). */
|
|
298
|
+
export declare function checkConsistency(cbor: Uint8Array, trustedLogs: string[], now?: number): OldNewResult;
|
|
299
|
+
/** Check a split view document `{a, b, proof?}` (CBOR). */
|
|
300
|
+
export declare function checkSplitView(cbor: Uint8Array, trustedLogs: string[], now?: number): PairResult;
|
|
301
|
+
/**
|
|
302
|
+
* The verifier's own context for loading an SRL (Draft 04, spec section 8): the
|
|
303
|
+
* cached list and the list are loaded with steps 1 to 8 against these.
|
|
304
|
+
* `attestations` is the local store (step 8 reads valid `retired` attestations
|
|
305
|
+
* from it), `revocations` the directly supplied identity revocations.
|
|
306
|
+
*/
|
|
307
|
+
export interface SrlContext {
|
|
308
|
+
known_bundles?: HexOrBytes[];
|
|
309
|
+
attestations?: HexOrBytes[];
|
|
310
|
+
revocations?: {
|
|
311
|
+
id: string;
|
|
312
|
+
reason: "retired" | "compromised";
|
|
313
|
+
revoked_at: number;
|
|
314
|
+
}[];
|
|
315
|
+
max_skew_secs?: number;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Verify a signed revocation list and apply the freshness rule. `cached` is a
|
|
319
|
+
* previously accepted SRL of the same issuer (rollback and conflict rules apply).
|
|
320
|
+
*/
|
|
321
|
+
export declare function verifySrl(srl: Uint8Array, options?: {
|
|
322
|
+
now?: number;
|
|
323
|
+
onStale?: "fail-closed" | "fail-open";
|
|
324
|
+
cached?: Uint8Array;
|
|
325
|
+
context?: SrlContext;
|
|
326
|
+
}): SrlResult | Rejected;
|
|
327
|
+
/** A decoded anchor record (spec section 9). `block_height` is null when absent. */
|
|
328
|
+
export interface AnchorRecordInfo {
|
|
329
|
+
checkpoint_hash: string;
|
|
330
|
+
chain_id: string;
|
|
331
|
+
transaction_id: string;
|
|
332
|
+
block_height: number | null;
|
|
333
|
+
anchored_at: number;
|
|
334
|
+
}
|
|
335
|
+
/** One parsed `require_anchor` rule: exactly one of the two age members is set. */
|
|
336
|
+
export interface AnchorRuleInfo {
|
|
337
|
+
log: string;
|
|
338
|
+
chain: string;
|
|
339
|
+
max_age_days?: number;
|
|
340
|
+
max_age_hours?: number;
|
|
341
|
+
}
|
|
342
|
+
export type ChainIdResult = {
|
|
343
|
+
ok: true;
|
|
344
|
+
kind: "registered" | "extension";
|
|
345
|
+
} | {
|
|
346
|
+
ok: false;
|
|
347
|
+
};
|
|
348
|
+
export type AnchorRecordResult = {
|
|
349
|
+
ok: true;
|
|
350
|
+
record: AnchorRecordInfo;
|
|
351
|
+
} | {
|
|
352
|
+
ok: false;
|
|
353
|
+
error: "anchor_record_invalid";
|
|
354
|
+
};
|
|
355
|
+
export type CheckpointHashResult = {
|
|
356
|
+
ok: true;
|
|
357
|
+
checkpoint: CheckpointInfo;
|
|
358
|
+
checkpoint_hash: string;
|
|
359
|
+
payload_hex: string;
|
|
360
|
+
} | Rejected;
|
|
361
|
+
export type PublishedAnchorResult = {
|
|
362
|
+
ok: true;
|
|
363
|
+
log: string;
|
|
364
|
+
record: AnchorRecordInfo;
|
|
365
|
+
} | Rejected;
|
|
366
|
+
export type RequireAnchorResult = {
|
|
367
|
+
ok: true;
|
|
368
|
+
require_anchor: AnchorRuleInfo[];
|
|
369
|
+
} | {
|
|
370
|
+
ok: false;
|
|
371
|
+
error: "policy_invalid";
|
|
372
|
+
};
|
|
373
|
+
export type AdmissionResult = {
|
|
374
|
+
ok: true;
|
|
375
|
+
document: "attestation" | "srl";
|
|
376
|
+
} | {
|
|
377
|
+
ok: false;
|
|
378
|
+
refusal: string;
|
|
379
|
+
step?: number;
|
|
380
|
+
error?: string;
|
|
381
|
+
};
|
|
382
|
+
/** The state of one domain record source (`not-read` when the check never asked for it). */
|
|
383
|
+
export type DomainSourceState = "listed" | "not-listed" | "absent" | "invalid" | "unavailable" | "not-read";
|
|
384
|
+
/** A fetcher answer for the well-known document. `body_filler` stands for a large body. */
|
|
385
|
+
export type WellKnownAnswer = {
|
|
386
|
+
unavailable: string;
|
|
387
|
+
} | {
|
|
388
|
+
status: number;
|
|
389
|
+
final_url?: string;
|
|
390
|
+
content_type?: string | null;
|
|
391
|
+
body?: string;
|
|
392
|
+
body_filler?: {
|
|
393
|
+
prefix: string;
|
|
394
|
+
fill: string;
|
|
395
|
+
suffix: string;
|
|
396
|
+
total_bytes: number;
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
export type TxtFixtureAnswer = {
|
|
400
|
+
unavailable: string;
|
|
401
|
+
} | {
|
|
402
|
+
records: (string | string[])[];
|
|
403
|
+
dnssec_validated?: boolean;
|
|
404
|
+
};
|
|
405
|
+
/** Input of `checkDomainBinding`: what a fake fetcher answers, by host and by TXT name. No network is used. */
|
|
406
|
+
export interface DomainBindingFixture {
|
|
407
|
+
domain: string;
|
|
408
|
+
agent_id: string;
|
|
409
|
+
options?: {
|
|
410
|
+
require_both?: boolean;
|
|
411
|
+
require_dnssec?: boolean;
|
|
412
|
+
};
|
|
413
|
+
well_known: Record<string, WellKnownAnswer>;
|
|
414
|
+
txt: Record<string, TxtFixtureAnswer>;
|
|
415
|
+
}
|
|
416
|
+
export interface DomainBindingResult {
|
|
417
|
+
well_known: DomainSourceState;
|
|
418
|
+
dns: DomainSourceState;
|
|
419
|
+
outcome: "bound" | "not-bound" | "indeterminate";
|
|
420
|
+
queried: {
|
|
421
|
+
well_known: string[];
|
|
422
|
+
txt: string[];
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/** Is `id` a valid `chain-id`: one of the five registered ids, or `x-` plus a lowercase name. Pure function. */
|
|
426
|
+
export declare function chainIdKind(id: string): ChainIdResult;
|
|
427
|
+
/** Decode an anchor record payload (strict deterministic CBOR). Invalid input is a result, not an exception. */
|
|
428
|
+
export declare function parseAnchorRecord(payload: Uint8Array): AnchorRecordResult;
|
|
429
|
+
/** Deterministic CBOR of an anchor record (no `block-height` key when it is null or absent). */
|
|
430
|
+
export declare function encodeAnchorRecord(record: Omit<AnchorRecordInfo, "block_height"> & {
|
|
431
|
+
block_height?: number | null;
|
|
432
|
+
}): Uint8Array;
|
|
433
|
+
/** Verify a checkpoint envelope (as `verifyCheckpoint`) and add `checkpoint_hash`: SHA-256 of the verified payload. */
|
|
434
|
+
export declare function checkpointHash(cbor: Uint8Array, trustedLogs: string[], now?: number): CheckpointHashResult;
|
|
435
|
+
/**
|
|
436
|
+
* Take a log-signed anchor envelope as published: steps 1 to 8 (reported as they are), then the content
|
|
437
|
+
* type, the record schema, the signer (`log`) and the checkpoint hash (hex), in that order.
|
|
438
|
+
* Whether the witness really holds the hash is not checked.
|
|
439
|
+
*/
|
|
440
|
+
export declare function checkPublishedAnchor(envelope: Uint8Array, log: string, checkpointHashHex: string, now?: number): PublishedAnchorResult;
|
|
441
|
+
/** Parse the `require_anchor` rules of a trust policy object. A bad policy is `{ok: false, error: "policy_invalid"}`. */
|
|
442
|
+
export declare function parseRequireAnchor(policy: unknown): RequireAnchorResult;
|
|
443
|
+
/**
|
|
444
|
+
* The admission rules of a log (spec section 9) applied to one submission, including the data rules of
|
|
445
|
+
* `registry-endpoint` and `domain-control`. `logged` are documents admitted first, in order (hex or bytes).
|
|
446
|
+
* This package has no log: this is a pure check of the rules.
|
|
447
|
+
*/
|
|
448
|
+
export declare function checkAdmission(submission: Uint8Array, options: {
|
|
449
|
+
now?: number;
|
|
450
|
+
log: string;
|
|
451
|
+
maxEnvelopeBytes?: number;
|
|
452
|
+
logged?: HexOrBytes[];
|
|
453
|
+
}): AdmissionResult;
|
|
454
|
+
/** Run the domain binding check (section 7) over a fixture of fetcher answers. No network is used. */
|
|
455
|
+
export declare function checkDomainBinding(fixture: DomainBindingFixture): DomainBindingResult;
|