Skip to content

Commit 0b82ff3

Browse files
committed
docs(automation, skills): teach config.signature where a vendor-signed callback was said to be refused; bind the signs union to flows.mdx
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzeeFznzXxc61VmVH12
1 parent 607a0d1 commit 0b82ff3

6 files changed

Lines changed: 83 additions & 14 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/trigger-api': patch
3+
'@objectstack/lint': patch
4+
'@objectstack/skills': patch
5+
---
6+
7+
feat(trigger-api): an `api` hook verifies the vendor signature its start node declares (`config.signature`)
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
- **`@objectstack/trigger-api`.** `start()` reads the hook's one verifier with `apiTriggerVerifierOf(binding.config)` (`@objectstack/spec/automation`). A start node that declares its sender's scheme (`config.signature`: DocuSign Connect's base64 `X-DocuSign-Signature-1`, a Stripe-style `t=…,v1=…`, a GitHub-style `sha256=`) now admits a correctly signed post that was answered `401` before. That scheme REPLACES the `x-objectstack-signature` check for its hook: the declared header is read on both faces of the door (the self-hosted mount and `handleInboundHook`) with `Headers.get`, so a repeated field is its one joined value; the HMAC-SHA256 is computed under the key `config.secretRef` names (read at every post through the engine's reader, `503` while it has no value), over the raw body or `<t>.<raw body>`; each digest is decoded strictly to 32 bytes and compared with `timingSafeEqual`, any one of several `v1` elements matching (a key roll); and a timestamped scheme is held to `HTTP_SIGNATURE_TOLERANCE_SECONDS` from `@objectstack/core`. A body-only scheme has no replay window, as the contract states. A valid `x-objectstack-signature` admits nothing on such a hook, and a post without the declared header is refused. A declaration the spec answers `unusable` arms a hook that refuses every post before any secret is read and never falls back to `x-objectstack-signature`; a declared scheme bound without the engine's `config.secretRef` reader is refused at `start()`. Every failure is the same `401 INVALID_SIGNATURE` with its own cause in the server log (`declared-header-absent`, `declared-header-malformed`, `declared-prefix-missing`, `declared-no-digest`, `declared-mismatch`, `declared-outside-window`, `declared-unusable`), never the key, the header value or the body. A hook that declares no scheme is verified exactly as before.
13+
- **`@objectstack/lint`.** `validateFlowApiTriggerSecret` grades an `api` hook by that same reader: a usable declaration is ready on its `config.secretRef` alone, and an unusable one is the new error `flow-api-trigger-signature-unusable` (with its `os explain` entry), located at the key the spec refuses. It fires only on a declaration the flow parse already refuses, so no stack that passed before is refused now.
14+
- **`@objectstack/skills`.** The automation and api skills teach `config.signature` where they said a vendor-signed callback cannot be admitted.

‎content/docs/automation/flows.mdx‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,57 @@ would send.
575575
A flow definition, including an `http` node's `url` and `headers`, is served to every member who can read flows. A token, API key or signed webhook url written there is readable by all of them. Route an outbound credential by where it sits, and call the connector with a `connector_action` node instead — see [Connectors](/docs/automation/connectors#authentication). A credential in a header goes to a declarative connector with `bearer`, `basic` or `api-key` auth, whose `auth.credentialRef` names the secret. A key in the query string goes to `api-key` auth with `paramName`. No `credentialRef` variant carries a secret in the url path, so an incoming-webhook url (whose path is the secret) cannot be routed that way: call the service through a token-authenticated connector instead, such as the `slack` connector, whose bot token is supplied to the plugin by host code rather than written in the flow (it is registered by that plugin, not declared as a `connectors:` instance). Otherwise such a url is served with the definition. Only `signingSecret` and a start node's `secret` are kept out of a flow saved through the metadata API: the metadata save door stores each in a write-only, encrypted flow credential store, a read never returns it, and the engine reads it only to verify an inbound post or sign an outbound request. A flow that ships in a package names its inbound hook secret instead of carrying it: the start node's `config.secretRef` holds the name the deployment fills (an environment variable of that name in the open tier, resolved through the same credential resolver as a connector's `auth.credentialRef`), and the engine reads it at every post, so no credential is published with the package. A post that arrives while the name has no value is answered `503`, never verified. The reference is a name, not a credential: it is served as written, it may not sit beside a literal `secret`, and it may not name a variable in the platform's `OS_` namespace. A packaged flow that carries a literal keeps it in its package source; the literal is withheld when the definition is served, and a credential store row for that flow, where one exists, wins when the engine verifies or signs. `url` and `headers` are stored and served as written.
576576
</Callout>
577577

