@capxul/sdk-react 0.2.0-alpha.4 → 0.2.0-alpha.5

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/package.json CHANGED
@@ -1,92 +1,54 @@
1
1
  {
2
2
  "name": "@capxul/sdk-react",
3
- "version": "0.2.0-alpha.4",
4
- "description": "React provider + hooks for the @capxul/sdk headless client.",
5
- "license": "UNLICENSED",
6
- "private": false,
7
- "type": "module",
8
- "homepage": "https://capxul.com",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/Xelmar-tech/Capxul.git",
12
- "directory": "packages/sdk-react"
13
- },
14
- "bugs": {
15
- "url": "https://github.com/Xelmar-tech/Capxul/issues"
16
- },
17
- "author": "Capxul (Xelmar Tech Ltd.)",
18
- "keywords": [
19
- "capxul",
20
- "sdk",
21
- "react",
22
- "hooks",
23
- "stablecoin",
24
- "payments",
25
- "typescript"
3
+ "version": "0.2.0-alpha.5",
4
+ "files": [
5
+ "dist",
6
+ "package.json",
7
+ "README.md"
26
8
  ],
9
+ "type": "module",
27
10
  "exports": {
28
11
  ".": {
29
- "types": "./dist/index.d.ts",
30
- "import": "./dist/index.js",
31
- "require": "./dist/index.cjs"
32
- },
33
- "./proof": {
34
- "types": "./dist/proof/index.d.ts",
35
- "import": "./dist/proof/index.js",
36
- "require": "./dist/proof/index.cjs"
12
+ "types": "./dist/index.d.mts",
13
+ "import": "./dist/index.mjs"
37
14
  }
38
15
  },
39
- "files": [
40
- "dist",
41
- "README.md",
42
- "LICENSE",
43
- "CHANGELOG.md"
44
- ],
45
16
  "publishConfig": {
46
17
  "access": "public"
47
18
  },
48
19
  "dependencies": {
49
- "@capxul/sdk": "0.2.0-alpha.4"
50
- },
51
- "peerDependencies": {
52
- "@tanstack/react-query": "^5",
53
- "@xstate/react": "^5",
54
- "convex": ">=1.0.0",
55
- "react": ">=18.2.0 <20",
56
- "viem": ">=2.0.0"
20
+ "@capxul/config": "0.0.0",
21
+ "@capxul/sdk": "0.2.0-alpha.5",
22
+ "@capxul/types": "0.0.0"
57
23
  },
58
24
  "devDependencies": {
59
- "@tanstack/react-query": "^5",
25
+ "@tanstack/react-query": "^5.66.9",
26
+ "@testing-library/jest-dom": "^6.9.1",
60
27
  "@testing-library/react": "^16.3.2",
61
- "@xstate/react": "^5",
62
- "@types/node": "^22.15.3",
63
- "@types/react": "19.2.2",
64
- "@types/react-dom": "19.2.3",
65
- "jsdom": "^29.0.1",
66
- "react": "19.2.5",
67
- "react-dom": "19.2.5",
68
- "tsup": "^8.5.1",
69
- "tsx": "^4.21.0",
70
- "typescript": "5.9.2",
71
- "viem": "2.47.10",
72
- "vitest": "^4.1.2",
73
- "@repo/config": "0.0.0",
74
- "@repo/observability": "0.0.0",
75
- "@repo/platform-kernel": "0.0.0",
76
- "@repo/typescript-config": "0.0.0"
28
+ "@types/jsdom": "^28.0.3",
29
+ "@types/react": "^19.2.15",
30
+ "@types/react-test-renderer": "^19.1.0",
31
+ "@vitest/coverage-v8": "4.1.7",
32
+ "ink": "^7.0.3",
33
+ "ink-testing-library": "^4.0.0",
34
+ "jsdom": "^29.1.1",
35
+ "react": "^19.2.6",
36
+ "react-dom": "^19.2.6",
37
+ "react-test-renderer": "^19.2.6",
38
+ "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.23"
77
39
  },
78
- "scripts": {
79
- "build": "tsup",
80
- "check-types": "tsc --noEmit",
81
- "proof:contract": "vitest run ops/proof/sdk-contract.test.ts",
82
- "proof:drift": "vitest run ops/proof/reset-contract-drift.test.ts",
83
- "proof:evidence": "tsx ops/proof/evidence-cli.ts",
84
- "proof:plan": "tsx ops/proof/plan-cli.ts",
85
- "proof:react-headless": "vitest run ops/proof/react-headless.test.tsx",
86
- "test": "vitest run",
87
- "test:types": "vitest run --typecheck"
40
+ "peerDependencies": {
41
+ "@tanstack/react-query": "^5.66.9",
42
+ "react": "^18.0.0 || ^19.0.0"
43
+ },
44
+ "engines": {
45
+ "node": ">=22.12.0"
88
46
  },
89
- "main": "./dist/index.cjs",
90
- "module": "./dist/index.js",
91
- "types": "./dist/index.d.ts"
47
+ "scripts": {
48
+ "check-types": "tsc -p tsconfig.json --noEmit",
49
+ "lint": "oxlint -c ../../.oxlintrc.json . --deny-warnings",
50
+ "build": "vp pack",
51
+ "_vp-tasks-allowed": "vp-allowed: `test` + `test:coverage` are vp tasks in vite.config.ts so vitest self-writes don't bust cache (#205).",
52
+ "test:e2e": "vp test run --config vitest.e2e.config.ts"
53
+ }
92
54
  }
package/CHANGELOG.md DELETED
@@ -1,304 +0,0 @@
1
- # @capxul/sdk-react
2
-
3
- ## 0.2.0-alpha.4
4
-
5
- ### Minor Changes
6
-
7
- - b6c1f94: Complete the auth dogfooding epic around the canonical auth surface.
8
-
9
- The SDK now carries the guarded OTP proof path, bootstrap continuation states,
10
- canonical auth service behavior, and final funnel proof support needed for
11
- first-run auth dogfooding. The React SDK aligns its auth hooks and provider
12
- state with that canonical flow, including signout cleanup, bootstrap-required
13
- continuations, and funnel telemetry integration.
14
-
15
- ### Patch Changes
16
-
17
- - 50d3c55: Bundle the internal Safe derivation package into the SDK artifact instead of
18
- publishing it as a runtime dependency, and add a packaging guard that fails when
19
- publishable packages leak private `@repo/*` runtime dependencies.
20
- - Updated dependencies [b6c1f94]
21
- - Updated dependencies [50d3c55]
22
- - @capxul/sdk@0.2.0-alpha.4
23
-
24
- ## 0.2.0-alpha.3
25
-
26
- ### Patch Changes
27
-
28
- - Updated dependencies [5b99a9b]
29
- - @capxul/sdk@0.2.0-alpha.3
30
-
31
- ## 0.2.0-alpha.2
32
-
33
- ### Minor Changes
34
-
35
- - 995383f: Epic 660: Unified auth surface
36
- - Introduces AuthService promise-based auth API replacing the imperative capxul.auth.\* tuple interface
37
- - Adds SignerProvisioner for deterministic Safe v1.4.1 address derivation from viem signers
38
- - Adds useAuth() React hook with reactive state + promise-based methods
39
- - Deprecates useAuthFlow and useAuthBootstrapFlow in favor of useAuth()
40
- - Migrates reference CLI auth commands (send-otp, verify-otp, signout) to useAuth()
41
- - Migrates test surfaces: walkthroughs, type tests, e2e harness signup, lazy-dx provider
42
- - Adds @repo/safe-derive workspace package for Safe address derivation utilities
43
- - Aligns CapxulConfig.data to \_data with internal SDK transport ownership (Epic 652)
44
- - Pins esbuild to 0.25.12 to fix binary-version skew in fresh worktrees
45
-
46
- - 2ef4ee3: Reshape the organizations members surface around a single Membership entity
47
- with a status lifecycle (`pending | active | revoked | expired`).
48
- - Replaces the prior invitation/membership split (which produced a phantom
49
- `MemberInvitation` type that never compiled) with a single `Member` type
50
- exposing `status`, `email`, `acceptedAt`, `expiresAt`, and `resentCount`.
51
- - New methods on `organizations.members.*`: `accept(token)`, `revoke(memberId)`,
52
- `resend(memberId)`. `invite()` now returns a `MemberInviteResponse`
53
- containing the raw invite token (returned once).
54
- - Auto-accepts pending invitations on first sign-in for the matching email
55
- via a BetterAuth post-signup hook.
56
- - Nightly Convex cron expires overdue pending invitations.
57
-
58
- Public type changes:
59
- - Removed: `MemberInvitation` (was never exported; type didn't compile).
60
- - Added: `MembershipStatus`, `MemberInviteResponse`.
61
- - Updated: `Member` shape — see SDK reference for the full delta.
62
-
63
- React hooks:
64
- - New: `useAcceptInvitation`, `useRevokeMember`, `useResendInvitation`.
65
- - Updated: `useInviteMember` returns `MemberInviteResponse` (was returning a
66
- type that didn't exist).
67
-
68
- Reference CLI:
69
- - New commands: `org members invite`, `org members list`, `org members retrieve`,
70
- `org members accept`, `org members updateRole`, `org members revoke`,
71
- `org members remove`, `org members resend`.
72
-
73
- - c7146bf: **Transport ownership (#656):** The SDK now owns construction of the
74
- authenticated `ConvexHttpClient`. Consumers no longer wire `data` manually
75
- or provide `auth.createDataClient`. After `verifyOtp` exchanges a Convex
76
- JWT, the SDK builds the default data client internally via
77
- `createDefaultDataClient` and stores it on `config._data`.
78
- - `CapxulConfig.data` renamed to `_data` (internal test seam).
79
- - `CapxulAuthConfig.createDataClient` removed from public types.
80
- - `convex` moved from `peerDependencies` to `dependencies`.
81
-
82
- ### Patch Changes
83
-
84
- - d252aa7: Widen the published React peer dependency to `>=18.2.0 <20` so React 18 consumers, including the Ink reference proof app, can install the alpha SDK without peer conflicts.
85
- - Updated dependencies [995383f]
86
- - Updated dependencies [2ef4ee3]
87
- - Updated dependencies [c7146bf]
88
- - @capxul/sdk@0.2.0-alpha.2
89
-
90
- ## 0.2.0-alpha.1
91
-
92
- ### Minor Changes
93
-
94
- - **Transport ownership (#656):** Remove the `auth.createDataClient`
95
- callback from `CapxulProvider`. The React provider now passes its
96
- singleton data client via `CapxulConfig._data` and lets the SDK own
97
- runtime construction after OTP verification.
98
-
99
- ### Patch Changes
100
-
101
- - Updated dependencies
102
- - @capxul/sdk@0.2.0-alpha.1
103
-
104
- ## 0.1.0-alpha.12
105
-
106
- ### Minor Changes
107
-
108
- - Publish the post-alpha.11 SDK and React SDK surface: funds v1 sub-account
109
- runtime coverage, React hook wiring, payments list support, and the latest
110
- generated Convex API snapshots used by current alpha consumers.
111
-
112
- Note: alpha.10 and alpha.11 were intermediate runner artifacts from the
113
- prior release pipeline (manual `package.json` bumps that were never folded
114
- back into the repo). alpha.12 reconciles `package.json`, the changesets
115
- state, and npm to a single consistent version.
116
-
117
- ### Patch Changes
118
-
119
- - Updated dependencies
120
- - @capxul/sdk@0.1.0-alpha.12
121
-
122
- ## 0.1.0-alpha.9
123
-
124
- ### Minor Changes
125
-
126
- - Add the canonical auth bootstrap flow.
127
-
128
- `verifyOtp()` now resolves a verified email session into either an
129
- `existing_member` identity or a `bootstrap_required` continuation. New and
130
- incomplete members continue through `completeBootstrap()`, which validates a
131
- server-issued bootstrap token, claims the username, provisions the account/Safe
132
- through the backend bootstrap path, and returns the authenticated product
133
- identity. The React SDK adds `useAuthBootstrapFlow()` as the typed first-run
134
- flow wrapper.
135
-
136
- ### Patch Changes
137
-
138
- - Updated dependencies
139
- - @capxul/sdk@0.1.0-alpha.9
140
-
141
- ## 0.1.0-alpha.8
142
-
143
- ### Minor Changes
144
-
145
- - 3af04a9: Public `<CapxulProvider>` now wires authenticated Convex reads end-to-end (#487, closes #484).
146
-
147
- The `build-time-urls` arm of `BrowserCapxulConfig` now causes the provider to internally instantiate a `ConvexReactClient`, wrap it as a `CapxulDataClient`, and feed it as `config.data` into `createCapxulClient`. The existing `auth.createDataClient` callback is wired to the same singleton so a `verifyOtp` call refreshes the data client's auth header without churning the WebSocket. The provider also wraps `client.auth.signOut` so the data client survives sign-out — post-signout reads return typed backend `NOT_AUTHENTICATED` instead of the SDK's `NOT_IMPLEMENTED` stub (closes the #474 friction as a side-effect).
148
-
149
- New optional `sessionStore?: AuthSessionStore` prop lets browser apps opt into `localStorage`-backed persistence and Node consumers (CLIs, e2e harnesses) opt into file-backed persistence. Defaults to in-memory.
150
-
151
- This closes the architectural gap that made the React hook surface (`useMe`, `useAccount`, `useSafe`, ...) impossible to exercise end-to-end through the public provider — previously `config.data` was never populated, so every authenticated read short-circuited to `NOT_IMPLEMENTED`. The Ink reference CLI (`apps/reference-cli/`) is rebuilt on top of the public provider as proof: 17/17 agent-driver assertions pass against live alpha-3 Convex, including a dev-OTP authenticated round-trip that mints a real session via `AUTH_DEV_OTP=00000` and exercises three distinct hook end-states (`NOT_AUTHENTICATED`, `PROFILE_NOT_FOUND`, post-signout `NOT_AUTHENTICATED`).
152
-
153
- - 57203a4: Withdrawals v1 W2 (#465) — public surface tightening + org-scope create
154
- - `WithdrawalsCreateInput.destination` no longer accepts `kind`. The
155
- backend now resolves the `external_account` row by FK and infers
156
- the kind + rail server-side. Anything that doesn't route to
157
- `chain_wallet` (or is chain_wallet but non-EVM in slice 1) returns
158
- `VERIFICATION_REQUIRED` with `details.rail` + `details.currentKind`.
159
- - `organizations.withdrawals.create` is now a real mutation (no
160
- longer a `NOT_IMPLEMENTED` stub). Returns the `processing` row
161
- only — Safe + Zodiac submission orchestration ships in W3+.
162
- - `Errors.verificationRequired({ rail, currentKind })` factory
163
- added; the `VERIFICATION_REQUIRED` code now broadens to cover
164
- both KYC tier gates and unsupported withdrawal rails.
165
-
166
- **Migration:** Remove `destination.kind` from any
167
- `capxul.withdrawals.create({ destination: { kind, externalAccountId } })`
168
- call sites. Pass only `externalAccountId`.
169
-
170
- ### Patch Changes
171
-
172
- - Updated dependencies [57203a4]
173
- - @capxul/sdk@0.1.0-alpha.8
174
-
175
- ## 0.1.0-alpha.4
176
-
177
- ### Minor Changes
178
-
179
- - Post-alpha hardening — WAVE 1 + WAVE 2 cumulative
180
-
181
- **WAVE 1 (merged 2026-05-03 12:44Z):**
182
- - S2 story 1: wire onboarding readback hooks (#469) — `me.update`, `accounts.retrieve`, `accounts.update`, `useAccount`, `useSafe`
183
- - S3 phase 1: Ink reference CLI scaffold + `auth+me` end-to-end against live alpha-3 Convex (#470). Stickiness gate (D3) fired.
184
- - S5: split `CapxulProvider` into public single-input `BrowserCapxulConfig` + test-only `CapxulTestProvider` from `@capxul/sdk-react/proof` (#473). Q1 lock honored. 7 type-level provider-shape guards including `@ts-expect-error` against test-provider leaking to public barrel.
185
-
186
- **WAVE 2 (merged 2026-05-03 12:54-13:16Z):**
187
- - S3 phase 2: per-domain CLI commands closing #458 (#476) — `account retrieve/update`, `safe retrieve`, `payment retrieve`, `withdrawal retrieve/list`. 12/12 agent-driver tests pass.
188
- - S2 story 2: `capxul.tokenTransfers.*` non-canonical SDK namespace (#479) — Option A per #477 (canon-aligned `transfers.*` shape deferred to alpha.5+ pending backend canon work). New `useTokenTransfers` + `useTokenTransfer` hooks; new `getByTxLogIndex` backend query. Hook proof matrix length unchanged at 41 (non-canonical hooks deliberately excluded).
189
-
190
- **S1 (#456) closed no-op** — alpha publish infrastructure (tsup, lazy-DX, transport state machine, npm metadata, READMEs, CHANGELOG, changesets, OIDC release workflow) physically merged into `api-first` via PRs #449-#452 earlier the same day; the slice merge produced 0 file changes per clean-room probe.
191
-
192
- **Friction issues filed for alpha.4+ polish:**
193
- - #474 — `me.get` returns `NOT_IMPLEMENTED` when `config.data` is undefined; should be `NOT_AUTHENTICATED`.
194
- - #475 — `@capxul/sdk/headless` slim entry point excludes xstate flow machines + brand constructors (1.6 MB → much smaller).
195
- - #477 / #478 — `transfers.*` / `balanceLedger.*` / `treasury` canon-shape alignment with indexer feed.
196
- - #471 — Vercel-capxul-web preview-deploy systemic failure on api-first base (separate from epic).
197
-
198
- ### Patch Changes
199
-
200
- - Updated dependencies
201
- - @capxul/sdk@0.1.0-alpha.4
202
-
203
- ## 0.1.0-alpha.3
204
-
205
- ### Patch Changes
206
-
207
- - Re-export `tryCatch` from `@capxul/sdk`.
208
-
209
- `tryCatch` is referenced in `packages/sdk/README.md` (live on npm at
210
- `0.1.0-alpha.2`) and in `.claude/rules/sdk.md` as the canonical
211
- async-error helper for SDK operations:
212
-
213
- ```ts
214
- import { tryCatch } from "@capxul/sdk";
215
-
216
- const [err, payment] = await tryCatch(capxul.payments.create({ ... }));
217
- ```
218
-
219
- The helper lives at `@repo/observability/try-catch.ts` and is bundled
220
- into the SDK dist via tsup `noExternal`, but it was never re-exported
221
- from `packages/sdk/src/index.ts`. Consumers following the README example
222
- hit `Module '"@capxul/sdk"' has no exported member 'tryCatch'.` at
223
- import time.
224
-
225
- Caught during alpha.2 spike-install verification (REVIEW.html, "What's
226
- not proven" row 6). One-line public-export addition; no runtime change.
227
-
228
- - Updated dependencies
229
- - @capxul/sdk@0.1.0-alpha.3
230
-
231
- ## 0.1.0-alpha.2
232
-
233
- ### Patch Changes
234
-
235
- - Add `convex` as a peer dependency.
236
-
237
- `@capxul/sdk`'s bundled `_generated/api` snapshot calls
238
- `anyApi` / `componentsGeneric` from `convex/server` at runtime — they
239
- are not just types — and tsup correctly externalizes `convex` /
240
- `convex/server` / `convex/react` so the consumer's own Convex install
241
- is reused. The peer was missing from the published manifest, so
242
- `require('@capxul/sdk')` failed with `Cannot find module 'convex/server'`
243
- in any spike that hadn't already installed `convex`.
244
-
245
- `@capxul/sdk-react` mirrors the peer because its bundle re-exports
246
- flow-machine constructors from `@capxul/sdk` and may transitively
247
- pull in the same module.
248
-
249
- Caught during alpha.1 spike-install verification.
250
-
251
- - Updated dependencies
252
- - @capxul/sdk@0.1.0-alpha.2
253
-
254
- ## 0.1.0-alpha.1
255
-
256
- ### Patch Changes
257
-
258
- - Move workspace `@repo/*` packages from `dependencies` to
259
- `devDependencies` so the published `package.json` doesn't list them
260
- as runtime deps. The tsup pipeline bundles every `@repo/*` import
261
- inline (`noExternal`), so the published code has zero references to
262
- those packages — but until now the published `package.json` still
263
- declared them, and `npm install @capxul/sdk@0.1.0-alpha.0` failed
264
- trying to resolve `@repo/api-contract@0.0.0` etc. on the public
265
- registry.
266
-
267
- `@capxul/sdk-react` keeps `@capxul/sdk` as a runtime dep — that one
268
- is published.
269
-
270
- No public surface changes. Pure publish-metadata correction caught
271
- during alpha.0 spike-install verification.
272
-
273
- - Updated dependencies
274
- - @capxul/sdk@0.1.0-alpha.1
275
-
276
- Changelog managed by [changesets](https://github.com/changesets/changesets) —
277
- see `.changeset/README.md` for the operator workflow.
278
-
279
- ## 0.1.0-alpha.0
280
-
281
- ### Minor Changes
282
-
283
- - Initial alpha publish.
284
-
285
- `@capxul/sdk` ships the headless TypeScript client for Capxul's
286
- `/v1/*` HTTP contract — auth, me, accounts, payments, organizations,
287
- withdrawals, documents, and three XState v5 flow machines. Errors
288
- are typed `CapxulError` instances with narrowed `code` unions per
289
- method; `tryCatch` returns the canonical `[error, data]` tuple.
290
-
291
- `@capxul/sdk-react` ships the React provider and hooks. The lazy-DX
292
- `<CapxulProvider publishableKey="cap_pk_…">` mounts synchronously
293
- and bootstraps runtime URLs through `/v1/client/bootstrap` on the
294
- first SDK call. `useCapxulStatus()` exposes the canonical 5-state
295
- transport lifecycle through `useSyncExternalStore`. Read hooks
296
- return the canonical `QueryResult<T>` three-state discriminated
297
- union (loading / data / error) — never throws on "still loading".
298
-
299
- See each package's `README.md` for the public surface.
300
-
301
- ### Patch Changes
302
-
303
- - Updated dependencies
304
- - @capxul/sdk@0.1.0-alpha.0
package/LICENSE DELETED
@@ -1,44 +0,0 @@
1
- Copyright (c) 2026 Xelmar Tech Ltd. ("Capxul"). All rights reserved.
2
-
3
- This software ("@capxul/sdk-react", the "Software") is proprietary to
4
- Capxul. The Software is licensed, not sold, and is made available
5
- solely to registered Capxul customers under the Capxul Terms of
6
- Service or a separate written commercial agreement between Capxul and
7
- the licensee.
8
-
9
- Two-layer trust
10
- ---------------
11
- Capxul's value-bearing on-chain logic — Safe v1.4.1, ERC-4337 modules,
12
- and any contract that custodies, transfers, or signs over user funds —
13
- is open source under permissive licenses and is published in a
14
- separate, auditable repository. See:
15
-
16
- https://github.com/Xelmar-tech/Capxul
17
-
18
- The orchestration layer in this package — React provider, hooks,
19
- state-machine wiring, integration glue, and any code that translates
20
- customer intent into transactions or routes data between subsystems —
21
- is the proprietary product of Capxul and is governed by this license.
22
-
23
- Customers of the Capxul platform may use this Software solely:
24
- (a) to access Capxul's hosted services they have contracted for,
25
- (b) within the scope of their active subscription or trial, and
26
- (c) in accordance with the Capxul Terms of Service.
27
-
28
- Without limiting the foregoing, you may NOT:
29
- (i) redistribute, sublicense, sell, lease, or rent the Software,
30
- (ii) reverse-engineer, decompile, or disassemble the Software,
31
- except to the limited extent applicable mandatory law
32
- permits, and
33
- (iii) remove or alter copyright, trademark, or other proprietary
34
- notices in the Software.
35
-
36
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
37
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
38
- FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT
39
- SHALL CAPXUL OR ITS AFFILIATES BE LIABLE FOR ANY CLAIM, DAMAGES, OR
40
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE,
41
- ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
42
- OTHER DEALINGS IN THE SOFTWARE.
43
-
44
- Contact: legal@capxul.com
package/README.md DELETED
@@ -1,187 +0,0 @@
1
- # @capxul/sdk-react
2
-
3
- React provider + hooks for Capxul. Wraps [`@capxul/sdk`](https://www.npmjs.com/package/@capxul/sdk)
4
- in a synchronously-mounting provider with lazy bootstrap and a
5
- discriminated-union return shape on every read hook.
6
-
7
- > **Alpha — `0.x` is pre-release.** APIs can change between alpha
8
- > versions. Pin to an exact version and read the changelog before
9
- > upgrading.
10
-
11
- ## Install
12
-
13
- ```bash
14
- pnpm add @capxul/sdk @capxul/sdk-react react @tanstack/react-query
15
- # or: npm install @capxul/sdk @capxul/sdk-react react @tanstack/react-query
16
- ```
17
-
18
- Peer requirements:
19
-
20
- - React `>= 19.0.0`
21
- - `@tanstack/react-query` `^5`
22
- - `@xstate/react` `^5` (only if you use the flow hooks)
23
-
24
- ## Two-layer trust
25
-
26
- This package is the **orchestration** half of Capxul's two-layer
27
- architecture. Funds are custodied by audited, open-source Safe v1.4.1
28
- contracts published in the [Capxul GitHub repo](https://github.com/Xelmar-tech/Capxul/tree/main/packages/contracts).
29
- The React glue here is proprietary — see [`LICENSE`](./LICENSE).
30
-
31
- ## Quickstart
32
-
33
- Wrap your app once with `CapxulProvider`. Pass a publishable key
34
- (`cap_pk_live_…` / `cap_pk_test_…`). The provider mounts synchronously
35
- — no Suspense gate, no async-mount stall — and lazily bootstraps the
36
- runtime URLs from `/v1/client/bootstrap` on the first SDK call:
37
-
38
- ```tsx
39
- import { CapxulProvider } from "@capxul/sdk-react";
40
-
41
- export default function RootLayout({ children }) {
42
- return (
43
- <CapxulProvider
44
- config={{
45
- mode: "publishable-key",
46
- publishableKey: process.env.NEXT_PUBLIC_CAPXUL_PUBLISHABLE_KEY!,
47
- }}
48
- >
49
- {children}
50
- </CapxulProvider>
51
- );
52
- }
53
- ```
54
-
55
- Inside the tree, read identity with `useMe()`. The hook collapses the
56
- multi-step lifecycle (not-bootstrapped, bootstrapping, no-session,
57
- no-data, live) into three states the consumer cares about:
58
-
59
- ```tsx
60
- import { useMe } from "@capxul/sdk-react";
61
-
62
- function Header() {
63
- const me = useMe();
64
-
65
- if (me.isPending) return <span>Loading…</span>;
66
- if (me.isError) return <span>Couldn't load profile.</span>;
67
- return <span>Hi, {me.data.username}</span>;
68
- }
69
- ```
70
-
71
- Drive an OTP sign-in flow with `useAuth()` — the canonical React auth
72
- wrapper over `AuthService`:
73
-
74
- ```tsx
75
- import { useAuth } from "@capxul/sdk-react";
76
-
77
- function SignIn() {
78
- const auth = useAuth();
79
-
80
- if (auth.state === "idle") {
81
- return (
82
- <button onClick={() => auth.signIn("alice@example.com")}>
83
- Send code
84
- </button>
85
- );
86
- }
87
- // … handle "sendingOtp", "awaitingOtp", "bootstrapping", "authenticated"
88
- }
89
- ```
90
-
91
- ## Lifecycle observability — `useCapxulStatus()`
92
-
93
- Need a status indicator or a gate UI? Subscribe to the underlying
94
- transport state machine:
95
-
96
- ```tsx
97
- import { useCapxulStatus } from "@capxul/sdk-react";
98
-
99
- function Banner() {
100
- const status = useCapxulStatus();
101
-
102
- switch (status.status) {
103
- case "idle": // no network call yet
104
- case "bootstrapping": // /v1/client/bootstrap in flight
105
- return <Spinner />;
106
- case "ready": // bootstrapped, no session
107
- case "authenticated": // bootstrapped + session live
108
- return null;
109
- case "error":
110
- return <ErrorBanner error={status.error} />;
111
- }
112
- }
113
- ```
114
-
115
- `useCapxulStatus()` is a thin
116
- [`useSyncExternalStore`](https://react.dev/reference/react/useSyncExternalStore)
117
- subscription against the transport singleton — only the components
118
- that actually call it re-render when state changes. The provider
119
- itself never re-renders.
120
-
121
- ## Publishable-key proof status
122
-
123
- The publishable-key path is runtime-proven where the repo can run it
124
- without secrets:
125
-
126
- | Surface | Runtime proof | Expected safe signal |
127
- | -------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
128
- | Provider + `useMe()` | `corepack pnpm --filter @capxul/sdk-react check-types` plus the headless proof tests under `packages/sdk-react/ops/proof` | provider reaches `useCapxulStatus().status === "ready"` after one bootstrap request |
129
- | Reference CLI mock | `corepack pnpm --filter @capxul/reference-cli build && node apps/reference-cli/dist/cli.js bootstrap probe --mock --json` | `ok:true`, `mode:"publishable-key"`, `bootstrapRequests:1`, `authRequests:1`, `keyLengthClass:"provided"` |
130
- | Reference CLI live | same command without `--mock`, with `CAPXUL_REF_PUBLISHABLE_KEY` and optional `CAPXUL_REF_BOOTSTRAP_URL` set locally | success only when the key/origin/runtime are valid; otherwise sanitized SDK error JSON |
131
-
132
- Do not paste or commit publishable keys, session tokens, Convex JWTs,
133
- cookies, or provider payloads. Proof output reports only
134
- `keyLengthClass`.
135
-
136
- ## Hooks catalogue
137
-
138
- | Surface | Hook |
139
- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
140
- | Imperative client | `useCapxul()` |
141
- | Identity | `useMe`, `useAccount` |
142
- | Organizations | `useOrganization`, `useOrganizations`, `useMember`, `useMembers` |
143
- | Payments | `usePayment`, `usePayments`, `useOrgPayments` |
144
- | Transfers | `useTransfer`, `useTransfers`, `useOrgTransfers` |
145
- | Withdrawals | `useWithdrawal`, `useWithdrawals`, `useOrgWithdrawals` |
146
- | Documents | `useDocument`, `useDocuments`, `useOrgDocuments` |
147
- | Sub-accounts / virtual | `useSubAccount`, `useSubAccounts`, `useVirtualAccount`, `useVirtualAccounts`, `useVirtualCard`, `useVirtualCards` |
148
- | Settings | `useApiKey`, `useApiKeys`, `useWebhookEndpoint`, `useWebhookEndpoints`, `useWebhookEvent`, `useExternalAccount`, `useExternalAccounts`, `useBalanceLedgerEntry`, `useBalanceLedger` |
149
- | KYC / KYB | `useKycProfile` |
150
- | Treasury | `useTreasury`, `useSafe` |
151
- | Operations | `useOperation` (correlation join key per CANON.md §3.3) |
152
- | Lifecycle | `useCapxulStatus` |
153
- | Flows | `useOnboardingFlow`, `useProvisioningFlow` |
154
-
155
- Most "not-yet-implemented" verticals return a `QueryResult<T>` in the
156
- `error` state with `code: "NOT_IMPLEMENTED"` — they compile, render
157
- without crashing, and surface a clear runtime signal.
158
-
159
- ## Three-state read shape (`QueryResult<T>`)
160
-
161
- Read hooks return a discriminated union:
162
-
163
- ```ts
164
- type QueryResult<T> =
165
- | { readonly status: "loading" }
166
- | { readonly status: "data"; readonly data: T }
167
- | { readonly status: "error"; readonly error: CapxulError };
168
- ```
169
-
170
- Hooks **never throw** for a "still loading" condition. Pattern-match
171
- on `status`. (`useMe()` is the first hook migrated to TanStack Query
172
- — it returns `UseQueryResult<Account, CapxulError>` for now; the
173
- remaining hooks lift to that shape over time.)
174
-
175
- ## Server / CLI consumers
176
-
177
- `@capxul/sdk-react` is browser-only. For server, CLI, and harness
178
- code, build a `CapxulClient` directly with `createCapxulClient` from
179
- `@capxul/sdk` — no provider, no React. See that package's README.
180
-
181
- ## License
182
-
183
- Proprietary — see [`LICENSE`](./LICENSE). The orchestration code in
184
- this package is governed by the Capxul Terms of Service. The
185
- value-bearing custody contracts are open source.
186
-
187
- Contact: [legal@capxul.com](mailto:legal@capxul.com)