Skip to content

chore(security): retire CastingWords (same change as products#1923) - #45

Merged
shitratgit[bot] merged 2 commits into
mainfrom
worker/castingwords-retire
Nov 26, 2026
Merged

shitratgit[bot] merged 2 commits into
mainfrom
worker/castingwords-retire

Conversation

@shitratgit

@shitratgit shitratgit Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Same change as skillrecordings/products#1923, for scriptkit. The scriptkit Vercel project serves only products-scriptkit.vercel.app (scriptkit.com is a separate deployment), so nothing here receives CastingWords or Sanity video webhooks today.

Why

  • Dead webhook: /api/webhooks/castingwords has crashed on module load (ReferenceError: Cannot access 'k' before initialization) on every production build Vercel still keeps: epic-web back to 2026-03, total-typescript back to 2026-02. The cause is that skill-lesson's castingwords.ts and sanity.ts imported each other. The cycle has been in the source since June 2023.
  • Nothing ordered: the same cycle crashed total-typescript's /api/webhooks/sanity/videoResource/created, which is where the CastingWords orders were placed, so nothing has ordered a transcript in that time. epic-web orders Deepgram, and epic-react isn't live.
  • Old key exposure: the key went to Mux inside caption URLs whenever the webhook did work (sec-167). Retiring the code lets the key be revoked rather than rotated.

What changes

  • Removed: /api/webhooks/castingwords in epic-web, total-typescript, epic-react and the create-skill-app template. In skill-lesson: castingwords.ts, the unused duplicate casting-words.ts (unpatched keyed URLs, no importers), storeCaptionForMux, CASTINGWORDS_GET_TTL_SECONDS, and the sec-167 webhook tests that only covered the removed code.
  • sanityVideoResourceWebhook: now only creates the Mux asset (presigned GET, sec-165) and records {duration, muxAsset}. No transcript order, and no castingwords field is written.
  • Replay guard (new): a delivery for a resource that already has muxAsset.muxAssetId answers 200 and does nothing. No Mux call, no Sanity patch.
  • Env and mocks: the CASTINGWORDS_API_TOKEN type declarations, total-typescript's .env.test value, and the CastingWords msw mocks are gone.
  • Kept: historical castingwords transcript and SRT fields in Sanity stay readable. The schemas, the lesson queries and epic-web's /api/videoResource/[id]/srt are untouched.

Review focus: total-typescript's video-created webhook starts working again

Breaking the import cycle revives /api/webhooks/sanity/videoResource/created on total-typescript, which has returned 500 for at least nine months. Once it works, a new video resource gets a Mux asset again, which is what the route is for.

  • Backlog replay: I'm not aware of Sanity webhooks keeping a months-long retry queue; past deliveries were answered 500 and dropped. The replay guard covers any late or manual delivery for a document that already has an asset.
  • Documents created in those nine months with no Mux asset: a fresh delivery for one of them would now create its asset. That's the route's intended behavior, but it only happens if Sanity re-sends.

Tests

lib/upload-presigned-callers.test.ts:

  • a new resource: one Mux create with a presigned input, a patch of exactly {duration, muxAsset}, and no fetch to any transcription service;
  • a replayed resource that has a Mux asset: no Mux call, no patch, no fetch.

Both fail on main: main orders CastingWords and patches. skill-lesson lib/ is 24/24. tsc is clean on the changed files, and prettier is clean.

After merge

  • Lockjaw removes CASTINGWORDS_API_TOKEN from the epic-web, total-typescript-turbo and scriptkit Vercel projects.
  • Revoking the key needs the CastingWords account owner (likely Creeland), as one ask to Joel after Thursday.
  • Old Mux caption tracks: Mux fetched each caption file once, when the track was created, and serves its own copy, so revoking shouldn't affect playback. Spot-check one old total-typescript lesson with captions afterwards.

Rollback

Revert this PR. It only removes code that has been crashing; the replay guard is the one behavior change on a live route.

…products#1923)

skill-lesson's castingwords.ts and sanity.ts imported each other, the
CastingWords webhook is dead on the products sites, and this project serves
no public domain. Remove the CastingWords route, modules and env declaration;
sanityVideoResourceWebhook only creates and records the Mux asset, and leaves
a resource that already has one alone.
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptkit Ready Ready Preview Nov 26, 2026 6:02am UTC

@shitratgit
shitratgit Bot marked this pull request as ready for review November 26, 2026 19:08
@shitratgit
shitratgit Bot merged commit f5c3630 into main Nov 26, 2026
4 of 5 checks passed

This branch was successfully deployed

1 active deployment
Preview — eca4ea94 Deployed Nov 26, 2026 by vercel[bot]
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.

0 participants