578+
#### An inbound hook that verifies its sender's own signature — `config.signature`
579+
580+
By default an `api` flow's hook admits a post only by ObjectStack's own
581+
`x-objectstack-signature`. A vendor that signs its callbacks its own way
582+
(DocuSign Connect's `X-DocuSign-Signature-1`, a Stripe-style `t=…,v1=…`
583+
header, a GitHub-style `sha256=` header) is admitted by declaring how it signs
584+
on the start node, as `config.signature`, beside the `config.secretRef` that
585+
names the key:
586+
587+
```ts
588+
export const EnvelopeStatus = defineFlow({
589+
name: 'envelope_status', label: 'Envelope status', type: 'api', runAs: 'system',
590+
nodes: [
591+
{ id: 'start', type: 'start', label: 'DocuSign Connect', config: {
592+
hookId: 'docusign',
593+
secretRef: 'DOCUSIGN_CONNECT_KEY',
594+
signature: { signs: 'body', header: 'X-DocuSign-Signature-1', algorithm: 'hmac-sha256', encoding: 'base64' },
595+
} },
596+
{ id: 'end', type: 'end', label: 'End' },
597+
],
598+
edges: [{ id: 'e1', source: 'start', target: 'end' }],
599+
});
600+
```
601+
602+
`signs` says what the sender signs, and picks the form:
603+
604+
| `signs` | The sender signs | The header carries | Replay window |
605+
|:--|:--|:--|:--|
606+
| `body` | the raw body alone (DocuSign Connect; GitHub-style with `prefix: 'sha256='`) | the one digest, after `prefix` when one is declared | none: the sender signs no time, so a captured post verifies again while the key is unchanged |
607+
| `timestamp.body` | `<t>.<raw body>` (Stripe-style) | `NAME=value` elements: one `timestampElement` (`t`) and one or more `digestElement`s (`v1`, one per key while the sender rolls its key) | the same 300 seconds as `x-objectstack-signature` |
608+
609+
`header` is matched without regard to case; a field the sender repeats is
610+
read as its one value, the copies joined with `, `, so a body-only header sent
611+
twice does not verify. `algorithm` is `hmac-sha256`, `encoding` is `hex` or
612+
`base64`, and the digest must decode to the 32 bytes of the HMAC, compared in
613+
constant time over the body exactly as received. The key is only ever the one
614+
`config.secretRef` names, read at every post like any hook secret (`503` while
615+
it has no value); a literal `secret` beside `signature` is refused.
616+
617+
A declared scheme **replaces** the `x-objectstack-signature` check for its hook:
618+
the hook has that one verifier, so a post that carries only a valid
619+
`x-objectstack-signature` is refused, and so is one without the declared
620+
header. Every refusal is the same `401 INVALID_SIGNATURE` an unsigned post
621+
gets, with its cause in the server log only. A declaration the flow parse
622+
refuses (an unknown algorithm, a reserved header such as `authorization` or
623+
`x-objectstack-signature`, a timestamped scheme without its elements) never
624+
falls back to the platform check: `os validate` reports it as
625+
`flow-api-trigger-signature-unusable`, and a hook armed with it admits no post.
626+
The declared keys are listed in
627+
[api-trigger-signature](/docs/references/automation/api-trigger-signature).
628+
578629
**Script:**
579630

580631
The built-in `script` executor never evaluates an arbitrary JavaScript string —

‎packages/spec/variant-docs.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@
212212
{
213213
"key": "signs:body|timestamp.body",
214214
"label": "api trigger declared signature scheme",
215-
"exempt": "generated-reference-only",
216-
"reason": "An api flow start node's `config.signature` (#29983, the contract half): content/docs/references/automation/api-trigger-signature.mdx is generated from ApiTriggerSignatureSchema. No hand-written guide teaches it yet on purpose: the api trigger does not verify the key until the domain:server slice lands, so a guide written now would teach a hook that refuses every post. That slice writes the automation/flows.mdx section naming `body` and `timestamp.body` beside the `secretRef` paragraph and binds it here, replacing this exemption."
215+
"docs": [
216+
"content/docs/automation/flows.mdx"
217+
],
218+
"note": "An api flow start node's `config.signature` (#29983; the trigger verifies it since #30009). automation/flows.mdx teaches both forms beside the `secretRef` paragraph, in its `signs` table."
217219
}
218220
]
219221
}

