@capxul/sdk 0.0.0-rc-2cdddbb91

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.
@@ -0,0 +1,151 @@
1
+ import { Ao as TelemetryIdentifyInput, Mo as TelemetryPortEvent, R as CapxulClient, T as OpenfortBrowserSignerOptions, Vo as ObservationAdapter, Xo as CapxulResult, at as IdentityTransition, ba as CapxulSigner, c as CapxulClientInput, jo as TelemetryEvent, ko as TelemetryGroupInput, ro as OrganizationSetup } from "../index-Czjrh-Fo.mjs";
2
+ import { Effect, Layer } from "effect";
3
+ //#region src/platform/production-client.d.ts
4
+ /** Per-client signing controls; only the testing entry exposes these to consumers. */
5
+ interface ProductionSignerControls {
6
+ /** Final signing call. Address, readiness and session lifecycle retain their real owner. */
7
+ readonly signUserOpHash?: (hash: Parameters<CapxulSigner["signUserOpHash"]>[0], signer: CapxulSigner & {
8
+ readonly resetSession?: () => void;
9
+ }) => ReturnType<CapxulSigner["signUserOpHash"]>;
10
+ /** Embedded signing calls, including the existing recovery owner's single retry. */
11
+ readonly signEmbeddedUserOpHash?: OpenfortBrowserSignerOptions["signUserOpHash"];
12
+ }
13
+ //#endregion
14
+ //#region src/testing/production-client.d.ts
15
+ /** Create the one production client with per-client controls at its signing boundaries. */
16
+ export declare function createCapxulProductionTestClient(input: CapxulClientInput, controls: ProductionSignerControls): Promise<CapxulResult<CapxulClient>>;
17
+ //#endregion
18
+ //#region src/testing/signer-faults.d.ts
19
+ /**
20
+ * Which provider refusal to inject. The codes are the ones the SDK's own
21
+ * classifiers decode (`src/signing/signer.ts`), so a fault reaches the public error
22
+ * contract through the real decode path rather than a shortcut.
23
+ *
24
+ * - `missing-signer` — Openfort's typed not-ready code. `openfortSignerNotReadyCode`
25
+ * decodes it, so the production recovery wrapper runs its single retry (A02).
26
+ * - `user-rejected` — the EIP-1193 4001 result. `signerFailure` decodes it to
27
+ * `SIGNER_REJECTED`, an expected refusal (A08).
28
+ * - `unexpected` — no provider code at all, so it stays an unexpected
29
+ * `PROVIDER_ERROR` (A09).
30
+ */
31
+ type SignerFaultKind = "missing-signer" | "user-rejected" | "unexpected";
32
+ /** The value a controlled fault throws. Named so a test can assert its origin. */
33
+ export declare class ControlledSignerFault extends Error {
34
+ readonly kind: SignerFaultKind;
35
+ /** Provider code the SDK classifiers read; absent for `unexpected`. */
36
+ readonly code: string | number | undefined;
37
+ constructor(kind: SignerFaultKind);
38
+ }
39
+ /** Build one fault value without the harness, for a caller that writes its own control. */
40
+ export declare function signerFaultCause(kind: SignerFaultKind): ControlledSignerFault;
41
+ interface SignerFaultPlan {
42
+ /**
43
+ * Fault the next embedded signature ONCE, beneath the production recovery
44
+ * wrapper, then delegate every later call to the real signer. The address
45
+ * read and the readiness cycle still run first, so the fault lands at the
46
+ * actual final signing boundary after the prepared-command equality checks.
47
+ */
48
+ readonly signOnce?: SignerFaultKind;
49
+ /**
50
+ * Call the production signer's own `resetSession()` ONCE, immediately before
51
+ * the next signature and after the command is prepared. The delegate then
52
+ * re-runs the real readiness cycle, so the configure request under test is
53
+ * the first one the browser observes after the `reset-session` record (A03).
54
+ *
55
+ * Throws when the composed signer owns no session — a silently skipped reset
56
+ * would leave the run looking green while proving nothing.
57
+ */
58
+ readonly resetSessionBeforeNextSign?: boolean;
59
+ }
60
+ /** What the seam did. JSON-serializable, so a browser test can read it back. */
61
+ interface SignerSeamRecord {
62
+ readonly boundary: "reset-session" | "embedded-sign";
63
+ /** 1-based count of calls at that boundary. */
64
+ readonly attempt: number;
65
+ readonly hash?: string;
66
+ /** Present only on the call that actually threw. */
67
+ readonly fault?: SignerFaultKind;
68
+ readonly atMs: number;
69
+ }
70
+ interface ArmedSignerSeam {
71
+ /** Hand these to `createCapxulProductionTestClient`. */
72
+ readonly controls: ProductionSignerControls;
73
+ /** Oldest first. Empty until the client reaches a signing boundary. */
74
+ readonly records: () => readonly SignerSeamRecord[];
75
+ /** True once every armed one-shot has fired. */
76
+ readonly spent: () => boolean;
77
+ }
78
+ /**
79
+ * Arm one-shot faults on the production embedded signer.
80
+ *
81
+ * ```ts
82
+ * const seam = armSignerFaults({ signOnce: "user-rejected" });
83
+ * const client = await createCapxulProductionTestClient(input, seam.controls);
84
+ * const result = await client.org(orgId).permissions.create(command);
85
+ * // result.error.code === "SIGNER_REJECTED"; nothing was submitted.
86
+ * // seam.records() names the boundary that refused.
87
+ * ```
88
+ *
89
+ * An empty plan installs no controls, which composes the ordinary client.
90
+ */
91
+ export declare function armSignerFaults(plan?: SignerFaultPlan): ArmedSignerSeam;
92
+ //#endregion
93
+ //#region src/testing/organization-setup.d.ts
94
+ /** Exact backend setup shape for SDK tests. */
95
+ export declare function organizationSetupFixture(orgId: string, status?: OrganizationSetup["status"], overrides?: Partial<OrganizationSetup>): OrganizationSetup;
96
+ //#endregion
97
+ //#region src/testing/telemetry/RecordingTelemetryAdapter.d.ts
98
+ type RecordingTelemetryOperation = {
99
+ readonly type: "emit";
100
+ readonly event: TelemetryPortEvent;
101
+ } | {
102
+ readonly type: "identify";
103
+ readonly input: TelemetryIdentifyInput;
104
+ } | {
105
+ readonly type: "group";
106
+ readonly input: TelemetryGroupInput;
107
+ } | {
108
+ readonly type: "reset";
109
+ };
110
+ //#endregion
111
+ //#region src/testing/index.d.ts
112
+ export interface CreateCapxulTestClientOptions {
113
+ readonly requirement?: "none" | "counterfactual" | "deployed";
114
+ /** Optional Core SDK failure adapter for packed consumer proofs. */
115
+ readonly failureObservation?: ObservationAdapter;
116
+ }
117
+ export interface SeedTestIdentityInput {
118
+ readonly authUserId: string;
119
+ readonly email: string;
120
+ readonly displayName?: string;
121
+ readonly country?: string;
122
+ }
123
+ export interface CapxulTestClient {
124
+ readonly client: CapxulClient;
125
+ readonly clock: CapxulTestClock;
126
+ readonly observation: CapxulTestObservation;
127
+ readonly transitions: readonly IdentityTransition[];
128
+ readonly observations: readonly RecordingTelemetryOperation[];
129
+ readonly peekOtp: (email: string) => string | undefined;
130
+ readonly seedIdentity: (input: SeedTestIdentityInput) => Promise<void>;
131
+ readonly organizationSetup: {
132
+ readonly set: (setup: OrganizationSetup) => void;
133
+ };
134
+ readonly close: () => Promise<void>;
135
+ }
136
+ export interface CapxulTestClock {
137
+ readonly advance: (ms: number) => Promise<void>;
138
+ }
139
+ export interface CapxulTestObservation {
140
+ readonly emit: (event: TelemetryEvent) => Promise<void>;
141
+ readonly identify: (input: TelemetryIdentifyInput) => Promise<void>;
142
+ readonly group: (input: TelemetryGroupInput) => Promise<void>;
143
+ readonly reset: () => Promise<void>;
144
+ }
145
+ /**
146
+ * Assemble the real public client over deterministic in-memory ports.
147
+ * Unconfigured backend calls fail locally; no adapter owns a network exit.
148
+ */
149
+ export declare function createCapxulTestClient(options?: CreateCapxulTestClientOptions): CapxulTestClient;
150
+ //#endregion
151
+ export type { ArmedSignerSeam, ProductionSignerControls, SignerFaultKind, SignerFaultPlan, SignerSeamRecord };