Skip to content

Rewrite SDK around the modern Castle API surface#8

Open
bartes wants to merge 1 commit into
developfrom
modernize-sdk
Open

Rewrite SDK around the modern Castle API surface#8
bartes wants to merge 1 commit into
developfrom
modernize-sdk

Conversation

@bartes

@bartes bartes commented Jun 10, 2026

Copy link
Copy Markdown

Replaces the prototype Track/Authenticate client with a full SDK covering the current Castle API.

  • ScoringRisk (POST /risk), Filter (POST /filter) and Log (POST /log). Risk and Filter apply a configurable failover strategy (allow, challenge, deny, throw) on transport errors, timeouts and 5xx responses, returning a synthetic verdict (failover: true); Log does not fail over.
  • Lists & List itemsCreateList, GetAllLists, GetList, QueryLists, UpdateList, DeleteList; CreateListItem, CreateListItemsBatch, GetListItem, QueryListItems, CountListItems, UpdateListItem, ArchiveListItem, UnarchiveListItem.
  • Privacy & EventsRequestUserData, DeleteUserData; EventsSchema, QueryEvents, GroupEvents.
  • Webhooks & secure modeVerifyWebhook / VerifyWebhookRequest (HMAC-SHA256 over the body, base64, X-Castle-Signature) and SecureModeSignature (hex HMAC-SHA256 of the user id).
  • Request contextContextFromRequest builds { headers, ip, library } with header allowlist/denylist scrubbing (Cookie/Authorization always scrubbed, User-Agent always forwarded) and configurable IP resolution (WithIPHeaders, WithTrustedProxies, WithTrustProxyChain, WithTrustedProxyDepth).
  • Configuration — functional options for base URL, request timeout (default 1000ms), failover strategy (default allow), header allow/deny lists, IP resolution, do-not-track and a custom *http.Client.
  • Errors — typed hierarchy embedding APIError (BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, UserUnauthorizedError, InvalidParametersError, InvalidRequestTokenError, RateLimitError, InternalServerError), plus RequestError, ConfigurationError and WebhookVerificationError.

Removes the legacy Track/Authenticate endpoints and the client-id extraction (__cid cookie / X-Castle-Client-Id) from the default context. Requires Go 1.21+ and replaces Travis CI with GitHub Actions.

Replace the prototype Track/Authenticate client with a full SDK:

- Scoring: Risk, Filter and Log, with a configurable failover strategy
  (allow/challenge/deny/throw) on transport errors, timeouts and 5xx for
  Risk and Filter; Log does not fail over.
- Lists and List items APIs (create/get/query/update/delete, batch create,
  count, archive/unarchive).
- Privacy API (request/delete user data) and Events API (schema/query/group).
- Webhook signature verification and secure mode signing.
- Request context extraction with header allow/deny scrubbing and configurable
  IP resolution (ip headers, trusted proxies, trust-proxy-chain, depth).
- Functional configuration options and a typed error hierarchy.

Remove the legacy Track/Authenticate endpoints and client-id extraction.
Require Go 1.21+ and replace Travis CI with GitHub Actions.
@bartes bartes changed the base branch from master to develop June 10, 2026 23:27
@bartes bartes requested a review from zuchmanski June 11, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants