Skip to content

Commit ec2fa32

Browse files
leggetterclaude
andauthored
_shared/hookdeck: set source verification through the CLI only, on hookdeck-cli 3.2.0 (#51)
upsertSource passes config and auth together in the CLI's --config-file, so the REST API fallback (PUT /sources/{id}) is gone. hookdeck-cli 3.2.0 applies source auth correctly (3.1.0 left VAPI on the wrong header and failed on WEBHOOK). api() stays for the probe scripts' reads. Bumps hookdeck-cli to 3.2.0 in every demo that uses it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 593ff2b commit ec2fa32

26 files changed

Lines changed: 132 additions & 180 deletions

File tree

‎_shared/hookdeck/hookdeck-cli.ts‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface HookdeckCliOptions {
2727
runDir?: string;
2828
/** CLI binary. Defaults to $HOOKDECK_CLI, then the hookdeck-cli npm dependency. */
2929
bin?: string;
30-
/** Hookdeck API base URL, used by api(). */
30+
/** Hookdeck API base URL, used by api() (probe reads). */
3131
apiBase?: string;
3232
}
3333

@@ -39,9 +39,8 @@ export interface SourceSpec {
3939
config?: Record<string, unknown>;
4040
/**
4141
* Signature verification settings, i.e. the API's `config.auth` (e.g. VAPI:
42-
* { webhook_secret_key, algorithm, encoding, header_key }). Set through the Hookdeck API,
43-
* not the CLI: CLI 3.1.0 silently ignores auth passed with --source-config / --config-file
44-
* for at least VAPI sources, leaving verification off.
42+
* { webhook_secret_key, algorithm, encoding, header_key }). Merged into the config file the CLI
43+
* reads, so it needs hookdeck-cli 3.2.0 or later.
4544
*/
4645
auth?: Record<string, unknown>;
4746
}
@@ -166,28 +165,21 @@ export function createHookdeckCli(options: HookdeckCliOptions = {}) {
166165
}
167166

168167
/**
169-
* Creates or updates a source. `config` goes through the CLI; `auth` (if given) is then set
170-
* with PUT /sources/{id} {type, config: {...config, auth}} and the call throws if the API
171-
* rejects it.
168+
* Creates or updates a source through the CLI. `config` and `auth` go together into the source
169+
* config file (`--config-file`), so the CLI sets verification exactly as given: the provider's
170+
* header, algorithm and encoding stay whatever you pass, and types whose auth is more than one
171+
* secret (LIVEKIT's api_key and api_secret) work too. Needs hookdeck-cli 3.2.0 or later, where
172+
* source auth is applied correctly (3.1.0 left VAPI on the wrong header and failed on WEBHOOK).
172173
*
173-
* Confirmation is limited by the API: GET /sources redacts `auth`, so the secret and settings
174-
* can't be read back. The PUT response is the only check: an error status means it wasn't
175-
* applied; on success we also return the response's `config.auth_type` (undefined if the API
176-
* doesn't send it for this source type). Treat a signed + unsigned probe request as the only
177-
* end-to-end proof.
174+
* The secret travels in a private temp file, never on the command line. The API redacts `auth`
175+
* when you read a source back, so a signed + unsigned probe request is the end-to-end proof.
178176
*/
179-
async function upsertSource(spec: SourceSpec): Promise<any> {
177+
function upsertSource(spec: SourceSpec): any {
180178
const args = ['gateway', 'source', 'upsert', spec.name, '--type', spec.type];
181-
const source = spec.config
182-
? withPrivateJson(`source-${spec.name}.json`, spec.config, (file) => json([...args, '--config-file', file]))
179+
const config = spec.auth ? { ...spec.config, auth: spec.auth } : spec.config;
180+
return config
181+
? withPrivateJson(`source-${spec.name}.json`, config, (file) => json([...args, '--config-file', file]))
183182
: json(args);
184-
if (!spec.auth) return source;
185-
const updated = await api('PUT', `/sources/${source.id}`, {
186-
type: spec.type,
187-
config: { ...spec.config, auth: spec.auth },
188-
});
189-
if (updated?.id !== source.id) throw new Error(`Setting auth on source ${spec.name}: unexpected API response`);
190-
return { ...source, auth_applied: true, auth_type: updated.config?.auth_type as string | undefined };
191183
}
192184

193185
function upsertCliDestination(spec: { name: string; path: string }): any {
@@ -208,7 +200,7 @@ export function createHookdeckCli(options: HookdeckCliOptions = {}) {
208200
return withPrivateJson(`rules-${spec.name}.json`, spec.rules, (file) => json([...args, '--rules-file', file]));
209201
}
210202

211-
/** Calls the Hookdeck API with the project API key, for settings the CLI doesn't apply. */
203+
/** Reads from the Hookdeck API with the project API key. The demos' probe scripts use it to find a source and list its requests; setup goes through the CLI only. */
212204
async function api<T = any>(method: string, route: string, body?: unknown): Promise<T> {
213205
const response = await fetch(`${api_base}${route}`, {
214206
method,

‎deepgram/stt-tts/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ HOOKDECK_API_KEY=your_hookdeck_api_key_here
3030

3131
### 3. Set up Hookdeck Connections
3232

33-
The Hookdeck CLI is an npm dependency (`hookdeck-cli` 3.1.0, the first release that forwards binary bodies such as the TTS audio), installed by `npm install`. The setup and listen scripts log it in to the project for `HOOKDECK_API_KEY`, with a config file of their own in `run/`, so whatever you're logged in to with `hookdeck login` isn't used or changed.
33+
The Hookdeck CLI is an npm dependency (`hookdeck-cli` 3.2.0; binary bodies such as the TTS audio need 3.1.0 or later), installed by `npm install`. The setup and listen scripts log it in to the project for `HOOKDECK_API_KEY`, with a config file of their own in `run/`, so whatever you're logged in to with `hookdeck login` isn't used or changed.
3434

3535
Create the connections and write their Source URLs into `.env`:
3636

‎deepgram/stt-tts/package-lock.json‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deepgram/stt-tts/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@types/multer": "^2.0.0",
1818
"dotenv": "^16.3.1",
1919
"express": "^4.18.2",
20-
"hookdeck-cli": "3.1.0",
20+
"hookdeck-cli": "3.2.0",
2121
"multer": "^2.0.2",
2222
"ts-node": "^10.9.2",
2323
"typescript": "^5.9.2",

‎deepgram/stt-tts/scripts/hookdeck-cli.ts‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface HookdeckCliOptions {
2828
runDir?: string;
2929
/** CLI binary. Defaults to $HOOKDECK_CLI, then the hookdeck-cli npm dependency. */
3030
bin?: string;
31-
/** Hookdeck API base URL, used by api(). */
31+
/** Hookdeck API base URL, used by api() (probe reads). */
3232
apiBase?: string;
3333
}
3434

@@ -40,9 +40,8 @@ export interface SourceSpec {
4040
config?: Record<string, unknown>;
4141
/**
4242
* Signature verification settings, i.e. the API's `config.auth` (e.g. VAPI:
43-
* { webhook_secret_key, algorithm, encoding, header_key }). Set through the Hookdeck API,
44-
* not the CLI: CLI 3.1.0 silently ignores auth passed with --source-config / --config-file
45-
* for at least VAPI sources, leaving verification off.
43+
* { webhook_secret_key, algorithm, encoding, header_key }). Merged into the config file the CLI
44+
* reads, so it needs hookdeck-cli 3.2.0 or later.
4645
*/
4746
auth?: Record<string, unknown>;
4847
}
@@ -167,28 +166,21 @@ export function createHookdeckCli(options: HookdeckCliOptions = {}) {
167166
}
168167

169168
/**
170-
* Creates or updates a source. `config` goes through the CLI; `auth` (if given) is then set
171-
* with PUT /sources/{id} {type, config: {...config, auth}} and the call throws if the API
172-
* rejects it.
169+
* Creates or updates a source through the CLI. `config` and `auth` go together into the source
170+
* config file (`--config-file`), so the CLI sets verification exactly as given: the provider's
171+
* header, algorithm and encoding stay whatever you pass, and types whose auth is more than one
172+
* secret (LIVEKIT's api_key and api_secret) work too. Needs hookdeck-cli 3.2.0 or later, where
173+
* source auth is applied correctly (3.1.0 left VAPI on the wrong header and failed on WEBHOOK).
173174
*
174-
* Confirmation is limited by the API: GET /sources redacts `auth`, so the secret and settings
175-
* can't be read back. The PUT response is the only check: an error status means it wasn't
176-
* applied; on success we also return the response's `config.auth_type` (undefined if the API
177-
* doesn't send it for this source type). Treat a signed + unsigned probe request as the only
178-
* end-to-end proof.
175+
* The secret travels in a private temp file, never on the command line. The API redacts `auth`
176+
* when you read a source back, so a signed + unsigned probe request is the end-to-end proof.
179177
*/
180-
async function upsertSource(spec: SourceSpec): Promise<any> {
178+
function upsertSource(spec: SourceSpec): any {
181179
const args = ['gateway', 'source', 'upsert', spec.name, '--type', spec.type];
182-
const source = spec.config
183-
? withPrivateJson(`source-${spec.name}.json`, spec.config, (file) => json([...args, '--config-file', file]))
180+
const config = spec.auth ? { ...spec.config, auth: spec.auth } : spec.config;
181+
return config
182+
? withPrivateJson(`source-${spec.name}.json`, config, (file) => json([...args, '--config-file', file]))
184183
: json(args);
185-
if (!spec.auth) return source;
186-
const updated = await api('PUT', `/sources/${source.id}`, {
187-
type: spec.type,
188-
config: { ...spec.config, auth: spec.auth },
189-
});
190-
if (updated?.id !== source.id) throw new Error(`Setting auth on source ${spec.name}: unexpected API response`);
191-
return { ...source, auth_applied: true, auth_type: updated.config?.auth_type as string | undefined };
192184
}
193185

194186
function upsertCliDestination(spec: { name: string; path: string }): any {
@@ -209,7 +201,7 @@ export function createHookdeckCli(options: HookdeckCliOptions = {}) {
209201
return withPrivateJson(`rules-${spec.name}.json`, spec.rules, (file) => json([...args, '--rules-file', file]));
210202
}
211203

212-
/** Calls the Hookdeck API with the project API key, for settings the CLI doesn't apply. */
204+
/** Reads from the Hookdeck API with the project API key. The demos' probe scripts use it to find a source and list its requests; setup goes through the CLI only. */
213205
async function api<T = any>(method: string, route: string, body?: unknown): Promise<T> {
214206
const response = await fetch(`${api_base}${route}`, {
215207
method,

‎elevenlabs/post-call-transcripts/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@elevenlabs/elevenlabs-js": "^2.77.0",
2525
"dotenv": "^16.3.1",
2626
"express": "^4.18.2",
27-
"hookdeck-cli": "3.1.0",
27+
"hookdeck-cli": "3.2.0",
2828
"ts-node": "^10.9.2",
2929
"typescript": "^5.9.2",
3030
"ws": "^8.18.0"

‎elevenlabs/post-call-transcripts/scripts/hookdeck-cli.ts‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface HookdeckCliOptions {
2828
runDir?: string;
2929
/** CLI binary. Defaults to $HOOKDECK_CLI, then the hookdeck-cli npm dependency. */
3030
bin?: string;
31-
/** Hookdeck API base URL, used by api(). */
31+
/** Hookdeck API base URL, used by api() (probe reads). */
3232
apiBase?: string;
3333
}
3434

@@ -40,9 +40,8 @@ export interface SourceSpec {
4040
config?: Record<string, unknown>;
4141
/**
4242
* Signature verification settings, i.e. the API's `config.auth` (e.g. VAPI:
43-
* { webhook_secret_key, algorithm, encoding, header_key }). Set through the Hookdeck API,
44-
* not the CLI: CLI 3.1.0 silently ignores auth passed with --source-config / --config-file
45-
* for at least VAPI sources, leaving verification off.
43+
* { webhook_secret_key, algorithm, encoding, header_key }). Merged into the config file the CLI
44+
* reads, so it needs hookdeck-cli 3.2.0 or later.
4645
*/
4746
auth?: Record<string, unknown>;
4847
}
@@ -167,28 +166,21 @@ export function createHookdeckCli(options: HookdeckCliOptions = {}) {
167166
}
168167

169168
/**
170-
* Creates or updates a source. `config` goes through the CLI; `auth` (if given) is then set
171-
* with PUT /sources/{id} {type, config: {...config, auth}} and the call throws if the API
172-
* rejects it.
169+
* Creates or updates a source through the CLI. `config` and `auth` go together into the source
170+
* config file (`--config-file`), so the CLI sets verification exactly as given: the provider's
171+
* header, algorithm and encoding stay whatever you pass, and types whose auth is more than one
172+
* secret (LIVEKIT's api_key and api_secret) work too. Needs hookdeck-cli 3.2.0 or later, where
173+
* source auth is applied correctly (3.1.0 left VAPI on the wrong header and failed on WEBHOOK).
173174
*
174-
* Confirmation is limited by the API: GET /sources redacts `auth`, so the secret and settings
175-
* can't be read back. The PUT response is the only check: an error status means it wasn't
176-
* applied; on success we also return the response's `config.auth_type` (undefined if the API
177-
* doesn't send it for this source type). Treat a signed + unsigned probe request as the only
178-
* end-to-end proof.
175+
* The secret travels in a private temp file, never on the command line. The API redacts `auth`
176+
* when you read a source back, so a signed + unsigned probe request is the end-to-end proof.
179177
*/
180-
async function upsertSource(spec: SourceSpec): Promise<any> {
178+
function upsertSource(spec: SourceSpec): any {
181179
const args = ['gateway', 'source', 'upsert', spec.name, '--type', spec.type];
182-
const source = spec.config
183-
? withPrivateJson(`source-${spec.name}.json`, spec.config, (file) => json([...args, '--config-file', file]))
180+
const config = spec.auth ? { ...spec.config, auth: spec.auth } : spec.config;
181+
return config
182+
? withPrivateJson(`source-${spec.name}.json`, config, (file) => json([...args, '--config-file', file]))
184183
: json(args);
185-
if (!spec.auth) return source;
186-
const updated = await api('PUT', `/sources/${source.id}`, {
187-
type: spec.type,
188-
config: { ...spec.config, auth: spec.auth },
189-
});
190-
if (updated?.id !== source.id) throw new Error(`Setting auth on source ${spec.name}: unexpected API response`);
191-
return { ...source, auth_applied: true, auth_type: updated.config?.auth_type as string | undefined };
192184
}
193185

194186
function upsertCliDestination(spec: { name: string; path: string }): any {
@@ -209,7 +201,7 @@ export function createHookdeckCli(options: HookdeckCliOptions = {}) {
209201
return withPrivateJson(`rules-${spec.name}.json`, spec.rules, (file) => json([...args, '--rules-file', file]));
210202
}
211203

212-
/** Calls the Hookdeck API with the project API key, for settings the CLI doesn't apply. */
204+
/** Reads from the Hookdeck API with the project API key. The demos' probe scripts use it to find a source and list its requests; setup goes through the CLI only. */
213205
async function api<T = any>(method: string, route: string, body?: unknown): Promise<T> {
214206
const response = await fetch(`${api_base}${route}`, {
215207
method,

‎elevenlabs/post-call-transcripts/scripts/setup.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,16 @@ async function setupHookdeck(): Promise<{ source_url: string; source_id: string
119119
}
120120

121121
/**
122-
* Sets the signing secret on the source through the API (config.auth). The header name,
122+
* Sets the signing secret on the source through the CLI (config.auth). The header name,
123123
* algorithm and timestamp format are fixed by the ELEVENLABS source type, so only the secret is needed.
124124
*/
125125
async function setSourceSecret(secret: string): Promise<void> {
126-
const source = await cli.upsertSource({
126+
const source = cli.upsertSource({
127127
name: SOURCE_NAME,
128128
type: 'ELEVENLABS',
129129
auth: { webhook_secret_key: secret },
130130
});
131-
console.log(`Hookdeck: signature verification enabled on the source (auth ${source.auth_applied ? 'applied' : 'not applied'})`);
131+
console.log(`Hookdeck: signature verification enabled on the source (auth ${source.config?.auth ? 'set' : 'NOT set'})`);
132132
}
133133

134134
async function setupAgent(elevenlabs: ElevenLabsClient): Promise<string> {

‎hookdeck/binary-payloads/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ npm run ui
5757

5858
Open http://localhost:4300 to send cases one at a time, by group, or all at once. Each row shows the ingestion outcome, the time from send to delivery through the CLI with the Hookdeck event ID, whether the bytes match, and the `Content-Type` that arrived. Preview renders what arrived: images, audio, video, PDF, archive and multipart entries, decompressed gzip, and a hex dump. Stop the listener from the page to see that nothing is delivered without it: events sent while it's stopped aren't replayed when it reconnects, so retry them from the dashboard.
5959

60-
The Hookdeck CLI is an npm dependency (`hookdeck-cli` 3.1.0, the first release that forwards binary bodies), so `npm install` is all you need. To try a different build, set `HOOKDECK_CLI=/path/to/hookdeck`. With v3.0.3 or earlier, binary events fail with `CLI_BINARY_UNSUPPORTED`, and multipart still arrives, but as lossy text.
60+
The Hookdeck CLI is an npm dependency (`hookdeck-cli` 3.2.0; binary bodies need 3.1.0 or later), so `npm install` is all you need. To try a different build, set `HOOKDECK_CLI=/path/to/hookdeck`. With v3.0.3 or earlier, binary events fail with `CLI_BINARY_UNSUPPORTED`, and multipart still arrives, but as lossy text.
6161

6262
The CLI logs in to the API key's project in a config file of its own (`run/hookdeck-cli.toml`), so it never touches the project you're logged in to interactively.
6363

‎hookdeck/binary-payloads/package-lock.json‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)