@capxul/sdk-react 1.0.0-alpha.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -0
- package/dist/controllers-BU11km12.mjs +647 -0
- package/dist/controllers-BU11km12.mjs.map +1 -0
- package/dist/controllers-DuHYSiw1.d.mts +207 -0
- package/dist/controllers-DuHYSiw1.d.mts.map +1 -0
- package/dist/index.d.mts +156 -175
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +420 -395
- package/dist/index.mjs.map +1 -1
- package/dist/testing/index.d.mts +21 -0
- package/dist/testing/index.d.mts.map +1 -0
- package/dist/testing/index.mjs +24 -0
- package/dist/testing/index.mjs.map +1 -0
- package/package.json +10 -11
|
@@ -0,0 +1 @@
|
|
|
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,YAA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C;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"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { CapxulClient, CapxulErrorCode, IdentityDestination, IdentityEvent, IdentityProfileDetails, IdentityState, IdentityTransition, OrgLane, Readiness, StateLabel } from "@capxul/sdk";
|
|
3
|
+
|
|
4
|
+
//#region src/identity.d.ts
|
|
5
|
+
type Destination = IdentityDestination;
|
|
6
|
+
interface InvocationOptions {
|
|
7
|
+
readonly correlationId?: string;
|
|
8
|
+
readonly journeyId?: string;
|
|
9
|
+
readonly timeoutMs?: number;
|
|
10
|
+
readonly deadlineMs?: number;
|
|
11
|
+
readonly signal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
type SendResult = {
|
|
14
|
+
readonly ok: true;
|
|
15
|
+
readonly state: IdentityState;
|
|
16
|
+
} | {
|
|
17
|
+
readonly ok: false;
|
|
18
|
+
readonly refused: CapxulErrorCode;
|
|
19
|
+
readonly state: IdentityState;
|
|
20
|
+
};
|
|
21
|
+
type CapxulSend = (event: IdentityEvent, options?: InvocationOptions) => Promise<SendResult>;
|
|
22
|
+
type ProfileDetails = IdentityProfileDetails;
|
|
23
|
+
interface OrganizationDetails {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly handle: string;
|
|
26
|
+
readonly country: string;
|
|
27
|
+
readonly bio?: string;
|
|
28
|
+
readonly size?: string;
|
|
29
|
+
}
|
|
30
|
+
interface CreateOrganizationSubmission {
|
|
31
|
+
readonly profileDetails: ProfileDetails;
|
|
32
|
+
readonly organization: OrganizationDetails;
|
|
33
|
+
}
|
|
34
|
+
type FacadeFailure = {
|
|
35
|
+
readonly ok: false;
|
|
36
|
+
readonly reason: CapxulErrorCode;
|
|
37
|
+
};
|
|
38
|
+
type EmptyResult = {
|
|
39
|
+
readonly ok: true;
|
|
40
|
+
} | FacadeFailure;
|
|
41
|
+
interface CapxulAuth {
|
|
42
|
+
readonly requestCode: (email: string, options?: InvocationOptions) => Promise<{
|
|
43
|
+
readonly ok: true;
|
|
44
|
+
readonly requestedAt: number;
|
|
45
|
+
} | FacadeFailure>;
|
|
46
|
+
readonly verifyCode: (otp: string, options?: InvocationOptions) => Promise<{
|
|
47
|
+
readonly ok: true;
|
|
48
|
+
readonly authUserId: string;
|
|
49
|
+
readonly profileComplete: boolean;
|
|
50
|
+
} | FacadeFailure>;
|
|
51
|
+
readonly signOut: (options?: InvocationOptions) => Promise<EmptyResult>;
|
|
52
|
+
readonly createOrganization: (submission: CreateOrganizationSubmission, options?: InvocationOptions) => Promise<{
|
|
53
|
+
readonly ok: true;
|
|
54
|
+
readonly orgId: string;
|
|
55
|
+
} | FacadeFailure>;
|
|
56
|
+
readonly completePersonal: (profileDetails: ProfileDetails, options?: InvocationOptions) => Promise<EmptyResult>;
|
|
57
|
+
readonly retry: (options?: InvocationOptions) => Promise<EmptyResult>;
|
|
58
|
+
}
|
|
59
|
+
type TransitionListener = (record: IdentityTransition, state: IdentityState) => void;
|
|
60
|
+
declare function useCapxulIdentity(): IdentityState;
|
|
61
|
+
declare function useCapxulSend(): CapxulSend;
|
|
62
|
+
declare function useCapxulAuth(): CapxulAuth;
|
|
63
|
+
declare function useCapxulDestination(): Destination | null;
|
|
64
|
+
declare function useCapxulTransitions(listener: TransitionListener): void;
|
|
65
|
+
declare const entered: (record: IdentityTransition, target: StateLabel) => boolean;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/controllers.d.ts
|
|
68
|
+
type Slot<P> = (props: P) => ReactNode;
|
|
69
|
+
type ActionResult = {
|
|
70
|
+
readonly ok: true;
|
|
71
|
+
} | {
|
|
72
|
+
readonly ok: false;
|
|
73
|
+
readonly reason: import("@capxul/sdk").CapxulErrorCode;
|
|
74
|
+
};
|
|
75
|
+
type ControllerAction = () => Promise<ActionResult>;
|
|
76
|
+
type RetryAction = (options: InvocationOptions) => Promise<ActionResult>;
|
|
77
|
+
type NavigationAction = () => void;
|
|
78
|
+
type SignedOutState = Extract<IdentityState, {
|
|
79
|
+
phase: "signed_out";
|
|
80
|
+
}>;
|
|
81
|
+
type OtpPendingState = Extract<IdentityState, {
|
|
82
|
+
phase: "otp_pending";
|
|
83
|
+
}>;
|
|
84
|
+
type PendingAuthState = Extract<IdentityState, {
|
|
85
|
+
phase: "otp_sending" | "otp_verifying" | "signing_out";
|
|
86
|
+
}>;
|
|
87
|
+
type FaultedState = Extract<IdentityState, {
|
|
88
|
+
phase: "faulted";
|
|
89
|
+
}>;
|
|
90
|
+
type AuthenticatedState = Extract<IdentityState, {
|
|
91
|
+
phase: "authenticated";
|
|
92
|
+
}>;
|
|
93
|
+
type AccountProgress = Exclude<Readiness, {
|
|
94
|
+
at: "failed";
|
|
95
|
+
} | {
|
|
96
|
+
at: "claimed";
|
|
97
|
+
}>;
|
|
98
|
+
type AccountFailure = Extract<Readiness, {
|
|
99
|
+
at: "failed";
|
|
100
|
+
}>;
|
|
101
|
+
type OrgProgress = Exclude<OrgLane, {
|
|
102
|
+
at: "failed";
|
|
103
|
+
} | {
|
|
104
|
+
at: "ready";
|
|
105
|
+
}>;
|
|
106
|
+
type OrgFailure = Extract<OrgLane, {
|
|
107
|
+
at: "failed";
|
|
108
|
+
}>;
|
|
109
|
+
type ReadyDestination = Extract<IdentityDestination, {
|
|
110
|
+
to: "dashboardPersonal" | "dashboardOrganization";
|
|
111
|
+
}>;
|
|
112
|
+
interface AuthenticationSlots {
|
|
113
|
+
readonly email: Slot<{
|
|
114
|
+
state: SignedOutState;
|
|
115
|
+
requestCode: CapxulAuth["requestCode"];
|
|
116
|
+
}>;
|
|
117
|
+
readonly otp: Slot<{
|
|
118
|
+
state: OtpPendingState;
|
|
119
|
+
verifyCode: CapxulAuth["verifyCode"];
|
|
120
|
+
back: ControllerAction;
|
|
121
|
+
}>;
|
|
122
|
+
readonly pending: Slot<{
|
|
123
|
+
state: PendingAuthState;
|
|
124
|
+
}>;
|
|
125
|
+
readonly failure: Slot<{
|
|
126
|
+
state: FaultedState;
|
|
127
|
+
recover: ControllerAction;
|
|
128
|
+
back: ControllerAction;
|
|
129
|
+
}>;
|
|
130
|
+
readonly success: Slot<{
|
|
131
|
+
state: AuthenticatedState;
|
|
132
|
+
destination: IdentityDestination | null;
|
|
133
|
+
}>;
|
|
134
|
+
}
|
|
135
|
+
declare function CapxulAuthenticationController({
|
|
136
|
+
slots
|
|
137
|
+
}: {
|
|
138
|
+
readonly slots: AuthenticationSlots;
|
|
139
|
+
}): ReactNode;
|
|
140
|
+
type ProfileSlotProps = {
|
|
141
|
+
readonly intent: "personal";
|
|
142
|
+
readonly state: AuthenticatedState;
|
|
143
|
+
readonly completePersonal: CapxulAuth["completePersonal"];
|
|
144
|
+
readonly cancel: NavigationAction;
|
|
145
|
+
} | {
|
|
146
|
+
readonly intent: "organization";
|
|
147
|
+
readonly state: AuthenticatedState;
|
|
148
|
+
readonly continueOrganization: (profile: ProfileDetails) => void;
|
|
149
|
+
readonly cancel: NavigationAction;
|
|
150
|
+
};
|
|
151
|
+
interface OnboardingControllerProps {
|
|
152
|
+
readonly intent: "personal" | "organization" | null;
|
|
153
|
+
readonly organizationProfile: ProfileDetails | null;
|
|
154
|
+
readonly submittedOrganization: CreateOrganizationSubmission | null;
|
|
155
|
+
readonly onIntent: (intent: "personal" | "organization") => void;
|
|
156
|
+
readonly onOrganizationProfile: (profile: ProfileDetails | null) => void;
|
|
157
|
+
readonly onSubmittedOrganization: (submission: CreateOrganizationSubmission | null) => void;
|
|
158
|
+
readonly navigation: {
|
|
159
|
+
readonly selectorBack: NavigationAction;
|
|
160
|
+
readonly profileCancel: NavigationAction;
|
|
161
|
+
readonly organizationBack: NavigationAction;
|
|
162
|
+
readonly organizationCancel: NavigationAction;
|
|
163
|
+
};
|
|
164
|
+
readonly slots: {
|
|
165
|
+
readonly intent: Slot<{
|
|
166
|
+
state: AuthenticatedState;
|
|
167
|
+
select: OnboardingControllerProps["onIntent"];
|
|
168
|
+
back: NavigationAction;
|
|
169
|
+
}>;
|
|
170
|
+
readonly profile: Slot<ProfileSlotProps>;
|
|
171
|
+
readonly organization: Slot<{
|
|
172
|
+
state: AuthenticatedState;
|
|
173
|
+
profileDetails: ProfileDetails;
|
|
174
|
+
submitted: CreateOrganizationSubmission | null;
|
|
175
|
+
pinnedHandle: string | null;
|
|
176
|
+
submit: (organization: OrganizationDetails, options: InvocationOptions) => ReturnType<CapxulAuth["createOrganization"]>;
|
|
177
|
+
back: NavigationAction;
|
|
178
|
+
cancel: NavigationAction;
|
|
179
|
+
}>;
|
|
180
|
+
readonly accountProgress: Slot<{
|
|
181
|
+
state: AuthenticatedState;
|
|
182
|
+
account: AccountProgress;
|
|
183
|
+
}>;
|
|
184
|
+
readonly accountFailure: Slot<{
|
|
185
|
+
state: AuthenticatedState;
|
|
186
|
+
account: AccountFailure;
|
|
187
|
+
retry?: RetryAction;
|
|
188
|
+
}>;
|
|
189
|
+
readonly organizationProgress: Slot<{
|
|
190
|
+
state: AuthenticatedState;
|
|
191
|
+
org: OrgProgress;
|
|
192
|
+
}>;
|
|
193
|
+
readonly organizationFailure: Slot<{
|
|
194
|
+
state: AuthenticatedState;
|
|
195
|
+
org: OrgFailure;
|
|
196
|
+
retry?: RetryAction;
|
|
197
|
+
}>;
|
|
198
|
+
readonly ready: Slot<{
|
|
199
|
+
state: AuthenticatedState;
|
|
200
|
+
destination: ReadyDestination;
|
|
201
|
+
}>;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
declare function CapxulOnboardingController(props: OnboardingControllerProps): ReactNode;
|
|
205
|
+
//#endregion
|
|
206
|
+
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-DuHYSiw1.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controllers-DuHYSiw1.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,OAAA,EAAS,eAAA;EAAA,SACT,KAAA,EAAO,aAAA;AAAA;AAAA,KAGV,UAAA,IAAc,KAAA,EAAO,aAAA,EAAe,OAAA,GAAU,iBAAA,KAAsB,OAAA,CAAQ,UAAA;AAAA,KAE5E,cAAA,GAAiB,sBAAsB;AAAA,UAElC,mBAAA;EAAA,SACN,IAAA;EAAA,SACA,MAAA;EAAA,SACA,OAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA;AAAA;AAAA,UAGM,4BAAA;EAAA,SACN,cAAA,EAAgB,cAAA;EAAA,SAChB,YAAA,EAAc,mBAAmB;AAAA;AAAA,KAGvC,aAAA;EAAA,SAA2B,EAAA;EAAA,SAAoB,MAAA,EAAQ,eAAe;AAAA;AAAA,KAC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