@capxul/sdk 0.1.0-alpha.9 → 0.2.0-alpha.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/CHANGELOG.md +108 -0
- package/README.md +45 -0
- package/dist/{client-DG6ODWu6.d.cts → client-B_Z3ThFO.d.cts} +49 -51
- package/dist/{client-ChZrdf3R.d.ts → client-pMBRFcsz.d.ts} +49 -51
- package/dist/client.cjs +1283 -419
- package/dist/client.d.cts +4 -4
- package/dist/client.d.ts +4 -4
- package/dist/client.js +1283 -419
- 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 +1342 -410
- package/dist/index.d.cts +80 -9
- package/dist/index.d.ts +80 -9
- package/dist/index.js +1341 -412
- 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-hfcOE7Oi.d.cts → types-Brucpq0Z.d.cts} +63 -8
- package/dist/{types-PM4AQRLP.d.ts → types-V_D7qjxY.d.ts} +63 -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 +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,113 @@
|
|
|
1
1
|
# @capxul/sdk
|
|
2
2
|
|
|
3
|
+
## 0.2.0-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5b99a9b: **Publishable-key path + error classification (#675).** Two tangled bugs landed in the consumer-path proof.
|
|
8
|
+
|
|
9
|
+
**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.
|
|
10
|
+
|
|
11
|
+
Reference-cli now:
|
|
12
|
+
- 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.
|
|
13
|
+
- Strips the `build-time-urls` arm entirely. There is no silent fallback — missing env produces a structured `ENV_MISSING` envelope with an actionable message.
|
|
14
|
+
- Keeps `bootstrap probe --mock` working env-less (the mock factory bypasses `buildBrowserInputs()`).
|
|
15
|
+
|
|
16
|
+
**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`.
|
|
17
|
+
|
|
18
|
+
The SDK now:
|
|
19
|
+
- Preserves `CapxulError` verbatim in `postBetterAuth` and `exchangeConvexToken` catches. Genuine non-`CapxulError` throws still fall back to `NETWORK_ERROR`.
|
|
20
|
+
- Widens `SendOtpCodes` + `VerifyOtpCodes` to include `NOT_AUTHENTICATED` and `PERMISSION_DENIED` so consumers can exhaustively narrow bootstrap-layer errors.
|
|
21
|
+
|
|
22
|
+
**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.
|
|
23
|
+
|
|
24
|
+
## 0.2.0-alpha.2
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- 995383f: Epic 660: Unified auth surface
|
|
29
|
+
- Introduces AuthService promise-based auth API replacing the imperative capxul.auth.\* tuple interface
|
|
30
|
+
- Adds SignerProvisioner for deterministic Safe v1.4.1 address derivation from viem signers
|
|
31
|
+
- Adds useAuth() React hook with reactive state + promise-based methods
|
|
32
|
+
- Deprecates useAuthFlow and useAuthBootstrapFlow in favor of useAuth()
|
|
33
|
+
- Migrates reference CLI auth commands (send-otp, verify-otp, signout) to useAuth()
|
|
34
|
+
- Migrates test surfaces: walkthroughs, type tests, e2e harness signup, lazy-dx provider
|
|
35
|
+
- Adds @repo/safe-derive workspace package for Safe address derivation utilities
|
|
36
|
+
- Aligns CapxulConfig.data to \_data with internal SDK transport ownership (Epic 652)
|
|
37
|
+
- Pins esbuild to 0.25.12 to fix binary-version skew in fresh worktrees
|
|
38
|
+
|
|
39
|
+
- 2ef4ee3: Reshape the organizations members surface around a single Membership entity
|
|
40
|
+
with a status lifecycle (`pending | active | revoked | expired`).
|
|
41
|
+
- Replaces the prior invitation/membership split (which produced a phantom
|
|
42
|
+
`MemberInvitation` type that never compiled) with a single `Member` type
|
|
43
|
+
exposing `status`, `email`, `acceptedAt`, `expiresAt`, and `resentCount`.
|
|
44
|
+
- New methods on `organizations.members.*`: `accept(token)`, `revoke(memberId)`,
|
|
45
|
+
`resend(memberId)`. `invite()` now returns a `MemberInviteResponse`
|
|
46
|
+
containing the raw invite token (returned once).
|
|
47
|
+
- Auto-accepts pending invitations on first sign-in for the matching email
|
|
48
|
+
via a BetterAuth post-signup hook.
|
|
49
|
+
- Nightly Convex cron expires overdue pending invitations.
|
|
50
|
+
|
|
51
|
+
Public type changes:
|
|
52
|
+
- Removed: `MemberInvitation` (was never exported; type didn't compile).
|
|
53
|
+
- Added: `MembershipStatus`, `MemberInviteResponse`.
|
|
54
|
+
- Updated: `Member` shape — see SDK reference for the full delta.
|
|
55
|
+
|
|
56
|
+
React hooks:
|
|
57
|
+
- New: `useAcceptInvitation`, `useRevokeMember`, `useResendInvitation`.
|
|
58
|
+
- Updated: `useInviteMember` returns `MemberInviteResponse` (was returning a
|
|
59
|
+
type that didn't exist).
|
|
60
|
+
|
|
61
|
+
Reference CLI:
|
|
62
|
+
- New commands: `org members invite`, `org members list`, `org members retrieve`,
|
|
63
|
+
`org members accept`, `org members updateRole`, `org members revoke`,
|
|
64
|
+
`org members remove`, `org members resend`.
|
|
65
|
+
|
|
66
|
+
- c7146bf: **Transport ownership (#656):** The SDK now owns construction of the
|
|
67
|
+
authenticated `ConvexHttpClient`. Consumers no longer wire `data` manually
|
|
68
|
+
or provide `auth.createDataClient`. After `verifyOtp` exchanges a Convex
|
|
69
|
+
JWT, the SDK builds the default data client internally via
|
|
70
|
+
`createDefaultDataClient` and stores it on `config._data`.
|
|
71
|
+
- `CapxulConfig.data` renamed to `_data` (internal test seam).
|
|
72
|
+
- `CapxulAuthConfig.createDataClient` removed from public types.
|
|
73
|
+
- `convex` moved from `peerDependencies` to `dependencies`.
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- Updated dependencies [995383f]
|
|
78
|
+
- @repo/safe-derive@0.0.1-alpha.0
|
|
79
|
+
|
|
80
|
+
## 0.2.0-alpha.1
|
|
81
|
+
|
|
82
|
+
### Minor Changes
|
|
83
|
+
|
|
84
|
+
- **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
|
+
- Bundle `@repo/safe-derive` into the published artifact so the new
|
|
96
|
+
`SignerProvisioner` class works for external consumers.
|
|
97
|
+
|
|
98
|
+
## 0.1.0-alpha.12
|
|
99
|
+
|
|
100
|
+
### Minor Changes
|
|
101
|
+
|
|
102
|
+
- Publish the post-alpha.11 SDK and React SDK surface: funds v1 sub-account
|
|
103
|
+
runtime coverage, React hook wiring, payments list support, and the latest
|
|
104
|
+
generated Convex API snapshots used by current alpha consumers.
|
|
105
|
+
|
|
106
|
+
Note: alpha.10 and alpha.11 were intermediate runner artifacts from the
|
|
107
|
+
prior release pipeline (manual `package.json` bumps that were never folded
|
|
108
|
+
back into the repo). alpha.12 reconciles `package.json`, the changesets
|
|
109
|
+
state, and npm to a single consistent version.
|
|
110
|
+
|
|
3
111
|
## 0.1.0-alpha.9
|
|
4
112
|
|
|
5
113
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -186,6 +186,51 @@ Helpers:
|
|
|
186
186
|
- Branded type constructors — `toEmail`, `toAccountId`,
|
|
187
187
|
`toOrganizationId`, … — never cast raw strings
|
|
188
188
|
|
|
189
|
+
## Organizations
|
|
190
|
+
|
|
191
|
+
Create an organization, manage its treasury, and invite members with
|
|
192
|
+
role-based access:
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
// Create
|
|
196
|
+
const [err, org] = await capxul.organizations.create({ name: "Acme" });
|
|
197
|
+
|
|
198
|
+
// Invite a member — returns the raw token once
|
|
199
|
+
const [err, { member, inviteToken }] = await capxul.organizations.members.invite({
|
|
200
|
+
organizationId: org.id,
|
|
201
|
+
email: "alice@example.com",
|
|
202
|
+
role: "finance_manager",
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// List members — defaults to active; pass status to filter
|
|
206
|
+
const [err, list] = await capxul.organizations.members.list({
|
|
207
|
+
organizationId: org.id,
|
|
208
|
+
status: "pending", // "pending" | "active" | "revoked" | "expired" | "all"
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Accept an invitation (called by the invitee)
|
|
212
|
+
const [err, member] = await capxul.organizations.members.accept({ token: inviteToken });
|
|
213
|
+
|
|
214
|
+
// Revoke a pending invitation
|
|
215
|
+
const [err] = await capxul.organizations.members.revoke({
|
|
216
|
+
organizationId: org.id,
|
|
217
|
+
memberId: member.id,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// Remove an active member
|
|
221
|
+
const [err] = await capxul.organizations.members.remove({
|
|
222
|
+
organizationId: org.id,
|
|
223
|
+
memberId: member.id,
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Member roles: `owner`, `finance_manager`, `payments_operator`,
|
|
228
|
+
`org_admin`, `viewer`, `accountant`. Only `owner` and `org_admin` can
|
|
229
|
+
invite, revoke, remove, or change roles.
|
|
230
|
+
|
|
231
|
+
Pending invitations auto-accept on first sign-in when the user's email
|
|
232
|
+
matches. Overdue pending invitations expire via a nightly cron.
|
|
233
|
+
|
|
189
234
|
## Error model
|
|
190
235
|
|
|
191
236
|
Every method returns a `CapxulResult<T, Codes>` tuple. Errors are
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Account as Account$1 } from 'viem';
|
|
2
2
|
import * as xstate from 'xstate';
|
|
3
3
|
import { AnyStateMachine } from 'xstate';
|
|
4
|
-
import { A as AccountId, S as SafeId, c as KycProfileId, b as ExternalAccountId, f as SubAccountId, d as OrganizationId, a as ApiKeyId, X as TimestampIso, U as Username, E as Email, D as DocumentId, O as OperationId, P as PaymentId, g as TransferId, k as WithdrawalId, W as WebhookEndpointId, j as WebhookEventId, M as MemberId,
|
|
5
|
-
import { d as CapxulResult, C as CapxulError$1 } from './errors-
|
|
6
|
-
import { A as Account,
|
|
4
|
+
import { A as AccountId, S as SafeId, c as KycProfileId, b as ExternalAccountId, f as SubAccountId, d as OrganizationId, a as ApiKeyId, X as TimestampIso, U as Username, E as Email, D as DocumentId, O as OperationId, P as PaymentId, g as TransferId, k as WithdrawalId, W as WebhookEndpointId, j as WebhookEventId, M as MemberId, V as VirtualAccountId, i as VirtualCardId } from './next-action-CTGl8wpy.cjs';
|
|
5
|
+
import { d as CapxulResult, C as CapxulError$1 } from './errors-rqxuUhQP.cjs';
|
|
6
|
+
import { A as Account, X as UserIdentifier, a as AccountLookupResult, S as Safe, k as KycProfile, E as ExternalAccount, L as List, F as SubAccount, B as BalanceLedgerEntry, b as ApiKey, a5 as CreateApiKeyRequest, a6 as CreateDocumentRequest, D as Document, O as Operation, q as OperationStatus, p as Money, C as CreatePaymentResult, t as Payment, Q as TransferEndpoint, f as CreateTransferResult, J as Transfer, g as CreateWithdrawalResult, a3 as Withdrawal, a7 as CreateWebhookEndpointRequest, a1 as WebhookEndpoint, a2 as WebhookEvent, s as Organization, W as Treasury, o as MembershipStatus, M as Member, n as MemberInviteResponse, a8 as CreateVirtualAccountRequest, Y as VirtualAccount, a9 as CreateVirtualCardRequest, _ as VirtualCard } from './types-Brucpq0Z.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Accounts domain — individual user accounts per sdk-surface.md §1a.
|
|
@@ -22,7 +22,6 @@ type AccountUpdateInput = Partial<{
|
|
|
22
22
|
type LocalPrivateKeySignerProvider = {
|
|
23
23
|
readonly kind: "local-private-key";
|
|
24
24
|
readonly signerAddress: string;
|
|
25
|
-
readonly safeAddress: string;
|
|
26
25
|
};
|
|
27
26
|
type AccountProvisionPersonalInput = {
|
|
28
27
|
readonly displayName?: string;
|
|
@@ -40,6 +39,7 @@ type AccountListInput = {
|
|
|
40
39
|
type AccountCreateSubAccountInput = {
|
|
41
40
|
readonly accountId: AccountId;
|
|
42
41
|
readonly name: string;
|
|
42
|
+
readonly purpose?: string;
|
|
43
43
|
};
|
|
44
44
|
type AccountCreateExternalAccountInput = {
|
|
45
45
|
readonly accountId: AccountId;
|
|
@@ -59,6 +59,7 @@ type UpdateCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "
|
|
|
59
59
|
type ListCodes$b = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
|
|
60
60
|
type SafeRetrieveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "SAFE_NOT_READY";
|
|
61
61
|
type RemoveCodes$5 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
|
|
62
|
+
type SubAccountRemoveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
|
|
62
63
|
type AccountSafesClient = {
|
|
63
64
|
readonly retrieve: (safeId: SafeId) => Promise<CapxulResult<Safe, SafeRetrieveCodes$1>>;
|
|
64
65
|
};
|
|
@@ -75,12 +76,12 @@ type AccountExternalAccountsClient = {
|
|
|
75
76
|
readonly remove: (externalAccountId: ExternalAccountId) => Promise<CapxulResult<void, RemoveCodes$5>>;
|
|
76
77
|
};
|
|
77
78
|
type AccountSubAccountsClient = {
|
|
78
|
-
readonly create: (input: AccountCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes$1>>;
|
|
79
|
+
readonly create: (input: AccountCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes$1 | "PROVIDER_ERROR">>;
|
|
79
80
|
readonly list: (input: {
|
|
80
81
|
readonly accountId: AccountId;
|
|
81
|
-
} & AccountListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$b>>;
|
|
82
|
-
readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$e>>;
|
|
83
|
-
readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<
|
|
82
|
+
} & AccountListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$b | "PROVIDER_ERROR">>;
|
|
83
|
+
readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$e | "PROVIDER_ERROR">>;
|
|
84
|
+
readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, SubAccountRemoveCodes$1 | "PROVIDER_ERROR">>;
|
|
84
85
|
};
|
|
85
86
|
type AccountBalanceLedgerClient = {
|
|
86
87
|
readonly list: (input: {
|
|
@@ -211,7 +212,6 @@ type VerifyOtpResult = {
|
|
|
211
212
|
type CompleteBootstrapInput = {
|
|
212
213
|
readonly bootstrapToken: AuthBootstrapToken;
|
|
213
214
|
readonly username: Username;
|
|
214
|
-
readonly signerProvider: LocalPrivateKeySignerProvider;
|
|
215
215
|
readonly displayName?: string;
|
|
216
216
|
readonly countryCode?: string;
|
|
217
217
|
};
|
|
@@ -243,8 +243,8 @@ type ServiceToken = {
|
|
|
243
243
|
readonly token: string;
|
|
244
244
|
readonly expiresAt: TimestampIso;
|
|
245
245
|
};
|
|
246
|
-
type SendOtpCodes = "EMAIL_DELIVERY_FAILED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
|
|
247
|
-
type VerifyOtpCodes = "INVALID_INPUT" | "NOT_AUTHENTICATED" | "RATE_LIMITED" | "OPERATION_TIMEOUT" | "NETWORK_ERROR";
|
|
246
|
+
type SendOtpCodes = "EMAIL_DELIVERY_FAILED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR" | "PROVIDER_ERROR" | "INTERNAL_ERROR" | "ENV_MISSING" | "UNKNOWN" | "NOT_AUTHENTICATED" | "PERMISSION_DENIED";
|
|
247
|
+
type VerifyOtpCodes = "INVALID_INPUT" | "NOT_AUTHENTICATED" | "RATE_LIMITED" | "OPERATION_TIMEOUT" | "NETWORK_ERROR" | "PROVIDER_ERROR" | "INTERNAL_ERROR" | "ENV_MISSING" | "UNKNOWN" | "PERMISSION_DENIED";
|
|
248
248
|
type CompleteBootstrapCodes = "INVALID_INPUT" | "IDEMPOTENCY_CONFLICT" | "RATE_LIMITED" | "PROFILE_NOT_FOUND" | "SMART_ACCOUNT_MISSING" | "PROVIDER_UNAVAILABLE" | "PROVIDER_REJECTED" | "OPERATION_TIMEOUT" | "NETWORK_ERROR" | "INTERNAL_ERROR";
|
|
249
249
|
type GetSessionCodes = "NETWORK_ERROR";
|
|
250
250
|
type SignOutCodes = "NOT_AUTHENTICATED" | "NETWORK_ERROR";
|
|
@@ -691,7 +691,7 @@ type WebhookEventsClient = {
|
|
|
691
691
|
|
|
692
692
|
type OrganizationsCreateInput = {
|
|
693
693
|
readonly name: string;
|
|
694
|
-
readonly country
|
|
694
|
+
readonly country?: string;
|
|
695
695
|
};
|
|
696
696
|
type OrganizationsListInput = {
|
|
697
697
|
readonly limit?: number;
|
|
@@ -710,6 +710,9 @@ type OrgMemberInviteInput = {
|
|
|
710
710
|
readonly email: string;
|
|
711
711
|
readonly role: Member["role"];
|
|
712
712
|
};
|
|
713
|
+
type OrgMemberAcceptInput = {
|
|
714
|
+
readonly token: string;
|
|
715
|
+
};
|
|
713
716
|
type OrgMemberUpdateRoleInput = {
|
|
714
717
|
readonly organizationId: OrganizationId;
|
|
715
718
|
readonly memberId: MemberId;
|
|
@@ -720,21 +723,23 @@ type OrgMemberRemoveInput = {
|
|
|
720
723
|
readonly memberId: MemberId;
|
|
721
724
|
};
|
|
722
725
|
type OrgMemberRetrieveInput = OrgMemberRemoveInput;
|
|
726
|
+
type OrgMemberRevokeInput = OrgMemberRemoveInput;
|
|
727
|
+
type OrgMemberResendInput = OrgMemberRemoveInput;
|
|
723
728
|
type OrgListInput = {
|
|
724
729
|
readonly organizationId: OrganizationId;
|
|
725
730
|
readonly limit?: number;
|
|
726
731
|
readonly cursor?: string;
|
|
727
732
|
};
|
|
728
|
-
type
|
|
729
|
-
readonly organizationId: OrganizationId;
|
|
730
|
-
};
|
|
731
|
-
type OrgKybProfileRetrieveInput = {
|
|
733
|
+
type OrgMemberListInput = {
|
|
732
734
|
readonly organizationId: OrganizationId;
|
|
733
|
-
readonly
|
|
735
|
+
readonly status?: MembershipStatus | "all";
|
|
736
|
+
readonly limit?: number;
|
|
737
|
+
readonly cursor?: string;
|
|
734
738
|
};
|
|
735
739
|
type OrgCreateSubAccountInput = {
|
|
736
740
|
readonly organizationId: OrganizationId;
|
|
737
741
|
readonly name: string;
|
|
742
|
+
readonly purpose?: string;
|
|
738
743
|
};
|
|
739
744
|
type OrgCreateExternalAccountInput = {
|
|
740
745
|
readonly organizationId: OrganizationId;
|
|
@@ -766,6 +771,7 @@ type UpdateCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "IN
|
|
|
766
771
|
type SafeRetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
|
|
767
772
|
type TreasuryRetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "SAFE_NOT_READY";
|
|
768
773
|
type RemoveCodes$2 = RetrieveCodes$4;
|
|
774
|
+
type SubAccountRemoveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
|
|
769
775
|
type OrgSafesClient = {
|
|
770
776
|
readonly retrieve: (input: OrgSafeRetrieveInput) => Promise<CapxulResult<Safe, SafeRetrieveCodes>>;
|
|
771
777
|
};
|
|
@@ -773,27 +779,26 @@ type OrgTreasuryClient = {
|
|
|
773
779
|
readonly retrieve: (organizationId: OrganizationId) => Promise<CapxulResult<Treasury, TreasuryRetrieveCodes>>;
|
|
774
780
|
};
|
|
775
781
|
type OrgMembersClient = {
|
|
776
|
-
readonly list: (input:
|
|
782
|
+
readonly list: (input: OrgMemberListInput) => Promise<CapxulResult<List<Member>, ListCodes$3>>;
|
|
777
783
|
readonly retrieve: (input: OrgMemberRetrieveInput) => Promise<CapxulResult<Member, RetrieveCodes$4>>;
|
|
778
|
-
readonly invite: (input: OrgMemberInviteInput) => Promise<CapxulResult<
|
|
784
|
+
readonly invite: (input: OrgMemberInviteInput) => Promise<CapxulResult<MemberInviteResponse, UpdateCodes>>;
|
|
785
|
+
readonly accept: (input: OrgMemberAcceptInput) => Promise<CapxulResult<Member, UpdateCodes>>;
|
|
779
786
|
readonly updateRole: (input: OrgMemberUpdateRoleInput) => Promise<CapxulResult<Member, UpdateCodes>>;
|
|
787
|
+
readonly revoke: (input: OrgMemberRevokeInput) => Promise<CapxulResult<Member, UpdateCodes>>;
|
|
780
788
|
readonly remove: (input: OrgMemberRemoveInput) => Promise<CapxulResult<void, RemoveCodes$2>>;
|
|
781
|
-
|
|
782
|
-
type OrgKybProfileClient = {
|
|
783
|
-
readonly start: (input: OrgKybProfileStartInput) => Promise<CapxulResult<KybProfile, CreateCodes$2>>;
|
|
784
|
-
readonly retrieve: (input: OrgKybProfileRetrieveInput) => Promise<CapxulResult<KybProfile, RetrieveCodes$4>>;
|
|
789
|
+
readonly resend: (input: OrgMemberResendInput) => Promise<CapxulResult<MemberInviteResponse, UpdateCodes>>;
|
|
785
790
|
};
|
|
786
791
|
type OrgSubAccountsClient = {
|
|
787
|
-
readonly create: (input: OrgCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes>>;
|
|
788
|
-
readonly list: (input: OrgListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$3>>;
|
|
792
|
+
readonly create: (input: OrgCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes | "PROVIDER_ERROR">>;
|
|
793
|
+
readonly list: (input: OrgListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$3 | "PROVIDER_ERROR">>;
|
|
789
794
|
readonly retrieve: (input: {
|
|
790
795
|
readonly organizationId: OrganizationId;
|
|
791
796
|
readonly subAccountId: SubAccountId;
|
|
792
|
-
}) => Promise<CapxulResult<SubAccount, RetrieveCodes$4>>;
|
|
797
|
+
}) => Promise<CapxulResult<SubAccount, RetrieveCodes$4 | "PROVIDER_ERROR">>;
|
|
793
798
|
readonly remove: (input: {
|
|
794
799
|
readonly organizationId: OrganizationId;
|
|
795
800
|
readonly subAccountId: SubAccountId;
|
|
796
|
-
}) => Promise<CapxulResult<
|
|
801
|
+
}) => Promise<CapxulResult<SubAccount, SubAccountRemoveCodes | "PROVIDER_ERROR">>;
|
|
797
802
|
};
|
|
798
803
|
type OrgExternalAccountsClient = {
|
|
799
804
|
readonly create: (input: OrgCreateExternalAccountInput) => Promise<CapxulResult<ExternalAccount, UpdateCodes>>;
|
|
@@ -824,7 +829,6 @@ type OrganizationsClient = {
|
|
|
824
829
|
readonly treasury: OrgTreasuryClient;
|
|
825
830
|
readonly members: OrgMembersClient;
|
|
826
831
|
readonly apiKeys: OrgApiKeysClient;
|
|
827
|
-
readonly kybProfile: OrgKybProfileClient;
|
|
828
832
|
readonly subAccounts: OrgSubAccountsClient;
|
|
829
833
|
readonly externalAccounts: OrgExternalAccountsClient;
|
|
830
834
|
readonly balanceLedger: OrgBalanceLedgerClient;
|
|
@@ -977,13 +981,20 @@ declare function makeHttpTransport(config: BrowserCapxulConfig): HttpTransport;
|
|
|
977
981
|
* `accounts.subAccounts.create(...)` or
|
|
978
982
|
* `organizations.subAccounts.create(...)`), so only `retrieve` and
|
|
979
983
|
* `remove` live at the top level.
|
|
984
|
+
*
|
|
985
|
+
* Wired in PR-2a of the funds-v1 balance-closure stack: the backend
|
|
986
|
+
* always returns truthful `balance: Money` per canon §sub_account
|
|
987
|
+
* (PR-1 made `toCanonShape` populate it from `computeSubAccountBalance`).
|
|
988
|
+
* The SDK brands the wire shape and passes the balance through as-is.
|
|
989
|
+
* NO zero-balance fallback exists at the SDK layer — if the backend
|
|
990
|
+
* ever omits `balance`, that is a bug to surface, not paper over.
|
|
980
991
|
*/
|
|
981
992
|
|
|
982
|
-
type RetrieveCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
|
|
983
|
-
type RemoveCodes$1 =
|
|
993
|
+
type RetrieveCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "PROVIDER_ERROR";
|
|
994
|
+
type RemoveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT" | "PROVIDER_ERROR";
|
|
984
995
|
type SubAccountsClient = {
|
|
985
996
|
readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$3>>;
|
|
986
|
-
readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<
|
|
997
|
+
readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RemoveCodes$1>>;
|
|
987
998
|
};
|
|
988
999
|
|
|
989
1000
|
/**
|
|
@@ -1145,7 +1156,7 @@ type VirtualCardsClient = {
|
|
|
1145
1156
|
* Backend throws CapxulError → withErrorBoundary serializes to ConvexError →
|
|
1146
1157
|
* SDK deserializes back to CapxulError → frontend routes on err.code.
|
|
1147
1158
|
*/
|
|
1148
|
-
type CapxulErrorCode = "NOT_AUTHENTICATED" | "EMAIL_DELIVERY_FAILED" | "API_KEY_INVALID" | "API_KEY_EXPIRED" | "PROFILE_NOT_FOUND" | "SMART_ACCOUNT_MISSING" | "PLAYER_NOT_FOUND" | "ACCOUNT_NOT_FOUND" | "PROVIDER_ERROR" | "INVALID_INPUT" | "ENV_MISSING" | "NOT_IMPLEMENTED" | "VERIFICATION_REQUIRED" | "INSUFFICIENT_BALANCE" | "INVALID_RECIPIENT" | "TRANSACTION_FAILED" | "RATE_LIMITED" | "NETWORK_ERROR" | "PERMISSION_DENIED" | "IDEMPOTENCY_CONFLICT" | "NOT_FOUND" | "OPERATION_CANCELED" | "OPERATION_TIMEOUT" | "ACTION_REQUIRED" | "KYC_REQUIRED" | "POLICY_DENIED" | "SAFE_NOT_READY" | "PROVIDER_UNAVAILABLE" | "PROVIDER_REJECTED" | "RECONCILIATION_FAILED" | "INTERNAL_ERROR" | "QUOTE_EXPIRED" | "QUOTE_NOT_FOUND" | "UNKNOWN";
|
|
1159
|
+
type CapxulErrorCode = "NOT_AUTHENTICATED" | "EMAIL_DELIVERY_FAILED" | "API_KEY_INVALID" | "API_KEY_EXPIRED" | "PROFILE_NOT_FOUND" | "SMART_ACCOUNT_MISSING" | "PLAYER_NOT_FOUND" | "ACCOUNT_NOT_FOUND" | "PROVIDER_ERROR" | "INVALID_INPUT" | "ENV_MISSING" | "NOT_IMPLEMENTED" | "VERIFICATION_REQUIRED" | "INSUFFICIENT_BALANCE" | "INVALID_RECIPIENT" | "TRANSACTION_FAILED" | "RATE_LIMITED" | "NETWORK_ERROR" | "PERMISSION_DENIED" | "IDEMPOTENCY_CONFLICT" | "NOT_FOUND" | "OPERATION_CANCELED" | "OPERATION_TIMEOUT" | "ACTION_REQUIRED" | "KYC_REQUIRED" | "POLICY_DENIED" | "SAFE_NOT_READY" | "PROVIDER_UNAVAILABLE" | "PROVIDER_REJECTED" | "RECONCILIATION_FAILED" | "INTERNAL_ERROR" | "QUOTE_EXPIRED" | "QUOTE_NOT_FOUND" | "INDEXER_DELIVERY_TIMEOUT" | "UNKNOWN";
|
|
1149
1160
|
declare class CapxulError extends Error {
|
|
1150
1161
|
readonly code: CapxulErrorCode;
|
|
1151
1162
|
readonly details?: Record<string, unknown>;
|
|
@@ -1164,7 +1175,6 @@ type AuthBootstrapFlowContext = {
|
|
|
1164
1175
|
readonly email: Email | null;
|
|
1165
1176
|
readonly code: string | null;
|
|
1166
1177
|
readonly username: Username | null;
|
|
1167
|
-
readonly signerProvider: LocalPrivateKeySignerProvider | null;
|
|
1168
1178
|
readonly bootstrapToken: AuthBootstrapToken | null;
|
|
1169
1179
|
readonly bootstrapReason: AuthBootstrapReason | null;
|
|
1170
1180
|
readonly session: Session | null;
|
|
@@ -1185,9 +1195,6 @@ type AuthBootstrapFlowEvent = {
|
|
|
1185
1195
|
} | {
|
|
1186
1196
|
readonly type: "ENTER_USERNAME";
|
|
1187
1197
|
readonly username: Username;
|
|
1188
|
-
} | {
|
|
1189
|
-
readonly type: "ENTER_SIGNER_PROVIDER";
|
|
1190
|
-
readonly signerProvider: LocalPrivateKeySignerProvider;
|
|
1191
1198
|
} | {
|
|
1192
1199
|
readonly type: "COMPLETE_BOOTSTRAP";
|
|
1193
1200
|
} | {
|
|
@@ -1210,9 +1217,6 @@ declare function createAuthBootstrapFlowMachine(client: CapxulClient): xstate.St
|
|
|
1210
1217
|
} | {
|
|
1211
1218
|
readonly type: "ENTER_USERNAME";
|
|
1212
1219
|
readonly username: Username;
|
|
1213
|
-
} | {
|
|
1214
|
-
readonly type: "ENTER_SIGNER_PROVIDER";
|
|
1215
|
-
readonly signerProvider: LocalPrivateKeySignerProvider;
|
|
1216
1220
|
} | {
|
|
1217
1221
|
readonly type: "COMPLETE_BOOTSTRAP";
|
|
1218
1222
|
} | {
|
|
@@ -1230,7 +1234,6 @@ declare function createAuthBootstrapFlowMachine(client: CapxulClient): xstate.St
|
|
|
1230
1234
|
}, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<CompleteBootstrapResult, {
|
|
1231
1235
|
bootstrapToken: AuthBootstrapToken;
|
|
1232
1236
|
username: Username;
|
|
1233
|
-
signerProvider: LocalPrivateKeySignerProvider;
|
|
1234
1237
|
}, xstate.EventObject>> | undefined;
|
|
1235
1238
|
}, {
|
|
1236
1239
|
src: "sendOtp";
|
|
@@ -1254,7 +1257,6 @@ declare function createAuthBootstrapFlowMachine(client: CapxulClient): xstate.St
|
|
|
1254
1257
|
logic: xstate.PromiseActorLogic<CompleteBootstrapResult, {
|
|
1255
1258
|
bootstrapToken: AuthBootstrapToken;
|
|
1256
1259
|
username: Username;
|
|
1257
|
-
signerProvider: LocalPrivateKeySignerProvider;
|
|
1258
1260
|
}, xstate.EventObject>;
|
|
1259
1261
|
id: string | undefined;
|
|
1260
1262
|
}, {
|
|
@@ -1340,11 +1342,6 @@ type CapxulAuthConfig = {
|
|
|
1340
1342
|
readonly convexTokenUrl?: string;
|
|
1341
1343
|
/** Scenario/browser-local session store shared by auth + onboarding hooks. */
|
|
1342
1344
|
readonly sessionStore?: AuthSessionStore;
|
|
1343
|
-
/**
|
|
1344
|
-
* Optional bridge for environments that can build an authenticated data
|
|
1345
|
-
* client after BetterAuth returns a session.
|
|
1346
|
-
*/
|
|
1347
|
-
readonly createDataClient?: (session: Session) => Promise<CapxulDataClient>;
|
|
1348
1345
|
};
|
|
1349
1346
|
type CapxulConfig = {
|
|
1350
1347
|
/** Server-to-server partner key. Mutually exclusive with `publishableKey`. */
|
|
@@ -1360,12 +1357,13 @@ type CapxulConfig = {
|
|
|
1360
1357
|
*/
|
|
1361
1358
|
readonly signer?: Account$1;
|
|
1362
1359
|
/**
|
|
1363
|
-
*
|
|
1360
|
+
* @internal
|
|
1364
1361
|
*
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
1362
|
+
* Test-only override seam for injecting an authenticated Convex data client.
|
|
1363
|
+
* The SDK now owns runtime construction of the data client; this field is
|
|
1364
|
+
* reserved for tests and the React provider's singleton lifecycle.
|
|
1367
1365
|
*/
|
|
1368
|
-
readonly
|
|
1366
|
+
readonly _data?: CapxulDataClient;
|
|
1369
1367
|
/**
|
|
1370
1368
|
* Chain + bundler configuration for on-chain submission.
|
|
1371
1369
|
*
|
|
@@ -1483,4 +1481,4 @@ type CapxulClient = {
|
|
|
1483
1481
|
*/
|
|
1484
1482
|
declare function createCapxulClient(config?: CapxulConfig): CapxulClient;
|
|
1485
1483
|
|
|
1486
|
-
export {
|
|
1484
|
+
export { type WithdrawalsClient as $, type AccountProvisionPersonalInput as A, type BrowserCapxulConfig as B, CapxulError as C, type DocumentsClient as D, type ExternalAccountsClient as E, type SubAccountsClient as F, type TokenTransferId as G, type HttpTransport as H, type TokenTransfersClient as I, type TokenTransfersListInput as J, type TokenTransfersListPage as K, type LocalPrivateKeySignerProvider as L, type MeClient as M, type TokenTransfersRetrieveInput as N, type OperationsClient as O, type PaymentsClient as P, type TransfersClient as Q, type TransportRuntime as R, type Session as S, type TokenTransfer as T, type TransportState as U, type VerifyOtpResult as V, type VirtualAccountsClient as W, type VirtualCardsClient as X, type WebhookEndpointCreateResult as Y, type WebhookEndpointsClient as Z, type WebhookEventsClient as _, type CapxulClient as a, createAuthBootstrapFlowMachine as a0, createCapxulClient as a1, makeHttpTransport as a2, toTokenTransferId as a3, type CapxulConfig as b, type CompleteBootstrapInput as c, type CompleteBootstrapResult as d, type AccountsClient as e, type ApiKeyCreateResult as f, type ApiKeysClient as g, type AuthBootstrapFlowContext as h, type AuthBootstrapFlowError as i, type AuthBootstrapFlowEvent as j, type AuthBootstrapReason as k, type AuthBootstrapToken as l, type AuthClient as m, type AuthSessionStore as n, type CapxulAuthConfig as o, type CapxulDataClient as p, type CapxulFlowFactories as q, type CapxulSigningConfig as r, type OrgDocumentsClient as s, type OrgMembersClient as t, type OrgPaymentsClient as u, type OrgSafesClient as v, type OrgTransfersClient as w, type OrgTreasuryClient as x, type OrgWithdrawalsClient as y, type OrganizationsClient as z };
|