Skip to main content
kasadaproof-of-workarchitectureapi8 min readBy Catmouse Engineering

Kasada /p.js PScript PoW Extraction and cd Host Warming

Last reviewed
Short answer

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
  1. What proof-of-work parameters does Kasada bake into /p.js?
  2. How does PScript-only mode work on the solver endpoint?
  3. How do you pass pscript to POST /Solver/cd to warm a host?
  4. How should your client handle pjs_host_unwarmed and pjs_warming?
  5. Key takeaways
  6. Conclusion and scope
  7. Evidence and sources
  8. 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. When seed is set to "ct-lhw" or "auto" on POST /Solver/cd, lhw participates in deriving the puzzle seed alongside the session's x-kpsdk-ct token.
difficulty and subCount
The work factor and number of sub-puzzles that the client must solve to construct a valid workTime and answers array inside x-kpsdk-cd.
seedSuffix
The static suffix string appended during seed construction when the target's /p.js build requires one.
vHeader (Declared SDK Version)
The x-kpsdk-v version string declared inside /p.js, returned alongside pow so 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:

Table 1. PScriptRequest inspection mode versus POST /Solver/cd header generation
AspectPScriptRequest (ipsBody: "")POST /Solver/cd (CdRequest)
Primary purposeParse /p.js and return vHeader + pow parametersMint a ready-to-send x-kpsdk-cd header value
Required fieldsPScript and empty ipsBody: ""host and platform ("web" or "ios")
Geo fields (tz, tzOffset)Not requiredNot required
Billing impactNot charged (payload is absent)Charged to the key's USD balance at the cd price
Missing PoW behaviorReturns powError: "pscript_no_pow"Returns 422 pjs_pow_not_found or pjs_host_unwarmed
Four-part diagram of Kasada /p.js proof-of-work extraction and POST /Solver/cd warming: 1. Client fetches GET /<path>/p.js from the target host. 2. PScript-only mode (PScript with empty ipsBody) extracts vHeader and pow (lhw, difficulty, subCount, seedSuffix) at no cost. 3. Passing pscript to POST /Solver/cd refreshes the per-host PoW cache and mints x-kpsdk-cd. 4. Seed modes (auto, bare, ct, ct-lhw) and telemetry modes (real, zeroed, derived) prevent pjs_host_unwarmed errors.
Figure 1. Extracting /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:

  1. 422 pjs_host_unwarmed: The server does not have cached /p.js parameters for the requested host. Fetch /p.js from the target through your proxy exit and retry POST /Solver/cd with the pscript field populated.
  2. 503 pjs_warming (with Retry-After: 2): Background parameter warming is currently in progress for that host. Respect the HTTP Retry-After header (RFC 9110) or supply pscript directly in your next call.
  3. 422 pjs_pow_not_found or cd_shape_unproven: The supplied pscript string did not contain extractable proof-of-work constants (for example, an HTML error page was fetched instead of /p.js). Verify the response Content-Type before sending pscript.

Key takeaways

  • /p.js defines per-host PoW parameters: Kasada bakes lhw, difficulty, subCount, and seedSuffix into /p.js to govern x-kpsdk-cd generation.
  • PScriptRequest is free of charge: Sending PScript with an empty "ipsBody": "" extracts vHeader and pow without requiring tz or tzOffset and without charging your balance.
  • Pass pscript to POST /Solver/cd when needed: Including the /p.js source in CdRequest.pscript refreshes the server's per-host cache immediately and prevents 422 pjs_host_unwarmed.
  • Keep ct at least 16 characters: When passing ct to POST /Solver/cd, ensure it is the full x-kpsdk-ct session token (`minLength: 16`, otherwise 400 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:

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).