@inversealtruism/cairn-sdk 0.4.2 → 0.4.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/dist/board.cjs CHANGED
@@ -27,7 +27,7 @@ var import_csd_codec = require("@inversealtruism/csd-codec");
27
27
  var import_csd_codec2 = require("@inversealtruism/csd-codec");
28
28
 
29
29
  // src/errors.ts
30
- var SDK_VERSION = "0.4.2";
30
+ var SDK_VERSION = "0.4.3";
31
31
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
32
32
  var CairnError = class extends Error {
33
33
  /** Stable machine code for programmatic branching. */
package/dist/board.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BoardClient
3
- } from "./chunk-XPTP5W75.js";
4
- import "./chunk-REHDMKBF.js";
3
+ } from "./chunk-WEVDLGKT.js";
4
+ import "./chunk-EJENF4OP.js";
5
5
  export {
6
6
  BoardClient
7
7
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getWallet
3
- } from "./chunk-VGKXFRHY.js";
3
+ } from "./chunk-XZGNVYH3.js";
4
4
 
5
5
  // src/controller.ts
6
6
  var DISCONNECTED = Object.freeze({ status: "disconnected", account: null, error: null });
@@ -1,5 +1,5 @@
1
1
  // src/errors.ts
2
- var SDK_VERSION = "0.4.2";
2
+ var SDK_VERSION = "0.4.3";
3
3
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
4
4
  var CairnError = class extends Error {
5
5
  /** Stable machine code for programmatic branching. */
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HttpError
3
- } from "./chunk-REHDMKBF.js";
3
+ } from "./chunk-EJENF4OP.js";
4
4
 
5
5
  // src/registry.ts
6
6
  import { fromRecords } from "@inversealtruism/csd-registry";
@@ -90,7 +90,8 @@ var Http = class {
90
90
  },
91
91
  body: opts?.body !== void 0 ? JSON.stringify(opts.body) : void 0
92
92
  });
93
- return res;
93
+ const body = await readCapped(res, this.maxBytes);
94
+ return { res, body };
94
95
  } finally {
95
96
  clearTimeout(timer);
96
97
  }
@@ -108,13 +109,11 @@ var Http = class {
108
109
  const url = this.url(path, query);
109
110
  for (let attempt = 0; ; attempt++) {
110
111
  try {
111
- const res = await this.raw("GET", path, { query });
112
+ const { res, body } = await this.raw("GET", path, { query });
112
113
  if (!res.ok) {
113
- if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, await safeText(res));
114
- res.body?.cancel().catch(() => {
115
- });
114
+ if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, errText(body));
116
115
  } else {
117
- return this.parseJson(res, new TextDecoder().decode(await readCapped(res, this.maxBytes)), url);
116
+ return this.parseJson(res, new TextDecoder().decode(body), url);
118
117
  }
119
118
  } catch (e) {
120
119
  if (e instanceof HttpError && e.status < 500) throw e;
@@ -125,21 +124,21 @@ var Http = class {
125
124
  }
126
125
  async postJson(path, body, headers) {
127
126
  const url = this.url(path);
128
- const res = await this.raw("POST", path, { body, headers });
129
- if (!res.ok) throw new HttpError(res.status, url, await safeText(res));
130
- return this.parseJson(res, new TextDecoder().decode(await readCapped(res, this.maxBytes)), url);
127
+ const { res, body: respBody } = await this.raw("POST", path, { body, headers });
128
+ if (!res.ok) throw new HttpError(res.status, url, errText(respBody));
129
+ return this.parseJson(res, new TextDecoder().decode(respBody), url);
131
130
  }
132
131
  /** GET raw bytes (for content retrieval). Returns null on 404. */
133
132
  async getBytes(path) {
134
- const res = await this.raw("GET", path);
133
+ const { res, body } = await this.raw("GET", path);
135
134
  if (res.status === 404) return null;
136
- if (!res.ok) throw new HttpError(res.status, this.url(path), await safeText(res));
137
- return { bytes: await readCapped(res, this.maxBytes), headers: res.headers };
135
+ if (!res.ok) throw new HttpError(res.status, this.url(path), errText(body));
136
+ return { bytes: body, headers: res.headers };
138
137
  }
139
138
  };
