@capxul/sdk 4.20.0-beta.4 → 4.20.0-beta.40

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.
@@ -1,628 +0,0 @@
1
- import { Account, Address, Hex } from "viem";
2
- import { Context, Effect } from "effect";
3
- //#region ../errors/src/chain-cause.d.ts
4
- /**
5
- * Why an operation failed — the one flat vocabulary. The first four are the
6
- * auth/provider diagnoses that predate this file. The rest name the chain
7
- * path. `FailureMode` is derived from this list so a runtime membership check
8
- * (the SDK's `$exception` projection, the observability schema) and the type
9
- * can never drift apart.
10
- */
11
- declare const FAILURE_MODES: readonly [
12
- /** OTP cookies live on `localhost:PORT` but OpenFort hits the Convex host. */
13
- "auth-origin-mismatch",
14
- /** An old `userId` in scoped storage makes the SDK skip re-auth → 401. */
15
- "stale-openfort-cache",
16
- /** The selected app/deployment origin is not allowlisted → 401. */
17
- "app-env-allowlist",
18
- /** Sandboxed/headless browser with no Web Crypto. */
19
- "no-secure-context",
20
- /** The embedded wallet lost its configured signer state. */
21
- "signer-not-ready",
22
- /** One upstream answered HTTP 429 or JSON-RPC -32005. Retryable. */
23
- "rate-limited",
24
- /** No answer inside the budget. Retryable. */
25
- "timeout",
26
- /** HTTP 5xx, a connection failure, or a malformed envelope. Retryable. */
27
- "upstream-down",
28
- /** Simulation or execution reverted; `chain.revert` names it when decodable. */
29
- "revert",
30
- /** A balance pre-flight shortfall or a decoded `ERC20InsufficientBalance`. */
31
- "insufficient-balance",
32
- /** A decoded `ERC20InsufficientAllowance`. */
33
- "insufficient-allowance",
34
- /** The bundler's validation refused the operation (AA2x/AA3x); its text is carried. */
35
- "rejected",
36
- /** The upstream refused the credential (HTTP 401): the gateway token or a hosted node key. */
37
- "unauthorized",
38
- /** The upstream refused the key, origin, or method (HTTP 403). The next upstream's key may be fine. */
39
- "forbidden",
40
- /** The upstream refused the request shape (HTTP 400-family; JSON-RPC -32600, -32602, -32700). */
41
- "bad-request",
42
- /** The node does not serve the method (JSON-RPC -32601). The next upstream may. */
43
- "method-unsupported",
44
- /** No cause could be determined. */
45
- "unknown"];
46
- type FailureMode = (typeof FAILURE_MODES)[number];
47
- /** Who answered. `alto` is the bundler; `gateway` is the AA gateway's own logic. */
48
- declare const CHAIN_UPSTREAMS: readonly ["alchemy", "infura", "public", "alto", "gateway"];
49
- type ChainUpstream = (typeof CHAIN_UPSTREAMS)[number];
50
- /** A decoded revert. `name` is null when the selector is unknown or the data was empty. */
51
- type RevertSummary = {
52
- readonly name: string | null;
53
- readonly selector: string;
54
- readonly args: Readonly<Record<string, string>>;
55
- };
56
- /**
57
- * The structured cause of a chain-path failure. Built once by the layer that
58
- * saw the failure and passed on unchanged. `providerMessage` is the provider's
59
- * own words, bounded and secret-masked by the producer; it is evidence, never
60
- * something a consumer routes on.
61
- */
62
- type ChainCause = {
63
- readonly mode: FailureMode;
64
- readonly upstream: ChainUpstream;
65
- readonly method: string;
66
- readonly retryable: boolean;
67
- readonly httpStatus?: number;
68
- readonly rpcCode?: number;
69
- readonly revert?: RevertSummary;
70
- readonly providerMessage?: string;
71
- /**
72
- * Every upstream tried for this read, in order, ending with the one whose
73
- * answer this cause is (#1818). One `$exception` row then tells the whole
74
- * story of an exhausted chain; the recovered case stays an event.
75
- */
76
- readonly attempts?: readonly ChainAttempt[];
77
- /** The refusing upstream's allow-listed response headers, masked and bounded. */
78
- readonly responseHeaders?: Readonly<Record<string, string>>;
79
- };
80
- /** One upstream tried and the word for how it failed (#1818). */
81
- type ChainAttempt = {
82
- readonly upstream: ChainUpstream;
83
- readonly mode: FailureMode;
84
- readonly httpStatus?: number;
85
- readonly rpcCode?: number;
86
- readonly durationMs: number;
87
- };
88
- //#endregion
89
- //#region ../errors/src/errors.d.ts
90
- declare const CAPXUL_ERROR_CODES: readonly ["NOT_AUTHENTICATED", "EMAIL_DELIVERY_FAILED", "PROFILE_NOT_FOUND", "SMART_ACCOUNT_MISSING", "PLAYER_NOT_FOUND", "ACCOUNT_NOT_FOUND", "ACCOUNT_CLAIMED_BY_OTHER_SIGNER", "PROVIDER_ERROR", "CAPABILITY_UNAVAILABLE", "INVALID_INPUT", "ENV_MISSING", "NOT_IMPLEMENTED", "VERIFICATION_REQUIRED", "INSUFFICIENT_BALANCE", "INVALID_RECIPIENT", "ROLE_PERMISSION_DENIED", "TRANSACTION_FAILED", "RATE_LIMITED", "NETWORK_ERROR", "UNKNOWN", "OTP_EXPIRED", "SIGNER_REJECTED", "CANCELLED", "WRONG_STATE", "STALE_EPOCH", "SUPERSEDED", "WORK_DIED", "ACTOR_STOPPED"];
91
- type CapxulErrorCode = (typeof CAPXUL_ERROR_CODES)[number];
92
- /**
93
- * The one failure representation carried by domain state, actor work, and
94
- * public error projection. Keeping it beside the canonical error catalog
95
- * prevents a machine or shell from inventing a second code vocabulary.
96
- */
97
- interface Failure {
98
- readonly code: CapxulErrorCode;
99
- readonly message: string;
100
- readonly mode?: FailureMode;
101
- readonly error?: CapxulError;
102
- }
103
- type CapxulErrorDetails = Record<string, unknown>;
104
- type SignerSource = "openfort-embedded" | "injected-eip1193" | "local-private-key";
105
- type VerificationRequiredDetails = {
106
- readonly requiredTier: number;
107
- } | {
108
- readonly rail: string;
109
- readonly currentKind: string;
110
- };
111
- type CapxulErrorOptions = {
112
- readonly cause?: unknown;
113
- readonly details?: CapxulErrorDetails;
114
- readonly correlationId?: string;
115
- readonly layer?: string;
116
- readonly mode?: FailureMode;
117
- readonly chain?: ChainCause;
118
- };
119
- declare class CapxulError extends Error {
120
- readonly code: CapxulErrorCode;
121
- readonly details?: CapxulErrorDetails;
122
- readonly correlationId?: string;
123
- readonly layer?: string;
124
- /** The one-word cause (`FailureMode`). `chain.mode` when a chain cause is set. */
125
- readonly mode?: FailureMode;
126
- /** The structured chain-path cause. Never rewritten by a later layer. */
127
- readonly chain?: ChainCause;
128
- constructor(code: CapxulErrorCode, message: string, options?: CapxulErrorOptions);
129
- }
130
- declare function isCapxulError(value: unknown): value is CapxulError;
131
- type NetworkErrorOptions = {
132
- readonly provider?: string;
133
- readonly target_host?: string;
134
- readonly failure_mode?: FailureMode;
135
- readonly reason?: "connection-lost-in-flight";
136
- readonly connection_id?: string;
137
- readonly connection_count?: number;
138
- readonly connection_retries?: number;
139
- readonly close_code?: number;
140
- readonly close_was_clean?: boolean;
141
- readonly close_reason_present?: boolean;
142
- readonly document_visibility?: string;
143
- readonly navigator_online?: boolean;
144
- readonly last_browser_event?: string;
145
- readonly ms_since_browser_event?: number;
146
- };
147
- declare const Errors: {
148
- readonly notAuthenticated: (message?: string, opts?: {
149
- readonly failure_mode?: FailureMode;
150
- }) => CapxulError;
151
- readonly emailDeliveryFailed: (detail: string) => CapxulError;
152
- readonly profileNotFound: (authUserId: string) => CapxulError;
153
- readonly smartAccountMissing: (authUserId: string) => CapxulError;
154
- readonly playerNotFound: (playerId?: string) => CapxulError;
155
- readonly accountNotFound: (accountId?: string) => CapxulError;
156
- /**
157
- * The Safe at this email's address is deployed and its owner is neither the
158
- * Capxul bootstrap owner nor the caller's signer. The claim
159
- * `swapOwner(bootstrap → signer)` cannot succeed: only the on-chain owner
160
- * can hand the account over. Read from `getOwners()` before any
161
- * UserOperation is built (2026-09-02), so no simulation and no retry.
162
- */
163
- readonly accountClaimedByOtherSigner: (details: {
164
- readonly safeAddress: string;
165
- readonly onChainOwner: string;
166
- /** A bounded sample of the `getOwners()` answer, for a Safe that is not single-owner. */
167
- readonly owners?: readonly string[];
168
- /** The full size of that answer, when the sample is shorter. */
169
- readonly ownerCount?: number;
170
- readonly expectedOwner: string;
171
- readonly signerAddress: string;
172
- }) => CapxulError;
173
- readonly providerError: (provider: string, operation: string, cause: unknown, opts?: {
174
- readonly failure_mode?: FailureMode;
175
- readonly httpStatus?: number;
176
- /** Extra evidence for the operator (response body, edge error code). */
177
- readonly details?: Readonly<Record<string, unknown>>;
178
- /** The structured chain-path cause; sets `mode` and `details.failure_mode` too. */
179
- readonly chain?: ChainCause;
180
- }) => CapxulError;
181
- readonly capabilityUnavailable: (provider: string, operation: string) => CapxulError;
182
- readonly invalidInput: (field: string, reason: string) => CapxulError;
183
- readonly envMissing: (name: string) => CapxulError;
184
- readonly notImplemented: (domain: string, method: string) => CapxulError;
185
- /**
186
- * Sibling factory to {@link Errors.providerError} for the per-state timeout
187
- * path in flows. Same `PROVIDER_ERROR` code as
188
- * `providerError`, plus a `details.reason: "timeout"` discriminator so
189
- * downstream observers can distinguish failure modes without parsing the
190
- * message string. The redacted message names the timeout budget; the
191
- * native `cause` carries the same information for `reportError` fidelity.
192
- */
193
- readonly providerTimeout: (provider: string, operation: string, timeoutMs: number) => CapxulError;
194
- readonly verificationRequired: (details: VerificationRequiredDetails) => CapxulError;
195
- readonly insufficientBalance: (asset: string, available: string, required: string) => CapxulError;
196
- readonly invalidRecipient: (reason: string) => CapxulError;
197
- /**
198
- * The org Zodiac Roles modifier REFUSED the spend on-chain (G4 · #547): the
199
- * member's role condition (per-tx cap, per-day allowance, allowed recipient,
200
- * or membership) was violated, so `execTransactionWithRole` reverted. This is
201
- * a PERMISSION denial — explicitly NOT an `INSUFFICIENT_BALANCE` (the treasury
202
- * held the funds; the role's authority is what bound). `reason` discriminates
203
- * the violated condition (`over_cap` / `daily_cap` / `not_member` /
204
- * `disallowed_recipient` / `condition_violation`); leak-safe — no on-chain
205
- * identifiers ever enter the details.
206
- */
207
- readonly rolePermissionDenied: (details: {
208
- readonly reason: "over_cap" | "daily_cap" | "not_member" | "disallowed_recipient" | "condition_violation";
209
- readonly operation?: string;
210
- }) => CapxulError;
211
- /**
212
- * A transaction (or sponsored UserOp) failed. `details.reason` discriminates
213
- * the failure mode for callers that must distinguish a CONFIRMED on-chain
214
- * revert (`"onchain_revert"` — the op executed and reverted, e.g. a Zodiac
215
- * Roles condition violation) from an inconclusive infra failure. A confirmed
216
- * revert is the ONLY mode the org spend port may map to a roles denial.
217
- */
218
- readonly transactionFailed: (operation: string, cause?: unknown, extra?: {
219
- readonly reason?: string;
220
- }) => CapxulError;
221
- readonly rateLimited: (details?: {
222
- readonly retryAfterMs?: number;
223
- readonly resource?: string;
224
- }) => CapxulError;
225
- readonly networkError: (operation: string, cause?: unknown, opts?: NetworkErrorOptions) => CapxulError;
226
- readonly unknown: (cause?: unknown) => CapxulError;
227
- readonly otpExpired: (details?: {
228
- readonly email?: string;
229
- readonly expiredAt?: number;
230
- }) => CapxulError;
231
- readonly signerRejected: (details: {
232
- readonly source: SignerSource;
233
- readonly reason?: string;
234
- readonly cause?: unknown;
235
- }) => CapxulError;
236
- readonly superseded: (details: {
237
- readonly operation: string;
238
- readonly reason: string;
239
- readonly executionId?: string;
240
- }) => CapxulError;
241
- readonly cancelled: (details?: {
242
- readonly operation?: string;
243
- readonly reason?: string;
244
- }) => CapxulError;
245
- /**
246
- * Method called from a flow state where its precondition fails (TA16). The
247
- * SDK's method API short-circuits with this error before driving the
248
- * internal state machine. `currentState` is the Effect-machine snapshot
249
- * tag (stringified from the SDK's actor-shell snapshot; see
250
- * `packages/errors/CONTEXT.md`); `validStates`
251
- * enumerates the states the method accepts.
252
- */
253
- readonly wrongState: (details: {
254
- readonly method: string;
255
- readonly currentState: string;
256
- readonly validStates: readonly string[];
257
- }) => CapxulError;
258
- };
259
- //#endregion
260
- //#region ../types/src/brand.d.ts
261
- /**
262
- * Nominal type helper. `Brand<T, B>` is structurally a `T` at runtime but
263
- * distinct at compile time, preventing accidental swaps between primitives.
264
- *
265
- * @internal
266
- */
267
- declare const brand: unique symbol;
268
- type Brand<T, B extends string> = T & {
269
- readonly [brand]: B;
270
- };
271
- //#endregion
272
- //#region ../types/src/index.d.ts
273
- type Address$1 = Brand<string, "Address">;
274
- /** Canonical ERC-20 CAIP-19 identity. Currency is not asset identity. */
275
- type AssetId = Brand<string, "AssetId">;
276
- /** One asset quantity in major units. Registry metadata supplies precision. */
277
- type AssetAmount = {
278
- readonly asset: AssetId;
279
- readonly value: string;
280
- };
281
- type Email = Brand<string, "Email">;
282
- type TesterKind = "human" | "e2e" | "agent";
283
- type Profile$1 = {
284
- readonly testerKind?: TesterKind;
285
- readonly authUserId: AuthUserId;
286
- readonly email: Email;
287
- readonly displayName: string | null;
288
- readonly country: CountryCode | null;
289
- readonly onboarded: boolean;
290
- readonly withdrawalAddress: Address$1 | null;
291
- readonly handle: Handle | null;
292
- readonly imageUrl: string | null;
293
- readonly kycTier: KycTier;
294
- readonly createdAt: EpochMs;
295
- readonly updatedAt: EpochMs;
296
- };
297
- type SmartAccount$1 = {
298
- readonly authUserId: AuthUserId;
299
- readonly signerAddress: Address$1 | null;
300
- readonly smartAccountAddress: Address$1;
301
- readonly chainId: ChainId;
302
- readonly deployedAt: EpochMs | null;
303
- readonly claimedAt: EpochMs | null;
304
- readonly createdAt: EpochMs;
305
- };
306
- type Money = {
307
- readonly currency: CurrencyCode;
308
- readonly value: string;
309
- readonly decimals: number;
310
- };
311
- type Account$1 = {
312
- readonly id: AccountId;
313
- readonly balance: Money;
314
- readonly available: Money;
315
- };
316
- type AuthUserId = Brand<string, "AuthUserId">;
317
- type AnonymousDistinctId = Brand<string, "AnonymousDistinctId">;
318
- type AccountId = Brand<string, "AccountId">;
319
- type PartyId = Brand<string, "PartyId">;
320
- /** One globally unique public name for a claimed person or Organization Party. */
321
- type Handle = Brand<string, "Handle">;
322
- type PermissionId = Brand<string, "PermissionId">;
323
- type PermissionAssignmentId = Brand<string, "PermissionAssignmentId">;
324
- type BudgetId = Brand<string, "BudgetId">;
325
- type PaymentCommandId = Brand<string, "PaymentCommandId">;
326
- type PayrollRunId = Brand<string, "PayrollRunId">;
327
- type PayrollGroupId = Brand<string, "PayrollGroupId">;
328
- type OrgId = Brand<string, "OrgId">;
329
- type AppId = Brand<string, "AppId">;
330
- type AllowedOrigin = Brand<string, "AllowedOrigin">;
331
- type PublishableKey = Brand<string, "PublishableKey">;
332
- type DurationMs = Brand<number, "DurationMs">;
333
- type TxHash = Brand<string, "TxHash">;
334
- type DocumentHash = Brand<string, "DocumentHash">;
335
- type EpochMs = Brand<number, "EpochMs">;
336
- type EpochSeconds = Brand<number, "EpochSeconds">;
337
- type ChainId = Brand<number, "ChainId">;
338
- type CountryCode = Brand<string, "CountryCode">;
339
- type CurrencyCode = Brand<SupportedCurrencyCode, "CurrencyCode">;
340
- type KycTier = Brand<0 | 1 | 2 | 3, "KycTier">;
341
- type BlockNumber = Brand<number, "BlockNumber">;
342
- type WeiAmount = Brand<string, "WeiAmount">;
343
- type RoleKey = Brand<string, "RoleKey">;
344
- type AllowanceKey = Brand<string, "AllowanceKey">;
345
- type SessionToken = Brand<string, "SessionToken">;
346
- type JwtToken = Brand<string, "JwtToken">;
347
- type AuthSession = {
348
- readonly authUserId: AuthUserId;
349
- readonly email: Email;
350
- readonly token: SessionToken;
351
- readonly expiresAt: EpochMs;
352
- };
353
- declare const EVM_ADDRESS_RE: RegExp;
354
- declare const SUPPORTED_CURRENCIES: readonly [{
355
- readonly code: "USD";
356
- readonly symbol: "$";
357
- readonly name: "US Dollar";
358
- }, {
359
- readonly code: "NGN";
360
- readonly symbol: "NGN";
361
- readonly name: "Nigerian Naira";
362
- }, {
363
- readonly code: "GHS";
364
- readonly symbol: "GHS";
365
- readonly name: "Ghanaian Cedi";
366
- }, {
367
- readonly code: "KES";
368
- readonly symbol: "KSh";
369
- readonly name: "Kenyan Shilling";
370
- }, {
371
- readonly code: "UGX";
372
- readonly symbol: "USh";
373
- readonly name: "Ugandan Shilling";
374
- }];
375
- type SupportedCurrencyCode = (typeof SUPPORTED_CURRENCIES)[number]["code"];
376
- declare function toAddress(raw: unknown): Address$1;
377
- declare function toPartyId(raw: unknown): PartyId;
378
- declare function toHandle(raw: unknown): Handle;
379
- declare function toCountryCode(raw: unknown): CountryCode;
380
- //#endregion
381
- //#region ../config/src/capxul-payments-v2.d.ts
382
- /** Immutable CapxulPaymentsV2 deployment on Base Sepolia. */
383
- declare const CAPXUL_PAYMENTS_V2_ADDRESS: Address;
384
- //#endregion
385
- //#region src/ports/auth-cache.d.ts
386
- /**
387
- * AuthCachePort stores the user session and the cached
388
- * Convex JWT. The two slots are independent. A session refresh does not
389
- * invalidate the JWT.
390
- *
391
- * Three adapters implement this port:
392
- * - `BrowserAuthCacheAdapter` — backed by `localStorage`
393
- * - `FileSystemAuthCacheAdapter` — mode-0600 JSON file in `~/.config/capxul/`
394
- * - `InMemoryAuthCacheAdapter` — for tests
395
- *
396
- * Session and JWT persistence share this cache boundary.
397
- */
398
- interface AuthCachePort {
399
- readonly getSession: Effect.Effect<AuthSession | null, AuthCacheError>;
400
- readonly setSession: (session: AuthSession) => Effect.Effect<void, AuthCacheError>;
401
- readonly clearSession: Effect.Effect<void, AuthCacheError>;
402
- /**
403
- * JWT cache for the `/api/auth/convex/token` bridge endpoint.
404
- * Stored separately from the session so a session refresh does not
405
- * invalidate cached JWT.
406
- */
407
- readonly getJwt: Effect.Effect<CachedJwt | null, AuthCacheError>;
408
- readonly setJwt: (jwt: CachedJwt) => Effect.Effect<void, AuthCacheError>;
409
- readonly clearJwt: Effect.Effect<void, AuthCacheError>;
410
- }
411
- /**
412
- * Cached Convex JWT shape. `expEpochSeconds` is decoded from the JWT's
413
- * `exp` claim at fetch time so the `tokenProvider` cache eviction logic can
414
- * refresh at `exp - 30s`.
415
- */
416
- interface CachedJwt {
417
- readonly token: JwtToken;
418
- readonly expEpochSeconds: EpochSeconds;
419
- }
420
- declare const AuthCacheError_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 & {
421
- readonly _tag: "AuthCacheError";
422
- } & Readonly<A>;
423
- declare class AuthCacheError extends AuthCacheError_base<{
424
- readonly operation: string;
425
- readonly cause: unknown;
426
- }> {}
427
- declare const AuthCachePortTag_base: Context.ServiceClass<AuthCachePortTag, "@capxul/sdk/ports/AuthCachePort", AuthCachePort>;
428
- declare class AuthCachePortTag extends AuthCachePortTag_base {}
429
- //#endregion
430
- //#region src/ports/auth-client.d.ts
431
- type AuthClientOperationOptions = {
432
- readonly signal?: AbortSignal;
433
- };
434
- type SendOtpInput = {
435
- readonly email: Email;
436
- };
437
- type CanSendOtpInput = {
438
- readonly email: Email;
439
- };
440
- type CanSendOtpStatus = {
441
- readonly allowed: boolean;
442
- readonly cooldownMs: DurationMs;
443
- };
444
- type VerifyOtpInput = {
445
- readonly email: Email;
446
- readonly otp: string;
447
- };
448
- type GetConvexJwtOptions = AuthClientOperationOptions & {
449
- readonly forceRefresh?: boolean;
450
- };
451
- 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 & {
452
- readonly _tag: "AuthClientError";
453
- } & Readonly<A>;
454
- declare class AuthClientError extends AuthClientError_base<{
455
- readonly operation: string;
456
- readonly kind: string;
457
- readonly cause: unknown;
458
- }> {}
459
- interface AuthClientPort {
460
- canSendOtp(input: CanSendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<CanSendOtpStatus, AuthClientError>;
461
- sendOtp(input: SendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
462
- verifyOtp(input: VerifyOtpInput, options?: AuthClientOperationOptions): Effect.Effect<AuthSession, AuthClientError>;
463
- getSession(options?: AuthClientOperationOptions): Effect.Effect<AuthSession | null, AuthClientError>;
464
- signOut(options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
465
- /**
466
- * Fetches a Convex-aud JWT from `/api/auth/convex/token` (W7). Server mints
467
- * a fresh JWT on every call per Probe A's 2026-05-19 finding (RS256, 900 s
468
- * lifetime, `iss = <site-url>`, `aud = convex`). The caller (the SDK's
469
- * `tokenProvider` wired into ConvexCallPort) is responsible for the
470
- * `exp - 30s` proactive cache + `forceRefresh` callback handshake.
471
- */
472
- getConvexJwt(options?: GetConvexJwtOptions): Effect.Effect<CachedJwt, AuthClientError>;
473
- }
474
- //#endregion
475
- //#region src/ports/clock.d.ts
476
- interface ClockPort {
477
- readonly now: Effect.Effect<EpochMs, ClockError>;
478
- readonly sleep: (duration: DurationMs) => Effect.Effect<void, ClockError>;
479
- }
480
- 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 & {
481
- readonly _tag: "ClockError";
482
- } & Readonly<A>;
483
- declare class ClockError extends ClockError_base<{
484
- readonly operation: "now" | "sleep" | "initialize";
485
- readonly cause: unknown;
486
- }> {}
487
- //#endregion
488
- //#region src/surface/types.d.ts
489
- type Session = AuthSession;
490
- type Profile = Profile$1;
491
- type SmartAccount = SmartAccount$1;
492
- /**
493
- * Result-shape returned by every method on `CapxulClient`. Mirrors the
494
- * existing per-port `Result` aliases; centralized here so consumers have
495
- * a single import for the consumer-facing surface.
496
- */
497
- type CapxulResult<T> = {
498
- readonly ok: true;
499
- readonly value: T;
500
- } | {
501
- readonly ok: false;
502
- readonly error: CapxulError;
503
- };
504
- //#endregion
505
- //#region src/surface/account-providers.d.ts
506
- type AccountProviderSource = "local-private-key" | "openfort-embedded" | "injected-eip1193";
507
- type AccountRequirement = "none" | "counterfactual" | "deployed";
508
- interface AccountProvider {
509
- readonly source: AccountProviderSource;
510
- /**
511
- * Resolve the signer's EVM address.
512
- *
513
- * @determinism MUST return the same `Address` across calls for the
514
- * lifetime of a single provider instance — the SDK-level deploy mutex
515
- * keys on `(authUserId, safeAddress)` where `safeAddress` is computed
516
- * from `getAddress()`'s result before the port's `prepare()` round-trip.
517
- * If two successive calls returned different addresses, concurrent
518
- * `deploySafe` invocations would compute different mutex keys and
519
- * bypass dedup, defeating the mutex.
520
- *
521
- * The two sanctioned providers both satisfy this invariant:
522
- * - `localPrivateKeyAccountProvider` — derives once from the key
523
- * - `eip1193AccountProvider` — reads `eth_accounts` (idempotent once
524
- * the wallet is connected; consumer is responsible for connection)
525
- *
526
- * The Openfort embedded path no longer needs a provider: the
527
- * `openfortEmbeddedSigner` `CapxulSigner` caches its own address and the
528
- * deploy is backend-orchestrated (backend-orchestrated-deploy.md).
529
- *
530
- * Custom providers MUST honor this contract.
531
- */
532
- getAddress(): Promise<CapxulResult<Address$1>>;
533
- getDeployAccount(): Promise<CapxulResult<Account>>;
534
- }
535
- interface Eip1193Provider {
536
- request(args: {
537
- readonly method: string;
538
- readonly params?: readonly unknown[];
539
- }): Promise<unknown>;
540
- }
541
- declare function localPrivateKeyAccountProvider(input: {
542
- readonly privateKey: Hex;
543
- }): AccountProvider;
544
- declare function eip1193AccountProvider(input: {
545
- readonly provider: Eip1193Provider;
546
- }): AccountProvider;
547
- //#endregion
548
- //#region src/signer.d.ts
549
- interface CapxulDigestSigner {
550
- /**
551
- * Sign the EIP-712 `SafeOp` digest the backend returns for the prepared
552
- * deployment UserOperation. Returns the raw 65-byte ECDSA signature; the
553
- * backend packs `validAfter|validUntil|signature`.
554
- */
555
- signUserOpHash(hash: Hex): Promise<Hex>;
556
- }
557
- interface CapxulSigner extends CapxulDigestSigner {
558
- /**
559
- * Signer kind — surfaced on the `accountProviderReady` status so the
560
- * readiness ladder reports which signer the consumer wired.
561
- */
562
- readonly source: AccountProviderSource;
563
- /** Owner EOA address — the Safe's single owner. */
564
- getAddress(): Promise<Address$1>;
565
- /**
566
- * Readiness this signer reports, when it runs a readiness cycle at all. Only
567
- * the Openfort browser signer does. `assembleCapxulClient` reads it onto
568
- * `client.signer`, and substitutes `UNOBSERVABLE_SIGNER_STATUS` when absent.
569
- */
570
- readonly statusStore?: SignerStatusStore;
571
- /**
572
- * Start this signer's readiness cycle, or join the one already running,
573
- * without signing anything. `assembleCapxulClient` calls it when the
574
- * identity is claimed, so the status converges on `ready` or `unavailable`
575
- * on its own (#1667). A signer that runs no cycle omits this, and keeps
576
- * reporting `unknown`.
577
- */
578
- readonly ensureWalletReady?: () => Promise<void>;
579
- }
580
- /**
581
- * Observable signer readiness (ACCESS #1520 · C12). `unknown` means the
582
- * wallet-ready cycle did not start. `recovering` means it is running; the
583
- * stale-cache heal runs inside that phase. `ready` means the signer can sign.
584
- * `unavailable` means the cycle failed. A failure is distinguishable from a
585
- * cycle that never started. That is why there are four states.
586
- */
587
- type SignerStatus = "unknown" | "recovering" | "ready" | "unavailable";
588
- /** Subscribable readiness surface. Assembled onto `client.signer`. */
589
- interface SignerStatusStore {
590
- /** The current status. */
591
- status(): SignerStatus;
592
- /** Fires on every change. Returns its own unsubscribe. */
593
- subscribe(listener: (status: SignerStatus) => void): () => void;
594
- }
595
- /** Minimal EIP-1193 surface an injected browser wallet exposes. */
596
- interface Eip1193RequestProvider {
597
- request(args: {
598
- readonly method: string;
599
- readonly params?: readonly unknown[];
600
- }): Promise<unknown>;
601
- }
602
- /**
603
- * Browser `CapxulSigner` backed by an injected EIP-1193 wallet (MetaMask, etc.).
604
- * Signs the SafeOp digest via `eth_sign`, then verifies the returned signature
605
- * recovers the selected account against that raw digest. Wallets that prefix
606
- * `eth_sign` payloads are rejected before the backend submits an invalid SafeOp.
607
- * The node key signer lives in `@capxul/sdk/node` (`localPrivateKeySigner`).
608
- */
609
- declare function injectedWalletSigner(provider: Eip1193RequestProvider): CapxulSigner;
610
- //#endregion
611
- //#region src/adapters/auth-client/OAuthBearerAuthClient.d.ts
612
- interface OAuthBearerAuthClientInput {
613
- /** The exchange endpoint: `{authBaseUrl}/api/auth/agent/exchange`. */
614
- readonly exchangeUrl: string;
615
- /** The shared secret the exchange endpoint checks. The caller holds it. */
616
- readonly exchangeSecret: string;
617
- /** The agent's OAuth access token. */
618
- readonly accessToken: string;
619
- readonly fetch?: typeof fetch;
620
- readonly clock?: ClockPort;
621
- }
622
- /**
623
- * `AuthClientPort` over the backend agent-token exchange. Build one per OAuth
624
- * access token and hand it to `createCapxulClient({ authClient })`.
625
- */
626
- declare function oauthBearerAuthClient(input: OAuthBearerAuthClientInput): AuthClientPort;
627
- //#endregion
628
- export { PayrollGroupId as $, AllowanceKey as A, ChainId as B, AuthCachePort as C, ChainCause as Ct, Account$1 as D, RevertSummary as Dt, CAPXUL_PAYMENTS_V2_ADDRESS as E, FailureMode as Et, AssetId as F, EVM_ADDRESS_RE as G, CurrencyCode as H, AuthSession as I, Handle as J, Email as K, AuthUserId as L, AnonymousDistinctId as M, AppId as N, AccountId as O, AssetAmount as P, PaymentCommandId as Q, BlockNumber as R, AuthCacheError as S, CHAIN_UPSTREAMS as St, CachedJwt as T, FAILURE_MODES as Tt, DocumentHash as U, CountryCode as V, DurationMs as W, OrgId as X, Money as Y, PartyId as Z, Session as _, CapxulErrorCode as _t, Eip1193RequestProvider as a, RoleKey as at, AuthClientPort as b, Failure as bt, injectedWalletSigner as c, TesterKind as ct, AccountRequirement as d, toAddress as dt, PayrollRunId as et, Eip1193Provider as f, toCountryCode as ft, Profile as g, CapxulError as gt, CapxulResult as h, CAPXUL_ERROR_CODES as ht, CapxulSigner as i, PublishableKey as it, AllowedOrigin as j, Address$1 as k, AccountProvider as l, TxHash as lt, localPrivateKeyAccountProvider as m, toPartyId as mt, oauthBearerAuthClient as n, PermissionId as nt, SignerStatus as o, SessionToken as ot, eip1193AccountProvider as p, toHandle as pt, EpochMs as q, CapxulDigestSigner as r, Profile$1 as rt, SignerStatusStore as s, SmartAccount$1 as st, OAuthBearerAuthClientInput as t, PermissionAssignmentId as tt, AccountProviderSource as u, WeiAmount as ut, SmartAccount as v, CapxulErrorDetails as vt, AuthCachePortTag as w, ChainUpstream as wt, CanSendOtpStatus as x, isCapxulError as xt, ClockPort as y, Errors as yt, BudgetId as z };