feat(types): fix DriverAnalytics shape + add TireHealthSnapshot/WinProb/LTOE types + simulate pause/resume - #1
Closed
jlazar wants to merge 6 commits into
Closed
Conversation
- verifySignature now throws typed errors (WebhookSignatureError / WebhookTimestampError) instead of returning bool - Add verifySignatureBoolean for backward-compatible non-throwing usage - Add signPayload, SIGNATURE_HEADER, TIMESTAMP_HEADER constants - Add constructEvent(), safeConstructEvent() helpers - Add webhookHandler() Express/Fastify/plain-http middleware - Extend RaceHooksConfig with secret and toleranceSeconds options - RaceHooks class gains constructEvent, safeConstructEvent, webhookHandler methods - 44 Jest tests covering all new paths - CI workflow updated to run tests before build Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- http.ts: only send Content-Type: application/json when a body is present (fixes RFC 9110 violation on GET/DELETE — sending Content-Type with no body breaks strict servers) - verify.ts: export headerValue so webhook-middleware.ts can import it instead of re-declaring an identical copy (DRY) - webhook-middleware.ts: remove duplicate headerValue, import from verify.ts - webhook-middleware.ts: resolveRawBody now skips empty rawBody (length 0) rather than passing "" to verifySignature, which would produce a confusing signature-mismatch error instead of falling through to the stream-read path - verify.ts: secureCompare runs timingSafeEqual even when buffer lengths differ, so signature comparisons are constant-time regardless of the submitted signature length Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- WebhookPayload.type renamed to .feed across types, middleware, client, and tests - SubscriptionTier updated to "free" | "live" | "analytics" (starter→live, pro dropped) - Add DriverRef, DriverAnalytics, and drivers[] to WebhookPayload; data becomes optional - Add driverIds to WebhookFilters Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…re usage, and domain - README JSON example: `type` → `feed` (field was renamed) - Signature example: `verifySignature` → `verifySignatureBoolean` — the throwing variant doesn't return a boolean, so the `if (!...)` guard was always wrong - Analytics section: replace old `payload.analytics?.[driverNumber]` map access with current inline `payload.drivers[].analytics` shape - package.json homepage: `racehooks-ai.com` → `racehooks.io` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…te pause/resume DriverAnalytics was typed incorrectly — tireHealth was number but the API sends a full TireHealthSnapshot object; degRateSecPerLap/cliffLapPredicted/ cliffRisk were top-level but live inside tireHealth; fuelCorrectedTimeSec was present but absent from the API. Adds missing fields: overtakeProbability, winProbability (WinProbabilitySnapshot), undercutThreat, ltoe (LTOESnapshot), ltoeConfidenceFlag, regulationsEra. Also adds TireHealthSnapshot, WinProbabilitySnapshot, LTOESnapshot, UndercutThreatSnapshot, CliffRisk, DegMode, HealthLabel as exported types. Adds simulate.pause() and simulate.resume() matching the API's POST /simulate/:id/pause and POST /simulate/:id/resume endpoints. Tests: types.test.ts (19 new tests) and simulate.test.ts (8 new tests). All 66 tests pass, typecheck clean, build clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Exposes the SC/VSC split fields added in the API Analytics tier payload. safetyCarProbability is kept for backward compatibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
DriverAnalyticstype to match live Analytics-tier API outputtireHealthwasnumber; the API sends a fullTireHealthSnapshotobject (12 fields)degRateSecPerLap,cliffLapPredicted,cliffRiskwere top-level; they live insidetireHealthfuelCorrectedTimeSectyped but absent from the APIovertakeProbability,winProbability(full snapshot),undercutThreat,ltoe,ltoeConfidenceFlag,regulationsEraNew exported types matching backend analytics types:
TireHealthSnapshot,WinProbabilitySnapshot,LTOESnapshot,UndercutThreatSnapshotCliffRisk,DegMode,HealthLabelstring literal unionsAdd
simulate.pause()andsimulate.resume()— maps toPOST /simulate/:id/pauseandPOST /simulate/:id/resumeTest plan
npm run typecheck— cleannpm test— 66 tests pass (19 new intypes.test.ts, 8 new insimulate.test.ts, 44 existing webhook tests unchanged)npm run build— clean (ESM + CJS + DTS)🤖 Generated with Claude Code