@inversealtruism/cairn-sdk 0.5.0 → 0.7.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/index.d.cts CHANGED
@@ -5,9 +5,8 @@ import { IndexerClient } from './indexer.cjs';
5
5
  export { InclusionResult, IndexEvent, MerkleProof, StreamHandle, StreamHandlers, TrustLevel } from './indexer.cjs';
6
6
  import { ContentClient } from './content.cjs';
7
7
  export { ContentClientOptions, PreparedContent } from './content.cjs';
8
- import { RegistryClient } from './registry.cjs';
9
- import { NameState, ProvenOfferTerms } from '@inversealtruism/cairnx-core';
10
- export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
8
+ import { NameState, MintedProvenOfferTerms } from '@inversealtruism/cairnx-core';
9
+ export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, MintedProvenOfferTerms, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
11
10
  import { WalletConnection, DetectOptions } from './connect.cjs';
12
11
  export { AttestParams, CairnProvider, ConnectResult, FillParams, ProposeParams, ProviderDetail, ProviderInfo, SealClaimParams, SendParams, SignInResult, SiwcParams, SiwcResult, TxResult, WalletCapabilities, WalletPermission, connect, detectProvider, discoverProviders, getWallet, isInstalled } from './connect.cjs';
13
12
  import { InclusionResult } from '@inversealtruism/csd-light';
@@ -16,7 +15,6 @@ import '@inversealtruism/csd-client';
16
15
  import '@inversealtruism/csd-tx';
17
16
  import '@inversealtruism/csd-codec';
18
17
  import '@inversealtruism/csd-crypto';
19
- import '@inversealtruism/csd-registry';
20
18
 
21
19
  /** `/cairnx/resolve/:name` — the display-path name→address resolution. */
