@capxul/sdk 1.0.0-alpha.9 → 1.2.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 +121 -6
- package/dist/{InMemoryAuthCacheAdapter-v5W-XB5M.mjs → InMemoryAuthCacheAdapter-Dr1sEd9y.mjs} +36 -16
- package/dist/InMemoryAuthCacheAdapter-Dr1sEd9y.mjs.map +1 -0
- package/dist/create-capxul-client-C7H5b68l.d.mts +2764 -0
- package/dist/create-capxul-client-C7H5b68l.d.mts.map +1 -0
- package/dist/create-capxul-client-DiqVIxsV.mjs +6980 -0
- package/dist/create-capxul-client-DiqVIxsV.mjs.map +1 -0
- package/dist/index.d.mts +119 -2020
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2464 -6308
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.d.mts +3 -6
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.mjs +27 -27
- package/dist/node/index.mjs.map +1 -1
- package/dist/signer-CJT0pPiO.d.mts +301 -0
- package/dist/signer-CJT0pPiO.d.mts.map +1 -0
- package/dist/testing/index.d.mts +54 -0
- package/dist/testing/index.d.mts.map +1 -0
- package/dist/testing/index.mjs +1068 -0
- package/dist/testing/index.mjs.map +1 -0
- package/package.json +17 -18
- package/dist/InMemoryAuthCacheAdapter-v5W-XB5M.mjs.map +0 -1
- package/dist/index-CTXgQ_xR.d.mts +0 -158
- package/dist/index-CTXgQ_xR.d.mts.map +0 -1
- package/dist/ports/safe-deployment.d.mts +0 -2
- package/dist/ports/safe-deployment.mjs +0 -38
- package/dist/ports/safe-deployment.mjs.map +0 -1
- package/dist/safe-deployment-D3k9yndM.d.mts +0 -136
- package/dist/safe-deployment-D3k9yndM.d.mts.map +0 -1
- package/dist/signer-DqDtJU1l.d.mts +0 -145
- package/dist/signer-DqDtJU1l.d.mts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,2023 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as
|
|
3
|
-
import { a as SafeDeploymentEvidence, n as SafeDeploymentConfig } from "./safe-deployment-D3k9yndM.mjs";
|
|
1
|
+
import { $ as isCapxulError, E as AuthUserId, F as Money, I as OrgId, J as CapxulError, K as toAddress, Q as FailureMode, T as AuthSession, U as SubAccount, W as SubAccountId, X as CapxulErrorDetails, Y as CapxulErrorCode, a as AccountProvider, b as AccountId, c as Eip1193Provider, d as CapxulResult, f as Profile, i as injectedWalletSigner, k as CountryCode, l as eip1193AccountProvider, m as SmartAccount, n as CapxulSigner, o as AccountProviderSource, p as Session, q as toCountryCode, r as Eip1193RequestProvider, s as AccountRequirement, t as CapxulDigestSigner, u as localPrivateKeyAccountProvider, x as Address, y as Account, z as RoleKey } from "./signer-CJT0pPiO.mjs";
|
|
2
|
+
import { $ as InsightsSummary, $t as OrgSetupStep, A as PayrollRosterLine, At as PaymentMoney, B as ActorProfileMethods, Bt as RecipientResolutionKind, C as OrgTemplate, Ct as PayeesMethods, D as PayrollMethods, Dt as PaymentDocumentRender, E as OrganizationAuditLogItem, Et as PaymentDocumentRef, F as RoleSpendCap, Ft as PaymentsMethods, G as AddressBookAddInput, Gt as TargetsMethods, H as ActorRequest, Ht as Ref, I as RoleView, It as PaymentsPayInput, J as AddressBookMethods, Jt as isSettingUpLifecycle, K as AddressBookEntry, Kt as AccountLifecycle, L as AccountsMethods, Lt as PaymentsPayoutInput, M as RemoveMemberInput, Mt as PaymentStatus, N as ResendInviteTokenInput, Nt as PaymentTiming, O as PayrollPayslipTemplate, Ot as PaymentDocumentVerification, P as RoleDefinition, Pt as PaymentType, Q as InsightsMethods, Qt as OrgLifecycle, R as AccountMethods, Rt as PaymentsWithdrawInput, S as OrgSpendViaPaymentsInput, St as Payee, T as OrganizationAccount, Tt as PaymentDocumentKind, U as ActorRequestIssueInput, Ut as ResolvedTarget, V as ActorRelationshipMethods, Vt as ReconciliationEntry, W as ActorRequestsMethods, Wt as TargetReference, X as InboxItem, Xt as SmartAccountMethods, Y as InboxApproveInput, Yt as IdentityMethods, Z as InboxMethods, Zt as AuthMethods, _ as MemberView, _n as InvocationControls, _t as MeProfile, a as IdentityRuntimeSendResult, at as DepositInstructions, b as OrgPayrollRun, bt as OfframpQuoteInput, c as SystemHealth, cn as TelemetryPort, ct as DestinationKind, d as CurrentUserMethods, dn as IdentityState, dt as DestinationRail, en as WireObservationContext, et as ActivityItem, f as AssignRoleInput, fn as OrgLane, ft as DestinationRemoveInput, g as MemberStatus, gn as IdentityTransition, gt as MeMethods, h as InviteMemberInput, hn as destination, ht as HandlesMethods, i as IdentityRuntime, in as CapxulEnv, it as ActorReference, j as PayrollRunInput, jt as PaymentSettlementInput, k as PayrollRosterAddInput, kt as PaymentDocumentsMethods, l as MediaMethods, ln as Destination$1, lt as DestinationListInput, m as DetectPendingOrgInvitationsResult, mn as StateLabel, mt as FinancialOpsMethods, n as CreateCapxulClientInput, nn as TransferInput, nt as ActivityMethods, o as SubAccountsMethods, ot as Destination, p as CreateOrgInput, pn as Readiness, pt as DestinationsMethods, q as AddressBookLabelInput, qt as AccountSetupStep, r as IdentityProfileDetails, rn as TransferResult, rt as ActivityPage, s as SystemMethods, st as DestinationAddInput, t as CapxulClient, tn as TransferEndpoint, tt as ActivityListParams, u as CurrentUserContext, un as IdentityEvent, ut as DestinationPayload, v as OrgBatchPayrollInput, vt as OfframpMethods, w as OrgView, wt as Payment, x as OrgScopedMethods, xt as OfframpStatus, y as OrgMethods, yt as OfframpQuote, z as ActorProfile, zt as RecipientResolution } from "./create-capxul-client-C7H5b68l.mjs";
|
|
4
3
|
import { Hex } from "viem";
|
|
5
|
-
import { Context, Effect, Layer,
|
|
6
|
-
import { Schema } from "@effect/schema";
|
|
4
|
+
import { Context, Effect, Layer, Tracer } from "effect";
|
|
7
5
|
import { FunctionReference } from "convex/server";
|
|
8
|
-
import {
|
|
6
|
+
import { OtlpExporter } from "effect/unstable/observability";
|
|
9
7
|
|
|
10
|
-
//#region src/ports/auth-client.d.ts
|
|
11
|
-
type AuthClientOperationOptions = {
|
|
12
|
-
readonly signal?: AbortSignal;
|
|
13
|
-
};
|
|
14
|
-
type SendOtpInput = {
|
|
15
|
-
readonly email: Email;
|
|
16
|
-
};
|
|
17
|
-
type CanSendOtpInput = {
|
|
18
|
-
readonly email: Email;
|
|
19
|
-
};
|
|
20
|
-
type CanSendOtpStatus = {
|
|
21
|
-
readonly allowed: boolean;
|
|
22
|
-
readonly cooldownMs: DurationMs;
|
|
23
|
-
};
|
|
24
|
-
type VerifyOtpInput = {
|
|
25
|
-
readonly email: Email;
|
|
26
|
-
readonly otp: string;
|
|
27
|
-
};
|
|
28
|
-
type GetConvexJwtOptions = AuthClientOperationOptions & {
|
|
29
|
-
readonly forceRefresh?: boolean;
|
|
30
|
-
};
|
|
31
|
-
declare const AuthClientError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
32
|
-
readonly _tag: "AuthClientError";
|
|
33
|
-
} & Readonly<A>;
|
|
34
|
-
declare class AuthClientError extends AuthClientError_base<{
|
|
35
|
-
readonly operation: string;
|
|
36
|
-
readonly kind: string;
|
|
37
|
-
readonly cause: unknown;
|
|
38
|
-
}> {}
|
|
39
|
-
interface AuthClientPort {
|
|
40
|
-
canSendOtp(input: CanSendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<CanSendOtpStatus, AuthClientError>;
|
|
41
|
-
sendOtp(input: SendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
|
|
42
|
-
verifyOtp(input: VerifyOtpInput, options?: AuthClientOperationOptions): Effect.Effect<AuthSession, AuthClientError>;
|
|
43
|
-
getSession(options?: AuthClientOperationOptions): Effect.Effect<AuthSession | null, AuthClientError>;
|
|
44
|
-
signOut(options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
|
|
45
|
-
/**
|
|
46
|
-
* Fetches a Convex-aud JWT from `/api/auth/convex/token` (W7). Server mints
|
|
47
|
-
* a fresh JWT on every call per Probe A's 2026-05-19 finding (RS256, 900 s
|
|
48
|
-
* lifetime, `iss = <site-url>`, `aud = convex`). The caller (the SDK's
|
|
49
|
-
* `tokenProvider` wired into ConvexCallPort) is responsible for the
|
|
50
|
-
* `exp - 30s` proactive cache + `forceRefresh` callback handshake.
|
|
51
|
-
*/
|
|
52
|
-
getConvexJwt(options?: GetConvexJwtOptions): Effect.Effect<CachedJwt, AuthClientError>;
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/ports/clock.d.ts
|
|
56
|
-
interface ClockPort {
|
|
57
|
-
readonly now: Effect.Effect<EpochMs, ClockError>;
|
|
58
|
-
readonly sleep: (duration: DurationMs) => Effect.Effect<void, ClockError>;
|
|
59
|
-
}
|
|
60
|
-
declare const ClockError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
61
|
-
readonly _tag: "ClockError";
|
|
62
|
-
} & Readonly<A>;
|
|
63
|
-
declare class ClockError extends ClockError_base<{
|
|
64
|
-
readonly operation: "now" | "sleep" | "initialize";
|
|
65
|
-
readonly cause: unknown;
|
|
66
|
-
}> {}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region ../observability/src/telemetry-port.d.ts
|
|
69
|
-
/**
|
|
70
|
-
* Context for reporting handled errors via `reportHandledError`.
|
|
71
|
-
* Carries structured metadata extracted from the error context.
|
|
72
|
-
*/
|
|
73
|
-
interface HandledErrorReportContext$1 {
|
|
74
|
-
readonly layer?: string;
|
|
75
|
-
readonly operation?: string;
|
|
76
|
-
readonly failure_mode?: FailureMode;
|
|
77
|
-
readonly provider?: string;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Canonical TelemetryPort interface. Every adapter (production, test, in-memory)
|
|
81
|
-
* implements this contract. All methods return `Effect<void, never>` —
|
|
82
|
-
* fire-and-forget, defects are caught and traced.
|
|
83
|
-
*/
|
|
84
|
-
interface TelemetryPort {
|
|
85
|
-
readonly emit: (event: TelemetryEvent) => Effect.Effect<void, never>;
|
|
86
|
-
readonly identify: (input: TelemetryIdentifyInput) => Effect.Effect<void, never>;
|
|
87
|
-
readonly group: (input: TelemetryGroupInput) => Effect.Effect<void, never>;
|
|
88
|
-
readonly reset: () => Effect.Effect<void, never>;
|
|
89
|
-
readonly reportHandledError?: (error: CapxulError, context?: HandledErrorReportContext$1) => Effect.Effect<void, never>;
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region ../observability/src/index.d.ts
|
|
93
|
-
declare const TELEMETRY_EVENT_NAMES: readonly ["auth_otp_requested", "auth_otp_delivered", "auth_otp_expired", "auth_verified", "auth_failed", "auth_signed_out", "provisioning_safe_created", "provisioning_safe_confirmed", "bootstrap_resolved", "bootstrap_failed", "account_balance_read", "account_balance_failed", "faucet_requested", "faucet_confirmed", "faucet_failed", "subaccount_created", "subaccount_renamed", "subaccount_deleted", "subaccount_op_failed", "transfer_requested", "transfer_confirmed", "transfer_failed", "org_create_started", "org_safe_created", "org_safe_confirmed", "org_roles_seeded", "org_created", "org_create_failed", "org_invite_sent", "org_invite_accepted", "org_role_granted", "org_member_active", "org_member_removed", "org_invite_expired", "org_role_grant_failed", "payment_requested", "payment_resolved", "payment_document_attached", "payment_submitted", "payment_settled", "payment_claimed", "payment_cancelled", "payment_redirected", "payment_failed", "stream_created", "stream_claimed", "stream_cancelled", "stream_completed", "stream_failed", "withdrawal_requested", "withdrawal_submitted", "withdrawal_settled", "withdrawal_failed"];
|
|
94
|
-
type TelemetryEventName = (typeof TELEMETRY_EVENT_NAMES)[number];
|
|
95
|
-
type TelemetryProps = Record<string, unknown>;
|
|
96
|
-
type TelemetryEvent = {
|
|
97
|
-
readonly name: TelemetryEventName;
|
|
98
|
-
readonly props?: TelemetryProps | undefined;
|
|
99
|
-
};
|
|
100
|
-
interface TelemetryIdentifyInput {
|
|
101
|
-
readonly distinctId: string;
|
|
102
|
-
readonly anonDistinctId?: AnonymousDistinctId;
|
|
103
|
-
readonly traits?: TelemetryProps;
|
|
104
|
-
readonly properties?: TelemetryProps;
|
|
105
|
-
}
|
|
106
|
-
interface TelemetryGroupInput {
|
|
107
|
-
readonly groupType: string;
|
|
108
|
-
readonly groupKey: string;
|
|
109
|
-
readonly properties?: TelemetryProps;
|
|
110
|
-
}
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/flows/auth.d.ts
|
|
113
|
-
interface AuthFlowInput {
|
|
114
|
-
readonly otpTtlMs?: number;
|
|
115
|
-
}
|
|
116
|
-
type AuthFlowState = "idle" | "sending_otp" | "otp_requested" | "verifying" | "authenticated" | "signing_out" | "error";
|
|
117
|
-
interface AuthFlowContext {
|
|
118
|
-
readonly state: AuthFlowState;
|
|
119
|
-
readonly email: Email | null;
|
|
120
|
-
readonly session: AuthSession | null;
|
|
121
|
-
readonly otpRequestedAt: EpochMs | null;
|
|
122
|
-
readonly anonDistinctId?: AnonymousDistinctId;
|
|
123
|
-
readonly error: CapxulError | null;
|
|
124
|
-
}
|
|
125
|
-
interface AuthFlowObserver {
|
|
126
|
-
readonly input: AuthFlowInput;
|
|
127
|
-
readonly getSnapshot: () => {
|
|
128
|
-
readonly value: AuthFlowState;
|
|
129
|
-
readonly context: AuthFlowContext;
|
|
130
|
-
readonly status: "active" | "stopped";
|
|
131
|
-
};
|
|
132
|
-
readonly stop: () => void;
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/env/_internal.d.ts
|
|
136
|
-
declare const envShapeSchema: Schema.Struct<{
|
|
137
|
-
[k: string]: Schema.Schema<string, string, never> | Schema.optional<Schema.Schema<string, string, never>>;
|
|
138
|
-
}>;
|
|
139
|
-
type EnvShape = Schema.Schema.Type<typeof envShapeSchema>;
|
|
140
|
-
type EnvKey = keyof EnvShape & string;
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/env/index.d.ts
|
|
143
|
-
type RequiredEnvKey = EnvKey;
|
|
144
|
-
type OptionalEnvKey = EnvKey;
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/ports/env.d.ts
|
|
147
|
-
declare const EnvError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
148
|
-
readonly _tag: "EnvError";
|
|
149
|
-
} & Readonly<A>;
|
|
150
|
-
declare class EnvError extends EnvError_base<{
|
|
151
|
-
readonly publicError: CapxulError;
|
|
152
|
-
readonly publicCode?: CapxulErrorCode;
|
|
153
|
-
readonly key?: string;
|
|
154
|
-
readonly details?: CapxulErrorDetails;
|
|
155
|
-
readonly cause?: unknown;
|
|
156
|
-
}> {}
|
|
157
|
-
interface EnvPort {
|
|
158
|
-
readonly require: <K extends RequiredEnvKey>(key: K) => Effect.Effect<EnvShape[K], EnvError, never>;
|
|
159
|
-
readonly optional: <K extends OptionalEnvKey>(key: K) => Effect.Effect<EnvShape[K] | undefined, EnvError, never>;
|
|
160
|
-
readonly has: (key: EnvKey) => Effect.Effect<boolean, EnvError, never>;
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/ports/transport.d.ts
|
|
164
|
-
type TransportOperationKind = "query" | "mutation" | "action";
|
|
165
|
-
type TransportRequest<TArgs = unknown> = {
|
|
166
|
-
readonly name: string;
|
|
167
|
-
readonly args: TArgs;
|
|
168
|
-
readonly correlationId?: string;
|
|
169
|
-
};
|
|
170
|
-
declare const TransportError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
171
|
-
readonly _tag: "TransportError";
|
|
172
|
-
} & Readonly<A>;
|
|
173
|
-
declare class TransportError extends TransportError_base<{
|
|
174
|
-
readonly operation: TransportOperationKind;
|
|
175
|
-
readonly name: string;
|
|
176
|
-
readonly publicCode: CapxulErrorCode;
|
|
177
|
-
readonly publicError: CapxulError;
|
|
178
|
-
readonly cause: unknown;
|
|
179
|
-
readonly correlationId?: string;
|
|
180
|
-
readonly details?: CapxulErrorDetails;
|
|
181
|
-
}> {}
|
|
182
|
-
interface TransportPort {
|
|
183
|
-
readonly runQuery: <TOutput = unknown, TArgs = unknown>(request: TransportRequest<TArgs>) => Effect.Effect<TOutput, TransportError>;
|
|
184
|
-
readonly runMutation: <TOutput = unknown, TArgs = unknown>(request: TransportRequest<TArgs>) => Effect.Effect<TOutput, TransportError>;
|
|
185
|
-
readonly runAction: <TOutput = unknown, TArgs = unknown>(request: TransportRequest<TArgs>) => Effect.Effect<TOutput, TransportError>;
|
|
186
|
-
}
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region src/ports/bootstrap.d.ts
|
|
189
|
-
type BootstrapInput = {
|
|
190
|
-
readonly publishableKey: PublishableKey;
|
|
191
|
-
/**
|
|
192
|
-
* Browser callers send the App origin so bootstrap can enforce the
|
|
193
|
-
* publishable-key allowlist. Node/server callers may omit it; the backend
|
|
194
|
-
* only applies the origin allowlist when an origin is present.
|
|
195
|
-
*/
|
|
196
|
-
readonly origin?: AllowedOrigin;
|
|
197
|
-
};
|
|
198
|
-
type BootstrapResolution = {
|
|
199
|
-
readonly applicationId: AppId;
|
|
200
|
-
readonly chainId: ChainId;
|
|
201
|
-
/**
|
|
202
|
-
* SDK-handshake session token — distinct from the user-auth `AuthSession`
|
|
203
|
-
* token issued by `AuthClientPort`. Both use the `SessionToken` brand for
|
|
204
|
-
* opaque-string discipline; the issuance source distinguishes them.
|
|
205
|
-
*/
|
|
206
|
-
readonly sessionToken: SessionToken;
|
|
207
|
-
readonly issuedAt: EpochMs;
|
|
208
|
-
readonly expiresIn: DurationMs;
|
|
209
|
-
readonly authBaseUrl: string;
|
|
210
|
-
readonly convexUrl: string;
|
|
211
|
-
readonly siteBaseUrl: string;
|
|
212
|
-
readonly openfortPublishableKey: string;
|
|
213
|
-
readonly shieldPublishableKey: string;
|
|
214
|
-
};
|
|
215
|
-
type BootstrapErrorKind = "notAuthenticated" | "network" | "provider" | "malformedBody" | "invalidInput" | "rateLimited";
|
|
216
|
-
declare const BootstrapError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
217
|
-
readonly _tag: "BootstrapError";
|
|
218
|
-
} & Readonly<A>;
|
|
219
|
-
declare class BootstrapError extends BootstrapError_base<{
|
|
220
|
-
readonly operation: "resolve";
|
|
221
|
-
readonly kind: BootstrapErrorKind;
|
|
222
|
-
readonly publicCode: CapxulErrorCode;
|
|
223
|
-
readonly cause: unknown;
|
|
224
|
-
readonly details?: CapxulErrorDetails;
|
|
225
|
-
}> {}
|
|
226
|
-
interface BootstrapPort {
|
|
227
|
-
readonly resolve: (input: BootstrapInput) => Effect.Effect<BootstrapResolution, BootstrapError>;
|
|
228
|
-
}
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region src/ports/subscription.d.ts
|
|
231
|
-
/**
|
|
232
|
-
* Canonical teardown handle for substrate-level reactive callbacks.
|
|
233
|
-
*
|
|
234
|
-
* Calling it stops the subscription; no further snapshots will be delivered
|
|
235
|
-
* to the callback after the first invocation. Calling more than once is a
|
|
236
|
-
* no-op (idempotent).
|
|
237
|
-
*
|
|
238
|
-
* @internal-use
|
|
239
|
-
*/
|
|
240
|
-
type Unsubscribe = () => void;
|
|
241
|
-
/**
|
|
242
|
-
* Snapshot is the substrate discriminated union for reactive callbacks over
|
|
243
|
-
* `ConvexCallPort.subscribe`. The public SDK surface is imperative
|
|
244
|
-
* (`Promise<CapxulResult>`). This type is reachable for internal XState
|
|
245
|
-
* `fromCallback` actor wiring,
|
|
246
|
-
* property-based `crossAdapterSubscriptionProperty` harness consumers, and
|
|
247
|
-
* genuinely non-React advanced consumers.
|
|
248
|
-
*
|
|
249
|
-
* - `loading` · initial state before any value arrives from the substrate
|
|
250
|
-
* - `ok` · a successful snapshot carrying `value`
|
|
251
|
-
* - `error` · a failed snapshot carrying a typed error (defaults to
|
|
252
|
-
* `CapxulError`)
|
|
253
|
-
*
|
|
254
|
-
* Generic over the value type `T`. The error type `E` is parameterised but
|
|
255
|
-
* defaults to `CapxulError` — every shipped port today uses the default. A
|
|
256
|
-
* narrower or wider `E` is reserved for future ports that need a different
|
|
257
|
-
* error vocabulary.
|
|
258
|
-
*
|
|
259
|
-
* The substrate guarantees the first snapshot is `loading` (CC8 in the
|
|
260
|
-
* `ConvexCallPort` contract); subsequent snapshots carry `ok` or `error`
|
|
261
|
-
* per the underlying transport.
|
|
262
|
-
*
|
|
263
|
-
* Per ARCH-LOCK-1 (`docs/decisions/stage-4-reactivity-pivot.html`), domain
|
|
264
|
-
* ports do not expose reactive callback methods.
|
|
265
|
-
*
|
|
266
|
-
* @internal-use
|
|
267
|
-
*/
|
|
268
|
-
type Snapshot<T, E = CapxulError> = {
|
|
269
|
-
readonly status: "loading";
|
|
270
|
-
} | {
|
|
271
|
-
readonly status: "ok";
|
|
272
|
-
readonly value: T;
|
|
273
|
-
} | {
|
|
274
|
-
readonly status: "error";
|
|
275
|
-
readonly error: E;
|
|
276
|
-
};
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region src/ports/convex-call.d.ts
|
|
279
|
-
declare const ConvexCallError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
280
|
-
readonly _tag: "ConvexCallError";
|
|
281
|
-
} & Readonly<A>;
|
|
282
|
-
declare class ConvexCallError extends ConvexCallError_base<{
|
|
283
|
-
readonly operation: string;
|
|
284
|
-
readonly publicCode: CapxulErrorCode;
|
|
285
|
-
readonly publicError: CapxulError;
|
|
286
|
-
readonly cause: unknown;
|
|
287
|
-
readonly details?: CapxulErrorDetails;
|
|
288
|
-
}> {}
|
|
289
|
-
interface ConvexCallPort {
|
|
290
|
-
query<TArgs extends Record<string, unknown>, TOutput>(fn: FunctionReference<"query", "public", TArgs, TOutput>, args: TArgs): Effect.Effect<TOutput, ConvexCallError>;
|
|
291
|
-
mutation<TArgs extends Record<string, unknown>, TOutput>(fn: FunctionReference<"mutation", "public", TArgs, TOutput>, args: TArgs): Effect.Effect<TOutput, ConvexCallError>;
|
|
292
|
-
action<TArgs extends Record<string, unknown>, TOutput>(fn: FunctionReference<"action", "public", TArgs, TOutput>, args: TArgs): Effect.Effect<TOutput, ConvexCallError>;
|
|
293
|
-
/**
|
|
294
|
-
* Substrate-level reactive transport over Convex's `onUpdate`.
|
|
295
|
-
*
|
|
296
|
-
* @internal-use — substrate only; see `ports/subscription.ts`. Domain
|
|
297
|
-
* ports do not expose reactive callback methods to consumers (ARCH-LOCK-1).
|
|
298
|
-
*/
|
|
299
|
-
subscribe<TArgs extends Record<string, unknown>, TOutput>(fn: FunctionReference<"query", "public", TArgs, TOutput>, args: TArgs, callback: (snapshot: Snapshot<TOutput>) => void): Effect.Effect<Unsubscribe, ConvexCallError>;
|
|
300
|
-
}
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/ports/credentials.d.ts
|
|
303
|
-
type CreateApplicationInput = {
|
|
304
|
-
readonly authUserId: AuthUserId;
|
|
305
|
-
readonly name: string;
|
|
306
|
-
readonly allowedOrigins: readonly AllowedOrigin[];
|
|
307
|
-
};
|
|
308
|
-
type MintKeyInput = {
|
|
309
|
-
readonly applicationId: AppId;
|
|
310
|
-
readonly authUserId: AuthUserId;
|
|
311
|
-
};
|
|
312
|
-
type RotateKeyInput = {
|
|
313
|
-
readonly keyId: PublishableKeyId;
|
|
314
|
-
readonly authUserId: AuthUserId;
|
|
315
|
-
readonly graceMs: DurationMs;
|
|
316
|
-
};
|
|
317
|
-
type RevokeKeyInput = {
|
|
318
|
-
readonly keyId: PublishableKeyId;
|
|
319
|
-
readonly authUserId: AuthUserId;
|
|
320
|
-
};
|
|
321
|
-
type RotateKeyResult = {
|
|
322
|
-
readonly active: PublishableKeyRecord;
|
|
323
|
-
readonly retired: PublishableKeyRecord;
|
|
324
|
-
};
|
|
325
|
-
declare const CredentialsError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
326
|
-
readonly _tag: "CredentialsError";
|
|
327
|
-
} & Readonly<A>;
|
|
328
|
-
declare class CredentialsError extends CredentialsError_base<{
|
|
329
|
-
readonly operation: string;
|
|
330
|
-
readonly publicCode: CapxulErrorCode;
|
|
331
|
-
readonly publicError: CapxulError;
|
|
332
|
-
readonly cause: unknown;
|
|
333
|
-
readonly details?: CapxulErrorDetails;
|
|
334
|
-
}> {}
|
|
335
|
-
interface CredentialsPort {
|
|
336
|
-
listApplications(authUserId: AuthUserId): Effect.Effect<readonly DeveloperApplication[], CredentialsError>;
|
|
337
|
-
createApplication(input: CreateApplicationInput): Effect.Effect<DeveloperApplication, CredentialsError>;
|
|
338
|
-
mintPublishableKey(input: MintKeyInput): Effect.Effect<PublishableKeyRecord, CredentialsError>;
|
|
339
|
-
rotatePublishableKey(input: RotateKeyInput): Effect.Effect<RotateKeyResult, CredentialsError>;
|
|
340
|
-
revokePublishableKey(input: RevokeKeyInput): Effect.Effect<void, CredentialsError>;
|
|
341
|
-
}
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region src/ports/identity.d.ts
|
|
344
|
-
type CreateIdentityInput = {
|
|
345
|
-
readonly authUserId: AuthUserId;
|
|
346
|
-
readonly email: Email;
|
|
347
|
-
readonly displayName?: string;
|
|
348
|
-
readonly country?: CountryCode;
|
|
349
|
-
};
|
|
350
|
-
type UpdateIdentityInput = {
|
|
351
|
-
readonly authUserId: AuthUserId;
|
|
352
|
-
readonly displayName?: string;
|
|
353
|
-
readonly country?: CountryCode;
|
|
354
|
-
};
|
|
355
|
-
/**
|
|
356
|
-
* D-ONBOARD (#669) — the onboarding-complete identity write. Composes the
|
|
357
|
-
* existing create/update write into one idempotent upsert that ALSO sets the
|
|
358
|
-
* `onboarded` flag and persists the optional `withdrawalAddress` (the one
|
|
359
|
-
* allowed raw-0x class). `displayName` + `country` are required at onboarding
|
|
360
|
-
* time. The returned `Profile` is the existing branded shape — the onboarding
|
|
361
|
-
* flags live on the wire row and are not projected onto the read surface.
|
|
362
|
-
*/
|
|
363
|
-
type CompleteOnboardingIdentityInput = {
|
|
364
|
-
readonly authUserId: AuthUserId;
|
|
365
|
-
readonly email: Email;
|
|
366
|
-
readonly displayName: string;
|
|
367
|
-
readonly country: CountryCode;
|
|
368
|
-
readonly withdrawalAddress?: Address;
|
|
369
|
-
};
|
|
370
|
-
declare const IdentityError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
371
|
-
readonly _tag: "IdentityError";
|
|
372
|
-
} & Readonly<A>;
|
|
373
|
-
declare class IdentityError extends IdentityError_base<{
|
|
374
|
-
readonly operation: string;
|
|
375
|
-
readonly publicCode: CapxulErrorCode;
|
|
376
|
-
readonly publicError: CapxulError;
|
|
377
|
-
readonly cause: unknown;
|
|
378
|
-
readonly details?: CapxulErrorDetails;
|
|
379
|
-
}> {}
|
|
380
|
-
interface IdentityPort {
|
|
381
|
-
loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<Profile$1 | null, IdentityError, never>;
|
|
382
|
-
create(input: CreateIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
|
|
383
|
-
update(input: UpdateIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
|
|
384
|
-
/** D-ONBOARD (#669): idempotent upsert that marks the identity onboarded. */
|
|
385
|
-
completeOnboarding(input: CompleteOnboardingIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
|
|
386
|
-
}
|
|
387
|
-
//#endregion
|
|
388
|
-
//#region src/ports/smart-account.d.ts
|
|
389
|
-
type ProvisionInput = {
|
|
390
|
-
readonly authUserId: AuthUserId;
|
|
391
|
-
readonly chainId: ChainId;
|
|
392
|
-
};
|
|
393
|
-
/**
|
|
394
|
-
* Input to `SmartAccountPort.confirmDeployment` (#161 · γ-B).
|
|
395
|
-
*
|
|
396
|
-
* The SDK provides evidence pointers; the backend is the oracle for
|
|
397
|
-
* `deployedAt`. `evidence.deployedAt` does NOT exist by schema (see
|
|
398
|
-
* `SafeDeploymentEvidence`) — the backend derives `deployedAt` from
|
|
399
|
-
* the on-chain receipt block via `eth_getBlockByNumber`.
|
|
400
|
-
*
|
|
401
|
-
* Precheck path: `evidence.userOpHash` omitted; backend scans
|
|
402
|
-
* `SafeProxyFactory.ProxyCreation(safeAddress, _)` via `eth_getLogs`.
|
|
403
|
-
*
|
|
404
|
-
* Real-userOp path: `evidence.userOpHash` populated; backend calls
|
|
405
|
-
* `eth_getUserOperationReceipt(userOpHash)` to re-verify and derive.
|
|
406
|
-
*/
|
|
407
|
-
type ConfirmDeploymentInput = {
|
|
408
|
-
readonly authUserId: AuthUserId;
|
|
409
|
-
readonly chainId: ChainId;
|
|
410
|
-
readonly safeAddress: Address;
|
|
411
|
-
readonly evidence: SafeDeploymentEvidence;
|
|
412
|
-
/**
|
|
413
|
-
* Optional live-E2E correlation id. This does not prove deployment; the
|
|
414
|
-
* backend still re-verifies chain evidence and only mirrors this branded
|
|
415
|
-
* id onto telemetry for PostHog run joins.
|
|
416
|
-
*/
|
|
417
|
-
readonly telemetryRunId?: RunId;
|
|
418
|
-
};
|
|
419
|
-
/**
|
|
420
|
-
* Input to `SmartAccountPort.claim` (PRD #462). The authenticated session
|
|
421
|
-
* reports the browser-created signer address; the BACKEND builds and
|
|
422
|
-
* bootstrap-signs the claim userOp (deploy + swapOwner) — the consumer signs
|
|
423
|
-
* nothing at claim.
|
|
424
|
-
*/
|
|
425
|
-
type ClaimInput = {
|
|
426
|
-
readonly authUserId: AuthUserId;
|
|
427
|
-
readonly chainId: ChainId;
|
|
428
|
-
readonly signerAddress: Address;
|
|
429
|
-
readonly telemetryRunId?: RunId;
|
|
430
|
-
};
|
|
431
|
-
declare const SmartAccountError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
432
|
-
readonly _tag: "SmartAccountError";
|
|
433
|
-
} & Readonly<A>;
|
|
434
|
-
declare class SmartAccountError extends SmartAccountError_base<{
|
|
435
|
-
readonly operation: string;
|
|
436
|
-
readonly publicCode: CapxulErrorCode;
|
|
437
|
-
readonly publicError: CapxulError;
|
|
438
|
-
readonly cause: unknown;
|
|
439
|
-
readonly details?: CapxulErrorDetails;
|
|
440
|
-
}> {}
|
|
441
|
-
interface SmartAccountPort {
|
|
442
|
-
loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
|
|
443
|
-
loadBySmartAccountAddress(address: Address): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
|
|
444
|
-
provision(input: ProvisionInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
|
|
445
|
-
/**
|
|
446
|
-
* Persist on-chain Safe-deployment evidence. The backend re-verifies
|
|
447
|
-
* the evidence against chain state and derives `deployedAt` from the
|
|
448
|
-
* receipt block's timestamp. Returns the updated `SmartAccount` row.
|
|
449
|
-
*
|
|
450
|
-
* γ-B trust model: the SDK supplies evidence pointers only. The
|
|
451
|
-
* backend is the SOLE oracle for `deployedAt` — see
|
|
452
|
-
* `docs/canon/ports/smart-account.md`.
|
|
453
|
-
*/
|
|
454
|
-
confirmDeployment(input: ConfirmDeploymentInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
|
|
455
|
-
/**
|
|
456
|
-
* Claim the account (PRD #462): the backend builds, bootstrap-signs, and
|
|
457
|
-
* submits ONE sponsored userOp — deploy (when undeployed) + swapOwner
|
|
458
|
-
* (bootstrap → `signerAddress`). Idempotent; returns the updated row. When
|
|
459
|
-
* another claim is in flight the row comes back with `claimedAt: null` —
|
|
460
|
-
* callers poll lifecycle until the claim lands.
|
|
461
|
-
*/
|
|
462
|
-
claim(input: ClaimInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
|
|
463
|
-
}
|
|
464
|
-
//#endregion
|
|
465
|
-
//#region src/ports/account-read.d.ts
|
|
466
|
-
type ReadAccountBalanceInput = {
|
|
467
|
-
readonly chainId: ChainId;
|
|
468
|
-
};
|
|
469
|
-
type FundFromFaucetInput = {
|
|
470
|
-
readonly chainId: ChainId;
|
|
471
|
-
readonly amount: Money;
|
|
472
|
-
};
|
|
473
|
-
type FundFromFaucetResult = {
|
|
474
|
-
readonly txHash: string;
|
|
475
|
-
};
|
|
476
|
-
declare const AccountReadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
477
|
-
readonly _tag: "AccountReadError";
|
|
478
|
-
} & Readonly<A>;
|
|
479
|
-
declare class AccountReadError extends AccountReadError_base<{
|
|
480
|
-
readonly operation: string;
|
|
481
|
-
readonly publicCode: CapxulErrorCode;
|
|
482
|
-
readonly publicError: CapxulError;
|
|
483
|
-
readonly cause: unknown;
|
|
484
|
-
readonly details?: CapxulErrorDetails;
|
|
485
|
-
}> {}
|
|
486
|
-
/**
|
|
487
|
-
* Logical Account money read (M2 Slice S1a). Joins the `accounts` row with a
|
|
488
|
-
* live RPC `balanceOf` pull; the adapter lifts wire integers to `Money`.
|
|
489
|
-
*/
|
|
490
|
-
interface AccountReadPort {
|
|
491
|
-
readBalance(input: ReadAccountBalanceInput): Effect.Effect<Account, AccountReadError, never>;
|
|
492
|
-
fundFromFaucet(input: FundFromFaucetInput): Effect.Effect<FundFromFaucetResult, AccountReadError, never>;
|
|
493
|
-
}
|
|
494
|
-
//#endregion
|
|
495
|
-
//#region src/ports/sub-account.d.ts
|
|
496
|
-
declare const SubAccountError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
497
|
-
readonly _tag: "SubAccountError";
|
|
498
|
-
} & Readonly<A>;
|
|
499
|
-
declare class SubAccountError extends SubAccountError_base<{
|
|
500
|
-
readonly operation: string;
|
|
501
|
-
readonly publicCode: CapxulErrorCode;
|
|
502
|
-
readonly publicError: CapxulError;
|
|
503
|
-
readonly cause: unknown;
|
|
504
|
-
readonly details?: CapxulErrorDetails;
|
|
505
|
-
}> {}
|
|
506
|
-
type CreateSubAccountInput = {
|
|
507
|
-
readonly accountId: AccountId;
|
|
508
|
-
readonly name: string;
|
|
509
|
-
};
|
|
510
|
-
type SubAccountIdInput = {
|
|
511
|
-
readonly subAccountId: SubAccountId;
|
|
512
|
-
};
|
|
513
|
-
type RenameSubAccountInput = {
|
|
514
|
-
readonly subAccountId: SubAccountId;
|
|
515
|
-
readonly name: string;
|
|
516
|
-
};
|
|
517
|
-
/**
|
|
518
|
-
* A `transfer` endpoint is either the Account's MAIN balance (the remainder
|
|
519
|
-
* left over after every sub-account is funded — never a stored row) or a
|
|
520
|
-
* specific sub-account, addressed by its `SubAccountId` (canon
|
|
521
|
-
* `account-balance-model.md` §5, §12).
|
|
522
|
-
*/
|
|
523
|
-
type TransferEndpoint = "main" | SubAccountId;
|
|
524
|
-
/**
|
|
525
|
-
* Move money between two of the SAME Account's balances (canon §12). The
|
|
526
|
-
* backend resolves the Account from auth (v1 = one Account per user), so the
|
|
527
|
-
* input carries no `accountId` — only the from/to endpoints and the `Money`
|
|
528
|
-
* amount. One verb covers money in (`main → sub`), money out (`sub → main`),
|
|
529
|
-
* and `sub → sub`.
|
|
530
|
-
*/
|
|
531
|
-
type TransferInput = {
|
|
532
|
-
readonly from: TransferEndpoint;
|
|
533
|
-
readonly to: TransferEndpoint;
|
|
534
|
-
readonly amount: Money;
|
|
535
|
-
};
|
|
536
|
-
/**
|
|
537
|
-
* Result of a `transfer`: the recomputed `available` (`balanceOf − Σ`), plus
|
|
538
|
-
* the updated source/destination sub-account rows. An endpoint that is `"main"`
|
|
539
|
-
* has no stored row, so its slot is `null`.
|
|
540
|
-
*/
|
|
541
|
-
type TransferResult = {
|
|
542
|
-
readonly available: Money;
|
|
543
|
-
readonly from: SubAccount | null;
|
|
544
|
-
readonly to: SubAccount | null;
|
|
545
|
-
};
|
|
546
|
-
interface SubAccountPort {
|
|
547
|
-
create(input: CreateSubAccountInput): Effect.Effect<SubAccount, SubAccountError, never>;
|
|
548
|
-
get(input: SubAccountIdInput): Effect.Effect<SubAccount | null, SubAccountError, never>;
|
|
549
|
-
list(input: {
|
|
550
|
-
readonly accountId: AccountId;
|
|
551
|
-
}): Effect.Effect<readonly SubAccount[], SubAccountError, never>;
|
|
552
|
-
rename(input: RenameSubAccountInput): Effect.Effect<SubAccount, SubAccountError, never>;
|
|
553
|
-
delete(input: SubAccountIdInput): Effect.Effect<void, SubAccountError, never>;
|
|
554
|
-
transfer(input: TransferInput): Effect.Effect<TransferResult, SubAccountError, never>;
|
|
555
|
-
}
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region src/flows/types.d.ts
|
|
558
|
-
/**
|
|
559
|
-
* The full 13-port bundle that `assembleCapxulClient` (slice 5) consumes.
|
|
560
|
-
* (Was 15 before the dead local-signer port was retired; the deploy path
|
|
561
|
-
* now signs exclusively through `CapxulSigner`.)
|
|
562
|
-
*
|
|
563
|
-
* Each per-flow factory in slices 2-4 takes a narrowed subset, e.g.
|
|
564
|
-
* `AuthFlowPorts = Pick<FlowPorts, "authClient" | "clock" | "telemetry">`.
|
|
565
|
-
* Slice 1 ships only the union; per Q6 each per-flow slice declares its
|
|
566
|
-
* own narrowed `Pick<FlowPorts, ...>` inside its flow file.
|
|
567
|
-
*/
|
|
568
|
-
interface FlowPorts {
|
|
569
|
-
readonly authClient: AuthClientPort;
|
|
570
|
-
readonly authCache: AuthCachePort;
|
|
571
|
-
readonly identity: IdentityPort;
|
|
572
|
-
readonly smartAccount: SmartAccountPort;
|
|
573
|
-
readonly accountRead: AccountReadPort;
|
|
574
|
-
readonly subAccount: SubAccountPort;
|
|
575
|
-
readonly credentials: CredentialsPort;
|
|
576
|
-
readonly bootstrap: BootstrapPort;
|
|
577
|
-
readonly clock: ClockPort;
|
|
578
|
-
readonly env: EnvPort;
|
|
579
|
-
readonly telemetry: TelemetryPort;
|
|
580
|
-
readonly transport: TransportPort;
|
|
581
|
-
readonly convexCall: ConvexCallPort;
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Pre-resolved external signer + signed proof. The UI obtains this
|
|
585
|
-
* BEFORE prompting the user to verify (MetaMask popup, hardware-wallet
|
|
586
|
-
* confirm, etc.), then the consumer sends it to AuthFlow via the
|
|
587
|
-
* `SET_SIGNER` event between `idle` and `verifying`. AuthFlow assigns
|
|
588
|
-
* to `context.externalSigner` on the SET_SIGNER self-loop in either
|
|
589
|
-
* `idle` or `otp_requested`, then flows the value through to the
|
|
590
|
-
* invoked ProvisioningFlow child via `invoke.input.externalSigner`.
|
|
591
|
-
* The child's `branching` state inspects `context.signerAddress`
|
|
592
|
-
* (derived from `input.externalSigner?.address`) to route through
|
|
593
|
-
* `register_external` instead of `mint_openfort` when present.
|
|
594
|
-
*
|
|
595
|
-
* The signer's lifetime is the authenticated session — `clearAuthContext`
|
|
596
|
-
* (on SIGN_OUT → idle) and `clearErrorAndContext` (on error → RESET →
|
|
597
|
-
* idle) both wipe `context.externalSigner`. A subsequent sign-in cycle
|
|
598
|
-
* begins fresh; the consumer re-sends SET_SIGNER (or omits it for the
|
|
599
|
-
* Openfort fallback path). Reference:
|
|
600
|
-
* `docs/decisions/stage-3-external-signer-lifecycle.html` (Option C,
|
|
601
|
-
* locked 2026-05-17, supersedes the earlier factory-input shape).
|
|
602
|
-
*
|
|
603
|
-
* `signedProof` is an EIP-191 signed message proving the user controls
|
|
604
|
-
* the address. ProvisioningFlow does not verify the proof itself —
|
|
605
|
-
* verification is delegated to the indexer registration in Stage 4 when
|
|
606
|
-
* `IndexerPort.registerSafe` lands. For Stage 3 the field is recorded
|
|
607
|
-
* verbatim for trace fidelity.
|
|
608
|
-
*
|
|
609
|
-
* The type lives in this flows/types module (not in `@capxul/types`)
|
|
610
|
-
* because it is a flow-shape composite — `Address` + a freeform proof
|
|
611
|
-
* string — not a primitive brand. Per the Stage 3 plan's vocabulary
|
|
612
|
-
* convention, flow-shape composites stay co-located with their flow.
|
|
613
|
-
*/
|
|
614
|
-
interface ExternalSigner {
|
|
615
|
-
readonly address: Address;
|
|
616
|
-
readonly signedProof: string;
|
|
617
|
-
}
|
|
618
|
-
//#endregion
|
|
619
|
-
//#region src/client/auth.d.ts
|
|
620
|
-
interface SignInOptions {
|
|
621
|
-
readonly signal?: AbortSignal;
|
|
622
|
-
}
|
|
623
|
-
type AuthMethodOptions = SignInOptions;
|
|
624
|
-
interface AuthMethods {
|
|
625
|
-
canSendOtp(input: {
|
|
626
|
-
readonly email: string;
|
|
627
|
-
}, options?: AuthMethodOptions): Promise<CapxulResult<CanSendOtpStatus>>;
|
|
628
|
-
signIn(input: {
|
|
629
|
-
readonly email: string;
|
|
630
|
-
}, options?: SignInOptions): Promise<CapxulResult<{
|
|
631
|
-
readonly sessionId: string;
|
|
632
|
-
readonly expiresAt: number;
|
|
633
|
-
}>>;
|
|
634
|
-
verifyOtp(input: {
|
|
635
|
-
readonly email: string;
|
|
636
|
-
readonly code: string;
|
|
637
|
-
readonly signer?: ExternalSigner;
|
|
638
|
-
}, options?: AuthMethodOptions): Promise<CapxulResult<Session>>;
|
|
639
|
-
signOut(options?: AuthMethodOptions): Promise<CapxulResult<void>>;
|
|
640
|
-
getSession(options?: AuthMethodOptions): Promise<CapxulResult<Session | null>>;
|
|
641
|
-
}
|
|
642
|
-
//#endregion
|
|
643
|
-
//#region src/client/smart-account.d.ts
|
|
644
|
-
interface SmartAccountMethods {
|
|
645
|
-
loadCurrent(options?: {
|
|
646
|
-
readonly signal?: AbortSignal;
|
|
647
|
-
}): Promise<CapxulResult<SmartAccount | null>>;
|
|
648
|
-
provision(input?: {
|
|
649
|
-
readonly externalSigner?: ExternalSigner;
|
|
650
|
-
}): Promise<CapxulResult<SmartAccount>>;
|
|
651
|
-
}
|
|
652
|
-
//#endregion
|
|
653
|
-
//#region src/client/identity.d.ts
|
|
654
|
-
interface IdentityMethods {
|
|
655
|
-
loadCurrent(options?: {
|
|
656
|
-
readonly signal?: AbortSignal;
|
|
657
|
-
}): Promise<CapxulResult<Profile | null>>;
|
|
658
|
-
}
|
|
659
|
-
//#endregion
|
|
660
|
-
//#region src/client/account-lane.d.ts
|
|
661
|
-
type ProvisioningFailureStep = "wallet" | "identity" | "provision" | "deploy";
|
|
662
|
-
type ProvisioningPhase = {
|
|
663
|
-
readonly status: "idle";
|
|
664
|
-
} | {
|
|
665
|
-
readonly status: "wallet";
|
|
666
|
-
} | {
|
|
667
|
-
readonly status: "identity";
|
|
668
|
-
} | {
|
|
669
|
-
readonly status: "provision";
|
|
670
|
-
} | {
|
|
671
|
-
readonly status: "deploy";
|
|
672
|
-
} | {
|
|
673
|
-
readonly status: "ready";
|
|
674
|
-
} | {
|
|
675
|
-
readonly status: "failed";
|
|
676
|
-
readonly at: ProvisioningFailureStep;
|
|
677
|
-
readonly error: CapxulError;
|
|
678
|
-
};
|
|
679
|
-
//#endregion
|
|
680
|
-
//#region src/client/account-lifecycle.d.ts
|
|
681
|
-
type AccountSetupStep = "connecting" | "confirmingIdentity" | "registering" | "activating";
|
|
682
|
-
type AccountLifecycle = {
|
|
683
|
-
readonly status: "loading";
|
|
684
|
-
} | {
|
|
685
|
-
readonly status: "settingUp";
|
|
686
|
-
readonly step: AccountSetupStep;
|
|
687
|
-
} | {
|
|
688
|
-
readonly status: "ready";
|
|
689
|
-
readonly accountId: string;
|
|
690
|
-
readonly canTransact: boolean;
|
|
691
|
-
} | {
|
|
692
|
-
readonly status: "failed";
|
|
693
|
-
readonly at: AccountSetupStep;
|
|
694
|
-
readonly error: CapxulError;
|
|
695
|
-
};
|
|
696
|
-
declare function isSettingUpLifecycle(lifecycle: AccountLifecycle): boolean;
|
|
697
|
-
//#endregion
|
|
698
|
-
//#region src/client/account.d.ts
|
|
699
|
-
type AccountStatus = {
|
|
700
|
-
readonly status: "notAuthenticated";
|
|
701
|
-
} | {
|
|
702
|
-
readonly status: "accountRequired";
|
|
703
|
-
readonly requirement: AccountRequirement;
|
|
704
|
-
readonly chainId: number;
|
|
705
|
-
} | {
|
|
706
|
-
readonly status: "accountProviderReady";
|
|
707
|
-
readonly requirement: AccountRequirement;
|
|
708
|
-
readonly chainId: number;
|
|
709
|
-
readonly source: AccountProviderSource;
|
|
710
|
-
readonly signerAddress: Address;
|
|
711
|
-
} | {
|
|
712
|
-
readonly status: "accountPrepared";
|
|
713
|
-
readonly requirement: AccountRequirement;
|
|
714
|
-
readonly account: SmartAccount$1;
|
|
715
|
-
readonly deployment: {
|
|
716
|
-
readonly status: "counterfactual";
|
|
717
|
-
};
|
|
718
|
-
} | {
|
|
719
|
-
readonly status: "accountReady";
|
|
720
|
-
readonly requirement: AccountRequirement;
|
|
721
|
-
readonly account: SmartAccount$1 | null;
|
|
722
|
-
readonly deployment: {
|
|
723
|
-
readonly status: "counterfactual";
|
|
724
|
-
} | {
|
|
725
|
-
readonly status: "deployed";
|
|
726
|
-
readonly deployedAt: SmartAccount$1["deployedAt"];
|
|
727
|
-
};
|
|
728
|
-
};
|
|
729
|
-
/**
|
|
730
|
-
* Public consumer-facing surface (issue #159 · AC1+AC3). Exactly two
|
|
731
|
-
* methods. `provision` and `deploySafe` are intentionally NOT here —
|
|
732
|
-
* they are advanced/testing-only and will live on
|
|
733
|
-
* `client._internal.account` when sibling issue #161 lands. Per
|
|
734
|
-
* `docs/canon/rules/public-surface.md`, the narrowing is enforced at
|
|
735
|
-
* both the type level (the `keyof AccountMethods` extract is exactly
|
|
736
|
-
* `"getStatus" | "ensureReady"`) and at runtime (the bundle returned
|
|
737
|
-
* here has those two own-keys and nothing else).
|
|
738
|
-
*
|
|
739
|
-
* Per `docs/canon/conventions/flow-internal-substrate.md`, the
|
|
740
|
-
* `AccountStatus` discriminant — including the variants this slice can
|
|
741
|
-
* only reach via `getStatus` (e.g. `accountPrepared`) — is the durable
|
|
742
|
-
* shape consumers depend on. Sibling #161 will extend `ensureReady` to
|
|
743
|
-
* advance the ladder past `accountProviderReady` and from
|
|
744
|
-
* `accountPrepared` to `accountReady(deployed)`; until then, the type
|
|
745
|
-
* surface is stable and the runtime fixed-point is documented.
|
|
746
|
-
*/
|
|
747
|
-
interface AccountMethods {
|
|
748
|
-
/**
|
|
749
|
-
* Post-auth account setup lifecycle — domain vocabulary over the internal
|
|
750
|
-
* readiness ladder + provisioning lane (#356).
|
|
751
|
-
*/
|
|
752
|
-
getLifecycle(): Promise<CapxulResult<AccountLifecycle>>;
|
|
753
|
-
/** Resume setup after `failed` and return the updated lifecycle snapshot. */
|
|
754
|
-
retrySetup(): Promise<CapxulResult<AccountLifecycle>>;
|
|
755
|
-
/**
|
|
756
|
-
* Internal advanced surface (#161 · AC1). Reserved for the rebuild's
|
|
757
|
-
* own `ensureReady` upward transitions and for testing harnesses;
|
|
758
|
-
* consumers MUST NOT depend on this in production. Tagged
|
|
759
|
-
* `@internal-use` per `.claude/rules/flow-internal-substrate.md`.
|
|
760
|
-
*
|
|
761
|
-
* @internal-use
|
|
762
|
-
*/
|
|
763
|
-
readonly _internal: AccountInternalSurface;
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* Internal `provision` + `deploySafe` arms exposed at
|
|
767
|
-
* `client._internal.account` (#161). Each returns `Promise<CapxulResult<T>>`
|
|
768
|
-
* with the same error catalog the public methods use.
|
|
769
|
-
*
|
|
770
|
-
* @internal-use
|
|
771
|
-
*/
|
|
772
|
-
interface AccountInternalSurface {
|
|
773
|
-
provision(): Promise<CapxulResult<SmartAccount$1>>;
|
|
774
|
-
deploySafe(): Promise<CapxulResult<SmartAccount$1>>;
|
|
775
|
-
/** @internal-use Substrate readiness ladder — tests and e2e only. */
|
|
776
|
-
getStatus(): Promise<CapxulResult<AccountStatus>>;
|
|
777
|
-
/** @internal-use Lane runner — tests and e2e only. */
|
|
778
|
-
ensureReady(): Promise<CapxulResult<AccountStatus>>;
|
|
779
|
-
/** @internal-use Provisioning lane phase — tests and e2e only. */
|
|
780
|
-
getProvisioningPhase(): Promise<CapxulResult<ProvisioningPhase>>;
|
|
781
|
-
/** @internal-use Lane retry — tests and e2e only. */
|
|
782
|
-
retryProvisioning(): Promise<CapxulResult<ProvisioningPhase>>;
|
|
783
|
-
}
|
|
784
|
-
//#endregion
|
|
785
|
-
//#region src/client/accounts.d.ts
|
|
786
|
-
interface AccountsMethods {
|
|
787
|
-
read(options?: {
|
|
788
|
-
readonly signal?: AbortSignal;
|
|
789
|
-
}): Promise<CapxulResult<Account>>;
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Faucet surface (dev-only). Deliberately OFF the public `AccountsMethods`;
|
|
793
|
-
* reachable only via `client._internal.accounts` (production-surface-policy.md).
|
|
794
|
-
* The reference CLI uses it behind a test-env gate — consumers never see `fund`.
|
|
795
|
-
*/
|
|
796
|
-
interface AccountsFaucetMethods {
|
|
797
|
-
fund(amount: Money, options?: {
|
|
798
|
-
readonly signal?: AbortSignal;
|
|
799
|
-
}): Promise<CapxulResult<{
|
|
800
|
-
readonly txHash: string;
|
|
801
|
-
}>>;
|
|
802
|
-
}
|
|
803
|
-
//#endregion
|
|
804
|
-
//#region ../wire/src/financial-ops.d.ts
|
|
805
|
-
declare const PaymentDocumentEnvelope: Schema.Union<[Schema.Struct<{
|
|
806
|
-
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
807
|
-
version: Schema.Literal<[1]>;
|
|
808
|
-
domain: Schema.Struct<{
|
|
809
|
-
name: Schema.Literal<["CapxulPayments"]>;
|
|
810
|
-
version: Schema.Literal<["1"]>;
|
|
811
|
-
chainId: Schema.Schema<ChainId, number, never>;
|
|
812
|
-
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
813
|
-
}>;
|
|
814
|
-
primaryType: Schema.Literal<["Memo"]>;
|
|
815
|
-
message: Schema.Struct<{
|
|
816
|
-
kind: Schema.Literal<[0]>;
|
|
817
|
-
reference: typeof Schema.String;
|
|
818
|
-
note: typeof Schema.String;
|
|
819
|
-
issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
820
|
-
}>;
|
|
821
|
-
}>, Schema.Struct<{
|
|
822
|
-
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
823
|
-
version: Schema.Literal<[1]>;
|
|
824
|
-
domain: Schema.Struct<{
|
|
825
|
-
name: Schema.Literal<["CapxulPayments"]>;
|
|
826
|
-
version: Schema.Literal<["1"]>;
|
|
827
|
-
chainId: Schema.Schema<ChainId, number, never>;
|
|
828
|
-
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
829
|
-
}>;
|
|
830
|
-
primaryType: Schema.Literal<["Invoice"]>;
|
|
831
|
-
message: Schema.Struct<{
|
|
832
|
-
kind: Schema.Literal<[1]>;
|
|
833
|
-
invoiceNumber: typeof Schema.String;
|
|
834
|
-
payerRef: typeof Schema.String;
|
|
835
|
-
payeeRef: typeof Schema.String;
|
|
836
|
-
amount: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
837
|
-
currency: Schema.Schema<CurrencyCode, string, never>;
|
|
838
|
-
decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
839
|
-
issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
840
|
-
dueAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
841
|
-
lineItemsHash: Schema.Schema<DocumentHash, string, never>;
|
|
842
|
-
}>;
|
|
843
|
-
}>, Schema.Struct<{
|
|
844
|
-
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
845
|
-
version: Schema.Literal<[1]>;
|
|
846
|
-
domain: Schema.Struct<{
|
|
847
|
-
name: Schema.Literal<["CapxulPayments"]>;
|
|
848
|
-
version: Schema.Literal<["1"]>;
|
|
849
|
-
chainId: Schema.Schema<ChainId, number, never>;
|
|
850
|
-
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
851
|
-
}>;
|
|
852
|
-
primaryType: Schema.Literal<["Payslip"]>;
|
|
853
|
-
message: Schema.Struct<{
|
|
854
|
-
kind: Schema.Literal<[2]>;
|
|
855
|
-
employerRef: typeof Schema.String;
|
|
856
|
-
employeeRef: typeof Schema.String;
|
|
857
|
-
period: typeof Schema.String;
|
|
858
|
-
gross: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
859
|
-
net: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
860
|
-
currency: Schema.Schema<CurrencyCode, string, never>;
|
|
861
|
-
decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
862
|
-
issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
863
|
-
}>;
|
|
864
|
-
}>, Schema.Struct<{
|
|
865
|
-
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
866
|
-
version: Schema.Literal<[1]>;
|
|
867
|
-
domain: Schema.Struct<{
|
|
868
|
-
name: Schema.Literal<["CapxulPayments"]>;
|
|
869
|
-
version: Schema.Literal<["1"]>;
|
|
870
|
-
chainId: Schema.Schema<ChainId, number, never>;
|
|
871
|
-
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
872
|
-
}>;
|
|
873
|
-
primaryType: Schema.Literal<["Receipt"]>;
|
|
874
|
-
message: Schema.Struct<{
|
|
875
|
-
kind: Schema.Literal<[3]>;
|
|
876
|
-
reference: typeof Schema.String;
|
|
877
|
-
amount: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
878
|
-
currency: Schema.Schema<CurrencyCode, string, never>;
|
|
879
|
-
decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
880
|
-
paidAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
881
|
-
note: typeof Schema.String;
|
|
882
|
-
}>;
|
|
883
|
-
}>, Schema.Struct<{
|
|
884
|
-
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
885
|
-
version: Schema.Literal<[1]>;
|
|
886
|
-
domain: Schema.Struct<{
|
|
887
|
-
name: Schema.Literal<["CapxulPayments"]>;
|
|
888
|
-
version: Schema.Literal<["1"]>;
|
|
889
|
-
chainId: Schema.Schema<ChainId, number, never>;
|
|
890
|
-
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
891
|
-
}>;
|
|
892
|
-
primaryType: Schema.Literal<["Withdrawal"]>;
|
|
893
|
-
message: Schema.Struct<{
|
|
894
|
-
kind: Schema.Literal<[4]>;
|
|
895
|
-
reference: typeof Schema.String;
|
|
896
|
-
amount: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
897
|
-
currency: Schema.Schema<CurrencyCode, string, never>;
|
|
898
|
-
decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
899
|
-
destChain: Schema.Schema<ChainId, number, never>;
|
|
900
|
-
destAddress: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
901
|
-
settledAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
902
|
-
provider: typeof Schema.String;
|
|
903
|
-
note: typeof Schema.String;
|
|
904
|
-
}>;
|
|
905
|
-
}>]>;
|
|
906
|
-
/**
|
|
907
|
-
* #592 invoice line item. `quantity` is a positive integer; `unitMinor` is the
|
|
908
|
-
* per-unit price in integer minor units. The list is canonically hashed by
|
|
909
|
-
* `hashLineItems` (payment-document-hash.ts) into the Invoice `lineItemsHash`,
|
|
910
|
-
* and Σ(quantity × unitMinor) MUST equal the invoice `amount`. The hash binds
|
|
911
|
-
* the documentHash to the exact items; the sum-check makes the items add up to
|
|
912
|
-
* the amount due. See the payment-document spec (canon/mcp/financial-ops.md).
|
|
913
|
-
*/
|
|
914
|
-
declare const LineItem: Schema.Struct<{
|
|
915
|
-
description: typeof Schema.String;
|
|
916
|
-
quantity: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
917
|
-
unitMinor: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
918
|
-
}>;
|
|
919
|
-
type PaymentDocumentEnvelopeV1 = Schema.Schema.Type<typeof PaymentDocumentEnvelope>;
|
|
920
|
-
type LineItemV1 = Schema.Schema.Type<typeof LineItem>;
|
|
921
|
-
//#endregion
|
|
922
|
-
//#region ../wire/src/leak-safety.d.ts
|
|
923
|
-
declare const OnchainEvidenceBrand: unique symbol;
|
|
924
|
-
/**
|
|
925
|
-
* The branded `{ userOpHash, txHash }` pair. On-chain settlement evidence is
|
|
926
|
-
* INTERNAL — it flows on the server-internal channel only, never onto a wire
|
|
927
|
-
* Payment or any MCP tool output. The brand makes "this is internal evidence"
|
|
928
|
-
* a type, so a loose pair can't be passed where a wire field is expected.
|
|
929
|
-
*/
|
|
930
|
-
type OnchainEvidence = {
|
|
931
|
-
readonly userOpHash: string;
|
|
932
|
-
readonly txHash: string;
|
|
933
|
-
} & {
|
|
934
|
-
readonly [OnchainEvidenceBrand]: "OnchainEvidence";
|
|
935
|
-
};
|
|
936
|
-
//#endregion
|
|
937
|
-
//#region src/client/financial-ops.d.ts
|
|
938
|
-
type RecipientResolutionKind = "email" | "org" | "payee";
|
|
939
|
-
interface MeProfile {
|
|
940
|
-
readonly authUserId: string;
|
|
941
|
-
readonly email: string;
|
|
942
|
-
readonly displayName: string | null;
|
|
943
|
-
readonly personalSafeAddress: string;
|
|
944
|
-
}
|
|
945
|
-
interface DepositInstructions {
|
|
946
|
-
readonly accountKind: "personalSafe";
|
|
947
|
-
readonly chainId: number;
|
|
948
|
-
readonly network: "base-sepolia";
|
|
949
|
-
readonly currency: "USD";
|
|
950
|
-
readonly address: string;
|
|
951
|
-
readonly label: string;
|
|
952
|
-
}
|
|
953
|
-
interface RecipientResolution {
|
|
954
|
-
readonly kind: RecipientResolutionKind;
|
|
955
|
-
readonly recipient: string;
|
|
956
|
-
readonly label: string;
|
|
957
|
-
readonly safeAddress: string;
|
|
958
|
-
readonly payeeId?: string;
|
|
959
|
-
readonly orgId?: string;
|
|
960
|
-
readonly handle?: string;
|
|
961
|
-
readonly email?: string;
|
|
962
|
-
}
|
|
963
|
-
interface Payee {
|
|
964
|
-
readonly payeeId: string;
|
|
965
|
-
readonly label: string;
|
|
966
|
-
readonly recipientRef: string;
|
|
967
|
-
readonly handle: string | null;
|
|
968
|
-
readonly destinationKind: "email" | "org" | "payeeHandle";
|
|
969
|
-
readonly safeAddress: string;
|
|
970
|
-
readonly createdAt: number;
|
|
971
|
-
readonly updatedAt: number;
|
|
972
|
-
}
|
|
973
|
-
interface MeMethods {
|
|
974
|
-
get(options?: {
|
|
975
|
-
readonly signal?: AbortSignal;
|
|
976
|
-
}): Promise<CapxulResult<MeProfile>>;
|
|
977
|
-
depositInstructions(options?: {
|
|
978
|
-
readonly signal?: AbortSignal;
|
|
979
|
-
}): Promise<CapxulResult<DepositInstructions>>;
|
|
980
|
-
}
|
|
981
|
-
interface HandlesMethods {
|
|
982
|
-
resolve(handle: string, options?: {
|
|
983
|
-
readonly signal?: AbortSignal;
|
|
984
|
-
}): Promise<CapxulResult<RecipientResolution>>;
|
|
985
|
-
}
|
|
986
|
-
interface PayeesMethods {
|
|
987
|
-
create(input: {
|
|
988
|
-
readonly label: string;
|
|
989
|
-
readonly recipient: string;
|
|
990
|
-
readonly handle?: string;
|
|
991
|
-
}, options?: {
|
|
992
|
-
readonly signal?: AbortSignal;
|
|
993
|
-
}): Promise<CapxulResult<Payee>>;
|
|
994
|
-
get(payeeId: string, options?: {
|
|
995
|
-
readonly signal?: AbortSignal;
|
|
996
|
-
}): Promise<CapxulResult<Payee | null>>;
|
|
997
|
-
resolve(recipient: string, options?: {
|
|
998
|
-
readonly signal?: AbortSignal;
|
|
999
|
-
}): Promise<CapxulResult<RecipientResolution>>;
|
|
1000
|
-
}
|
|
1001
|
-
interface PaymentMoney {
|
|
1002
|
-
readonly currency: string;
|
|
1003
|
-
readonly value: string;
|
|
1004
|
-
readonly decimals: number;
|
|
1005
|
-
}
|
|
1006
|
-
type PaymentStatus = "pending" | "submitted" | "pending_claim" | "scheduled" | "streaming" | "settled" | "cancelled" | "redirected" | "expired" | "failed";
|
|
1007
|
-
type PaymentType = "unspecified" | "invoice" | "payroll" | "reimbursement";
|
|
1008
|
-
interface PaymentDocumentRef {
|
|
1009
|
-
readonly documentHash: string;
|
|
1010
|
-
readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
|
|
1011
|
-
readonly title?: string;
|
|
1012
|
-
readonly uri?: string;
|
|
1013
|
-
readonly issuedAt?: number;
|
|
1014
|
-
}
|
|
1015
|
-
type PaymentRelease = {
|
|
1016
|
-
readonly kind: "instant";
|
|
1017
|
-
} | {
|
|
1018
|
-
readonly kind: "scheduled";
|
|
1019
|
-
readonly at: number;
|
|
1020
|
-
} | {
|
|
1021
|
-
readonly kind: "stream";
|
|
1022
|
-
readonly startsAt: number;
|
|
1023
|
-
readonly endsAt: number;
|
|
1024
|
-
readonly cliffAt?: number;
|
|
1025
|
-
};
|
|
1026
|
-
interface Payment {
|
|
1027
|
-
readonly id: string;
|
|
1028
|
-
readonly status: PaymentStatus;
|
|
1029
|
-
readonly amount: PaymentMoney;
|
|
1030
|
-
readonly paymentType: PaymentType;
|
|
1031
|
-
readonly recipient: {
|
|
1032
|
-
readonly kind: "handle" | "email" | "payee" | "me" | "org" | "external_address";
|
|
1033
|
-
readonly label: string;
|
|
1034
|
-
readonly payeeId?: string;
|
|
1035
|
-
};
|
|
1036
|
-
readonly documents: readonly PaymentDocumentRef[];
|
|
1037
|
-
readonly release: PaymentRelease;
|
|
1038
|
-
readonly released: PaymentMoney;
|
|
1039
|
-
readonly availableToClaim: PaymentMoney;
|
|
1040
|
-
readonly createdAt: number;
|
|
1041
|
-
readonly updatedAt: number;
|
|
1042
|
-
}
|
|
1043
|
-
interface PaymentsPayInput {
|
|
1044
|
-
readonly to: string;
|
|
1045
|
-
readonly amount: PaymentMoney;
|
|
1046
|
-
/** Full EIP-712 document envelope; hashed + stored, committed on-chain. */
|
|
1047
|
-
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1048
|
-
/**
|
|
1049
|
-
* Release clause (G3 · #546). Omitted ⇒ `instant` (the G2 direct-send path).
|
|
1050
|
-
* A `scheduled`/`stream` clause turns the payment into a Commitment
|
|
1051
|
-
* (escrow-vest-claim) backed by `CapxulPayments.createCommitment`.
|
|
1052
|
-
*/
|
|
1053
|
-
readonly release?: PaymentRelease;
|
|
1054
|
-
/**
|
|
1055
|
-
* #592: itemized line items backing an Invoice `document`. The backend asserts
|
|
1056
|
-
* `hashLineItems(lineItems) === document.lineItemsHash` AND `Σ(quantity ×
|
|
1057
|
-
* unitMinor) === document.amount`, then persists the list for itemized render.
|
|
1058
|
-
*/
|
|
1059
|
-
readonly lineItems?: readonly LineItemV1[];
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
* B3 withdraw / cash-out input. Stripe-shaped: `to` is the EXTERNAL 0x wallet
|
|
1063
|
-
* (the ONE place the SDK accepts a raw address — the pay lane never does),
|
|
1064
|
-
* `amount` is a Money, `document` is the REQUIRED kind:4 Withdrawal envelope
|
|
1065
|
-
* (carries the audit-visible destAddress). No chain / Safe / token / hash
|
|
1066
|
-
* custody substrate on the input. Returns a leak-safe `Payment` whose recipient
|
|
1067
|
-
* label is the redacted address — never the full 0x.
|
|
1068
|
-
*/
|
|
1069
|
-
interface PaymentsWithdrawInput {
|
|
1070
|
-
readonly to: string;
|
|
1071
|
-
readonly amount: PaymentMoney;
|
|
1072
|
-
readonly document: PaymentDocumentEnvelopeV1;
|
|
1073
|
-
}
|
|
1074
|
-
interface PaymentSettlementInput {
|
|
1075
|
-
readonly paymentId: string;
|
|
1076
|
-
readonly evidence: OnchainEvidence;
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
|
-
* Host-execution callback recording the on-chain escrow of a commitment
|
|
1080
|
-
* (G3 · #546): `createCommitment` returned `onchainCommitmentId`, escrowing
|
|
1081
|
-
* the total. `onchainCommitmentId` + the userOp/tx hashes are internal evidence,
|
|
1082
|
-
* never on the wire (internal channel only).
|
|
1083
|
-
*/
|
|
1084
|
-
interface CommitmentCreatedInput {
|
|
1085
|
-
readonly paymentId: string;
|
|
1086
|
-
readonly onchainCommitmentId: string;
|
|
1087
|
-
readonly evidence: OnchainEvidence;
|
|
1088
|
-
}
|
|
1089
|
-
/** Host-execution callback recording a recipient-side `claim` (G3 · #546). */
|
|
1090
|
-
interface CommitmentClaimInput {
|
|
1091
|
-
readonly paymentId: string;
|
|
1092
|
-
readonly evidence: OnchainEvidence;
|
|
1093
|
-
}
|
|
1094
|
-
/**
|
|
1095
|
-
* Host-execution callback recording a creator-side `cancel` (G3 · #546):
|
|
1096
|
-
* on-chain the unvested remainder returns to the creator; vested-unclaimed
|
|
1097
|
-
* stays the recipient's. An optional credit-note document is appended.
|
|
1098
|
-
*/
|
|
1099
|
-
interface CommitmentCancelInput {
|
|
1100
|
-
readonly paymentId: string;
|
|
1101
|
-
readonly evidence: OnchainEvidence;
|
|
1102
|
-
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1103
|
-
}
|
|
1104
|
-
/**
|
|
1105
|
-
* Host-execution callback recording a pre-claim `redirect` to a new validated
|
|
1106
|
-
* recipient (G3 · #546). `to` is a validated recipient (handle/email/payee id),
|
|
1107
|
-
* never a raw address.
|
|
1108
|
-
*/
|
|
1109
|
-
interface CommitmentRedirectInput {
|
|
1110
|
-
readonly paymentId: string;
|
|
1111
|
-
readonly to: string;
|
|
1112
|
-
readonly evidence: OnchainEvidence;
|
|
1113
|
-
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1114
|
-
}
|
|
1115
|
-
/**
|
|
1116
|
-
* Host-execution callback recording a settled ORG spend/payroll on the ONE
|
|
1117
|
-
* `payments` ledger (D3 · #565). An org spend is a KIND of Payment — it lands a
|
|
1118
|
-
* real `payments` row with `source:"org"` + `orgId` (no parallel `orgSpends`
|
|
1119
|
-
* table, no synthetic client-side fabrication). The signer-side host calls this
|
|
1120
|
-
* AFTER the on-chain Roles-modifier spend settles; `evidence` carries the
|
|
1121
|
-
* internal userOp/tx hashes (never wire fields). `recipient` is the validated
|
|
1122
|
-
* recipient ref label; `recipientSafeAddress` is internal evidence on the row.
|
|
1123
|
-
*/
|
|
1124
|
-
interface OrgPaymentRecordInput {
|
|
1125
|
-
readonly orgId: string;
|
|
1126
|
-
readonly recipientLabel: string;
|
|
1127
|
-
readonly recipientSafeAddress: string;
|
|
1128
|
-
readonly amount: PaymentMoney;
|
|
1129
|
-
readonly paymentType: PaymentType;
|
|
1130
|
-
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1131
|
-
/** The org Safe the spend debited — bound as the `from` of the settlement transfer. */
|
|
1132
|
-
readonly orgSafeAddress: string;
|
|
1133
|
-
/**
|
|
1134
|
-
* 0-based occurrence among batch runs with the same (recipient, amount), so
|
|
1135
|
-
* each run binds to + de-dupes on its own on-chain `Transfer` (D3 · #565).
|
|
1136
|
-
*/
|
|
1137
|
-
readonly occurrenceIndex: number;
|
|
1138
|
-
readonly evidence: OnchainEvidence;
|
|
1139
|
-
}
|
|
1140
|
-
interface PaymentDocumentVerification {
|
|
1141
|
-
readonly documentHash: string;
|
|
1142
|
-
readonly ok: boolean;
|
|
1143
|
-
readonly derivedHash: string;
|
|
1144
|
-
readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
|
|
1145
|
-
}
|
|
1146
|
-
/**
|
|
1147
|
-
* #577 render-on-demand result. `html` is self-contained user-visible document
|
|
1148
|
-
* HTML (stylesheet + rendered document). The MCP `paymentDocuments.render` tool
|
|
1149
|
-
* exposes only `{documentHash, kind, ok}` to the model and returns `html` in an
|
|
1150
|
-
* audience:["user"] content block (#506 redaction matrix).
|
|
1151
|
-
*/
|
|
1152
|
-
interface PaymentDocumentRender {
|
|
1153
|
-
readonly documentHash: string;
|
|
1154
|
-
readonly ok: boolean;
|
|
1155
|
-
readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
|
|
1156
|
-
readonly html: string;
|
|
1157
|
-
}
|
|
1158
|
-
/**
|
|
1159
|
-
* Internal commitment execution reference (G3 · #546). The on-chain
|
|
1160
|
-
* `onchainCommitmentId` is internal evidence (like userOp/tx hashes) — it never
|
|
1161
|
-
* appears on the wire `Payment` or any MCP tool output, but the signer-side host
|
|
1162
|
-
* needs it to build a claim/cancel/redirect UserOp. This is the server-internal
|
|
1163
|
-
* channel that carries it (and the recipient Safe address for an auto-claim
|
|
1164
|
-
* relayer), never a consumer-facing surface.
|
|
1165
|
-
*/
|
|
1166
|
-
interface PaymentCommitmentRef {
|
|
1167
|
-
readonly paymentId: string;
|
|
1168
|
-
readonly onchainCommitmentId: string | null;
|
|
1169
|
-
readonly status: PaymentStatus;
|
|
1170
|
-
}
|
|
1171
|
-
/**
|
|
1172
|
-
* The host-execution + on-chain-evidence channel for Payments (D2 · #564).
|
|
1173
|
-
* SPLIT OFF the public `PaymentsMethods` so an external builder consuming
|
|
1174
|
-
* `@capxul/sdk` directly never sees the custody substrate. Reached only via
|
|
1175
|
-
* `client.payments._internal` (mirrors `client._internal.*`); the signer-side
|
|
1176
|
-
* host (the dev MCP edge / a self-custody integrator) drives it AFTER executing
|
|
1177
|
-
* a UserOp. Every input carries the `OnchainEvidence` brand — never a wire field.
|
|
1178
|
-
*/
|
|
1179
|
-
interface PaymentsInternalMethods {
|
|
1180
|
-
/** Report on-chain settlement evidence for an instant payment. */
|
|
1181
|
-
markSettled(input: PaymentSettlementInput, options?: {
|
|
1182
|
-
readonly signal?: AbortSignal;
|
|
1183
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1184
|
-
/**
|
|
1185
|
-
* B3: report on-chain settlement evidence for a withdraw/cash-out. The
|
|
1186
|
-
* backend binds the userOp to a matching external `Transfer` before settling.
|
|
1187
|
-
*/
|
|
1188
|
-
markWithdrawalSettled(input: PaymentSettlementInput, options?: {
|
|
1189
|
-
readonly signal?: AbortSignal;
|
|
1190
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1191
|
-
/**
|
|
1192
|
-
* Record the on-chain escrow of a commitment after `createCommitment` returns
|
|
1193
|
-
* its `onchainCommitmentId` (G3 · #546).
|
|
1194
|
-
*/
|
|
1195
|
-
markCommitmentCreated(input: CommitmentCreatedInput, options?: {
|
|
1196
|
-
readonly signal?: AbortSignal;
|
|
1197
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1198
|
-
/**
|
|
1199
|
-
* Record a settled ORG spend/payroll on the one `payments` ledger
|
|
1200
|
-
* (D3 · #565) — `source:"org"` + `orgId`, read back as a leak-safe Payment.
|
|
1201
|
-
*/
|
|
1202
|
-
recordOrgPayment(input: OrgPaymentRecordInput, options?: {
|
|
1203
|
-
readonly signal?: AbortSignal;
|
|
1204
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1205
|
-
/** Record a recipient-side `claim` after the on-chain claim UserOp settles. */
|
|
1206
|
-
claim(input: CommitmentClaimInput, options?: {
|
|
1207
|
-
readonly signal?: AbortSignal;
|
|
1208
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1209
|
-
/** Record a creator-side `cancel` reclaiming only the unvested remainder. */
|
|
1210
|
-
cancel(input: CommitmentCancelInput, options?: {
|
|
1211
|
-
readonly signal?: AbortSignal;
|
|
1212
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1213
|
-
/** Record a pre-claim `redirect` to a new validated recipient. */
|
|
1214
|
-
redirect(input: CommitmentRedirectInput, options?: {
|
|
1215
|
-
readonly signal?: AbortSignal;
|
|
1216
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1217
|
-
/**
|
|
1218
|
-
* The on-chain commitment reference the signer-side host needs to build a
|
|
1219
|
-
* claim/cancel/redirect UserOp. `onchainCommitmentId` is internal evidence.
|
|
1220
|
-
*/
|
|
1221
|
-
commitmentRef(paymentId: string, options?: {
|
|
1222
|
-
readonly signal?: AbortSignal;
|
|
1223
|
-
}): Promise<CapxulResult<PaymentCommitmentRef | null>>;
|
|
1224
|
-
}
|
|
1225
|
-
/**
|
|
1226
|
-
* The PUBLIC, Stripe-shaped Payments surface (D2 · #564). Genus verbs only —
|
|
1227
|
-
* `pay` / `list` / `get`. No `userOpHash` / `txHash` / `onchainCommitmentId` /
|
|
1228
|
-
* `chainId` / `safeAddress`. Host-execution + on-chain evidence live on the
|
|
1229
|
-
* `_internal` channel below; an external builder never touches custody substrate.
|
|
1230
|
-
*/
|
|
1231
|
-
interface PaymentsMethods {
|
|
1232
|
-
pay(input: PaymentsPayInput, options?: {
|
|
1233
|
-
readonly signal?: AbortSignal;
|
|
1234
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1235
|
-
/**
|
|
1236
|
-
* B3 withdraw / cash-out: send USDX from the user's custody Safe to an
|
|
1237
|
-
* external 0x wallet, minting a kind:4 Withdrawal document. Returns a
|
|
1238
|
-
* leak-safe `Payment` (recipient label is the redacted address).
|
|
1239
|
-
*/
|
|
1240
|
-
withdraw(input: PaymentsWithdrawInput, options?: {
|
|
1241
|
-
readonly signal?: AbortSignal;
|
|
1242
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1243
|
-
list(options?: {
|
|
1244
|
-
readonly signal?: AbortSignal;
|
|
1245
|
-
}): Promise<CapxulResult<readonly Payment[]>>;
|
|
1246
|
-
get(paymentId: string, options?: {
|
|
1247
|
-
readonly signal?: AbortSignal;
|
|
1248
|
-
}): Promise<CapxulResult<Payment | null>>;
|
|
1249
|
-
/**
|
|
1250
|
-
* Host-execution + on-chain-evidence channel — off the public surface
|
|
1251
|
-
* (production-surface-policy.md pattern). Self-custody integrators drive this;
|
|
1252
|
-
* a Stripe-shaped consumer never does.
|
|
1253
|
-
*
|
|
1254
|
-
* @internal-use
|
|
1255
|
-
*/
|
|
1256
|
-
readonly _internal: PaymentsInternalMethods;
|
|
1257
|
-
}
|
|
1258
|
-
interface PaymentDocumentsMethods {
|
|
1259
|
-
verify(documentHash: string, options?: {
|
|
1260
|
-
readonly signal?: AbortSignal;
|
|
1261
|
-
}): Promise<CapxulResult<PaymentDocumentVerification>>;
|
|
1262
|
-
/**
|
|
1263
|
-
* #577: render-on-demand. Loads the owner's stored document by `documentHash`,
|
|
1264
|
-
* re-verifies its EIP-712 hash, and renders it to self-contained HTML using the
|
|
1265
|
-
* verified stored line items. Returns `{documentHash, kind, ok, html}`.
|
|
1266
|
-
*/
|
|
1267
|
-
render(documentHash: string, options?: {
|
|
1268
|
-
readonly signal?: AbortSignal;
|
|
1269
|
-
}): Promise<CapxulResult<PaymentDocumentRender>>;
|
|
1270
|
-
}
|
|
1271
|
-
type PaymentRequestStatus = "draft" | "sent" | "viewed" | "paid" | "expired" | "cancelled";
|
|
1272
|
-
interface PaymentRequest {
|
|
1273
|
-
readonly id: string;
|
|
1274
|
-
readonly status: PaymentRequestStatus;
|
|
1275
|
-
readonly amount: PaymentMoney;
|
|
1276
|
-
readonly reference: string;
|
|
1277
|
-
readonly memo: string | null;
|
|
1278
|
-
/** Fixed-amount payment link token (HITL #519: basic, not replay-hardened). */
|
|
1279
|
-
readonly linkToken: string;
|
|
1280
|
-
/** Minimal entitlement (HITL #501): true once paid. */
|
|
1281
|
-
readonly entitlementGranted: boolean;
|
|
1282
|
-
/** The Payment this receivable settled into (set on collect). */
|
|
1283
|
-
readonly settledPaymentId: string | null;
|
|
1284
|
-
/** The receipt document committed for this receivable (set on collect). */
|
|
1285
|
-
readonly receiptDocumentHash: string | null;
|
|
1286
|
-
readonly expiresAt: number | null;
|
|
1287
|
-
readonly createdAt: number;
|
|
1288
|
-
readonly updatedAt: number;
|
|
1289
|
-
}
|
|
1290
|
-
interface ReconciliationEntry {
|
|
1291
|
-
readonly paymentRequestId: string;
|
|
1292
|
-
readonly reference: string;
|
|
1293
|
-
readonly status: "paid" | "exception";
|
|
1294
|
-
readonly settledPaymentId: string | null;
|
|
1295
|
-
readonly receiptDocumentHash: string | null;
|
|
1296
|
-
}
|
|
1297
|
-
interface PaymentRequestsCreateInput {
|
|
1298
|
-
readonly amount: PaymentMoney;
|
|
1299
|
-
readonly reference: string;
|
|
1300
|
-
readonly memo?: string;
|
|
1301
|
-
/** Optional expiry (epoch ms). HITL #519: expiry policy is a basic timestamp. */
|
|
1302
|
-
readonly expiresAt?: number;
|
|
1303
|
-
}
|
|
1304
|
-
interface PaymentRequestsMethods {
|
|
1305
|
-
/** Open a receivable in `draft` with a fixed-amount payment link. */
|
|
1306
|
-
create(input: PaymentRequestsCreateInput, options?: {
|
|
1307
|
-
readonly signal?: AbortSignal;
|
|
1308
|
-
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1309
|
-
markSent(paymentRequestId: string, options?: {
|
|
1310
|
-
readonly signal?: AbortSignal;
|
|
1311
|
-
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1312
|
-
markViewed(paymentRequestId: string, options?: {
|
|
1313
|
-
readonly signal?: AbortSignal;
|
|
1314
|
-
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1315
|
-
cancel(paymentRequestId: string, options?: {
|
|
1316
|
-
readonly signal?: AbortSignal;
|
|
1317
|
-
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1318
|
-
/**
|
|
1319
|
-
* Collect the receivable (HERMETIC until a live inbound path exists): settle
|
|
1320
|
-
* it into the Payment ledger and mint a receipt linked by `documentHash`.
|
|
1321
|
-
*/
|
|
1322
|
-
collect(paymentRequestId: string, options?: {
|
|
1323
|
-
readonly signal?: AbortSignal;
|
|
1324
|
-
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1325
|
-
list(options?: {
|
|
1326
|
-
readonly signal?: AbortSignal;
|
|
1327
|
-
}): Promise<CapxulResult<readonly PaymentRequest[]>>;
|
|
1328
|
-
get(paymentRequestId: string, options?: {
|
|
1329
|
-
readonly signal?: AbortSignal;
|
|
1330
|
-
}): Promise<CapxulResult<PaymentRequest | null>>;
|
|
1331
|
-
getByLink(linkToken: string, options?: {
|
|
1332
|
-
readonly signal?: AbortSignal;
|
|
1333
|
-
}): Promise<CapxulResult<PaymentRequest | null>>;
|
|
1334
|
-
/** Inbound reconciliation: paid / exception status per receivable. */
|
|
1335
|
-
reconcile(options?: {
|
|
1336
|
-
readonly signal?: AbortSignal;
|
|
1337
|
-
}): Promise<CapxulResult<readonly ReconciliationEntry[]>>;
|
|
1338
|
-
}
|
|
1339
|
-
type PaymentDraftStatus = "draft" | "simulated" | "approval_pending" | "approved" | "executed" | "cancelled" | "expired";
|
|
1340
|
-
/** The leak-safe, model-visible draft/approval (#506). */
|
|
1341
|
-
interface PaymentDraft {
|
|
1342
|
-
readonly id: string;
|
|
1343
|
-
readonly status: PaymentDraftStatus;
|
|
1344
|
-
readonly recipient: {
|
|
1345
|
-
readonly kind: string;
|
|
1346
|
-
readonly label: string;
|
|
1347
|
-
};
|
|
1348
|
-
readonly amount: PaymentMoney;
|
|
1349
|
-
readonly documentHash: string | null;
|
|
1350
|
-
/** The canonical-plan binding fingerprint (set at approvals.request). */
|
|
1351
|
-
readonly planHash: string | null;
|
|
1352
|
-
/** The opaque read-model version the draft was simulated against (stale-state). */
|
|
1353
|
-
readonly readModelVersion: string;
|
|
1354
|
-
readonly idempotencyKey: string;
|
|
1355
|
-
readonly policyDecision: "allow" | "deny";
|
|
1356
|
-
readonly expiresAt: number | null;
|
|
1357
|
-
readonly settledPaymentId: string | null;
|
|
1358
|
-
readonly createdAt: number;
|
|
1359
|
-
readonly updatedAt: number;
|
|
1360
|
-
}
|
|
1361
|
-
interface WorkbenchDraftInput {
|
|
1362
|
-
readonly clientId: string;
|
|
1363
|
-
readonly audience: string;
|
|
1364
|
-
readonly scopes: readonly string[];
|
|
1365
|
-
readonly to: string;
|
|
1366
|
-
readonly amount: PaymentMoney;
|
|
1367
|
-
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1368
|
-
readonly idempotencyKey: string;
|
|
1369
|
-
/** Untrusted connector/model suggestion blob (default-deny taint). */
|
|
1370
|
-
readonly tainted?: Record<string, unknown>;
|
|
1371
|
-
}
|
|
1372
|
-
interface WorkbenchMintResult {
|
|
1373
|
-
readonly approvalToken: string;
|
|
1374
|
-
readonly planHash: string;
|
|
1375
|
-
readonly expiresAt: number;
|
|
1376
|
-
}
|
|
1377
|
-
interface WorkbenchExecuteInput {
|
|
1378
|
-
readonly draftId: string;
|
|
1379
|
-
readonly clientId: string;
|
|
1380
|
-
readonly approvalToken: string;
|
|
1381
|
-
readonly readModelVersion: string;
|
|
1382
|
-
readonly userOpHash: string;
|
|
1383
|
-
readonly txHash: string;
|
|
1384
|
-
}
|
|
1385
|
-
/**
|
|
1386
|
-
* The decomposed workbench (G6 · #549). The edge PROPOSES (draft → simulate →
|
|
1387
|
-
* request); the BACKEND mints the one-time plan-bound token via the human's
|
|
1388
|
-
* browser (`mint`); `execute` consumes it. `mint` is the human step — the edge
|
|
1389
|
-
* normally only reaches `request`, then hands the human a browser URL.
|
|
1390
|
-
*/
|
|
1391
|
-
interface WorkbenchMethods {
|
|
1392
|
-
draft(input: WorkbenchDraftInput, options?: {
|
|
1393
|
-
readonly signal?: AbortSignal;
|
|
1394
|
-
}): Promise<CapxulResult<PaymentDraft>>;
|
|
1395
|
-
simulate(draftId: string, options?: {
|
|
1396
|
-
readonly signal?: AbortSignal;
|
|
1397
|
-
}): Promise<CapxulResult<PaymentDraft>>;
|
|
1398
|
-
requestApproval(draftId: string, options?: {
|
|
1399
|
-
readonly signal?: AbortSignal;
|
|
1400
|
-
}): Promise<CapxulResult<PaymentDraft>>;
|
|
1401
|
-
/**
|
|
1402
|
-
* THE HUMAN STEP: mint the one-time approval token (browser/approval app).
|
|
1403
|
-
* F2 (#549): the backend gates minting on a human-origin `capability` the
|
|
1404
|
-
* agent/edge does NOT possess (`CAPXUL_APPROVAL_CAPABILITY`); only the
|
|
1405
|
-
* apps/approve browser app passes it. The edge/SDK lane cannot self-approve.
|
|
1406
|
-
*/
|
|
1407
|
-
mint(draftId: string, capability: string, options?: {
|
|
1408
|
-
readonly signal?: AbortSignal;
|
|
1409
|
-
}): Promise<CapxulResult<WorkbenchMintResult>>;
|
|
1410
|
-
execute(input: WorkbenchExecuteInput, options?: {
|
|
1411
|
-
readonly signal?: AbortSignal;
|
|
1412
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1413
|
-
status(draftId: string, options?: {
|
|
1414
|
-
readonly signal?: AbortSignal;
|
|
1415
|
-
}): Promise<CapxulResult<PaymentDraft | null>>;
|
|
1416
|
-
cancel(draftId: string, options?: {
|
|
1417
|
-
readonly signal?: AbortSignal;
|
|
1418
|
-
}): Promise<CapxulResult<PaymentDraft>>;
|
|
1419
|
-
}
|
|
1420
|
-
interface FinancialOpsMethods {
|
|
1421
|
-
readonly me: MeMethods;
|
|
1422
|
-
readonly handles: HandlesMethods;
|
|
1423
|
-
readonly payees: PayeesMethods;
|
|
1424
|
-
readonly payments: PaymentsMethods;
|
|
1425
|
-
readonly paymentDocuments: PaymentDocumentsMethods;
|
|
1426
|
-
/** Receivables surface (G5 · #548). */
|
|
1427
|
-
readonly paymentRequests: PaymentRequestsMethods;
|
|
1428
|
-
/** Decomposed workbench + trust substrate (G6 · #549). */
|
|
1429
|
-
readonly workbench: WorkbenchMethods;
|
|
1430
|
-
}
|
|
1431
|
-
//#endregion
|
|
1432
|
-
//#region src/client/sub-accounts.d.ts
|
|
1433
|
-
interface SubAccountsMethods {
|
|
1434
|
-
create(accountId: AccountId, input: {
|
|
1435
|
-
readonly name: string;
|
|
1436
|
-
}, options?: {
|
|
1437
|
-
readonly signal?: AbortSignal;
|
|
1438
|
-
}): Promise<CapxulResult<SubAccount>>;
|
|
1439
|
-
get(subAccountId: SubAccountId, options?: {
|
|
1440
|
-
readonly signal?: AbortSignal;
|
|
1441
|
-
}): Promise<CapxulResult<SubAccount | null>>;
|
|
1442
|
-
list(accountId: AccountId, options?: {
|
|
1443
|
-
readonly signal?: AbortSignal;
|
|
1444
|
-
}): Promise<CapxulResult<readonly SubAccount[]>>;
|
|
1445
|
-
rename(subAccountId: SubAccountId, name: string, options?: {
|
|
1446
|
-
readonly signal?: AbortSignal;
|
|
1447
|
-
}): Promise<CapxulResult<SubAccount>>;
|
|
1448
|
-
delete(subAccountId: SubAccountId, options?: {
|
|
1449
|
-
readonly signal?: AbortSignal;
|
|
1450
|
-
}): Promise<CapxulResult<void>>;
|
|
1451
|
-
transfer(input: TransferInput, options?: {
|
|
1452
|
-
readonly signal?: AbortSignal;
|
|
1453
|
-
}): Promise<CapxulResult<TransferResult>>;
|
|
1454
|
-
}
|
|
1455
|
-
//#endregion
|
|
1456
|
-
//#region src/client/org-spend-gate.d.ts
|
|
1457
|
-
/**
|
|
1458
|
-
* The role's allowed recipients. The address form backs the S4 `spend` path
|
|
1459
|
-
* (recipient is a resolved `Address`); the string form backs the G4
|
|
1460
|
-
* `spendViaPayments` / `batchPayroll` path, whose recipient is a VALIDATED REF
|
|
1461
|
-
* (handle/email/payee/org) compared in the same ref space as the role's set.
|
|
1462
|
-
* Comparison is case-insensitive over the raw string value either way.
|
|
1463
|
-
*/
|
|
1464
|
-
type SpendGateRecipients = "anyone" | readonly (Address | string)[];
|
|
1465
|
-
type SpendGateSubAccountScope = {
|
|
1466
|
-
readonly scope: "all";
|
|
1467
|
-
} | {
|
|
1468
|
-
readonly scope: "only";
|
|
1469
|
-
readonly subAccountIds: readonly SubAccountId[];
|
|
1470
|
-
};
|
|
1471
|
-
//#endregion
|
|
1472
|
-
//#region src/ports/org.d.ts
|
|
1473
|
-
/**
|
|
1474
|
-
* The minimal `{from, to, amount}` spend shape the authority read keys off
|
|
1475
|
-
* (D3 #565). The legacy address-keyed `OrgSpendInput`/`org.spend` lane was
|
|
1476
|
-
* hard-removed when `orgSpends` folded into the one `payments` ledger; the
|
|
1477
|
-
* leak-safe ref-based lane (`spendViaPayments`/`batchPayroll`) constructs this
|
|
1478
|
-
* internally and enforces the real validated recipient on the gate.
|
|
1479
|
-
*/
|
|
1480
|
-
type OrgSpendShape = {
|
|
1481
|
-
readonly from: SubAccountId;
|
|
1482
|
-
readonly to: Address;
|
|
1483
|
-
readonly amount: Money;
|
|
1484
|
-
};
|
|
1485
|
-
type CreateOrgPortInput = {
|
|
1486
|
-
readonly input: CreateOrgInput;
|
|
1487
|
-
};
|
|
1488
|
-
type ReadOrgTreasuryInput = {
|
|
1489
|
-
readonly orgId: OrgId;
|
|
1490
|
-
};
|
|
1491
|
-
type ListOrgsInput = Record<never, never>;
|
|
1492
|
-
type ListOrgRolesInput = {
|
|
1493
|
-
readonly orgId: OrgId;
|
|
1494
|
-
};
|
|
1495
|
-
type ListOrgMembersInput = {
|
|
1496
|
-
readonly orgId: OrgId;
|
|
1497
|
-
};
|
|
1498
|
-
type InviteOrgMemberInput = {
|
|
1499
|
-
readonly orgId: OrgId;
|
|
1500
|
-
readonly input: InviteMemberInput;
|
|
1501
|
-
};
|
|
1502
|
-
type DetectPendingOrgInvitationsInput = Record<never, never>;
|
|
1503
|
-
type DetectPendingOrgInvitationsResult$1 = {
|
|
1504
|
-
readonly matched: readonly OrgId[];
|
|
1505
|
-
};
|
|
1506
|
-
type DeployOrgRolesInput = {
|
|
1507
|
-
readonly orgId: OrgId;
|
|
1508
|
-
};
|
|
1509
|
-
type OrgRolesDeploymentResult = {
|
|
1510
|
-
readonly orgId: OrgId;
|
|
1511
|
-
readonly roles: readonly RoleView[];
|
|
1512
|
-
};
|
|
1513
|
-
type GrantOrgRoleInput = {
|
|
1514
|
-
readonly orgId: OrgId;
|
|
1515
|
-
readonly input: AssignRoleInput;
|
|
1516
|
-
};
|
|
1517
|
-
type RevokeOrgRoleInput = {
|
|
1518
|
-
readonly orgId: OrgId;
|
|
1519
|
-
readonly input: RemoveMemberInput;
|
|
1520
|
-
};
|
|
1521
|
-
type OrgSpendAuthority = {
|
|
1522
|
-
readonly activeMember: boolean;
|
|
1523
|
-
readonly subAccountBalanceRaw: string;
|
|
1524
|
-
readonly recipients: SpendGateRecipients;
|
|
1525
|
-
readonly subAccounts: SpendGateSubAccountScope;
|
|
1526
|
-
readonly perTxCapRaw?: string | null;
|
|
1527
|
-
readonly perDayCapRaw?: string | null;
|
|
1528
|
-
readonly spentTodayRaw?: string | null;
|
|
1529
|
-
readonly role?: string;
|
|
1530
|
-
};
|
|
1531
|
-
type ReadOrgSpendAuthorityInput = {
|
|
1532
|
-
readonly orgId: OrgId;
|
|
1533
|
-
readonly input: OrgSpendShape;
|
|
1534
|
-
readonly amountRaw: string;
|
|
1535
|
-
};
|
|
1536
|
-
declare const OrgError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
1537
|
-
readonly _tag: "OrgError";
|
|
1538
|
-
} & Readonly<A>;
|
|
1539
|
-
declare class OrgError extends OrgError_base<{
|
|
1540
|
-
readonly operation: string;
|
|
1541
|
-
readonly publicCode: CapxulErrorCode;
|
|
1542
|
-
readonly publicError: CapxulError;
|
|
1543
|
-
readonly cause: unknown;
|
|
1544
|
-
readonly details?: CapxulErrorDetails;
|
|
1545
|
-
}> {}
|
|
1546
|
-
/**
|
|
1547
|
-
* Live org seam. `createOrg` runs the SDK-orchestrated deploy (D10) and returns
|
|
1548
|
-
* the created `OrgView` (its treasury is the real M2 `Account` over the Org
|
|
1549
|
-
* Safe — $0 at creation, D3). `readTreasury` pulls the org's Account via RPC
|
|
1550
|
-
* `balanceOf` (D3). `listOrgs` lists the orgs the authenticated user belongs to.
|
|
1551
|
-
*/
|
|
1552
|
-
interface OrgPort {
|
|
1553
|
-
createOrg(input: CreateOrgPortInput): Effect.Effect<OrgView, OrgError, never>;
|
|
1554
|
-
readTreasury(input: ReadOrgTreasuryInput): Effect.Effect<Account, OrgError, never>;
|
|
1555
|
-
listOrgs(input: ListOrgsInput): Effect.Effect<readonly OrgView[], OrgError, never>;
|
|
1556
|
-
listRoles(input: ListOrgRolesInput): Effect.Effect<readonly RoleView[], OrgError, never>;
|
|
1557
|
-
listMembers(input: ListOrgMembersInput): Effect.Effect<readonly MemberView[], OrgError, never>;
|
|
1558
|
-
inviteMember(input: InviteOrgMemberInput): Effect.Effect<MemberView, OrgError, never>;
|
|
1559
|
-
detectAndAcceptPendingInvitations(input: DetectPendingOrgInvitationsInput): Effect.Effect<DetectPendingOrgInvitationsResult$1, OrgError, never>;
|
|
1560
|
-
}
|
|
1561
|
-
interface OrgRolesDeploymentPort {
|
|
1562
|
-
deployRoles(input: DeployOrgRolesInput): Effect.Effect<OrgRolesDeploymentResult, OrgError, never>;
|
|
1563
|
-
grantRole(input: GrantOrgRoleInput): Effect.Effect<MemberView, OrgError, never>;
|
|
1564
|
-
revokeRole(input: RevokeOrgRoleInput): Effect.Effect<void, OrgError, never>;
|
|
1565
|
-
}
|
|
1566
|
-
type SubmitOrgSpendViaPaymentsInput = {
|
|
1567
|
-
readonly orgId: OrgId;
|
|
1568
|
-
readonly input: OrgSpendViaPaymentsInput;
|
|
1569
|
-
readonly amountRaw: string;
|
|
1570
|
-
readonly authority: OrgSpendAuthority;
|
|
1571
|
-
};
|
|
1572
|
-
type SubmitOrgBatchPayrollInput = {
|
|
1573
|
-
readonly orgId: OrgId;
|
|
1574
|
-
readonly from: OrgSpendViaPaymentsInput["from"];
|
|
1575
|
-
readonly runs: readonly {
|
|
1576
|
-
readonly run: OrgPayrollRun;
|
|
1577
|
-
readonly amountRaw: string;
|
|
1578
|
-
}[];
|
|
1579
|
-
readonly authorities: readonly OrgSpendAuthority[];
|
|
1580
|
-
};
|
|
1581
|
-
interface OrgSpendPort {
|
|
1582
|
-
readSpendAuthority(input: ReadOrgSpendAuthorityInput): Effect.Effect<OrgSpendAuthority, OrgError, never>;
|
|
1583
|
-
/**
|
|
1584
|
-
* Leak-safe org spend (G4 · #547; D3 #565 — the one ledger of record): execute
|
|
1585
|
-
* the spend through the payments engine (Roles modifier → CapxulPayments),
|
|
1586
|
-
* write a real `payments` row (`source:"org"`) and read it back as a `Payment`
|
|
1587
|
-
* — the wire carries no `txHash` / Safe / userOp internals. Optional so a
|
|
1588
|
-
* hermetic adapter without a payments-submit lane still compiles; absent ⇒ the
|
|
1589
|
-
* program falls back to a deterministic hermetic `Payment`.
|
|
1590
|
-
*/
|
|
1591
|
-
submitSpendViaPayments?(input: SubmitOrgSpendViaPaymentsInput): Effect.Effect<Payment, OrgError, never>;
|
|
1592
|
-
/** Leak-safe org payroll batch (G4 · #547): one MultiSend, one Payment per run. */
|
|
1593
|
-
submitBatchPayroll?(input: SubmitOrgBatchPayrollInput): Effect.Effect<readonly Payment[], OrgError, never>;
|
|
1594
|
-
}
|
|
1595
|
-
//#endregion
|
|
1596
|
-
//#region src/client/org.d.ts
|
|
1597
|
-
/**
|
|
1598
|
-
* A member's lifecycle status (D9 — unified `Member` with status
|
|
1599
|
-
* `pending | active | revoked | expired`). `pending` = invited (incl. a
|
|
1600
|
-
* non-user emailed into existence) but not yet a provisioned member with an
|
|
1601
|
-
* on-chain grant; `active` = on-chain role granted; `revoked` = offboarded
|
|
1602
|
-
* (on-chain REVOKE fired); `expired` = pending invitation timed out.
|
|
1603
|
-
*/
|
|
1604
|
-
type MemberStatus = "pending" | "pending_safe" | "pending_grant" | "active" | "revoked" | "expired";
|
|
1605
|
-
/**
|
|
1606
|
-
* One Org you belong to (canon §C1 "Org list" — name, role, balance).
|
|
1607
|
-
* `role` is the member's role label within THIS org. `treasury` is the M2
|
|
1608
|
-
* `Account` over the Org Safe (D3). `handle` is the globally-unique,
|
|
1609
|
-
* normalized org handle (D10a). Pure record of brand-typed fields — not a
|
|
1610
|
-
* brand.
|
|
1611
|
-
*/
|
|
1612
|
-
type OrgView = {
|
|
1613
|
-
readonly id: OrgId;
|
|
1614
|
-
readonly name: string;
|
|
1615
|
-
readonly handle: string;
|
|
1616
|
-
readonly safeAddress: Address; /** The viewing member's own role label within this org. */
|
|
1617
|
-
readonly role: string; /** The Org treasury — the real M2 Account over the Org Safe (D3). */
|
|
1618
|
-
readonly treasury: Account;
|
|
1619
|
-
};
|
|
1620
|
-
/**
|
|
1621
|
-
* One member of an Org (canon §C1 "Members" — name/email, role, status; D7/D8).
|
|
1622
|
-
* `personalSafeAddress` is the member-identity key (D7 — Safe-as-identity); it
|
|
1623
|
-
* is `null` while the member is still `pending` (emailed into existence but not
|
|
1624
|
-
* yet provisioned a personal Safe). `email` is the universal entry point (D8).
|
|
1625
|
-
*/
|
|
1626
|
-
type MemberView = {
|
|
1627
|
-
readonly orgId: OrgId;
|
|
1628
|
-
readonly email: Email;
|
|
1629
|
-
readonly name: string | null; /** Member-identity key (D7). `null` until the invitee provisions a Safe. */
|
|
1630
|
-
readonly personalSafeAddress: Address | null; /** The member's role label (maps deterministically to the on-chain `roleKey`, D9). */
|
|
1631
|
-
readonly role: string;
|
|
1632
|
-
readonly roleKey: RoleKey | null;
|
|
1633
|
-
readonly status: MemberStatus;
|
|
1634
|
-
readonly grantTxHash: string | null;
|
|
1635
|
-
readonly revokeTxHash: string | null;
|
|
1636
|
-
};
|
|
1637
|
-
/**
|
|
1638
|
-
* A role's on-chain Level-1 spend cap (D4/D5 — physically enforced via Zodiac
|
|
1639
|
-
* Roles + Allowance). `perTx` / `perDay` are `Money`; `toRecipients` scopes the
|
|
1640
|
-
* allowed recipient set. Omitting a field means "unbounded on that axis"
|
|
1641
|
-
* (the Owner role).
|
|
1642
|
-
*/
|
|
1643
|
-
type RoleSpendCap = {
|
|
1644
|
-
readonly perTx?: Money;
|
|
1645
|
-
readonly perDay?: Money;
|
|
1646
|
-
readonly toRecipients?: "anyone" | readonly Address[];
|
|
1647
|
-
};
|
|
1648
|
-
/**
|
|
1649
|
-
* The Capxul-owned Role DSL definition (D4). `label` becomes the sticky
|
|
1650
|
-
* bytes32 `roleKey` on-chain. `spend` compiles to Level-1 on-chain Zodiac
|
|
1651
|
-
* conditions; `subAccounts` + `canManage*` compile to Level-2 off-chain Convex
|
|
1652
|
-
* guards (D5).
|
|
1653
|
-
*/
|
|
1654
|
-
type RoleDefinition = {
|
|
1655
|
-
readonly label: string;
|
|
1656
|
-
readonly spend?: RoleSpendCap;
|
|
1657
|
-
readonly subAccounts?: {
|
|
1658
|
-
readonly scope: "all" | readonly SubAccountId[];
|
|
1659
|
-
};
|
|
1660
|
-
readonly canManageMembers?: boolean;
|
|
1661
|
-
readonly canManageRoles?: boolean;
|
|
1662
|
-
};
|
|
1663
|
-
/**
|
|
1664
|
-
* One role seeded on an Org (canon §C1 "Roles" — label + caps; D4/D6).
|
|
1665
|
-
* `roleKey` is the on-chain bytes32 role key derived from the label. `definition`
|
|
1666
|
-
* is the full Role DSL entry.
|
|
1667
|
-
*/
|
|
1668
|
-
type RoleView = {
|
|
1669
|
-
readonly orgId: OrgId;
|
|
1670
|
-
readonly label: string;
|
|
1671
|
-
readonly roleKey: RoleKey;
|
|
1672
|
-
readonly definition: RoleDefinition;
|
|
1673
|
-
};
|
|
1674
|
-
/** Built-in role templates that seed a new Org at creation (D6). */
|
|
1675
|
-
type OrgTemplate = "Solo" | "Startup" | "Custom";
|
|
1676
|
-
/**
|
|
1677
|
-
* Input to `capxul.createOrg` (S1, D10a, D14). `name` is the display name;
|
|
1678
|
-
* `handle` is the globally-unique normalized handle (`^[a-z0-9-]{3,32}$`, D10a);
|
|
1679
|
-
* `template` seeds the initial role set (D6); `country` is stored unvalidated
|
|
1680
|
-
* (D14 — KYB deferred). For `template: "Custom"`, `roles` carries the authored
|
|
1681
|
-
* `RoleDefinition[]`.
|
|
1682
|
-
*/
|
|
1683
|
-
type CreateOrgInput = {
|
|
1684
|
-
readonly name: string;
|
|
1685
|
-
readonly handle: string;
|
|
1686
|
-
readonly template: OrgTemplate;
|
|
1687
|
-
readonly country?: string;
|
|
1688
|
-
readonly roles?: readonly RoleDefinition[];
|
|
1689
|
-
};
|
|
1690
|
-
/**
|
|
1691
|
-
* Input to `org(orgId).invite` (S3, D8). Email is the universal entry point —
|
|
1692
|
-
* inviting an address that is not yet a Capxul user auto-creates a `pending`
|
|
1693
|
-
* membership that resolves on sign-in (the virality loop). `role` names the
|
|
1694
|
-
* role label the invitee is granted on accept.
|
|
1695
|
-
*/
|
|
1696
|
-
type InviteMemberInput = {
|
|
1697
|
-
readonly email: string;
|
|
1698
|
-
readonly role: string;
|
|
1699
|
-
};
|
|
1700
|
-
/**
|
|
1701
|
-
* Input to `org(orgId).removeMember` (S3, D8). Keyed on the member's personal
|
|
1702
|
-
* Safe address (D7 — Safe-as-identity). Drives the on-chain REVOKE + Convex
|
|
1703
|
-
* mirror.
|
|
1704
|
-
*/
|
|
1705
|
-
type RemoveMemberInput = {
|
|
1706
|
-
readonly memberSafeAddress: Address;
|
|
1707
|
-
};
|
|
1708
|
-
/**
|
|
1709
|
-
* Input to `org(orgId).assignRole` (S3, D7/D9). Keyed on the member's personal
|
|
1710
|
-
* Safe address (D7). Drives the on-chain GRANT + Convex mirror; the `role`
|
|
1711
|
-
* label maps deterministically to the on-chain `roleKey`.
|
|
1712
|
-
*/
|
|
1713
|
-
type AssignRoleInput = {
|
|
1714
|
-
readonly memberSafeAddress: Address;
|
|
1715
|
-
readonly role: string;
|
|
1716
|
-
};
|
|
1717
|
-
/**
|
|
1718
|
-
* Input to `org(orgId).spendViaPayments` (G4 · #547). The LEAK-SAFE org spend:
|
|
1719
|
-
* delegates `org.spend` to the payments engine WITH the member's org role
|
|
1720
|
-
* authority and returns a `Payment`, not a `txHash`. `to` is a VALIDATED
|
|
1721
|
-
* recipient ref (handle / email / payee id / org handle) — never a raw
|
|
1722
|
-
* `Address` (the legacy address-keyed `org.spend` lane was hard-removed in D3
|
|
1723
|
-
* #565 when `orgSpends` was folded into the one `payments` ledger).
|
|
1724
|
-
* `from` is the Level-2 sub-account envelope the spend draws from (D5).
|
|
1725
|
-
*/
|
|
1726
|
-
type OrgSpendViaPaymentsInput = {
|
|
1727
|
-
readonly from: SubAccountId; /** Validated recipient ref (handle/email/payee/org) — never a raw address. */
|
|
1728
|
-
readonly to: string;
|
|
1729
|
-
readonly amount: Money; /** Full EIP-712 payment document; hashed + stored, committed on-chain. */
|
|
1730
|
-
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1731
|
-
readonly paymentType?: PaymentType;
|
|
1732
|
-
};
|
|
1733
|
-
/**
|
|
1734
|
-
* One run in an `org(orgId).batchPayroll` batch (G4 · #547): a validated
|
|
1735
|
-
* recipient, an amount, and an optional payslip document. Each run is gated
|
|
1736
|
-
* independently against the role's per-tx / per-day / recipient conditions.
|
|
1737
|
-
*/
|
|
1738
|
-
type OrgPayrollRun = {
|
|
1739
|
-
/** Validated recipient ref (handle/email/payee/org) — never a raw address. */readonly to: string;
|
|
1740
|
-
readonly amount: Money; /** The payslip — an EIP-712 payment document, committed by `documentHash`. */
|
|
1741
|
-
readonly payslip?: PaymentDocumentEnvelopeV1;
|
|
1742
|
-
};
|
|
1743
|
-
/**
|
|
1744
|
-
* Input to `org(orgId).batchPayroll` (G4 · #547). Pays N employees in one
|
|
1745
|
-
* MultiSend through the Roles modifier; each carries a payslip and settles as
|
|
1746
|
-
* `paymentType = payroll`. Every run is gated; an over-cap run REJECTS the
|
|
1747
|
-
* whole batch (no partial treasury drain). Returns one leak-safe `Payment` per
|
|
1748
|
-
* run.
|
|
1749
|
-
*/
|
|
1750
|
-
type OrgBatchPayrollInput = {
|
|
1751
|
-
readonly from: SubAccountId;
|
|
1752
|
-
readonly runs: readonly OrgPayrollRun[];
|
|
1753
|
-
};
|
|
1754
|
-
type DetectPendingOrgInvitationsResult = {
|
|
1755
|
-
readonly matched: readonly OrgId[];
|
|
1756
|
-
};
|
|
1757
|
-
/**
|
|
1758
|
-
* Entity-scoped Org method bundle, returned by `capxul.org(orgId)`. Every
|
|
1759
|
-
* method names the entity implicitly via the closed-over `orgId` (D13 — no
|
|
1760
|
-
* stateful active context). `treasury()` returns the real M2 `Account` over
|
|
1761
|
-
* the Org Safe (D3).
|
|
1762
|
-
*/
|
|
1763
|
-
interface OrgScopedMethods {
|
|
1764
|
-
/** The Org treasury — the real M2 Account over the Org Safe (D3). */
|
|
1765
|
-
treasury(options?: {
|
|
1766
|
-
readonly signal?: AbortSignal;
|
|
1767
|
-
}): Promise<CapxulResult<Account>>;
|
|
1768
|
-
members(options?: {
|
|
1769
|
-
readonly signal?: AbortSignal;
|
|
1770
|
-
}): Promise<CapxulResult<readonly MemberView[]>>;
|
|
1771
|
-
roles(options?: {
|
|
1772
|
-
readonly signal?: AbortSignal;
|
|
1773
|
-
}): Promise<CapxulResult<readonly RoleView[]>>;
|
|
1774
|
-
deployRoles(options?: {
|
|
1775
|
-
readonly signal?: AbortSignal;
|
|
1776
|
-
}): Promise<CapxulResult<readonly RoleView[]>>;
|
|
1777
|
-
invite(input: InviteMemberInput, options?: {
|
|
1778
|
-
readonly signal?: AbortSignal;
|
|
1779
|
-
}): Promise<CapxulResult<MemberView>>;
|
|
1780
|
-
removeMember(input: RemoveMemberInput, options?: {
|
|
1781
|
-
readonly signal?: AbortSignal;
|
|
1782
|
-
}): Promise<CapxulResult<void>>;
|
|
1783
|
-
assignRole(input: AssignRoleInput, options?: {
|
|
1784
|
-
readonly signal?: AbortSignal;
|
|
1785
|
-
}): Promise<CapxulResult<MemberView>>;
|
|
1786
|
-
/**
|
|
1787
|
-
* Leak-safe org spend (G4 · #547; D3 #565 — the one ledger of record): execute
|
|
1788
|
-
* the spend through the payments engine with the member's org role authority
|
|
1789
|
-
* and return a `Payment` (no `to: Address`, no `txHash`, no Safe / userOp
|
|
1790
|
-
* internals). Writes a real `payments` row (`source:"org"`).
|
|
1791
|
-
*/
|
|
1792
|
-
spendViaPayments(input: OrgSpendViaPaymentsInput, options?: {
|
|
1793
|
-
readonly signal?: AbortSignal;
|
|
1794
|
-
}): Promise<CapxulResult<Payment>>;
|
|
1795
|
-
/**
|
|
1796
|
-
* Org payroll batch (G4 · #547): pay N employees in one MultiSend through the
|
|
1797
|
-
* Roles modifier, each with a payslip. Every run is gated; an over-cap run
|
|
1798
|
-
* rejects the whole batch. Returns one leak-safe `Payment` per run.
|
|
1799
|
-
*/
|
|
1800
|
-
batchPayroll(input: OrgBatchPayrollInput, options?: {
|
|
1801
|
-
readonly signal?: AbortSignal;
|
|
1802
|
-
}): Promise<CapxulResult<readonly Payment[]>>;
|
|
1803
|
-
}
|
|
1804
|
-
type OrgsMethod = {
|
|
1805
|
-
(options?: {
|
|
1806
|
-
readonly signal?: AbortSignal;
|
|
1807
|
-
}): Promise<CapxulResult<readonly OrgView[]>>;
|
|
1808
|
-
detectAndAcceptPendingInvitations(options?: {
|
|
1809
|
-
readonly signal?: AbortSignal;
|
|
1810
|
-
}): Promise<CapxulResult<DetectPendingOrgInvitationsResult>>;
|
|
1811
|
-
};
|
|
1812
|
-
/**
|
|
1813
|
-
* Top-level Org method bundle, exposed at `client.org` / `client.orgs` /
|
|
1814
|
-
* `client.createOrg`. `org(orgId)` resolves the entity-scoped bundle (D13).
|
|
1815
|
-
*/
|
|
1816
|
-
interface OrgMethods {
|
|
1817
|
-
createOrg(input: CreateOrgInput, options?: {
|
|
1818
|
-
readonly signal?: AbortSignal;
|
|
1819
|
-
}): Promise<CapxulResult<OrgView>>;
|
|
1820
|
-
readonly orgs: OrgsMethod;
|
|
1821
|
-
/** Resolve the entity-scoped bundle for a specific Org (D13). */
|
|
1822
|
-
org(orgId: OrgId): OrgScopedMethods;
|
|
1823
|
-
}
|
|
1824
|
-
//#endregion
|
|
1825
|
-
//#region src/client/onboarding.d.ts
|
|
1826
|
-
/**
|
|
1827
|
-
* Input to `capxul.onboarding.completePersonal`. `displayName` + `country`
|
|
1828
|
-
* (ISO-3166, persisted to `identities.country`) are required; `withdrawalAddress`
|
|
1829
|
-
* is the OPTIONAL cash-out destination — a `0x`-prefixed 20-byte address string
|
|
1830
|
-
* (the one allowed raw-0x class), validated + normalized at the boundary.
|
|
1831
|
-
*/
|
|
1832
|
-
type CompletePersonalOnboardingInput = {
|
|
1833
|
-
readonly displayName: string;
|
|
1834
|
-
readonly country: string;
|
|
1835
|
-
readonly withdrawalAddress?: string;
|
|
1836
|
-
};
|
|
1837
|
-
/**
|
|
1838
|
-
* Input to `capxul.onboarding.completeOrganization`. `handle` is the org slug
|
|
1839
|
-
* (`createOrg` requires it); `ownerDisplayName` is the founder's personal
|
|
1840
|
-
* identity profile.
|
|
1841
|
-
*/
|
|
1842
|
-
type CompleteOrganizationOnboardingInput = {
|
|
1843
|
-
readonly organizationName: string;
|
|
1844
|
-
readonly handle: string;
|
|
1845
|
-
readonly country: string;
|
|
1846
|
-
readonly ownerDisplayName: string;
|
|
1847
|
-
};
|
|
1848
|
-
/** Result of `completePersonal` — the post-onboarding readiness snapshot. */
|
|
1849
|
-
type CompletePersonalOnboardingResult = {
|
|
1850
|
-
readonly lifecycle: AccountLifecycle;
|
|
1851
|
-
};
|
|
1852
|
-
/** Result of `completeOrganization` — the created org + readiness snapshot. */
|
|
1853
|
-
type CompleteOrganizationOnboardingResult = {
|
|
1854
|
-
readonly org: OrgView;
|
|
1855
|
-
readonly lifecycle: AccountLifecycle;
|
|
1856
|
-
};
|
|
1857
|
-
/**
|
|
1858
|
-
* Onboarding method bundle, exposed at `client.onboarding`. Exactly two verbs;
|
|
1859
|
-
* the choreography lives in `flows/onboarding.ts`.
|
|
1860
|
-
*/
|
|
1861
|
-
interface OnboardingMethods {
|
|
1862
|
-
completePersonal(input: CompletePersonalOnboardingInput, options?: {
|
|
1863
|
-
readonly signal?: AbortSignal;
|
|
1864
|
-
}): Promise<CapxulResult<CompletePersonalOnboardingResult>>;
|
|
1865
|
-
completeOrganization(input: CompleteOrganizationOnboardingInput, options?: {
|
|
1866
|
-
readonly signal?: AbortSignal;
|
|
1867
|
-
}): Promise<CapxulResult<CompleteOrganizationOnboardingResult>>;
|
|
1868
|
-
}
|
|
1869
|
-
//#endregion
|
|
1870
|
-
//#region src/client/create-capxul-client.d.ts
|
|
1871
|
-
interface CapxulClient {
|
|
1872
|
-
readonly auth: AuthMethods;
|
|
1873
|
-
readonly smartAccount: SmartAccountMethods;
|
|
1874
|
-
readonly identity: IdentityMethods;
|
|
1875
|
-
/**
|
|
1876
|
-
* Consumer-facing account readiness surface (issue #159 · AC1+AC3).
|
|
1877
|
-
* Exactly `getStatus` + `ensureReady`; the `_internal.account`
|
|
1878
|
-
* namespace with `provision` + `deploySafe` lands in sibling #161.
|
|
1879
|
-
*/
|
|
1880
|
-
readonly account: AccountMethods;
|
|
1881
|
-
/**
|
|
1882
|
-
* Consumer-facing logical Account money read (M2 Slice S1a · #265).
|
|
1883
|
-
* Returns `{ balance, available }` as `Money` — never wei or token units.
|
|
1884
|
-
*/
|
|
1885
|
-
readonly accounts: AccountsMethods;
|
|
1886
|
-
readonly me: MeMethods;
|
|
1887
|
-
readonly handles: HandlesMethods;
|
|
1888
|
-
readonly payees: PayeesMethods;
|
|
1889
|
-
/**
|
|
1890
|
-
* Direct Payments surface (G2 · #545). `pay` records a validated-recipient
|
|
1891
|
-
* payment; `list`/`get` read the ledger; `markSettled` is the host-execution
|
|
1892
|
-
* callback. The MCP `draft → simulate → approve → execute` workbench is G6.
|
|
1893
|
-
*/
|
|
1894
|
-
readonly payments: PaymentsMethods;
|
|
1895
|
-
/** Payment document verification (G2 · #545): re-derive the EIP-712 hash. */
|
|
1896
|
-
readonly paymentDocuments: PaymentDocumentsMethods;
|
|
1897
|
-
/**
|
|
1898
|
-
* Receivables surface (G5 · #548). `create` opens a `PaymentRequest` with a
|
|
1899
|
-
* fixed-amount link; `markSent`/`markViewed`/`cancel` move the funnel;
|
|
1900
|
-
* `collect` settles the receivable into the Payment ledger + mints a receipt
|
|
1901
|
-
* linked by `documentHash`; `list`/`get`/`getByLink`/`reconcile` read it.
|
|
1902
|
-
*/
|
|
1903
|
-
readonly paymentRequests: PaymentRequestsMethods;
|
|
1904
|
-
/**
|
|
1905
|
-
* Decomposed workbench + trust substrate (G6 · #549). The MCP
|
|
1906
|
-
* `draft → simulate → approvals.request → execute` workbench: the edge
|
|
1907
|
-
* PROPOSES, the BACKEND mints a one-time plan-bound approval token via the
|
|
1908
|
-
* human's browser (#510), and `execute` consumes it. Taint / idempotency /
|
|
1909
|
-
* stale-state / scope guards are enforced backend-side.
|
|
1910
|
-
*/
|
|
1911
|
-
readonly workbench: WorkbenchMethods;
|
|
1912
|
-
/** Sub-account lifecycle (M2 Slice S2a · #267). Transfer lands in S2b. */
|
|
1913
|
-
readonly subAccounts: SubAccountsMethods;
|
|
1914
|
-
/**
|
|
1915
|
-
* Organization domain surface (canon `org-domain-model.md` §C2/§C3, D13).
|
|
1916
|
-
* `createOrg(input)` creates an Org; `orgs()` lists the Orgs you belong to;
|
|
1917
|
-
* `org(orgId)` resolves the entity-scoped bundle (treasury / members / roles
|
|
1918
|
-
* / invite / removeMember / assignRole / spend). Explicit entity scoping —
|
|
1919
|
-
* NO stateful active context (D13). RED until the S1→S4 slices fill it.
|
|
1920
|
-
*/
|
|
1921
|
-
readonly createOrg: OrgMethods["createOrg"];
|
|
1922
|
-
readonly orgs: OrgMethods["orgs"];
|
|
1923
|
-
readonly org: OrgMethods["org"];
|
|
1924
|
-
/**
|
|
1925
|
-
* Onboarding domain surface (D-ONBOARD · #669). `completePersonal` /
|
|
1926
|
-
* `completeOrganization` bridge the post-OTP auth → provision bookends:
|
|
1927
|
-
* persist the first identity profile (+ org), then trigger the existing
|
|
1928
|
-
* provisioning lane. Pre-scope — the on-ramp before the D-RELATE actor
|
|
1929
|
-
* scopes. `lifecycle.status` is the single routing source of truth.
|
|
1930
|
-
*/
|
|
1931
|
-
readonly onboarding: OnboardingMethods;
|
|
1932
|
-
/**
|
|
1933
|
-
* Internal observation namespace. Consumers MUST NOT drive the actor
|
|
1934
|
-
* directly — use the method bundles instead.
|
|
1935
|
-
*
|
|
1936
|
-
* @internal-use
|
|
1937
|
-
*/
|
|
1938
|
-
readonly _internal: {
|
|
1939
|
-
readonly authActor: AuthFlowObserver;
|
|
1940
|
-
/**
|
|
1941
|
-
* Resolved bootstrap for this client instance (chain, auth URLs, etc.).
|
|
1942
|
-
* Off the public surface per production-surface-policy.md (#31).
|
|
1943
|
-
*/
|
|
1944
|
-
readonly bootstrap: BootstrapResolution;
|
|
1945
|
-
/**
|
|
1946
|
-
* Dev-only faucet bundle (production-surface-policy.md). `fund` lives here,
|
|
1947
|
-
* NOT on the public `client.accounts` surface.
|
|
1948
|
-
*/
|
|
1949
|
-
readonly accounts: AccountsFaucetMethods; /** Telemetry port for error reporting. Used by React hooks to report errors before throwing. */
|
|
1950
|
-
readonly telemetry?: TelemetryPort;
|
|
1951
|
-
readonly close?: () => Promise<void>;
|
|
1952
|
-
};
|
|
1953
|
-
}
|
|
1954
|
-
interface CreateCapxulClientInput {
|
|
1955
|
-
/**
|
|
1956
|
-
* The 13-port `FlowPorts` bundle. The factory narrows this to the
|
|
1957
|
-
* 3-port AuthFlow subset (`authClient`, `clock`, `telemetry`) for
|
|
1958
|
-
* the flow internally, and uses additional ports (`identity`,
|
|
1959
|
-
* `smartAccount`) for the method bundles.
|
|
1960
|
-
*/
|
|
1961
|
-
readonly ports: FlowPorts;
|
|
1962
|
-
/**
|
|
1963
|
-
* Bootstrap resolution for this client instance. The factory closes over
|
|
1964
|
-
* `bootstrap.chainId` internally; consumers do not pass a standalone
|
|
1965
|
-
* chainId and no method boundary accepts one.
|
|
1966
|
-
*/
|
|
1967
|
-
readonly bootstrap: BootstrapResolution;
|
|
1968
|
-
/**
|
|
1969
|
-
* Optional AuthCachePort. When omitted, `detectAuthCacheAdapter()` selects
|
|
1970
|
-
* the appropriate per-environment adapter (Browser/FileSystem/InMemory).
|
|
1971
|
-
*/
|
|
1972
|
-
readonly authCache?: AuthCachePort;
|
|
1973
|
-
/**
|
|
1974
|
-
* Optional AbortSignal reserved for callers that coordinate client lifetime.
|
|
1975
|
-
*/
|
|
1976
|
-
readonly signal?: AbortSignal;
|
|
1977
|
-
/**
|
|
1978
|
-
* OTP TTL window in ms. Default 300_000 (5 min).
|
|
1979
|
-
*/
|
|
1980
|
-
readonly otpTtlMs?: number;
|
|
1981
|
-
/**
|
|
1982
|
-
* Optional per-call timeout for invoked auth requests.
|
|
1983
|
-
*/
|
|
1984
|
-
readonly invokeTimeoutMs?: number;
|
|
1985
|
-
/**
|
|
1986
|
-
* Init-time account readiness target (issue #159 · AC4). The factory
|
|
1987
|
-
* closes over this so `client.account.{getStatus,ensureReady}` don't
|
|
1988
|
-
* need to take a per-call requirement arg. REQUIRED — there is no
|
|
1989
|
-
* hidden default. Consumers building flows that never need a smart
|
|
1990
|
-
* account pass `"none"`; flows that want a counterfactual deposit
|
|
1991
|
-
* address pass `"counterfactual"`; flows that need an on-chain Safe
|
|
1992
|
-
* pass `"deployed"` (deploy path lands in sibling #161).
|
|
1993
|
-
*/
|
|
1994
|
-
readonly requirement: AccountRequirement;
|
|
1995
|
-
/**
|
|
1996
|
-
* Consumer-held signer (backend-orchestrated-deploy.md). Required for
|
|
1997
|
-
* `requirement: "deployed"` flows: `provision` reads `getAddress()` and the
|
|
1998
|
-
* deploy path signs the backend's SafeOp digest via `signUserOpHash()`. The
|
|
1999
|
-
* backend orchestrates build + gas + paymaster + submit — the client never
|
|
2000
|
-
* holds an RPC URL, a gas-sponsorship policy, or a bundler.
|
|
2001
|
-
*/
|
|
2002
|
-
readonly signer?: CapxulSigner;
|
|
2003
|
-
/**
|
|
2004
|
-
* Optional live Org-deploy lane (canon D10 SDK-orchestrated Org Safe deploy +
|
|
2005
|
-
* D3 RPC treasury). When supplied, `client.createOrg` / `org(id).treasury`
|
|
2006
|
-
* run the live path (real deploy + on-chain balance); when omitted, the
|
|
2007
|
-
* hermetic `$0` path runs (a fresh Org has no on-chain funds). The adapter
|
|
2008
|
-
* that CONSTRUCTS this port (deployer key + RPC + authenticated Convex seam)
|
|
2009
|
-
* is wired by the CLI deploy-stack; the factory only threads it through.
|
|
2010
|
-
*/
|
|
2011
|
-
readonly orgDeploymentPort?: OrgPort;
|
|
2012
|
-
/** Locked D6 data-port name. Prefer over `orgDeploymentPort` in new code. */
|
|
2013
|
-
readonly orgPort?: OrgPort;
|
|
2014
|
-
/** S2 deploy/grant/revoke port. S2 uses deploy; S3 adds grant/revoke. */
|
|
2015
|
-
readonly orgRolesDeploymentPort?: OrgRolesDeploymentPort;
|
|
2016
|
-
/** S4 treasury-spend authority + submit port. */
|
|
2017
|
-
readonly orgSpendPort?: OrgSpendPort;
|
|
2018
|
-
readonly orgDeploymentConfig?: SafeDeploymentConfig;
|
|
2019
|
-
}
|
|
2020
|
-
//#endregion
|
|
2021
8
|
//#region src/adapters/auth-cache/BrowserAuthCacheAdapter.d.ts
|
|
2022
9
|
interface BrowserStorageShape {
|
|
2023
10
|
getItem(key: string): string | null;
|
|
@@ -2043,7 +30,7 @@ declare function deriveDevPrivateKey(seed: string, email: string): Hex;
|
|
|
2043
30
|
*/
|
|
2044
31
|
declare function devPrivateKeySigner(input: DevPrivateKeySignerInput): CapxulSigner;
|
|
2045
32
|
//#endregion
|
|
2046
|
-
//#region src/
|
|
33
|
+
//#region src/ports/embedded-wallet.d.ts
|
|
2047
34
|
/**
|
|
2048
35
|
* Minimal Openfort embedded-wallet surface for hermetic tests and
|
|
2049
36
|
* `openfortEmbeddedSigner`. Keeps Convex / Shield secrets out of the SDK.
|
|
@@ -2100,6 +87,70 @@ declare function openfortEmbeddedSigner(input: OpenfortEmbeddedSignerInput): Ope
|
|
|
2100
87
|
*/
|
|
2101
88
|
declare const embeddedSigner: typeof openfortEmbeddedSigner;
|
|
2102
89
|
//#endregion
|
|
90
|
+
//#region ../observability/src/engineering.d.ts
|
|
91
|
+
type EngineeringProducer = "browser" | "server";
|
|
92
|
+
type EngineeringCapxulEnv = "development" | "e2e" | "staging" | "production";
|
|
93
|
+
interface EngineeringTelemetryConfig {
|
|
94
|
+
readonly host: string;
|
|
95
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
96
|
+
readonly capxulEnv: EngineeringCapxulEnv;
|
|
97
|
+
readonly producer: EngineeringProducer;
|
|
98
|
+
readonly sdkVersion: string;
|
|
99
|
+
readonly serviceName?: string;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/observation.d.ts
|
|
103
|
+
/** Host-owned correlation fields that are safe to attach to an SDK failure. */
|
|
104
|
+
interface ObservationContext extends Omit<WireObservationContext, "applicationId"> {}
|
|
105
|
+
/**
|
|
106
|
+
* The small, SDK-owned failure envelope delivered to observation adapters.
|
|
107
|
+
* Method arguments, response bodies, wallet payloads, and arbitrary error
|
|
108
|
+
* details are deliberately absent.
|
|
109
|
+
*/
|
|
110
|
+
interface SdkFailureObservation {
|
|
111
|
+
readonly exception: Error;
|
|
112
|
+
readonly sdkVersion: string;
|
|
113
|
+
readonly operation: string;
|
|
114
|
+
readonly errorKind: string;
|
|
115
|
+
/** Invocation snapshot; failure correlation wins over later host state. */
|
|
116
|
+
readonly context?: ObservationContext;
|
|
117
|
+
}
|
|
118
|
+
type ObservationDelivery = void | PromiseLike<void>;
|
|
119
|
+
/**
|
|
120
|
+
* High-level host observation boundary. The SDK owns when each method is
|
|
121
|
+
* called; the host owns the destination client, consent, and delivery policy.
|
|
122
|
+
*/
|
|
123
|
+
interface ObservationAdapter {
|
|
124
|
+
/**
|
|
125
|
+
* Optional read-only invocation context. Transport adapters snapshot it once
|
|
126
|
+
* at call start; implementations must not mutate global SDK state.
|
|
127
|
+
*/
|
|
128
|
+
readonly resolveContext?: () => ObservationContext | undefined;
|
|
129
|
+
/** A method returned the SDK's typed `{ ok: false, error }` result. */
|
|
130
|
+
captureOperationFailure(failure: SdkFailureObservation): ObservationDelivery;
|
|
131
|
+
/** A method unexpectedly threw or rejected instead of returning a typed result. */
|
|
132
|
+
captureException(exception: SdkFailureObservation): ObservationDelivery;
|
|
133
|
+
}
|
|
134
|
+
/** The host-owned PostHog capabilities consumed by the supported adapter. */
|
|
135
|
+
interface PostHogObservationClient {
|
|
136
|
+
capture(event: string, properties?: Readonly<Record<string, unknown>>): unknown;
|
|
137
|
+
/** Optional host capability; the supported adapter uses ordinary capture for slim clients. */
|
|
138
|
+
captureException?(exception: Error, properties?: Readonly<Record<string, unknown>>): unknown;
|
|
139
|
+
}
|
|
140
|
+
interface PostHogObservationOptions {
|
|
141
|
+
/** Consent / kill-switch seam. Defaults to enabled. */
|
|
142
|
+
readonly enabled?: boolean | (() => boolean);
|
|
143
|
+
/** Snapshotted at invocation start and resolved again for direct adapter capture. */
|
|
144
|
+
readonly context?: ObservationContext | (() => ObservationContext | undefined);
|
|
145
|
+
}
|
|
146
|
+
/** Stable PostHog event used for typed failures that are expected product outcomes. */
|
|
147
|
+
declare const CAPXUL_SDK_EXPECTED_OUTCOME_EVENT = "capxul_sdk_expected_outcome";
|
|
148
|
+
/**
|
|
149
|
+
* Adapt the host's already-initialized PostHog-like client. This function does
|
|
150
|
+
* not import, initialize, configure, or own PostHog.
|
|
151
|
+
*/
|
|
152
|
+
declare function fromPostHog(client: PostHogObservationClient | null | undefined, options?: PostHogObservationOptions): ObservationAdapter;
|
|
153
|
+
//#endregion
|
|
2103
154
|
//#region src/production.d.ts
|
|
2104
155
|
/**
|
|
2105
156
|
* Consumer-facing `createCapxulClient` input (SDK DX public surface · #326).
|
|
@@ -2108,6 +159,25 @@ declare const embeddedSigner: typeof openfortEmbeddedSigner;
|
|
|
2108
159
|
*/
|
|
2109
160
|
interface CapxulClientInput {
|
|
2110
161
|
readonly publishableKey: string;
|
|
162
|
+
/**
|
|
163
|
+
* Optional high-level observation adapter. The host supplies an adapter
|
|
164
|
+
* around its existing analytics client; Capxul never initializes or bundles
|
|
165
|
+
* another vendor SDK. Omit this property for zero observation work.
|
|
166
|
+
*/
|
|
167
|
+
readonly observation?: ObservationAdapter;
|
|
168
|
+
/**
|
|
169
|
+
* Optional host success-telemetry sink. Build it from your posthog-js client
|
|
170
|
+
* with `telemetryFromPostHog(posthog, …)`; events from SDK producers wired to
|
|
171
|
+
* this port then reach the host's PostHog person after the host calls
|
|
172
|
+
* `identify()`. Capxul never initializes or bundles a vendor SDK. Omit for no
|
|
173
|
+
* host telemetry.
|
|
174
|
+
*/
|
|
175
|
+
readonly telemetry?: TelemetryPort;
|
|
176
|
+
/**
|
|
177
|
+
* Optional engineering OTLP sink. The SDK supplies producer and version;
|
|
178
|
+
* the host supplies its environment, PostHog host, and receipt-safe headers.
|
|
179
|
+
*/
|
|
180
|
+
readonly engineeringTelemetry?: Omit<EngineeringTelemetryConfig, "producer" | "sdkVersion">;
|
|
2111
181
|
/**
|
|
2112
182
|
* Init-time account readiness target (issue #159 · AC4). Threaded into
|
|
2113
183
|
* `assembleCapxulClient` so `client.account.{getStatus,ensureReady}` reflect
|
|
@@ -2126,10 +196,39 @@ interface CapxulClientInput {
|
|
|
2126
196
|
readonly signer?: CapxulSigner;
|
|
2127
197
|
}
|
|
2128
198
|
//#endregion
|
|
2129
|
-
//#region src/
|
|
199
|
+
//#region src/surface/create-capxul-client-from-production.d.ts
|
|
2130
200
|
/** Consumer-facing factory — accepts only production-meaningful inputs (#326). */
|
|
2131
201
|
declare function createCapxulClient(input: CapxulClientInput): Promise<CapxulResult<CapxulClient>>;
|
|
2132
202
|
//#endregion
|
|
203
|
+
//#region src/telemetry/from-posthog.d.ts
|
|
204
|
+
/**
|
|
205
|
+
* The subset of a posthog-js client the seam calls. `identify` / `group` /
|
|
206
|
+
* `reset` are optional — a host that only wants event capture can omit them.
|
|
207
|
+
*/
|
|
208
|
+
interface PostHogTelemetryClient {
|
|
209
|
+
capture(event: string, properties?: Record<string, unknown>): unknown;
|
|
210
|
+
identify?(distinctId: string, properties?: Record<string, unknown>): unknown;
|
|
211
|
+
group?(groupType: string, groupKey: string, properties?: Record<string, unknown>): unknown;
|
|
212
|
+
reset?(): unknown;
|
|
213
|
+
}
|
|
214
|
+
interface PostHogTelemetryOptions {
|
|
215
|
+
/** Consent / kill-switch seam. Defaults to enabled. */
|
|
216
|
+
readonly enabled?: boolean | (() => boolean);
|
|
217
|
+
/** Host environment stamped on every SDK-owned product event. */
|
|
218
|
+
readonly capxulEnv?: CapxulEnv;
|
|
219
|
+
/** Host-owned correlation context, merged (sanitized) onto every captured event. */
|
|
220
|
+
readonly context?: ObservationContext | (() => ObservationContext | undefined);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Adapt the host's already-initialized posthog-like client into a
|
|
224
|
+
* `TelemetryPort` for the `telemetry` prop / input. This port SUPPLANTS the
|
|
225
|
+
* SDK's no-op default telemetry sink (`production.ts` binds it via
|
|
226
|
+
* `Layer.succeed`, not `compose` — there is no client-side success relay to
|
|
227
|
+
* compose with); it is additive to Capxul's backend first-party record and
|
|
228
|
+
* never owns the client.
|
|
229
|
+
*/
|
|
230
|
+
declare function telemetryFromPostHog(client: PostHogTelemetryClient | null | undefined, options?: PostHogTelemetryOptions): TelemetryPort;
|
|
231
|
+
//#endregion
|
|
2133
232
|
//#region src/telemetry/capture-exception.d.ts
|
|
2134
233
|
interface HandledErrorReportContext {
|
|
2135
234
|
readonly layer?: string;
|
|
@@ -2157,5 +256,5 @@ declare function captureException(telemetry: TelemetryPort, error: unknown, cont
|
|
|
2157
256
|
*/
|
|
2158
257
|
declare function captureExceptionSync(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): void;
|
|
2159
258
|
//#endregion
|
|
2160
|
-
export { type Account, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type Address, type AssignRoleInput, type AuthMethods, type AuthSession, type AuthUserId, type CapxulClient, type CapxulClientInput, type
|
|
259
|
+
export { type Account, type AccountId, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type ActivityItem, type ActivityListParams, type ActivityMethods, type ActivityPage, type ActorProfile, type ActorProfileMethods, type ActorReference, type ActorRelationshipMethods, type ActorRequest, type ActorRequestIssueInput, type ActorRequestsMethods, type Address, type AddressBookAddInput, type AddressBookEntry, type AddressBookLabelInput, type AddressBookMethods, type AssignRoleInput, type AuthMethods, type AuthSession, type AuthUserId, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, type CapxulClient, type CapxulClientInput, type CapxulDigestSigner, CapxulError, type CapxulErrorCode, type CapxulErrorDetails, type CapxulResult, type CapxulSigner, type CountryCode, type CreateCapxulClientInput, type CreateOrgInput, type CurrentUserContext, type CurrentUserMethods, type DepositInstructions, type Destination, type DestinationAddInput, type DestinationKind, type DestinationListInput, type DestinationPayload, type DestinationRail, type DestinationRemoveInput, type DestinationsMethods, type DetectPendingOrgInvitationsResult, type DevPrivateKeySignerInput, type Eip1193Provider, type Eip1193RequestProvider, type FinancialOpsMethods, type HandledErrorReportContext, type HandlesMethods, type Destination$1 as IdentityDestination, type IdentityEvent, type IdentityMethods, type IdentityProfileDetails, type IdentityRuntime, type IdentityRuntimeSendResult, type IdentityState, type IdentityTransition, type InboxApproveInput, type InboxItem, type InboxMethods, type InsightsMethods, type InsightsSummary, type InviteMemberInput, type InvocationControls, type MeMethods, type MeProfile, type MediaMethods, type MemberStatus, type MemberView, type Money, type ObservationAdapter, type ObservationContext, type ObservationDelivery, type OfframpMethods, type OfframpQuote, type OfframpQuoteInput, type OfframpStatus, type OpenfortEmbeddedSignerInput, type OpenfortEmbeddedWalletApi, type OpenfortEmbeddedWalletPort, type OrgBatchPayrollInput, type OrgId, type OrgLane, type OrgLifecycle, type OrgMethods, type OrgPayrollRun, type OrgScopedMethods, type OrgSetupStep, type OrgSpendViaPaymentsInput, type OrgTemplate, type OrgView, type OrganizationAccount, type OrganizationAuditLogItem, type Payee, type PayeesMethods, type Payment, type PaymentDocumentKind, type PaymentDocumentRef, type PaymentDocumentRender, type PaymentDocumentVerification, type PaymentDocumentsMethods, type PaymentMoney, type PaymentSettlementInput, type PaymentStatus, type PaymentTiming, type PaymentType, type PaymentsMethods, type PaymentsPayInput, type PaymentsPayoutInput, type PaymentsWithdrawInput, type PayrollMethods, type PayrollPayslipTemplate, type PayrollRosterAddInput, type PayrollRosterLine, type PayrollRunInput, type PostHogObservationClient, type PostHogObservationOptions, type PostHogTelemetryClient, type PostHogTelemetryOptions, type Profile, type Readiness, type RecipientResolution, type RecipientResolutionKind, type ReconciliationEntry, type Ref, type RemoveMemberInput, type ResendInviteTokenInput, type ResolvedTarget, type RoleDefinition, type RoleKey, type RoleSpendCap, type RoleView, type SdkFailureObservation, type Session, type SmartAccount, type SmartAccountMethods, type StateLabel, type SubAccount, type SubAccountId, type SubAccountsMethods, type SystemHealth, type SystemMethods, type TargetReference, type TargetsMethods, type TelemetryPort, type TransferEndpoint, type TransferInput, type TransferResult, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, fromPostHog, injectedWalletSigner, isCapxulError, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort, destination as resolveIdentityDestination, telemetryFromPostHog, toCountryCode, toAddress as toEvmAddress };
|
|
2161
260
|
//# sourceMappingURL=index.d.mts.map
|