Skip to content

feat: add headless CDN API client and provider methods#126

Open
ethanpschoen wants to merge 8 commits into
mainfrom
ethanpschoen/feat/headless-api
Open

feat: add headless CDN API client and provider methods#126
ethanpschoen wants to merge 8 commits into
mainfrom
ethanpschoen/feat/headless-api

Conversation

@ethanpschoen

@ethanpschoen ethanpschoen commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description of this change

Adds pre-WebView headless CDN API (KetchHeadless, HeadlessApiClient) and wires methods through KetchServiceProvider / useKetchService().

Why is this change being made?

  • Chore (non-functional changes)
  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How was this tested? How can the reviewer verify your testing?

  • cd package && npm run typecheck && npm test
  • Optional: KETCH_INTEGRATION_TESTS=1 npm run test:integration

Related issues

KD-17456

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have evaluated the security impact of this change, and OWASP Secure Coding Practices have been observed.
  • I have informed stakeholders of my changes.

Note

Medium Risk
Adds server-side consent, profile, and rights APIs that send identities over the network; behavior is new but isolated behind optional context methods with documented separation from WebView consent.

Overview
Adds a pre-WebView headless stack (KetchHeadless / HeadlessApiClient) that calls Ketch web/v3 over fetch (data-center CDN base URLs), covering geo/config, server consent get/update (with payload helpers and tolerant empty/malformed response handling), rights, profile, subscriptions, preference QR URLs, and telemetry.

Those capabilities are re-exported from the package entrypoint and surfaced on useKetchService() via a memoized headless instance in KetchServiceProvider (optional methods on KetchService; distinct from WebView-backed getConsent).

Tests: broad Jest coverage for URL building and consent behavior with injectable fetchFn, plus opt-in live CDN integration (KETCH_INTEGRATION_TESTS=1). package.json adds test / test:integration scripts.

Reviewed by Cursor Bugbot for commit fd26918. Configure here.

Expose pre-WebView headless endpoints via KetchHeadless, wire them through
KetchServiceProvider, and harden JSON/network error handling in the client.
When jurisdiction/environment aren't fully set, getFullConfiguration()
falls back to the short config.json path, which previously carried no
language hint. Now the short path always sends a language query param:
the explicit languageCode if set, otherwise the device locale
(formatted to match ketch-tag's formatLanguage convention), plus an
Accept-Language header. jurisdiction/region are forwarded when
explicitly set. The full static path is unchanged.

Device-locale detection is extracted from KetchServiceProvider into a
shared util so both the WebView and headless paths use it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant