@deliverd/sdk 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  You build the action. Deliverd handles the human.
4
4
 
5
+ > **Now published from a public repository. From 0.26.0, `@deliverd/sdk` is built and released from [deliverd-dev/deliverd-sdk](https://github.com/deliverd-dev/deliverd-sdk), Deliverd's public SDK repository, by GitHub Actions with npm's trusted publishing, so each release carries provenance linking it to the commit and workflow that built it. Versions up to 0.25.1 were published from a private repository under a single developer's account. Deliverd is growing, and as a company that supports open source it no longer made sense to keep it there: the source is now public, under the MIT licence. If npm shows a change of provenance or source repository at 0.26.0, this is why.**
6
+
5
7
  ```bash
6
8
  npm install @deliverd/sdk
7
9
  ```
@@ -221,6 +223,43 @@ the handle exposed, for work that resumes on a webhook rather than in this call.
221
223
  Try it before you have an account: `DELIVERD_DEV_OUTCOME=denied` rehearses a
222
224
  policy refusal, which is the branch agents most often forget to write.
223
225
 
226
+ ### Checking the yes where the action happens
227
+
228
+ A gate on its own is advisory: the agent asks, then acts. When the code that
229
+ actually performs the action is yours — the refund service, the deploy job —
230
+ make it check. Every gate that may be acted on carries `decisionToken`, the yes
231
+ signed with your deployment's Ed25519 key. Pass it along with the request, and
232
+ verify it against what you are about to do:
233
+
234
+ ```ts
235
+ // In the agent
236
+ await fetch(REFUND_SERVICE, {
237
+ method: "POST",
238
+ headers: { "deliverd-decision": decision.decisionToken ?? "" },
239
+ body: JSON.stringify(decision.input),
240
+ });
241
+
242
+ // In the refund service
243
+ const check = await deliverd.decisionTokens.verify(req.headers["deliverd-decision"], {
244
+ action: "finance.refund",
245
+ input: req.body,
246
+ });
247
+ if (!check.ok) return res.status(403).json({ error: check.reason });
248
+ ```
249
+
250
+ It refuses a token signed by any other key, an expired one (tokens last at most
251
+ fifteen minutes, and never past the permission's own window), one for another
252
+ action, and one agreed for a different input: a yes for £1200 does not cover
253
+ £1240. When the gate named a `destination` or an artifact, pass `destination`
254
+ and `artifactSha256` too. The public key is fetched once from
255
+ `/.well-known/deliverd-evidence-key` on the deployment the client talks to, and
256
+ the token must have been issued by that deployment. With the key already in
257
+ hand, `verifyDecisionToken(token, expected, { publicKey, issuer })` does the
258
+ same with no network at all.
259
+
260
+ A token does not count uses. Record the execution against the gate to spend
261
+ it, and the server refuses a second.
262
+
224
263
  ## Flows
225
264
 
226
265
  A job that takes more than one of them is one job, and a firm asking about it
@@ -324,6 +363,48 @@ A finding of kind `decision` is a suggestion until a person confirms it.
324
363
  `task.requestDecisionApproval(findingId)` puts it to somebody. Only a person
325
364
  changes what a task is for; an agent proposes that as a finding too.
326
365
 
366
+ ## Context
367
+
368
+ What your agents know, and how the job gets done, kept in Deliverd rather than
369
+ in any one agent's memory. An agent proposes knowledge; a person confirms it;
370
+ every agent after that reads it.
371
+
372
+ ```ts
373
+ const { entries } = await deliverd.knowledge.search({ q: "supplier bank details" });
374
+
375
+ await deliverd.knowledge.propose({
376
+ kind: "convention",
377
+ title: "Bank details are confirmed by phone",
378
+ body: "Call the number on file, never the one in the email asking for the change.",
379
+ tags: ["payments"],
380
+ });
381
+ ```
382
+
383
+ A task's context carries the confirmed entries relevant to it as
384
+ `context.knowledge`, so most agents never call `search()` at all. The
385
+ knowledge is yours to take anywhere: `deliverd.knowledge.exportMarkdown()`
386
+ returns Markdown that `import()` reads back, and `agentsMd()` writes an
387
+ AGENTS.md for a tool that reads files rather than calling APIs.
388
+
389
+ A playbook is a job written down as steps, each with the rule that applies
390
+ before it acts. A person puts it in force; running it starts an objective with
391
+ a side task per step:
392
+
393
+ ```ts
394
+ const [playbook] = await deliverd.playbooks.list();
395
+ const run = await deliverd.playbooks.start(playbook.inForce!.id, {
396
+ inputs: { supplier: "Northwind" },
397
+ externalId: "onboard-northwind",
398
+ });
399
+ run.steps; // [{ key, taskId, title, rule }], in order
400
+ ```
401
+
402
+ A step's context names the call its rule needs (`check_gate`,
403
+ `request_approval` or `request_review`). `deliverd.knowledge.given(taskId)`
404
+ says what a run was given, and who confirmed it. Confirming knowledge and
405
+ putting a playbook in force are a person's, in the app; a key can draft and
406
+ propose, never decide.
407
+
327
408
  ## Compliance Mode
328
409
 
329
410
  On Business and Enterprise, a task can be governed: the AI system doing the
@@ -0,0 +1,46 @@
1
+ import type { HttpClient } from "./http.js";
2
+ import type { ContextGiven, DraftPlaybookInput, EditKnowledgeInput, ExportKnowledgeInput, ImportedKnowledge, ImportKnowledgeInput, KnowledgeDetail, KnowledgeEntryData, KnowledgeExport, KnowledgeSearchResult, PlaybookData, PlaybookDetail, PlaybookSummary, PromoteFindingInput, ProposedKnowledge, ProposeKnowledgeInput, RequestPlaybookApprovalInput, SearchKnowledgeInput, StartedPlaybook, StartPlaybookInput } from "./types.js";
3
+ export declare class Knowledge {
4
+ private readonly http;
5
+ constructor(http: HttpClient);
6
+ /** Ranked by relevance to `q`; confirmed entries unless `status` says otherwise. */
7
+ search(input?: SearchKnowledgeInput, signal?: AbortSignal): Promise<KnowledgeSearchResult>;
8
+ /** One entry, with the versions before and after it. */
9
+ get(id: string, signal?: AbortSignal): Promise<KnowledgeDetail>;
10
+ /** Propose an entry. It is a proposal until a person confirms it. */
11
+ propose(input: ProposeKnowledgeInput, signal?: AbortSignal): Promise<ProposedKnowledge>;
12
+ /** Change a proposal you made. A confirmed entry is changed by proposing a revision (`supersedesId`). */
13
+ edit(id: string, input: EditKnowledgeInput, signal?: AbortSignal): Promise<KnowledgeEntryData>;
14
+ /** Propose a task's finding as knowledge, keeping where it came from. */
15
+ promoteFinding(taskId: string, findingId: string, input?: PromoteFindingInput, signal?: AbortSignal): Promise<ProposedKnowledge>;
16
+ /** Bring in a Deliverd export or a notes file such as AGENTS.md. Each heading becomes a proposed entry. */
17
+ import(input: ImportKnowledgeInput, signal?: AbortSignal): Promise<ImportedKnowledge>;
18
+ /** Everything you may see, as Markdown that imports back. */
19
+ exportMarkdown(input?: ExportKnowledgeInput, signal?: AbortSignal): Promise<string>;
20
+ /** The same, as JSON. */
21
+ exportJson(input?: ExportKnowledgeInput, signal?: AbortSignal): Promise<KnowledgeExport>;
22
+ /** An AGENTS.md of the confirmed knowledge and the playbooks in force, for a tool that reads files. */
23
+ agentsMd(options?: {
24
+ workspaceId?: string;
25
+ }, signal?: AbortSignal): Promise<string>;
26
+ /** What a task and its side tasks were given, newest first: the record behind "what did it know?". */
27
+ given(taskId: string, signal?: AbortSignal): Promise<ContextGiven[]>;
28
+ }
29
+ export declare class Playbooks {
30
+ private readonly http;
31
+ constructor(http: HttpClient);
32
+ /** One row per playbook: its newest version, and the version in force. */
33
+ list(signal?: AbortSignal): Promise<PlaybookSummary[]>;
34
+ get(id: string, signal?: AbortSignal): Promise<PlaybookDetail>;
35
+ /** Draft a new playbook. Nobody runs a draft until a person puts it in force. */
36
+ draft(input: DraftPlaybookInput, signal?: AbortSignal): Promise<PlaybookData>;
37
+ /** Draft the next version of a playbook; the version in force keeps running until this one replaces it. */
38
+ draftVersion(id: string, input: DraftPlaybookInput, signal?: AbortSignal): Promise<PlaybookData>;
39
+ /** Change a draft that has not been put to anybody. */
40
+ updateDraft(id: string, input: DraftPlaybookInput, signal?: AbortSignal): Promise<PlaybookData>;
41
+ /** Put a draft to people as a Deliverd approval. Approved, it goes in force. Needs `approvals:write` and `tasks:write`. */
42
+ requestApproval(id: string, input?: RequestPlaybookApprovalInput, signal?: AbortSignal): Promise<PlaybookData>;
43
+ /** Run the version in force: an objective, and a side task per step. */
44
+ start(id: string, input?: StartPlaybookInput, signal?: AbortSignal): Promise<StartedPlaybook>;
45
+ }
46
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,oBAAo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AE,kBAAuB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;CAGlG"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Context: what your agents know, and how the job gets done.
3
+ *
4
+ * Knowledge is the organisation's, not any one agent's: an agent proposes an
5
+ * entry, a person confirms it in Deliverd, and every agent after that reads
6
+ * it, through this SDK, the MCP tools, or an AGENTS.md exported from it. The
7
+ * export is Markdown and imports back, so none of it is locked to a tool.
8
+ *
9
+ * A playbook is a written-down job: steps, each with the rule that applies
10
+ * before it acts (a gate, an approval, a review). Running one starts an
11
+ * objective with a side task per step. A person puts a playbook in force; an
12
+ * agent's key can draft one and run one, never publish it, and never confirm
13
+ * knowledge.
14
+ */
15
+ const enc = encodeURIComponent;
16
+ export class Knowledge {
17
+ http;
18
+ constructor(http) {
19
+ this.http = http;
20
+ }
21
+ /** Ranked by relevance to `q`; confirmed entries unless `status` says otherwise. */
22
+ search(input = {}, signal) {
23
+ return this.http.request({
24
+ method: "GET",
25
+ path: "/knowledge",
26
+ query: { q: input.q, kind: input.kind, status: input.status, workspaceId: input.workspaceId, flowId: input.flowId, limit: input.limit },
27
+ signal,
28
+ });
29
+ }
30
+ /** One entry, with the versions before and after it. */
31
+ get(id, signal) {
32
+ return this.http.request({ method: "GET", path: `/knowledge/${enc(id)}`, signal });
33
+ }
34
+ /** Propose an entry. It is a proposal until a person confirms it. */
35
+ propose(input, signal) {
36
+ return this.http.request({ method: "POST", path: "/knowledge", body: input, signal });
37
+ }
38
+ /** Change a proposal you made. A confirmed entry is changed by proposing a revision (`supersedesId`). */
39
+ edit(id, input, signal) {
40
+ return this.http.request({ method: "PATCH", path: `/knowledge/${enc(id)}`, body: input, signal });
41
+ }
42
+ /** Propose a task's finding as knowledge, keeping where it came from. */
43
+ promoteFinding(taskId, findingId, input = {}, signal) {
44
+ return this.http.request({
45
+ method: "POST",
46
+ path: `/tasks/${enc(taskId)}/findings/${enc(findingId)}/knowledge`,
47
+ body: input,
48
+ signal,
49
+ });
50
+ }
51
+ /** Bring in a Deliverd export or a notes file such as AGENTS.md. Each heading becomes a proposed entry. */
52
+ import(input, signal) {
53
+ return this.http.request({ method: "POST", path: "/knowledge/import", body: input, signal });
54
+ }
55
+ /** Everything you may see, as Markdown that imports back. */
56
+ exportMarkdown(input = {}, signal) {
57
+ return this.http.request({
58
+ method: "GET",
59
+ path: "/knowledge/export",
60
+ query: { format: "markdown", status: input.status, workspaceId: input.workspaceId },
61
+ responseType: "text",
62
+ signal,
63
+ });
64
+ }
65
+ /** The same, as JSON. */
66
+ exportJson(input = {}, signal) {
67
+ return this.http.request({
68
+ method: "GET",
69
+ path: "/knowledge/export",
70
+ query: { format: "json", status: input.status, workspaceId: input.workspaceId },
71
+ signal,
72
+ });
73
+ }
74
+ /** An AGENTS.md of the confirmed knowledge and the playbooks in force, for a tool that reads files. */
75
+ agentsMd(options = {}, signal) {
76
+ return this.http.request({
77
+ method: "GET",
78
+ path: "/knowledge/agents-md",
79
+ query: { workspaceId: options.workspaceId },
80
+ responseType: "text",
81
+ signal,
82
+ });
83
+ }
84
+ /** What a task and its side tasks were given, newest first: the record behind "what did it know?". */
85
+ async given(taskId, signal) {
86
+ const out = await this.http.request({ method: "GET", path: `/tasks/${enc(taskId)}/context-given`, signal });
87
+ return out.given;
88
+ }
89
+ }
90
+ export class Playbooks {
91
+ http;
92
+ constructor(http) {
93
+ this.http = http;
94
+ }
95
+ /** One row per playbook: its newest version, and the version in force. */
96
+ async list(signal) {
97
+ const out = await this.http.request({ method: "GET", path: "/playbooks", signal });
98
+ return out.playbooks;
99
+ }
100
+ get(id, signal) {
101
+ return this.http.request({ method: "GET", path: `/playbooks/${enc(id)}`, signal });
102
+ }
103
+ /** Draft a new playbook. Nobody runs a draft until a person puts it in force. */
104
+ draft(input, signal) {
105
+ return this.http.request({ method: "POST", path: "/playbooks", body: input, signal });
106
+ }
107
+ /** Draft the next version of a playbook; the version in force keeps running until this one replaces it. */
108
+ draftVersion(id, input, signal) {
109
+ return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/versions`, body: input, signal });
110
+ }
111
+ /** Change a draft that has not been put to anybody. */
112
+ updateDraft(id, input, signal) {
113
+ return this.http.request({ method: "PATCH", path: `/playbooks/${enc(id)}`, body: input, signal });
114
+ }
115
+ /** Put a draft to people as a Deliverd approval. Approved, it goes in force. Needs `approvals:write` and `tasks:write`. */
116
+ requestApproval(id, input = {}, signal) {
117
+ return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/approval`, body: input, signal });
118
+ }
119
+ /** Run the version in force: an objective, and a side task per step. */
120
+ start(id, input = {}, signal) {
121
+ return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/start`, body: input, signal });
122
+ }
123
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"data-screen.d.ts","sourceRoot":"","sources":["../src/data-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,+DAAgE,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E,eAAO,MAAM,iBAAiB,yEAA0E,CAAC;AACzG,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,eAAO,MAAM,eAAe,6CAA8C,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,qEAAqE;AACrE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAerD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUrB,6FAA6F;;;;;;;;;;;;;;;;;;;;;;;;;CAKlD,CAAC;AAE9C,MAAM,MAAM,QAAQ,GAAG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M,EAAE,CAAC;CACnB;AAMD,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAe3D;AAID,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAgB3D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,MAAM,GAAE,YAAoC,EAC5C,kBAAkB,GAAE,oBAAqC,GACxD,gBAAgB,CAiDlB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,WAAW,CAAC,GAAG,SAAS,GAAG,IAAI,CAIzJ;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,CAE7F"}
@@ -312,6 +312,12 @@ export function describeCounts(counts) {
312
312
  return plural(n, "confidential term");
313
313
  if (k === "person_name")
314
314
  return `${n} ${n === 1 ? "person's name" : "people's names"}`;
315
+ if (k === "ip_address")
316
+ return `${n} IP address${n === 1 ? "" : "es"}`;
317
+ if (k === "date_of_birth")
318
+ return `${n} date${n === 1 ? "" : "s"} of birth`;
319
+ if (k === "ie_pps")
320
+ return `${n} Irish PPS number${n === 1 ? "" : "s"}`;
315
321
  return /^[A-Z]{2,}/.test(label) ? `${n} ${label}${n === 1 ? "" : "s"}` : plural(n, label);
316
322
  });
317
323
  if (parts.length <= 1)
@@ -0,0 +1,102 @@
1
+ import { type KeyObject } from "node:crypto";
2
+ /**
3
+ * Checking a decision token where the action happens.
4
+ *
5
+ * A gate that may be acted on carries `decisionToken`: the yes, signed with
6
+ * the deployment's Ed25519 evidence key. Hand it to the service that performs
7
+ * the action — the one that issues the refund or merges the change — and that
8
+ * service checks it against what it is about to do before it does it:
9
+ *
10
+ * ```ts
11
+ * const check = await deliverd.decisionTokens.verify(req.headers["deliverd-decision"], {
12
+ * action: "finance.refund",
13
+ * input: { customer_id, amount, currency },
14
+ * });
15
+ * if (!check.ok) return res.status(403).send(check.reason);
16
+ * ```
17
+ *
18
+ * It fails when the token was not signed by your Deliverd, has expired, is for
19
+ * another action, or was agreed for a different input: a refund of £1240
20
+ * against a yes for £1200 is refused. It needs no API key and makes no call
21
+ * beyond fetching the public key once.
22
+ *
23
+ * What it does not check is how many times the yes has been used. Record the
24
+ * execution against the gate (`gate.recordExecution`) to spend the use; the
25
+ * server refuses a second.
26
+ *
27
+ * Kept byte-for-byte with the server's `lib/governance/decision-token.ts`;
28
+ * `decision-token.test.ts` on the server signs there and verifies here.
29
+ */
30
+ export declare const DECISION_TOKEN_PREFIX = "dlv_dt1";
31
+ export declare const DECISION_TOKEN_CONTEXT = "deliverd-decision-token:v1:";
32
+ /** Where a deployment publishes the key that signs its tokens and evidence packs. */
33
+ export declare const EVIDENCE_KEY_PATH = "/.well-known/deliverd-evidence-key";
34
+ export interface DecisionTokenClaims {
35
+ v: 1;
36
+ kid: string;
37
+ iss: string;
38
+ org: string;
39
+ gate: string;
40
+ action: string;
41
+ /** Hex SHA-256 of the approved input in canonical JSON. */
42
+ input: string;
43
+ dest: {
44
+ type: string;
45
+ id: string;
46
+ } | null;
47
+ artifact: string | null;
48
+ iat: number;
49
+ exp: number;
50
+ }
51
+ export interface DecisionTokenExpectation {
52
+ /** The action you are about to perform. */
53
+ action: string;
54
+ /** The input you are about to perform it with. */
55
+ input: unknown;
56
+ /** Where it lands, when the gate named a destination. */
57
+ destination?: {
58
+ type: string;
59
+ id: string;
60
+ } | null;
61
+ /** The SHA-256 of what you are sending, when the gate named an artifact. */
62
+ artifactSha256?: string | null;
63
+ }
64
+ export type DecisionTokenFailure = "missing" | "malformed" | "bad_signature" | "wrong_issuer" | "expired" | "wrong_action" | "input_mismatch" | "destination_mismatch" | "artifact_mismatch";
65
+ export type DecisionTokenResult = {
66
+ ok: true;
67
+ claims: DecisionTokenClaims;
68
+ } | {
69
+ ok: false;
70
+ reason: DecisionTokenFailure;
71
+ };
72
+ /** Keys sorted at every depth, undefined dropped: the server's `canonicalJson`. */
73
+ export declare function canonicalJson(value: unknown): string;
74
+ export declare function decisionInputHash(input: unknown): string;
75
+ /**
76
+ * Verify with a key you already hold: a PEM string or a `KeyObject`. `issuer`
77
+ * is the origin of the deployment you trust, such as `https://deliverd.dev`.
78
+ */
79
+ export declare function verifyDecisionToken(token: string | null | undefined, expected: DecisionTokenExpectation, key: {
80
+ publicKey: string | KeyObject;
81
+ issuer: string;
82
+ now?: Date;
83
+ skewSeconds?: number;
84
+ }): DecisionTokenResult;
85
+ /**
86
+ * `deliverd.decisionTokens`: verification against the deployment this client
87
+ * talks to. The key comes from that deployment's own well-known address and
88
+ * the issuer must be that deployment, never whatever the token names, so a
89
+ * token signed by somebody else's Deliverd does not pass.
90
+ */
91
+ export declare class DecisionTokens {
92
+ private readonly baseUrl;
93
+ private readonly doFetch;
94
+ private key;
95
+ constructor(baseUrl: string, doFetch?: typeof globalThis.fetch);
96
+ verify(token: string | null | undefined, expected: DecisionTokenExpectation, options?: {
97
+ now?: Date;
98
+ skewSeconds?: number;
99
+ }): Promise<DecisionTokenResult>;
100
+ private publicKey;
101
+ }
102
+ //# sourceMappingURL=decision-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-token.d.ts","sourceRoot":"","sources":["../src/decision-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAGlF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAC/C,eAAO,MAAM,sBAAsB,gCAAgC,CAAC;AACpE,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,uCAAuC,CAAC;AAEtE,MAAM,WAAW,mBAA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gB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ,EAAE,wBAAwB,EAClC,GAAG,EAAE;IAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACvF,mBAAmB,CAmCrB;AAED;;;;;GAKG;AACH,qBAAa,cAAc;IAIvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,GAAG,CAAmC;gBAG3B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,OAAO,UAAU,CAAC,KAAwB;IAGhE,MAAM,CACV,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ,EAAE,wBAAwB,EAClC,OAAO,GAAE;QAAE,GAAG,CAAC,EAAE,IAAI,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GACjD,OAAO,CAAC,mBAAmB,CAAC;IAM/B,OAAO,CAAC,SAAS;CAelB"}
@@ -0,0 +1,139 @@
1
+ import { createHash, createPublicKey, verify } from "node:crypto";
2
+ import { DeliverdError } from "./errors.js";
3
+ /**
4
+ * Checking a decision token where the action happens.
5
+ *
6
+ * A gate that may be acted on carries `decisionToken`: the yes, signed with
7
+ * the deployment's Ed25519 evidence key. Hand it to the service that performs
8
+ * the action — the one that issues the refund or merges the change — and that
9
+ * service checks it against what it is about to do before it does it:
10
+ *
11
+ * ```ts
12
+ * const check = await deliverd.decisionTokens.verify(req.headers["deliverd-decision"], {
13
+ * action: "finance.refund",
14
+ * input: { customer_id, amount, currency },
15
+ * });
16
+ * if (!check.ok) return res.status(403).send(check.reason);
17
+ * ```
18
+ *
19
+ * It fails when the token was not signed by your Deliverd, has expired, is for
20
+ * another action, or was agreed for a different input: a refund of £1240
21
+ * against a yes for £1200 is refused. It needs no API key and makes no call
22
+ * beyond fetching the public key once.
23
+ *
24
+ * What it does not check is how many times the yes has been used. Record the
25
+ * execution against the gate (`gate.recordExecution`) to spend the use; the
26
+ * server refuses a second.
27
+ *
28
+ * Kept byte-for-byte with the server's `lib/governance/decision-token.ts`;
29
+ * `decision-token.test.ts` on the server signs there and verifies here.
30
+ */
31
+ export const DECISION_TOKEN_PREFIX = "dlv_dt1";
32
+ export const DECISION_TOKEN_CONTEXT = "deliverd-decision-token:v1:";
33
+ /** Where a deployment publishes the key that signs its tokens and evidence packs. */
34
+ export const EVIDENCE_KEY_PATH = "/.well-known/deliverd-evidence-key";
35
+ /** Keys sorted at every depth, undefined dropped: the server's `canonicalJson`. */
36
+ export function canonicalJson(value) {
37
+ if (value === null || typeof value !== "object")
38
+ return JSON.stringify(value ?? null);
39
+ if (Array.isArray(value))
40
+ return `[${value.map(canonicalJson).join(",")}]`;
41
+ const entries = Object.entries(value)
42
+ .filter(([, v]) => v !== undefined)
43
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
44
+ return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
45
+ }
46
+ export function decisionInputHash(input) {
47
+ return createHash("sha256").update(canonicalJson(input ?? {}), "utf8").digest("hex");
48
+ }
49
+ /** The server's `sameDestination`: addresses and domains ignore case, ids do not. */
50
+ function sameDestination(a, b) {
51
+ if (a.type !== b.type)
52
+ return false;
53
+ const fold = a.type === "email" || a.type === "domain";
54
+ return fold ? a.id.trim().toLowerCase() === b.id.trim().toLowerCase() : a.id.trim() === b.id.trim();
55
+ }
56
+ /**
57
+ * Verify with a key you already hold: a PEM string or a `KeyObject`. `issuer`
58
+ * is the origin of the deployment you trust, such as `https://deliverd.dev`.
59
+ */
60
+ export function verifyDecisionToken(token, expected, key) {
61
+ if (!token)
62
+ return { ok: false, reason: "missing" };
63
+ const parts = token.split(".");
64
+ if (parts.length !== 3 || parts[0] !== DECISION_TOKEN_PREFIX)
65
+ return { ok: false, reason: "malformed" };
66
+ let claims;
67
+ try {
68
+ claims = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
69
+ }
70
+ catch {
71
+ return { ok: false, reason: "malformed" };
72
+ }
73
+ if (claims?.v !== 1)
74
+ return { ok: false, reason: "malformed" };
75
+ let good = false;
76
+ try {
77
+ const publicKey = typeof key.publicKey === "string" ? createPublicKey(key.publicKey) : key.publicKey;
78
+ good = verify(null, Buffer.from(DECISION_TOKEN_CONTEXT + parts[1], "utf8"), publicKey, Buffer.from(parts[2], "base64url"));
79
+ }
80
+ catch {
81
+ good = false;
82
+ }
83
+ if (!good)
84
+ return { ok: false, reason: "bad_signature" };
85
+ if (claims.iss !== key.issuer.replace(/\/+$/, ""))
86
+ return { ok: false, reason: "wrong_issuer" };
87
+ const now = Math.floor((key.now ?? new Date()).getTime() / 1000);
88
+ if (claims.exp + (key.skewSeconds ?? 30) <= now)
89
+ return { ok: false, reason: "expired" };
90
+ if (claims.action !== expected.action)
91
+ return { ok: false, reason: "wrong_action" };
92
+ if (claims.input !== decisionInputHash(expected.input))
93
+ return { ok: false, reason: "input_mismatch" };
94
+ if (claims.dest) {
95
+ const d = expected.destination;
96
+ if (!d || !sameDestination(d, claims.dest))
97
+ return { ok: false, reason: "destination_mismatch" };
98
+ }
99
+ if (claims.artifact && expected.artifactSha256 !== claims.artifact)
100
+ return { ok: false, reason: "artifact_mismatch" };
101
+ return { ok: true, claims };
102
+ }
103
+ /**
104
+ * `deliverd.decisionTokens`: verification against the deployment this client
105
+ * talks to. The key comes from that deployment's own well-known address and
106
+ * the issuer must be that deployment, never whatever the token names, so a
107
+ * token signed by somebody else's Deliverd does not pass.
108
+ */
109
+ export class DecisionTokens {
110
+ baseUrl;
111
+ doFetch;
112
+ key = null;
113
+ constructor(baseUrl, doFetch = globalThis.fetch) {
114
+ this.baseUrl = baseUrl;
115
+ this.doFetch = doFetch;
116
+ }
117
+ async verify(token, expected, options = {}) {
118
+ if (!token)
119
+ return { ok: false, reason: "missing" };
120
+ const publicKey = await this.publicKey();
121
+ return verifyDecisionToken(token, expected, { publicKey, issuer: new URL(this.baseUrl).origin, ...options });
122
+ }
123
+ publicKey() {
124
+ this.key ??= (async () => {
125
+ const res = await this.doFetch(`${this.baseUrl.replace(/\/+$/, "")}${EVIDENCE_KEY_PATH}`);
126
+ if (!res.ok) {
127
+ throw new DeliverdError(res.status, "no_signing_key", "This deployment does not publish a signing key.");
128
+ }
129
+ const body = (await res.json());
130
+ if (!body.publicKey)
131
+ throw new DeliverdError(0, "no_signing_key", "The signing key response had no public key.");
132
+ return createPublicKey(body.publicKey);
133
+ })().catch((err) => {
134
+ this.key = null;
135
+ throw err;
136
+ });
137
+ return this.key;
138
+ }
139
+ }
package/dist/dev.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAWb,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE7F,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,kBAAkB,CAAC,CAAC;IAC/E,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAcD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,UAAU,CAAC,KAAK,CAqnB1F"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAYb,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE7F,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,kBAAkB,CAAC,CAAC;IAC/E,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAcD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,UAAU,CAAC,KAAK,CAwnB1F"}
package/dist/dev.js CHANGED
@@ -45,6 +45,7 @@ export function developmentFetch(options = {}) {
45
45
  changes: [],
46
46
  concerns: [],
47
47
  requestedBy: "You (development mode)",
48
+ ...declaredOf(body),
48
49
  approvers: body.approvers ?? [],
49
50
  /*
50
51
  * One, always. A standing rule could raise it on a real organisation,
@@ -136,6 +137,7 @@ export function developmentFetch(options = {}) {
136
137
  externalId: body.externalId ?? null,
137
138
  metadata: body.metadata ?? {},
138
139
  requestedBy: "You (development mode)",
140
+ ...declaredOf(body),
139
141
  requiredApprovals: body.requiredApprovals ?? 1,
140
142
  reviewers,
141
143
  verdicts: [],
@@ -382,6 +384,7 @@ export function developmentFetch(options = {}) {
382
384
  externalId: body.externalId ?? null,
383
385
  metadata: body.metadata ?? {},
384
386
  requestedBy: "You (development mode)",
387
+ ...declaredOf(body),
385
388
  requiredResponses: body.requiredResponses ?? (asked.length || 1),
386
389
  questions,
387
390
  responses: asked.map((who) => ({
@@ -593,6 +596,18 @@ export function developmentFetch(options = {}) {
593
596
  });
594
597
  return handle;
595
598
  }
599
+ /**
600
+ * The agent and model a request declared, as the API echoes them: what was
601
+ * sent, every field present, null when nothing was. Development mode stores
602
+ * nothing, so this is the whole of it.
603
+ */
604
+ function declaredOf(body) {
605
+ const a = body.agent;
606
+ const agent = a && (a.name || a.provider || a.externalId)
607
+ ? { name: a.name ?? null, provider: a.provider ?? null, externalId: a.externalId ?? null }
608
+ : null;
609
+ return { agent, model: typeof body.model === "string" && body.model ? body.model : null };
610
+ }
596
611
  function resolveOutcome(outcome, body) {
597
612
  const fromEnv = process.env.DELIVERD_DEV_OUTCOME;
598
613
  const chosen = outcome ?? fromEnv ?? "approved";
package/dist/gates.d.ts CHANGED
@@ -73,6 +73,8 @@ export declare class Gate {
73
73
  get scope(): GateData["scope"];
74
74
  /** How long it lasts and how many uses are left. */
75
75
  get authorisation(): GateData["authorisation"];
76
+ /** The signed yes to hand the code that performs the action. Null unless `canExecute`. */
77
+ get decisionToken(): string | null;
76
78
  /** A person sent it back. Revise and ask again with `supersedesGateId: gate.id`. */
77
79
  get changesRequested(): boolean;
78
80
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../src/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACrB,MAAM,YAAY,CAAC;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Ae,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,gFAAgF;IAC1E,eAAe,CACnB,EAAE,EAAE,MAAM,EACV,KAAK,GAAE,oBAAyB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC;IAKrD,mDAAmD;IAC7C,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlG;;;OAGG;IACG,OAAO,CACX,EAAE,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,YAAY,EACpB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,IAAI,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAUlE,yCAAyC;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAIlF;;;;;OAKG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBzE,8BAA8B;IACxB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ3D"}
package/dist/gates.js CHANGED
@@ -98,6 +98,8 @@ export class Gate {
98
98
  get scope() { return this.data.scope; }
99
99
  /** How long it lasts and how many uses are left. */
100
100
  get authorisation() { return this.data.authorisation; }
101
+ /** The signed yes to hand the code that performs the action. Null unless `canExecute`. */
102
+ get decisionToken() { return this.data.decisionToken ?? null; }
101
103
  /** A person sent it back. Revise and ask again with `supersedesGateId: gate.id`. */
102
104
  get changesRequested() { return this.data.status === "changes_requested"; }
103
105
  /**
@@ -133,6 +135,7 @@ export class Gate {
133
135
  changes: this.data.changes ?? [],
134
136
  id: this.data.id,
135
137
  approvalUrl: this.data.approvalUrl,
138
+ decisionToken: this.data.decisionToken ?? null,
136
139
  gate: this,
137
140
  };
138
141
  }