Browser flow
The browser flow is isolated from machine API-key authentication. Pinchana Web uses Cloudflare Turnstile plus a signed API browser session and keeps the bearer token in an HttpOnly cookie on the Web origin.
Default instance flow
Section titled “Default instance flow”- Web server reads server-only
PINCHANA_API_URL. - Browser calls same-origin
GET /api/instanceto obtain browser-safe instance metadata and the public Turnstile site key. - Browser calls
GET /api/session. - The BFF forwards an existing HttpOnly session token to API
GET /web/session. - If the session is absent/invalid, Web renders Turnstile with action
turnstile-spin-v1. - Browser posts the one-use Turnstile token to same-origin
POST /api/verify. - BFF forwards it to API
POST /web/verify. - API calls Cloudflare Siteverify with
TURNSTILE_SECRET_KEY, checksTURNSTILE_EXPECTED_HOSTNAMEandTURNSTILE_EXPECTED_ACTION, and signs a browser session usingTURNSTILE_SESSION_SECRET. - Web stores that access token in
pinchana_web_sessionas an HttpOnly cookie. - The form unlocks.
Browser JavaScript never receives the API machine key or the signed bearer token value.
Scrape flow
Section titled “Scrape flow”After verification:
- Browser posts
{url}to WebPOST /api/scrape. - Web validates the URL and calls API
POST /v1/web/scrapewith the signed bearer token. - API routes the URL through the same normal module selection used by
/v1/scrape. - API returns the normalized v1
{data, meta}response with protected/web/media/...URLs. - Web rewrites those media paths to same-origin
/api/media/.... - Browser previews/downloads the media through the Web proxy.
The legacy API /web/scrape exists for compatibility but is not the current Web contract.
Custom instance flow
Section titled “Custom instance flow”A custom API adds a certificate verification step before Turnstile:
- Browser fetches the entered origin’s public
/web/identitycertificate. - Web server verifies the Ed25519 signature with
PINCHANA_INSTANCE_PUBLIC_KEY. - Web validates that the certificate’s exact origin and time bounds are valid.
- The certified public Turnstile site key becomes the widget key for that selected instance.
- Web stores the verified certificate in an HttpOnly instance cookie and clears any old session.
- Normal Turnstile/session establishment repeats against the new API.
This prevents arbitrary origins from being selected through client-side settings.
Capabilities and DLP
Section titled “Capabilities and DLP”Once the session is verified, Web calls same-origin /api/capabilities, which proxies API /web/capabilities.
If the API advertises DLP protocol v2 as healthy, ordinary YouTube URLs can use the separate DLP job flow. Cookie Vault plaintext, when selected, is encrypted in the browser to the allocated worker and is not decrypted by the Web BFF or gateway.
Session expiry
Section titled “Session expiry”The Web session expires according to API-issued expiry. When it becomes invalid, GET /api/session returns an unauthorized state and the UI returns to the Turnstile gate.
Switching API instances also clears the current session even if it has not expired, because a session issued by one origin must not be silently reused against another.