Kasada /p.js PScript PoW Extraction and cd Host Warming
Kasada /p.js (PScript) extraction is an offline protocol mechanism that reads a target host's proof-of-work parameters (lhw, difficulty, subCount, and seedSuffix) and warms the per-host cache used by POST /Solver/cd. Below: how PScriptRequest and pscript warming work.
Who this is for
Security researchers and protocol engineers integrating POST /Solver/cd against Kasada-protected origins who want to extract /p.js proof-of-work constants and eliminate pjs_host_unwarmed errors.
On this page
- What proof-of-work parameters does Kasada bake into /p.js?
- How does PScript-only mode work on the solver endpoint?
- How do you pass pscript to POST /Solver/cd to warm a host?
- How should your client handle pjs_host_unwarmed and pjs_warming?
- Key takeaways
- Conclusion and scope
- Evidence and sources
- Frequently asked questions
What proof-of-work parameters does Kasada bake into /p.js?
Each Kasada /p.js script embeds the host proof-of-work difficulty, sub-puzzle count, hash prefix, and seed suffix needed to mint single-use cd headers.
While the challenge bootstrap script (ips.js) executes inside the /fp challenge iframe to produce the initial /tl telemetry payload over a trusted TLS session, Kasada-protected pages also load a separate companion script whose path ends in /p.js. This script stays resident in the storefront context and computes a fresh x-kpsdk-cd proof-of-work header immediately before each protected XHR or GraphQL call.
In contrast to generic hashcash challenges, a target's /p.js file bakes host-specific constants directly into its JavaScript source. When you inspect /p.js through the Catmouse OpenAPI 3.1 contract, four proof-of-work fields are extracted into the pow response object:
lhw(Hash Prefix / Target Identifier)- The host-specific proof-of-work identifier baked into
/p.js. Whenseedis set to"ct-lhw"or"auto"onPOST /Solver/cd,lhwparticipates in deriving the puzzle seed alongside the session'sx-kpsdk-cttoken. difficultyandsubCount- The work factor and number of sub-puzzles that the client must solve to construct a valid
workTimeandanswersarray insidex-kpsdk-cd. seedSuffix- The static suffix string appended during seed construction when the target's
/p.jsbuild requires one. vHeader(Declared SDK Version)- The
x-kpsdk-vversion string declared inside/p.js, returned alongsidepowso callers can verify whether the storefront rotated its SDK build.
How does PScript-only mode work on the solver endpoint?
Sending a PScript field alongside an empty ipsBody extracts the declared version header and proof-of-work parameters without charging anything.
As documented under the PScriptRequest schema in /openapi.json, the solve endpoint supports an dedicated inspection mode when you want to parse a fetched /p.js file without solving an ips.js challenge. In the flat JSON shape, you pass PScript (aliases pScript, pscript, p_script) containing the UTF-8 source of /p.js and set "ipsBody": "" (present and empty; omitting ipsBody in the flat shape returns HTTP 400 missing field ipsBody, whereas inside a kasadaRequest envelope the ips key may be omitted).
Comparing PScriptRequest inspection versus POST /Solver/cd generation
The table below compares inspecting a /p.js file via PScriptRequest versus minting a live x-kpsdk-cd header via POST /Solver/cd:
| Aspect | PScriptRequest (ipsBody: "") | POST /Solver/cd (CdRequest) |
|---|---|---|
| Primary purpose | Parse /p.js and return vHeader + pow parameters | Mint a ready-to-send x-kpsdk-cd header value |
| Required fields | PScript and empty ipsBody: "" | host and platform ("web" or "ios") |
Geo fields (tz, tzOffset) | Not required | Not required |
| Billing impact | Not charged (payload is absent) | Charged to the key's USD balance at the cd price |
| Missing PoW behavior | Returns powError: "pscript_no_pow" | Returns 422 pjs_pow_not_found or pjs_host_unwarmed |
/p.js proof-of-work parameters and warming the per-host cache on POST /Solver/cd. Diagram by Catmouse Engineering.How do you pass pscript to POST /Solver/cd to warm a host?
While the Catmouse server keeps a per-host proof-of-work parameter cache warm for operator-configured hosts, your client can warm or refresh any host on demand by passing the fetched /p.js source in the pscript field of POST /Solver/cd (or its alias /cd).
The Python example below sends host, platform, the session's ct token (at least 16 characters), and the fetched pscript source to POST https://kasadaapi.catmouse.ai/Solver/cd:
import os
import requests
r = requests.post(
"https://kasadaapi.catmouse.ai/Solver/cd",
headers={"x-api-key": os.environ["CATMOUSE_KEY"]},
json={
"host": "www.example.com",
"platform": "web",
"ct": "0123456789abcdef0123456789abcdef",
"pscript": "<UTF-8 source text of the target /p.js script>",
"telemetry": "real",
"seed": "auto",
},
timeout=15,
)
print(r.status_code, r.text)How should your client handle pjs_host_unwarmed and pjs_warming?
Inspecting the structured error string returned by POST /Solver/cd on non-200 responses (RFC 9110) lets your client recover automatically without dropping the session:
422 pjs_host_unwarmed: The server does not have cached/p.jsparameters for the requestedhost. Fetch/p.jsfrom the target through your proxy exit and retryPOST /Solver/cdwith thepscriptfield populated.503 pjs_warming(withRetry-After: 2): Background parameter warming is currently in progress for that host. Respect the HTTPRetry-Afterheader (RFC 9110) or supplypscriptdirectly in your next call.422 pjs_pow_not_foundorcd_shape_unproven: The suppliedpscriptstring did not contain extractable proof-of-work constants (for example, an HTML error page was fetched instead of/p.js). Verify the responseContent-Typebefore sendingpscript.
Key takeaways
/p.jsdefines per-host PoW parameters: Kasada bakeslhw,difficulty,subCount, andseedSuffixinto/p.jsto governx-kpsdk-cdgeneration.PScriptRequestis free of charge: SendingPScriptwith an empty"ipsBody": ""extractsvHeaderandpowwithout requiringtzortzOffsetand without charging your balance.- Pass
pscripttoPOST /Solver/cdwhen needed: Including the/p.jssource inCdRequest.pscriptrefreshes the server's per-host cache immediately and prevents422 pjs_host_unwarmed. - Keep
ctat least 16 characters: When passingcttoPOST /Solver/cd, ensure it is the fullx-kpsdk-ctsession token (`minLength: 16`, otherwise400 invalid_ct).
Conclusion and scope
Following these recommendations for /p.js parameter extraction and pscript cache warming ensures your client can mint valid x-kpsdk-cd headers even when testing newly onboarded hosts or immediately after a target rotates its /p.js bundle.
Scope and limitations. Every schema name (PScriptRequest, CdRequest, CdResponse), field (PScript, pow, lhw, difficulty, subCount, seedSuffix, seed, telemetry), and error code in this article is verified from the Catmouse OpenAPI 3.1 contract (/openapi.json) as of 2026-10-24. No pass-rate, latency, or throughput benchmarks are claimed. Use these techniques only on systems you own or have explicit written authorization to test.
Evidence and sources
All endpoint schemas, field constraints, and HTTP status codes in this article are backed by the primary references below:
- Catmouse OpenAPI 3.1 specification document (
/openapi.json) and online API reference (/reference.html). Supports:PScriptRequestschema (PScript, emptyipsBody, zero-charge behavior),SolveResponsePoW fields (vHeader,pow,powError), andCdRequest/CdResponsefields and error codes (pscript,seed,telemetry,pjs_host_unwarmed,pjs_warming,pjs_pow_not_found). Reviewed 2026-10-24. - IETF RFC 9110 (HTTP Semantics) and IANA HTTP Status Code Registry. Supports: HTTP
400 Bad Request,422 Unprocessable Content, and503 Service UnavailablewithRetry-After. - MDN Retry-After HTTP header documentation and W3C High Resolution Time Level 3. Supports: client retry backoff and sub-millisecond work timing measurement.
Methodology and limits. Documented: exact request and response contracts from the production server source published in /openapi.json. Not claimed: unverified third-party edge internals or numerical performance metrics. Reviewed 2026-10-24.
Frequently asked questions
What is the Kasada /p.js script and how does it relate to x-kpsdk-cd?
The /p.js script is Kasada's client-side proof-of-work script. It bakes the host's proof-of-work parameters (lhw, difficulty, subCount, and seedSuffix) and declared x-kpsdk-v version string used to compute per-request x-kpsdk-cd headers.
How do you inspect a /p.js script using PScriptRequest without charging your balance?
Per the Catmouse OpenAPI 3.1 contract (/openapi.json), sending PScript alongside an empty ipsBody string ("ipsBody": "") in the flat request shape triggers PScript-only mode, returning vHeader and the pow object without charging your balance or requiring tz/tzOffset.
What causes pjs_host_unwarmed or pjs_warming on POST /Solver/cd?
When POST /Solver/cd is called for a host whose /p.js proof-of-work parameters are not yet cached server-side and no pscript field was supplied in the request, the endpoint returns 422 pjs_host_unwarmed (or 503 pjs_warming with Retry-After: 2 while warming).
How do you warm the per-host cache on POST /Solver/cd?
Fetch the target's /p.js script over your own proxy exit and pass its UTF-8 source text in the optional pscript field of your POST /Solver/cd JSON body alongside host, platform, and ct.
What do the seed and telemetry fields control in CdRequest?
In CdRequest, seed selects the proof-of-work seed derivation mode (auto, bare, ct, or ct-lhw, defaulting to auto) and telemetry selects the timing profile (real, zeroed, or derived, defaulting to real).