140
- async function safeText(res) {
139
+ function errText(body) {
141
140
  try {
142
- return new TextDecoder().decode(await readCapped(res, ERR_TEXT_CAP));
141
+ return new TextDecoder().decode(body).slice(0, ERR_TEXT_CAP);
143
142
  } catch {
144
143
  return "";
145
144
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ContentVerificationError
3
- } from "./chunk-REHDMKBF.js";
3
+ } from "./chunk-EJENF4OP.js";
4
4
 
5
5
  // src/content.ts
6
6
  import { payloadHash, canonicalJson, verifyContentBytes } from "@inversealtruism/csd-codec";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CairnError
3
- } from "./chunk-REHDMKBF.js";
3
+ } from "./chunk-EJENF4OP.js";
4
4
 
5
5
  // src/board.ts
6
6
  import { payloadHash } from "@inversealtruism/csd-codec";
@@ -4,7 +4,7 @@ import {
4
4
  UnsupportedMethodError,
5
5
  mapProviderError,
6
6
  mapSubmitResultError
7
- } from "./chunk-REHDMKBF.js";
7
+ } from "./chunk-EJENF4OP.js";
8
8
 
9
9
  // src/connect.ts
10
10
  var DEFAULT_PROVIDER_TIMEOUT_MS = 10 * 6e4;
package/dist/connect.cjs CHANGED
@@ -30,7 +30,7 @@ __export(connect_exports, {
30
30
  module.exports = __toCommonJS(connect_exports);
31
31
 
32
32
  // src/errors.ts
33
- var SDK_VERSION = "0.4.2";
33
+ var SDK_VERSION = "0.4.3";
34
34
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
35
35
  var CairnError = class extends Error {
36
36
  /** Stable machine code for programmatic branching. */
package/dist/connect.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  discoverProviders,
6
6
  getWallet,
7
7
  isInstalled
8
- } from "./chunk-VGKXFRHY.js";
9
- import "./chunk-REHDMKBF.js";
8
+ } from "./chunk-XZGNVYH3.js";
9
+ import "./chunk-EJENF4OP.js";
10
10
  export {
11
11
  WalletConnection,
12
12
  connect,
package/dist/content.cjs CHANGED
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(content_exports);
26
26
  var import_csd_codec = require("@inversealtruism/csd-codec");
27
27
 
28
28
  // src/errors.ts
29
- var SDK_VERSION = "0.4.2";
29
+ var SDK_VERSION = "0.4.3";
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/content.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ContentClient
3
- } from "./chunk-PZEQ4YHR.js";
4
- import "./chunk-REHDMKBF.js";
3
+ } from "./chunk-V7C5GXQY.js";
4
+ import "./chunk-EJENF4OP.js";
5
5
  export {
6
6
  ContentClient
7
7
  };
