@capxul/sdk-react 1.2.0 → 1.2.1
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 +4 -1
- package/dist/{controllers-BU11km12.mjs → controllers-CbZCgTGu.mjs} +50 -15
- package/dist/controllers-CbZCgTGu.mjs.map +1 -0
- package/dist/{controllers-DuHYSiw1.d.mts → controllers-D3_Q5d2t.d.mts} +2 -1
- package/dist/{controllers-DuHYSiw1.d.mts.map → controllers-D3_Q5d2t.d.mts.map} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/controllers-BU11km12.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -25,7 +25,10 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
|
25
25
|
- `useCapxulSend` carries caller-owned invocation controls to that actor.
|
|
26
26
|
- `useCapxulAuth` is the stable six-verb application facade.
|
|
27
27
|
- `CapxulAuthenticationController` and `CapxulOnboardingController` select
|
|
28
|
-
app-owned slots and render no SDK-owned DOM.
|
|
28
|
+
app-owned slots and render no SDK-owned DOM. Supplying the onboarding
|
|
29
|
+
controller's `recoveryOptions` factory lets a fresh actor resume account
|
|
30
|
+
prerequisites before the stored Organization replay; a failed prerequisite
|
|
31
|
+
returns the same manual replay instead of looping.
|
|
29
32
|
- Rich-data hooks such as `useCapxulProfile`, `useCapxulOrgs`, members, roles,
|
|
30
33
|
treasury, and money hooks remain TanStack Query projections.
|
|
31
34
|
|
|
@@ -169,6 +169,22 @@ function createAuth(client, clearAuthenticatedQueries) {
|
|
|
169
169
|
const result = await runtime.completeProfile(profile, invocation);
|
|
170
170
|
return result.ok ? { ok: true } : result;
|
|
171
171
|
};
|
|
172
|
+
const prepareOrganization = async (submission, invocation) => {
|
|
173
|
+
const organization = normalizeOrganization(submission.organization);
|
|
174
|
+
if (organization === null) return {
|
|
175
|
+
ok: false,
|
|
176
|
+
reason: "INVALID_INPUT"
|
|
177
|
+
};
|
|
178
|
+
const completed = await completeProfile(submission.profileDetails, invocation);
|
|
179
|
+
if (!completed.ok) return completed;
|
|
180
|
+
const refreshed = await read(invocation);
|
|
181
|
+
if (!refreshed.ok) return refreshed;
|
|
182
|
+
const claimed = await reachClaimed(invocation);
|
|
183
|
+
return claimed.ok ? {
|
|
184
|
+
ok: true,
|
|
185
|
+
organization
|
|
186
|
+
} : claimed;
|
|
187
|
+
};
|
|
172
188
|
return {
|
|
173
189
|
requestCode: (email, options) => guarded(runtime, "requestCode", options, async (invocation) => {
|
|
174
190
|
const result = await client.auth.signIn({ email }, invocation);
|
|
@@ -232,20 +248,11 @@ function createAuth(client, clearAuthenticatedQueries) {
|
|
|
232
248
|
return ensureAccount(invocation);
|
|
233
249
|
}),
|
|
234
250
|
createOrganization: (submission, options) => guarded(runtime, "createOrganization", options, async (invocation) => {
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
ok: false,
|
|
238
|
-
reason: "INVALID_INPUT"
|
|
239
|
-
};
|
|
240
|
-
const completed = await completeProfile(submission.profileDetails, invocation);
|
|
241
|
-
if (!completed.ok) return completed;
|
|
242
|
-
const refreshed = await read(invocation);
|
|
243
|
-
if (!refreshed.ok) return refreshed;
|
|
244
|
-
const claimed = await reachClaimed(invocation);
|
|
245
|
-
if (!claimed.ok) return claimed;
|
|
251
|
+
const prepared = await prepareOrganization(submission, invocation);
|
|
252
|
+
if (!prepared.ok) return prepared;
|
|
246
253
|
const created = await runtime.send({
|
|
247
254
|
_tag: "CreateOrganization",
|
|
248
|
-
draft: organization
|
|
255
|
+
draft: prepared.organization
|
|
249
256
|
}, invocation);
|
|
250
257
|
const refused = failure(created);
|
|
251
258
|
if (refused !== null) return refused;
|
|
@@ -263,6 +270,10 @@ function createAuth(client, clearAuthenticatedQueries) {
|
|
|
263
270
|
const state = runtime.snapshot();
|
|
264
271
|
const event = state.phase === "authenticated" && state.account.at === "claimed" ? { _tag: "RetryOrganization" } : { _tag: "RetryAccount" };
|
|
265
272
|
return failure(await runtime.send(event, invocation)) ?? { ok: true };
|
|
273
|
+
}),
|
|
274
|
+
resumeSubmittedOrganization: (submission, options) => guarded(runtime, "createOrganization", options, async (invocation) => {
|
|
275
|
+
const prepared = await prepareOrganization(submission, invocation);
|
|
276
|
+
return prepared.ok ? { ok: true } : prepared;
|
|
266
277
|
})
|
|
267
278
|
};
|
|
268
279
|
}
|
|
@@ -296,10 +307,12 @@ function CapxulIdentityProvider({ client, children }) {
|
|
|
296
307
|
await queryClient.cancelQueries({ queryKey: capxulKeys.root });
|
|
297
308
|
await queryClient.resetQueries({ queryKey: capxulKeys.root });
|
|
298
309
|
};
|
|
310
|
+
const auth = createAuth(client, clearAuthenticatedQueries);
|
|
299
311
|
return {
|
|
300
312
|
runtime,
|
|
301
313
|
send,
|
|
302
|
-
auth
|
|
314
|
+
auth,
|
|
315
|
+
resumeSubmittedOrganization: auth.resumeSubmittedOrganization,
|
|
303
316
|
addTransitionListener
|
|
304
317
|
};
|
|
305
318
|
}, [
|
|
@@ -337,6 +350,9 @@ function useCapxulSend() {
|
|
|
337
350
|
function useCapxulAuth() {
|
|
338
351
|
return useIdentityContext().auth;
|
|
339
352
|
}
|
|
353
|
+
function useResumeSubmittedOrganization() {
|
|
354
|
+
return useIdentityContext().resumeSubmittedOrganization;
|
|
355
|
+
}
|
|
340
356
|
function useCapxulDestination() {
|
|
341
357
|
const next = resolveIdentityDestination(useCapxulIdentity());
|
|
342
358
|
const held = useRef(null);
|
|
@@ -547,6 +563,25 @@ function CapxulOnboardingController(props) {
|
|
|
547
563
|
const state = useCapxulIdentity();
|
|
548
564
|
const destination = useCapxulDestination();
|
|
549
565
|
const auth = useCapxulAuth();
|
|
566
|
+
const resumeSubmittedOrganization = useResumeSubmittedOrganization();
|
|
567
|
+
const resumedSubmission = useRef(null);
|
|
568
|
+
const [failedRecovery, setFailedRecovery] = useState(null);
|
|
569
|
+
const submission = props.submittedOrganization;
|
|
570
|
+
const accountAt = state.phase === "authenticated" ? state.account.at : null;
|
|
571
|
+
useEffect(() => {
|
|
572
|
+
if (props.intent !== "organization" || submission === null || props.recoveryOptions === void 0 || accountAt !== "unknown" && accountAt !== "counterfactual" || resumedSubmission.current === submission) return;
|
|
573
|
+
resumedSubmission.current = submission;
|
|
574
|
+
setFailedRecovery(null);
|
|
575
|
+
resumeSubmittedOrganization(submission, props.recoveryOptions()).then((result) => {
|
|
576
|
+
if (!result.ok) setFailedRecovery(submission);
|
|
577
|
+
});
|
|
578
|
+
}, [
|
|
579
|
+
accountAt,
|
|
580
|
+
props.intent,
|
|
581
|
+
props.recoveryOptions,
|
|
582
|
+
resumeSubmittedOrganization,
|
|
583
|
+
submission
|
|
584
|
+
]);
|
|
550
585
|
if (state.phase !== "authenticated") return null;
|
|
551
586
|
const { slots, navigation } = props;
|
|
552
587
|
if (props.intent === null) return slots.intent({
|
|
@@ -560,7 +595,6 @@ function CapxulOnboardingController(props) {
|
|
|
560
595
|
completePersonal: auth.completePersonal,
|
|
561
596
|
cancel: navigation.profileCancel
|
|
562
597
|
});
|
|
563
|
-
const submission = props.submittedOrganization;
|
|
564
598
|
if (props.intent === "organization" && props.organizationProfile === null && submission === null) return slots.profile({
|
|
565
599
|
intent: "organization",
|
|
566
600
|
state,
|
|
@@ -568,6 +602,7 @@ function CapxulOnboardingController(props) {
|
|
|
568
602
|
cancel: navigation.profileCancel
|
|
569
603
|
});
|
|
570
604
|
if (props.intent === "organization" && props.organizationProfile !== null && submission === null) return organizationForm(props, state, auth, null);
|
|
605
|
+
if (submission !== null && failedRecovery === submission && state.account.at !== "claimed") return organizationForm(props, state, auth, submission);
|
|
571
606
|
if (submission !== null && state.account.at !== "claimed") {
|
|
572
607
|
if (state.account.at === "failed") {
|
|
573
608
|
const retry = state.account.retryable ? (options) => auth.createOrganization(submission, options) : void 0;
|
|
@@ -644,4 +679,4 @@ function organizationForm(props, state, auth, submitted) {
|
|
|
644
679
|
//#endregion
|
|
645
680
|
export { useCapxulAuth as a, useCapxulIdentityOrNull as c, capxulKeys as d, useCapxulClientOrNull as f, entered as i, useCapxulSend as l, CapxulOnboardingController as n, useCapxulDestination as o, useCapxul as p, CapxulProvider as r, useCapxulIdentity as s, CapxulAuthenticationController as t, useCapxulTransitions as u };
|
|
646
681
|
|
|
647
|
-
//# sourceMappingURL=controllers-
|
|
682
|
+
//# sourceMappingURL=controllers-CbZCgTGu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controllers-CbZCgTGu.mjs","names":[],"sources":["../src/internal/capxul-bootstrap-context.tsx","../src/internal/capxul-client-context.tsx","../src/internal/reactivity-keys.ts","../src/identity.tsx","../src/provider.tsx","../src/controllers.tsx"],"sourcesContent":["\"use client\";\n\n// Bootstrap-state context (SDK publish readiness · sdk-provider-owned-bootstrap).\n//\n// `<CapxulProvider>` runs the async client bootstrap and publishes its status\n// here. Consumers read it via `useCapxul()` for an opt-in splash / error / retry\n// surface. Data hooks do NOT need it — they sit in `isPending` until the client\n// resolves (see `useCapxulClientOrNull`).\n\nimport * as React from \"react\";\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport type { CapxulError } from \"@capxul/sdk\";\n\nexport type CapxulBootstrapStatus = \"bootstrapping\" | \"ready\" | \"error\";\n\nexport interface CapxulBootstrapState {\n readonly status: CapxulBootstrapStatus;\n readonly error: CapxulError | null;\n readonly retry: () => void;\n}\n\nconst CapxulBootstrapContext = createContext<CapxulBootstrapState | null>(null);\n\nexport interface CapxulBootstrapProviderProps {\n readonly value: CapxulBootstrapState;\n readonly children: ReactNode;\n}\n\nexport function CapxulBootstrapProvider({ value, children }: CapxulBootstrapProviderProps) {\n return (\n <CapxulBootstrapContext.Provider value={value}>{children}</CapxulBootstrapContext.Provider>\n );\n}\n\nexport function useCapxul(): CapxulBootstrapState {\n const state = useContext(CapxulBootstrapContext);\n if (state === null) {\n throw new Error(\"useCapxul must be used within <CapxulProvider>\");\n }\n return state;\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { CapxulClient } from \"@capxul/sdk\";\n\nconst MISSING_CAPXUL_CLIENT_PROVIDER = Symbol(\"MISSING_CAPXUL_CLIENT_PROVIDER\");\n\nconst CapxulClientContext = createContext<\n CapxulClient | null | typeof MISSING_CAPXUL_CLIENT_PROVIDER\n>(MISSING_CAPXUL_CLIENT_PROVIDER);\n\nexport interface CapxulClientProviderProps {\n readonly client: CapxulClient | null;\n readonly children: ReactNode;\n}\n\nexport function CapxulClientProvider({ client, children }: CapxulClientProviderProps) {\n return <CapxulClientContext.Provider value={client}>{children}</CapxulClientContext.Provider>;\n}\n\nexport function useCapxulClient(): CapxulClient {\n const client = useCapxulClientOrNull();\n if (client === null) {\n throw new Error(\"useCapxulClient called before <CapxulProvider> bootstrap resolved\");\n }\n return client;\n}\n\n/**\n * Returns the client, or `null` while `<CapxulProvider>` is still bootstrapping.\n * Data hooks use this so they can sit in `isPending` (disabled query) until the\n * client resolves, rather than throwing during bootstrap.\n */\nexport function useCapxulClientOrNull(): CapxulClient | null {\n const client = useContext(CapxulClientContext);\n if (client === MISSING_CAPXUL_CLIENT_PROVIDER) {\n throw new Error(\"useCapxulClient must be used within <CapxulProvider>\");\n }\n return client;\n}\n","// Typed query-key catalog (epic #258 · TanStack reactive surface).\n//\n// Auth-boundary mutations (`verifyOtp`, `signOut`) invalidate all three\n// keys on success. `signIn` does not — OTP sent leaves session null.\n//\n// #1145 (DEMOLITION §D5): the actor-scope / destinations / activity / offramp /\n// payroll / auditLog / currentUser / orgAccount key builders — and the\n// `actorKey` / `targetKey` / `activityKey` / `destinationListKey` /\n// `offrampQuoteKey` serializers that existed only to feed them — went with the\n// hooks they keyed. A key builder with no query to name is dead flexibility.\n\nimport type { AccountId, OrgId } from \"@capxul/sdk\";\n\nexport const capxulKeys = {\n // Root of the SDK query namespace. Every key below is prefixed with it, so a\n // reset/cancel on `root` covers the whole authenticated surface (used by\n // sign-out teardown — see resetAuthBoundary).\n root: [\"capxul\"] as const,\n profile: [\"capxul\", \"profile\"] as const,\n // #1062: availability probe, keyed by the (debounced) candidate username.\n usernameAvailability: (username: string) =>\n [\"capxul\", \"profile\", \"username-availability\", username] as const,\n account: [\"capxul\", \"account\"] as const,\n provisioning: [\"capxul\", \"provisioning\"] as const,\n binding: [\"capxul\", \"binding\"] as const,\n accountBalance: [\"capxul\", \"accountBalance\"] as const,\n subAccounts: (accountId: AccountId | undefined) =>\n [\"capxul\", \"subAccounts\", accountId ?? \"pending\"] as const,\n // Organization domain (canon §C3, D13 — entity-scoped, keyed by OrgId).\n orgs: [\"capxul\", \"orgs\"] as const,\n org: (orgId: OrgId | undefined) => [\"capxul\", \"org\", orgId ?? \"pending\"] as const,\n orgMembers: (orgId: OrgId | undefined) =>\n [\"capxul\", \"org\", orgId ?? \"pending\", \"members\"] as const,\n orgRoles: (orgId: OrgId | undefined) => [\"capxul\", \"org\", orgId ?? \"pending\", \"roles\"] as const,\n orgTreasury: (orgId: OrgId | undefined) =>\n [\"capxul\", \"org\", orgId ?? \"pending\", \"treasury\"] as const,\n payments: [\"capxul\", \"payments\"] as const,\n payment: (paymentId: string | undefined) =>\n [\"capxul\", \"payments\", paymentId ?? \"pending\"] as const,\n} satisfies Record<string, readonly unknown[] | ((...args: never[]) => readonly unknown[])>;\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\n\nimport type {\n CapxulClient,\n CapxulErrorCode,\n IdentityDestination,\n IdentityEvent,\n IdentityProfileDetails,\n IdentityState,\n IdentityTransition,\n StateLabel,\n} from \"@capxul/sdk\";\nimport { resolveIdentityDestination, toCountryCode } from \"@capxul/sdk\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { capxulKeys } from \"./internal/reactivity-keys\";\n\nexport type Destination = IdentityDestination;\n\nexport interface InvocationOptions {\n readonly correlationId?: string;\n readonly journeyId?: string;\n readonly timeoutMs?: number;\n readonly deadlineMs?: number;\n readonly signal?: AbortSignal;\n}\n\nexport type SendResult =\n | { readonly ok: true; readonly state: IdentityState }\n | {\n readonly ok: false;\n readonly refused: CapxulErrorCode;\n readonly state: IdentityState;\n };\n\nexport type CapxulSend = (event: IdentityEvent, options?: InvocationOptions) => Promise<SendResult>;\n\nexport type ProfileDetails = IdentityProfileDetails;\n\nexport interface OrganizationDetails {\n readonly name: string;\n readonly handle: string;\n readonly country: string;\n readonly bio?: string;\n readonly size?: string;\n}\n\nexport interface CreateOrganizationSubmission {\n readonly profileDetails: ProfileDetails;\n readonly organization: OrganizationDetails;\n}\n\ntype FacadeFailure = { readonly ok: false; readonly reason: CapxulErrorCode };\ntype EmptyResult = { readonly ok: true } | FacadeFailure;\ntype RuntimeInvocationControls = Parameters<CapxulClient[\"_internal\"][\"identity\"][\"send\"]>[1];\n\nexport interface CapxulAuth {\n readonly requestCode: (\n email: string,\n options?: InvocationOptions,\n ) => Promise<{ readonly ok: true; readonly requestedAt: number } | FacadeFailure>;\n readonly verifyCode: (\n otp: string,\n options?: InvocationOptions,\n ) => Promise<\n | { readonly ok: true; readonly authUserId: string; readonly profileComplete: boolean }\n | FacadeFailure\n >;\n readonly signOut: (options?: InvocationOptions) => Promise<EmptyResult>;\n readonly createOrganization: (\n submission: CreateOrganizationSubmission,\n options?: InvocationOptions,\n ) => Promise<{ readonly ok: true; readonly orgId: string } | FacadeFailure>;\n readonly completePersonal: (\n profileDetails: ProfileDetails,\n options?: InvocationOptions,\n ) => Promise<EmptyResult>;\n readonly retry: (options?: InvocationOptions) => Promise<EmptyResult>;\n}\n\ntype TransitionListener = (record: IdentityTransition, state: IdentityState) => void;\n\ninterface IdentityContextValue {\n readonly runtime: CapxulClient[\"_internal\"][\"identity\"];\n readonly send: CapxulSend;\n readonly auth: CapxulAuth;\n readonly resumeSubmittedOrganization: (\n submission: CreateOrganizationSubmission,\n options: InvocationOptions,\n ) => Promise<EmptyResult>;\n readonly addTransitionListener: (listener: TransitionListener) => () => void;\n}\n\ntype PreparedOrganization =\n | { readonly ok: true; readonly organization: OrganizationDetails }\n | FacadeFailure;\n\ntype IdentityAuth = CapxulAuth & {\n readonly resumeSubmittedOrganization: (\n submission: CreateOrganizationSubmission,\n options: InvocationOptions,\n ) => Promise<EmptyResult>;\n};\n\nconst MISSING_IDENTITY_PROVIDER = Symbol(\"MISSING_IDENTITY_PROVIDER\");\nconst IdentityContext = createContext<\n IdentityContextValue | null | typeof MISSING_IDENTITY_PROVIDER\n>(MISSING_IDENTITY_PROVIDER);\n\nfunction controls(options: InvocationOptions | undefined) {\n if (options === undefined) return undefined;\n return {\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),\n ...(options.deadlineMs === undefined ? {} : { deadlineMs: options.deadlineMs }),\n ...(options.correlationId === undefined ? {} : { correlation_id: options.correlationId }),\n ...(options.journeyId === undefined ? {} : { journey_id: options.journeyId }),\n };\n}\n\nconst failure = (result: SendResult): FacadeFailure | null =>\n result.ok ? null : { ok: false, reason: result.refused };\n\nasync function guarded<T>(\n runtime: CapxulClient[\"_internal\"][\"identity\"],\n verb: Parameters<NonNullable<CapxulClient[\"_internal\"][\"identity\"][\"runFacade\"]>>[0],\n options: InvocationOptions | undefined,\n run: (invocation: RuntimeInvocationControls) => Promise<T>,\n): Promise<T | FacadeFailure> {\n const invocation = controls(options);\n try {\n return await (runtime.runFacade?.(verb, invocation, run) ?? run(invocation));\n } catch {\n return { ok: false, reason: \"UNKNOWN\" };\n }\n}\n\nconst ORGANIZATION_HANDLE = /^[a-z0-9-]{3,32}$/;\n\nexport function normalizeOrganization(\n organization: OrganizationDetails,\n): OrganizationDetails | null {\n const name = typeof organization.name === \"string\" ? organization.name.trim() : \"\";\n const handle =\n typeof organization.handle === \"string\" ? organization.handle.trim().toLowerCase() : \"\";\n if (name.length === 0 || !ORGANIZATION_HANDLE.test(handle)) return null;\n if (organization.bio !== undefined && typeof organization.bio !== \"string\") return null;\n if (organization.size !== undefined && typeof organization.size !== \"string\") return null;\n try {\n return {\n name,\n handle,\n country: toCountryCode(organization.country),\n ...(organization.bio === undefined ? {} : { bio: organization.bio }),\n ...(organization.size === undefined ? {} : { size: organization.size }),\n };\n } catch {\n return null;\n }\n}\n\nfunction createAuth(\n client: CapxulClient,\n clearAuthenticatedQueries: () => Promise<void>,\n): IdentityAuth {\n const runtime = client._internal.identity;\n const read = async (invocation: RuntimeInvocationControls): Promise<EmptyResult> => {\n const result = await runtime.send({ _tag: \"ReadSession\" }, invocation);\n return failure(result) ?? { ok: true };\n };\n const ensureAccount = async (invocation: RuntimeInvocationControls): Promise<EmptyResult> => {\n const result = await runtime.send({ _tag: \"EnsureAccount\" }, invocation);\n return failure(result) ?? { ok: true };\n };\n\n const reachClaimed = async (invocation: RuntimeInvocationControls): Promise<EmptyResult> => {\n let state = runtime.snapshot();\n if (state.phase !== \"authenticated\" || state.account.at === \"unknown\") {\n const result = await runtime.send({ _tag: \"EnsureAccount\" }, invocation);\n const refused = failure(result);\n if (refused !== null) return refused;\n state = result.state;\n }\n if (state.phase !== \"authenticated\") return { ok: false, reason: \"WRONG_STATE\" };\n if (state.account.at === \"claimed\") return { ok: true };\n const event: IdentityEvent =\n state.account.at === \"failed\"\n ? { _tag: \"RetryAccount\" }\n : state.account.at === \"counterfactual\"\n ? { _tag: \"ClaimAccount\" }\n : { _tag: \"EnsureAccount\" };\n const result = await runtime.send(event, invocation);\n const refused = failure(result);\n if (refused !== null) return refused;\n const next = result.state;\n return next.phase === \"authenticated\" && next.account.at === \"claimed\"\n ? { ok: true }\n : { ok: false, reason: \"WRONG_STATE\" };\n };\n\n const completeProfile = async (\n profile: ProfileDetails,\n invocation: RuntimeInvocationControls,\n ): Promise<EmptyResult> => {\n const result = await runtime.completeProfile(profile, invocation);\n return result.ok ? { ok: true } : result;\n };\n\n const prepareOrganization = async (\n submission: CreateOrganizationSubmission,\n invocation: RuntimeInvocationControls,\n ): Promise<PreparedOrganization> => {\n const organization = normalizeOrganization(submission.organization);\n if (organization === null) return { ok: false, reason: \"INVALID_INPUT\" };\n const completed = await completeProfile(submission.profileDetails, invocation);\n if (!completed.ok) return completed;\n const refreshed = await read(invocation);\n if (!refreshed.ok) return refreshed;\n const claimed = await reachClaimed(invocation);\n return claimed.ok ? { ok: true, organization } : claimed;\n };\n\n return {\n requestCode: (email, options) =>\n guarded(runtime, \"requestCode\", options, async (invocation) => {\n const result = await client.auth.signIn({ email }, invocation);\n if (!result.ok) return { ok: false as const, reason: result.error.code };\n const state = runtime.snapshot();\n return state.phase === \"otp_pending\"\n ? { ok: true as const, requestedAt: state.requestedAt }\n : {\n ok: false as const,\n reason: state.phase === \"faulted\" ? state.failure.code : \"UNKNOWN\",\n };\n }),\n verifyCode: (otp, options) =>\n guarded(runtime, \"verifyCode\", options, async (invocation) => {\n const state = runtime.snapshot();\n const email =\n state.phase === \"otp_pending\"\n ? state.email\n : state.phase === \"faulted\" && state.resume !== null\n ? state.resume.email\n : \"\";\n if (!/^\\d{6}$/.test(otp)) {\n const refused = await runtime.send(\n { _tag: \"VerifyOtp\", email, otp, now: Date.now() },\n invocation,\n );\n return failure(refused) ?? { ok: false as const, reason: \"UNKNOWN\" as const };\n }\n const result = await client.auth.verifyOtp({ email, code: otp }, invocation);\n if (!result.ok) return { ok: false as const, reason: result.error.code };\n const next = runtime.snapshot();\n return next.phase === \"authenticated\"\n ? {\n ok: true as const,\n authUserId: next.session.authUserId,\n profileComplete: next.profileComplete,\n }\n : {\n ok: false as const,\n reason: next.phase === \"faulted\" ? next.failure.code : \"UNKNOWN\",\n };\n }),\n signOut: (options) =>\n guarded(runtime, \"signOut\", options, async (invocation) => {\n const result = await client.auth.signOut(invocation);\n if (!result.ok) return { ok: false as const, reason: result.error.code };\n await clearAuthenticatedQueries();\n return { ok: true as const };\n }),\n completePersonal: (profile, options) =>\n guarded(runtime, \"completePersonal\", options, async (invocation) => {\n const completed = await completeProfile(profile, invocation);\n if (!completed.ok) return completed;\n const refreshed = await read(invocation);\n if (!refreshed.ok) return refreshed;\n return ensureAccount(invocation);\n }),\n createOrganization: (submission, options) =>\n guarded(runtime, \"createOrganization\", options, async (invocation) => {\n const prepared = await prepareOrganization(submission, invocation);\n if (!prepared.ok) return prepared;\n const created = await runtime.send(\n { _tag: \"CreateOrganization\", draft: prepared.organization },\n invocation,\n );\n const refused = failure(created);\n if (refused !== null) return refused;\n const state = created.state;\n const org =\n state.phase === \"authenticated\" && state.account.at === \"claimed\"\n ? state.account.org\n : null;\n return org !== null && org.at !== \"creating\" && org.orgId !== null\n ? { ok: true as const, orgId: org.orgId }\n : { ok: false as const, reason: \"UNKNOWN\" as const };\n }),\n retry: (options) =>\n guarded(runtime, \"retry\", options, async (invocation) => {\n const state = runtime.snapshot();\n const event: IdentityEvent =\n state.phase === \"authenticated\" && state.account.at === \"claimed\"\n ? { _tag: \"RetryOrganization\" }\n : { _tag: \"RetryAccount\" };\n const result = await runtime.send(event, invocation);\n return failure(result) ?? { ok: true as const };\n }),\n resumeSubmittedOrganization: (submission, options) =>\n guarded(runtime, \"createOrganization\", options, async (invocation) => {\n const prepared = await prepareOrganization(submission, invocation);\n return prepared.ok ? { ok: true as const } : prepared;\n }),\n };\n}\n\nexport function CapxulIdentityProvider({\n client,\n children,\n}: {\n readonly client: CapxulClient | null;\n readonly children: ReactNode;\n}) {\n const queryClient = useQueryClient();\n const runtime = client?._internal.identity ?? null;\n const listeners = useRef(new Set<TransitionListener>());\n\n useEffect(() => {\n if (client === null) return;\n void Promise.resolve()\n .then(() => client.auth.getSession())\n .catch(() => undefined);\n }, [client]);\n\n useEffect(() => {\n if (runtime === null) return;\n return runtime.subscribeTransitions((record) => {\n const state = runtime.snapshot();\n for (const listener of listeners.current) {\n try {\n listener(record, state);\n } catch {\n listeners.current.delete(listener);\n }\n }\n });\n }, [runtime]);\n\n const addTransitionListener = useCallback((listener: TransitionListener) => {\n listeners.current.add(listener);\n return () => listeners.current.delete(listener);\n }, []);\n\n const value = useMemo<IdentityContextValue | null>(() => {\n if (client === null || runtime === null) return null;\n const send: CapxulSend = (event, options) => runtime.send(event, controls(options));\n const clearAuthenticatedQueries = async () => {\n await queryClient.cancelQueries({ queryKey: capxulKeys.root });\n await queryClient.resetQueries({ queryKey: capxulKeys.root });\n };\n const auth = createAuth(client, clearAuthenticatedQueries);\n return {\n runtime,\n send,\n auth,\n resumeSubmittedOrganization: auth.resumeSubmittedOrganization,\n addTransitionListener,\n };\n }, [client, runtime, addTransitionListener, queryClient]);\n\n return <IdentityContext.Provider value={value}>{children}</IdentityContext.Provider>;\n}\n\nfunction useIdentityContext(): IdentityContextValue {\n const value = useContext(IdentityContext);\n if (value === MISSING_IDENTITY_PROVIDER) {\n throw new Error(\"identity hooks must be used within <CapxulProvider>\");\n }\n if (value === null) {\n throw new Error(\"identity hooks require a ready <CapxulProvider>\");\n }\n return value;\n}\n\nconst noSubscribe = () => () => undefined;\nconst noState = () => null;\n\nexport function useCapxulIdentityOrNull(): IdentityState | null {\n const value = useContext(IdentityContext);\n if (value === MISSING_IDENTITY_PROVIDER) {\n throw new Error(\"identity hooks must be used within <CapxulProvider>\");\n }\n return useSyncExternalStore(\n value?.runtime.subscribe ?? noSubscribe,\n value?.runtime.snapshot ?? noState,\n value?.runtime.snapshot ?? noState,\n );\n}\n\nexport function useCapxulIdentity(): IdentityState {\n const state = useCapxulIdentityOrNull();\n if (state === null) throw new Error(\"identity hooks require a ready <CapxulProvider>\");\n return state;\n}\n\nexport function useCapxulSend(): CapxulSend {\n return useIdentityContext().send;\n}\n\nexport function useCapxulAuth(): CapxulAuth {\n return useIdentityContext().auth;\n}\n\nexport function useResumeSubmittedOrganization() {\n return useIdentityContext().resumeSubmittedOrganization;\n}\n\nexport function useCapxulDestination(): Destination | null {\n const state = useCapxulIdentity();\n const next = resolveIdentityDestination(state);\n const held = useRef<{ readonly key: string; readonly value: Destination | null } | null>(null);\n const key = JSON.stringify(next);\n if (held.current?.key !== key) held.current = { key, value: next };\n return held.current.value;\n}\n\nexport function useCapxulTransitions(listener: TransitionListener): void {\n const { addTransitionListener } = useIdentityContext();\n useEffect(() => addTransitionListener(listener), [addTransitionListener, listener]);\n}\n\nexport const entered = (record: IdentityTransition, target: StateLabel): boolean =>\n record.outcome === \"applied\" && record.from !== target && record.to === target;\n","\"use client\";\n\n// CapxulProvider — owns the client lifecycle (sdk-provider-owned-bootstrap.md).\n//\n// Two modes:\n// - `publishableKey` (browser/app): the provider runs the async bootstrap via\n// `createCapxulClient`, owns the TanStack QueryClient, exposes status via\n// `useCapxul()`, and closes the client on unmount / re-bootstrap.\n// - `client` (Node/server consumers that bootstrap before React, plus test\n// harnesses): a pre-built client is supplied; the provider is `ready`\n// immediately and leaves that client's lifecycle to the caller.\n//\n// `signer` threads into the deploy lane via `createCapxulClient` when supplied.\n// Browser apps with `requirement: \"deployed\"` omit it — the SDK auto-wires Openfort.\n\nimport * as React from \"react\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\n\nimport type {\n AccountRequirement,\n CapxulClient,\n CapxulError,\n CapxulErrorCode,\n CapxulSigner,\n ObservationAdapter,\n TelemetryPort,\n} from \"@capxul/sdk\";\nimport { createCapxulClient, isCapxulError } from \"@capxul/sdk\";\n\nimport {\n CapxulBootstrapProvider,\n type CapxulBootstrapState,\n} from \"./internal/capxul-bootstrap-context\";\nimport { CapxulClientProvider } from \"./internal/capxul-client-context\";\nimport { CapxulIdentityProvider } from \"./identity\";\n\nvoid React;\n\ntype CapxulProviderSharedProps = {\n /** Bring your own QueryClient; otherwise the provider creates one. */\n readonly queryClient?: QueryClient;\n readonly children: ReactNode;\n};\n\n/** Browser / app path — the provider bootstraps the client from a publishable key. */\ntype CapxulProviderPublishableKeyProps = CapxulProviderSharedProps & {\n readonly publishableKey: string;\n readonly client?: never;\n /** Host-owned observation adapter passed to the core SDK boundary. */\n readonly observation?: ObservationAdapter;\n /**\n * Host success-telemetry sink, typically `telemetryFromPostHog(posthog, …)`.\n * Events from SDK producers wired to this port reach the host's PostHog\n * person after the host calls `identify()`.\n */\n readonly telemetry?: TelemetryPort;\n /** Init-time account readiness target. Default `\"none\"`. */\n readonly requirement?: AccountRequirement;\n /**\n * Optional consumer-held signer for the deploy lane. Omitted in browser apps\n * with `requirement: \"deployed\"` — the SDK wires Openfort from bootstrap.\n */\n readonly signer?: CapxulSigner;\n};\n\n/**\n * Node / server / test path — a pre-built client is supplied; lifecycle stays\n * with the caller. Mutually exclusive with `publishableKey`.\n */\ntype CapxulProviderInjectedClientProps = CapxulProviderSharedProps & {\n readonly client: CapxulClient;\n readonly publishableKey?: never;\n /** Injected clients must be created with observation at their owning factory. */\n readonly observation?: never;\n /** Injected clients must be created with telemetry at their owning factory. */\n readonly telemetry?: never;\n readonly requirement?: never;\n readonly signer?: never;\n};\n\nexport type CapxulProviderProps =\n | CapxulProviderPublishableKeyProps\n | CapxulProviderInjectedClientProps;\n\ntype OwnedBootstrap = {\n readonly input: Parameters<typeof createCapxulClient>[0];\n readonly client: CapxulClient | null;\n readonly status: CapxulBootstrapState[\"status\"];\n readonly error: CapxulError | null;\n};\n\n/**\n * Transient failure codes worth a retry — network blips, rate limits, and\n * upstream provider/unknown hiccups that a later attempt may clear. Everything\n * else (including any future code) is deterministic and NOT retried: retrying a\n * deterministic failure only multiplies the failed backend actions. A fresh\n * user with no Safe yet hits `SMART_ACCOUNT_MISSING` on every attempt, so the\n * old blanket `retry: 2` tripled that (and every other deterministic) failed\n * action for zero benefit (#1031).\n */\nconst RETRYABLE_QUERY_ERROR_CODES: ReadonlySet<CapxulErrorCode> = new Set([\n \"NETWORK_ERROR\",\n \"RATE_LIMITED\",\n \"PROVIDER_ERROR\",\n \"UNKNOWN\",\n]);\n\n/** Matches the previous `retry: 2` budget (initial attempt + up to 2 retries). */\nconst MAX_CAPXUL_QUERY_RETRIES = 2;\n\n/**\n * TanStack `retry` predicate: `failureCount` is 0-indexed and checked before\n * increment, so `< MAX` reproduces the old numeric budget for retryable codes.\n * Exported for direct unit coverage of the deterministic-vs-transient split.\n */\nexport function shouldRetryCapxulQuery(failureCount: number, error: unknown): boolean {\n if (failureCount >= MAX_CAPXUL_QUERY_RETRIES) return false;\n return isCapxulError(error) && RETRYABLE_QUERY_ERROR_CODES.has(error.code);\n}\n\n/**\n * The default query client used when the host injects none. Exported so a test\n * can pin that `queries.retry` is wired to `shouldRetryCapxulQuery` — reverting\n * it to the old blanket `retry: 2` must fail a test (#1031).\n */\nexport function makeDefaultQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: { retry: shouldRetryCapxulQuery, staleTime: 30_000 },\n mutations: { retry: 0 },\n },\n });\n}\n\nfunction isCapxulQueryKey(queryKey: readonly unknown[]): boolean {\n return queryKey[0] === \"capxul\";\n}\n\nfunction clearClientScopedQueries(queryClient: QueryClient, ownsQueryClient: boolean): void {\n if (ownsQueryClient) {\n queryClient.clear();\n return;\n }\n queryClient.removeQueries({ predicate: (query) => isCapxulQueryKey(query.queryKey) });\n}\n\nexport function CapxulProvider(props: CapxulProviderProps) {\n const {\n publishableKey,\n client: injectedClient,\n requirement,\n signer,\n observation,\n telemetry,\n queryClient,\n children,\n } = props;\n\n // The QueryClient is pinned at mount: a later `queryClient` prop swap is\n // ignored (consumers should not swap it mid-tree) — pass your own once, or\n // let the provider create one.\n const [resolvedQueryClient] = useState(() => queryClient ?? makeDefaultQueryClient());\n const [ownsQueryClient] = useState(() => queryClient === undefined);\n\n const [attempt, setAttempt] = useState(0);\n const retry = useCallback(() => {\n setAttempt((n) => n + 1);\n }, []);\n const bootstrapInput = useMemo(\n () =>\n publishableKey === undefined\n ? null\n : {\n publishableKey,\n ...(requirement === undefined ? {} : { requirement }),\n ...(signer === undefined ? {} : { signer }),\n ...(observation === undefined ? {} : { observation }),\n ...(telemetry === undefined ? {} : { telemetry }),\n },\n [publishableKey, requirement, signer, observation, telemetry, attempt],\n );\n const [ownedBootstrap, setOwnedBootstrap] = useState<OwnedBootstrap | null>(null);\n const activeOwnedBootstrap =\n bootstrapInput !== null && ownedBootstrap?.input === bootstrapInput ? ownedBootstrap : null;\n const client = injectedClient ?? activeOwnedBootstrap?.client ?? null;\n const previousClientRef = useRef<CapxulClient | null>(injectedClient ?? null);\n\n // Bootstrap path: the provider owns the client it creates and closes it on\n // unmount / re-bootstrap. The `cancelled` guard closes a client that resolves\n // after the effect tears down (StrictMode double-invoke, retry, unmount).\n useEffect(() => {\n if (bootstrapInput === null) return;\n let cancelled = false;\n let created: CapxulClient | null = null;\n setOwnedBootstrap({\n input: bootstrapInput,\n client: null,\n status: \"bootstrapping\",\n error: null,\n });\n void (async () => {\n const result = await createCapxulClient(bootstrapInput);\n if (cancelled) {\n if (result.ok) await result.value._internal.close?.();\n return;\n }\n if (result.ok) {\n created = result.value;\n setOwnedBootstrap({\n input: bootstrapInput,\n client: result.value,\n status: \"ready\",\n error: null,\n });\n } else {\n setOwnedBootstrap({\n input: bootstrapInput,\n client: null,\n status: \"error\",\n error: result.error,\n });\n }\n })();\n return () => {\n cancelled = true;\n void created?._internal.close?.();\n };\n }, [bootstrapInput]);\n\n useEffect(() => {\n const previous = previousClientRef.current;\n if (previous !== null && previous !== client) {\n clearClientScopedQueries(resolvedQueryClient, ownsQueryClient);\n }\n previousClientRef.current = client;\n }, [client, ownsQueryClient, resolvedQueryClient]);\n\n const bootstrapState = useMemo<CapxulBootstrapState>(\n () => ({\n status:\n injectedClient === undefined ? (activeOwnedBootstrap?.status ?? \"bootstrapping\") : \"ready\",\n error: injectedClient === undefined ? (activeOwnedBootstrap?.error ?? null) : null,\n retry,\n }),\n [activeOwnedBootstrap, injectedClient, retry],\n );\n\n // Validate AFTER the hooks so a publishableKey↔client prop transition never\n // changes the hook count (rules of hooks); the throw aborts render cleanly.\n if ((publishableKey === undefined) === (injectedClient === undefined)) {\n throw new Error(\"CapxulProvider requires exactly one of `publishableKey` or `client`\");\n }\n\n return (\n <QueryClientProvider client={resolvedQueryClient}>\n <CapxulBootstrapProvider value={bootstrapState}>\n <CapxulClientProvider client={client}>\n <CapxulIdentityProvider client={client}>{children}</CapxulIdentityProvider>\n </CapxulClientProvider>\n </CapxulBootstrapProvider>\n </QueryClientProvider>\n );\n}\n","\"use client\";\n\nimport { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport type {\n IdentityState,\n IdentityDestination as Destination,\n OrgLane,\n Readiness,\n} from \"@capxul/sdk\";\n\nimport {\n normalizeOrganization,\n useCapxulAuth,\n useCapxulDestination,\n useCapxulIdentity,\n useResumeSubmittedOrganization,\n useCapxulSend,\n type CapxulAuth,\n type CreateOrganizationSubmission,\n type InvocationOptions,\n type OrganizationDetails,\n type ProfileDetails,\n} from \"./identity\";\n\nexport type Slot<P> = (props: P) => ReactNode;\nexport type ActionResult =\n | { readonly ok: true }\n | { readonly ok: false; readonly reason: import(\"@capxul/sdk\").CapxulErrorCode };\nexport type ControllerAction = () => Promise<ActionResult>;\nexport type RetryAction = (options: InvocationOptions) => Promise<ActionResult>;\nexport type NavigationAction = () => void;\n\nexport type SignedOutState = Extract<IdentityState, { phase: \"signed_out\" }>;\nexport type OtpPendingState = Extract<IdentityState, { phase: \"otp_pending\" }>;\nexport type PendingAuthState = Extract<\n IdentityState,\n { phase: \"otp_sending\" | \"otp_verifying\" | \"signing_out\" }\n>;\nexport type FaultedState = Extract<IdentityState, { phase: \"faulted\" }>;\nexport type AuthenticatedState = Extract<IdentityState, { phase: \"authenticated\" }>;\nexport type AccountProgress = Exclude<Readiness, { at: \"failed\" } | { at: \"claimed\" }>;\nexport type AccountFailure = Extract<Readiness, { at: \"failed\" }>;\nexport type OrgProgress = Exclude<OrgLane, { at: \"failed\" } | { at: \"ready\" }>;\nexport type OrgFailure = Extract<OrgLane, { at: \"failed\" }>;\nexport type ReadyDestination = Extract<\n Destination,\n { to: \"dashboardPersonal\" | \"dashboardOrganization\" }\n>;\n\nexport interface AuthenticationSlots {\n readonly email: Slot<{ state: SignedOutState; requestCode: CapxulAuth[\"requestCode\"] }>;\n readonly otp: Slot<{\n state: OtpPendingState;\n verifyCode: CapxulAuth[\"verifyCode\"];\n back: ControllerAction;\n }>;\n readonly pending: Slot<{ state: PendingAuthState }>;\n readonly failure: Slot<{\n state: FaultedState;\n recover: ControllerAction;\n back: ControllerAction;\n }>;\n readonly success: Slot<{\n state: AuthenticatedState;\n destination: Destination | null;\n }>;\n}\n\nconst action = async (\n send: ReturnType<typeof useCapxulSend>,\n event: Parameters<ReturnType<typeof useCapxulSend>>[0],\n): Promise<ActionResult> => {\n const result = await send(event);\n return result.ok ? { ok: true } : { ok: false, reason: result.refused };\n};\n\nexport function CapxulAuthenticationController({ slots }: { readonly slots: AuthenticationSlots }) {\n const state = useCapxulIdentity();\n const destination = useCapxulDestination();\n const auth = useCapxulAuth();\n const send = useCapxulSend();\n switch (state.phase) {\n case \"signed_out\":\n return slots.email({ state, requestCode: auth.requestCode });\n case \"otp_pending\":\n return slots.otp({\n state,\n verifyCode: auth.verifyCode,\n back: () => action(send, { _tag: \"Reset\" }),\n });\n case \"otp_sending\":\n case \"otp_verifying\":\n case \"signing_out\":\n return slots.pending({ state });\n case \"faulted\":\n return slots.failure({\n state,\n recover: () =>\n action(\n send,\n state.resume === null ? { _tag: \"Reset\" } : { _tag: \"ResumeOtpEntry\", now: Date.now() },\n ),\n back: () => action(send, { _tag: \"Reset\" }),\n });\n case \"authenticated\":\n return slots.success({ state, destination });\n }\n}\n\nexport type ProfileSlotProps =\n | {\n readonly intent: \"personal\";\n readonly state: AuthenticatedState;\n readonly completePersonal: CapxulAuth[\"completePersonal\"];\n readonly cancel: NavigationAction;\n }\n | {\n readonly intent: \"organization\";\n readonly state: AuthenticatedState;\n readonly continueOrganization: (profile: ProfileDetails) => void;\n readonly cancel: NavigationAction;\n };\n\nexport interface OnboardingControllerProps {\n readonly intent: \"personal\" | \"organization\" | null;\n readonly organizationProfile: ProfileDetails | null;\n readonly submittedOrganization: CreateOrganizationSubmission | null;\n readonly recoveryOptions?: () => InvocationOptions;\n readonly onIntent: (intent: \"personal\" | \"organization\") => void;\n readonly onOrganizationProfile: (profile: ProfileDetails | null) => void;\n readonly onSubmittedOrganization: (submission: CreateOrganizationSubmission | null) => void;\n readonly navigation: {\n readonly selectorBack: NavigationAction;\n readonly profileCancel: NavigationAction;\n readonly organizationBack: NavigationAction;\n readonly organizationCancel: NavigationAction;\n };\n readonly slots: {\n readonly intent: Slot<{\n state: AuthenticatedState;\n select: OnboardingControllerProps[\"onIntent\"];\n back: NavigationAction;\n }>;\n readonly profile: Slot<ProfileSlotProps>;\n readonly organization: Slot<{\n state: AuthenticatedState;\n profileDetails: ProfileDetails;\n submitted: CreateOrganizationSubmission | null;\n pinnedHandle: string | null;\n submit: (\n organization: OrganizationDetails,\n options: InvocationOptions,\n ) => ReturnType<CapxulAuth[\"createOrganization\"]>;\n back: NavigationAction;\n cancel: NavigationAction;\n }>;\n readonly accountProgress: Slot<{ state: AuthenticatedState; account: AccountProgress }>;\n readonly accountFailure: Slot<{\n state: AuthenticatedState;\n account: AccountFailure;\n retry?: RetryAction;\n }>;\n readonly organizationProgress: Slot<{ state: AuthenticatedState; org: OrgProgress }>;\n readonly organizationFailure: Slot<{\n state: AuthenticatedState;\n org: OrgFailure;\n retry?: RetryAction;\n }>;\n readonly ready: Slot<{ state: AuthenticatedState; destination: ReadyDestination }>;\n };\n}\n\nfunction ready(destination: Destination | null): destination is ReadyDestination {\n return destination?.to === \"dashboardPersonal\" || destination?.to === \"dashboardOrganization\";\n}\n\n// The ruled exhaustive intent/Profile/account/Organization slot table is clearer\n// as one flat selector than split across hidden partial routers.\n// oxlint-disable-next-line eslint/complexity\nexport function CapxulOnboardingController(props: OnboardingControllerProps) {\n const state = useCapxulIdentity();\n const destination = useCapxulDestination();\n const auth = useCapxulAuth();\n const resumeSubmittedOrganization = useResumeSubmittedOrganization();\n const resumedSubmission = useRef<CreateOrganizationSubmission | null>(null);\n const [failedRecovery, setFailedRecovery] = useState<CreateOrganizationSubmission | null>(null);\n const submission = props.submittedOrganization;\n const accountAt = state.phase === \"authenticated\" ? state.account.at : null;\n\n useEffect(() => {\n if (\n props.intent !== \"organization\" ||\n submission === null ||\n props.recoveryOptions === undefined ||\n (accountAt !== \"unknown\" && accountAt !== \"counterfactual\") ||\n resumedSubmission.current === submission\n ) {\n return;\n }\n resumedSubmission.current = submission;\n setFailedRecovery(null);\n void resumeSubmittedOrganization(submission, props.recoveryOptions()).then((result) => {\n if (!result.ok) setFailedRecovery(submission);\n });\n }, [accountAt, props.intent, props.recoveryOptions, resumeSubmittedOrganization, submission]);\n\n if (state.phase !== \"authenticated\") return null;\n\n const { slots, navigation } = props;\n if (props.intent === null) {\n return slots.intent({ state, select: props.onIntent, back: navigation.selectorBack });\n }\n\n if (props.intent === \"personal\" && !state.profileComplete) {\n return slots.profile({\n intent: \"personal\",\n state,\n completePersonal: auth.completePersonal,\n cancel: navigation.profileCancel,\n });\n }\n\n if (\n props.intent === \"organization\" &&\n props.organizationProfile === null &&\n submission === null\n ) {\n return slots.profile({\n intent: \"organization\",\n state,\n continueOrganization: props.onOrganizationProfile,\n cancel: navigation.profileCancel,\n });\n }\n\n if (\n props.intent === \"organization\" &&\n props.organizationProfile !== null &&\n submission === null\n ) {\n return organizationForm(props, state, auth, null);\n }\n\n if (submission !== null && failedRecovery === submission && state.account.at !== \"claimed\") {\n return organizationForm(props, state, auth, submission);\n }\n\n if (submission !== null && state.account.at !== \"claimed\") {\n if (state.account.at === \"failed\") {\n const retry = state.account.retryable\n ? (options: InvocationOptions) => auth.createOrganization(submission, options)\n : undefined;\n return slots.accountFailure({\n state,\n account: state.account,\n ...(retry === undefined ? {} : { retry }),\n });\n }\n return slots.accountProgress({ state, account: state.account });\n }\n\n if (submission !== null && state.account.at === \"claimed\") {\n const org = state.account.org;\n if (org === null) return organizationForm(props, state, auth, submission);\n if (org.at === \"failed\") {\n const retry = org.retryable\n ? org.orgId === null\n ? (options: InvocationOptions) => auth.createOrganization(submission, options)\n : auth.retry\n : undefined;\n return slots.organizationFailure({\n state,\n org,\n ...(retry === undefined ? {} : { retry }),\n });\n }\n if (org.at !== \"ready\") return slots.organizationProgress({ state, org });\n }\n\n if (state.account.at === \"failed\") {\n return slots.accountFailure({\n state,\n account: state.account,\n ...(state.account.retryable ? { retry: auth.retry } : {}),\n });\n }\n if (state.account.at !== \"claimed\") {\n return slots.accountProgress({ state, account: state.account });\n }\n return ready(destination) ? slots.ready({ state, destination }) : null;\n}\n\nfunction organizationForm(\n props: OnboardingControllerProps,\n state: AuthenticatedState,\n auth: CapxulAuth,\n submitted: CreateOrganizationSubmission | null,\n) {\n const profileDetails = submitted?.profileDetails ?? props.organizationProfile;\n if (profileDetails === null) return null;\n return props.slots.organization({\n state,\n profileDetails,\n submitted,\n pinnedHandle: submitted?.organization.handle ?? null,\n submit: (organization, options) => {\n if (submitted !== null) return auth.createOrganization(submitted, options);\n const normalized = normalizeOrganization(organization);\n if (normalized === null) {\n return Promise.resolve({ ok: false, reason: \"INVALID_INPUT\" });\n }\n const next = { profileDetails, organization: normalized };\n props.onSubmittedOrganization(next);\n return auth.createOrganization(next, options);\n },\n back: () => {\n props.onOrganizationProfile(null);\n props.navigation.organizationBack();\n },\n cancel: props.navigation.organizationCancel,\n });\n}\n"],"mappings":";;;;;AAqBA,MAAM,yBAAyB,cAA2C,IAAI;AAO9E,SAAgB,wBAAwB,EAAE,OAAO,YAA0C;CACzF,OACE,oBAAC,uBAAuB,UAAxB;EAAwC;EAAQ;CAA0C,CAAA;AAE9F;AAEA,SAAgB,YAAkC;CAChD,MAAM,QAAQ,WAAW,sBAAsB;CAC/C,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM,gDAAgD;CAElE,OAAO;AACT;;;ACjCA,MAAM,iCAAiC,OAAO,gCAAgC;AAE9E,MAAM,sBAAsB,cAE1B,8BAA8B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ACA,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM;GACzC,CAAC;EACH;EACA,IAAI,IAAI,OAAO,SAAS,OAAO,MAAM,qBAAqB;GAAE;GAAO;EAAI,CAAC;CAC1E;CAEA,IAAI,MAAM,QAAQ,OAAO,UACvB,OAAO,MAAM,eAAe;EAC1B;EACA,SAAS,MAAM;EACf,GAAI,MAAM,QAAQ,YAAY,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;CACzD,CAAC;CAEH,IAAI,MAAM,QAAQ,OAAO,WACvB,OAAO,MAAM,gBAAgB;EAAE;EAAO,SAAS,MAAM;CAAQ,CAAC;CAEhE,OAAO,MAAM,WAAW,IAAI,MAAM,MAAM;EAAE;EAAO;CAAY,CAAC,IAAI;AACpE;AAEA,SAAS,iBACP,OACA,OACA,MACA,WACA;CACA,MAAM,iBAAiB,WAAW,kBAAkB,MAAM;CAC1D,IAAI,mBAAmB,MAAM,OAAO;CACpC,OAAO,MAAM,MAAM,aAAa;EAC9B;EACA;EACA;EACA,cAAc,WAAW,aAAa,UAAU;EAChD,SAAS,cAAc,YAAY;GACjC,IAAI,cAAc,MAAM,OAAO,KAAK,mBAAmB,WAAW,OAAO;GACzE,MAAM,aAAa,sBAAsB,YAAY;GACrD,IAAI,eAAe,MACjB,OAAO,QAAQ,QAAQ;IAAE,IAAI;IAAO,QAAQ;GAAgB,CAAC;GAE/D,MAAM,OAAO;IAAE;IAAgB,cAAc;GAAW;GACxD,MAAM,wBAAwB,IAAI;GAClC,OAAO,KAAK,mBAAmB,MAAM,OAAO;EAC9C;EACA,YAAY;GACV,MAAM,sBAAsB,IAAI;GAChC,MAAM,WAAW,iBAAiB;EACpC;EACA,QAAQ,MAAM,WAAW;CAC3B,CAAC;AACH"}
|
|
@@ -152,6 +152,7 @@ interface OnboardingControllerProps {
|
|
|
152
152
|
readonly intent: "personal" | "organization" | null;
|
|
153
153
|
readonly organizationProfile: ProfileDetails | null;
|
|
154
154
|
readonly submittedOrganization: CreateOrganizationSubmission | null;
|
|
155
|
+
readonly recoveryOptions?: () => InvocationOptions;
|
|
155
156
|
readonly onIntent: (intent: "personal" | "organization") => void;
|
|
156
157
|
readonly onOrganizationProfile: (profile: ProfileDetails | null) => void;
|
|
157
158
|
readonly onSubmittedOrganization: (submission: CreateOrganizationSubmission | null) => void;
|
|
@@ -204,4 +205,4 @@ interface OnboardingControllerProps {
|
|
|
204
205
|
declare function CapxulOnboardingController(props: OnboardingControllerProps): ReactNode;
|
|
205
206
|
//#endregion
|
|
206
207
|
export { useCapxulAuth as A, CreateOrganizationSubmission as C, ProfileDetails as D, OrganizationDetails as E, useCapxulIdentity as M, useCapxulSend as N, SendResult as O, useCapxulTransitions as P, CapxulSend as S, InvocationOptions as T, ReadyDestination as _, AuthenticationSlots as a, Slot as b, ControllerAction as c, OnboardingControllerProps as d, OrgFailure as f, ProfileSlotProps as g, PendingAuthState as h, AuthenticatedState as i, useCapxulDestination as j, entered as k, FaultedState as l, OtpPendingState as m, AccountProgress as n, CapxulAuthenticationController as o, OrgProgress as p, ActionResult as r, CapxulOnboardingController as s, AccountFailure as t, NavigationAction as u, RetryAction as v, Destination as w, CapxulAuth as x, SignedOutState as y };
|
|
207
|
-
//# sourceMappingURL=controllers-
|
|
208
|
+
//# sourceMappingURL=controllers-D3_Q5d2t.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers-
|
|
1
|
+
{"version":3,"file":"controllers-D3_Q5d2t.d.mts","names":[],"sources":["../src/identity.tsx","../src/controllers.tsx"],"mappings":";;;;KA4BY,WAAA,GAAc,mBAAmB;AAAA,UAE5B,iBAAA;EAAA,SACN,aAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA,GAAS,WAAW;AAAA;AAAA,KAGnB,UAAA;EAAA,SACG,EAAA;EAAA,SAAmB,KAAA,EAAO,aAAA;AAAA;EAAA,SAE1B,EAAA;EAAA,SACA,OAA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A;EAAA;EAAA,SAEtB,KAAA;IAAA,SACE,MAAA,EAAQ,IAAA;MACf,KAAA,EAAO,kBAAA;MACP,MAAA,EAAQ,yBAAA;MACR,IAAA,EAAM,gBAAA;IAAA;IAAA,SAEC,OAAA,EAAS,IAAA,CAAK,gBAAA;IAAA,SACd,YAAA,EAAc,IAAA;MACrB,KAAA,EAAO,kBAAA;MACP,cAAA,EAAgB,cAAA;MAChB,SAAA,EAAW,4BAAA;MACX,YAAA;MACA,MAAA,GACE,YAAA,EAAc,mBAAA,EACd,OAAA,EAAS,iBAAA,KACN,UAAA,CAAW,UAAA;MAChB,IAAA,EAAM,gBAAA;MACN,MAAA,EAAQ,gBAAA;IAAA;IAAA,SAED,eAAA,EAAiB,IAAA;MAAO,KAAA,EAAO,kBAAA;MAAoB,OAAA,EAAS,eAAA;IAAA;IAAA,SAC5D,cAAA,EAAgB,IAAA;MACvB,KAAA,EAAO,kBAAA;MACP,OAAA,EAAS,cAAA;MACT,KAAA,GAAQ,WAAA;IAAA;IAAA,SAED,oBAAA,EAAsB,IAAA;MAAO,KAAA,EAAO,kBAAA;MAAoB,GAAA,EAAK,WAAA;IAAA;IAAA,SAC7D,mBAAA,EAAqB,IAAA;MAC5B,KAAA,EAAO,kBAAA;MACP,GAAA,EAAK,UAAA;MACL,KAAA,GAAQ,WAAA;IAAA;IAAA,SAED,KAAA,EAAO,IAAA;MAAO,KAAA,EAAO,kBAAA;MAAoB,WAAA,EAAa,gBAAA;IAAA;EAAA;AAAA;AAAA,iBAWnD,0BAAA,CAA2B,KAAA,EAAO,yBAAA,GAAyB,SAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as useCapxulAuth, C as CreateOrganizationSubmission, D as ProfileDetails, E as OrganizationDetails, M as useCapxulIdentity, N as useCapxulSend, O as SendResult, P as useCapxulTransitions, S as CapxulSend, T as InvocationOptions, _ as ReadyDestination, a as AuthenticationSlots, b as Slot, c as ControllerAction, d as OnboardingControllerProps, f as OrgFailure, g as ProfileSlotProps, h as PendingAuthState, i as AuthenticatedState, j as useCapxulDestination, k as entered, l as FaultedState, m as OtpPendingState, n as AccountProgress, o as CapxulAuthenticationController, p as OrgProgress, r as ActionResult, s as CapxulOnboardingController, t as AccountFailure, u as NavigationAction, v as RetryAction, w as Destination, x as CapxulAuth, y as SignedOutState } from "./controllers-
|
|
1
|
+
import { A as useCapxulAuth, C as CreateOrganizationSubmission, D as ProfileDetails, E as OrganizationDetails, M as useCapxulIdentity, N as useCapxulSend, O as SendResult, P as useCapxulTransitions, S as CapxulSend, T as InvocationOptions, _ as ReadyDestination, a as AuthenticationSlots, b as Slot, c as ControllerAction, d as OnboardingControllerProps, f as OrgFailure, g as ProfileSlotProps, h as PendingAuthState, i as AuthenticatedState, j as useCapxulDestination, k as entered, l as FaultedState, m as OtpPendingState, n as AccountProgress, o as CapxulAuthenticationController, p as OrgProgress, r as ActionResult, s as CapxulOnboardingController, t as AccountFailure, u as NavigationAction, v as RetryAction, w as Destination, x as CapxulAuth, y as SignedOutState } from "./controllers-D3_Q5d2t.mjs";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { QueryClient, UseMutationResult, UseQueryResult } from "@tanstack/react-query";
|
|
4
4
|
import { Account, AccountId, AccountRequirement, AssignRoleInput, CapxulClient, CapxulError, CapxulSigner, CreateOrgInput, InviteMemberInput, MemberView, Money, ObservationAdapter, OrgId, OrgView, Payment, PaymentsPayInput, PaymentsPayoutInput, PaymentsWithdrawInput, Profile, RemoveMemberInput, RoleView, SubAccount, SubAccountId, TelemetryPort, TransferInput, TransferResult } from "@capxul/sdk";
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as useCapxulAuth, c as useCapxulIdentityOrNull, d as capxulKeys, f as useCapxulClientOrNull, i as entered, l as useCapxulSend, n as CapxulOnboardingController, o as useCapxulDestination, p as useCapxul, r as CapxulProvider, s as useCapxulIdentity, t as CapxulAuthenticationController, u as useCapxulTransitions } from "./controllers-
|
|
2
|
+
import { a as useCapxulAuth, c as useCapxulIdentityOrNull, d as capxulKeys, f as useCapxulClientOrNull, i as entered, l as useCapxulSend, n as CapxulOnboardingController, o as useCapxulDestination, p as useCapxul, r as CapxulProvider, s as useCapxulIdentity, t as CapxulAuthenticationController, u as useCapxulTransitions } from "./controllers-CbZCgTGu.mjs";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
//#region ../errors/src/errors.ts
|
package/dist/testing/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AuthenticationSlots, d as OnboardingControllerProps } from "../controllers-
|
|
1
|
+
import { a as AuthenticationSlots, d as OnboardingControllerProps } from "../controllers-D3_Q5d2t.mjs";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { CapxulTestClient, CapxulTestClock, CapxulTestObservation, CreateCapxulTestClientOptions, SeedTestIdentityInput, createCapxulTestClient } from "@capxul/sdk/testing";
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as CapxulOnboardingController, r as CapxulProvider, t as CapxulAuthenticationController } from "../controllers-
|
|
1
|
+
import { n as CapxulOnboardingController, r as CapxulProvider, t as CapxulAuthenticationController } from "../controllers-CbZCgTGu.mjs";
|
|
2
2
|
import "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createCapxulTestClient } from "@capxul/sdk/testing";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/sdk-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"package.json",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@capxul/sdk": "1.2.
|
|
24
|
+
"@capxul/sdk": "1.2.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@tanstack/react-query": "^5.66.9",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controllers-BU11km12.mjs","names":[],"sources":["../src/internal/capxul-bootstrap-context.tsx","../src/internal/capxul-client-context.tsx","../src/internal/reactivity-keys.ts","../src/identity.tsx","../src/provider.tsx","../src/controllers.tsx"],"sourcesContent":["\"use client\";\n\n// Bootstrap-state context (SDK publish readiness · sdk-provider-owned-bootstrap).\n//\n// `<CapxulProvider>` runs the async client bootstrap and publishes its status\n// here. Consumers read it via `useCapxul()` for an opt-in splash / error / retry\n// surface. Data hooks do NOT need it — they sit in `isPending` until the client\n// resolves (see `useCapxulClientOrNull`).\n\nimport * as React from \"react\";\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport type { CapxulError } from \"@capxul/sdk\";\n\nexport type CapxulBootstrapStatus = \"bootstrapping\" | \"ready\" | \"error\";\n\nexport interface CapxulBootstrapState {\n readonly status: CapxulBootstrapStatus;\n readonly error: CapxulError | null;\n readonly retry: () => void;\n}\n\nconst CapxulBootstrapContext = createContext<CapxulBootstrapState | null>(null);\n\nexport interface CapxulBootstrapProviderProps {\n readonly value: CapxulBootstrapState;\n readonly children: ReactNode;\n}\n\nexport function CapxulBootstrapProvider({ value, children }: CapxulBootstrapProviderProps) {\n return (\n <CapxulBootstrapContext.Provider value={value}>{children}</CapxulBootstrapContext.Provider>\n );\n}\n\nexport function useCapxul(): CapxulBootstrapState {\n const state = useContext(CapxulBootstrapContext);\n if (state === null) {\n throw new Error(\"useCapxul must be used within <CapxulProvider>\");\n }\n return state;\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { CapxulClient } from \"@capxul/sdk\";\n\nconst MISSING_CAPXUL_CLIENT_PROVIDER = Symbol(\"MISSING_CAPXUL_CLIENT_PROVIDER\");\n\nconst CapxulClientContext = createContext<\n CapxulClient | null | typeof MISSING_CAPXUL_CLIENT_PROVIDER\n>(MISSING_CAPXUL_CLIENT_PROVIDER);\n\nexport interface CapxulClientProviderProps {\n readonly client: CapxulClient | null;\n readonly children: ReactNode;\n}\n\nexport function CapxulClientProvider({ client, children }: CapxulClientProviderProps) {\n return <CapxulClientContext.Provider value={client}>{children}</CapxulClientContext.Provider>;\n}\n\nexport function useCapxulClient(): CapxulClient {\n const client = useCapxulClientOrNull();\n if (client === null) {\n throw new Error(\"useCapxulClient called before <CapxulProvider> bootstrap resolved\");\n }\n return client;\n}\n\n/**\n * Returns the client, or `null` while `<CapxulProvider>` is still bootstrapping.\n * Data hooks use this so they can sit in `isPending` (disabled query) until the\n * client resolves, rather than throwing during bootstrap.\n */\nexport function useCapxulClientOrNull(): CapxulClient | null {\n const client = useContext(CapxulClientContext);\n if (client === MISSING_CAPXUL_CLIENT_PROVIDER) {\n throw new Error(\"useCapxulClient must be used within <CapxulProvider>\");\n }\n return client;\n}\n","// Typed query-key catalog (epic #258 · TanStack reactive surface).\n//\n// Auth-boundary mutations (`verifyOtp`, `signOut`) invalidate all three\n// keys on success. `signIn` does not — OTP sent leaves session null.\n//\n// #1145 (DEMOLITION §D5): the actor-scope / destinations / activity / offramp /\n// payroll / auditLog / currentUser / orgAccount key builders — and the\n// `actorKey` / `targetKey` / `activityKey` / `destinationListKey` /\n// `offrampQuoteKey` serializers that existed only to feed them — went with the\n// hooks they keyed. A key builder with no query to name is dead flexibility.\n\nimport type { AccountId, OrgId } from \"@capxul/sdk\";\n\nexport const capxulKeys = {\n // Root of the SDK query namespace. Every key below is prefixed with it, so a\n // reset/cancel on `root` covers the whole authenticated surface (used by\n // sign-out teardown — see resetAuthBoundary).\n root: [\"capxul\"] as const,\n profile: [\"capxul\", \"profile\"] as const,\n // #1062: availability probe, keyed by the (debounced) candidate username.\n usernameAvailability: (username: string) =>\n [\"capxul\", \"profile\", \"username-availability\", username] as const,\n account: [\"capxul\", \"account\"] as const,\n provisioning: [\"capxul\", \"provisioning\"] as const,\n binding: [\"capxul\", \"binding\"] as const,\n accountBalance: [\"capxul\", \"accountBalance\"] as const,\n subAccounts: (accountId: AccountId | undefined) =>\n [\"capxul\", \"subAccounts\", accountId ?? \"pending\"] as const,\n // Organization domain (canon §C3, D13 — entity-scoped, keyed by OrgId).\n orgs: [\"capxul\", \"orgs\"] as const,\n org: (orgId: OrgId | undefined) => [\"capxul\", \"org\", orgId ?? \"pending\"] as const,\n orgMembers: (orgId: OrgId | undefined) =>\n [\"capxul\", \"org\", orgId ?? \"pending\", \"members\"] as const,\n orgRoles: (orgId: OrgId | undefined) => [\"capxul\", \"org\", orgId ?? \"pending\", \"roles\"] as const,\n orgTreasury: (orgId: OrgId | undefined) =>\n [\"capxul\", \"org\", orgId ?? \"pending\", \"treasury\"] as const,\n payments: [\"capxul\", \"payments\"] as const,\n payment: (paymentId: string | undefined) =>\n [\"capxul\", \"payments\", paymentId ?? \"pending\"] as const,\n} satisfies Record<string, readonly unknown[] | ((...args: never[]) => readonly unknown[])>;\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\n\nimport type {\n CapxulClient,\n CapxulErrorCode,\n IdentityDestination,\n IdentityEvent,\n IdentityProfileDetails,\n IdentityState,\n IdentityTransition,\n StateLabel,\n} from \"@capxul/sdk\";\nimport { resolveIdentityDestination, toCountryCode } from \"@capxul/sdk\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { capxulKeys } from \"./internal/reactivity-keys\";\n\nexport type Destination = IdentityDestination;\n\nexport interface InvocationOptions {\n readonly correlationId?: string;\n readonly journeyId?: string;\n readonly timeoutMs?: number;\n readonly deadlineMs?: number;\n readonly signal?: AbortSignal;\n}\n\nexport type SendResult =\n | { readonly ok: true; readonly state: IdentityState }\n | {\n readonly ok: false;\n readonly refused: CapxulErrorCode;\n readonly state: IdentityState;\n };\n\nexport type CapxulSend = (event: IdentityEvent, options?: InvocationOptions) => Promise<SendResult>;\n\nexport type ProfileDetails = IdentityProfileDetails;\n\nexport interface OrganizationDetails {\n readonly name: string;\n readonly handle: string;\n readonly country: string;\n readonly bio?: string;\n readonly size?: string;\n}\n\nexport interface CreateOrganizationSubmission {\n readonly profileDetails: ProfileDetails;\n readonly organization: OrganizationDetails;\n}\n\ntype FacadeFailure = { readonly ok: false; readonly reason: CapxulErrorCode };\ntype EmptyResult = { readonly ok: true } | FacadeFailure;\ntype RuntimeInvocationControls = Parameters<CapxulClient[\"_internal\"][\"identity\"][\"send\"]>[1];\n\nexport interface CapxulAuth {\n readonly requestCode: (\n email: string,\n options?: InvocationOptions,\n ) => Promise<{ readonly ok: true; readonly requestedAt: number } | FacadeFailure>;\n readonly verifyCode: (\n otp: string,\n options?: InvocationOptions,\n ) => Promise<\n | { readonly ok: true; readonly authUserId: string; readonly profileComplete: boolean }\n | FacadeFailure\n >;\n readonly signOut: (options?: InvocationOptions) => Promise<EmptyResult>;\n readonly createOrganization: (\n submission: CreateOrganizationSubmission,\n options?: InvocationOptions,\n ) => Promise<{ readonly ok: true; readonly orgId: string } | FacadeFailure>;\n readonly completePersonal: (\n profileDetails: ProfileDetails,\n options?: InvocationOptions,\n ) => Promise<EmptyResult>;\n readonly retry: (options?: InvocationOptions) => Promise<EmptyResult>;\n}\n\ntype TransitionListener = (record: IdentityTransition, state: IdentityState) => void;\n\ninterface IdentityContextValue {\n readonly runtime: CapxulClient[\"_internal\"][\"identity\"];\n readonly send: CapxulSend;\n readonly auth: CapxulAuth;\n readonly addTransitionListener: (listener: TransitionListener) => () => void;\n}\n\nconst MISSING_IDENTITY_PROVIDER = Symbol(\"MISSING_IDENTITY_PROVIDER\");\nconst IdentityContext = createContext<\n IdentityContextValue | null | typeof MISSING_IDENTITY_PROVIDER\n>(MISSING_IDENTITY_PROVIDER);\n\nfunction controls(options: InvocationOptions | undefined) {\n if (options === undefined) return undefined;\n return {\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),\n ...(options.deadlineMs === undefined ? {} : { deadlineMs: options.deadlineMs }),\n ...(options.correlationId === undefined ? {} : { correlation_id: options.correlationId }),\n ...(options.journeyId === undefined ? {} : { journey_id: options.journeyId }),\n };\n}\n\nconst failure = (result: SendResult): FacadeFailure | null =>\n result.ok ? null : { ok: false, reason: result.refused };\n\nasync function guarded<T>(\n runtime: CapxulClient[\"_internal\"][\"identity\"],\n verb: Parameters<NonNullable<CapxulClient[\"_internal\"][\"identity\"][\"runFacade\"]>>[0],\n options: InvocationOptions | undefined,\n run: (invocation: RuntimeInvocationControls) => Promise<T>,\n): Promise<T | FacadeFailure> {\n const invocation = controls(options);\n try {\n return await (runtime.runFacade?.(verb, invocation, run) ?? run(invocation));\n } catch {\n return { ok: false, reason: \"UNKNOWN\" };\n }\n}\n\nconst ORGANIZATION_HANDLE = /^[a-z0-9-]{3,32}$/;\n\nexport function normalizeOrganization(\n organization: OrganizationDetails,\n): OrganizationDetails | null {\n const name = typeof organization.name === \"string\" ? organization.name.trim() : \"\";\n const handle =\n typeof organization.handle === \"string\" ? organization.handle.trim().toLowerCase() : \"\";\n if (name.length === 0 || !ORGANIZATION_HANDLE.test(handle)) return null;\n if (organization.bio !== undefined && typeof organization.bio !== \"string\") return null;\n if (organization.size !== undefined && typeof organization.size !== \"string\") return null;\n try {\n return {\n name,\n handle,\n country: toCountryCode(organization.country),\n ...(organization.bio === undefined ? {} : { bio: organization.bio }),\n ...(organization.size === undefined ? {} : { size: organization.size }),\n };\n } catch {\n return null;\n }\n}\n\nfunction createAuth(\n client: CapxulClient,\n clearAuthenticatedQueries: () => Promise<void>,\n): CapxulAuth {\n const runtime = client._internal.identity;\n const read = async (invocation: RuntimeInvocationControls): Promise<EmptyResult> => {\n const result = await runtime.send({ _tag: \"ReadSession\" }, invocation);\n return failure(result) ?? { ok: true };\n };\n const ensureAccount = async (invocation: RuntimeInvocationControls): Promise<EmptyResult> => {\n const result = await runtime.send({ _tag: \"EnsureAccount\" }, invocation);\n return failure(result) ?? { ok: true };\n };\n\n const reachClaimed = async (invocation: RuntimeInvocationControls): Promise<EmptyResult> => {\n let state = runtime.snapshot();\n if (state.phase !== \"authenticated\" || state.account.at === \"unknown\") {\n const result = await runtime.send({ _tag: \"EnsureAccount\" }, invocation);\n const refused = failure(result);\n if (refused !== null) return refused;\n state = result.state;\n }\n if (state.phase !== \"authenticated\") return { ok: false, reason: \"WRONG_STATE\" };\n if (state.account.at === \"claimed\") return { ok: true };\n const event: IdentityEvent =\n state.account.at === \"failed\"\n ? { _tag: \"RetryAccount\" }\n : state.account.at === \"counterfactual\"\n ? { _tag: \"ClaimAccount\" }\n : { _tag: \"EnsureAccount\" };\n const result = await runtime.send(event, invocation);\n const refused = failure(result);\n if (refused !== null) return refused;\n const next = result.state;\n return next.phase === \"authenticated\" && next.account.at === \"claimed\"\n ? { ok: true }\n : { ok: false, reason: \"WRONG_STATE\" };\n };\n\n const completeProfile = async (\n profile: ProfileDetails,\n invocation: RuntimeInvocationControls,\n ): Promise<EmptyResult> => {\n const result = await runtime.completeProfile(profile, invocation);\n return result.ok ? { ok: true } : result;\n };\n\n return {\n requestCode: (email, options) =>\n guarded(runtime, \"requestCode\", options, async (invocation) => {\n const result = await client.auth.signIn({ email }, invocation);\n if (!result.ok) return { ok: false as const, reason: result.error.code };\n const state = runtime.snapshot();\n return state.phase === \"otp_pending\"\n ? { ok: true as const, requestedAt: state.requestedAt }\n : {\n ok: false as const,\n reason: state.phase === \"faulted\" ? state.failure.code : \"UNKNOWN\",\n };\n }),\n verifyCode: (otp, options) =>\n guarded(runtime, \"verifyCode\", options, async (invocation) => {\n const state = runtime.snapshot();\n const email =\n state.phase === \"otp_pending\"\n ? state.email\n : state.phase === \"faulted\" && state.resume !== null\n ? state.resume.email\n : \"\";\n if (!/^\\d{6}$/.test(otp)) {\n const refused = await runtime.send(\n { _tag: \"VerifyOtp\", email, otp, now: Date.now() },\n invocation,\n );\n return failure(refused) ?? { ok: false as const, reason: \"UNKNOWN\" as const };\n }\n const result = await client.auth.verifyOtp({ email, code: otp }, invocation);\n if (!result.ok) return { ok: false as const, reason: result.error.code };\n const next = runtime.snapshot();\n return next.phase === \"authenticated\"\n ? {\n ok: true as const,\n authUserId: next.session.authUserId,\n profileComplete: next.profileComplete,\n }\n : {\n ok: false as const,\n reason: next.phase === \"faulted\" ? next.failure.code : \"UNKNOWN\",\n };\n }),\n signOut: (options) =>\n guarded(runtime, \"signOut\", options, async (invocation) => {\n const result = await client.auth.signOut(invocation);\n if (!result.ok) return { ok: false as const, reason: result.error.code };\n await clearAuthenticatedQueries();\n return { ok: true as const };\n }),\n completePersonal: (profile, options) =>\n guarded(runtime, \"completePersonal\", options, async (invocation) => {\n const completed = await completeProfile(profile, invocation);\n if (!completed.ok) return completed;\n const refreshed = await read(invocation);\n if (!refreshed.ok) return refreshed;\n return ensureAccount(invocation);\n }),\n createOrganization: (submission, options) =>\n guarded(runtime, \"createOrganization\", options, async (invocation) => {\n const organization = normalizeOrganization(submission.organization);\n if (organization === null) return { ok: false as const, reason: \"INVALID_INPUT\" as const };\n const completed = await completeProfile(submission.profileDetails, invocation);\n if (!completed.ok) return completed;\n const refreshed = await read(invocation);\n if (!refreshed.ok) return refreshed;\n const claimed = await reachClaimed(invocation);\n if (!claimed.ok) return claimed;\n const created = await runtime.send(\n { _tag: \"CreateOrganization\", draft: organization },\n invocation,\n );\n const refused = failure(created);\n if (refused !== null) return refused;\n const state = created.state;\n const org =\n state.phase === \"authenticated\" && state.account.at === \"claimed\"\n ? state.account.org\n : null;\n return org !== null && org.at !== \"creating\" && org.orgId !== null\n ? { ok: true as const, orgId: org.orgId }\n : { ok: false as const, reason: \"UNKNOWN\" as const };\n }),\n retry: (options) =>\n guarded(runtime, \"retry\", options, async (invocation) => {\n const state = runtime.snapshot();\n const event: IdentityEvent =\n state.phase === \"authenticated\" && state.account.at === \"claimed\"\n ? { _tag: \"RetryOrganization\" }\n : { _tag: \"RetryAccount\" };\n const result = await runtime.send(event, invocation);\n return failure(result) ?? { ok: true as const };\n }),\n };\n}\n\nexport function CapxulIdentityProvider({\n client,\n children,\n}: {\n readonly client: CapxulClient | null;\n readonly children: ReactNode;\n}) {\n const queryClient = useQueryClient();\n const runtime = client?._internal.identity ?? null;\n const listeners = useRef(new Set<TransitionListener>());\n\n useEffect(() => {\n if (client === null) return;\n void Promise.resolve()\n .then(() => client.auth.getSession())\n .catch(() => undefined);\n }, [client]);\n\n useEffect(() => {\n if (runtime === null) return;\n return runtime.subscribeTransitions((record) => {\n const state = runtime.snapshot();\n for (const listener of listeners.current) {\n try {\n listener(record, state);\n } catch {\n listeners.current.delete(listener);\n }\n }\n });\n }, [runtime]);\n\n const addTransitionListener = useCallback((listener: TransitionListener) => {\n listeners.current.add(listener);\n return () => listeners.current.delete(listener);\n }, []);\n\n const value = useMemo<IdentityContextValue | null>(() => {\n if (client === null || runtime === null) return null;\n const send: CapxulSend = (event, options) => runtime.send(event, controls(options));\n const clearAuthenticatedQueries = async () => {\n await queryClient.cancelQueries({ queryKey: capxulKeys.root });\n await queryClient.resetQueries({ queryKey: capxulKeys.root });\n };\n return {\n runtime,\n send,\n auth: createAuth(client, clearAuthenticatedQueries),\n addTransitionListener,\n };\n }, [client, runtime, addTransitionListener, queryClient]);\n\n return <IdentityContext.Provider value={value}>{children}</IdentityContext.Provider>;\n}\n\nfunction useIdentityContext(): IdentityContextValue {\n const value = useContext(IdentityContext);\n if (value === MISSING_IDENTITY_PROVIDER) {\n throw new Error(\"identity hooks must be used within <CapxulProvider>\");\n }\n if (value === null) {\n throw new Error(\"identity hooks require a ready <CapxulProvider>\");\n }\n return value;\n}\n\nconst noSubscribe = () => () => undefined;\nconst noState = () => null;\n\nexport function useCapxulIdentityOrNull(): IdentityState | null {\n const value = useContext(IdentityContext);\n if (value === MISSING_IDENTITY_PROVIDER) {\n throw new Error(\"identity hooks must be used within <CapxulProvider>\");\n }\n return useSyncExternalStore(\n value?.runtime.subscribe ?? noSubscribe,\n value?.runtime.snapshot ?? noState,\n value?.runtime.snapshot ?? noState,\n );\n}\n\nexport function useCapxulIdentity(): IdentityState {\n const state = useCapxulIdentityOrNull();\n if (state === null) throw new Error(\"identity hooks require a ready <CapxulProvider>\");\n return state;\n}\n\nexport function useCapxulSend(): CapxulSend {\n return useIdentityContext().send;\n}\n\nexport function useCapxulAuth(): CapxulAuth {\n return useIdentityContext().auth;\n}\n\nexport function useCapxulDestination(): Destination | null {\n const state = useCapxulIdentity();\n const next = resolveIdentityDestination(state);\n const held = useRef<{ readonly key: string; readonly value: Destination | null } | null>(null);\n const key = JSON.stringify(next);\n if (held.current?.key !== key) held.current = { key, value: next };\n return held.current.value;\n}\n\nexport function useCapxulTransitions(listener: TransitionListener): void {\n const { addTransitionListener } = useIdentityContext();\n useEffect(() => addTransitionListener(listener), [addTransitionListener, listener]);\n}\n\nexport const entered = (record: IdentityTransition, target: StateLabel): boolean =>\n record.outcome === \"applied\" && record.from !== target && record.to === target;\n","\"use client\";\n\n// CapxulProvider — owns the client lifecycle (sdk-provider-owned-bootstrap.md).\n//\n// Two modes:\n// - `publishableKey` (browser/app): the provider runs the async bootstrap via\n// `createCapxulClient`, owns the TanStack QueryClient, exposes status via\n// `useCapxul()`, and closes the client on unmount / re-bootstrap.\n// - `client` (Node/server consumers that bootstrap before React, plus test\n// harnesses): a pre-built client is supplied; the provider is `ready`\n// immediately and leaves that client's lifecycle to the caller.\n//\n// `signer` threads into the deploy lane via `createCapxulClient` when supplied.\n// Browser apps with `requirement: \"deployed\"` omit it — the SDK auto-wires Openfort.\n\nimport * as React from \"react\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\n\nimport type {\n AccountRequirement,\n CapxulClient,\n CapxulError,\n CapxulErrorCode,\n CapxulSigner,\n ObservationAdapter,\n TelemetryPort,\n} from \"@capxul/sdk\";\nimport { createCapxulClient, isCapxulError } from \"@capxul/sdk\";\n\nimport {\n CapxulBootstrapProvider,\n type CapxulBootstrapState,\n} from \"./internal/capxul-bootstrap-context\";\nimport { CapxulClientProvider } from \"./internal/capxul-client-context\";\nimport { CapxulIdentityProvider } from \"./identity\";\n\nvoid React;\n\ntype CapxulProviderSharedProps = {\n /** Bring your own QueryClient; otherwise the provider creates one. */\n readonly queryClient?: QueryClient;\n readonly children: ReactNode;\n};\n\n/** Browser / app path — the provider bootstraps the client from a publishable key. */\ntype CapxulProviderPublishableKeyProps = CapxulProviderSharedProps & {\n readonly publishableKey: string;\n readonly client?: never;\n /** Host-owned observation adapter passed to the core SDK boundary. */\n readonly observation?: ObservationAdapter;\n /**\n * Host success-telemetry sink, typically `telemetryFromPostHog(posthog, …)`.\n * Events from SDK producers wired to this port reach the host's PostHog\n * person after the host calls `identify()`.\n */\n readonly telemetry?: TelemetryPort;\n /** Init-time account readiness target. Default `\"none\"`. */\n readonly requirement?: AccountRequirement;\n /**\n * Optional consumer-held signer for the deploy lane. Omitted in browser apps\n * with `requirement: \"deployed\"` — the SDK wires Openfort from bootstrap.\n */\n readonly signer?: CapxulSigner;\n};\n\n/**\n * Node / server / test path — a pre-built client is supplied; lifecycle stays\n * with the caller. Mutually exclusive with `publishableKey`.\n */\ntype CapxulProviderInjectedClientProps = CapxulProviderSharedProps & {\n readonly client: CapxulClient;\n readonly publishableKey?: never;\n /** Injected clients must be created with observation at their owning factory. */\n readonly observation?: never;\n /** Injected clients must be created with telemetry at their owning factory. */\n readonly telemetry?: never;\n readonly requirement?: never;\n readonly signer?: never;\n};\n\nexport type CapxulProviderProps =\n | CapxulProviderPublishableKeyProps\n | CapxulProviderInjectedClientProps;\n\ntype OwnedBootstrap = {\n readonly input: Parameters<typeof createCapxulClient>[0];\n readonly client: CapxulClient | null;\n readonly status: CapxulBootstrapState[\"status\"];\n readonly error: CapxulError | null;\n};\n\n/**\n * Transient failure codes worth a retry — network blips, rate limits, and\n * upstream provider/unknown hiccups that a later attempt may clear. Everything\n * else (including any future code) is deterministic and NOT retried: retrying a\n * deterministic failure only multiplies the failed backend actions. A fresh\n * user with no Safe yet hits `SMART_ACCOUNT_MISSING` on every attempt, so the\n * old blanket `retry: 2` tripled that (and every other deterministic) failed\n * action for zero benefit (#1031).\n */\nconst RETRYABLE_QUERY_ERROR_CODES: ReadonlySet<CapxulErrorCode> = new Set([\n \"NETWORK_ERROR\",\n \"RATE_LIMITED\",\n \"PROVIDER_ERROR\",\n \"UNKNOWN\",\n]);\n\n/** Matches the previous `retry: 2` budget (initial attempt + up to 2 retries). */\nconst MAX_CAPXUL_QUERY_RETRIES = 2;\n\n/**\n * TanStack `retry` predicate: `failureCount` is 0-indexed and checked before\n * increment, so `< MAX` reproduces the old numeric budget for retryable codes.\n * Exported for direct unit coverage of the deterministic-vs-transient split.\n */\nexport function shouldRetryCapxulQuery(failureCount: number, error: unknown): boolean {\n if (failureCount >= MAX_CAPXUL_QUERY_RETRIES) return false;\n return isCapxulError(error) && RETRYABLE_QUERY_ERROR_CODES.has(error.code);\n}\n\n/**\n * The default query client used when the host injects none. Exported so a test\n * can pin that `queries.retry` is wired to `shouldRetryCapxulQuery` — reverting\n * it to the old blanket `retry: 2` must fail a test (#1031).\n */\nexport function makeDefaultQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: { retry: shouldRetryCapxulQuery, staleTime: 30_000 },\n mutations: { retry: 0 },\n },\n });\n}\n\nfunction isCapxulQueryKey(queryKey: readonly unknown[]): boolean {\n return queryKey[0] === \"capxul\";\n}\n\nfunction clearClientScopedQueries(queryClient: QueryClient, ownsQueryClient: boolean): void {\n if (ownsQueryClient) {\n queryClient.clear();\n return;\n }\n queryClient.removeQueries({ predicate: (query) => isCapxulQueryKey(query.queryKey) });\n}\n\nexport function CapxulProvider(props: CapxulProviderProps) {\n const {\n publishableKey,\n client: injectedClient,\n requirement,\n signer,\n observation,\n telemetry,\n queryClient,\n children,\n } = props;\n\n // The QueryClient is pinned at mount: a later `queryClient` prop swap is\n // ignored (consumers should not swap it mid-tree) — pass your own once, or\n // let the provider create one.\n const [resolvedQueryClient] = useState(() => queryClient ?? makeDefaultQueryClient());\n const [ownsQueryClient] = useState(() => queryClient === undefined);\n\n const [attempt, setAttempt] = useState(0);\n const retry = useCallback(() => {\n setAttempt((n) => n + 1);\n }, []);\n const bootstrapInput = useMemo(\n () =>\n publishableKey === undefined\n ? null\n : {\n publishableKey,\n ...(requirement === undefined ? {} : { requirement }),\n ...(signer === undefined ? {} : { signer }),\n ...(observation === undefined ? {} : { observation }),\n ...(telemetry === undefined ? {} : { telemetry }),\n },\n [publishableKey, requirement, signer, observation, telemetry, attempt],\n );\n const [ownedBootstrap, setOwnedBootstrap] = useState<OwnedBootstrap | null>(null);\n const activeOwnedBootstrap =\n bootstrapInput !== null && ownedBootstrap?.input === bootstrapInput ? ownedBootstrap : null;\n const client = injectedClient ?? activeOwnedBootstrap?.client ?? null;\n const previousClientRef = useRef<CapxulClient | null>(injectedClient ?? null);\n\n // Bootstrap path: the provider owns the client it creates and closes it on\n // unmount / re-bootstrap. The `cancelled` guard closes a client that resolves\n // after the effect tears down (StrictMode double-invoke, retry, unmount).\n useEffect(() => {\n if (bootstrapInput === null) return;\n let cancelled = false;\n let created: CapxulClient | null = null;\n setOwnedBootstrap({\n input: bootstrapInput,\n client: null,\n status: \"bootstrapping\",\n error: null,\n });\n void (async () => {\n const result = await createCapxulClient(bootstrapInput);\n if (cancelled) {\n if (result.ok) await result.value._internal.close?.();\n return;\n }\n if (result.ok) {\n created = result.value;\n setOwnedBootstrap({\n input: bootstrapInput,\n client: result.value,\n status: \"ready\",\n error: null,\n });\n } else {\n setOwnedBootstrap({\n input: bootstrapInput,\n client: null,\n status: \"error\",\n error: result.error,\n });\n }\n })();\n return () => {\n cancelled = true;\n void created?._internal.close?.();\n };\n }, [bootstrapInput]);\n\n useEffect(() => {\n const previous = previousClientRef.current;\n if (previous !== null && previous !== client) {\n clearClientScopedQueries(resolvedQueryClient, ownsQueryClient);\n }\n previousClientRef.current = client;\n }, [client, ownsQueryClient, resolvedQueryClient]);\n\n const bootstrapState = useMemo<CapxulBootstrapState>(\n () => ({\n status:\n injectedClient === undefined ? (activeOwnedBootstrap?.status ?? \"bootstrapping\") : \"ready\",\n error: injectedClient === undefined ? (activeOwnedBootstrap?.error ?? null) : null,\n retry,\n }),\n [activeOwnedBootstrap, injectedClient, retry],\n );\n\n // Validate AFTER the hooks so a publishableKey↔client prop transition never\n // changes the hook count (rules of hooks); the throw aborts render cleanly.\n if ((publishableKey === undefined) === (injectedClient === undefined)) {\n throw new Error(\"CapxulProvider requires exactly one of `publishableKey` or `client`\");\n }\n\n return (\n <QueryClientProvider client={resolvedQueryClient}>\n <CapxulBootstrapProvider value={bootstrapState}>\n <CapxulClientProvider client={client}>\n <CapxulIdentityProvider client={client}>{children}</CapxulIdentityProvider>\n </CapxulClientProvider>\n </CapxulBootstrapProvider>\n </QueryClientProvider>\n );\n}\n","\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type {\n IdentityState,\n IdentityDestination as Destination,\n OrgLane,\n Readiness,\n} from \"@capxul/sdk\";\n\nimport {\n normalizeOrganization,\n useCapxulAuth,\n useCapxulDestination,\n useCapxulIdentity,\n useCapxulSend,\n type CapxulAuth,\n type CreateOrganizationSubmission,\n type InvocationOptions,\n type OrganizationDetails,\n type ProfileDetails,\n} from \"./identity\";\n\nexport type Slot<P> = (props: P) => ReactNode;\nexport type ActionResult =\n | { readonly ok: true }\n | { readonly ok: false; readonly reason: import(\"@capxul/sdk\").CapxulErrorCode };\nexport type ControllerAction = () => Promise<ActionResult>;\nexport type RetryAction = (options: InvocationOptions) => Promise<ActionResult>;\nexport type NavigationAction = () => void;\n\nexport type SignedOutState = Extract<IdentityState, { phase: \"signed_out\" }>;\nexport type OtpPendingState = Extract<IdentityState, { phase: \"otp_pending\" }>;\nexport type PendingAuthState = Extract<\n IdentityState,\n { phase: \"otp_sending\" | \"otp_verifying\" | \"signing_out\" }\n>;\nexport type FaultedState = Extract<IdentityState, { phase: \"faulted\" }>;\nexport type AuthenticatedState = Extract<IdentityState, { phase: \"authenticated\" }>;\nexport type AccountProgress = Exclude<Readiness, { at: \"failed\" } | { at: \"claimed\" }>;\nexport type AccountFailure = Extract<Readiness, { at: \"failed\" }>;\nexport type OrgProgress = Exclude<OrgLane, { at: \"failed\" } | { at: \"ready\" }>;\nexport type OrgFailure = Extract<OrgLane, { at: \"failed\" }>;\nexport type ReadyDestination = Extract<\n Destination,\n { to: \"dashboardPersonal\" | \"dashboardOrganization\" }\n>;\n\nexport interface AuthenticationSlots {\n readonly email: Slot<{ state: SignedOutState; requestCode: CapxulAuth[\"requestCode\"] }>;\n readonly otp: Slot<{\n state: OtpPendingState;\n verifyCode: CapxulAuth[\"verifyCode\"];\n back: ControllerAction;\n }>;\n readonly pending: Slot<{ state: PendingAuthState }>;\n readonly failure: Slot<{\n state: FaultedState;\n recover: ControllerAction;\n back: ControllerAction;\n }>;\n readonly success: Slot<{\n state: AuthenticatedState;\n destination: Destination | null;\n }>;\n}\n\nconst action = async (\n send: ReturnType<typeof useCapxulSend>,\n event: Parameters<ReturnType<typeof useCapxulSend>>[0],\n): Promise<ActionResult> => {\n const result = await send(event);\n return result.ok ? { ok: true } : { ok: false, reason: result.refused };\n};\n\nexport function CapxulAuthenticationController({ slots }: { readonly slots: AuthenticationSlots }) {\n const state = useCapxulIdentity();\n const destination = useCapxulDestination();\n const auth = useCapxulAuth();\n const send = useCapxulSend();\n switch (state.phase) {\n case \"signed_out\":\n return slots.email({ state, requestCode: auth.requestCode });\n case \"otp_pending\":\n return slots.otp({\n state,\n verifyCode: auth.verifyCode,\n back: () => action(send, { _tag: \"Reset\" }),\n });\n case \"otp_sending\":\n case \"otp_verifying\":\n case \"signing_out\":\n return slots.pending({ state });\n case \"faulted\":\n return slots.failure({\n state,\n recover: () =>\n action(\n send,\n state.resume === null ? { _tag: \"Reset\" } : { _tag: \"ResumeOtpEntry\", now: Date.now() },\n ),\n back: () => action(send, { _tag: \"Reset\" }),\n });\n case \"authenticated\":\n return slots.success({ state, destination });\n }\n}\n\nexport type ProfileSlotProps =\n | {\n readonly intent: \"personal\";\n readonly state: AuthenticatedState;\n readonly completePersonal: CapxulAuth[\"completePersonal\"];\n readonly cancel: NavigationAction;\n }\n | {\n readonly intent: \"organization\";\n readonly state: AuthenticatedState;\n readonly continueOrganization: (profile: ProfileDetails) => void;\n readonly cancel: NavigationAction;\n };\n\nexport interface OnboardingControllerProps {\n readonly intent: \"personal\" | \"organization\" | null;\n readonly organizationProfile: ProfileDetails | null;\n readonly submittedOrganization: CreateOrganizationSubmission | null;\n readonly onIntent: (intent: \"personal\" | \"organization\") => void;\n readonly onOrganizationProfile: (profile: ProfileDetails | null) => void;\n readonly onSubmittedOrganization: (submission: CreateOrganizationSubmission | null) => void;\n readonly navigation: {\n readonly selectorBack: NavigationAction;\n readonly profileCancel: NavigationAction;\n readonly organizationBack: NavigationAction;\n readonly organizationCancel: NavigationAction;\n };\n readonly slots: {\n readonly intent: Slot<{\n state: AuthenticatedState;\n select: OnboardingControllerProps[\"onIntent\"];\n back: NavigationAction;\n }>;\n readonly profile: Slot<ProfileSlotProps>;\n readonly organization: Slot<{\n state: AuthenticatedState;\n profileDetails: ProfileDetails;\n submitted: CreateOrganizationSubmission | null;\n pinnedHandle: string | null;\n submit: (\n organization: OrganizationDetails,\n options: InvocationOptions,\n ) => ReturnType<CapxulAuth[\"createOrganization\"]>;\n back: NavigationAction;\n cancel: NavigationAction;\n }>;\n readonly accountProgress: Slot<{ state: AuthenticatedState; account: AccountProgress }>;\n readonly accountFailure: Slot<{\n state: AuthenticatedState;\n account: AccountFailure;\n retry?: RetryAction;\n }>;\n readonly organizationProgress: Slot<{ state: AuthenticatedState; org: OrgProgress }>;\n readonly organizationFailure: Slot<{\n state: AuthenticatedState;\n org: OrgFailure;\n retry?: RetryAction;\n }>;\n readonly ready: Slot<{ state: AuthenticatedState; destination: ReadyDestination }>;\n };\n}\n\nfunction ready(destination: Destination | null): destination is ReadyDestination {\n return destination?.to === \"dashboardPersonal\" || destination?.to === \"dashboardOrganization\";\n}\n\n// The ruled exhaustive intent/Profile/account/Organization slot table is clearer\n// as one flat selector than split across hidden partial routers.\n// oxlint-disable-next-line eslint/complexity\nexport function CapxulOnboardingController(props: OnboardingControllerProps) {\n const state = useCapxulIdentity();\n const destination = useCapxulDestination();\n const auth = useCapxulAuth();\n if (state.phase !== \"authenticated\") return null;\n\n const { slots, navigation } = props;\n if (props.intent === null) {\n return slots.intent({ state, select: props.onIntent, back: navigation.selectorBack });\n }\n\n if (props.intent === \"personal\" && !state.profileComplete) {\n return slots.profile({\n intent: \"personal\",\n state,\n completePersonal: auth.completePersonal,\n cancel: navigation.profileCancel,\n });\n }\n\n const submission = props.submittedOrganization;\n if (\n props.intent === \"organization\" &&\n props.organizationProfile === null &&\n submission === null\n ) {\n return slots.profile({\n intent: \"organization\",\n state,\n continueOrganization: props.onOrganizationProfile,\n cancel: navigation.profileCancel,\n });\n }\n\n if (\n props.intent === \"organization\" &&\n props.organizationProfile !== null &&\n submission === null\n ) {\n return organizationForm(props, state, auth, null);\n }\n\n if (submission !== null && state.account.at !== \"claimed\") {\n if (state.account.at === \"failed\") {\n const retry = state.account.retryable\n ? (options: InvocationOptions) => auth.createOrganization(submission, options)\n : undefined;\n return slots.accountFailure({\n state,\n account: state.account,\n ...(retry === undefined ? {} : { retry }),\n });\n }\n return slots.accountProgress({ state, account: state.account });\n }\n\n if (submission !== null && state.account.at === \"claimed\") {\n const org = state.account.org;\n if (org === null) return organizationForm(props, state, auth, submission);\n if (org.at === \"failed\") {\n const retry = org.retryable\n ? org.orgId === null\n ? (options: InvocationOptions) => auth.createOrganization(submission, options)\n : auth.retry\n : undefined;\n return slots.organizationFailure({\n state,\n org,\n ...(retry === undefined ? {} : { retry }),\n });\n }\n if (org.at !== \"ready\") return slots.organizationProgress({ state, org });\n }\n\n if (state.account.at === \"failed\") {\n return slots.accountFailure({\n state,\n account: state.account,\n ...(state.account.retryable ? { retry: auth.retry } : {}),\n });\n }\n if (state.account.at !== \"claimed\") {\n return slots.accountProgress({ state, account: state.account });\n }\n return ready(destination) ? slots.ready({ state, destination }) : null;\n}\n\nfunction organizationForm(\n props: OnboardingControllerProps,\n state: AuthenticatedState,\n auth: CapxulAuth,\n submitted: CreateOrganizationSubmission | null,\n) {\n const profileDetails = submitted?.profileDetails ?? props.organizationProfile;\n if (profileDetails === null) return null;\n return props.slots.organization({\n state,\n profileDetails,\n submitted,\n pinnedHandle: submitted?.organization.handle ?? null,\n submit: (organization, options) => {\n if (submitted !== null) return auth.createOrganization(submitted, options);\n const normalized = normalizeOrganization(organization);\n if (normalized === null) {\n return Promise.resolve({ ok: false, reason: \"INVALID_INPUT\" });\n }\n const next = { profileDetails, organization: normalized };\n props.onSubmittedOrganization(next);\n return auth.createOrganization(next, options);\n },\n back: () => {\n props.onOrganizationProfile(null);\n props.navigation.organizationBack();\n },\n cancel: props.navigation.organizationCancel,\n });\n}\n"],"mappings":";;;;;AAqBA,MAAM,yBAAyB,cAA2C,IAAI;AAO9E,SAAgB,wBAAwB,EAAE,OAAO,YAA0C;CACzF,OACE,oBAAC,uBAAuB,UAAxB;EAAwC;EAAQ;CAA0C,CAAA;AAE9F;AAEA,SAAgB,YAAkC;CAChD,MAAM,QAAQ,WAAW,sBAAsB;CAC/C,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM,gDAAgD;CAElE,OAAO;AACT;;;ACjCA,MAAM,iCAAiC,OAAO,gCAAgC;AAE9E,MAAM,sBAAsB,cAE1B,8BAA8B;AAOhC,SAAgB,qBAAqB,EAAE,QAAQ,YAAuC;CACpF,OAAO,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAAS;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