@inversealtruism/cairn-sdk 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,6 +10,7 @@ The **Compute Substrate dApp kit:** one cohesive toolkit for building apps on CS
10
10
  | `cairn.index` | The L2 **explorer/indexer**: REST + merkle proofs + live SSE/WS feeds. |
11
11
  | `cairn.content` | **Self-certifying content:** publish via the board, fetch with client-side verification. |
12
12
  | `cairn.registry` | L3 **peer / gateway / identity** resolution. |
13
+ | `cairn.names` | **.csd names + CairnX reads:** name resolution, reverse/primary lookup, tokens, offers, bids, canonical state. |
13
14
 
14
15
  ```bash
15
16
  npm i @inversealtruism/cairn-sdk
@@ -65,6 +66,8 @@ try {
65
66
 
66
67
  **`cairn.index`:** `tipHeight()`, `block()/blockTxids()`, `tx()/txStatus()/txMerkleProof()`, `address()/addressTxs()/addressUtxo()`, `proposal()/attestations()`, `reputation()`, `registryPeers()/registryGateways()/identity()`, **`verifyInclusion(txid)`** (trust-minimized), `streamAll()/streamBlocks()/streamDomain()` (SSE), `subscribe()` (WS).
67
68
 
69
+ **`cairn.names`:** `resolve(name)` (display-path name to address), `name(name)`/`nameHistory(name)`, `primary(addr)` (reverse lookup)/`namesOf(addr)`, `names()`, `tokens()/token(ticker)`, `offers()`, `bids()`, `state()` (the canonical CairnX state). Reads go through the public `/trade/api/cairnx/*` proxy; for payment-grade name resolution verify through the wallet or a replaying resolver, not a bare read (see `src/names.ts` header).
70
+
68
71
  **`cairn.content`:** `prepare(obj)`/`put(obj)` → `{ payloadHash, canonical, bytes }`; `get(hash)` / `getBytes(hash)` (fetch **and verify** `sha256(bytes) === hash`, throws `ContentVerificationError` on tamper); `hash(obj)`.
69
72
 
70
73
  **`cairn.chain`:** `tip()`, `utxos(addr)`, `submit(nodeJsonTx)`, `.client` (full `CsdClient`), `.light()` (verifying light client). The package also re-exports the primitives under the `/chain` subpath: `buildSend/buildPropose/buildAttest`, `signTx`, `keygen`, `payloadHash`, `verifyMerkleProof`, `LightClient`, etc.
@@ -84,7 +87,7 @@ Subpath imports are available for tree-shaking: `@inversealtruism/cairn-sdk/{con
84
87
  - **Merkle inclusion is trust-minimized, to the strength of your header source.** `verifyInclusion()` folds the proof and, when a header-merkle source is wired, cross-checks the root against it → `trustLevel: "verified-inclusion"`; otherwise `"proof-consistent"` (indexer trusted). That cross-check only means something against an *independent* header, so the default `Cairn` wiring enables it ONLY when your node RPC is a different origin than the indexer (the default same-origin proxy stays at `"proof-consistent"`, a single compromised server can't be cross-checked against itself). For full trust-minimization against a lying node too, supply a PoW-verifying `headerMerkleAt` (e.g. backed by `cairn.chain.light()`).
85
88
  - **Balances are RPC-trusted.** Headers don't commit to the UTXO set; balance reads trust the node/proxy (same as every light client).
86
89
  - **Indexer/swarm run behind the cairn proxy.** By default `cairn.index` and content resolution use the cairn server's hardened, read-only, rate-limited `/explorer/api` reverse proxy (no separate public indexer needed). **SSE works through it; `subscribe()` (WebSocket) needs a direct indexer endpoint:** set `baseUrls.indexer` to a private/localhost indexer for WS.
87
- - **Today the wallet injects only on `cairn-substrate.com` + localhost.** Connecting from an arbitrary third-party origin requires the wallet's "connect anywhere" release (broadened injection), which ships after the per-origin consent layer is proven.
90
+ - **The wallet injects on every site** (connect-anywhere shipped in 0.2.4x) behind a per-origin consent gate: a site sees nothing until the user approves the connection, and some request kinds stay first-party-only (the `FIRST_PARTY_ONLY` error code).
88
91
 
89
92
  ## Configuration
90
93
 
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.2.0";
30
+ var SDK_VERSION = "0.2.2";
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-RYZJDZLJ.js";
4
- import "./chunk-JGXD3WIC.js";
3
+ } from "./chunk-HI5STMH3.js";
4
+ import "./chunk-ZJURNM5P.js";
5
5
  export {
6
6
  BoardClient
7
7
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ContentVerificationError
3
- } from "./chunk-JGXD3WIC.js";
3
+ } from "./chunk-ZJURNM5P.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-JGXD3WIC.js";
3
+ } from "./chunk-ZJURNM5P.js";
4
4
 
5
5
  // src/board.ts
6
6
  import { payloadHash } from "@inversealtruism/csd-codec";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getWallet
3
- } from "./chunk-UIEOBVFI.js";
3
+ } from "./chunk-QRVMYGSL.js";
4
4
 
5
5
  // src/controller.ts
6
6
  var DISCONNECTED = Object.freeze({ status: "disconnected", account: null, error: null });
@@ -2,7 +2,7 @@ import {
2
2
  NotInstalledError,
3
3
  UnsupportedMethodError,
4
4
  mapProviderError
5
- } from "./chunk-JGXD3WIC.js";
5
+ } from "./chunk-ZJURNM5P.js";
6
6
 
7
7
  // src/connect.ts
8
8
  function discoverProviders(opts = {}) {
@@ -1,5 +1,5 @@
1
1
  // src/errors.ts
2
- var SDK_VERSION = "0.2.0";
2
+ var SDK_VERSION = "0.2.2";
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. */
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.2.0";
33
+ var SDK_VERSION = "0.2.2";
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-UIEOBVFI.js";
9
- import "./chunk-JGXD3WIC.js";
8
+ } from "./chunk-QRVMYGSL.js";
9
+ import "./chunk-ZJURNM5P.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.2.0";
29
+ var SDK_VERSION = "0.2.2";
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-SIUUY6FZ.js";
4
- import "./chunk-JGXD3WIC.js";
3
+ } from "./chunk-3EXZQPPT.js";
4
+ import "./chunk-ZJURNM5P.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.2.0";
28
+ var SDK_VERSION = "0.2.2";
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-PYREGAB3.js";
4
- import "./chunk-UIEOBVFI.js";
5
- import "./chunk-JGXD3WIC.js";
3
+ } from "./chunk-LCE4IWMW.js";
4
+ import "./chunk-QRVMYGSL.js";
5
+ import "./chunk-ZJURNM5P.js";
6
6
  export {
7
7
  CairnController
8
8
  };