22
20
  interface NameResolution {
@@ -139,7 +137,8 @@ interface OfferFillCheck {
139
137
  transient?: boolean;
140
138
  payto?: string;
141
139
  seller?: string;
142
- terms?: ProvenOfferTerms;
140
+ /** Minted by cairnx-core's `provenOfferTerms`, so it can be passed back to `bindOfferTerms` without the opt-out. */
141
+ terms?: MintedProvenOfferTerms;
143
142
  blockHeight?: number;
144
143
  /** B7b (REBIND W3/M1): the PROVEN CSD outputs to build for `pay` (a WHOLE fill of a non-partial offer),
145
144
  * sized from the merkle-proven offer by the single-sourced `fillOutputPlan`. Present only when `pay` was
@@ -190,7 +189,7 @@ declare function preverifyOffer(opts: {
190
189
 
191
190
  /** Stable machine-readable error codes (branch on these, not the message text). */
192
191
  type CairnErrorCode = "NOT_INSTALLED" | "USER_REJECTED" | "WALLET_LOCKED" | "UNSUPPORTED_METHOD" | "HTTP_ERROR" | "CONTENT_VERIFICATION" | "CONTENT_NOT_JSON" | "ACCOUNT_CHANGED" | "FIRST_PARTY_ONLY" | "RATE_LIMITED" | "APPROVAL_CLOSED" | "FORBIDDEN" | "INTERNAL" | "GHOST_INPUTS_SKIPPED" | "VERIFY_UNAVAILABLE" | "VERIFY_TAMPER" | "INSUFFICIENT" | "TOO_MANY_INPUTS" | "FEE_TOO_LOW" | "FEE_CAP" | "BAD_FEE" | "ZERO_ADDR_REFUSED" | "BAD_OUTPUTS" | "NO_OUTPUTS" | "BAD_REQUEST" | "OFFER_UNKNOWN" | "FILL_UNSAFE" | "FILL_WRONG_TARGET" | "SOURCE_DIVERGENCE" | "SUBMIT_REJECTED" | "SUBMIT_MAYBE_INFLIGHT" | "SUBMIT_DUPLICATE" | "NOTHING_TO_CONSOLIDATE" | "OFFER_SOURCE_CONFLICT" | "FILL_LEGACY_SUNSET" | "VERIFY_HORIZON" | "VERIFY_UNREPRESENTABLE" | "WALLET_UNAVAILABLE" | "REVIEW_REQUIRED" | "UNKNOWN";
193
- declare const SDK_VERSION = "0.5.0";
192
+ declare const SDK_VERSION = "0.7.0";
194
193
  interface CairnErrorOptions {
195
194
  code?: CairnErrorCode;
196
195
  docsPath?: string;
@@ -210,7 +209,7 @@ declare class CairnError extends Error {
210
209
  /** Relative docs path (under the SDK docs base), if any. */
211
210
  readonly docsPath?: string;
212
211
  /** The cairn-sdk version that produced this error. */
213
- readonly version = "0.5.0";
212
+ readonly version = "0.7.0";
214
213
  /**
215
214
  * Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
216
215
  * declines (the default); `true` only for provably transient infra faults where nothing was signed.
@@ -301,12 +300,6 @@ interface CairnBaseUrls {
301
300
  * needs a direct indexer endpoint (set this to a localhost/private indexer URL).
302
301
  */
303
302
  indexer?: string;
304
- /**
305
- * Optional direct csd-swarm gateway base. Not set by default — content is reached
306
- * via the indexer proxy (which fronts the swarm) and the cairn origin, both verified.
307
- * Set this only if you run a public swarm gateway.
308
- */
309
- swarm?: string;
310
303
  }
311
304
  interface CairnConfig {
312
305
  /** Currently only "mainnet". Selects the default base URLs. */
@@ -342,7 +335,6 @@ declare class Cairn {
342
335
  readonly chain: Chain;
343
336
  readonly index: IndexerClient;
344
337
  readonly content: ContentClient;
345
- readonly registry: RegistryClient;
346
338
  /** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
347
339
  readonly names: NamesClient;
348
340
  wallet?: WalletConnection;
@@ -423,4 +415,4 @@ declare class Cairn {
423
415
  get connected(): boolean;
424
416
  }
425
417
 
426
- export { Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameHistory, type NameHistoryEntry, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, RegistryClient, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
418
+ export { Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameHistory, type NameHistoryEntry, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
package/dist/index.d.ts CHANGED
@@ -5,9 +5,8 @@ import { IndexerClient } from './indexer.js';
5
5
  export { InclusionResult, IndexEvent, MerkleProof, StreamHandle, StreamHandlers, TrustLevel } from './indexer.js';
6
6
  import { ContentClient } from './content.js';
7
7
  export { ContentClientOptions, PreparedContent } from './content.js';
8
- import { RegistryClient } from './registry.js';
9
- import { NameState, ProvenOfferTerms } from '@inversealtruism/cairnx-core';
10
- export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
8
+ import { NameState, MintedProvenOfferTerms } from '@inversealtruism/cairnx-core';
9
+ export { FillEndorsement, FillOutputPlan, FillPreview, FillSafety, MintedProvenOfferTerms, ProvenOfferTerms, bindOfferTerms, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, previewFill, requiredFillOutputs } from '@inversealtruism/cairnx-core';
11
10
  import { WalletConnection, DetectOptions } from './connect.js';
12
11
  export { AttestParams, CairnProvider, ConnectResult, FillParams, ProposeParams, ProviderDetail, ProviderInfo, SealClaimParams, SendParams, SignInResult, SiwcParams, SiwcResult, TxResult, WalletCapabilities, WalletPermission, connect, detectProvider, discoverProviders, getWallet, isInstalled } from './connect.js';
13
12
  import { InclusionResult } from '@inversealtruism/csd-light';
@@ -16,7 +15,6 @@ import '@inversealtruism/csd-client';
16
15
  import '@inversealtruism/csd-tx';
17
16
  import '@inversealtruism/csd-codec';
18
17
  import '@inversealtruism/csd-crypto';
19
- import '@inversealtruism/csd-registry';
20
18
 
21
19
  /** `/cairnx/resolve/:name` — the display-path name→address resolution. */
22
20
  interface NameResolution {
@@ -139,7 +137,8 @@ interface OfferFillCheck {
139
137
  transient?: boolean;
140
138
  payto?: string;
141
139
  seller?: string;
142
- terms?: ProvenOfferTerms;
140
+ /** Minted by cairnx-core's `provenOfferTerms`, so it can be passed back to `bindOfferTerms` without the opt-out. */
141
+ terms?: MintedProvenOfferTerms;
143
142
  blockHeight?: number;
144
143
  /** B7b (REBIND W3/M1): the PROVEN CSD outputs to build for `pay` (a WHOLE fill of a non-partial offer),
145
144
  * sized from the merkle-proven offer by the single-sourced `fillOutputPlan`. Present only when `pay` was
@@ -190,7 +189,7 @@ declare function preverifyOffer(opts: {
190
189
 
191
190
  /** Stable machine-readable error codes (branch on these, not the message text). */
192
191
  type CairnErrorCode = "NOT_INSTALLED" | "USER_REJECTED" | "WALLET_LOCKED" | "UNSUPPORTED_METHOD" | "HTTP_ERROR" | "CONTENT_VERIFICATION" | "CONTENT_NOT_JSON" | "ACCOUNT_CHANGED" | "FIRST_PARTY_ONLY" | "RATE_LIMITED" | "APPROVAL_CLOSED" | "FORBIDDEN" | "INTERNAL" | "GHOST_INPUTS_SKIPPED" | "VERIFY_UNAVAILABLE" | "VERIFY_TAMPER" | "INSUFFICIENT" | "TOO_MANY_INPUTS" | "FEE_TOO_LOW" | "FEE_CAP" | "BAD_FEE" | "ZERO_ADDR_REFUSED" | "BAD_OUTPUTS" | "NO_OUTPUTS" | "BAD_REQUEST" | "OFFER_UNKNOWN" | "FILL_UNSAFE" | "FILL_WRONG_TARGET" | "SOURCE_DIVERGENCE" | "SUBMIT_REJECTED" | "SUBMIT_MAYBE_INFLIGHT" | "SUBMIT_DUPLICATE" | "NOTHING_TO_CONSOLIDATE" | "OFFER_SOURCE_CONFLICT" | "FILL_LEGACY_SUNSET" | "VERIFY_HORIZON" | "VERIFY_UNREPRESENTABLE" | "WALLET_UNAVAILABLE" | "REVIEW_REQUIRED" | "UNKNOWN";
193
- declare const SDK_VERSION = "0.5.0";
192
+ declare const SDK_VERSION = "0.7.0";
194
193
  interface CairnErrorOptions {
195
194
  code?: CairnErrorCode;
196
195
  docsPath?: string;
@@ -210,7 +209,7 @@ declare class CairnError extends Error {
210
209
  /** Relative docs path (under the SDK docs base), if any. */
211
210
  readonly docsPath?: string;
212
211
  /** The cairn-sdk version that produced this error. */
213
- readonly version = "0.5.0";
212
+ readonly version = "0.7.0";
214
213
  /**
215
214
  * Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
216
215
  * declines (the default); `true` only for provably transient infra faults where nothing was signed.
@@ -301,12 +300,6 @@ interface CairnBaseUrls {
301
300
  * needs a direct indexer endpoint (set this to a localhost/private indexer URL).
302
301
  */
303
302
  indexer?: string;
304
- /**
305
- * Optional direct csd-swarm gateway base. Not set by default — content is reached
306
- * via the indexer proxy (which fronts the swarm) and the cairn origin, both verified.
307
- * Set this only if you run a public swarm gateway.
308
- */
309
- swarm?: string;
310
303
  }
311
304
  interface CairnConfig {
312
305
  /** Currently only "mainnet". Selects the default base URLs. */
@@ -342,7 +335,6 @@ declare class Cairn {
342
335
  readonly chain: Chain;
343
336
  readonly index: IndexerClient;
344
337
  readonly content: ContentClient;
345
- readonly registry: RegistryClient;
346
338
  /** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
347
339
  readonly names: NamesClient;
348
340
  wallet?: WalletConnection;
@@ -423,4 +415,4 @@ declare class Cairn {
423
415
  get connected(): boolean;
424
416
  }
425
417
 
426
- export { Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameHistory, type NameHistoryEntry, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, RegistryClient, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
418
+ export { Cairn, type CairnBaseUrls, type CairnConfig, CairnError, type CairnErrorCode, type CairnErrorOptions, Chain, ContentClient, ContentVerificationError, DEFAULT_SPV_CHECKPOINT, DetectOptions, FetchLike, Http, HttpError, IndexerClient, type NameDetail, type NameHistory, type NameHistoryEntry, type NameResolution, NamesClient, NotInstalledError, type OfferFillCheck, type PrimaryName, SDK_VERSION, SubmitInFlightError, type TokenInfo, UnsupportedMethodError, UserRejectedError, WalletConnection, WalletLockedError, errorCode, mapProviderError, mapSubmitResultError, preverifyOffer };
package/dist/index.js CHANGED
@@ -4,13 +4,13 @@ import {
4
4
  } from "./chunk-C452UODV.js";
5
5
  import {
6
6
  ContentClient
7
- } from "./chunk-CZAQNZZG.js";
7
+ } from "./chunk-TDXGYP3G.js";
8
8
  import {
9
9
  IndexerClient
10
- } from "./chunk-K5MGEYEU.js";
10
+ } from "./chunk-CI7YODPP.js";
11
11
  import {
12
12
  CairnController
13
- } from "./chunk-OE5BEEQY.js";
13
+ } from "./chunk-XOGOSGC6.js";
14
14
  import {
15
15
  WalletConnection,
16
16
  connect,
@@ -18,14 +18,7 @@ import {
18
18
  discoverProviders,
19
19
  getWallet,
20
20
  isInstalled
21
- } from "./chunk-5RGFC2JR.js";
22
- import {
23
- Http,
24
- RegistryClient,
25
- RetryWaitBudget,
26
- readCapped,
27
- retryAfterMs
28
- } from "./chunk-BL6VFALH.js";
21
+ } from "./chunk-4FFLCCL4.js";
29
22
  import {
30
23
  CairnError,
31
24
  ContentVerificationError,
@@ -39,7 +32,175 @@ import {
39
32
  errorCode,
40
33
  mapProviderError,
41
34
  mapSubmitResultError
42
- } from "./chunk-OSPAN7GX.js";
35
+ } from "./chunk-PBKDSDID.js";
36
+
37
+ // src/http.ts
38
+ var DEFAULT_MAX_BYTES = 16 * 1024 * 1024;
39
+ var ERR_TEXT_CAP = 8 * 1024;
40
+ var MAX_RETRY_AFTER_MS = 6e4;
41
+ function retryAfterMs(res) {
42
+ const secs = Number(res.headers.get("retry-after"));
43
+ return Number.isFinite(secs) && secs > 0 ? Math.min(secs * 1e3, MAX_RETRY_AFTER_MS) : 0;
44
+ }
45
+ var RetryWaitBudget = class {
46
+ left;
47
+ constructor(totalMs) {
48
+ this.left = totalMs;
49
+ }
50
+ /** The ms to sleep before the next attempt (`ownMs` is the caller's backoff, clipped to what is left), or
51
+ * null when the server's hint exceeds the remaining budget. */
52
+ take(ownMs, serverMs) {
53
+ if (serverMs > this.left) return null;
54
+ const ms = Math.min(Math.max(ownMs, serverMs), this.left);
55
+ this.left -= ms;
56
+ return ms;
57
+ }
58
+ };
59
+ var HTTP_RETRY_WAIT_BUDGET_MS = 3e4;
60
+ async function readCapped(res, maxBytes) {
61
+ const cl = Number(res.headers.get("content-length"));
62
+ if (Number.isFinite(cl) && cl > maxBytes) throw new HttpError(res.status, res.url, `response too large (content-length ${cl} > ${maxBytes})`);
63
+ const body = res.body;
64
+ if (!body || typeof body.getReader !== "function") {
65
+ const buf = new Uint8Array(await res.arrayBuffer());
66
+ if (buf.byteLength > maxBytes) throw new HttpError(res.status, res.url, `response too large (${buf.byteLength} > ${maxBytes})`);
67
+ return buf;
68
+ }
69
+ const reader = body.getReader();
70
+ const chunks = [];
71
+ let total = 0;
72
+ for (; ; ) {
73
+ const { done, value } = await reader.read();
74
+ if (done) break;
75
+ if (value) {
76
+ total += value.byteLength;
77
+ if (total > maxBytes) {
78
+ try {
79
+ await reader.cancel();
80
+ } catch {
81
+ }
82
+ throw new HttpError(res.status, res.url, `response exceeded ${maxBytes} bytes`);
83
+ }
84
+ chunks.push(value);
85
+ }
86
+ }
87
+ const out = new Uint8Array(total);
88
+ let off = 0;
89
+ for (const c of chunks) {
90
+ out.set(c, off);
91
+ off += c.byteLength;
92
+ }
93
+ return out;
94
+ }
95
+ var Http = class {
96
+ baseUrl;
97
+ _fetch;
98
+ timeoutMs;
99
+ maxBytes;
100
+ headers;
101
+ retries;
102
+ constructor(opts) {
103
+ this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
104
+ const f = opts.fetch ?? globalThis.fetch;
105
+ if (!f) throw new Error("No fetch available \u2014 pass `fetch` in the SDK options.");
106
+ this._fetch = opts.fetch ? opts.fetch : f.bind(globalThis);
107
+ this.timeoutMs = opts.timeoutMs ?? 15e3;
108
+ this.maxBytes = Number.isFinite(opts.maxBytes) && opts.maxBytes >= 1 ? Math.floor(opts.maxBytes) : DEFAULT_MAX_BYTES;
109
+ this.headers = opts.headers ?? {};
110
+ const retries = Number(opts.retries ?? 0);
111
+ this.retries = Number.isNaN(retries) ? 0 : Math.min(10, Math.max(0, Math.floor(retries)));
112
+ }
113
+ /** Build an absolute URL from a path + optional query params. */
114
+ url(path, query) {
115
+ const p = path.startsWith("/") ? path : `/${path}`;
116
+ const u = new URL(this.baseUrl + p);
117
+ const basePath = new URL(this.baseUrl + "/").pathname;
118
+ if (basePath !== "/" && !(u.pathname + "/").startsWith(basePath)) {
119
+ throw new Error(`illegal path '${path}' \u2014 escapes base ${basePath}`);
120
+ }
121
+ if (query) {
122
+ for (const [k, v] of Object.entries(query)) {
123
+ if (v !== void 0 && v !== null) u.searchParams.set(k, String(v));
124
+ }
125
+ }
126
+ return u.toString();
127
+ }
128
+ async raw(method, path, opts) {
129
+ const url = this.url(path, opts?.query);
130
+ const ctrl = new AbortController();
131
+ const timer = setTimeout(() => ctrl.abort(), this.timeoutMs);
132
+ try {
133
+ const res = await this._fetch(url, {
134
+ method,
135
+ signal: ctrl.signal,
136
+ headers: {
137
+ ...opts?.body !== void 0 ? { "content-type": "application/json" } : {},
138
+ ...this.headers,
139
+ ...opts?.headers ?? {}
140
+ },
141
+ body: opts?.body !== void 0 ? JSON.stringify(opts.body) : void 0
142
+ });
143
+ const body = await readCapped(res, this.maxBytes);
144
+ return { res, body };
145
+ } finally {
146
+ clearTimeout(timer);
147
+ }
148
+ }
149
+ // A malformed 2xx body must surface as a TYPED HttpError, not a leaked SyntaxError (B10: dApp
150
+ // code branches on `instanceof CairnError`; a raw parse error escaped that contract).
151
+ parseJson(res, text, url) {
152
+ try {
153
+ return JSON.parse(text);
154
+ } catch (e) {
155
+ throw new HttpError(res.status, url, `invalid JSON body: ${text.slice(0, 120)}`);
156
+ }
157
+ }
158
+ async getJson(path, query) {
159
+ const url = this.url(path, query);
160
+ const budget = new RetryWaitBudget(HTTP_RETRY_WAIT_BUDGET_MS);
161
+ for (let attempt = 0; ; attempt++) {
162
+ let serverWaitMs = 0;
163
+ let last;
164
+ try {
165
+ const { res, body } = await this.raw("GET", path, { query });
166
+ if (!res.ok) {
167
+ last = new HttpError(res.status, url, errText(body));
168
+ if (!(res.status >= 500 && attempt < this.retries)) throw last;
169
+ serverWaitMs = retryAfterMs(res);
170
+ } else {
171
+ return this.parseJson(res, new TextDecoder().decode(body), url);
172
+ }
173
+ } catch (e) {
174
+ if (e instanceof HttpError && e.status < 500) throw e;
175
+ if (attempt >= this.retries) throw e;
176
+ }
177
+ const jitterMs = Math.floor(Math.random() * Math.min(4e3, 250 * 2 ** attempt));
178
+ const waitMs = budget.take(jitterMs, serverWaitMs);
179
+ if (waitMs === null) throw last ?? new HttpError(0, url, "retry wait budget exhausted");
180
+ await new Promise((r) => setTimeout(r, waitMs));
181
+ }
182
+ }
183
+ async postJson(path, body, headers) {
184
+ const url = this.url(path);
185
+ const { res, body: respBody } = await this.raw("POST", path, { body, headers });
186
+ if (!res.ok) throw new HttpError(res.status, url, errText(respBody));
187
+ return this.parseJson(res, new TextDecoder().decode(respBody), url);
188
+ }
189
+ /** GET raw bytes (for content retrieval). Returns null on 404. */
190
+ async getBytes(path) {
191
+ const { res, body } = await this.raw("GET", path);
192
+ if (res.status === 404) return null;
193
+ if (!res.ok) throw new HttpError(res.status, this.url(path), errText(body));
194
+ return { bytes: body, headers: res.headers };
195
+ }
196
+ };
197
+ function errText(body) {
198
+ try {
199
+ return new TextDecoder().decode(body).slice(0, ERR_TEXT_CAP);
200
+ } catch {
201
+ return "";
202
+ }
203
+ }
43
204
 
44
205
  // src/names.ts
45
206
  import { NAME_RE, RESERVED_NAMES, TICKER_RE, AMOUNT_RE, HASH_RE } from "@inversealtruism/cairnx-core";
@@ -379,7 +540,6 @@ var Cairn = class {
379
540
  chain;
380
541
  index;
381
542
  content;
382
- registry;
383
543
  /** .csd names + CairnX market READS (server-trusted display reads; see names.ts trust note). */
384
544
  names;
385
545
  wallet;
@@ -403,7 +563,6 @@ var Cairn = class {
403
563
  this.cairnHttp = new Http({ baseUrl: cairn, fetch, timeoutMs });
404
564
  this._cairnBase = cairn;
405
565
  const indexerHttp = new Http({ baseUrl: indexer, fetch, timeoutMs });
406
- const swarmHttp = config.baseUrls?.swarm ? new Http({ baseUrl: config.baseUrls.swarm.replace(/\/+$/, ""), fetch, timeoutMs }) : void 0;
407
566
  this._spvCp = config.spvCheckpoint ?? DEFAULT_SPV_CHECKPOINT;
408
567
  this.chain = new Chain({ rpcUrl: rpc, fetch, timeoutMs });
409
568
  this.wallet = config.wallet;
@@ -412,8 +571,7 @@ var Cairn = class {
412
571
  WebSocketImpl: config.WebSocketImpl,
413
572
  headerMerkleAt: (h) => this.verifiedHeaderMerkleAt(h)
414
573
  });
415
- this.content = new ContentClient({ swarm: swarmHttp, indexer: indexerHttp, cairn: this.cairnHttp });
416
- this.registry = new RegistryClient(indexerHttp);
574
+ this.content = new ContentClient({ cairn: this.cairnHttp });
417
575
  this.names = new NamesClient(this.cairnHttp);
418
576
  }
419
577
  /**
@@ -621,7 +779,6 @@ export {
621
779
  IndexerClient,
622
780
  NamesClient,
623
781
  NotInstalledError,
624
- RegistryClient,
625
782
  SDK_VERSION,
626
783
  SubmitInFlightError,
627
784
  UnsupportedMethodError,
package/dist/indexer.cjs CHANGED
@@ -93,18 +93,6 @@ var IndexerClient = class {
93
93
  attestations(id) {
94
94
  return this.http.getJson(`/proposal/${encodeURIComponent(id)}/attestations`);
95
95
  }
96
- registryPeers() {
97
- return this.http.getJson("/registry/peers");
98
- }
99
- registryGateways() {
100
- return this.http.getJson("/registry/gateways");
101
- }
102
- identity(handle) {
103
- return this.http.getJson(`/identity/${encodeURIComponent(handle)}`);
104
- }
105
- reverseIdentity(addr) {
106
- return this.http.getJson(`/address/${encodeURIComponent(addr)}/identity`);
107
- }
108
96
  // ---- trust-minimized inclusion ----------------------------------------
109
97
  /**
110
98
  * Verify a tx is included in a block by folding its merkle branch to the root
@@ -68,10 +68,6 @@ declare class IndexerClient {
68
68
  domainProposals(d: string): Promise<unknown[]>;
69
69
  proposal(id: string): Promise<unknown>;
70
70
  attestations(id: string): Promise<unknown[]>;
71
- registryPeers(): Promise<unknown[]>;
72
- registryGateways(): Promise<unknown[]>;
73
- identity(handle: string): Promise<unknown>;
74
- reverseIdentity(addr: string): Promise<unknown>;
75
71
  /**
76
72
  * Verify a tx is included in a block by folding its merkle branch to the root
77
73
  * with csd-codec.verifyMerkleProof. If `headerMerkleAt` was provided, the
package/dist/indexer.d.ts CHANGED
@@ -68,10 +68,6 @@ declare class IndexerClient {
68
68
  domainProposals(d: string): Promise<unknown[]>;
69
69
  proposal(id: string): Promise<unknown>;
70
70
  attestations(id: string): Promise<unknown[]>;
71
- registryPeers(): Promise<unknown[]>;
72
- registryGateways(): Promise<unknown[]>;
73
- identity(handle: string): Promise<unknown>;
74
- reverseIdentity(addr: string): Promise<unknown>;
75
71
  /**
76
72
  * Verify a tx is included in a block by folding its merkle branch to the root
77
73
  * with csd-codec.verifyMerkleProof. If `headerMerkleAt` was provided, the
package/dist/indexer.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IndexerClient
3
- } from "./chunk-K5MGEYEU.js";
3
+ } from "./chunk-CI7YODPP.js";
4
4
  export {
5
5
  IndexerClient
6
6
  };
package/dist/react.cjs CHANGED
@@ -26,7 +26,7 @@ __export(react_exports, {
26
26
  module.exports = __toCommonJS(react_exports);
27
27
 
28
28
  // src/errors.ts
29
- var SDK_VERSION = "0.5.0";
29
+ var SDK_VERSION = "0.7.0";
30
30
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
31
31
  var CairnError = class extends Error {
32
32
  /** Stable machine code for programmatic branching. */
package/dist/react.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  CairnController
3
- } from "./chunk-OE5BEEQY.js";
4
- import "./chunk-5RGFC2JR.js";
5
- import "./chunk-OSPAN7GX.js";
3
+ } from "./chunk-XOGOSGC6.js";
4
+ import "./chunk-4FFLCCL4.js";
5
+ import "./chunk-PBKDSDID.js";
6
6
 
7
7
  // src/react.ts
8
8
  function createCairnHooks(React, controllerOrOpts) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inversealtruism/cairn-sdk",
3
- "version": "0.5.0",
4
- "description": "The Compute Substrate dApp kit: one cohesive toolkit to connect the Cairn Wallet, read the chain, the indexer and .csd names, verify self-certifying content, and resolve registries. Composes the published csd-* primitives.",
3
+ "version": "0.7.0",
4
+ "description": "The Compute Substrate dApp kit: one cohesive toolkit to connect the Cairn Wallet, read the chain, the indexer and .csd names, verify self-certifying content, and resolve .csd names. Composes the published csd-* primitives.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -27,11 +27,6 @@
27
27
  "import": "./dist/content.js",
28
28
  "require": "./dist/content.cjs"
29
29
  },
30
- "./registry": {
31
- "types": "./dist/registry.d.ts",
32
- "import": "./dist/registry.js",
33
- "require": "./dist/registry.cjs"
34
- },
35
30
  "./chain": {
36
31
  "types": "./dist/chain.d.ts",
37
32
  "import": "./dist/chain.js",
@@ -54,21 +49,22 @@
54
49
  "README.md"
55
50
  ],
56
51
  "dependencies": {
57
- "@inversealtruism/cairnx-core": "0.1.42",
58
- "@inversealtruism/csd-client": "0.1.16",
59
- "@inversealtruism/csd-codec": "0.1.16",
60
- "@inversealtruism/csd-crypto": "0.1.16",
61
- "@inversealtruism/csd-light": "0.1.21",
62
- "@inversealtruism/csd-registry": "0.1.18",
63
- "@inversealtruism/csd-tx": "0.1.19"
52
+ "@inversealtruism/cairnx-core": "0.2.0",
53
+ "@inversealtruism/csd-client": "0.1.18",
54
+ "@inversealtruism/csd-codec": "0.1.18",
55
+ "@inversealtruism/csd-crypto": "0.1.18",
56
+ "@inversealtruism/csd-light": "0.1.23",
57
+ "@inversealtruism/csd-tx": "0.1.21"
64
58
  },
65
59
  "devDependencies": {
66
- "@inversealtruism/csd-siwc": "0.1.17",
67
- "esbuild": "^0.27.0",
68
- "playwright-core": "^1.49.0",
69
- "tsup": "^8.5.1",
70
- "tsx": "^4.19.2",
71
- "typescript": "^5.6.0"
60
+ "@biomejs/biome": "2.5.15",
61
+ "@inversealtruism/csd-siwc": "0.1.19",
62
+ "@types/node": "22.19.20",
63
+ "esbuild": "0.28.2",
64
+ "playwright-core": "1.60.0",
65
+ "tsup": "8.5.1",
66
+ "tsx": "4.22.4",
67
+ "typescript": "5.9.3"
72
68
  },
73
69
  "sideEffects": false,
74
70
  "license": "MIT",
@@ -90,14 +86,15 @@
90
86
  "blockchain"
91
87
  ],
92
88
  "scripts": {
93
- "build": "tsup src/index.ts src/connect.ts src/indexer.ts src/content.ts src/registry.ts src/chain.ts src/controller.ts src/react.ts --format esm,cjs --dts --clean",
89
+ "build": "tsup src/index.ts src/connect.ts src/indexer.ts src/content.ts src/chain.ts src/controller.ts src/react.ts --format esm,cjs --dts --clean",
90
+ "typecheck": "tsc -p tsconfig.typecheck.json",
91
+ "lint": "biome lint --max-diagnostics=none .",
92
+ "check:dashes-paths": "node scripts/check-dashes-paths.mjs",
94
93
  "test": "node test/run.mjs",
95
- "test:live": "node examples/read-only.mjs",
94
+ "test:live": "node examples/read-only.mjs && node test/e2e/e2e-read.mjs",
95
+ "test:live:wallet": "xvfb-run -a node test/e2e/e2e-wallet-connect.mjs",
96
96
  "build:example": "node scripts/build-example.mjs",
97
97
  "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
98
- "test:e2e:read": "node test/e2e/e2e-read.mjs",
99
- "test:e2e:wallet": "xvfb-run -a node test/e2e/e2e-wallet-connect.mjs",
100
- "test:e2e": "node test/e2e/e2e-read.mjs && xvfb-run -a node test/e2e/e2e-wallet-connect.mjs",
101
- "test:all": "pnpm test && pnpm test:e2e"
98
+ "test:all": "pnpm test && pnpm test:live && pnpm test:live:wallet"
102
99
  }
103
100
  }