@capxul/sdk 0.1.0-alpha.9 → 0.2.0-alpha.4
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/CHANGELOG.md +126 -0
- package/README.md +103 -16
- package/dist/{client-ChZrdf3R.d.ts → client-CbUeJoM9.d.ts} +84 -235
- package/dist/{client-DG6ODWu6.d.cts → client-UEm2oZbZ.d.cts} +84 -235
- package/dist/client.cjs +1655 -1073
- package/dist/client.d.cts +4 -4
- package/dist/client.d.ts +4 -4
- package/dist/client.js +1655 -1073
- package/dist/{errors-QHD5Tlok.d.ts → errors-CwhCWGxm.d.ts} +1 -1
- package/dist/{errors-GgKrSUKp.d.cts → errors-rqxuUhQP.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/index.cjs +1655 -1076
- package/dist/index.d.cts +73 -112
- package/dist/index.d.ts +73 -112
- package/dist/index.js +1654 -1076
- package/dist/{next-action-DkrwXYay.d.cts → next-action-CTGl8wpy.d.cts} +2 -2
- package/dist/{next-action-DkrwXYay.d.ts → next-action-CTGl8wpy.d.ts} +2 -2
- package/dist/{types-PM4AQRLP.d.ts → types-BD4VAQb5.d.ts} +77 -8
- package/dist/{types-hfcOE7Oi.d.cts → types-HlwCIjgQ.d.cts} +77 -8
- package/dist/webhooks.cjs +1 -1
- package/dist/webhooks.d.cts +2 -2
- package/dist/webhooks.d.ts +2 -2
- package/dist/webhooks.js +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,131 @@
|
|
|
1
1
|
# @capxul/sdk
|
|
2
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
|
+
|
|
21
|
+
## 0.2.0-alpha.3
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 5b99a9b: **Publishable-key path + error classification (#675).** Two tangled bugs landed in the consumer-path proof.
|
|
26
|
+
|
|
27
|
+
**Reference-cli was on the wrong path.** `build-browser-config.ts` had a `build-time-urls` fallback that fired silently whenever `CAPXUL_REF_PUBLISHABLE_KEY` was unset, so the CLI routed direct to Convex URLs and bypassed `/v1/client/bootstrap` entirely. It "worked" through a code path no external SDK consumer will ever run, masking publishable-key path breakage.
|
|
28
|
+
|
|
29
|
+
Reference-cli now:
|
|
30
|
+
- Requires `CAPXUL_REF_PUBLISHABLE_KEY`. The repo ships a long-lived shared sandbox key at `apps/reference-cli/.env.example` so `git clone && export $(...)` works; the key targets `elated-oyster-269`, is environment `test` (`cap_pk_test_*`), and is intentionally shareable.
|
|
31
|
+
- Strips the `build-time-urls` arm entirely. There is no silent fallback — missing env produces a structured `ENV_MISSING` envelope with an actionable message.
|
|
32
|
+
- Keeps `bootstrap probe --mock` working env-less (the mock factory bypasses `buildBrowserInputs()`).
|
|
33
|
+
|
|
34
|
+
**Error classification.** The SDK's auth-layer catch was swallowing typed bootstrap errors. A bad publishable key produced HTTP 401 + `NOT_AUTHENTICATED: "Publishable key is invalid or revoked."` from the bootstrap endpoint, but `postBetterAuth`'s `catch (cause)` wrapped any throw from `transport.fetch()` as `NETWORK_ERROR: "BetterAuth … network failure."`, burying the real diagnosis on `cause`. Reference-cli then flattened further to `AUTH_ERROR`.
|
|
35
|
+
|
|
36
|
+
The SDK now:
|
|
37
|
+
- Preserves `CapxulError` verbatim in `postBetterAuth` and `exchangeConvexToken` catches. Genuine non-`CapxulError` throws still fall back to `NETWORK_ERROR`.
|
|
38
|
+
- Widens `SendOtpCodes` + `VerifyOtpCodes` to include `NOT_AUTHENTICATED` and `PERMISSION_DENIED` so consumers can exhaustively narrow bootstrap-layer errors.
|
|
39
|
+
|
|
40
|
+
**Consumer impact:** SDK consumers that switch on `err.code` from `auth.sendOtp` / `auth.verifyOtp` should now expect `NOT_AUTHENTICATED` (bad/revoked publishable key) and `PERMISSION_DENIED` (origin not on the key's allow-list) as additional possible codes alongside the existing BetterAuth + rate-limit codes. No type-narrowing regressions — the unions only widened.
|
|
41
|
+
|
|
42
|
+
## 0.2.0-alpha.2
|
|
43
|
+
|
|
44
|
+
### Minor Changes
|
|
45
|
+
|
|
46
|
+
- 995383f: Epic 660: Unified auth surface
|
|
47
|
+
- Introduces AuthService promise-based auth API replacing the imperative capxul.auth.\* tuple interface
|
|
48
|
+
- Adds SignerProvisioner for deterministic Safe v1.4.1 address derivation from viem signers
|
|
49
|
+
- Adds useAuth() React hook with reactive state + promise-based methods
|
|
50
|
+
- Deprecates useAuthFlow and useAuthBootstrapFlow in favor of useAuth()
|
|
51
|
+
- Migrates reference CLI auth commands (send-otp, verify-otp, signout) to useAuth()
|
|
52
|
+
- Migrates test surfaces: walkthroughs, type tests, e2e harness signup, lazy-dx provider
|
|
53
|
+
- Adds @repo/safe-derive workspace package for Safe address derivation utilities
|
|
54
|
+
- Aligns CapxulConfig.data to \_data with internal SDK transport ownership (Epic 652)
|
|
55
|
+
- Pins esbuild to 0.25.12 to fix binary-version skew in fresh worktrees
|
|
56
|
+
|
|
57
|
+
- 2ef4ee3: Reshape the organizations members surface around a single Membership entity
|
|
58
|
+
with a status lifecycle (`pending | active | revoked | expired`).
|
|
59
|
+
- Replaces the prior invitation/membership split (which produced a phantom
|
|
60
|
+
`MemberInvitation` type that never compiled) with a single `Member` type
|
|
61
|
+
exposing `status`, `email`, `acceptedAt`, `expiresAt`, and `resentCount`.
|
|
62
|
+
- New methods on `organizations.members.*`: `accept(token)`, `revoke(memberId)`,
|
|
63
|
+
`resend(memberId)`. `invite()` now returns a `MemberInviteResponse`
|
|
64
|
+
containing the raw invite token (returned once).
|
|
65
|
+
- Auto-accepts pending invitations on first sign-in for the matching email
|
|
66
|
+
via a BetterAuth post-signup hook.
|
|
67
|
+
- Nightly Convex cron expires overdue pending invitations.
|
|
68
|
+
|
|
69
|
+
Public type changes:
|
|
70
|
+
- Removed: `MemberInvitation` (was never exported; type didn't compile).
|
|
71
|
+
- Added: `MembershipStatus`, `MemberInviteResponse`.
|
|
72
|
+
- Updated: `Member` shape — see SDK reference for the full delta.
|
|
73
|
+
|
|
74
|
+
React hooks:
|
|
75
|
+
- New: `useAcceptInvitation`, `useRevokeMember`, `useResendInvitation`.
|
|
76
|
+
- Updated: `useInviteMember` returns `MemberInviteResponse` (was returning a
|
|
77
|
+
type that didn't exist).
|
|
78
|
+
|
|
79
|
+
Reference CLI:
|
|
80
|
+
- New commands: `org members invite`, `org members list`, `org members retrieve`,
|
|
81
|
+
`org members accept`, `org members updateRole`, `org members revoke`,
|
|
82
|
+
`org members remove`, `org members resend`.
|
|
83
|
+
|
|
84
|
+
- c7146bf: **Transport ownership (#656):** The SDK now owns construction of the
|
|
85
|
+
authenticated `ConvexHttpClient`. Consumers no longer wire `data` manually
|
|
86
|
+
or provide `auth.createDataClient`. After `verifyOtp` exchanges a Convex
|
|
87
|
+
JWT, the SDK builds the default data client internally via
|
|
88
|
+
`createDefaultDataClient` and stores it on `config._data`.
|
|
89
|
+
- `CapxulConfig.data` renamed to `_data` (internal test seam).
|
|
90
|
+
- `CapxulAuthConfig.createDataClient` removed from public types.
|
|
91
|
+
- `convex` moved from `peerDependencies` to `dependencies`.
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [995383f]
|
|
96
|
+
- @repo/safe-derive@0.0.1-alpha.0
|
|
97
|
+
|
|
98
|
+
## 0.2.0-alpha.1
|
|
99
|
+
|
|
100
|
+
### Minor Changes
|
|
101
|
+
|
|
102
|
+
- **Transport ownership (#656):** The SDK now owns construction of the
|
|
103
|
+
authenticated `ConvexHttpClient`. Consumers no longer wire `data` manually
|
|
104
|
+
or provide `auth.createDataClient`. After `verifyOtp` exchanges a Convex
|
|
105
|
+
JWT, the SDK builds the default data client internally via
|
|
106
|
+
`createDefaultDataClient` and stores it on `config._data`.
|
|
107
|
+
- `CapxulConfig.data` renamed to `_data` (internal test seam).
|
|
108
|
+
- `CapxulAuthConfig.createDataClient` removed from public types.
|
|
109
|
+
- `convex` moved from `peerDependencies` to `dependencies`.
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- Bundle `@repo/safe-derive` into the published artifact so the new
|
|
114
|
+
`SignerProvisioner` class works for external consumers.
|
|
115
|
+
|
|
116
|
+
## 0.1.0-alpha.12
|
|
117
|
+
|
|
118
|
+
### Minor Changes
|
|
119
|
+
|
|
120
|
+
- Publish the post-alpha.11 SDK and React SDK surface: funds v1 sub-account
|
|
121
|
+
runtime coverage, React hook wiring, payments list support, and the latest
|
|
122
|
+
generated Convex API snapshots used by current alpha consumers.
|
|
123
|
+
|
|
124
|
+
Note: alpha.10 and alpha.11 were intermediate runner artifacts from the
|
|
125
|
+
prior release pipeline (manual `package.json` bumps that were never folded
|
|
126
|
+
back into the repo). alpha.12 reconciles `package.json`, the changesets
|
|
127
|
+
state, and npm to a single consistent version.
|
|
128
|
+
|
|
3
129
|
## 0.1.0-alpha.9
|
|
4
130
|
|
|
5
131
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -30,10 +30,10 @@ React-flavored entry point lives in `@capxul/sdk-react`. Pick:
|
|
|
30
30
|
|
|
31
31
|
Capxul splits the platform into two layers with different licenses:
|
|
32
32
|
|
|
33
|
-
| Layer
|
|
34
|
-
|
|
35
|
-
| Custody (on-chain)
|
|
36
|
-
| Orchestration (this package) | Workflow logic, business rules, integration glue, the `/v1/*` HTTP client
|
|
33
|
+
| Layer | What it does | License |
|
|
34
|
+
| ---------------------------- | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| Custody (on-chain) | Safe v1.4.1 + ERC-4337 modules — every contract that holds, transfers, or signs over user funds | Open source, audited, in the [Capxul GitHub repo](https://github.com/Xelmar-tech/Capxul/tree/main/packages/contracts) |
|
|
36
|
+
| Orchestration (this package) | Workflow logic, business rules, integration glue, the `/v1/*` HTTP client | Proprietary — see `LICENSE` |
|
|
37
37
|
|
|
38
38
|
You don't have to take our word for the parts that hold money — those
|
|
39
39
|
contracts are open and auditable. The parts that orchestrate workflows
|
|
@@ -94,7 +94,10 @@ runtime URLs by POSTing to `/v1/client/bootstrap` on the first auth or
|
|
|
94
94
|
small:
|
|
95
95
|
|
|
96
96
|
```json
|
|
97
|
-
{
|
|
97
|
+
{
|
|
98
|
+
"authBaseUrl": "https://<deployment>.convex.site/api/auth",
|
|
99
|
+
"convexUrl": "https://<deployment>.convex.cloud"
|
|
100
|
+
}
|
|
98
101
|
```
|
|
99
102
|
|
|
100
103
|
The resolved runtime is cached for the lifetime of the transport. Concurrent
|
|
@@ -136,11 +139,11 @@ try {
|
|
|
136
139
|
|
|
137
140
|
Runtime proof status:
|
|
138
141
|
|
|
139
|
-
| Surface
|
|
140
|
-
|
|
141
|
-
| SDK transport
|
|
142
|
-
| React provider | `CapxulProvider config={{ mode: "publishable-key", ... }}`
|
|
143
|
-
| Reference CLI
|
|
142
|
+
| Surface | Source support | Runtime proof | Status |
|
|
143
|
+
| -------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
|
|
144
|
+
| SDK transport | `makeHttpTransport({ mode: "publishable-key", publishableKey })` | `packages/sdk/tests/unit/transport.test.ts` proves config validation, singleflight bootstrap, retry after failure, lifecycle transitions, and sanitized backend errors. | Proven with mocked fetch |
|
|
145
|
+
| React provider | `CapxulProvider config={{ mode: "publishable-key", ... }}` | `packages/sdk-react/ops/proof/react-headless.test.tsx` proves bootstrap before a real `useMe()` read through the provider and lazy Convex data client. | Proven with mocked fetch + headless React |
|
|
146
|
+
| Reference CLI | `bootstrap probe --mock --json` | `apps/reference-cli/scripts/agent-driver.ts` phase 0 and the direct CLI command prove provider/bootstrap/auth ordering and sanitized output. | Proven locally; live endpoint remains manual-key gated |
|
|
144
147
|
|
|
145
148
|
Copy-paste local replication:
|
|
146
149
|
|
|
@@ -160,7 +163,16 @@ fresh checkout; the CLI depends on their generated declaration outputs.
|
|
|
160
163
|
Expected sanitized pass signal:
|
|
161
164
|
|
|
162
165
|
```json
|
|
163
|
-
{
|
|
166
|
+
{
|
|
167
|
+
"command": "bootstrap.probe",
|
|
168
|
+
"ok": true,
|
|
169
|
+
"mode": "publishable-key",
|
|
170
|
+
"status": "ready",
|
|
171
|
+
"bootstrapRequests": 1,
|
|
172
|
+
"authRequests": 1,
|
|
173
|
+
"keyLengthClass": "provided",
|
|
174
|
+
"mocked": true
|
|
175
|
+
}
|
|
164
176
|
```
|
|
165
177
|
|
|
166
178
|
## Public surface (alpha)
|
|
@@ -171,12 +183,36 @@ capxul.me // get, update — first-party caller identity
|
|
|
171
183
|
capxul.accounts // create, retrieve, list
|
|
172
184
|
capxul.organizations // CRUD + members + payments + treasury
|
|
173
185
|
capxul.payments // create, retrieve, list
|
|
174
|
-
capxul.invoices // create, retrieve, list
|
|
175
186
|
capxul.withdrawals // create, retrieve, list
|
|
176
|
-
capxul.documents //
|
|
187
|
+
capxul.documents // personal invoices first; broader document variants typed
|
|
177
188
|
capxul.flows.{auth, onboarding, provisioning} // XState v5 flows
|
|
178
189
|
```
|
|
179
190
|
|
|
191
|
+
### Personal invoice documents
|
|
192
|
+
|
|
193
|
+
The first `documents` runtime surface is the personal invoice pilot.
|
|
194
|
+
It creates immutable open invoice documents with a canonical
|
|
195
|
+
`invoiceHash`. The backend stores the private invoice payload; the
|
|
196
|
+
chain receives only the hash as `documentHash`.
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
const [err, invoice] = await capxul.documents.create({
|
|
200
|
+
type: "invoice",
|
|
201
|
+
recipient: { email: "client@example.com" },
|
|
202
|
+
amount: { value: "25.00", currency: "USD" },
|
|
203
|
+
lineItems: [
|
|
204
|
+
{ description: "Design", quantity: 1, unitPrice: "25.00", currency: "USD" },
|
|
205
|
+
],
|
|
206
|
+
reference: "May design work",
|
|
207
|
+
dueAt: "2026-05-20T00:00:00.000Z",
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Use `capxul.documents.retrieve(docId)`, `.list({ type: "invoice" })`,
|
|
212
|
+
and `.cancel(docId)` for the rest of the pilot surface. Org-admin
|
|
213
|
+
invoices, file uploads, PDFs, partial payments, and mutable open
|
|
214
|
+
invoices are outside this pilot.
|
|
215
|
+
|
|
180
216
|
Helpers:
|
|
181
217
|
|
|
182
218
|
- `tryCatch(promise)` — error tuple `[error, data]`; routes on
|
|
@@ -186,6 +222,54 @@ Helpers:
|
|
|
186
222
|
- Branded type constructors — `toEmail`, `toAccountId`,
|
|
187
223
|
`toOrganizationId`, … — never cast raw strings
|
|
188
224
|
|
|
225
|
+
## Organizations
|
|
226
|
+
|
|
227
|
+
Create an organization, manage its treasury, and invite members with
|
|
228
|
+
role-based access:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
// Create
|
|
232
|
+
const [err, org] = await capxul.organizations.create({ name: "Acme" });
|
|
233
|
+
|
|
234
|
+
// Invite a member — returns the raw token once
|
|
235
|
+
const [err, { member, inviteToken }] =
|
|
236
|
+
await capxul.organizations.members.invite({
|
|
237
|
+
organizationId: org.id,
|
|
238
|
+
email: "alice@example.com",
|
|
239
|
+
role: "finance_manager",
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// List members — defaults to active; pass status to filter
|
|
243
|
+
const [err, list] = await capxul.organizations.members.list({
|
|
244
|
+
organizationId: org.id,
|
|
245
|
+
status: "pending", // "pending" | "active" | "revoked" | "expired" | "all"
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Accept an invitation (called by the invitee)
|
|
249
|
+
const [err, member] = await capxul.organizations.members.accept({
|
|
250
|
+
token: inviteToken,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// Revoke a pending invitation
|
|
254
|
+
const [err] = await capxul.organizations.members.revoke({
|
|
255
|
+
organizationId: org.id,
|
|
256
|
+
memberId: member.id,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// Remove an active member
|
|
260
|
+
const [err] = await capxul.organizations.members.remove({
|
|
261
|
+
organizationId: org.id,
|
|
262
|
+
memberId: member.id,
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Member roles: `owner`, `finance_manager`, `payments_operator`,
|
|
267
|
+
`org_admin`, `viewer`, `accountant`. Only `owner` and `org_admin` can
|
|
268
|
+
invite, revoke, remove, or change roles.
|
|
269
|
+
|
|
270
|
+
Pending invitations auto-accept on first sign-in when the user's email
|
|
271
|
+
matches. Overdue pending invitations expire via a nightly cron.
|
|
272
|
+
|
|
189
273
|
## Error model
|
|
190
274
|
|
|
191
275
|
Every method returns a `CapxulResult<T, Codes>` tuple. Errors are
|
|
@@ -196,9 +280,12 @@ const [err, account] = await tryCatch(capxul.me.get());
|
|
|
196
280
|
|
|
197
281
|
if (err) {
|
|
198
282
|
switch (err.code) {
|
|
199
|
-
case "PROFILE_NOT_FOUND":
|
|
200
|
-
|
|
201
|
-
|
|
283
|
+
case "PROFILE_NOT_FOUND":
|
|
284
|
+
return router.push("/onboarding");
|
|
285
|
+
case "NOT_AUTHENTICATED":
|
|
286
|
+
return router.push("/login");
|
|
287
|
+
default:
|
|
288
|
+
throw err; // unhandled — bubble to the error boundary
|
|
202
289
|
}
|
|
203
290
|
}
|
|
204
291
|
```
|