> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://ensforge.com/api/mcp` to find what you need.

# Remote registration

`@ensforge/hca/remote` advances **saved session-backed registrations**. It does not remotely control an
owner wallet or expose arbitrary HCA call execution. The browser sends `{ action: "status" | "resume"
| "cancel", id }`; extra request fields are rejected.

```ts
import { createHcaRemoteHandler } from "@ensforge/hca/remote";

const handle = createHcaRemoteHandler({
  authenticate, // request credentials -> principal or null
  resolveConfig, // principal -> server config with durable storage
  authorize, // principal + action + operation identity -> boolean
  resolveExecution, // authorized signerReference -> session execution adapter
});
const json = await handle(requestBody, requestCredentials, abortSignal);
```

All callbacks are supplied by the host. Authenticate the requester, scope the database to their tenant,
then authorize access to the exact saved operation. Signer resolution happens only after authorization.
The saved operation must match the configured chain, use an adapter session and carry a signer reference.
The host provisions and protects the actual session key; browser requests never choose a key or replace
registration limits. Session revocation and expiry remain enforced by the account/provider path.

The result is a JSON string encoded for bigint-safe transport. It contains ID, revision, chain, HCA,
status and relevant timing/funding/hash fields. It excludes registration secrets, session keys,
permission payloads and provider internals. Do not JSON-stringify that returned string a second time.

## Browser transport

```ts
import { createRemoteHcaRegistrationActions } from "@ensforge/hca/remote";

const remote = createRemoteHcaRegistrationActions({
  transport: async (request, signal) => {
    const response = await fetch("/api/hca/registration", {
      method: "POST",
      credentials: "same-origin",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(request),
      signal,
    });
    if (!response.ok) throw new Error("Registration request failed");
    return response.text();
  },
});
const progress = await remote.getRegistration(config, { id });
```

`getRegistration`, `resumeRegistration` and `cancelRegistration` are ordinary Ensforge actions with
`.effect`. Use `useEnsQuery`/`useEnsMutation` in React. Responses are validated against the requested ID
and configured chain. Keep action objects stable across renders.

The [HTTP example](https://github.com/thenamespace/ensforge/blob/main/apps/docs/examples/hca/remote.ts) adapts Web `Request`/`Response`. Integrate your own authentication,
resource authorization, origin/CSRF checks, request limits, error logging and HTTP status mapping.
Never expose raw server exceptions to the browser. An HTTP timeout does not establish that submission
failed; fetch status before retrying. Aborting a browser request does not revoke server-held sessions.
