@openvtc/trust-tasks 0.12.16 → 0.13.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.
Files changed (52) hide show
  1. package/README.md +27 -3
  2. package/dist/_runtime/canonical.d.ts +40 -0
  3. package/dist/_runtime/canonical.d.ts.map +1 -0
  4. package/dist/_runtime/canonical.js +147 -0
  5. package/dist/_runtime/canonical.js.map +1 -0
  6. package/dist/_runtime/consume.d.ts +108 -2
  7. package/dist/_runtime/consume.d.ts.map +1 -1
  8. package/dist/_runtime/consume.js +174 -8
  9. package/dist/_runtime/consume.js.map +1 -1
  10. package/dist/_runtime/document.d.ts +17 -4
  11. package/dist/_runtime/document.d.ts.map +1 -1
  12. package/dist/_runtime/document.js +17 -4
  13. package/dist/_runtime/document.js.map +1 -1
  14. package/dist/_runtime/freshness.d.ts +105 -0
  15. package/dist/_runtime/freshness.d.ts.map +1 -0
  16. package/dist/_runtime/freshness.js +142 -0
  17. package/dist/_runtime/freshness.js.map +1 -0
  18. package/dist/_runtime/index.d.ts +4 -1
  19. package/dist/_runtime/index.d.ts.map +1 -1
  20. package/dist/_runtime/index.js +4 -1
  21. package/dist/_runtime/index.js.map +1 -1
  22. package/dist/_runtime/replay.d.ts +176 -0
  23. package/dist/_runtime/replay.d.ts.map +1 -0
  24. package/dist/_runtime/replay.js +147 -0
  25. package/dist/_runtime/replay.js.map +1 -0
  26. package/dist/keys/create/0.1/payload.d.ts +27 -13
  27. package/dist/keys/create/0.1/payload.d.ts.map +1 -1
  28. package/dist/keys/create/0.1/payload.js +11 -5
  29. package/dist/keys/create/0.1/payload.js.map +1 -1
  30. package/dist/keys/import/0.1/payload.d.ts +10 -10
  31. package/dist/keys/import/0.1/payload.d.ts.map +1 -1
  32. package/dist/keys/import/0.1/payload.js +6 -4
  33. package/dist/keys/import/0.1/payload.js.map +1 -1
  34. package/dist/keys/list/0.1/payload.d.ts +10 -10
  35. package/dist/keys/list/0.1/payload.d.ts.map +1 -1
  36. package/dist/keys/list/0.1/payload.js +6 -4
  37. package/dist/keys/list/0.1/payload.js.map +1 -1
  38. package/dist/keys/show/0.1/payload.d.ts +10 -10
  39. package/dist/keys/show/0.1/payload.d.ts.map +1 -1
  40. package/dist/keys/show/0.1/payload.js +6 -4
  41. package/dist/keys/show/0.1/payload.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/_runtime/canonical.ts +159 -0
  44. package/src/_runtime/consume.ts +267 -10
  45. package/src/_runtime/document.ts +17 -4
  46. package/src/_runtime/freshness.ts +183 -0
  47. package/src/_runtime/index.ts +30 -0
  48. package/src/_runtime/replay.ts +250 -0
  49. package/src/keys/create/0.1/payload.ts +20 -8
  50. package/src/keys/import/0.1/payload.ts +8 -6
  51. package/src/keys/list/0.1/payload.ts +8 -6
  52. package/src/keys/show/0.1/payload.ts +8 -6
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Duplicate-execution protection — SPEC §7.2 item 11, §8.4, §10.1.
3
+ *
4
+ * Mirrors `replay.rs` in trust-tasks-rs, check for check.
5
+ *
6
+ * # The rule
7
+ *
8
+ * §7.2 item 11 is normative and unconditional for a *consequential Trust
9
+ * Task*: once a consumer has accepted a document with a given `id` for
10
+ * execution, receiving that same document again **MUST NOT** cause the
11
+ * consequential effect a second time, and receiving a *different* document
12
+ * under the same `id` **MUST** be rejected with `idConflict`.
13
+ *
14
+ * §8.4 is the same mechanism from the producer's end: a retry is a bit-for-bit
15
+ * identical resend, and it is safe *precisely because* item 11 obliges the
16
+ * consumer to absorb it. Every transport binding in this repo delegates replay
17
+ * defence to the consumer — `bindings/https/0.2` §5 says "Freshness / replay:
18
+ * None", and the DIDComm and TSP bindings say the same — so if the consumer
19
+ * does not do it, nobody does, and an ordinary mediator redelivery grants an
20
+ * ACL entry twice by accident. §10.1: "The rule deliberately does not
21
+ * distinguish a hostile replay from a legitimate transport retry, because at
22
+ * the document layer the two are indistinguishable."
23
+ *
24
+ * # The key
25
+ *
26
+ * The `id` **alone** — "Transport request identifiers, transport message
27
+ * identifiers, and execution handles **MUST NOT** substitute" — plus a digest
28
+ * of the canonical serialization, because "an `id` alone cannot distinguish
29
+ * the retry it must absorb from the conflict it must reject".
30
+ *
31
+ * {@link documentDigest} hashes {@link canonicalJson} of the whole document
32
+ * rather than the octets as received: a re-indented body or a member order
33
+ * chosen by an intermediary would otherwise make a legitimate §8.4 retry look
34
+ * like a *different* document.
35
+ *
36
+ * The digest covers the **entire** document, `proof` included. That differs
37
+ * deliberately from the §4.9.3 *task digest*, computed over
38
+ * `JCS(document ∖ proof)`, and the spec spells the distinction out: "Item 11
39
+ * and §8.4 ask *which serialization arrived*, so a re-signed `proof` over
40
+ * identical content makes a different document — that is the `idConflict`
41
+ * case, and the distinction is the whole point of the rule."
42
+ */
43
+
44
+ import { canonicalJson, sha256Hex } from "./canonical.js";
45
+ import type { TrustTaskDocument } from "./document.js";
46
+
47
+ /**
48
+ * The content identity of a document, per SPEC §7.2's keying paragraph:
49
+ * SHA-256 over the canonical serialization of the whole document, as hex.
50
+ *
51
+ * Consumer-local. Never on the wire, and **not** the §4.9.3 task digest.
52
+ */
53
+ export function documentDigest<P>(doc: TrustTaskDocument<P>): string {
54
+ return sha256Hex(canonicalJson(doc));
55
+ }
56
+
57
+ /** What a {@link ReplayGuard} says about a document offered for execution. */
58
+ export type ReplayVerdict =
59
+ /** Not seen before. The caller may execute. */
60
+ | { kind: "fresh" }
61
+ /**
62
+ * Already accepted under the *same* digest — a §8.4 retry, or a replay. The
63
+ * caller **MUST NOT** execute again.
64
+ */
65
+ | {
66
+ kind: "duplicate";
67
+ /** The response the first execution produced, where one was retained. */
68
+ priorResponse?: unknown;
69
+ /** Whether that first execution is still running. */
70
+ inFlight: boolean;
71
+ }
72
+ /**
73
+ * Already accepted under a *different* digest. §7.2 item 11 requires
74
+ * `idConflict`, and requires that this not be treated as a retry.
75
+ */
76
+ | { kind: "conflict" };
77
+
78
+ /**
79
+ * The consumer-side record that makes SPEC §7.2 item 11 true.
80
+ *
81
+ * An interface, so a deployment can back it with Redis, Postgres, or anything
82
+ * that survives a process restart. {@link InMemoryReplayGuard} is the default
83
+ * and is correct for a single-process consumer; it is **not** correct behind a
84
+ * load balancer, where two replicas would each accept the same document once.
85
+ */
86
+ export interface ReplayGuard {
87
+ /**
88
+ * Claim `id` for execution on behalf of a document with identity `digest`.
89
+ *
90
+ * `retainUntil` is the instant past which the record may be dropped —
91
+ * {@link recordExpiry}, which SPEC §7.2 makes the same instant as the end of
92
+ * the consumer's willingness to execute the document. An implementation
93
+ * SHOULD treat a record whose `retainUntil` has passed as absent, so the key
94
+ * is released rather than conflicting forever with a document nobody would
95
+ * execute.
96
+ *
97
+ * Implementations **MUST** make claim-and-record atomic with respect to
98
+ * concurrent calls: two simultaneous deliveries of the same document must
99
+ * not both receive `fresh`. That is the whole guarantee.
100
+ *
101
+ * Throwing means the record could not be consulted. {@link consumeInbound}
102
+ * fails closed on that, mapping it to `unavailable` with `retryable: true` —
103
+ * a consumer that cannot establish whether a document is a duplicate has not
104
+ * satisfied item 11, and executing anyway is the double execution the rule
105
+ * forbids.
106
+ */
107
+ claim(
108
+ id: string,
109
+ digest: string,
110
+ retainUntil: number | undefined,
111
+ now: number,
112
+ ): Promise<ReplayVerdict> | ReplayVerdict;
113
+
114
+ /**
115
+ * Attach the response a completed execution produced, so a later duplicate
116
+ * can be answered with it per §7.2 (*Disposition of a duplicate*) rather
117
+ * than merely absorbed in silence.
118
+ *
119
+ * Optional: a guard that records nothing still satisfies item 11 — the
120
+ * effect does not happen twice — and is the right shape for a
121
+ * fire-and-forget specification, which has no response to return.
122
+ */
123
+ recordResponse?(id: string, response: unknown): Promise<void> | void;
124
+
125
+ /**
126
+ * Release a claim whose execution is not to stand — for example a refusal
127
+ * the consumer marked `retryable`, where §8.4 has just invited the producer
128
+ * to re-send the same bytes. Without this, that invited retry would come
129
+ * back as an absorbed duplicate carrying the same failure forever.
130
+ */
131
+ release?(id: string, digest: string): Promise<void> | void;
132
+ }
133
+
134
+ /** How a consumer applies SPEC §7.2 item 11 in {@link consumeInbound}. */
135
+ export type ReplayPolicy =
136
+ /** Apply item 11 using this guard. Correct for any consequential spec. */
137
+ | { kind: "guard"; guard: ReplayGuard }
138
+ /**
139
+ * Keep no duplicate-execution record. Conformant **only** where the task is
140
+ * not consequential (§2), or where the specification "explicitly declares
141
+ * repeated execution safe and intended" — a property of the operation, not
142
+ * of the consumer's convenience.
143
+ */
144
+ | { kind: "notConsequential" };
145
+
146
+ interface Entry {
147
+ digest: string;
148
+ retainUntil: number | undefined;
149
+ response: unknown;
150
+ completed: boolean;
151
+ }
152
+
153
+ /**
154
+ * A bounded, in-process {@link ReplayGuard}: an LRU map from `id` to the
155
+ * digest accepted under it, its retention deadline, and the response it
156
+ * produced.
157
+ *
158
+ * **Suitable when** one process is the sole consumer for the `recipient` VID
159
+ * it serves and losing the record on restart is acceptable.
160
+ *
161
+ * **Not suitable when** the consumer is replicated: two replicas hold separate
162
+ * maps, so a document accepted by replica A is `fresh` at replica B and the
163
+ * effect happens twice — the exact failure item 11 exists to prevent.
164
+ * Replicated deployments MUST back the guard with a shared store.
165
+ *
166
+ * Eviction is by capacity as well as by `retainUntil`: a burst of distinct
167
+ * documents can push an older record out before its deadline, and a replay
168
+ * arriving after that would be accepted. Size the capacity above the number of
169
+ * distinct documents the widest acceptance window can hold.
170
+ *
171
+ * `Map` preserves insertion order, which is what makes the LRU a delete-then-
172
+ * reinsert rather than a second index.
173
+ */
174
+ export class InMemoryReplayGuard implements ReplayGuard {
175
+ readonly #entries = new Map<string, Entry>();
176
+ readonly #capacity: number;
177
+
178
+ /**
179
+ * @param capacity Maximum records retained. Must be positive: a guard that
180
+ * retains nothing answers `fresh` to everything, which is a silent total
181
+ * defeat of item 11 rather than a visible misconfiguration.
182
+ */
183
+ constructor(capacity = 10_000) {
184
+ if (!Number.isInteger(capacity) || capacity < 1) {
185
+ throw new RangeError("InMemoryReplayGuard capacity must be a positive integer");
186
+ }
187
+ this.#capacity = capacity;
188
+ }
189
+
190
+ /** Number of records currently retained. For tests and metrics. */
191
+ get size(): number {
192
+ return this.#entries.size;
193
+ }
194
+
195
+ /** Drop every record whose `retainUntil` has passed. */
196
+ purgeExpired(now: number): void {
197
+ for (const [id, entry] of this.#entries) {
198
+ if (entry.retainUntil !== undefined && entry.retainUntil <= now) this.#entries.delete(id);
199
+ }
200
+ }
201
+
202
+ claim(id: string, digest: string, retainUntil: number | undefined, now: number): ReplayVerdict {
203
+ const existing = this.#entries.get(id);
204
+
205
+ // An expired record is treated as absent: the consumer would refuse the
206
+ // document under §7.2 item 4 or the acceptance window anyway, so holding
207
+ // the key would only manufacture a permanent `idConflict` for an `id`
208
+ // nobody can use.
209
+ if (existing !== undefined && existing.retainUntil !== undefined && existing.retainUntil <= now) {
210
+ this.#entries.delete(id);
211
+ } else if (existing !== undefined) {
212
+ if (existing.digest !== digest) {
213
+ // A conflicting document is not a *use* of the record, so it does not
214
+ // refresh recency — otherwise a flood of conflicts could pin an entry
215
+ // and evict live ones.
216
+ return { kind: "conflict" };
217
+ }
218
+ this.#entries.delete(id);
219
+ this.#entries.set(id, existing);
220
+ return existing.response === undefined
221
+ ? { kind: "duplicate", inFlight: !existing.completed }
222
+ : { kind: "duplicate", priorResponse: existing.response, inFlight: !existing.completed };
223
+ }
224
+
225
+ this.#entries.set(id, { digest, retainUntil, response: undefined, completed: false });
226
+ while (this.#entries.size > this.#capacity) {
227
+ const oldest = this.#entries.keys().next();
228
+ if (oldest.done === true) break;
229
+ this.#entries.delete(oldest.value);
230
+ }
231
+ return { kind: "fresh" };
232
+ }
233
+
234
+ recordResponse(id: string, response: unknown): void {
235
+ const entry = this.#entries.get(id);
236
+ if (entry === undefined) return;
237
+ entry.response = response;
238
+ entry.completed = true;
239
+ }
240
+
241
+ release(id: string, digest: string): void {
242
+ const entry = this.#entries.get(id);
243
+ // Only release the claim this digest made, and only while it is
244
+ // unfinished: a concurrent arrival that legitimately holds the key must
245
+ // not have it taken away by another document's cleanup.
246
+ if (entry !== undefined && entry.digest === digest && !entry.completed) {
247
+ this.#entries.delete(id);
248
+ }
249
+ }
250
+ }
@@ -16,16 +16,22 @@ export type KeyType1 = "ed25519" | "x25519" | "p256";
16
16
  */
