Skip to content

3.0.0: modernize toolchain, drop legacy endpoints, add helpers#189

Merged
bartes merged 4 commits into
masterfrom
chore/modernize-sdk
Jun 2, 2026
Merged

3.0.0: modernize toolchain, drop legacy endpoints, add helpers#189
bartes merged 4 commits into
masterfrom
chore/modernize-sdk

Conversation

@bartes
Copy link
Copy Markdown
Contributor

@bartes bartes commented Jun 1, 2026

Summary

3.0.0 modernizes the SDK to current Node.js and TypeScript standards, removes the long-deprecated device/authentication endpoints, and introduces webhook-verification and secure-mode helpers. This is a major release: the minimum supported runtime is now Node 20, and a small number of legacy APIs have been removed.

The public risk / filter / log / Lists / Privacy / Events surface is unchanged.

Breaking changes

  • Node 20+ required. The SDK now relies on the runtime's built-in global fetch / AbortSignal.
  • Legacy endpoints removed. The authenticate, track, getDevice, getDevicesForUser, approveDevice and reportDevice methods are gone, along with the Payload, DevicePayload, UserDevicePayload and AuthenticateResult types.

Migration

Removed Use instead
authenticate, track risk / filter / log
approveDevice, reportDevice Lists API (createListItem / archiveListItem)
getDevice, getDevicesForUser — (no replacement)

New features

  • Webhook signature verificationcastle.verifyWebhookSignature(rawBody, signature) validates the X-Castle-Signature header (constant-time HMAC-SHA256 of the raw body) and throws WebhookVerificationError on mismatch.
  • Secure modecastle.secureModeSignature(userId) returns the hex HMAC-SHA256 of a user id, for signing user identifiers sent from the browser.

Improvements

  • Add a typed transaction field to RiskPayload, FilterPayload and LogPayload (base_amount, amount, payment_method, shipping_address, merchant), exported as TransactionPayload (Missing transaction field in RiskPayload type #188).
  • Add region_code to AddressPayload; type RiskPayload.user.address as AddressPayload.
  • risk() no longer throws in doNotTrack mode when the payload has no user.
  • Remove the dead ImpersonationFailed error.

Internal

  • Dual ESM + CJS build via tsup with an exports map and bundled type definitions (verified under both require() and import).
  • Replace the lodash.* micro-packages with native helpers.
  • tsconfig targets ES2022; the previously ignored strict flag is fixed, so strictNullChecks is now enforced.
  • Migrate CI from CircleCI to GitHub Actions (Node 20/22/24 + lint); switch the package manager from Yarn to npm; bump pino v9 / pino-pretty v13.
  • Rewrite the README and complete the 3.0.0 changelog.

Notes

  • noImplicitAny is intentionally left off for now; only strictNullChecks is newly enforced. Tightening it further can be a follow-up.

@bartes bartes changed the title Modernize SDK toolchain + drop legacy endpoints (3.0.0) Modernize SDK (3.0.0): native fetch, ESM/CJS, npm, drop legacy endpoints Jun 1, 2026
@bartes bartes changed the title Modernize SDK (3.0.0): native fetch, ESM/CJS, npm, drop legacy endpoints 3.0.0: modernize toolchain, drop legacy endpoints, add webhook & secure-mode helpers Jun 1, 2026
@bartes bartes changed the title 3.0.0: modernize toolchain, drop legacy endpoints, add webhook & secure-mode helpers 3.0.0: modernize toolchain, drop legacy endpoints, add helpers Jun 1, 2026
Runtime & build:
- Use the built-in global fetch / AbortSignal; drop node-fetch,
  abort-controller and timeout-signal. Requires Node >= 20.
- Replace the lodash.* micro-packages with native helpers.
- Ship a dual ESM + CJS build via tsup with an exports map and type
  definitions.
- Modernize tsconfig (target ES2022; enforce strictNullChecks and fix the
  resulting null-safety issues).
- Migrate CI to GitHub Actions (Node 20/22/24 matrix + lint); switch the
  package manager to npm; bump pino v9 / pino-pretty v13.

Breaking:
- Remove the legacy endpoints and their Castle methods: authenticate, track,
  getDevice, getDevicesForUser, approveDevice, reportDevice. Use risk /
  filter / log instead. Remove the related payload/result types.

Features:
- Webhook signature verification: verifyWebhookSignature / WebhookVerifyService
  validate the X-Castle-Signature header (constant-time HMAC-SHA256 of the raw
  body) and raise WebhookVerificationError on mismatch.
- Secure mode: secureModeSignature / SecureModeService return a hex
  HMAC-SHA256 of the user id.

Payload types:
- Add a typed transaction field to RiskPayload (base_amount, amount as a
  fiat/crypto object, payment_method, shipping_address, merchant), exported as
  TransactionPayload. Add the same field to FilterPayload and LogPayload.
  Addresses #188.
- Add region_code to AddressPayload and type RiskPayload.user.address as
  AddressPayload.
- Remove the dead ImpersonationFailed error.
- risk() no longer throws in doNotTrack mode when the payload has no user.

Docs:
- Restructure the README and complete the 3.0.0 changelog.
@bartes bartes force-pushed the chore/modernize-sdk branch from ab93042 to 376663f Compare June 1, 2026 15:16
@bartes bartes marked this pull request as ready for review June 1, 2026 15:17
@bartes bartes requested a review from zuchmanski June 2, 2026 10:30
Comment thread .github/workflows/test.yml Outdated
bartes added 3 commits June 2, 2026 15:22
Make queryEvents, eventsSchema, and groupEvents the official Events API
methods, keeping searchEvents and getEventsSchema as deprecated aliases
so existing code keeps working. Update the README and CHANGELOG to
recommend the new names, and cover both the new methods and the aliases
in tests.

Add Node 26 to the CI test matrix, bump the lint workflow to Node 26,
and pin Node 26.2.0 as the local default in .tool-versions / .nvmrc.
The rename ships as part of the unreleased 3.0.0, so list it under
3.0.0 Enhancements rather than a separate Unreleased heading.
Provide searchEvents and getEventsSchema as straightforward aliases of
queryEvents and eventsSchema without a deprecation notice.
@bartes bartes merged commit 9ff65d9 into master Jun 2, 2026
5 checks passed
@bartes bartes deleted the chore/modernize-sdk branch June 2, 2026 16:47
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