package/dist/index.cjs CHANGED
@@ -50,7 +50,7 @@ __export(index_exports, {
50
50
  module.exports = __toCommonJS(index_exports);
51
51
 
52
52
  // src/errors.ts
53
- var SDK_VERSION = "0.2.0";
53
+ var SDK_VERSION = "0.2.2";
54
54
  var DOCS_BASE = "https://cairn-substrate.com/docs/sdk";
55
55
  var CairnError = class extends Error {
56
56
  /** Stable machine code for programmatic branching. */
package/dist/index.d.cts CHANGED
@@ -106,7 +106,7 @@ declare class NamesClient {
106
106
 
107
107
  /** Stable machine-readable error codes (branch on these, not the message text). */
108
108
  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" | "UNKNOWN";
109
- declare const SDK_VERSION = "0.2.0";
109
+ declare const SDK_VERSION = "0.2.2";
110
110
  interface CairnErrorOptions {
111
111
  code?: CairnErrorCode;
112
112
  docsPath?: string;
@@ -120,7 +120,7 @@ declare class CairnError extends Error {
120
120
  /** Relative docs path (under the SDK docs base), if any. */
121
121
  readonly docsPath?: string;
122
122
  /** The cairn-sdk version that produced this error. */
123
- readonly version = "0.2.0";
123
+ readonly version = "0.2.2";
124
124
  constructor(shortMessage: string, opts?: CairnErrorOptions);
125
125
  /**
126
126
  * Walk the `cause` chain. With a predicate, returns the FIRST matching error (or null). Without one,
package/dist/index.d.ts CHANGED
@@ -106,7 +106,7 @@ declare class NamesClient {
106
106
 
107
107
  /** Stable machine-readable error codes (branch on these, not the message text). */
108
108
  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" | "UNKNOWN";
109
- declare const SDK_VERSION = "0.2.0";
109
+ declare const SDK_VERSION = "0.2.2";
110
110
  interface CairnErrorOptions {
111
111
  code?: CairnErrorCode;
112
112
  docsPath?: string;
@@ -120,7 +120,7 @@ declare class CairnError extends Error {
120
120
  /** Relative docs path (under the SDK docs base), if any. */
121
121
  readonly docsPath?: string;
122
122
  /** The cairn-sdk version that produced this error. */
123
- readonly version = "0.2.0";
123
+ readonly version = "0.2.2";
124
124
  constructor(shortMessage: string, opts?: CairnErrorOptions);
125
125
  /**
126
126
  * Walk the `cause` chain. With a predicate, returns the FIRST matching error (or null). Without one,
package/dist/index.js CHANGED
@@ -3,20 +3,20 @@ import {
3
3
  } from "./chunk-BGJZF7S2.js";
4
4
  import {
5
5
  BoardClient
6
- } from "./chunk-RYZJDZLJ.js";
6
+ } from "./chunk-HI5STMH3.js";
7
7
  import {
8
8
  Chain,
9
9
  LightClient
10
10
  } from "./chunk-C452UODV.js";
11
11
  import {
12
12
  ContentClient
13
- } from "./chunk-SIUUY6FZ.js";
13
+ } from "./chunk-3EXZQPPT.js";
14
14
  import {
15
15
  IndexerClient
16
16
  } from "./chunk-J5J4JEJ6.js";
17
17
  import {
18
18
  CairnController
19
- } from "./chunk-PYREGAB3.js";
19
+ } from "./chunk-LCE4IWMW.js";
20
20
  import {
21
21
  WalletConnection,
22
22
  connect,
@@ -24,7 +24,7 @@ import {
24
24
  discoverProviders,
25
25
  getWallet,
26
26
  isInstalled
27
- } from "./chunk-UIEOBVFI.js";
27
+ } from "./chunk-QRVMYGSL.js";
28
28
  import {
29
29
  CairnError,
30
30
  ContentVerificationError,
@@ -36,7 +36,7 @@ import {
36
36
  WalletLockedError,
37
37
  errorCode,
38
38
  mapProviderError
39
- } from "./chunk-JGXD3WIC.js";
39
+ } from "./chunk-ZJURNM5P.js";
40
40
 
41
41
  // src/http.ts
42
42
  var DEFAULT_MAX_BYTES = 16 * 1024 * 1024;
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.2.0";
29
+ var SDK_VERSION = "0.2.2";
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-PYREGAB3.js";
4
- import "./chunk-UIEOBVFI.js";
5
- import "./chunk-JGXD3WIC.js";
3
+ } from "./chunk-LCE4IWMW.js";
4
+ import "./chunk-QRVMYGSL.js";
5
+ import "./chunk-ZJURNM5P.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.2.0",
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.",
3
+ "version": "0.2.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.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -58,27 +58,14 @@
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": "tsx test/sdk.test.ts && tsx test/connect.test.ts && tsx test/errors.test.ts && tsx test/controller.test.ts && tsx test/react.test.ts && tsx test/hardening.test.ts && tsx test/spv-checkpoint.test.ts && tsx test/names-b10.test.ts",
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
- "prepublishOnly": "npm run build && npm test"
73
- },
74
61
  "dependencies": {
75
- "@inversealtruism/cairnx-core": "0.1.31",
62
+ "@inversealtruism/cairnx-core": "0.1.36",
76
63
  "@inversealtruism/csd-client": "0.1.15",
77
64
  "@inversealtruism/csd-codec": "0.1.15",
78
65
  "@inversealtruism/csd-crypto": "0.1.15",
79
- "@inversealtruism/csd-light": "0.1.15",
80
- "@inversealtruism/csd-registry": "0.1.15",
81
- "@inversealtruism/csd-tx": "0.1.15"
66
+ "@inversealtruism/csd-light": "0.1.17",
67
+ "@inversealtruism/csd-registry": "0.1.16",
68
+ "@inversealtruism/csd-tx": "0.1.16"
82
69
  },
83
70
  "devDependencies": {
84
71
  "esbuild": "^0.27.0",
@@ -89,12 +76,6 @@
89
76
  "@inversealtruism/csd-siwc": "0.1.15"
90
77
  },
91
78
  "sideEffects": false,
92
- "packageManager": "pnpm@10.32.1",
93
- "pnpm": {
94
- "onlyBuiltDependencies": [
95
- "esbuild"
96
- ]
97
- },
98
79
  "license": "MIT",
99
80
  "publishConfig": {
100
81
  "access": "public"
@@ -112,5 +93,17 @@
112
93
  "dapp",
113
94
  "sdk",
114
95
  "blockchain"
115
- ]
116
- }
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": "tsx test/sdk.test.ts && tsx test/connect.test.ts && tsx test/errors.test.ts && tsx test/controller.test.ts && tsx test/react.test.ts && tsx test/hardening.test.ts && tsx test/spv-checkpoint.test.ts && tsx test/names-b10.test.ts",
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
+ }
109
+ }