17
17
  export type KeyStatus = "active" | "revoked";
18
18
  /**
19
- * Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.
19
+ * Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.
20
20
  */
21
- export type KeyOrigin = "derived" | "imported";
21
+ export type KeyOrigin = "derived" | "imported" | "internal";
22
22
 
23
23
  export interface KeysCreatePayload {
24
24
  keyType: KeyType;
25
25
  /**
26
- * Hierarchical-deterministic path to derive at. Where the custodian derives from a seed, supplying the path makes the key reproducible from that seed; omitting it leaves the choice to the custodian.
26
+ * Hierarchical-deterministic path to derive at. Where the custodian derives from a seed, supplying the path makes the key reproducible from that seed; omitting it leaves the choice to the custodian. MUST NOT be combined with `internal: true`, which derives from no seed and records no path — a request carrying both is contradictory and the maintainer SHOULD reject it.
27
27
  */
28
28
  derivationPath?: string;
29
+ /**
30
+ * Absent is the same as `false`, and this member deliberately declares no JSON Schema `default`: a declared default is materialised by generated bindings, so an absent `internal` would reappear as an explicit `false` on re-serialisation and break round-trip idempotence for every existing request document. Request a key generated from the maintainer's CSPRNG rather than derived from a seed. Such a key is reproducible from nothing: it is not recoverable from a recovery phrase, and a maintainer offering it SHOULD exclude it from backup and export. A consumer asks for this when the key's value lies in being unexportable — the maintainer can sign with it and nothing can take it away — and accepts that losing the maintainer's storage destroys it permanently.
31
+ *
32
+ * A maintainer that cannot mint such a key MUST reject the request rather than silently return a derived one, because the consumer's whole reason for asking is a property the derived key does not have. Consumers MUST confirm the outcome by reading `origin` on the returned record, which is `internal` iff the request was honoured; a maintainer that ignored an unrecognised member returns `derived`, and that difference is the consumer's only reliable signal.
33
+ */
34
+ internal?: boolean;
29
35
  /**
30
36
  * BIP-39 phrase to derive from instead of the custodian's own seed. Supplying it makes this an import of externally-generated seed material wearing create's clothes: the phrase reconstitutes the key anywhere, so it is secret-bearing in exactly the way the rest of this payload is not. A custodian MUST refuse it on any transport that is not end-to-end confidential, for the reason `keys/import` refuses its cleartext carrier, and MUST NOT log or echo it.
31
37
  */
@@ -138,7 +144,11 @@ export const PAYLOAD_SCHEMA = {
138
144
  },
139
145
  "derivationPath": {
140
146
  "type": "string",
141
- "description": "Hierarchical-deterministic path to derive at. Where the custodian derives from a seed, supplying the path makes the key reproducible from that seed; omitting it leaves the choice to the custodian."
147
+ "description": "Hierarchical-deterministic path to derive at. Where the custodian derives from a seed, supplying the path makes the key reproducible from that seed; omitting it leaves the choice to the custodian. MUST NOT be combined with `internal: true`, which derives from no seed and records no path — a request carrying both is contradictory and the maintainer SHOULD reject it."
148
+ },
149
+ "internal": {
150
+ "type": "boolean",
151
+ "description": "Absent is the same as `false`, and this member deliberately declares no JSON Schema `default`: a declared default is materialised by generated bindings, so an absent `internal` would reappear as an explicit `false` on re-serialisation and break round-trip idempotence for every existing request document. Request a key generated from the maintainer's CSPRNG rather than derived from a seed. Such a key is reproducible from nothing: it is not recoverable from a recovery phrase, and a maintainer offering it SHOULD exclude it from backup and export. A consumer asks for this when the key's value lies in being unexportable — the maintainer can sign with it and nothing can take it away — and accepts that losing the maintainer's storage destroys it permanently.\n\nA maintainer that cannot mint such a key MUST reject the request rather than silently return a derived one, because the consumer's whole reason for asking is a property the derived key does not have. Consumers MUST confirm the outcome by reading `origin` on the returned record, which is `internal` iff the request was honoured; a maintainer that ignored an unrecognised member returns `derived`, and that difference is the consumer's only reliable signal."
142
152
  },
143
153
  "mnemonic": {
144
154
  "type": "string",
@@ -255,9 +265,10 @@ export const PAYLOAD_SCHEMA = {
255
265
  "type": "string",
256
266
  "enum": [
257
267
  "derived",
258
- "imported"
268
+ "imported",
269
+ "internal"
259
270
  ],
260
- "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.",
271
+ "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.",
261
272
  "default": "derived"
262
273
  },
263
274
  "KeyStatus": {
@@ -384,9 +395,10 @@ export const RESPONSE_PAYLOAD_SCHEMA = {
384
395
  "type": "string",
385
396
  "enum": [
386
397
  "derived",
387
- "imported"
398
+ "imported",
399
+ "internal"
388
400
  ],
389
- "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.",
401
+ "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.",
390
402
  "default": "derived"
391
403
  },
392
404
  "KeyStatus": {
@@ -45,9 +45,9 @@ export type KeyType1 = "ed25519" | "x25519" | "p256";
45
45
  */
46
46
  export type KeyStatus = "active" | "revoked";
47
47
  /**
48
- * Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.
48
+ * Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.
49
49
  */
50
- export type KeyOrigin = "derived" | "imported";
50
+ export type KeyOrigin = "derived" | "imported" | "internal";
51
51
 
52
52
  /**
53
53
  * Ecosystem-defined extension members per SPEC.md §4.5.1.
@@ -286,9 +286,10 @@ export const PAYLOAD_SCHEMA = {
286
286
  "type": "string",
287
287
  "enum": [
288
288
  "derived",
289
- "imported"
289
+ "imported",
290
+ "internal"
290
291
  ],
291
- "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.",
292
+ "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.",
292
293
  "default": "derived"
293
294
  },
294
295
  "KeyStatus": {
@@ -415,9 +416,10 @@ export const RESPONSE_PAYLOAD_SCHEMA = {
415
416
  "type": "string",
416
417
  "enum": [
417
418
  "derived",
418
- "imported"
419
+ "imported",
420
+ "internal"
419
421
  ],
420
- "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.",
422
+ "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.",
421
423
  "default": "derived"
422
424
  },
423
425
  "KeyStatus": {
@@ -16,9 +16,9 @@ export type KeyType = "ed25519" | "x25519" | "p256";
16
16
  */
17
17
  export type KeyStatus1 = "active" | "revoked";
18
18
  /**
19
- * Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.
19
+ * Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.
20
20
  */
21
- export type KeyOrigin = "derived" | "imported";
21
+ export type KeyOrigin = "derived" | "imported" | "internal";
22
22
 
23
23
  export interface KeysListPayload {
24
24
  status?: KeyStatus;
@@ -279,9 +279,10 @@ export const PAYLOAD_SCHEMA = {
279
279
  "type": "string",
280
280
  "enum": [
281
281
  "derived",
282
- "imported"
282
+ "imported",
283
+ "internal"
283
284
  ],
284
- "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.",
285
+ "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.",
285
286
  "default": "derived"
286
287
  },
287
288
  "KeyStatus": {
@@ -429,9 +430,10 @@ export const RESPONSE_PAYLOAD_SCHEMA = {
429
430
  "type": "string",
430
431
  "enum": [
431
432
  "derived",
432
- "imported"
433
+ "imported",
434
+ "internal"
433
435
  ],
434
- "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.",
436
+ "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.",
435
437
  "default": "derived"
436
438
  },
437
439
  "KeyStatus": {
@@ -12,9 +12,9 @@ export type KeyType = "ed25519" | "x25519" | "p256";
12
12
  */
13
13
  export type KeyStatus = "active" | "revoked";
14
14
  /**
15
- * Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.
15
+ * Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.
16
16
  */
17
- export type KeyOrigin = "derived" | "imported";
17
+ export type KeyOrigin = "derived" | "imported" | "internal";
18
18
 
19
19
  export interface KeysShowPayload {
20
20
  /**
@@ -230,9 +230,10 @@ export const PAYLOAD_SCHEMA = {
230
230
  "type": "string",
231
231
  "enum": [
232
232
  "derived",
233
- "imported"
233
+ "imported",
234
+ "internal"
234
235
  ],
235
- "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.",
236
+ "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.",
236
237
  "default": "derived"
237
238
  },
238
239
  "KeyStatus": {
@@ -366,9 +367,10 @@ export const RESPONSE_PAYLOAD_SCHEMA = {
366
367
  "type": "string",
367
368
  "enum": [
368
369
  "derived",
369
- "imported"
370
+ "imported",
371
+ "internal"
370
372
  ],
371
- "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately.",
373
+ "description": "Where the private key came from. `derived` means the maintainer generated it from a seed it holds and can reproduce it from `derivationPath`; `imported` means it arrived from outside and exists only as stored material; `internal` means the maintainer generated it from a CSPRNG and it is reproducible from nothing at all. The distinction is operationally load-bearing: a `derived` key survives a seed restore, an `imported` one is lost unless it was backed up separately, and an `internal` one cannot be recovered by any means once the maintainer's storage is gone. This member is also the only way a consumer can confirm that a `keys/create` request for an `internal` key was honoured rather than silently downgraded to a derived one — see that specification's `internal` member.",
372
374
  "default": "derived"
373
375
  },
374
376
  "KeyStatus": {