@cardanowall/sdk-ts 0.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 (67) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +207 -0
  3. package/dist/client/index.cjs +2695 -0
  4. package/dist/client/index.cjs.map +1 -0
  5. package/dist/client/index.d.cts +397 -0
  6. package/dist/client/index.d.ts +397 -0
  7. package/dist/client/index.js +2641 -0
  8. package/dist/client/index.js.map +1 -0
  9. package/dist/conformance/cli.cjs +4901 -0
  10. package/dist/conformance/cli.cjs.map +1 -0
  11. package/dist/conformance/cli.d.cts +18 -0
  12. package/dist/conformance/cli.d.ts +18 -0
  13. package/dist/conformance/cli.js +4878 -0
  14. package/dist/conformance/cli.js.map +1 -0
  15. package/dist/fetch/index.cjs +335 -0
  16. package/dist/fetch/index.cjs.map +1 -0
  17. package/dist/fetch/index.d.cts +13 -0
  18. package/dist/fetch/index.d.ts +13 -0
  19. package/dist/fetch/index.js +323 -0
  20. package/dist/fetch/index.js.map +1 -0
  21. package/dist/fetch-outbound-BT5-NiYN.d.cts +76 -0
  22. package/dist/fetch-outbound-BT5-NiYN.d.ts +76 -0
  23. package/dist/hash/index.cjs +25 -0
  24. package/dist/hash/index.cjs.map +1 -0
  25. package/dist/hash/index.d.cts +1 -0
  26. package/dist/hash/index.d.ts +1 -0
  27. package/dist/hash/index.js +21 -0
  28. package/dist/hash/index.js.map +1 -0
  29. package/dist/identity/index.cjs +1388 -0
  30. package/dist/identity/index.cjs.map +1 -0
  31. package/dist/identity/index.d.cts +27 -0
  32. package/dist/identity/index.d.ts +27 -0
  33. package/dist/identity/index.js +1362 -0
  34. package/dist/identity/index.js.map +1 -0
  35. package/dist/ids/index.cjs +146 -0
  36. package/dist/ids/index.cjs.map +1 -0
  37. package/dist/ids/index.d.cts +55 -0
  38. package/dist/ids/index.d.ts +55 -0
  39. package/dist/ids/index.js +135 -0
  40. package/dist/ids/index.js.map +1 -0
  41. package/dist/index-BhnlWJAY.d.cts +10 -0
  42. package/dist/index-BhnlWJAY.d.ts +10 -0
  43. package/dist/index-Cg1QqVmA.d.cts +19 -0
  44. package/dist/index-Cg1QqVmA.d.ts +19 -0
  45. package/dist/index.cjs +7127 -0
  46. package/dist/index.cjs.map +1 -0
  47. package/dist/index.d.cts +21 -0
  48. package/dist/index.d.ts +21 -0
  49. package/dist/index.js +7004 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/merkle/index.cjs +396 -0
  52. package/dist/merkle/index.cjs.map +1 -0
  53. package/dist/merkle/index.d.cts +2 -0
  54. package/dist/merkle/index.d.ts +2 -0
  55. package/dist/merkle/index.js +387 -0
  56. package/dist/merkle/index.js.map +1 -0
  57. package/dist/types-B8Q3gW54.d.ts +123 -0
  58. package/dist/types-BQMtbRCb.d.cts +321 -0
  59. package/dist/types-BQMtbRCb.d.ts +321 -0
  60. package/dist/types-CLXdbjqr.d.cts +123 -0
  61. package/dist/verifier/index.cjs +4901 -0
  62. package/dist/verifier/index.cjs.map +1 -0
  63. package/dist/verifier/index.d.cts +176 -0
  64. package/dist/verifier/index.d.ts +176 -0
  65. package/dist/verifier/index.js +4848 -0
  66. package/dist/verifier/index.js.map +1 -0
  67. package/package.json +108 -0
