Scan your whole stack
From OX Research Newsroom
Are you using @xochi/client?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.4.0
@xochi/client was last scanned on 29 Nov 2026 at version 0.4.0. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.4.0 LATEST | 29 Nov 2026 | No rules fired |
| 0.3.1 | 29 Nov 2026 | No rules fired |
| 0.3.0 | 28 Nov 2026 | No rules fired |
| 0.2.1 | 27 Nov 2026 | Not shown |
| 0.2.1-staging.0 | 26 Nov 2026 | Not shown |
Findings for v0.4.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.4.0; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Cross-chain swap client for the Xochi Worker API (https://api.xochi.fi/api/*): a transport, a pure trade state machine (update(model, msg) -> [model, effects], view(model)), the fund-safety checks it runs on every quote, and the layered fee reference.
npm install @xochi/client
Node 22+ or a current browser. ESM + CommonJS with types.
import { createXochiClient } from "@xochi/client";
const xochi = createXochiClient({
baseUrl: "https://api.xochi.fi",
getAuthToken: () => session.token, // optional
getAuthGeneration: () => session.generation, // optional in-memory credential epoch
onAuthExpired: (e) => session.reauthenticate(e),
});
const quote = await xochi.getQuote(request);
execute makes one attempt and never retries. Never re-post a failed one: even a refused execute leaves its signed request executable until it expires, so poll getIntentStatus until the intent ends. The only resend is the machine's, on ApiError.notAccepted (Fund safety).getIntentStatus returns the status, { notFound: true } on 404, or null on a transient failure.execute response may carry readToken, kept only for the intent the execute named. Pass { readToken } to getIntent / getIntentStatus, which send it as X-Xochi-Read-Token. Who reads which view with and without it: IntentReadOptions (SPEC.md §5.1).takeApiErrorReadToken(error), before the error reaches any reporter. It is never a property of the error.ResumeRequested carries none), and delete it once the intent is no longer shown. Not persisting it is safe.read_token) is never re-issued. Wallet SIWE for the intent's wallet is then the only way to the full view.getIntent rejects a token not of the issued shape before any request; getIntentStatus reads anonymously instead and logs it once per intent.getIntentStatus carries legsWithheld: true and settlementConfirmed, and getIntent returns a WithheldIntentRecord. IntentState.legsWithheld is null before the first status reply, so test legsWithheld === true before offering recovery (the token for stealth, else wallet SIWE).execute is pinned to the baseUrl origin. A refusal is a RedirectRefused: getIntent / getIntentHistory / execute reject with it; getIntentStatus logs it once per intent and returns null. Which redirects are followed: RedirectRefused.execute follows none, and its refusal is in doubt: point baseUrl at the origin that answers /api/intent/execute itself, or every swap reads "Still confirming".fetch MUST honour redirect: "manual" and return the response it fetched. A response that names no url is refused on execute and on token reads (logged once).ApiError.message is a capped, redacted excerpt of the error body; never log raw bodies. What is redacted: src/transport/redact.ts.getQuoteSupportCode(result) returns the optional X-Xochi-Support-Code from the original declined getQuote result or the final error it throws. Pass that object directly to the accessor. Offer the code for manual copying into a private report and keep it out of logs, URLs, and automatic reporting.ApiError with retryAfter (absolute unix seconds, capped at MAX_RETRY_WAIT_SEC), read from Retry-After, else X-RateLimit-Reset, else a JSON body's retryAfter. notAccepted is the exception.ApiError.errorCategory preserves a JSON error body's error_category. Copy it into StructuredError.errorCategory when reporting failures to the machine. tag_resolution_unavailable never auto-retries: show the lookup error and offer a manual fresh quote for the same tag. It invalidates held quotes even on silent refresh; tag quotes never cache one-time recipient addresses. RefreshRequested forces a new quote after this failure.tag_unresolved decline. It also clears a stale held quote, including on silent refresh; the machine retains its category in StructuredError.errorCategory.ApiError.notAccepted is true only on the Worker's not-accepted 503 for the executed intent (exact shape: isNotAcceptedExecuteBody in src/transport/client.ts); its retryAfter is the body's retry_after wait, which a later Retry-After header can only extend. Pass it to the machine as ErrorReport.notAccepted.ApiError.inDoubt is false only on the three execute answers that speak for the intent (the not-accepted 503, a 502 failed with substatus: "not_executed", a 409 promo_unavailable); every other execute failure, ApiError or not, is in doubt (isInDoubtExecuteAnswer). It is for the host's copy and logs; the machine never reads it. false does not end the order: the signed request stays executable until it expires. Word input errors from code and the message.Credential-failure callbacks apply only to the request's still-current bearer.
Set getAuthGeneration to an in-memory counter changed on logout and
re-authentication to invalidate earlier requests even when a token is reused.
The transport rechecks both values after reading the error body; neither value
is added to the callback event.
QuoteResponseSchema / ExecuteResponseSchema (undeclared top-level keys tolerated); a malformed read_token is dropped rather than failing the execute. Each attempt's timeout stays armed until the body is read. The only quote-cache TTL is DEFAULT_TIMEOUTS.quoteCacheTtlMs..strict() (the declared wire shape); the transport validates with a .passthrough() copy so undeclared served fields (e.g. escrow) reach the signer checks. Running the exported schema directly is stricter than the transport.TOKENS is the public per-chain metadata registry. TokenInfo, findTokenBySymbol,
findTokenByAddress, getTokenInfoByAddress, getTokenInfoForChain,
getTokenDecimals and TOKEN_DECIMALS expose the same address/symbol/decimal
vocabulary to widgets and headless clients. getTokenInfoForChain resolves only
an address registered on that exact chain and returns undefined otherwise;
Tron addresses remain case-sensitive. The address-only EVM lookup keeps its
explicit display fallback for unknown contracts.
Registry presence means only that metadata can be resolved. It never advertises
a route: use the live capability routes contract and advertisedRoute before
offering a chain/token pair. isStableSymbol is the case-sensitive domain
classification used for dollar-stablecoin pricing and rate checks, not a token
picker or route allowlist.
parseCapabilities, advertisedRoute and routeSupportsPrivacyMode are re-exported from @xochi/client for route discovery:
const capabilities = parseCapabilities(await response.json());
const route = capabilities
? advertisedRoute(capabilities, {
origin: { chainId: 8453, token: "USDC" },
destination: { kind: "chain", chainId: 8453, token: "DAI" },
})
: null;
const stealth = route?.privacyModes.includes("stealth") === true;
When routes is present, it is the authoritative selector source for same-symbol and cross-token routes; query the exact typed endpoint and do not reconstruct a cross-product. A served [] or malformed present value means no routes. Only an absent field parses as null and triggers the legacy conservative downgrade: same-symbol cross-chain corridors may use their existing leg support, cross-token same-chain still requires conversionPairs[].sameChain, and cross-token cross-chain remains disabled. A chain destination is never a zk_money destination by implication.
effectiveStealthChains(capabilities.stealthChains, (chainId) => stealthFactoryFor(capabilities, chainId)) intersects current solver
advertisement and its per-chain factory with TRUSTED_STEALTH_FACTORIES for
quote availability. Missing, untrusted, or mismatched factories and missing
advertisement fail closed to []. trustedStealthChains() is different: it
lists every locally trusted chain for scanning and claiming historical payments,
regardless of current quote availability.
A stealth payout to address(P') is claimed by delegating that EOA under
EIP-7702. Sign an authorization only to a delegate on TRUSTED_7702_DELEGATES
for the payment's chain (isTrusted7702Delegate), never to one the server names.
resolveRouteModel(capabilities, state, options) validates chain/token rows and
indexes only exact advertised routes. state is "live", "stale",
"fallback" or "failed"; only live, present typed routes authorize execution.
Duplicate rows, invalid addresses/decimals and untrusted Stealth factories fail
closed. Typed zk_money destinations remain distinct from chain destinations.
The required options.chainEnabledForRole(chainId, role) applies the consuming
application's launch gates. options.presentationTokens supplies names and
optional logos only; addresses, decimals and route authority always come from
capabilities. RouteToken, RouteLeg, ExecutableRouteDestination,
ResolvedRouteModel and ResolvedRouteAvailability describe this model.
Presentation defaults and fallback capability construction remain outside the
client.
capabilityVmType, destination/refund address validation, token-role accessors,
orderBounds and servedStealthChains share the same capability interpretation.
stealthToggleState and shieldedToggleState let quotes narrow, never expand,
live settlement eligibility. parseTrustFeatures accepts only literal true;
effectiveTrustScore returns zero while trust economics is disabled.
The additional shared vocabulary was extracted from MIT-licensed
@xochi/shared (Copyright 2025-2026 Xochi Contributors), under this package's
MIT license. Fee display helpers derive their layers from the existing public
FEE_SCHEDULE; they do not maintain an alternate fee schedule. Static address
maps are metadata, never route authorization or a security pin.
Widget presentation stays in @xochi/widget: popular-token ordering, offline
origin/destination display lists and estimated fallback USD prices are not client
exports. These preserve the extracted widget's display continuity only; typed
live routes remain the execution authority, and only fresh live prices can feed
market comparisons or the excessive-slippage guard. The fallback lists do not
advertise executable routes.
Token-amount formatting/parsing, address truncation, formatSupportedTokens and
its display cap are owned by the widget's formatting utilities, not exported
from the client. classifyDecline and supportedOriginSentence accept
caller-supplied origin symbols for guidance; without them they give generic
advice, not a static token support claim.
This #98 ownership disposition is an extraction prerequisite only: publication remains gated on the producer/claim-chain prerequisites tracked in #98 and separate registry approval.
atomic, parseRamp, rampOutcome, and checkRampCommand expose the provider-neutral
ramp/1 contract. TypeScript uses canonical snake_case wire fields.
Atomic money never uses floating-point numbers. Independent Peer/Xochi snapshots
preserve partial success; in-doubt operations permit reconciliation, never execute-again.
The exported JSON Schema and runtime-neutral conformance vectors are available at
@xochi/client/ramp/contract.schema.json and @xochi/client/ramp/conformance.json.
import { atomic, parseRamp, rampOutcome } from "@xochi/client";
const baseUsdcAmount = atomic("5000000"); // 5 USDC in atomic units
const message = parseRamp(untrustedJson);
if (message.ok && message.value.kind === "snapshot") {
const outcome = rampOutcome(message.value);
renderRampState(outcome.state);
}
Preserve optional peer.payout_state and peer.partial_result when storing
sanitized snapshots. Older ramp/1 messages can omit either field.
createRampClient serializes commands through a RampOperationStore; trusted adapters
own external provider and wallet boundaries. offerRoute(operationId, context) adds
an optional onramp Xochi leg only after confirmed Peer delivery and hold release.
It obtains no quote and cannot repeat a Peer operation.
createXochiRampLeg({ store, delivered, driver }) implements that leg over the existing
validated Xochi swap interpreter. The driver fetches a fresh quote, executes only its
held quote through an explicit wallet approval, and polls the existing Xochi intent.
Its preview is an allowlisted projection with exact atomic amounts, recipient,
settlement and expiry; signing material stays inside the swap interpreter.
approve_route prepares the preview, execute_route approves execution, and
recover_route fetches a fresh quote after a proven safe failure. Unknown execution
permits only check_status; skip_route preserves Peer completion. Failed route
quotes remain recoverable partial success, including a timeout before execution.
The Peer compatibility example evaluates one browser SDK graph separately from live provider availability. Public source and package compatibility do not grant hosted iframe permissions or prove live signed execution. No release, host cutover or deployment is included.
import { init, update, view, type MsgBody } from "@xochi/client";
let model = init(
{
solverPin: { erc3009Allowlist: [...], permit2Allowlist: [...], requirePin: true },
pullRecipients: { 8453: { erc3009: "0x...", permit2: "0x..." } }, // your pin
depositAttestationSigner: "0x...", // your pin; null refuses every deposit route
},
context,
);
function dispatch(body: MsgBody) {
const [next, effects] = update(model, { ...body, now: Date.now(), hidden: false });
model = next;
for (const effect of effects) perform(effect); // Api / Wallet / Timer / Emit
render(view(next));
}
Lifecycle rules the machine enforces, beyond the signer checks under Fund safety:
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.