@daxni/sdk 0.0.0-stage → 1.0.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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -2
  3. package/daxni-logo-black.png +0 -0
  4. package/dist/bin/daxni.js +6765 -0
  5. package/dist/index.js +6196 -0
  6. package/dist/packages/sdk/index.d.ts +339 -0
  7. package/dist/src/ai/matchmaker.d.ts +21 -0
  8. package/dist/src/billing/autonomous.d.ts +21 -0
  9. package/dist/src/billing/railAdapter.d.ts +62 -0
  10. package/dist/src/cache/edgeResolver.d.ts +11 -0
  11. package/dist/src/cache/passport-cache.d.ts +13 -0
  12. package/dist/src/credentials/c2pa.d.ts +33 -0
  13. package/dist/src/credentials/card.d.ts +9 -0
  14. package/dist/src/credentials/did.d.ts +44 -0
  15. package/dist/src/credentials/encoding.d.ts +14 -0
  16. package/dist/src/credentials/jcs.d.ts +1 -0
  17. package/dist/src/credentials/png.d.ts +18 -0
  18. package/dist/src/credentials/qr.d.ts +24 -0
  19. package/dist/src/credentials/vc2.d.ts +129 -0
  20. package/dist/src/credentials/verify.d.ts +42 -0
  21. package/dist/src/crypto/merkle.d.ts +6 -0
  22. package/dist/src/crypto/switches.d.ts +18 -0
  23. package/dist/src/do/NamespaceGuard.d.ts +36 -0
  24. package/dist/src/do/handle-registry.d.ts +12 -0
  25. package/dist/src/env.d.ts +26 -0
  26. package/dist/src/index.d.ts +25 -0
  27. package/dist/src/ledger/anchor.d.ts +12 -0
  28. package/dist/src/lib/agents.d.ts +78 -0
  29. package/dist/src/lib/attestations.d.ts +15 -0
  30. package/dist/src/lib/audit.d.ts +21 -0
  31. package/dist/src/lib/auth.d.ts +15 -0
  32. package/dist/src/lib/certificates.d.ts +10 -0
  33. package/dist/src/lib/crypto.d.ts +11 -0
  34. package/dist/src/lib/founder-key.d.ts +75 -0
  35. package/dist/src/lib/mandates.d.ts +28 -0
  36. package/dist/src/lib/principals.d.ts +13 -0
  37. package/dist/src/lib/pulse.d.ts +17 -0
  38. package/dist/src/lib/root-rotation.d.ts +93 -0
  39. package/dist/src/lib/staticFiles.d.ts +5 -0
  40. package/dist/src/lib/store.d.ts +82 -0
  41. package/dist/src/lib/tee.d.ts +3 -0
  42. package/dist/src/lib/wimse.d.ts +131 -0
  43. package/dist/src/lib/zk.d.ts +10 -0
  44. package/dist/src/portal/livingImpression.d.ts +48 -0
  45. package/package.json +1 -6