@@ -0,0 +1,321 @@
1
+ type FetchImpl = (input: string | URL, init?: RequestInit) => Promise<Response>;
2
+ interface Cip309ClientConfig {
3
+ /**
4
+ * Bearer credential, forwarded verbatim as `Authorization: Bearer <apiKey>`.
5
+ *
6
+ * Treated as an OPAQUE token: the SDK never parses, validates, or infers
7
+ * anything from it, since each CIP-309 gateway issues keys in its own format.
8
+ * Omit for anonymous read-only usage.
9
+ */
10
+ readonly apiKey?: string;
11
+ /**
12
+ * Base URL of the CIP-309 gateway, e.g. `https://gateway.example.com`.
13
+ * REQUIRED — the client is gateway-agnostic and has no default deployment.
14
+ * Used VERBATIM (a single trailing slash is stripped). A missing or empty
15
+ * value throws `InvalidClientConfigError` from the constructor.
16
+ */
17
+ readonly baseUrl: string;
18
+ /** Optional custom fetch (defaults to `globalThis.fetch`). */
19
+ readonly fetch?: FetchImpl;
20
+ }
21
+ type StorageTarget = 'arweave';
22
+ interface UploadsInput {
23
+ readonly target: StorageTarget;
24
+ /** 1..32 file blobs. Position `i` lands on the response as `uploads[i]`. */
25
+ readonly data: ReadonlyArray<Uint8Array>;
26
+ readonly idempotencyKey?: string;
27
+ }
28
+ interface UploadSuccessEntry {
29
+ readonly idx: number;
30
+ readonly ok: true;
31
+ readonly uri: string;
32
+ readonly sha256: string;
33
+ readonly bytes: number;
34
+ }
35
+ interface UploadFailureEntry {
36
+ readonly idx: number;
37
+ readonly ok: false;
38
+ readonly error: {
39
+ readonly code: string;
40
+ readonly detail: string;
41
+ };
42
+ }
43
+ type UploadEntry = UploadSuccessEntry | UploadFailureEntry;
44
+ interface UploadsResponse {
45
+ readonly uploads: ReadonlyArray<UploadEntry>;
46
+ }
47
+ interface QuoteInput {
48
+ /** Canonical-CBOR record length in bytes (header + items). */
49
+ readonly recordBytes: number;
50
+ /** Number of sealed-PoE recipients (each adds an envelope slot). */
51
+ readonly recipientCount: number;
52
+ /** Sum of all file bytes uploaded for this record (0 for hash-only). */
53
+ readonly fileBytesTotal: number;
54
+ }
55
+ /**
56
+ * An opaque price lock returned by `POST /api/v1/poe/quote`. It is a sealed
57
+ * price token, not a pricing breakdown: pass `quote_id` to `/publish` and
58
+ * surface `amount` / `currency` / `expires_at` to the user. The gateway's
59
+ * pricing internals (FX, margins, per-component costs) are not exposed.
60
+ */
61
+ interface QuoteResponse {
62
+ /** Opaque id of the persisted price lock; pass to /publish. */
63
+ readonly quote_id: string;
64
+ /** Total locked price, as a decimal string (promote to bigint/decimal as needed). */
65
+ readonly amount: string;
66
+ /** Currency the `amount` is denominated in (e.g. ISO 4217 `USD`). */
67
+ readonly currency: string;
68
+ /** ISO8601 expiry timestamp after which the gateway rejects the quote. */
69
+ readonly expires_at: string;
70
+ }
71
+ interface RecordSignature {
72
+ readonly cose_sign1: string;
73
+ readonly cose_key?: string;
74
+ }
75
+ interface PublishInput {
76
+ readonly record: Uint8Array | string;
77
+ /** UUID returned by POST /api/v1/poe/quote. */
78
+ readonly quoteId: string;
79
+ readonly signatures?: ReadonlyArray<RecordSignature>;
80
+ readonly idempotencyKey?: string;
81
+ }
82
+ type PoeStatus = 'submitting' | 'submitted' | 'confirmed' | 'permanent_failure';
83
+ type ConformanceProfile = 'core' | 'signed' | 'sealed' | 'recipient-sealed';
84
+ interface PoeItemResponse {
85
+ readonly item_idx: number;
86
+ readonly hashes: Record<string, string>;
87
+ readonly uris?: ReadonlyArray<string>;
88
+ readonly enc?: Record<string, unknown>;
89
+ }
90
+ interface PublishResponse {
91
+ /** Wire-format prefixed id (`poe_<26-char-crockford-base32>`) of the
92
+ * freshly-inserted `poe_record` row. Stable across the submit→confirm
93
+ * lifecycle; use it to subscribe to live status frames via
94
+ * `GET /api/v1/poe/events/<id>`. */
95
+ readonly id: string;
96
+ readonly tx_hash: string | null;
97
+ readonly status: PoeStatus;
98
+ readonly items_count: number;
99
+ readonly signed: boolean;
100
+ readonly sealed: boolean;
101
+ readonly items: ReadonlyArray<PoeItemResponse>;
102
+ readonly conformance_profile: ConformanceProfile;
103
+ /** Account balance after the debit, USD micro-cents (decimal string). */
104
+ readonly balance_after_usd_micros: string;
105
+ /**
106
+ * `true` when the server returned 200 (dedup hit on the prior submission
107
+ * of an identical record by this account) rather than 202 (freshly
108
+ * enqueued).
109
+ */
110
+ readonly dedup_hit: boolean;
111
+ }
112
+ interface PublishBatchEntry {
113
+ readonly record: Uint8Array | string;
114
+ /** UUID returned by POST /api/v1/poe/quote, scoped to this record. */
115
+ readonly quoteId: string;
116
+ readonly signatures?: ReadonlyArray<RecordSignature>;
117
+ }
118
+ interface PublishBatchInput {
119
+ readonly records: ReadonlyArray<PublishBatchEntry>;
120
+ readonly idempotencyKey?: string;
121
+ }
122
+ interface PublishBatchSuccessEntry {
123
+ readonly record_idx: number;
124
+ readonly id: string;
125
+ readonly tx_hash: string | null;
126
+ readonly status: PoeStatus;
127
+ readonly items_count: number;
128
+ readonly signed: boolean;
129
+ readonly sealed: boolean;
130
+ readonly items: ReadonlyArray<PoeItemResponse>;
131
+ readonly conformance_profile: ConformanceProfile;
132
+ }
133
+ interface PublishBatchFailureError {
134
+ readonly code: string;
135
+ readonly detail: string;
136
+ readonly errors?: ReadonlyArray<{
137
+ readonly field: string;
138
+ readonly code: string;
139
+ readonly detail: string;
140
+ }>;
141
+ readonly extensions?: Record<string, unknown>;
142
+ }
143
+ interface PublishBatchFailureEntry {
144
+ readonly record_idx: number;
145
+ readonly error: PublishBatchFailureError;
146
+ }
147
+ type PublishBatchResultEntry = PublishBatchSuccessEntry | PublishBatchFailureEntry;
148
+ interface PublishBatchResponse {
149
+ readonly results: ReadonlyArray<PublishBatchResultEntry>;
150
+ /** Aggregate balance after every successful debit in the batch. */
151
+ readonly balance_after_usd_micros: string;
152
+ }
153
+ type RecordStatus = 'submitting' | 'confirming' | 'confirmed' | 'failed';
154
+ type RecordScheme = 0 | 1 | 2;
155
+ interface RecordResource {
156
+ readonly tx_hash: string;
157
+ readonly status: RecordStatus | null;
158
+ readonly block_height: number | null;
159
+ readonly block_time: string | null;
160
+ readonly num_confirmations: number;
161
+ readonly scheme: RecordScheme;
162
+ readonly item_count: number;
163
+ readonly signer_ed25519: string | null;
164
+ readonly metadata_cbor_base64: string;
165
+ /** Owner-only — present iff the caller authenticated as the row's owner. */
166
+ readonly account_id?: string;
167
+ }
168
+ interface RecordsListInput {
169
+ /** Opaque pagination cursor — pass back the `next_cursor` from a prior page. */
170
+ readonly cursor?: string | null;
171
+ /** Page size (the gateway may clamp). */
172
+ readonly limit?: number;
173
+ /**
174
+ * When `true`, restrict the page to sealed records addressed to the
175
+ * authenticated caller. When omitted, list every record the caller may read.
176
+ */
177
+ readonly sealed?: boolean;
178
+ }
179
+ interface RecordsListResponse {
180
+ readonly object: 'list';
181
+ readonly data: ReadonlyArray<RecordResource>;
182
+ readonly has_more: boolean;
183
+ readonly next_cursor: string | null;
184
+ readonly url: string;
185
+ /**
186
+ * The chain tip block height observed when this page was served, used to
187
+ * compute confirmation depth during a sealed-record sync.
188
+ *
189
+ * Optional: a gateway that reports it (JSON key `tip_block_height`) populates
190
+ * confirmation data directly; otherwise the SDK derives it from the page rows
191
+ * as `max(block_height + num_confirmations - 1)`, falling back to `null` for
192
+ * an empty page or rows without a block height.
193
+ */
194
+ readonly tip_block_height?: number | null;
195
+ }
196
+ /**
197
+ * The caller's current prepaid USD balance.
198
+ *
199
+ * `balanceUsdMicros` is the gateway's `balance_usd_micros` wire field — the
200
+ * balance in USD micro-cents, carried as a decimal STRING (never a JS number)
201
+ * so the bigint value survives JSON without precision loss. An account with no
202
+ * ledger activity yet reads `"0"`.
203
+ */
204
+ interface AccountBalance {
205
+ readonly balanceUsdMicros: string;
206
+ }
207
+ interface PoeVerifyInput {
208
+ readonly verify_uris?: boolean;
209
+ readonly decryption?: ReadonlyArray<{
210
+ readonly item_idx: number;
211
+ readonly recipient_secret_key?: string;
212
+ readonly passphrase?: string;
213
+ }>;
214
+ }
215
+ /**
216
+ * Pluggable Ed25519 signer for the high-level publish helpers. The SDK does
217
+ * NOT hold identity keys (see the privacy contract in `off-host-sign.ts`); the
218
+ * caller owns the key material and decides how to expose signing — in-memory
219
+ * `@noble/ed25519`,
220
+ * AWS KMS, GCP HSM, YubiHSM, an air-gapped offline signer, or a CIP-30
221
+ * wallet wrapper.
222
+ *
223
+ * `signerPubkey` MUST be the 32-byte raw Ed25519 public key.
224
+ *
225
+ * `sign(sigStructureBytes)` receives the canonical-CBOR
226
+ * `[ "Signature1", protected_bytes, h'' /* empty external_aad *\/, to_sign ]`
227
+ * bytes and MUST return a 64-byte raw Ed25519 signature (NOT a DER-encoded
228
+ * one). This is byte-identical to the input accepted by AWS KMS `Sign` for
229
+ * Ed25519 keys.
230
+ */
231
+ interface Signer {
232
+ readonly signerPubkey: Uint8Array;
233
+ sign(sigStructureBytes: Uint8Array): Promise<Uint8Array>;
234
+ }
235
+ type SupportedHashAlg = 'sha2-256' | 'blake2b-256';
236
+ interface PublishContentInput {
237
+ /** Content bytes to anchor. Strings are UTF-8 encoded before hashing. */
238
+ readonly content: Uint8Array | string;
239
+ /** UUID returned by POST /api/v1/poe/quote. */
240
+ readonly quoteId: string;
241
+ /** Hash algorithm registered in the CIP-309 hash registry. */
242
+ readonly hashAlg?: SupportedHashAlg;
243
+ /** Optional signer — when omitted the record publishes unsigned (profile=core). */
244
+ readonly signer?: Signer;
245
+ readonly idempotencyKey?: string;
246
+ }
247
+ /**
248
+ * Hash-already-computed variant. Use when the caller already holds the
249
+ * content digest (`sha2-256` and/or `blake2b-256`) — e.g. the CLI's `--hash`
250
+ * mode, an air-gapped offline hashing flow, or a system that proxies digests
251
+ * from another tool. The SDK does not re-hash; it constructs a single-item
252
+ * record with the supplied digests in `items[0].hashes` and (optionally)
253
+ * signs.
254
+ */
255
+ interface PublishPrehashedInput {
256
+ readonly hashes: Partial<Record<SupportedHashAlg, string>>;
257
+ /** UUID returned by POST /api/v1/poe/quote. */
258
+ readonly quoteId: string;
259
+ readonly signer?: Signer;
260
+ readonly idempotencyKey?: string;
261
+ }
262
+ /**
263
+ * Sealed-PoE helper input. Encrypts `content` to the supplied X25519
264
+ * recipient public keys (age-style sealed envelope), uploads the ciphertext
265
+ * to Arweave via /uploads, builds a CIP-309 record with the resulting
266
+ * `ar://` URI in `items[0].uris`, optionally signs it, and submits to
267
+ * /publish.
268
+ *
269
+ * Each recipient public key is a 32-byte raw X25519 public key. At least
270
+ * one recipient is required; the sender SHOULD include themselves as a
271
+ * recipient to retain decrypt access.
272
+ */
273
+ interface PublishSealedInput {
274
+ readonly content: Uint8Array | string;
275
+ /**
276
+ * Recipient public keys. The length each key MUST be matches the chosen
277
+ * `kem`: 32 bytes for `x25519`, 1216 bytes for `mlkem768x25519` (X-Wing).
278
+ */
279
+ readonly recipients: ReadonlyArray<Uint8Array>;
280
+ /** UUID returned by POST /api/v1/poe/quote. */
281
+ readonly quoteId: string;
282
+ /** Hash algorithm for the plaintext-bind hash in `items[0].hashes`. */
283
+ readonly hashAlg?: SupportedHashAlg;
284
+ /**
285
+ * KEM the sealed envelope is built under. Defaults to `mlkem768x25519`
286
+ * (X-Wing hybrid, ML-KEM-768 + X25519) — the post-quantum-safe choice. Pass
287
+ * `x25519` only for the classical, higher-capacity path. Every recipient MUST
288
+ * be addressed under this single KEM; mixing is not permitted.
289
+ */
290
+ readonly kem?: 'x25519' | 'mlkem768x25519';
291
+ readonly signer?: Signer;
292
+ readonly idempotencyKey?: string;
293
+ }
294
+ interface PublishMerkleInput {
295
+ /**
296
+ * Leaf hashes — either raw 32-byte Uint8Array digests or hex-encoded
297
+ * strings (64 chars, case-insensitive). Tree size is `leaves.length`.
298
+ */
299
+ readonly leaves: ReadonlyArray<Uint8Array | string>;
300
+ /** UUID returned by POST /api/v1/poe/quote. */
301
+ readonly quoteId: string;
302
+ /**
303
+ * Leaf-hash algorithm. Only `'sha2-256'` is supported in v1 because the
304
+ * single registered tree algorithm is `rfc9162-sha256` (SHA-256 underlying).
305
+ */
306
+ readonly hashAlg?: 'sha2-256';
307
+ readonly signer?: Signer;
308
+ readonly idempotencyKey?: string;
309
+ }
310
+ interface PublishMerkleResponse {
311
+ readonly id: string;
312
+ readonly tx_hash: string | null;
313
+ readonly status: PoeStatus;
314
+ readonly root: string;
315
+ readonly leaf_count: number;
316
+ readonly ar_uri: string;
317
+ /** Account balance after the debit, USD micro-cents (decimal string). */
318
+ readonly balance_after_usd_micros: string;
319
+ }
320
+
321
+ export type { AccountBalance as A, UploadSuccessEntry as B, Cip309ClientConfig as C, UploadsInput as D, UploadsResponse as E, FetchImpl as F, PoeItemResponse as P, QuoteInput as Q, RecordResource as R, Signer as S, UploadEntry as U, ConformanceProfile as a, PoeStatus as b, PoeVerifyInput as c, PublishBatchEntry as d, PublishBatchFailureEntry as e, PublishBatchFailureError as f, PublishBatchInput as g, PublishBatchResponse as h, PublishBatchResultEntry as i, PublishBatchSuccessEntry as j, PublishContentInput as k, PublishInput as l, PublishMerkleInput as m, PublishMerkleResponse as n, PublishPrehashedInput as o, PublishResponse as p, PublishSealedInput as q, QuoteResponse as r, RecordScheme as s, RecordSignature as t, RecordStatus as u, RecordsListInput as v, RecordsListResponse as w, StorageTarget as x, SupportedHashAlg as y, UploadFailureEntry as z };
@@ -0,0 +1,321 @@
1
+ type FetchImpl = (input: string | URL, init?: RequestInit) => Promise<Response>;
2
+ interface Cip309ClientConfig {
3
+ /**
4
+ * Bearer credential, forwarded verbatim as `Authorization: Bearer <apiKey>`.
5
+ *
6
+ * Treated as an OPAQUE token: the SDK never parses, validates, or infers
7
+ * anything from it, since each CIP-309 gateway issues keys in its own format.
8
+ * Omit for anonymous read-only usage.
9
+ */
10
+ readonly apiKey?: string;
11
+ /**
12
+ * Base URL of the CIP-309 gateway, e.g. `https://gateway.example.com`.
13
+ * REQUIRED — the client is gateway-agnostic and has no default deployment.
14
+ * Used VERBATIM (a single trailing slash is stripped). A missing or empty
15
+ * value throws `InvalidClientConfigError` from the constructor.
16
+ */
17
+ readonly baseUrl: string;
18
+ /** Optional custom fetch (defaults to `globalThis.fetch`). */
19
+ readonly fetch?: FetchImpl;
20
+ }
21
+ type StorageTarget = 'arweave';
22
+ interface UploadsInput {
23
+ readonly target: StorageTarget;
24
+ /** 1..32 file blobs. Position `i` lands on the response as `uploads[i]`. */
25
+ readonly data: ReadonlyArray<Uint8Array>;
26
+ readonly idempotencyKey?: string;
27
+ }
28
+ interface UploadSuccessEntry {
29
+ readonly idx: number;
30
+ readonly ok: true;
31
+ readonly uri: string;
32
+ readonly sha256: string;
33
+ readonly bytes: number;
34
+ }
35
+ interface UploadFailureEntry {
36
+ readonly idx: number;
37
+ readonly ok: false;
38
+ readonly error: {
39
+ readonly code: string;
40
+ readonly detail: string;
41
+ };
42
+ }
43
+ type UploadEntry = UploadSuccessEntry | UploadFailureEntry;
44
+ interface UploadsResponse {
45
+ readonly uploads: ReadonlyArray<UploadEntry>;
46
+ }
47
+ interface QuoteInput {
48
+ /** Canonical-CBOR record length in bytes (header + items). */
49
+ readonly recordBytes: number;
50
+ /** Number of sealed-PoE recipients (each adds an envelope slot). */
51
+ readonly recipientCount: number;
52
+ /** Sum of all file bytes uploaded for this record (0 for hash-only). */
53
+ readonly fileBytesTotal: number;
54
+ }
55
+ /**
56
+ * An opaque price lock returned by `POST /api/v1/poe/quote`. It is a sealed
57
+ * price token, not a pricing breakdown: pass `quote_id` to `/publish` and
58
+ * surface `amount` / `currency` / `expires_at` to the user. The gateway's
59
+ * pricing internals (FX, margins, per-component costs) are not exposed.
60
+ */
61
+ interface QuoteResponse {
62
+ /** Opaque id of the persisted price lock; pass to /publish. */
63
+ readonly quote_id: string;
64
+ /** Total locked price, as a decimal string (promote to bigint/decimal as needed). */
65
+ readonly amount: string;
66
+ /** Currency the `amount` is denominated in (e.g. ISO 4217 `USD`). */
67
+ readonly currency: string;
68
+ /** ISO8601 expiry timestamp after which the gateway rejects the quote. */
69
+ readonly expires_at: string;
70
+ }
71
+ interface RecordSignature {
72
+ readonly cose_sign1: string;
73
+ readonly cose_key?: string;
74
+ }
75
+ interface PublishInput {
76
+ readonly record: Uint8Array | string;
77
+ /** UUID returned by POST /api/v1/poe/quote. */
78
+ readonly quoteId: string;
79
+ readonly signatures?: ReadonlyArray<RecordSignature>;
80
+ readonly idempotencyKey?: string;
81
+ }
82
+ type PoeStatus = 'submitting' | 'submitted' | 'confirmed' | 'permanent_failure';
83
+ type ConformanceProfile = 'core' | 'signed' | 'sealed' | 'recipient-sealed';
84
+ interface PoeItemResponse {
85
+ readonly item_idx: number;
86
+ readonly hashes: Record<string, string>;
87
+ readonly uris?: ReadonlyArray<string>;
88
+ readonly enc?: Record<string, unknown>;
89
+ }
90
+ interface PublishResponse {
91
+ /** Wire-format prefixed id (`poe_<26-char-crockford-base32>`) of the
92
+ * freshly-inserted `poe_record` row. Stable across the submit→confirm
93
+ * lifecycle; use it to subscribe to live status frames via
94
+ * `GET /api/v1/poe/events/<id>`. */
95
+ readonly id: string;
96
+ readonly tx_hash: string | null;
97
+ readonly status: PoeStatus;
98
+ readonly items_count: number;
99
+ readonly signed: boolean;
100
+ readonly sealed: boolean;
101
+ readonly items: ReadonlyArray<PoeItemResponse>;
102
+ readonly conformance_profile: ConformanceProfile;
103
+ /** Account balance after the debit, USD micro-cents (decimal string). */
104
+ readonly balance_after_usd_micros: string;
105
+ /**
106
+ * `true` when the server returned 200 (dedup hit on the prior submission
107
+ * of an identical record by this account) rather than 202 (freshly
108
+ * enqueued).
109
+ */
110
+ readonly dedup_hit: boolean;
111
+ }
112
+ interface PublishBatchEntry {
113
+ readonly record: Uint8Array | string;
114
+ /** UUID returned by POST /api/v1/poe/quote, scoped to this record. */
115
+ readonly quoteId: string;
116
+ readonly signatures?: ReadonlyArray<RecordSignature>;
117
+ }
118
+ interface PublishBatchInput {
119
+ readonly records: ReadonlyArray<PublishBatchEntry>;
120
+ readonly idempotencyKey?: string;
121
+ }
122
+ interface PublishBatchSuccessEntry {
123
+ readonly record_idx: number;
124
+ readonly id: string;
125
+ readonly tx_hash: string | null;
126
+ readonly status: PoeStatus;
127
+ readonly items_count: number;
128
+ readonly signed: boolean;
129
+ readonly sealed: boolean;
130
+ readonly items: ReadonlyArray<PoeItemResponse>;
131
+ readonly conformance_profile: ConformanceProfile;
132
+ }
133
+ interface PublishBatchFailureError {
134
+ readonly code: string;
135
+ readonly detail: string;
136
+ readonly errors?: ReadonlyArray<{
137
+ readonly field: string;
138
+ readonly code: string;
139
+ readonly detail: string;
140
+ }>;
141
+ readonly extensions?: Record<string, unknown>;
142
+ }
143
+ interface PublishBatchFailureEntry {
144
+ readonly record_idx: number;
145
+ readonly error: PublishBatchFailureError;
146
+ }
147
+ type PublishBatchResultEntry = PublishBatchSuccessEntry | PublishBatchFailureEntry;
148
+ interface PublishBatchResponse {
149
+ readonly results: ReadonlyArray<PublishBatchResultEntry>;
150
+ /** Aggregate balance after every successful debit in the batch. */
151
+ readonly balance_after_usd_micros: string;
152
+ }
153
+ type RecordStatus = 'submitting' | 'confirming' | 'confirmed' | 'failed';
154
+ type RecordScheme = 0 | 1 | 2;
155
+ interface RecordResource {
156
+ readonly tx_hash: string;
157
+ readonly status: RecordStatus | null;
158
+ readonly block_height: number | null;
159
+ readonly block_time: string | null;
160
+ readonly num_confirmations: number;
161
+ readonly scheme: RecordScheme;
162
+ readonly item_count: number;
163
+ readonly signer_ed25519: string | null;
164
+ readonly metadata_cbor_base64: string;
165
+ /** Owner-only — present iff the caller authenticated as the row's owner. */
166
+ readonly account_id?: string;
167
+ }
168
+ interface RecordsListInput {
169
+ /** Opaque pagination cursor — pass back the `next_cursor` from a prior page. */
170
+ readonly cursor?: string | null;
171
+ /** Page size (the gateway may clamp). */
172
+ readonly limit?: number;
173
+ /**
174
+ * When `true`, restrict the page to sealed records addressed to the
175
+ * authenticated caller. When omitted, list every record the caller may read.
176
+ */
177
+ readonly sealed?: boolean;
178
+ }
179
+ interface RecordsListResponse {
180
+ readonly object: 'list';
181
+ readonly data: ReadonlyArray<RecordResource>;
182
+ readonly has_more: boolean;
183
+ readonly next_cursor: string | null;
184
+ readonly url: string;
185
+ /**
186
+ * The chain tip block height observed when this page was served, used to
187
+ * compute confirmation depth during a sealed-record sync.
188
+ *
189
+ * Optional: a gateway that reports it (JSON key `tip_block_height`) populates
190
+ * confirmation data directly; otherwise the SDK derives it from the page rows
191
+ * as `max(block_height + num_confirmations - 1)`, falling back to `null` for
192
+ * an empty page or rows without a block height.
193
+ */
194
+ readonly tip_block_height?: number | null;
195
+ }
196
+ /**
197
+ * The caller's current prepaid USD balance.
198
+ *
199
+ * `balanceUsdMicros` is the gateway's `balance_usd_micros` wire field — the
200
+ * balance in USD micro-cents, carried as a decimal STRING (never a JS number)
201
+ * so the bigint value survives JSON without precision loss. An account with no
202
+ * ledger activity yet reads `"0"`.
203
+ */
204
+ interface AccountBalance {
205
+ readonly balanceUsdMicros: string;
206
+ }
207
+ interface PoeVerifyInput {
208
+ readonly verify_uris?: boolean;
209
+ readonly decryption?: ReadonlyArray<{
210
+ readonly item_idx: number;
211
+ readonly recipient_secret_key?: string;
212
+ readonly passphrase?: string;
213
+ }>;
214
+ }
215
+ /**
216
+ * Pluggable Ed25519 signer for the high-level publish helpers. The SDK does
217
+ * NOT hold identity keys (see the privacy contract in `off-host-sign.ts`); the
218
+ * caller owns the key material and decides how to expose signing — in-memory
219
+ * `@noble/ed25519`,
220
+ * AWS KMS, GCP HSM, YubiHSM, an air-gapped offline signer, or a CIP-30
221
+ * wallet wrapper.
222
+ *
223
+ * `signerPubkey` MUST be the 32-byte raw Ed25519 public key.
224
+ *
225
+ * `sign(sigStructureBytes)` receives the canonical-CBOR
226
+ * `[ "Signature1", protected_bytes, h'' /* empty external_aad *\/, to_sign ]`
227
+ * bytes and MUST return a 64-byte raw Ed25519 signature (NOT a DER-encoded
228
+ * one). This is byte-identical to the input accepted by AWS KMS `Sign` for
229
+ * Ed25519 keys.
230
+ */
231
+ interface Signer {
232
+ readonly signerPubkey: Uint8Array;
233
+ sign(sigStructureBytes: Uint8Array): Promise<Uint8Array>;
234
+ }
235
+ type SupportedHashAlg = 'sha2-256' | 'blake2b-256';
236
+ interface PublishContentInput {
237
+ /** Content bytes to anchor. Strings are UTF-8 encoded before hashing. */
238
+ readonly content: Uint8Array | string;
239
+ /** UUID returned by POST /api/v1/poe/quote. */
240
+ readonly quoteId: string;
241
+ /** Hash algorithm registered in the CIP-309 hash registry. */
242
+ readonly hashAlg?: SupportedHashAlg;
243
+ /** Optional signer — when omitted the record publishes unsigned (profile=core). */
244
+ readonly signer?: Signer;
245
+ readonly idempotencyKey?: string;
246
+ }
247
+ /**
248
+ * Hash-already-computed variant. Use when the caller already holds the
249
+ * content digest (`sha2-256` and/or `blake2b-256`) — e.g. the CLI's `--hash`
250
+ * mode, an air-gapped offline hashing flow, or a system that proxies digests
251
+ * from another tool. The SDK does not re-hash; it constructs a single-item
252
+ * record with the supplied digests in `items[0].hashes` and (optionally)
253
+ * signs.
254
+ */
255
+ interface PublishPrehashedInput {
256
+ readonly hashes: Partial<Record<SupportedHashAlg, string>>;
257
+ /** UUID returned by POST /api/v1/poe/quote. */
258
+ readonly quoteId: string;
259
+ readonly signer?: Signer;
260
+ readonly idempotencyKey?: string;
261
+ }
262
+ /**
263
+ * Sealed-PoE helper input. Encrypts `content` to the supplied X25519
264
+ * recipient public keys (age-style sealed envelope), uploads the ciphertext
265
+ * to Arweave via /uploads, builds a CIP-309 record with the resulting
266
+ * `ar://` URI in `items[0].uris`, optionally signs it, and submits to
267
+ * /publish.
268
+ *
269
+ * Each recipient public key is a 32-byte raw X25519 public key. At least
270
+ * one recipient is required; the sender SHOULD include themselves as a
271
+ * recipient to retain decrypt access.
272
+ */
273
+ interface PublishSealedInput {
274
+ readonly content: Uint8Array | string;
275
+ /**
276
+ * Recipient public keys. The length each key MUST be matches the chosen
277
+ * `kem`: 32 bytes for `x25519`, 1216 bytes for `mlkem768x25519` (X-Wing).
278
+ */
279
+ readonly recipients: ReadonlyArray<Uint8Array>;
280
+ /** UUID returned by POST /api/v1/poe/quote. */
281
+ readonly quoteId: string;
282
+ /** Hash algorithm for the plaintext-bind hash in `items[0].hashes`. */
283
+ readonly hashAlg?: SupportedHashAlg;
284
+ /**
285
+ * KEM the sealed envelope is built under. Defaults to `mlkem768x25519`
286
+ * (X-Wing hybrid, ML-KEM-768 + X25519) — the post-quantum-safe choice. Pass
287
+ * `x25519` only for the classical, higher-capacity path. Every recipient MUST
288
+ * be addressed under this single KEM; mixing is not permitted.
289
+ */
290
+ readonly kem?: 'x25519' | 'mlkem768x25519';
291
+ readonly signer?: Signer;
292
+ readonly idempotencyKey?: string;
293
+ }
294
+ interface PublishMerkleInput {
295
+ /**
296
+ * Leaf hashes — either raw 32-byte Uint8Array digests or hex-encoded
297
+ * strings (64 chars, case-insensitive). Tree size is `leaves.length`.
298
+ */
299
+ readonly leaves: ReadonlyArray<Uint8Array | string>;
300
+ /** UUID returned by POST /api/v1/poe/quote. */
301
+ readonly quoteId: string;
302
+ /**
303
+ * Leaf-hash algorithm. Only `'sha2-256'` is supported in v1 because the
304
+ * single registered tree algorithm is `rfc9162-sha256` (SHA-256 underlying).
305
+ */
306
+ readonly hashAlg?: 'sha2-256';
307
+ readonly signer?: Signer;
308
+ readonly idempotencyKey?: string;
309
+ }
310
+ interface PublishMerkleResponse {
311
+ readonly id: string;
312
+ readonly tx_hash: string | null;
313
+ readonly status: PoeStatus;
314
+ readonly root: string;
315
+ readonly leaf_count: number;
316
+ readonly ar_uri: string;
317
+ /** Account balance after the debit, USD micro-cents (decimal string). */
318
+ readonly balance_after_usd_micros: string;
319
+ }
320
+
321
+ export type { AccountBalance as A, UploadSuccessEntry as B, Cip309ClientConfig as C, UploadsInput as D, UploadsResponse as E, FetchImpl as F, PoeItemResponse as P, QuoteInput as Q, RecordResource as R, Signer as S, UploadEntry as U, ConformanceProfile as a, PoeStatus as b, PoeVerifyInput as c, PublishBatchEntry as d, PublishBatchFailureEntry as e, PublishBatchFailureError as f, PublishBatchInput as g, PublishBatchResponse as h, PublishBatchResultEntry as i, PublishBatchSuccessEntry as j, PublishContentInput as k, PublishInput as l, PublishMerkleInput as m, PublishMerkleResponse as n, PublishPrehashedInput as o, PublishResponse as p, PublishSealedInput as q, QuoteResponse as r, RecordScheme as s, RecordSignature as t, RecordStatus as u, RecordsListInput as v, RecordsListResponse as w, StorageTarget as x, SupportedHashAlg as y, UploadFailureEntry as z };