@capxul/sdk 2.1.1 → 2.3.0
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 +24 -0
- package/dist/{InMemoryAuthCacheAdapter-Rc8tCtml.mjs → InMemoryAuthCacheAdapter-qMpBOGb3.mjs} +15 -2
- package/dist/{create-capxul-client-CPhTPz_9.mjs → create-capxul-client-mArFr_Os.mjs} +675 -532
- package/dist/index.d.mts +25 -64
- package/dist/index.mjs +260 -103
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/{create-capxul-client-BI-6Za6X.d.mts → observation-Ci8gIQjm.d.mts} +193 -20
- package/dist/{signer-Bj4F-RwT.d.mts → signer-BejoR3bA.d.mts} +116 -1
- package/dist/testing/index.d.mts +3 -1
- package/dist/testing/index.mjs +4 -3
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as BlockNumber, B as MovementId, C as Address$1, D as AppId, E as AnonymousDistinctId, F as DocumentHash, G as PermissionId, H as PartyId, I as DurationMs, J as RoleKey, K as Profile, L as Email, M as ChainId, N as CountryCode, O as AuthSession, P as CurrencyCode, Q as WeiAmount, R as EpochMs, T as AllowedOrigin, U as PaymentCommandId, V as OrgId, W as PermissionAssignmentId, X as SmartAccount, Y as SessionToken, Z as TxHash, a as SignerStatusStore, b as CachedJwt, c as AccountProviderSource, g as SmartAccount$1, h as Session$1, it as CapxulErrorDetails, j as BudgetId, k as AuthUserId, l as AccountRequirement, m as Profile$1, n as CapxulSigner, nt as CapxulError, ot as Failure, p as CapxulResult, q as PublishableKey, rt as CapxulErrorCode, st as FailureMode, v as AuthCachePort, w as AllowanceKey, x as Account$1, z as Money } from "./signer-BejoR3bA.mjs";
|
|
2
2
|
import { Address, Hex } from "viem";
|
|
3
3
|
import { Context, Effect, Layer, Schema, Scope, Tracer } from "effect";
|
|
4
4
|
import { FunctionReference } from "convex/server";
|
|
@@ -127,7 +127,13 @@ type Readiness = {
|
|
|
127
127
|
readonly failure: Failure;
|
|
128
128
|
readonly retryable: boolean;
|
|
129
129
|
};
|
|
130
|
-
type IdentityState =
|
|
130
|
+
type IdentityState =
|
|
131
|
+
/** The INITIAL state: a session probe is in flight and the machine knows
|
|
132
|
+
* nothing yet. Distinct from `signed_out`, which is a settled answer. Without
|
|
133
|
+
* it every consumer read the restore window as a real sign-out. */
|
|
134
|
+
{
|
|
135
|
+
readonly phase: "restoring";
|
|
136
|
+
} | {
|
|
131
137
|
readonly phase: "signed_out";
|
|
132
138
|
} | {
|
|
133
139
|
readonly phase: "otp_sending";
|
|
@@ -159,7 +165,7 @@ type IdentityState = {
|
|
|
159
165
|
readonly requestedAt: number;
|
|
160
166
|
} | null;
|
|
161
167
|
};
|
|
162
|
-
declare const STATE_LABELS: readonly ["signed_out", "otp_sending", "otp_pending", "otp_verifying", "authenticated:unknown", "authenticated:deriving", "authenticated:counterfactual", "authenticated:claiming", "authenticated:failed", "authenticated:claimed", "authenticated:claimed:creating", "authenticated:claimed:loading", "authenticated:claimed:settingUp", "authenticated:claimed:ready", "authenticated:claimed:failed", "signing_out", "faulted"];
|
|
168
|
+
declare const STATE_LABELS: readonly ["restoring", "signed_out", "otp_sending", "otp_pending", "otp_verifying", "authenticated:unknown", "authenticated:deriving", "authenticated:counterfactual", "authenticated:claiming", "authenticated:failed", "authenticated:claimed", "authenticated:claimed:creating", "authenticated:claimed:loading", "authenticated:claimed:settingUp", "authenticated:claimed:ready", "authenticated:claimed:failed", "signing_out", "faulted"];
|
|
163
169
|
type StateLabel = (typeof STATE_LABELS)[number];
|
|
164
170
|
type IdentityEvent = {
|
|
165
171
|
readonly _tag: "RequestOtp";
|
|
@@ -182,6 +188,12 @@ type IdentityEvent = {
|
|
|
182
188
|
readonly now: number;
|
|
183
189
|
} | {
|
|
184
190
|
readonly _tag: "Reset";
|
|
191
|
+
} | {
|
|
192
|
+
readonly _tag: "SessionRestored";
|
|
193
|
+
readonly session: Session;
|
|
194
|
+
readonly profileComplete: boolean;
|
|
195
|
+
} | {
|
|
196
|
+
readonly _tag: "SessionAbsent";
|
|
185
197
|
} | {
|
|
186
198
|
readonly _tag: "EnsureAccount";
|
|
187
199
|
} | {
|
|
@@ -223,6 +235,22 @@ type Destination$1 = {
|
|
|
223
235
|
* there is no org list in the state, only the ONE active lane.
|
|
224
236
|
*/
|
|
225
237
|
declare const destination: (state: IdentityState) => Destination$1 | null;
|
|
238
|
+
/**
|
|
239
|
+
* True while the machine has not settled enough to route or to gate on.
|
|
240
|
+
*
|
|
241
|
+
* NEGATIVE classification, deliberately: the SETTLED positions are the ones
|
|
242
|
+
* enumerated, and everything else waits. A phase or readiness variant added
|
|
243
|
+
* later therefore defaults to holding, never to redirecting a member who is in
|
|
244
|
+
* fact signed in. Terminal for the account lane is `claimed | failed`.
|
|
245
|
+
*
|
|
246
|
+
* The org lane's own settledness (`ready | failed`) is the route gate's
|
|
247
|
+
* question, not this one: every org lane sits under a CLAIMED account, and
|
|
248
|
+
* `destination()` already names a real screen for each of its positions.
|
|
249
|
+
*/
|
|
250
|
+
declare const isRestoring: (state: IdentityState) => boolean;
|
|
251
|
+
/** The claimed-account gate as one function. The inlined consumers move onto
|
|
252
|
+
* it in #1521; this ticket ships the selector they move onto. */
|
|
253
|
+
declare const isClaimed: (state: IdentityState) => boolean;
|
|
226
254
|
//#endregion
|
|
227
255
|
//#region ../config/src/capxul-payments-v2.d.ts
|
|
228
256
|
/** Immutable CapxulPaymentsV2 deployment on Base Sepolia. */
|
|
@@ -774,7 +802,7 @@ interface IdentityPort {
|
|
|
774
802
|
type SafeDeploymentConfig = {
|
|
775
803
|
readonly chainId: ChainId;
|
|
776
804
|
readonly rpcUrl: string;
|
|
777
|
-
readonly
|
|
805
|
+
readonly bundlerRpcUrl: string;
|
|
778
806
|
readonly receiptTimeoutMs?: DurationMs;
|
|
779
807
|
};
|
|
780
808
|
/**
|
|
@@ -1107,6 +1135,9 @@ type TargetReference = {
|
|
|
1107
1135
|
} | {
|
|
1108
1136
|
readonly kind: "payee";
|
|
1109
1137
|
readonly id: string;
|
|
1138
|
+
} | {
|
|
1139
|
+
readonly kind: "party";
|
|
1140
|
+
readonly partyId: PartyId;
|
|
1110
1141
|
} | {
|
|
1111
1142
|
readonly kind: "destination";
|
|
1112
1143
|
readonly id: string;
|
|
@@ -1142,6 +1173,9 @@ type Ref$1 = {
|
|
|
1142
1173
|
} | {
|
|
1143
1174
|
readonly kind: "payeeId";
|
|
1144
1175
|
readonly payeeId: string;
|
|
1176
|
+
} | {
|
|
1177
|
+
readonly kind: "party";
|
|
1178
|
+
readonly partyId: PartyId;
|
|
1145
1179
|
};
|
|
1146
1180
|
interface MeProfile {
|
|
1147
1181
|
readonly authUserId: string;
|
|
@@ -1243,7 +1277,7 @@ interface Payment {
|
|
|
1243
1277
|
readonly transactionHash: string;
|
|
1244
1278
|
} | null;
|
|
1245
1279
|
readonly recipient: {
|
|
1246
|
-
readonly kind: "handle" | "email" | "payee" | "capxulUserId" | "me" | "org" | "external_address";
|
|
1280
|
+
readonly kind: "handle" | "email" | "payee" | "capxulUserId" | "me" | "org" | "party" | "external_address";
|
|
1247
1281
|
readonly label: string;
|
|
1248
1282
|
readonly payeeId?: string;
|
|
1249
1283
|
};
|
|
@@ -1589,35 +1623,54 @@ interface ActorProfile {
|
|
|
1589
1623
|
readonly email?: string;
|
|
1590
1624
|
readonly handle?: string;
|
|
1591
1625
|
}
|
|
1626
|
+
/**
|
|
1627
|
+
* How a counterparty entered the book, and what they are to the actor today.
|
|
1628
|
+
*
|
|
1629
|
+
* The first six values are the backend edge provenance VERBATIM (ADR-0022 R2);
|
|
1630
|
+
* `employed` is projected from an open employment edge. The pre-substrate
|
|
1631
|
+
* union published `requested` (a value that collapsed two directions) and
|
|
1632
|
+
* `employee` (a value no backend path ever wrote).
|
|
1633
|
+
*/
|
|
1634
|
+
type AddressBookRelationship = "paid" | "paidBy" | "invoiced" | "invoicedBy" | "member" | "manual" | "employed";
|
|
1592
1635
|
interface AddressBookEntry {
|
|
1593
|
-
|
|
1636
|
+
/**
|
|
1637
|
+
* The counterparty's `PartyId`. It is stable: the id you read before a
|
|
1638
|
+
* counterparty signs up is the id you read after (ADR-0022 R1). The old id
|
|
1639
|
+
* was a derived string that changed at signup.
|
|
1640
|
+
*/
|
|
1641
|
+
readonly id: PartyId;
|
|
1594
1642
|
readonly ref: Ref$1;
|
|
1595
1643
|
readonly label: string;
|
|
1596
|
-
readonly relationship: readonly
|
|
1644
|
+
readonly relationship: readonly AddressBookRelationship[];
|
|
1597
1645
|
readonly hidden: boolean;
|
|
1646
|
+
/** Epoch milliseconds of the most recent activity with this counterparty. */
|
|
1647
|
+
readonly lastActivityAt: number;
|
|
1598
1648
|
}
|
|
1599
1649
|
interface AddressBookAddInput {
|
|
1600
1650
|
readonly ref: Ref$1;
|
|
1601
1651
|
readonly label?: string;
|
|
1602
1652
|
}
|
|
1603
1653
|
interface AddressBookLabelInput {
|
|
1604
|
-
readonly entryId:
|
|
1654
|
+
readonly entryId: PartyId;
|
|
1605
1655
|
readonly label: string;
|
|
1606
1656
|
}
|
|
1657
|
+
interface AddressBookListInput {
|
|
1658
|
+
readonly includeHidden?: boolean;
|
|
1659
|
+
}
|
|
1607
1660
|
interface AddressBookMethods {
|
|
1608
|
-
list(options?: {
|
|
1661
|
+
list(input?: AddressBookListInput, options?: {
|
|
1609
1662
|
readonly signal?: AbortSignal;
|
|
1610
1663
|
}): Promise<CapxulResult<readonly AddressBookEntry[]>>;
|
|
1611
|
-
get(entryId:
|
|
1664
|
+
get(entryId: PartyId, options?: {
|
|
1612
1665
|
readonly signal?: AbortSignal;
|
|
1613
1666
|
}): Promise<CapxulResult<AddressBookEntry | null>>;
|
|
1614
1667
|
add(input: AddressBookAddInput, options?: {
|
|
1615
1668
|
readonly signal?: AbortSignal;
|
|
1616
1669
|
}): Promise<CapxulResult<AddressBookEntry>>;
|
|
1617
|
-
hide(entryId:
|
|
1670
|
+
hide(entryId: PartyId, options?: {
|
|
1618
1671
|
readonly signal?: AbortSignal;
|
|
1619
1672
|
}): Promise<CapxulResult<AddressBookEntry>>;
|
|
1620
|
-
unhide(entryId:
|
|
1673
|
+
unhide(entryId: PartyId, options?: {
|
|
1621
1674
|
readonly signal?: AbortSignal;
|
|
1622
1675
|
}): Promise<CapxulResult<AddressBookEntry>>;
|
|
1623
1676
|
label(input: AddressBookLabelInput, options?: {
|
|
@@ -1846,6 +1899,47 @@ interface OrgPort {
|
|
|
1846
1899
|
detectAndAcceptPendingInvitations(input: DetectPendingOrgInvitationsInput): Effect.Effect<DetectPendingOrgInvitationsResult$1, OrgError, never>;
|
|
1847
1900
|
}
|
|
1848
1901
|
//#endregion
|
|
1902
|
+
//#region src/surface/org-me.d.ts
|
|
1903
|
+
/**
|
|
1904
|
+
* One spend authority the Member holds. `limit` is the cap the payment gate
|
|
1905
|
+
* enforces on a single payment — `null` means the Budget carries no cap. The
|
|
1906
|
+
* amount still available under the cap is not part of this read and is not
|
|
1907
|
+
* computable from it.
|
|
1908
|
+
*/
|
|
1909
|
+
interface Budget {
|
|
1910
|
+
readonly id: BudgetId;
|
|
1911
|
+
/** Display name, taken from the Role the grant was motivated by. */
|
|
1912
|
+
readonly label: string;
|
|
1913
|
+
readonly limit: Money | null;
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* The caller's own standing in one Organization.
|
|
1917
|
+
*
|
|
1918
|
+
* `role` is `null` when the Role catalog cannot name the Member's Role — a
|
|
1919
|
+
* label-less owner is tolerated (ADR-0017), so consumers must render an
|
|
1920
|
+
* absent Role rather than invent one.
|
|
1921
|
+
*
|
|
1922
|
+
* `capabilities` are the two facts the backend actually enforces, and nothing
|
|
1923
|
+
* else: managing people, and spending. Payroll and invoice approval are both
|
|
1924
|
+
* spending, so both read `canSpend`.
|
|
1925
|
+
*/
|
|
1926
|
+
interface OrgMe {
|
|
1927
|
+
readonly role: {
|
|
1928
|
+
readonly label: string;
|
|
1929
|
+
} | null;
|
|
1930
|
+
readonly capabilities: {
|
|
1931
|
+
readonly canManagePeople: boolean;
|
|
1932
|
+
readonly canSpend: boolean;
|
|
1933
|
+
};
|
|
1934
|
+
/** Named Budgets this Member can spend from. `canSpend` is the authority fact. */
|
|
1935
|
+
readonly budgets: readonly Budget[];
|
|
1936
|
+
readonly observedAt: number;
|
|
1937
|
+
}
|
|
1938
|
+
type OrgMeOptions = {
|
|
1939
|
+
readonly signal?: AbortSignal;
|
|
1940
|
+
};
|
|
1941
|
+
type OrgMeMethod = (options?: OrgMeOptions) => Promise<CapxulResult<OrgMe>>;
|
|
1942
|
+
//#endregion
|
|
1849
1943
|
//#region src/contract/permission.d.ts
|
|
1850
1944
|
interface PermissionReadResult {
|
|
1851
1945
|
readonly permissions: readonly Permission[];
|
|
@@ -1966,11 +2060,14 @@ type RoleSpendCap = {
|
|
|
1966
2060
|
type RoleDefinition = {
|
|
1967
2061
|
readonly label: string;
|
|
1968
2062
|
readonly spend?: RoleSpendCap;
|
|
2063
|
+
readonly canSpend?: boolean;
|
|
1969
2064
|
readonly canManageMembers?: boolean;
|
|
1970
2065
|
readonly canManageRoles?: boolean;
|
|
1971
2066
|
};
|
|
1972
2067
|
/**
|
|
1973
|
-
* One role
|
|
2068
|
+
* One role a member can be invited into on an Organization — a role that
|
|
2069
|
+
* carries member-management authority. A Budget is granted, never offered as a
|
|
2070
|
+
* job title (ADR-0024 R5), so it never appears here.
|
|
1974
2071
|
* `roleKey` is the on-chain bytes32 role key derived from the label. `definition`
|
|
1975
2072
|
* is the full Role DSL entry.
|
|
1976
2073
|
*/
|
|
@@ -1980,21 +2077,22 @@ type RoleView = {
|
|
|
1980
2077
|
readonly roleKey: RoleKey;
|
|
1981
2078
|
readonly definition: RoleDefinition;
|
|
1982
2079
|
};
|
|
1983
|
-
/**
|
|
1984
|
-
|
|
2080
|
+
/**
|
|
2081
|
+
* The role template a new Organization is created from. Creation supports
|
|
2082
|
+
* exactly one shape — a single founding owner (ADR-0024 R8). Any other value
|
|
2083
|
+
* is REFUSED with `WRONG_STATE`.
|
|
2084
|
+
*/
|
|
2085
|
+
type OrgTemplate = "Solo";
|
|
1985
2086
|
/**
|
|
1986
2087
|
* Input to `capxul.createOrg`. `name` is the display name.
|
|
1987
2088
|
* `handle` is the globally unique normalized handle (`^[a-z0-9-]{3,32}$`).
|
|
1988
2089
|
* `template` seeds the initial role set. `country` is stored without validation.
|
|
1989
|
-
* For `template: "Custom"`, `roles` carries the authored
|
|
1990
|
-
* `RoleDefinition[]`.
|
|
1991
2090
|
*/
|
|
1992
2091
|
type CreateOrgInput = {
|
|
1993
2092
|
readonly name: string;
|
|
1994
2093
|
readonly handle: string;
|
|
1995
2094
|
readonly template: OrgTemplate;
|
|
1996
2095
|
readonly country?: string;
|
|
1997
|
-
readonly roles?: readonly RoleDefinition[];
|
|
1998
2096
|
};
|
|
1999
2097
|
/**
|
|
2000
2098
|
* Input to `org(orgId).invite`. Email is the universal entry point.
|
|
@@ -2015,6 +2113,12 @@ type DetectPendingOrgInvitationsResult = {
|
|
|
2015
2113
|
};
|
|
2016
2114
|
/** Organization methods for one `orgId`. */
|
|
2017
2115
|
interface OrgScopedMethods extends ActorRelationshipMethods {
|
|
2116
|
+
/**
|
|
2117
|
+
* The caller's own standing in this Organization — Role, the two enforced
|
|
2118
|
+
* capabilities, and the Budgets they can spend from. A caller who is not an
|
|
2119
|
+
* active Member is refused, not reported as a Member without capabilities.
|
|
2120
|
+
*/
|
|
2121
|
+
readonly me: OrgMeMethod;
|
|
2018
2122
|
/** Observe the durable, leak-safe lifecycle for this Organization only. */
|
|
2019
2123
|
getLifecycle(options?: {
|
|
2020
2124
|
readonly signal?: AbortSignal;
|
|
@@ -2263,6 +2367,16 @@ interface CapxulClient {
|
|
|
2263
2367
|
readonly createOrg: OrgMethods["createOrg"];
|
|
2264
2368
|
readonly orgs: OrgMethods["orgs"];
|
|
2265
2369
|
readonly org: OrgMethods["org"];
|
|
2370
|
+
/**
|
|
2371
|
+
* Observable signer readiness (ACCESS #1520 · C12). `status()` reads the
|
|
2372
|
+
* current `SignerStatus`. `subscribe` fires on every change and returns its
|
|
2373
|
+
* own unsubscribe. Only the Openfort browser signer runs a readiness cycle.
|
|
2374
|
+
* Every other signer reports `"unknown"`, so a gate that reads this fails
|
|
2375
|
+
* closed. This is an observation surface, not a domain method: it performs no
|
|
2376
|
+
* work and cannot fail, so it returns a value rather than a `CapxulResult`.
|
|
2377
|
+
* It is not a public React surface — the action part that needs it reads this.
|
|
2378
|
+
*/
|
|
2379
|
+
readonly signer: SignerStatusStore;
|
|
2266
2380
|
/**
|
|
2267
2381
|
* Internal identity integration runtime. It is consumed by
|
|
2268
2382
|
* `@capxul/sdk-react`, not exported as the actor substrate itself.
|
|
@@ -2281,7 +2395,7 @@ interface CapxulClient {
|
|
|
2281
2395
|
* NOT on the public `client.accounts` surface.
|
|
2282
2396
|
*/
|
|
2283
2397
|
readonly accounts: AccountsFaucetMethods; /** Quarantined Reference-harness evidence; never a product Organization method. */
|
|
2284
|
-
readonly organizationSetup: OrganizationSetupProofMethods; /**
|
|
2398
|
+
readonly organizationSetup: OrganizationSetupProofMethods; /** Product telemetry projection for internal composition and test harnesses. */
|
|
2285
2399
|
readonly telemetry?: TelemetryPort;
|
|
2286
2400
|
readonly close?: () => Promise<void>;
|
|
2287
2401
|
};
|
|
@@ -2357,4 +2471,63 @@ interface CreateCapxulClientInput {
|
|
|
2357
2471
|
};
|
|
2358
2472
|
}
|
|
2359
2473
|
//#endregion
|
|
2360
|
-
|
|
2474
|
+
//#region src/host-observability.d.ts
|
|
2475
|
+
/** One host-owned observability module at the SDK consumer boundary. */
|
|
2476
|
+
interface HostObservability {
|
|
2477
|
+
readonly failures: ObservationAdapter;
|
|
2478
|
+
readonly product: TelemetryPort;
|
|
2479
|
+
}
|
|
2480
|
+
interface PostHogObservabilityClient {
|
|
2481
|
+
capture(event: string, properties?: Readonly<Record<string, unknown>>): unknown;
|
|
2482
|
+
captureException?(exception: Error, properties?: Readonly<Record<string, unknown>>): unknown;
|
|
2483
|
+
identify?(distinctId: string, properties?: Readonly<Record<string, unknown>>): unknown;
|
|
2484
|
+
group?(groupType: string, groupKey: string, properties?: Readonly<Record<string, unknown>>): unknown;
|
|
2485
|
+
reset?(): unknown;
|
|
2486
|
+
}
|
|
2487
|
+
interface PostHogObservabilityOptions {
|
|
2488
|
+
/** Consent / kill-switch seam. Defaults to enabled. */
|
|
2489
|
+
readonly enabled?: boolean | (() => boolean);
|
|
2490
|
+
/** Host environment stamped on every SDK-owned product event. */
|
|
2491
|
+
readonly capxulEnv?: CapxulEnv;
|
|
2492
|
+
/** Host-owned correlation context shared by product and failure delivery. */
|
|
2493
|
+
readonly context?: ObservationContext | (() => ObservationContext | undefined);
|
|
2494
|
+
}
|
|
2495
|
+
/** Build the SDK's one host module around an already-initialized PostHog client. */
|
|
2496
|
+
declare function postHogObservability(client: PostHogObservabilityClient | null | undefined, options?: PostHogObservabilityOptions): HostObservability;
|
|
2497
|
+
//#endregion
|
|
2498
|
+
//#region src/observation.d.ts
|
|
2499
|
+
/** Host-owned correlation fields that are safe to attach to an SDK failure. */
|
|
2500
|
+
interface ObservationContext extends Omit<WireObservationContext, "applicationId"> {}
|
|
2501
|
+
/**
|
|
2502
|
+
* The small, SDK-owned failure envelope delivered to observation adapters.
|
|
2503
|
+
* Method arguments, response bodies, wallet payloads, and arbitrary error
|
|
2504
|
+
* details are deliberately absent.
|
|
2505
|
+
*/
|
|
2506
|
+
interface SdkFailureObservation {
|
|
2507
|
+
readonly exception: Error;
|
|
2508
|
+
readonly sdkVersion: string;
|
|
2509
|
+
readonly operation: string;
|
|
2510
|
+
readonly errorKind: string;
|
|
2511
|
+
/** Invocation snapshot; failure correlation wins over later host state. */
|
|
2512
|
+
readonly context?: ObservationContext;
|
|
2513
|
+
}
|
|
2514
|
+
type ObservationDelivery = void | PromiseLike<void>;
|
|
2515
|
+
/**
|
|
2516
|
+
* High-level host observation boundary. The SDK owns when each method is
|
|
2517
|
+
* called; the host owns the destination client, consent, and delivery policy.
|
|
2518
|
+
*/
|
|
2519
|
+
interface ObservationAdapter {
|
|
2520
|
+
/**
|
|
2521
|
+
* Optional read-only invocation context. Transport adapters snapshot it once
|
|
2522
|
+
* at call start; implementations must not mutate global SDK state.
|
|
2523
|
+
*/
|
|
2524
|
+
readonly resolveContext?: () => ObservationContext | undefined;
|
|
2525
|
+
/** A method returned the SDK's typed `{ ok: false, error }` result. */
|
|
2526
|
+
captureOperationFailure(failure: SdkFailureObservation): ObservationDelivery;
|
|
2527
|
+
/** A method unexpectedly threw or rejected instead of returning a typed result. */
|
|
2528
|
+
captureException(exception: SdkFailureObservation): ObservationDelivery;
|
|
2529
|
+
}
|
|
2530
|
+
/** Stable PostHog event used for typed failures that are expected product outcomes. */
|
|
2531
|
+
declare const CAPXUL_SDK_EXPECTED_OUTCOME_EVENT = "capxul_sdk_expected_outcome";
|
|
2532
|
+
//#endregion
|
|
2533
|
+
export { AccountMethods as $, RecipientResolution as $t, OrganizationAccount as A, isClaimed as An, FinancialOpsMethods as At, PermissionAssignInput as B, Payment as Bt, InviteMemberInput as C, Destination$1 as Cn, DestinationAddInput as Ct, OrgScopedMethods as D, Readiness as Dn, DestinationRail as Dt, OrgMethods as E, OrgLane as En, DestinationPayload as Et, RoleView as F, OfframpQuote as Ft, PermissionReplaceInput as G, PaymentDocumentVerification as Gt, PermissionCreateInput as H, PaymentDocumentKind as Ht, OrganizationPaymentBatchInput as I, OfframpQuoteInput as It, Budget as J, PaymentStatus as Jt, PermissionRevokeInput as K, PaymentDocumentsMethods as Kt, OrganizationPaymentInput as L, OfframpStatus as Lt, ResendInviteTokenInput as M, IdentityTransition as Mn, MeMethods as Mt, RoleDefinition as N, InvocationControls as Nn, MeProfile as Nt, OrgTemplate as O, StateLabel as On, DestinationRemoveInput as Ot, RoleSpendCap as P, OfframpMethods as Pt, AccountsMethods as Q, PaymentsPayInput as Qt, OrganizationPaymentItemInput as R, Payee as Rt, DetectPendingOrgInvitationsResult as S, CAPXUL_PAYMENTS_V2_ADDRESS as Sn, Destination as St, MemberView as T, IdentityState as Tn, DestinationListInput as Tt, PermissionMethods as U, PaymentDocumentRef as Ut, PermissionChangeInput as V, PaymentDirection as Vt, PermissionOptions as W, PaymentDocumentRender as Wt, OrgMeMethod as X, PaymentType as Xt, OrgMe as Y, PaymentTiming as Yt, OrgMeOptions as Z, PaymentsMethods as Zt, SystemHealth as _, SubmittedPermissionExecution as _n, ActivityMethods as _t, SdkFailureObservation as a, fingerprintPaymentIntent as an, ActorRequestsMethods as at, CurrentUserMethods as b, TelemetryIdentifyInput as bn, ActorReference as bt, PostHogObservabilityOptions as c, isSettingUpLifecycle as cn, AddressBookLabelInput as ct, CreateCapxulClientInput as d, AuthMethods as dn, InboxItem as dt, RecipientResolutionKind as en, ActorProfile as et, IdentityProfileDetails as f, OrgLifecycle as fn, InboxMethods as ft, SystemMethods as g, Permission as gn, ActivityListParams as gt, HoldingsMethods as h, MovementAnnotation as hn, ActivityItem as ht, ObservationDelivery as i, TargetsMethods as in, ActorRequestIssueInput as it, OrganizationAuditLogItem as j, isRestoring as jn, HandlesMethods as jt, OrgView as k, destination as kn, DestinationsMethods as kt, postHogObservability as l, IdentityMethods as ln, AddressBookMethods as lt, IdentityRuntimeSendResult as m, CurrentHoldings as mn, ActivityDetail as mt, ObservationAdapter as n, ResolvedTarget as nn, ActorRelationshipMethods as nt, HostObservability as o, AccountLifecycle as on, AddressBookAddInput as ot, IdentityRuntime as p, OrgSetupStep as pn, ActivityAnnotationInput as pt, PermissionReadResult as q, PaymentMoney as qt, ObservationContext as r, TargetReference as rn, ActorRequest as rt, PostHogObservabilityClient as s, AccountSetupStep as sn, AddressBookEntry as st, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as t, Ref$1 as tn, ActorProfileMethods as tt, CapxulClient as u, SmartAccountMethods as un, InboxApproveInput as ut, MediaMethods as v, TelemetryEvent as vn, ActivityPage as vt, MemberStatus as w, IdentityEvent as wn, DestinationKind as wt, CreateOrgInput as x, TelemetryPort as xn, DepositInstructions as xt, CurrentUserContext as y, TelemetryGroupInput as yn, ActivityReference as yt, OrganizationPaymentsMethods as z, PayeesMethods as zt };
|
|
@@ -34,6 +34,13 @@ interface Failure {
|
|
|
34
34
|
readonly error?: CapxulError;
|
|
35
35
|
}
|
|
36
36
|
type CapxulErrorDetails = Record<string, unknown>;
|
|
37
|
+
type SignerSource = "openfort-embedded" | "injected-eip1193" | "local-private-key";
|
|
38
|
+
type VerificationRequiredDetails = {
|
|
39
|
+
readonly requiredTier: number;
|
|
40
|
+
} | {
|
|
41
|
+
readonly rail: string;
|
|
42
|
+
readonly currentKind: string;
|
|
43
|
+
};
|
|
37
44
|
type CapxulErrorOptions = {
|
|
38
45
|
readonly cause?: unknown;
|
|
39
46
|
readonly details?: CapxulErrorDetails;
|
|
@@ -48,6 +55,91 @@ declare class CapxulError extends Error {
|
|
|
48
55
|
constructor(code: CapxulErrorCode, message: string, options?: CapxulErrorOptions);
|
|
49
56
|
}
|
|
50
57
|
declare function isCapxulError(value: unknown): value is CapxulError;
|
|
58
|
+
declare const Errors: {
|
|
59
|
+
readonly notAuthenticated: (message?: string, opts?: {
|
|
60
|
+
readonly failure_mode?: FailureMode;
|
|
61
|
+
}) => CapxulError;
|
|
62
|
+
readonly emailDeliveryFailed: (detail: string) => CapxulError;
|
|
63
|
+
readonly profileNotFound: (authUserId: string) => CapxulError;
|
|
64
|
+
readonly smartAccountMissing: (authUserId: string) => CapxulError;
|
|
65
|
+
readonly playerNotFound: (playerId?: string) => CapxulError;
|
|
66
|
+
readonly accountNotFound: (accountId?: string) => CapxulError;
|
|
67
|
+
readonly providerError: (provider: string, operation: string, cause: unknown, opts?: {
|
|
68
|
+
readonly failure_mode?: FailureMode;
|
|
69
|
+
}) => CapxulError;
|
|
70
|
+
readonly capabilityUnavailable: (provider: string, operation: string) => CapxulError;
|
|
71
|
+
readonly invalidInput: (field: string, reason: string) => CapxulError;
|
|
72
|
+
readonly envMissing: (name: string) => CapxulError;
|
|
73
|
+
readonly notImplemented: (domain: string, method: string) => CapxulError;
|
|
74
|
+
/**
|
|
75
|
+
* Sibling factory to {@link Errors.providerError} for the per-state timeout
|
|
76
|
+
* path in flows. Same `PROVIDER_ERROR` code as
|
|
77
|
+
* `providerError`, plus a `details.reason: "timeout"` discriminator so
|
|
78
|
+
* downstream observers can distinguish failure modes without parsing the
|
|
79
|
+
* message string. The redacted message names the timeout budget; the
|
|
80
|
+
* native `cause` carries the same information for `reportError` fidelity.
|
|
81
|
+
*/
|
|
82
|
+
readonly providerTimeout: (provider: string, operation: string, timeoutMs: number) => CapxulError;
|
|
83
|
+
readonly verificationRequired: (details: VerificationRequiredDetails) => CapxulError;
|
|
84
|
+
readonly insufficientBalance: (asset: string, available: string, required: string) => CapxulError;
|
|
85
|
+
readonly invalidRecipient: (reason: string) => CapxulError;
|
|
86
|
+
/**
|
|
87
|
+
* The org Zodiac Roles modifier REFUSED the spend on-chain (G4 · #547): the
|
|
88
|
+
* member's role condition (per-tx cap, per-day allowance, allowed recipient,
|
|
89
|
+
* or membership) was violated, so `execTransactionWithRole` reverted. This is
|
|
90
|
+
* a PERMISSION denial — explicitly NOT an `INSUFFICIENT_BALANCE` (the treasury
|
|
91
|
+
* held the funds; the role's authority is what bound). `reason` discriminates
|
|
92
|
+
* the violated condition (`over_cap` / `daily_cap` / `not_member` /
|
|
93
|
+
* `disallowed_recipient` / `condition_violation`); leak-safe — no on-chain
|
|
94
|
+
* identifiers ever enter the details.
|
|
95
|
+
*/
|
|
96
|
+
readonly rolePermissionDenied: (details: {
|
|
97
|
+
readonly reason: "over_cap" | "daily_cap" | "not_member" | "disallowed_recipient" | "condition_violation";
|
|
98
|
+
readonly operation?: string;
|
|
99
|
+
}) => CapxulError;
|
|
100
|
+
/**
|
|
101
|
+
* A transaction (or sponsored UserOp) failed. `details.reason` discriminates
|
|
102
|
+
* the failure mode for callers that must distinguish a CONFIRMED on-chain
|
|
103
|
+
* revert (`"onchain_revert"` — the op executed and reverted, e.g. a Zodiac
|
|
104
|
+
* Roles condition violation) from an inconclusive infra failure. A confirmed
|
|
105
|
+
* revert is the ONLY mode the org spend port may map to a roles denial.
|
|
106
|
+
*/
|
|
107
|
+
readonly transactionFailed: (operation: string, cause?: unknown, extra?: {
|
|
108
|
+
readonly reason?: string;
|
|
109
|
+
}) => CapxulError;
|
|
110
|
+
readonly rateLimited: (details?: {
|
|
111
|
+
readonly retryAfterMs?: number;
|
|
112
|
+
readonly resource?: string;
|
|
113
|
+
}) => CapxulError;
|
|
114
|
+
readonly networkError: (operation: string, cause?: unknown) => CapxulError;
|
|
115
|
+
readonly unknown: (cause?: unknown) => CapxulError;
|
|
116
|
+
readonly otpExpired: (details?: {
|
|
117
|
+
readonly email?: string;
|
|
118
|
+
readonly expiredAt?: number;
|
|
119
|
+
}) => CapxulError;
|
|
120
|
+
readonly signerRejected: (details: {
|
|
121
|
+
readonly source: SignerSource;
|
|
122
|
+
readonly reason?: string;
|
|
123
|
+
readonly cause?: unknown;
|
|
124
|
+
}) => CapxulError;
|
|
125
|
+
readonly cancelled: (details?: {
|
|
126
|
+
readonly operation?: string;
|
|
127
|
+
readonly reason?: string;
|
|
128
|
+
}) => CapxulError;
|
|
129
|
+
/**
|
|
130
|
+
* Method called from a flow state where its precondition fails (TA16). The
|
|
131
|
+
* SDK's method API short-circuits with this error before driving the
|
|
132
|
+
* internal state machine. `currentState` is the Effect-machine snapshot
|
|
133
|
+
* tag (stringified from the SDK's actor-shell snapshot; see
|
|
134
|
+
* `packages/errors/CONTEXT.md`); `validStates`
|
|
135
|
+
* enumerates the states the method accepts.
|
|
136
|
+
*/
|
|
137
|
+
readonly wrongState: (details: {
|
|
138
|
+
readonly method: string;
|
|
139
|
+
readonly currentState: string;
|
|
140
|
+
readonly validStates: readonly string[];
|
|
141
|
+
}) => CapxulError;
|
|
142
|
+
};
|
|
51
143
|
//#endregion
|
|
52
144
|
//#region ../types/src/brand.d.ts
|
|
53
145
|
/**
|
|
@@ -99,9 +191,11 @@ type Account$1 = {
|
|
|
99
191
|
type AuthUserId = Brand<string, "AuthUserId">;
|
|
100
192
|
type AnonymousDistinctId = Brand<string, "AnonymousDistinctId">;
|
|
101
193
|
type AccountId = Brand<string, "AccountId">;
|
|
194
|
+
type PartyId = Brand<string, "PartyId">;
|
|
102
195
|
type MovementId = Brand<string, "MovementId">;
|
|
103
196
|
type PermissionId = Brand<string, "PermissionId">;
|
|
104
197
|
type PermissionAssignmentId = Brand<string, "PermissionAssignmentId">;
|
|
198
|
+
type BudgetId = Brand<string, "BudgetId">;
|
|
105
199
|
type PaymentCommandId = Brand<string, "PaymentCommandId">;
|
|
106
200
|
type OrgId = Brand<string, "OrgId">;
|
|
107
201
|
type AppId = Brand<string, "AppId">;
|
|
@@ -275,6 +369,27 @@ interface CapxulSigner extends CapxulDigestSigner {
|
|
|
275
369
|
readonly source: AccountProviderSource;
|
|
276
370
|
/** Owner EOA address — the Safe's single owner. */
|
|
277
371
|
getAddress(): Promise<Address$1>;
|
|
372
|
+
/**
|
|
373
|
+
* Readiness this signer reports, when it runs a readiness cycle at all. Only
|
|
374
|
+
* the Openfort browser signer does. `assembleCapxulClient` reads it onto
|
|
375
|
+
* `client.signer`, and substitutes `UNOBSERVABLE_SIGNER_STATUS` when absent.
|
|
376
|
+
*/
|
|
377
|
+
readonly statusStore?: SignerStatusStore;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Observable signer readiness (ACCESS #1520 · C12). `unknown` means the
|
|
381
|
+
* wallet-ready cycle did not start. `recovering` means it is running; the
|
|
382
|
+
* stale-cache heal runs inside that phase. `ready` means the signer can sign.
|
|
383
|
+
* `unavailable` means the cycle failed. A failure is distinguishable from a
|
|
384
|
+
* cycle that never started. That is why there are four states.
|
|
385
|
+
*/
|
|
386
|
+
type SignerStatus = "unknown" | "recovering" | "ready" | "unavailable";
|
|
387
|
+
/** Subscribable readiness surface. Assembled onto `client.signer`. */
|
|
388
|
+
interface SignerStatusStore {
|
|
389
|
+
/** The current status. */
|
|
390
|
+
status(): SignerStatus;
|
|
391
|
+
/** Fires on every change. Returns its own unsubscribe. */
|
|
392
|
+
subscribe(listener: (status: SignerStatus) => void): () => void;
|
|
278
393
|
}
|
|
279
394
|
/** Minimal EIP-1193 surface an injected browser wallet exposes. */
|
|
280
395
|
interface Eip1193RequestProvider {
|
|
@@ -292,4 +407,4 @@ interface Eip1193RequestProvider {
|
|
|
292
407
|
*/
|
|
293
408
|
declare function injectedWalletSigner(provider: Eip1193RequestProvider): CapxulSigner;
|
|
294
409
|
//#endregion
|
|
295
|
-
export {
|
|
410
|
+
export { toAddress as $, BlockNumber as A, MovementId as B, Address$1 as C, AppId as D, AnonymousDistinctId as E, DocumentHash as F, PermissionId as G, PartyId as H, DurationMs as I, RoleKey as J, Profile$1 as K, Email as L, ChainId as M, CountryCode as N, AuthSession as O, CurrencyCode as P, WeiAmount as Q, EpochMs as R, AccountId as S, AllowedOrigin as T, PaymentCommandId as U, OrgId as V, PermissionAssignmentId as W, SmartAccount$1 as X, SessionToken as Y, TxHash as Z, AuthCacheError as _, SignerStatusStore as a, Errors as at, CachedJwt as b, AccountProviderSource as c, isCapxulError as ct, eip1193AccountProvider as d, toCountryCode as et, localPrivateKeyAccountProvider as f, SmartAccount as g, Session as h, SignerStatus as i, CapxulErrorDetails as it, BudgetId as j, AuthUserId as k, AccountRequirement as l, Profile as m, CapxulSigner as n, CapxulError as nt, injectedWalletSigner as o, Failure as ot, CapxulResult as p, PublishableKey as q, Eip1193RequestProvider as r, CapxulErrorCode as rt, AccountProvider as s, FailureMode as st, CapxulDigestSigner as t, CAPXUL_ERROR_CODES as tt, Eip1193Provider as u, AuthCachePort as v, AllowanceKey as w, Account$1 as x, AuthCachePortTag as y, Money as z };
|
package/dist/testing/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Mn as IdentityTransition, bn as TelemetryIdentifyInput, n as ObservationAdapter, u as CapxulClient, vn as TelemetryEvent, yn as TelemetryGroupInput } from "../observation-Ci8gIQjm.mjs";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/testing/telemetry/RecordingTelemetryAdapter.d.ts
|
|
@@ -18,6 +18,8 @@ type RecordingTelemetryOperation = {
|
|
|
18
18
|
//#region src/testing/index.d.ts
|
|
19
19
|
interface CreateCapxulTestClientOptions {
|
|
20
20
|
readonly requirement?: "none" | "counterfactual" | "deployed";
|
|
21
|
+
/** Optional Core SDK failure adapter for packed consumer proofs. */
|
|
22
|
+
readonly failureObservation?: ObservationAdapter;
|
|
21
23
|
}
|
|
22
24
|
interface SeedTestIdentityInput {
|
|
23
25
|
readonly authUserId: string;
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { E as authClientPortFromPromiseAdapter, M as fromWei, T as bootstrapErrorFromCapxul, Y as deriveCapxulSafeAddress, _ as wireChainId, f as redactTelemetryEvent, g as accountReadErrorFromCapxul, j as toWei, m as smartAccountErrorFromCapxul, t as assembleCapxulClient, x as convexCallErrorFromCapxul, y as identityErrorFromCapxul } from "../create-capxul-client-mArFr_Os.mjs";
|
|
2
|
+
import { C as toDurationMs, D as toJwtToken, E as toEpochSeconds, I as CapxulError, N as toSessionToken, O as toKycTier, R as Errors, T as toEpochMs, _ as toAppId, b as toChainId, g as toAllowedOrigin, h as toAddress, j as toPublishableKey, m as toAccountId, t as InMemoryAuthCacheAdapter, v as toAuthUserId, w as toEmail, x as toCountryCode } from "../InMemoryAuthCacheAdapter-qMpBOGb3.mjs";
|
|
3
3
|
import { keccak256 } from "viem";
|
|
4
4
|
import { Effect, Result, Semaphore } from "effect";
|
|
5
5
|
import { getFunctionName } from "convex/server";
|
|
@@ -884,7 +884,8 @@ function createCapxulTestClient(options = {}) {
|
|
|
884
884
|
},
|
|
885
885
|
bootstrap: TEST_BOOTSTRAP,
|
|
886
886
|
authCache,
|
|
887
|
-
requirement: options.requirement ?? "none"
|
|
887
|
+
requirement: options.requirement ?? "none",
|
|
888
|
+
...options.failureObservation === void 0 ? {} : { failureObservation: options.failureObservation }
|
|
888
889
|
});
|
|
889
890
|
const transitions = [];
|
|
890
891
|
const unsubscribe = client._internal.identity.subscribeTransitions((record) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Xelmar-tech/infrastructure.git",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"vite-plus": "0.1.23",
|
|
48
48
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.23",
|
|
49
49
|
"@capxul/config": "0.2.0",
|
|
50
|
-
"@capxul/
|
|
51
|
-
"@capxul/observability": "2.1.1",
|
|
50
|
+
"@capxul/observability": "2.3.0",
|
|
52
51
|
"@capxul/typescript-config": "0.0.0",
|
|
53
|
-
"@capxul/
|
|
54
|
-
"@capxul/wire": "0.
|
|
52
|
+
"@capxul/errors": "0.0.1",
|
|
53
|
+
"@capxul/wire": "0.4.0",
|
|
54
|
+
"@capxul/types": "0.2.0"
|
|
55
55
|
},
|
|
56
56
|
"_permissionlessPinReason": "permissionless.toSafeSmartAccount is pinned to 0.3.4 for live Safe deployment E2E. Counterfactual address fixtures captured 2026-05-17 in packages/backend/convex/_shared/__tests__/counterfactual.test.ts and packages/config/tests/safe.test.ts must be re-verified before upgrading.",
|
|
57
57
|
"scripts": {
|