‎skills/objectstack-api/SKILL.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,18 @@ policy layer over an existing pipeline, never a second execution dialect.
129129
| **`defineStack({ apis })`** | The endpoint is a *projection* of something the platform already executes: query/return records, or trigger a flow. No code, no deploy artifact, publish-gated. **Prefer this.** |
130130
| **A flow that runs your code** | The endpoint needs real handler CODE: point a `type: 'flow'` endpoint at a flow whose `script` node names a stack function (`defineStack({ functions })`), or whose `connector_action` node calls a declared connector (outbound). The URL stays declarative; the code runs where the automation surface already runs it. |
131131

132-
An inbound webhook from a sender you control is a `type: 'api'` flow
133-
(objectstack-automation → **Inbound webhook (`api`) triggers**): it verifies
134-
ObjectStack's own `x-objectstack-signature`, enqueues, and answers `202`.
132+
An inbound webhook is a `type: 'api'` flow (objectstack-automation →
133+
**Inbound webhook (`api`) triggers**): it verifies ObjectStack's own
134+
`x-objectstack-signature`, or a vendor's own HMAC-SHA256 header its start node
135+
declares as `config.signature` (DocuSign Connect, Stripe-style), enqueues, and
136+
answers `202`.
135137
**An app never mounts on `http.server`** — that service is the platform
136138
plugins' own door-building primitive, and a code-mounted route gets no caller
137139
identity, auth gate, rate limit, namespace carve-out or OpenAPI entry. Three
138140
cases have no app surface today; say so rather than invent one: a third-party
139-
callback verified by its own signature over the raw body (the hook checks only
140-
`x-objectstack-signature`), a streaming response (a declared endpoint answers
141-
one JSON envelope), and a protocol the platform does not speak.
141+
callback signed in a form `config.signature` cannot declare (not HMAC-SHA256),
142+
a streaming response (a declared endpoint answers one JSON envelope), and a
143+
protocol the platform does not speak.
142144

143145
<!-- os:check -->
144146
```typescript

‎skills/objectstack-automation/SKILL.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ node `config`**:
355355
| `hookId` | URL path token (default `'default'`). **Rotate it to revoke** a leaked endpoint |
356356
| `secretRef` / `secret` | HMAC-SHA256 secret, **one required** (else refused at registration and `os validate`). Ship `secretRef: 'NAME'`: an env var the deployment fills, not `OS_*`; unfilled ⇒ `503`. Never a literal |
357357

358-
- **Signature:** `x-objectstack-signature: t=<unix seconds>,v1=<hex>` — `v1` = HMAC-SHA256 of `<t>.<raw body>` under the secret; refused when `t` is over 300 s from the server clock.
358+
- **Signature:** `x-objectstack-signature: t=<unix seconds>,v1=<hex>` — HMAC-SHA256 of `<t>.<raw body>`; `t` within 300 s. Vendor-signed: `config.signature` replaces it (recipe 4).
359359
- **Idempotency:** `x-idempotency-key` dedupes retries — author the flow to be idempotent (delivery is at-least-once).
360360
- **Queue-backed:** the endpoint ACKs `202` and enqueues; the flow runs on the consumer.
361361
- The JSON body surfaces to the flow as the trigger record (`record.*` / bare fields) plus `params`.
@@ -414,8 +414,8 @@ credential hand-off, loader limits: [references/integration-recipes.md](./refere
414414
Platform code only when one holds — and then it is the platform's, filed as a
415415
card, the app still writing none: the protocol is not HTTP; the work writes
416416
identity objects (users, units, positions); it processes files locally; one fixed
417-
action contract spans several vendors; the callback's signature is outside the
418-
`api` door's HMAC. A document the loader cannot take yet (YAML, Swagger 2.0,
417+
action contract spans several vendors; the callback is signed in no form
418+
`config.signature` declares. A document the loader cannot take yet (YAML, Swagger 2.0,
419419
`$ref`) is a gap named against its platform card, never a
420420
reason to write code.
421421

‎skills/objectstack-automation/references/integration-recipes.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ export const CarrierCallback = defineFlow({
130130
```
131131

132132
`requires: ['automation', 'triggers', 'queue']`. The sender signs each post
133-
under `CARRIER_HOOK_SECRET` (SKILL.md *Signature* bullet). The door verifies no
134-
other scheme: a vendor whose webhook signs its own header cannot post here
135-
today — poll its status (recipe 1's shape) until vendor schemes verify.
133+
under `CARRIER_HOOK_SECRET` (SKILL.md *Signature* bullet). A vendor signing
134+
its own header adds, keyed by that ref, `signature: { signs: 'body', header:
135+
'X-DocuSign-Signature-1', algorithm: 'hmac-sha256', encoding: 'base64' }`.
136136

137137
## 5 · Vendor with no machine-readable spec — write the document by hand
138138

0 commit comments

Comments
 (0)