@@ -25,7 +25,7 @@ __export(controller_exports, {
25
25
  module.exports = __toCommonJS(controller_exports);
26
26
 
27
27
  // src/errors.ts
28
- var SDK_VERSION = "0.4.2";
28
+ var SDK_VERSION = "0.4.3";
29
29
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
30
30
  var CairnError = class extends Error {
31
31
  /** Stable machine code for programmatic branching. */
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  CairnController
3
- } from "./chunk-FS2BQWA5.js";
4
- import "./chunk-VGKXFRHY.js";
5
- import "./chunk-REHDMKBF.js";
3
+ } from "./chunk-BFQVPITS.js";
4
+ import "./chunk-XZGNVYH3.js";
5
+ import "./chunk-EJENF4OP.js";
6
6
  export {
7
7
  CairnController
8
8
  };
package/dist/index.cjs CHANGED
@@ -60,7 +60,7 @@ __export(index_exports, {
60
60
  module.exports = __toCommonJS(index_exports);
61
61
 
62
62
  // src/errors.ts
63
- var SDK_VERSION = "0.4.2";
63
+ var SDK_VERSION = "0.4.3";
64
64
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
65
65
  var CairnError = class extends Error {
66
66
  /** Stable machine code for programmatic branching. */
@@ -283,7 +283,8 @@ var Http = class {
283
283
  },
284
284
  body: opts?.body !== void 0 ? JSON.stringify(opts.body) : void 0
285
285
  });
286
- return res;
286
+ const body = await readCapped(res, this.maxBytes);
287
+ return { res, body };
287
288
  } finally {
288
289
  clearTimeout(timer);
289
290
  }
@@ -301,13 +302,11 @@ var Http = class {
301
302
  const url = this.url(path, query);
302
303
  for (let attempt = 0; ; attempt++) {
303
304
  try {
304
- const res = await this.raw("GET", path, { query });
305
+ const { res, body } = await this.raw("GET", path, { query });
305
306
  if (!res.ok) {
306
- if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, await safeText(res));
307
- res.body?.cancel().catch(() => {
308
- });
307
+ if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, errText(body));
309
308
  } else {
310
- return this.parseJson(res, new TextDecoder().decode(await readCapped(res, this.maxBytes)), url);
309
+ return this.parseJson(res, new TextDecoder().decode(body), url);
311
310
  }
312
311
  } catch (e) {
313
312
  if (e instanceof HttpError && e.status < 500) throw e;
@@ -318,21 +317,21 @@ var Http = class {
318
317
  }
319
318
  async postJson(path, body, headers) {
320
319
  const url = this.url(path);
321
- const res = await this.raw("POST", path, { body, headers });
322
- if (!res.ok) throw new HttpError(res.status, url, await safeText(res));
323
- return this.parseJson(res, new TextDecoder().decode(await readCapped(res, this.maxBytes)), url);
320
+ const { res, body: respBody } = await this.raw("POST", path, { body, headers });
321
+ if (!res.ok) throw new HttpError(res.status, url, errText(respBody));
322
+ return this.parseJson(res, new TextDecoder().decode(respBody), url);
324
323
  }
325
324
  /** GET raw bytes (for content retrieval). Returns null on 404. */
326
325
  async getBytes(path) {
327
- const res = await this.raw("GET", path);
326
+ const { res, body } = await this.raw("GET", path);
328
327
  if (res.status === 404) return null;
329
- if (!res.ok) throw new HttpError(res.status, this.url(path), await safeText(res));
330
- return { bytes: await readCapped(res, this.maxBytes), headers: res.headers };
328
+ if (!res.ok) throw new HttpError(res.status, this.url(path), errText(body));
329
+ return { bytes: body, headers: res.headers };
331
330
  }
332
331
  };
333
- async function safeText(res) {
332
+ function errText(body) {
334
333
  try {
335
- return new TextDecoder().decode(await readCapped(res, ERR_TEXT_CAP));
334
+ return new TextDecoder().decode(body).slice(0, ERR_TEXT_CAP);
336
335
  } catch {
337
336
  return "";
338
337
  }
@@ -1371,6 +1370,11 @@ async function preverifyOffer(opts) {
1371
1370
  const w = rec.want ?? {};
1372
1371
  const payto = w.payto && ADDR.test(String(w.payto).toLowerCase()) ? String(w.payto).toLowerCase() : seller;
1373
1372
  const terms = (0, import_cairnx_core2.provenOfferTerms)(offerRec, blockHeight);
1373
+ if (payto === import_cairnx_core2.TREASURY_ADDR)
1374
+ return { ok: false, trust: "verified", blockHeight, reason: "the offer's payment recipient is the protocol treasury - the chain rejects it, and a fill would move CSD for nothing" };
1375
+ const provenExpiresEpoch = Number(app.expires_epoch);
1376
+ if (!Number.isSafeInteger(provenExpiresEpoch) || (0, import_cairnx_core2.epochOf)(blockHeight) > provenExpiresEpoch)
1377
+ return { ok: false, trust: "verified", blockHeight, reason: "the offer was already expired when it was mined - the chain rejects it, and a fill would move CSD for nothing" };
1374
1378
  let outputPlan;
1375
1379
  let sumsMismatch;
1376
1380
  if (opts.pay !== void 0 && opts.pay !== null && !(0, import_cairnx_core2.isTokenWant)(offerRec.want) && offerRec.min === void 0) {
package/dist/index.d.cts CHANGED
@@ -160,7 +160,7 @@ declare function preverifyOffer(opts: {
160
160
 
161
161
  /** Stable machine-readable error codes (branch on these, not the message text). */
162
162
  type CairnErrorCode = "NOT_INSTALLED" | "USER_REJECTED" | "WALLET_LOCKED" | "UNSUPPORTED_METHOD" | "HTTP_ERROR" | "CONTENT_VERIFICATION" | "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" | "UNKNOWN";
163
- declare const SDK_VERSION = "0.4.2";
163
+ declare const SDK_VERSION = "0.4.3";
164
164
  interface CairnErrorOptions {
165
165
  code?: CairnErrorCode;
166
166
  docsPath?: string;
@@ -180,7 +180,7 @@ declare class CairnError extends Error {
180
180
  /** Relative docs path (under the SDK docs base), if any. */
181
181
  readonly docsPath?: string;
182
182
  /** The cairn-sdk version that produced this error. */
183
- readonly version = "0.4.2";
183
+ readonly version = "0.4.3";
184
184
  /**
185
185
  * Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
186
186
  * declines (the default); `true` only for provably transient infra faults where nothing was signed.
package/dist/index.d.ts CHANGED
@@ -160,7 +160,7 @@ declare function preverifyOffer(opts: {
160
160
 
161
161
  /** Stable machine-readable error codes (branch on these, not the message text). */
162
162
  type CairnErrorCode = "NOT_INSTALLED" | "USER_REJECTED" | "WALLET_LOCKED" | "UNSUPPORTED_METHOD" | "HTTP_ERROR" | "CONTENT_VERIFICATION" | "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" | "UNKNOWN";
163
- declare const SDK_VERSION = "0.4.2";
163
+ declare const SDK_VERSION = "0.4.3";
164
164
  interface CairnErrorOptions {
165
165
  code?: CairnErrorCode;
166
166
  docsPath?: string;
@@ -180,7 +180,7 @@ declare class CairnError extends Error {
180
180
  /** Relative docs path (under the SDK docs base), if any. */
181
181
  readonly docsPath?: string;
182
182
  /** The cairn-sdk version that produced this error. */
183
- readonly version = "0.4.2";
183
+ readonly version = "0.4.3";
184
184
  /**
185
185
  * Whether a dApp may safely AUTO-retry this failure. `false` for fund-safety refusals and user-intent
186
186
  * declines (the default); `true` only for provably transient infra faults where nothing was signed.
package/dist/index.js CHANGED
@@ -2,23 +2,23 @@ import {
2
2
  Http,
3
3
  RegistryClient,
4
4
  readCapped
5
- } from "./chunk-WBU7KDI3.js";
5
+ } from "./chunk-KCRJL5HD.js";
6
6
  import {
7
7
  BoardClient
8
- } from "./chunk-XPTP5W75.js";
8
+ } from "./chunk-WEVDLGKT.js";
9
9
  import {
10
10
  Chain,
11
11
  LightClient
12
12
  } from "./chunk-C452UODV.js";
13
13
  import {
14
14
  ContentClient
15
- } from "./chunk-PZEQ4YHR.js";
15
+ } from "./chunk-V7C5GXQY.js";
16
16
  import {
17
17
  IndexerClient
18
18
  } from "./chunk-J5J4JEJ6.js";
19
19
  import {
20
20
  CairnController
21
- } from "./chunk-FS2BQWA5.js";
21
+ } from "./chunk-BFQVPITS.js";
22
22
  import {
23
23
  WalletConnection,
24
24
  connect,
@@ -26,7 +26,7 @@ import {
26
26
  discoverProviders,
27
27
  getWallet,
28
28
  isInstalled
29
- } from "./chunk-VGKXFRHY.js";
29
+ } from "./chunk-XZGNVYH3.js";
30
30
  import {
31
31
  CairnError,
32
32
  ContentVerificationError,
@@ -40,7 +40,7 @@ import {
40
40
  errorCode,
41
41
  mapProviderError,
42
42
  mapSubmitResultError
43
- } from "./chunk-REHDMKBF.js";
43
+ } from "./chunk-EJENF4OP.js";
44
44
 
45
45
  // src/names.ts
46
46
  import { NAME_RE, RESERVED_NAMES } from "@inversealtruism/cairnx-core";
@@ -146,7 +146,9 @@ import {
146
146
  fillEndorsement,
147
147
  fillIsSafe,
148
148
  requiredFillOutputs,
149
- previewFill
149
+ previewFill,
150
+ TREASURY_ADDR,
151
+ epochOf
150
152
  } from "@inversealtruism/cairnx-core";
151
153
  var ADDR = /^0x[0-9a-f]{40}$/;
152
154
  var HASH = /^0x[0-9a-f]{64}$/;
@@ -229,6 +231,11 @@ async function preverifyOffer(opts) {
229
231
  const w = rec.want ?? {};
230
232
  const payto = w.payto && ADDR.test(String(w.payto).toLowerCase()) ? String(w.payto).toLowerCase() : seller;
231
233
  const terms = provenOfferTerms(offerRec, blockHeight);
234
+ if (payto === TREASURY_ADDR)
235
+ return { ok: false, trust: "verified", blockHeight, reason: "the offer's payment recipient is the protocol treasury - the chain rejects it, and a fill would move CSD for nothing" };
236
+ const provenExpiresEpoch = Number(app.expires_epoch);
237
+ if (!Number.isSafeInteger(provenExpiresEpoch) || epochOf(blockHeight) > provenExpiresEpoch)
238
+ return { ok: false, trust: "verified", blockHeight, reason: "the offer was already expired when it was mined - the chain rejects it, and a fill would move CSD for nothing" };
232
239
  let outputPlan;
233
240
  let sumsMismatch;
234
241
  if (opts.pay !== void 0 && opts.pay !== null && !isTokenWant(offerRec.want) && offerRec.min === void 0) {
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.4.2";
29
+ var SDK_VERSION = "0.4.3";
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-FS2BQWA5.js";
4
- import "./chunk-VGKXFRHY.js";
5
- import "./chunk-REHDMKBF.js";
3
+ } from "./chunk-BFQVPITS.js";
4
+ import "./chunk-XZGNVYH3.js";
5
+ import "./chunk-EJENF4OP.js";
6
6
 
7
7
  // src/react.ts
8
8
  function createCairnHooks(React, controllerOrOpts) {
package/dist/registry.cjs CHANGED
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(registry_exports);
36
36
  var import_csd_registry = require("@inversealtruism/csd-registry");
37
37
 
38
38
  // src/errors.ts
39
- var SDK_VERSION = "0.4.2";
39
+ var SDK_VERSION = "0.4.3";
40
40
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
41
41
  var CairnError = class extends Error {
42
42
  /** Stable machine code for programmatic branching. */
@@ -177,7 +177,8 @@ var Http = class {
177
177
  },
178
178
  body: opts?.body !== void 0 ? JSON.stringify(opts.body) : void 0
179
179
  });
180
- return res;
180
+ const body = await readCapped(res, this.maxBytes);
181
+ return { res, body };
181
182
  } finally {
182
183
  clearTimeout(timer);
183
184
  }
@@ -195,13 +196,11 @@ var Http = class {
195
196
  const url = this.url(path, query);
196
197
  for (let attempt = 0; ; attempt++) {
197
198
  try {
198
- const res = await this.raw("GET", path, { query });
199
+ const { res, body } = await this.raw("GET", path, { query });
199
200
  if (!res.ok) {
200
- if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, await safeText(res));
201
- res.body?.cancel().catch(() => {
202
- });
201
+ if (!(res.status >= 500 && attempt < this.retries)) throw new HttpError(res.status, url, errText(body));
203
202
  } else {
204
- return this.parseJson(res, new TextDecoder().decode(await readCapped(res, this.maxBytes)), url);
203
+ return this.parseJson(res, new TextDecoder().decode(body), url);
205
204
  }
206
205
  } catch (e) {
207
206
  if (e instanceof HttpError && e.status < 500) throw e;
@@ -212,21 +211,21 @@ var Http = class {
212
211
  }
213
212
  async postJson(path, body, headers) {
214
213
  const url = this.url(path);
215
- const res = await this.raw("POST", path, { body, headers });
216
- if (!res.ok) throw new HttpError(res.status, url, await safeText(res));
217
- return this.parseJson(res, new TextDecoder().decode(await readCapped(res, this.maxBytes)), url);
214
+ const { res, body: respBody } = await this.raw("POST", path, { body, headers });
215
+ if (!res.ok) throw new HttpError(res.status, url, errText(respBody));
216
+ return this.parseJson(res, new TextDecoder().decode(respBody), url);
218
217
  }
219
218
  /** GET raw bytes (for content retrieval). Returns null on 404. */
220
219
  async getBytes(path) {
221
- const res = await this.raw("GET", path);
220
+ const { res, body } = await this.raw("GET", path);
222
221
  if (res.status === 404) return null;
223
- if (!res.ok) throw new HttpError(res.status, this.url(path), await safeText(res));
224
- return { bytes: await readCapped(res, this.maxBytes), headers: res.headers };
222
+ if (!res.ok) throw new HttpError(res.status, this.url(path), errText(body));
223
+ return { bytes: body, headers: res.headers };
225
224
  }
226
225
  };
227
- async function safeText(res) {
226
+ function errText(body) {
228
227
  try {
229
- return new TextDecoder().decode(await readCapped(res, ERR_TEXT_CAP));
228
+ return new TextDecoder().decode(body).slice(0, ERR_TEXT_CAP);
230
229
  } catch {
231
230
  return "";
232
231
  }
package/dist/registry.js CHANGED
@@ -10,8 +10,8 @@ import {
10
10
  verifyGateway,
11
11
  verifyIdentitySig,
12
12
  verifyPeer
13
- } from "./chunk-WBU7KDI3.js";
14
- import "./chunk-REHDMKBF.js";
13
+ } from "./chunk-KCRJL5HD.js";
14
+ import "./chunk-EJENF4OP.js";
15
15
  export {
16
16
  DOMAINS,
17
17
  RegistryClient,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inversealtruism/cairn-sdk",
3
- "version": "0.4.2",
4
- "description": "The Compute Substrate dApp kit — one cohesive toolkit to connect the Cairn Wallet, read the chain/board, publish self-certifying content, and resolve registries. Composes the published csd-* primitives.",
3
+ "version": "0.4.3",
4
+ "description": "The Compute Substrate dApp kit \u2014 one cohesive toolkit to connect the Cairn Wallet, read the chain/board, publish self-certifying content, and resolve registries. Composes the published csd-* primitives.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -58,14 +58,28 @@
58
58
  "LICENSE",
59
59
  "README.md"
60
60
  ],
61
+ "scripts": {
62
+ "build": "tsup src/index.ts src/connect.ts src/board.ts src/indexer.ts src/content.ts src/registry.ts src/chain.ts src/controller.ts src/react.ts --format esm,cjs --dts --clean",
63
+ "test": "node test/run.mjs",
64
+ "test:live": "node examples/read-only.mjs",
65
+ "build:example": "node scripts/build-example.mjs",
66
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
67
+ "test:e2e:read": "node test/e2e/e2e-read.mjs",
68
+ "test:e2e:wallet": "xvfb-run -a node test/e2e/e2e-wallet-connect.mjs",
69
+ "test:e2e:write": "node test/e2e/e2e-write.mjs",
70
+ "test:e2e": "node test/e2e/e2e-read.mjs && xvfb-run -a node test/e2e/e2e-wallet-connect.mjs",
71
+ "test:all": "pnpm test && pnpm test:e2e",
72
+ "prepack": "pnpm build",
73
+ "prepublishOnly": "npm run build && npm test"
74
+ },
61
75
  "dependencies": {
62
76
  "@inversealtruism/cairnx-core": "0.1.41",
63
- "@inversealtruism/csd-client": "0.1.15",
77
+ "@inversealtruism/csd-client": "0.1.16",
64
78
  "@inversealtruism/csd-codec": "0.1.16",
65
79
  "@inversealtruism/csd-crypto": "0.1.15",
66
80
  "@inversealtruism/csd-light": "0.1.19",
67
81
  "@inversealtruism/csd-registry": "0.1.17",
68
- "@inversealtruism/csd-tx": "0.1.17"
82
+ "@inversealtruism/csd-tx": "0.1.18"
69
83
  },
70
84
  "devDependencies": {
71
85
  "@inversealtruism/csd-siwc": "0.1.16",
@@ -76,6 +90,12 @@
76
90
  "typescript": "^5.6.0"
77
91
  },
78
92
  "sideEffects": false,
93
+ "packageManager": "pnpm@10.32.1",
94
+ "pnpm": {
95
+ "onlyBuiltDependencies": [
96
+ "esbuild"
97
+ ]
98
+ },
79
99
  "license": "MIT",
80
100
  "publishConfig": {
81
101
  "access": "public"
@@ -93,17 +113,5 @@
93
113
  "dapp",
94
114
  "sdk",
95
115
  "blockchain"
96
- ],
97
- "scripts": {
98
- "build": "tsup src/index.ts src/connect.ts src/board.ts src/indexer.ts src/content.ts src/registry.ts src/chain.ts src/controller.ts src/react.ts --format esm,cjs --dts --clean",
99
- "test": "node test/run.mjs",
100
- "test:live": "node examples/read-only.mjs",
101
- "build:example": "node scripts/build-example.mjs",
102
- "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
103
- "test:e2e:read": "node test/e2e/e2e-read.mjs",
104
- "test:e2e:wallet": "xvfb-run -a node test/e2e/e2e-wallet-connect.mjs",
105
- "test:e2e:write": "node test/e2e/e2e-write.mjs",
106
- "test:e2e": "node test/e2e/e2e-read.mjs && xvfb-run -a node test/e2e/e2e-wallet-connect.mjs",
107
- "test:all": "pnpm test && pnpm test:e2e"
108
- }
116
+ ]
109
117
  }