Skip to content

Add broadcastKey helper to derive the broadcast auth key from the app secret - #6

Open
irinanazarova wants to merge 1 commit into
masterfrom
feat-broadcast-key
Open

Add broadcastKey helper to derive the broadcast auth key from the app secret#6
irinanazarova wants to merge 1 commit into
masterfrom
feat-broadcast-key

Conversation

@irinanazarova

Copy link
Copy Markdown
Contributor

Why

When AnyCable runs with a single application secret (ANYCABLE_SECRET), the server secures the HTTP broadcast endpoint with a key derived from that secret: HMAC-SHA256(secret, "broadcast-cable"), hex-encoded. This SDK's broadcaster(url, key) requires that key, and until now users had to compute the HMAC themselves (or discover the need the hard way: broadcasts fail with an auth error in the single-secret setup that the AnyCable docs recommend).

What

  • broadcastKey(secret) export in the broadcast module, using the same sync createHmac style as the existing stream signer.
  • Vector test (b12500da... for secret s3cret, cross-checkable with echo -n 'broadcast-cable' | openssl dgst -sha256 -hmac 's3cret').
  • README: documents pairing broadcaster(broadcastURL, broadcastKey(process.env.ANYCABLE_SECRET)).
  • CHANGELOG entry.

Verification

The derivation was verified against a live anycable-go 1.6.14: with only ANYCABLE_SECRET set, the server logs "auto-generated authorization secret from the application secret ... (authorization required)", rejects unauthenticated POSTs, and accepts Authorization: Bearer <key from this formula> (exercised end-to-end while building the canonical serverless example for the docs).

Tests 23/23 pass, tsc --noEmit clean, eslint adds no new warnings.

…secret

AnyCable secures the HTTP broadcast endpoint with a key derived from the
application secret (HMAC-SHA256 of 'broadcast-cable', hex-encoded) unless an
explicit broadcast key is configured. Until now users had to compute that
HMAC themselves to pair this SDK with a single-secret AnyCable setup.

The derivation matches the server (verified against anycable-go 1.6.14: a
key produced by this formula is accepted by the secured /_broadcast
endpoint). Vector test included; README documents the pairing:

  broadcaster(url, broadcastKey(process.env.ANYCABLE_SECRET))
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