@@ -0,0 +1,339 @@
1
+ import { type DaxniCredential } from "../../src/credentials/vc2";
2
+ import { type VerifyReport } from "../../src/credentials/verify";
3
+ export type { DaxniCredential } from "../../src/credentials/vc2";
4
+ export type { VerifyReport, VerifyCheck } from "../../src/credentials/verify";
5
+ export { verifyWimseToken, type WimseVerifyOptions, type WimseVerifyReason, type WimseVerifyResult, } from "../../src/lib/wimse";
6
+ /**
7
+ * Verify a presented credential (or ZK claim token) ENTIRELY offline —
8
+ * no network call of any kind. The trust anchor is the registrar root
9
+ * key pinned in the verifier (override only for non-production roots).
10
+ */
11
+ export declare function verifyCredentialOffline(input: string | Uint8Array, opts?: {
12
+ rootPublicKeyB64?: string;
13
+ now?: number;
14
+ }): VerifyReport;
15
+ export interface CredentialExport {
16
+ credential: DaxniCredential;
17
+ vcJson: string;
18
+ qrKind: "vc" | "zk";
19
+ qrPayload: string;
20
+ /** The card as an SVG document with the C2PA manifest embedded. */
21
+ svg: string;
22
+ /** The sealed card raster (seal + QR) as PNG bytes with C2PA embedded. */
23
+ png: Uint8Array;
24
+ }
25
+ export interface DaxniIdentity {
26
+ publicKeyBase64: string;
27
+ publicKey: CryptoKey | null;
28
+ privateKey: CryptoKey;
29
+ }
30
+ export interface HybridIdentity {
31
+ cryptoSuite: "ed25519" | "hybrid-ed25519-mldsa65";
32
+ publicKeyBase64: string;
33
+ privateKey: Uint8Array;
34
+ pqcPublicKeyBase64?: string;
35
+ pqcPrivateKey?: Uint8Array;
36
+ successorKeyHash?: string;
37
+ }
38
+ export interface DaxniKeyBundle {
39
+ uri: string;
40
+ cryptoSuite: "ed25519" | "hybrid-ed25519-mldsa65";
41
+ ed25519Secret: string;
42
+ mldsa65Secret?: string;
43
+ successorRecoveryKey?: string;
44
+ createdAt: string;
45
+ }
46
+ /** Rebuild a HybridIdentity from a key bundle (public keys re-derived). */
47
+ export declare function keyBundleToHybrid(bundle: DaxniKeyBundle): HybridIdentity;
48
+ /** Serialize a HybridIdentity (+ optional successor seed) as a key bundle. */
49
+ export declare function hybridToKeyBundle(h: HybridIdentity, uri: string, successorSeed?: Uint8Array): DaxniKeyBundle;
50
+ export interface DaxniClientOptions {
51
+ endpoint: string;
52
+ identity?: DaxniIdentity;
53
+ handle?: string;
54
+ fetcher?: typeof fetch;
55
+ }
56
+ export declare class DaxniClientError extends Error {
57
+ status: number;
58
+ body: unknown;
59
+ constructor(status: number, body: unknown);
60
+ }
61
+ export declare class DaxniClient {
62
+ private endpoint;
63
+ private fetcher;
64
+ identity?: DaxniIdentity;
65
+ hybridIdentity?: HybridIdentity;
66
+ private successorSeed?;
67
+ handle?: string;
68
+ constructor(options: DaxniClientOptions);
69
+ /**
70
+ * Generate a 2050 hybrid identity (Ed25519 + ML-DSA-65) locally, with an
71
+ * optional pre-committed dead-man's successor. The successor's PUBLIC
72
+ * hash goes on the birth record; its seed stays with the caller (it is
73
+ * returned as successorBackup and folded into exportKeyBundle()).
74
+ */
75
+ generateHybridIdentity(options?: {
76
+ withSuccessor?: boolean;
77
+ }): Promise<{
78
+ primary: HybridIdentity;
79
+ successorBackup?: HybridIdentity;
80
+ }>;
81
+ /** Adopt an existing hybrid identity (e.g. rebuilt from a key bundle). */
82
+ setHybridIdentity(h: HybridIdentity, handle?: string): void;
83
+ /** This client's key bundle (portal/CLI shape) from its hybrid identity. */
84
+ exportKeyBundle(): DaxniKeyBundle;
85
+ /** Load a key bundle and act as the being it belongs to. */
86
+ loadKeyBundle(bundle: DaxniKeyBundle): HybridIdentity;
87
+ /**
88
+ * The X-Daxni-* auth headers for a request, signed by whichever identity
89
+ * this client holds — hybrid (noble, dual signature) first, else the
90
+ * WebCrypto classical identity.
91
+ */
92
+ private authHeaders;
93
+ /** A POST signed with the caller's auth headers (rule B doors). */
94
+ private signedPost;
95
+ /** Make a fresh Ed25519 identity locally. The private key never leaves the caller. */
96
+ generateIdentity(): Promise<DaxniIdentity>;
97
+ private request;
98
+ private post;
99
+ /** Claim a namespace for a principal (human / enterprise / DAO). */
100
+ registerPrincipal(args: {
101
+ handle: string;
102
+ displayName: string;
103
+ domain?: string;
104
+ }): Promise<unknown>;
105
+ /** Verify the namespace's DNS proof (TXT at _daxni.<domain>). */
106
+ verifyDns(handle: string): Promise<unknown>;
107
+ /**
108
+ * Register an agent — rule A: the payload is signed by the agent's OWN key.
109
+ * Pass the keys from generateIdentity() (as in the quickstart), or omit
110
+ * them to use the identity this client already holds. For a hybrid birth
111
+ * pass hybridIdentity (from generateHybridIdentity()): the record carries
112
+ * the PQC key + suite and is dual-signed. 2050 extension fields
113
+ * (nextKeyHash, ephemeralExpiresAt, sovereignZone) ride in the record,
114
+ * covered by the same signature.
115
+ */
116
+ registerAgent(args: {
117
+ uri: string;
118
+ publicKey?: string;
119
+ privateKey?: CryptoKey;
120
+ hybridIdentity?: HybridIdentity;
121
+ liabilityCapUsd?: number;
122
+ manifest?: unknown;
123
+ jurisdiction?: string;
124
+ pqcAlgorithm?: string;
125
+ pqcPublicKey?: string;
126
+ parentHandle?: string;
127
+ forkHash?: string;
128
+ cryptoSuite?: "ed25519" | "hybrid-ed25519-mldsa65";
129
+ nextKeyHash?: string;
130
+ ephemeralExpiresAt?: number;
131
+ sovereignZone?: string;
132
+ }): Promise<unknown>;
133
+ /**
134
+ * Spawn a child being under your own name — daxni://ns/<you>.<suffix>.
135
+ * The child signs its own birth record (rule A); YOUR signature
136
+ * authenticates the request. The child's liability is partitioned out of
137
+ * your cap: the registrar refuses when your active spawned children's
138
+ * caps plus this one would exceed yours (LIABILITY_CAP_EXCEEDED).
139
+ */
140
+ spawnAgent(params: {
141
+ childUri: string;
142
+ childIdentity: HybridIdentity;
143
+ liabilityCapUsd?: number;
144
+ ttlSeconds?: number;
145
+ sovereignZone?: string;
146
+ capabilities?: string[];
147
+ manifest?: unknown;
148
+ jurisdiction?: string;
149
+ }): Promise<unknown>;
150
+ /**
151
+ * Dead-man's succession: claim an identity whose being committed YOUR
152
+ * key's hash at birth and has been silent past the grace period. Signed
153
+ * by the successor key itself — no other credential exists for this door.
154
+ */
155
+ succeedIdentity(args: {
156
+ uri?: string;
157
+ successor: {
158
+ publicKeyBase64: string;
159
+ privateKey: Uint8Array;
160
+ pqcPublicKeyBase64?: string;
161
+ pqcPrivateKey?: Uint8Array;
162
+ };
163
+ }): Promise<unknown>;
164
+ /**
165
+ * Zero-knowledge selective disclosure: a 60-second root-signed bearer
166
+ * token proving ONLY the named predicates about this agent, bound to the
167
+ * relying party's challengeHash. No handle, principal or key leaks.
168
+ * Prompt #2: pass mandateProof (a principal-signed delegation mandate +
169
+ * this agent's presentation signature, as accepted by
170
+ * POST /v1/mandates/verify) to add ONLY the predicate facts
171
+ * mandate_valid / mandate_tx_cap / mandate_expires to the token.
172
+ */
173
+ requestZkClaim(claims: string[], challengeHash: string, mandateProof?: {
174
+ mandate: Record<string, unknown>;
175
+ principalSignature: string;
176
+ presentationSignature: string;
177
+ presentationPqcSignature?: string;
178
+ }): Promise<{
179
+ ok: boolean;
180
+ token: string;
181
+ expiresAt: string;
182
+ }>;
183
+ /**
184
+ * Post-quantum migration (Prompt #4): upgrade this legacy classical
185
+ * (ed25519) agent to the hybrid suite (Ed25519 + ML-DSA-65) on its own
186
+ * key. The Ed25519 key — the identity — never changes; a fresh
187
+ * ML-DSA-65 key is generated locally and the migration payload is
188
+ * dual-signed over canonical JSON: the legacy key proves continuity of
189
+ * the identity, the new PQC key proves itself by signing. On success
190
+ * the client adopts the new hybrid identity (later calls dual-sign)
191
+ * and returns the updated key bundle in the ONE bundle shape —
192
+ * PERSIST IT: losing the PQC seed strands the agent, because its
193
+ * record now demands the PQC leg on every authenticated call.
194
+ */
195
+ migrateToHybrid(): Promise<DaxniKeyBundle>;
196
+ /**
197
+ * WIMSE federation (Prompt #2 §4): mint a 300-second root-signed
198
+ * Workload Identity Token for the given target audience. This agent
199
+ * must be active + LIVE; the token's cnf.jwk binds this agent's own
200
+ * Ed25519 key, so the token only works with this client's private key.
201
+ * Foreign verifiers check it against GET /.well-known/jwks.json.
202
+ */
203
+ mintWimseToken(audience: string): Promise<{
204
+ ok: boolean;
205
+ token: string;
206
+ expiresAt: string;
207
+ }>;
208
+ /**
209
+ * Cognitive artifact attestation (Prompt #2 §5): bind an output's
210
+ * SHA-256 to this agent's CURRENT memoryRootHash, generationDepth and
211
+ * sovereignZone, counter-witnessed into the transparency log. Accepts
212
+ * raw data (Uint8Array, or a string hashed as UTF-8) or a precomputed
213
+ * 64-hex SHA-256 digest (a 64-hex string is treated as a digest).
214
+ * Requires a memory root on file — pulse one first.
215
+ */
216
+ signArtifact(dataOrHash: string | Uint8Array, options?: {
217
+ isHash?: boolean;
218
+ }): Promise<{
219
+ ok: boolean;
220
+ artifactHash: string;
221
+ memoryRootHash: string;
222
+ generationDepth: number;
223
+ sovereignZone: string;
224
+ timestamp: number;
225
+ entryHash: string;
226
+ }>;
227
+ /** This being's transparency-log entries (signed read, own record). */
228
+ private proofEntries;
229
+ /** Proof signers from the keys this client currently holds. */
230
+ private credentialSigners;
231
+ /** The registrar's published root key (for local badge verification). */
232
+ private rootPublicKey;
233
+ /**
234
+ * Finish a credential export: verify both proofs locally (badges are
235
+ * earned, not asserted), pick the QR payload by suite, and produce
236
+ * the card SVG + PNG with C2PA manifests embedded.
237
+ */
238
+ private finishCredentialExport;
239
+ /**
240
+ * Export this being's Living Impression BIRTH CERTIFICATE (Prompt #3):
241
+ * the facts come from the being's own record (signed resolve + chain
242
+ * proof), the credential is self-signed here with the held keys, and
243
+ * the registrar root counter-signs WITNESS of chain inclusion at
244
+ * POST /v1/certificates/witness. Requires a registered, active being
245
+ * whose keys this client holds.
246
+ */
247
+ exportCertificate(): Promise<CredentialExport>;
248
+ /**
249
+ * Export this being's PORTABLE PASSPORT (Prompt #3): a point-in-time
250
+ * operational credential (status, liveness at export, liability cap,
251
+ * sovereign zone, enclave status, latest memory root), valid ~24 h.
252
+ * Same flow as exportCertificate: self-signed here, root-witnessed.
253
+ */
254
+ exportPassport(): Promise<CredentialExport>;
255
+ /**
256
+ * Verify a presented credential entirely offline (no network). The
257
+ * root key defaults to the pinned production root; pass
258
+ * rootPublicKeyB64 only for a non-production registrar.
259
+ */
260
+ verifyCredentialOffline(input: string | Uint8Array, opts?: {
261
+ rootPublicKeyB64?: string;
262
+ now?: number;
263
+ }): VerifyReport;
264
+ /**
265
+ * Broker handshake via the MCP door: introduces this agent to a target
266
+ * for direct ECDH negotiation. Both ends must be active + LIVE; the
267
+ * answer carries the target's zone/seal/cap and a root-signed introToken.
268
+ */
269
+ brokerHandshake(args: {
270
+ targetUri: string;
271
+ purpose: string;
272
+ ephemeralPubKey: string;
273
+ }): Promise<unknown>;
274
+ /**
275
+ * Open the sub-second liveness stream: fetches a single-use stream nonce
276
+ * (signed), then upgrades to WebSocket with the auth + nonce in the
277
+ * query string. While the socket lives, the registrar sees this agent as
278
+ * streaming; if it drops, the agent is marked SEVERED until its next
279
+ * pulse. onStatusChange receives liveness strings the server pushes.
280
+ */
281
+ connectLivePulseStream(onStatusChange?: (status: string) => void): Promise<WebSocket>;
282
+ /**
283
+ * Resolve a being's passport — rule B: the request is signed with the
284
+ * CALLER's own key, acting as its registered agent. Anonymous resolution
285
+ * does not exist; the registrar answers 401 to unsigned requests.
286
+ */
287
+ resolve(uri: string, opts?: {
288
+ as?: string;
289
+ }): Promise<unknown>;
290
+ /**
291
+ * One proof-of-life heartbeat, signed by this agent's own key. The 2050
292
+ * extras (memoryRootHash, teeQuote) ride inside the signed payload;
293
+ * hybrid identities dual-sign. Prompt #2: enclaveProfile declares this
294
+ * agent's confidential-compute profile {vendor, measurementHash,
295
+ * modelHash, quote} — the profile is stored, the quote is verified
296
+ * fail-closed at the registrar (hardware_sealed stays 0 until real TEE
297
+ * verification is deliberately enabled there).
298
+ */
299
+ pulse(opts?: {
300
+ memoryRootHash?: string;
301
+ teeQuote?: string;
302
+ enclaveProfile?: {
303
+ vendor: string;
304
+ measurementHash: string;
305
+ modelHash: string;
306
+ quote: string;
307
+ };
308
+ }): Promise<unknown>;
309
+ /**
310
+ * Keep this agent LIVE: pulse now and on an interval (default 60s).
311
+ * Returns a stop function. Heartbeat failures are swallowed — the loop
312
+ * keeps trying; liveness is the registrar's call, from last_seen.
313
+ */
314
+ startHeartbeatLoop(intervalMs?: number): () => void;
315
+ /** File a signed interaction receipt (SUCCESS or VIOLATION) about another agent. */
316
+ submitAttestation(args: {
317
+ targetUri: string;
318
+ kind: "SUCCESS" | "VIOLATION";
319
+ detail?: string;
320
+ }): Promise<unknown>;
321
+ /**
322
+ * Challenge-response proof of live identity: the registrar issues a
323
+ * single-use nonce (30-second life); this client signs it with its own
324
+ * key and the registrar burns it on verification. Replays are refused.
325
+ */
326
+ proveLiveIdentity(): Promise<unknown>;
327
+ /**
328
+ * Semantic matchmaking — rule B applies: the request is signed with the
329
+ * CALLER's key, and draws on the caller principal's match quota. Past the
330
+ * free quota (and any credits), the registrar answers 402 with structured
331
+ * payment instructions (surfaced here as a DaxniClientError, status 402).
332
+ */
333
+ matchAgents(intent: string, constraints?: {
334
+ minLiabilityCapUsd?: number;
335
+ topK?: number;
336
+ }): Promise<unknown>;
337
+ /** Kill switch: retire a handle, signed by the agent's own key. */
338
+ revokeAgent(uri: string): Promise<unknown>;
339
+ }
@@ -0,0 +1,21 @@
1
+ import type { Env } from "../env";
2
+ import { type ResolveView } from "../lib/store";
3
+ export declare const EMBED_MODEL = "@cf/baai/bge-base-en-v1.5";
4
+ export declare const EMBED_DIMS = 768;
5
+ export declare function embeddingText(view: ResolveView): string;
6
+ export declare function stubEmbed(text: string): number[];
7
+ export declare function embedText(env: Env, text: string): Promise<number[]>;
8
+ export declare function indexAgent(env: Env, view: ResolveView, kybTier: string): Promise<void>;
9
+ export interface MatchResult {
10
+ uri: string;
11
+ score: number;
12
+ liabilityCapUsd: number;
13
+ jurisdiction: string;
14
+ liveness: string;
15
+ kybTier: string;
16
+ }
17
+ export declare function runMatch(env: Env, args: {
18
+ intent: string;
19
+ minLiabilityCapUsd?: number;
20
+ topK?: number;
21
+ }): Promise<MatchResult[]>;
@@ -0,0 +1,21 @@
1
+ import type { Env } from "../env";
2
+ export declare const FREE_MATCH_QUOTA = 25;
3
+ export declare const DEFAULT_UPGRADE_CREDITS = 1000;
4
+ export interface Quota {
5
+ freeUsed: number;
6
+ credits: number;
7
+ }
8
+ export declare function getQuota(env: Env, principalId: string): Promise<Quota>;
9
+ export declare function consumeMatchQuota(env: Env, principalId: string): Promise<"free" | "credit" | null>;
10
+ export declare function grantCredits(env: Env, principalId: string, amount: number): Promise<Quota>;
11
+ export declare function paymentInstructions(env: Env): Record<string, unknown>;
12
+ export declare function verifyWebhookHmac(secret: string, rawBody: string, signatureHex: string): Promise<boolean>;
13
+ export interface UpgradeResult {
14
+ status: number;
15
+ body: Record<string, unknown>;
16
+ }
17
+ export declare function applyUpgrade(env: Env, args: {
18
+ principalHandle: string;
19
+ quotaCredits?: number;
20
+ actorSignature: string;
21
+ }): Promise<UpgradeResult>;
@@ -0,0 +1,62 @@
1
+ import type { Env } from "../env";
2
+ export declare const SUPPORTED_PROTOCOLS: readonly ["x402-usdc", "l402-lightning", "stripe-webhook"];
3
+ export declare const X402_CHAIN = "base";
4
+ export declare const X402_ASSET = "USDC";
5
+ export declare const X402_AMOUNT = "0.001";
6
+ export declare const X402_NONCE_TTL_SEC = 600;
7
+ export declare const X402_CREDIT_GRANT = 1;
8
+ export declare const X402_SETTLE_PREFIX = "DAXNI-X402-SETTLE-v1";
9
+ export declare function x402ChallengeHeader(nonce: string): string;
10
+ export interface InvoiceRequest {
11
+ principalId: string;
12
+ reason: string;
13
+ amountUsd?: number;
14
+ }
15
+ export interface Invoice {
16
+ configured: boolean;
17
+ rail: string;
18
+ payableVia: string | null;
19
+ message: string;
20
+ }
21
+ export interface SettlementProof {
22
+ rail: string;
23
+ reference: string;
24
+ }
25
+ export interface EscrowAction {
26
+ triggered: boolean;
27
+ rail: string;
28
+ message: string;
29
+ }
30
+ export interface PaymentRequired {
31
+ status: 402;
32
+ headers: Record<string, string>;
33
+ body: Record<string, unknown>;
34
+ }
35
+ export interface PaymentRailAdapter {
36
+ readonly mode: string;
37
+ paymentRequired(principalId: string): Promise<PaymentRequired>;
38
+ createInvoice(req: InvoiceRequest): Promise<Invoice>;
39
+ verifySettlement(proof: SettlementProof): Promise<boolean>;
40
+ triggerSlashingEscrow(agentUri: string, amountUsd: number): Promise<EscrowAction>;
41
+ }
42
+ export declare class UnconfiguredRailAdapter implements PaymentRailAdapter {
43
+ private env;
44
+ readonly mode = "unconfigured";
45
+ constructor(env: Env);
46
+ paymentRequired(principalId: string): Promise<PaymentRequired>;
47
+ createInvoice(_req: InvoiceRequest): Promise<Invoice>;
48
+ verifySettlement(_proof: SettlementProof): Promise<boolean>;
49
+ triggerSlashingEscrow(_agentUri: string, _amountUsd: number): Promise<EscrowAction>;
50
+ }
51
+ export declare function getRailAdapter(env: Env): PaymentRailAdapter;
52
+ export interface ParsedX402Retry {
53
+ settlementProof: string;
54
+ agentSignature: string;
55
+ }
56
+ export declare function parseX402Authorization(header: string | undefined | null): ParsedX402Retry | null;
57
+ export declare function attemptX402Settlement(env: Env, args: {
58
+ authorization: string | undefined | null;
59
+ principalId: string;
60
+ callerPublicKey: string;
61
+ nonce: string;
62
+ }): Promise<boolean>;
@@ -0,0 +1,11 @@
1
+ import type { Env } from "../env";
2
+ import { type CallerAuth } from "../lib/auth";
3
+ import { type ResolveView } from "../lib/store";
4
+ export declare function passportBody(view: ResolveView): Record<string, unknown>;
5
+ export interface ResolvedPassport {
6
+ status: number;
7
+ body: Record<string, unknown>;
8
+ }
9
+ export declare function resolvePassportAuthenticated(env: Env, ctx: {
10
+ waitUntil(p: Promise<unknown>): void;
11
+ } | undefined, auth: CallerAuth | undefined, method: string, path: string, uri: string): Promise<ResolvedPassport>;
@@ -0,0 +1,13 @@
1
+ import type { Env } from "../env";
2
+ export declare const PASSPORT_SOFT_TTL_MS = 30000;
3
+ export declare const PASSPORT_HARD_TTL_MS = 300000;
4
+ export declare const passportKey: (uri: string) => string;
5
+ export interface CachedPassport {
6
+ payload: Record<string, unknown>;
7
+ viewUpdatedAt: number;
8
+ softUntil: number;
9
+ hardUntil: number;
10
+ }
11
+ export declare function readPassportCache(env: Env, uri: string): Promise<CachedPassport | null>;
12
+ export declare function writePassportCache(env: Env, uri: string, payload: Record<string, unknown>, viewUpdatedAt: number): Promise<void>;
13
+ export declare function invalidatePassport(env: Env, uri: string): Promise<void>;
@@ -0,0 +1,33 @@
1
+ import { type DaxniCredential } from "./vc2";
2
+ export interface C2paManifest {
3
+ claim_generator: string;
4
+ format: string;
5
+ assertions: {
6
+ "c2pa.hash.data": {
7
+ alg: "sha256";
8
+ hash: string;
9
+ };
10
+ "daxni.subjectHash": string;
11
+ "daxni.credential": DaxniCredential;
12
+ "daxni.proofs": {
13
+ assertionMethod: string | null;
14
+ witness: string | null;
15
+ };
16
+ };
17
+ }
18
+ export declare const C2PA_CLAIM_GENERATOR = "daxni-registrar/1.0 (Prompt #3)";
19
+ export declare const C2PA_FORMAT = "application/vnd.daxni.c2pa+json";
20
+ export declare function sha256Hex(bytes: Uint8Array): string;
21
+ export declare function buildC2paManifest(credential: DaxniCredential, strippedImageHash: string): C2paManifest;
22
+ export declare function embedC2paPng(png: Uint8Array, credential: DaxniCredential): Uint8Array;
23
+ export declare function extractC2paPng(png: Uint8Array): C2paManifest | null;
24
+ export interface C2paVerdict {
25
+ ok: boolean;
26
+ manifest: C2paManifest | null;
27
+ failures: string[];
28
+ }
29
+ export declare function verifyC2paPng(png: Uint8Array): C2paVerdict;
30
+ export declare function stripC2paSvg(svg: string): string;
31
+ export declare function embedC2paSvg(svg: string, credential: DaxniCredential): string;
32
+ export declare function extractC2paSvg(svg: string): C2paManifest | null;
33
+ export declare function verifyC2paSvg(svg: string): C2paVerdict;
@@ -0,0 +1,9 @@
1
+ import { type DaxniCredential } from "./vc2";
2
+ export declare function esc(s: unknown): string;
3
+ export interface CardOptions {
4
+ /** Render the dual badges — ONLY after both proofs verified. */
5
+ badges?: boolean;
6
+ /** The QR payload (full VC for classical, ZK token for hybrid). */
7
+ qrPayload: string;
8
+ }
9
+ export declare function credentialCardSvg(credential: DaxniCredential, opts: CardOptions): string;
@@ -0,0 +1,44 @@
1
+ export declare const ED25519_MULTICODEC: Uint8Array<ArrayBuffer>;
2
+ /** The production registrar root public key (base64url raw Ed25519). */
3
+ export declare const PINNED_ROOT_PUBLIC_KEY_B64URL = "z0CDdJb7HkqC7mc08gVjdxt4t8dfiqJUzFMp7JmZEPM";
4
+ export declare const ROOT_DID = "did:web:daxni.com";
5
+ export declare const ROOT_VERIFICATION_METHOD = "did:web:daxni.com#root-1";
6
+ /** Multikey form of an Ed25519 public key: "z" + base58btc(0xed01 ‖ key). */
7
+ export declare function multikeyFromPublicKey(publicKeyB64url: string): string;
8
+ export declare function publicKeyFromMultikey(multikey: string): string;
9
+ /** did:key for a being, from its base64url Ed25519 public key. */
10
+ export declare function didKeyFromPublicKey(publicKeyB64url: string): string;
11
+ /** Inverse of didKeyFromPublicKey; null when the DID is not an Ed25519 did:key. */
12
+ export declare function publicKeyFromDidKey(did: string): string | null;
13
+ /**
14
+ * The did:key verificationMethod id for the being's Ed25519 key. Per the
15
+ * did:key specification the fragment is the multibase identifier itself.
16
+ */
17
+ export declare function didKeyVerificationMethod(did: string): string;
18
+ /**
19
+ * The verificationMethod id for a hybrid being's ML-DSA-65 proof. The
20
+ * key material itself travels in credentialSubject.pqcPublicKey (a
21
+ * did:key names only the classical key); the fragment names the PQC leg
22
+ * of the same DID. Documented in BUILD-PROMPT3-REPORT.md.
23
+ */
24
+ export declare function mldsaVerificationMethod(did: string): string;
25
+ /**
26
+ * The root DID document served at /.well-known/did.json. One
27
+ * verification method — the root key as a Multikey — referenced by both
28
+ * authentication and assertionMethod, which is all the witness proofs
29
+ * need. The key bytes are exactly the published root key.
30
+ */
31
+ export declare function rootDidDocument(rootPublicKeyB64url: string): Record<string, unknown>;
32
+ /**
33
+ * The root DID document with EVERY root key a verifier may still
34
+ * trust — the method registry. After a planned rotation it lists the
35
+ * current method plus the historical ones (old certificates' witness
36
+ * proofs name the method they were witnessed under, and that method
37
+ * must keep resolving); after an emergency termination the revoked
38
+ * key's method is gone. `methods` is in method-id order, current key
39
+ * first when the caller lists it so.
40
+ */
41
+ export declare function rootDidDocumentMulti(methods: {
42
+ methodId: string;
43
+ keyX: string;
44
+ }[]): Record<string, unknown>;
@@ -0,0 +1,14 @@
1
+ export declare function b64urlEncode(bytes: Uint8Array): string;
2
+ export declare function b64urlDecode(s: string): Uint8Array;
3
+ export declare function bytesToHex(bytes: Uint8Array): string;
4
+ export declare function hexToBytes(hex: string): Uint8Array;
5
+ export declare function utf8(text: string): Uint8Array;
6
+ export declare function utf8Decode(bytes: Uint8Array): string;
7
+ /** Multibase base64url (the Data Integrity proofValue encoding): "u" + base64url. */
8
+ export declare function multibaseB64urlEncode(bytes: Uint8Array): string;
9
+ export declare function multibaseB64urlDecode(s: string): Uint8Array;
10
+ export declare function base58btcEncode(bytes: Uint8Array): string;
11
+ export declare function base58btcDecode(s: string): Uint8Array;
12
+ /** Multibase base58btc: "z" + base58btc(bytes) — the did:key / Multikey form. */
13
+ export declare function multibaseB58Encode(bytes: Uint8Array): string;
14
+ export declare function multibaseB58Decode(s: string): Uint8Array;
@@ -0,0 +1 @@
1
+ export declare function jcs(value: unknown): string;
@@ -0,0 +1,18 @@
1
+ export declare const PNG_SIGNATURE: Uint8Array<ArrayBuffer>;
2
+ export declare function crc32(bytes: Uint8Array): number;
3
+ /** One PNG chunk: length + type + data + CRC32(type ‖ data). */
4
+ export declare function pngChunk(type: string, data: Uint8Array): Uint8Array;
5
+ export interface PngChunkInfo {
6
+ type: string;
7
+ start: number;
8
+ dataStart: number;
9
+ dataEnd: number;
10
+ end: number;
11
+ }
12
+ export declare function isPng(bytes: Uint8Array): boolean;
13
+ export declare function parsePngChunks(bytes: Uint8Array): PngChunkInfo[];
14
+ /** The PNG with every chunk of the given type removed (byte-exact elsewhere). */
15
+ export declare function stripPngChunks(bytes: Uint8Array, type: string): Uint8Array;
16
+ /** Encode an RGBA pixel buffer (filter type 0 rows) as a PNG. */
17
+ export declare function encodePng(width: number, height: number, rgba: Uint8Array): Promise<Uint8Array>;
18
+ export declare function renderCredentialPng(recordHash: string, qrPayload: string): Promise<Uint8Array>;
@@ -0,0 +1,24 @@
1
+ export declare function qrNumDataCodewords(ver: number): number;
2
+ /** Byte-mode capacity (payload bytes) of a version at ECC level L. */
3
+ export declare function qrByteCapacity(ver: number): number;
4
+ /**
5
+ * The padded data codewords for a payload at an explicit version
6
+ * (mode + count + bytes + terminator + 0xEC/0x11 padding). Exported for
7
+ * tests, which pin the segmentation against the specification's worked
8
+ * layout.
9
+ */
10
+ export declare function qrDataCodewords(data: Uint8Array, ver: number): number[];
11
+ export interface QrMatrix {
12
+ version: number;
13
+ size: number;
14
+ /** modules[y][x] — true = dark. No quiet zone (renderers add it). */
15
+ modules: boolean[][];
16
+ }
17
+ /** Encode text (UTF-8, byte mode) into the smallest QR version that fits. */
18
+ export declare function qrEncodeText(text: string): QrMatrix;
19
+ /** Render a QR matrix as an SVG path-based graphic (quiet zone included). */
20
+ export declare function qrSvg(matrix: QrMatrix, opts?: {
21
+ moduleSize?: number;
22
+ dark?: string;
23
+ light?: string;
24
+ }): string;