@substrat-run/contracts 0.209.0 → 0.211.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.
@@ -1,6 +1,29 @@
1
1
  import { type ScopeStoreKeyProblem } from './scope-store-envelope.js';
2
- export declare const WIRE_ENVELOPE_VERSION = 1;
3
- /** The first line of every wire envelope: the protocol and its version. */
2
+ /** Every envelope version a verifier of this module accepts. */
3
+ export declare const WIRE_ENVELOPE_VERSIONS: readonly [1, 2];
4
+ export type WireEnvelopeVersion = (typeof WIRE_ENVELOPE_VERSIONS)[number];
5
+ /**
6
+ * The newest envelope version this module verifies: what an entry built from it records that it
7
+ * verifies (the capability record's `envelope`). Such an entry accepts every version in
8
+ * {@link WIRE_ENVELOPE_VERSIONS}.
9
+ */
10
+ export declare const WIRE_ENVELOPE_VERSION = 2;
11
+ /**
12
+ * The version a signer sends when it is not told: version 1, until every verifier the fleet runs
13
+ * knows version 2 and the signers switch (K-66, #3373).
14
+ */
15
+ export declare const WIRE_SIGNED_VERSION_DEFAULT = 1;
16
+ /**
17
+ * Each version's first line, spelled out: an entry that can parse version 2 carries its tag as text,
18
+ * which is how the fleet walk tells, from a script's own modules, which versions its entry verifies.
19
+ */
20
+ declare const TAGS: Readonly<{
21
+ readonly 1: 'substrat-wire/1';
22
+ readonly 2: 'substrat-wire/2';
23
+ }>;
24
+ /** The first line of an envelope of version `v`: the protocol and its version. */
25
+ export declare const wireEnvelopeTag: <V extends WireEnvelopeVersion>(v: V) => (typeof TAGS)[V];
26
+ /** The first line of a version 1 envelope. */
4
27
  export declare const WIRE_ENVELOPE_TAG: "substrat-wire/1";
5
28
  /** The request header carrying base64url of the canonical bytes. */
6
29
  export declare const WIRE_ENVELOPE_HEADER = "x-substrat-wire-envelope";
@@ -23,11 +46,38 @@ export interface WireEnvelopeShape {
23
46
  readonly vertical: WireFieldPresence;
24
47
  readonly body: WireFieldPresence;
25
48
  }
26
- /** What an (iss, kind) pair carries, or undefined when version 1 does not admit the pair. */
49
+ /** What an (iss, kind) pair carries, or undefined when the envelope does not admit the pair. Both versions admit the same pairs. */
27
50
  export declare function wireEnvelopeShape(iss: string, kind: string): WireEnvelopeShape | undefined;
51
+ /**
52
+ * Who a version 2 call acts for (K-66): the calling app as itself, the platform, or a person whose
53
+ * token the issuer minted for this target (`onBehalf`), bound by the token's SHA-256.
54
+ */
55
+ export type WireActor = 'app' | 'platform' | `person:${string}`;
56
+ /** The person actor that binds `token`: `person:` and the SHA-256 hex of its UTF-8. */
57
+ export declare function wirePersonActor(token: string): Promise<WireActor>;
58
+ /**
59
+ * Version 2's caller lines for one envelope (K-66's closed table), as one of the rows an (iss, kind)
60
+ * pair may carry:
61
+ *
62
+ * - `none`: no caller and no actor (a route).
63
+ * - `platform`: no caller, and the actor `platform` (a call the control plane signs, or one the
64
+ * router makes for the platform: a connector call or probe).
65
+ * - `peer`: the calling app and scope, and the actor `app` or a person (a peer invocation).
66
+ */
67
+ export type WireCallerShape = 'none' | 'platform' | 'peer';
68
+ /**
69
+ * The rows version 2 admits for an (iss, kind) pair. The router's call admits two, told apart by
70
+ * the target endpoint ({@link wireCallerShapeOf}), which the verifier checks against the target.
71
+ */
72
+ export declare function wireCallerShape(iss: string, kind: string): readonly WireCallerShape[];
73
+ /**
74
+ * The row the router's call to `target` (a pathname, with or without its search) must carry: `peer`
75
+ * at the peer invocation, `platform` at every other endpoint the router calls.
76
+ */
77
+ export declare function wireCallerShapeOf(iss: WireIssuer, kind: WireKind, target: string): WireCallerShape;
28
78
  /** One envelope's fields. An absent field is `null`, never an empty string. */
29
79
  export interface WireClaims {
30
- readonly v: 1;
80
+ readonly v: WireEnvelopeVersion;
31
81
  readonly iss: WireIssuer;
32
82
  readonly kind: WireKind;
33
83
  readonly kid: string;
@@ -36,6 +86,12 @@ export interface WireClaims {
36
86
  readonly scopeId: string | null;
37
87
  readonly surface: string | null;
38
88
  readonly vertical: string | null;
89
+ /** Version 2: the calling app's slug, on a peer invocation. Always null on version 1. */
90
+ readonly callerApp: string | null;
91
+ /** Version 2: the calling scope's id, on a peer invocation. Always null on version 1. */
92
+ readonly callerScope: string | null;
93
+ /** Version 2: who the call acts for, on every call. Always null on a route and on version 1. */
94
+ readonly actor: WireActor | null;
39
95
  readonly method: string;
40
96
  readonly targetDigest: string;
41
97
  readonly bodyDigest: string | null;
@@ -62,7 +118,10 @@ export declare function decodeWireEnvelope(header: string): {
62
118
  export declare class WireClaimsError extends Error {
63
119
  readonly name = "WireClaimsError";
64
120
  }
65
- /** Fifteen lines, no trailing newline. Throws {@link WireClaimsError} on a field the parser would refuse. */
121
+ /**
122
+ * Fifteen lines (version 1) or eighteen (version 2), no trailing newline. Throws
123
+ * {@link WireClaimsError} on a field the parser would refuse, and on caller lines on version 1.
124
+ */
66
125
  export declare function canonicalWireEnvelope(claims: WireClaims): string;
67
126
  /** A body or a target, as the bytes a digest is taken over. A string is its UTF-8. */
68
127
  export type WireBytes = string | ArrayBuffer | ArrayBufferView;
@@ -102,6 +161,8 @@ export interface WireSigningKey {
102
161
  export declare function importWireSigningKey(pkcs8: string): Promise<WireSigningKey>;
103
162
  /** What a signer is told. Absent optional fields are omitted or `null`. */
104
163
  export interface WireEnvelopeInput {
164
+ /** Defaults to {@link WIRE_SIGNED_VERSION_DEFAULT}, version 1. */
165
+ readonly v?: WireEnvelopeVersion;
105
166
  readonly iss: WireIssuer;
106
167
  readonly kind: WireKind;
107
168
  readonly aud: string;
@@ -109,6 +170,13 @@ export interface WireEnvelopeInput {
109
170
  readonly scopeId?: string | null;
110
171
  readonly surface?: string | null;
111
172
  readonly vertical?: string | null;
173
+ /**
174
+ * Version 2 only (K-66): the caller as the dispatch knows it, never as the caller's request says,
175
+ * and who the call acts for. A row version 2's table does not admit is refused by the encoder.
176
+ */
177
+ readonly callerApp?: string | null;
178
+ readonly callerScope?: string | null;
179
+ readonly actor?: WireActor | null;
112
180
  /** From {@link wireRequestBinding} over the request being sent. */
113
181
  readonly method: string;
114
182
  readonly target: string;
@@ -202,7 +270,7 @@ export type WireExpectation = WireExpectationOf<'route'> | (WireExpectationOf<'c
202
270
  readonly replay: WireReplayPolicy;
203
271
  });
204
272
  /** Why an envelope was refused, in the order the verifier checks. For metrics only. */
205
- export declare const WIRE_REFUSAL_REASONS: readonly ['missing', 'malformed', 'issuer', 'kind', 'kid', 'signature', 'audience', 'lifetime', 'not-yet-valid', 'expired', 'method', 'target', 'body', 'scope', 'claim-after-until', 'replay'];
273
+ export declare const WIRE_REFUSAL_REASONS: readonly ['missing', 'malformed', 'issuer', 'kind', 'kid', 'signature', 'audience', 'lifetime', 'not-yet-valid', 'expired', 'method', 'target', 'caller', 'body', 'scope', 'claim-after-until', 'replay'];
206
274
  export type WireRefusalReason = (typeof WIRE_REFUSAL_REASONS)[number];
207
275
  export interface WireAccepted {
208
276
  readonly ok: true;
@@ -215,9 +283,10 @@ export interface WireRefused {
215
283
  export declare const WIRE_REFUSED: WireRefused;
216
284
  export type WireVerdict = WireAccepted | WireRefused;
217
285
  /**
218
- * Every check a deployment makes on an envelope, in one fixed order: present, well-formed, the
219
- * expected issuer and kind, a listed key id, the signature, then (all over signed bytes) the
220
- * audience, the lifetime, the clock, the method, the target, a call's body, any pinned tenant
286
+ * Every check a deployment makes on an envelope of either version, in one fixed order: present,
287
+ * well-formed, the expected issuer and kind, a listed key id, the signature, then (all over signed
288
+ * bytes) the audience, the lifetime, the clock, the method, the target, version 2's caller row for
289
+ * that target, a call's body, any pinned tenant
221
290
  * and scope, and last a call's nonce when its policy keeps them, so an envelope that fails anything
222
291
  * else never spends a cache entry. A route keeps no nonces. `nowSeconds` is the time the request
223
292
  * arrived, not when its body finished reading.
@@ -250,6 +319,29 @@ export declare function verifyWireEnvelope(input: {
250
319
  /** Whatever it returns is ignored; a promise it returns is awaited by nobody and its rejection caught. */
251
320
  readonly onRefusal?: (reason: WireRefusalReason) => unknown;
252
321
  }): Promise<WireVerdict>;
322
+ /**
323
+ * What a verified version 2 call says about who made it and for whom (K-66): the calling app and
324
+ * scope on a peer invocation (null otherwise), and the actor, which every version 2 call carries.
325
+ */
326
+ export interface WireVerifiedCaller {
327
+ readonly iss: WireIssuer;
328
+ readonly callerApp: string | null;
329
+ readonly callerScope: string | null;
330
+ readonly actor: WireActor;
331
+ }
332
+ /**
333
+ * The entry's half: record what a version 2 call's verified envelope says, on the request it hands
334
+ * the vertical. Only the platform entry calls it, with claims {@link verifyWireEnvelope} accepted. A
335
+ * route and a version 1 envelope carry no caller, so nothing is recorded for them.
336
+ */
337
+ export declare function recordWireVerifiedCaller(request: Request, claims: WireClaims): void;
338
+ /**
339
+ * The receiver's half: what the platform entry verified about the caller of `request`, or null when
340
+ * it verified no version 2 envelope on it (a version 1 envelope, the shared credential alone, a
341
+ * deployment with no entry, a route). A check that needs the caller or the actor refuses on null; it
342
+ * never falls back to a header or a body field (K-66).
343
+ */
344
+ export declare function wireVerifiedCallerOf(request: Request): WireVerifiedCaller | null;
253
345
  /** The router's public keys, a comma-separated list. Plain configuration: public keys are not secret. */
254
346
  export declare const WIRE_ROUTER_KEYS_VAR = "SUBSTRAT_WIRE_ROUTER_KEYS";
255
347
  /** The control plane's public keys, a comma-separated list. */
@@ -376,6 +468,11 @@ export interface WireVerificationLine {
376
468
  readonly scopeId: string | null;
377
469
  /** The platform's `SUBSTRAT_VERSION_ID`, as on the invocation line. */
378
470
  readonly versionId: string | null;
471
+ /**
472
+ * The envelope version verified (K-66), so the switch to version 2 and the end of version 1 can be
473
+ * watched; null when no envelope was verified. Absent from a line an entry wrote before version 2.
474
+ */
475
+ readonly envelope?: WireEnvelopeVersion | null;
379
476
  }
380
477
  /**
381
478
  * Whether a signer's `sign` flag (RFC §5) is on: exactly `on`, around whitespace. Absent, empty or
@@ -1 +1 @@
1
- {"version":3,"file":"wire-signing.d.ts","sourceRoot":"","sources":["../src/wire-signing.ts"],"names":[],"mappings":"AAiDA,OAAO,EAQL,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAEnC,eAAO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B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AAEH,eAAO,MAAM,oBAAoB,EAAE,SAAS,iBAAiB,EAO3D,CAAC;AAEH,0GAA0G;AAC1G,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEnG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE;IAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAOpI"}
@@ -37,6 +37,25 @@
37
37
  * first line names the protocol, so no message signed under another protocol (a store
38
38
  * envelope's first line is `1`) parses as one of these, whatever key signed it.
39
39
  *
40
+ * **Version 2 (K-66)** is `substrat-wire/2` and three more lines after `<vertical>`, eighteen in
41
+ * all. The other fifteen keep their meaning, order and rules, and neither version parses as the
42
+ * other:
43
+ *
44
+ * ```
45
+ * <caller app> the calling app's slug, or empty
46
+ * <caller scope> the calling scope's id (a ULID), or empty
47
+ * <actor> app | platform | person:<sha256 hex of the onBehalf token>, or empty
48
+ * ```
49
+ *
50
+ * Which of them an envelope carries is version 2's closed table ({@link wireCallerShape}), with
51
+ * one row the parser cannot judge alone: the router's call carries a caller (and acts as `app`
52
+ * or a person) on a peer invocation, and none (acting as `platform`) on a call it makes for the
53
+ * platform. The two are told apart by the target endpoint, so the verifier checks that row against
54
+ * the target it was given, as `caller`. A verifier accepts both versions; a signer sends version 1
55
+ * unless told otherwise, until the signers switch (#3373). A receiver reads the caller and the actor
56
+ * only from a version 2 envelope it verified ({@link wireVerifiedCallerOf}), never from a header or
57
+ * a body.
58
+ *
40
59
  * Every refusal of a caller is the same value, {@link WIRE_REFUSED}: a caller cannot tell a wrong
41
60
  * audience from a bad signature, and neither can whoever it answers. The reason goes to
42
61
  * `onRefusal`, for metrics only. A fault of the deployment's own throws instead: a key set it
@@ -48,9 +67,28 @@
48
67
  */
49
68
  import { FIELD_COVERAGE_HEADER, PARENT_REQUEST_ID_HEADER, parentRequestIdOf } from './invocation-record.js';
50
69
  import { base64UrlToBytes, bytesToBase64Url, parseScopeStorePublicKeys, ScopeStoreKeyError, scopeStoreKeyId, scopeStoreSignerPublicKey, verifyScopeStoreEnvelope, } from './scope-store-envelope.js';
51
- export const WIRE_ENVELOPE_VERSION = 1;
52
- /** The first line of every wire envelope: the protocol and its version. */
53
- export const WIRE_ENVELOPE_TAG = `substrat-wire/${WIRE_ENVELOPE_VERSION}`;
70
+ /** Every envelope version a verifier of this module accepts. */
71
+ export const WIRE_ENVELOPE_VERSIONS = Object.freeze([1, 2]);
72
+ /**
73
+ * The newest envelope version this module verifies: what an entry built from it records that it
74
+ * verifies (the capability record's `envelope`). Such an entry accepts every version in
75
+ * {@link WIRE_ENVELOPE_VERSIONS}.
76
+ */
77
+ export const WIRE_ENVELOPE_VERSION = 2;
78
+ /**
79
+ * The version a signer sends when it is not told: version 1, until every verifier the fleet runs
80
+ * knows version 2 and the signers switch (K-66, #3373).
81
+ */
82
+ export const WIRE_SIGNED_VERSION_DEFAULT = 1;
83
+ /**
84
+ * Each version's first line, spelled out: an entry that can parse version 2 carries its tag as text,
85
+ * which is how the fleet walk tells, from a script's own modules, which versions its entry verifies.
86
+ */
87
+ const TAGS = Object.freeze({ 1: 'substrat-wire/1', 2: 'substrat-wire/2' });
88
+ /** The first line of an envelope of version `v`: the protocol and its version. */
89
+ export const wireEnvelopeTag = (v) => TAGS[v];
90
+ /** The first line of a version 1 envelope. */
91
+ export const WIRE_ENVELOPE_TAG = wireEnvelopeTag(1);
54
92
  /** The request header carrying base64url of the canonical bytes. */
55
93
  export const WIRE_ENVELOPE_HEADER = 'x-substrat-wire-envelope';
56
94
  /** The request header carrying the base64url signature. */
@@ -78,12 +116,60 @@ const SHAPES = {
78
116
  call: { scope: 'optional', surface: 'absent', vertical: 'absent', body: 'required' },
79
117
  },
80
118
  };
81
- /** What an (iss, kind) pair carries, or undefined when version 1 does not admit the pair. */
119
+ /** What an (iss, kind) pair carries, or undefined when the envelope does not admit the pair. Both versions admit the same pairs. */
82
120
  export function wireEnvelopeShape(iss, kind) {
83
121
  const byKind = Object.hasOwn(SHAPES, iss) ? SHAPES[iss] : undefined;
84
122
  return byKind && Object.hasOwn(byKind, kind) ? byKind[kind] : undefined;
85
123
  }
86
- const LINES = 15;
124
+ /** The person actor that binds `token`: `person:` and the SHA-256 hex of its UTF-8. */
125
+ export async function wirePersonActor(token) {
126
+ return `person:${await wireDigest(token)}`;
127
+ }
128
+ /** The actor grammar, in one place: `app`, `platform`, or `person:` and 64 lowercase hex. */
129
+ const isWireActor = (value) => value === 'app' || value === 'platform' || /^person:[0-9a-f]{64}$/.test(value);
130
+ /**
131
+ * The rows version 2 admits for an (iss, kind) pair. The router's call admits two, told apart by
132
+ * the target endpoint ({@link wireCallerShapeOf}), which the verifier checks against the target.
133
+ */
134
+ export function wireCallerShape(iss, kind) {
135
+ if (iss === 'router' && kind === 'route')
136
+ return ['none'];
137
+ if (iss === 'router' && kind === 'call')
138
+ return ['peer', 'platform'];
139
+ if (iss === 'platform' && kind === 'call')
140
+ return ['platform'];
141
+ return [];
142
+ }
143
+ /** Which row a version 2 envelope's caller lines are, or undefined when they are no row. */
144
+ function callerRowOf(callerApp, callerScope, actor) {
145
+ if (callerApp === '' && callerScope === '' && actor === '')
146
+ return 'none';
147
+ if (callerApp === '' && callerScope === '' && actor === 'platform')
148
+ return 'platform';
149
+ if (isText(callerApp) && callerApp !== '' && ULID.test(callerScope) && isWireActor(actor) && actor !== 'platform')
150
+ return 'peer';
151
+ return undefined;
152
+ }
153
+ /** The row a version 2 envelope's claims carry. */
154
+ const callerRowOfClaims = (claims) => callerRowOf(claims.callerApp ?? '', claims.callerScope ?? '', claims.actor ?? '');
155
+ /** The peer invocation's path: the one target at which the router's call names its caller. */
156
+ const PEER_INVOCATION_PATH = '/internal/vertical-invoke';
157
+ /**
158
+ * The row the router's call to `target` (a pathname, with or without its search) must carry: `peer`
159
+ * at the peer invocation, `platform` at every other endpoint the router calls.
160
+ */
161
+ export function wireCallerShapeOf(iss, kind, target) {
162
+ if (kind === 'route')
163
+ return 'none';
164
+ if (iss === 'platform')
165
+ return 'platform';
166
+ const pathname = target.split('?', 1)[0];
167
+ return pathname === PEER_INVOCATION_PATH ? 'peer' : 'platform';
168
+ }
169
+ /** How many lines each version's encoding has. */
170
+ const LINES = Object.freeze({ 1: 15, 2: 18 });
171
+ /** Version 2's three caller lines sit after the ninth line, `<vertical>`. */
172
+ const CALLER_AT = 9;
87
173
  /** The ULID grammar the router asserts and vertical-host's `ROUTED_ID` reads. */
88
174
  const ULID = /^[0-9A-HJKMNP-TV-Z]{26}$/;
89
175
  /**
@@ -121,15 +207,21 @@ function admits(presence, value, valid) {
121
207
  }
122
208
  /** The claims those bytes name, or undefined when they are not exactly what the encoder emits. */
123
209
  export function parseWireEnvelope(canonical) {
124
- const lines = canonical.split('\n');
125
- if (lines.length !== LINES)
126
- return undefined;
127
- const [tag, iss, kind, kid, aud, tenantId, scopeId, surface, vertical, method, targetDigest, bodyDigest, iat, exp, nonce] = lines;
128
- if (tag !== WIRE_ENVELOPE_TAG)
210
+ const all = canonical.split('\n');
211
+ const v = WIRE_ENVELOPE_VERSIONS.find((version) => all[0] === wireEnvelopeTag(version));
212
+ if (v === undefined || all.length !== LINES[v])
129
213
  return undefined;
214
+ // Version 2's caller lines, taken out so the fifteen shared lines read as version 1's.
215
+ const [callerApp, callerScope, actor] = v === 2 ? all.splice(CALLER_AT, 3) : ['', '', ''];
216
+ const [, iss, kind, kid, aud, tenantId, scopeId, surface, vertical, method, targetDigest, bodyDigest, iat, exp, nonce] = all;
130
217
  const shape = wireEnvelopeShape(iss, kind);
131
218
  if (!shape)
132
219
  return undefined;
220
+ if (v === 2) {
221
+ const row = callerRowOf(callerApp, callerScope, actor);
222
+ if (row === undefined || !wireCallerShape(iss, kind).includes(row))
223
+ return undefined;
224
+ }
133
225
  if (!isCanonicalBase64Url(kid, 8) || !isCanonicalBase64Url(nonce, 16))
134
226
  return undefined;
135
227
  if (!isWireAudience(aud))
@@ -146,7 +238,7 @@ export function parseWireEnvelope(canonical) {
146
238
  return undefined;
147
239
  const orNull = (value) => (value === '' ? null : value);
148
240
  return {
149
- v: 1,
241
+ v,
150
242
  iss: iss,
151
243
  kind: kind,
152
244
  kid,
@@ -155,6 +247,9 @@ export function parseWireEnvelope(canonical) {
155
247
  scopeId: orNull(scopeId),
156
248
  surface: orNull(surface),
157
249
  vertical: orNull(vertical),
250
+ callerApp: orNull(callerApp),
251
+ callerScope: orNull(callerScope),
252
+ actor: orNull(actor),
158
253
  method,
159
254
  targetDigest,
160
255
  bodyDigest: orNull(bodyDigest),
@@ -191,10 +286,17 @@ export function decodeWireEnvelope(header) {
191
286
  export class WireClaimsError extends Error {
192
287
  name = 'WireClaimsError';
193
288
  }
194
- /** Fifteen lines, no trailing newline. Throws {@link WireClaimsError} on a field the parser would refuse. */
289
+ /**
290
+ * Fifteen lines (version 1) or eighteen (version 2), no trailing newline. Throws
291
+ * {@link WireClaimsError} on a field the parser would refuse, and on caller lines on version 1.
292
+ */
195
293
  export function canonicalWireEnvelope(claims) {
196
- if (claims.v !== WIRE_ENVELOPE_VERSION)
197
- throw new WireClaimsError(`unknown wire envelope version ${claims.v}`);
294
+ if (!WIRE_ENVELOPE_VERSIONS.includes(claims.v))
295
+ throw new WireClaimsError(`unknown wire envelope version ${String(claims.v)}`);
296
+ // `!= null`: version 1 has no line to carry them, so naming one there is never silently dropped.
297
+ if (claims.v === 1 && (claims.callerApp != null || claims.callerScope != null || claims.actor != null)) {
298
+ throw new WireClaimsError('a version 1 envelope carries no caller and no actor');
299
+ }
198
300
  for (const time of [claims.iat, claims.exp]) {
199
301
  if (!Number.isSafeInteger(time) || time < 0)
200
302
  throw new WireClaimsError('a wire envelope time is not a non-negative integer');
@@ -205,7 +307,7 @@ export function canonicalWireEnvelope(claims) {
205
307
  return value ?? '';
206
308
  };
207
309
  const lines = [
208
- WIRE_ENVELOPE_TAG,
310
+ wireEnvelopeTag(claims.v),
209
311
  claims.iss,
210
312
  claims.kind,
211
313
  claims.kid,
@@ -214,6 +316,7 @@ export function canonicalWireEnvelope(claims) {
214
316
  optional(claims.scopeId),
215
317
  optional(claims.surface),
216
318
  optional(claims.vertical),
319
+ ...(claims.v === 2 ? [optional(claims.callerApp ?? null), optional(claims.callerScope ?? null), optional(claims.actor ?? null)] : []),
217
320
  claims.method,
218
321
  claims.targetDigest,
219
322
  optional(claims.bodyDigest),
@@ -293,8 +396,9 @@ export async function signWireEnvelope(key, input) {
293
396
  const exp = input.exp ?? iat + WIRE_ENVELOPE_LIFETIME_SECONDS;
294
397
  if (!lifetimeAdmitted(iat, exp))
295
398
  throw new WireClaimsError('a wire envelope lives for at most the maximum lifetime, and ends after it starts');
399
+ const v = input.v ?? WIRE_SIGNED_VERSION_DEFAULT;
296
400
  const claims = {
297
- v: 1,
401
+ v,
298
402
  iss: input.iss,
299
403
  kind: input.kind,
300
404
  kid: key.kid,
@@ -303,6 +407,9 @@ export async function signWireEnvelope(key, input) {
303
407
  scopeId: input.scopeId ?? null,
304
408
  surface: input.surface ?? null,
305
409
  vertical: input.vertical ?? null,
410
+ callerApp: input.callerApp ?? null,
411
+ callerScope: input.callerScope ?? null,
412
+ actor: input.actor ?? null,
306
413
  method: input.method,
307
414
  targetDigest: await wireDigest(input.target),
308
415
  bodyDigest: input.body === undefined ? null : await wireDigest(input.body),
@@ -311,6 +418,11 @@ export async function signWireEnvelope(key, input) {
311
418
  nonce: input.nonce ?? bytesToBase64Url(crypto.getRandomValues(new Uint8Array(16))),
312
419
  };
313
420
  const canonical = canonicalWireEnvelope(claims);
421
+ // The one row the parser cannot judge alone: the router's call names its caller exactly at the peer
422
+ // invocation. A signer that would send the other row is refused here, as the verifier would refuse it.
423
+ if (v === 2 && callerRowOfClaims(claims) !== wireCallerShapeOf(claims.iss, claims.kind, input.target)) {
424
+ throw new WireClaimsError(`a version 2 ${claims.kind} to this target carries the ${wireCallerShapeOf(claims.iss, claims.kind, input.target)} caller row`);
425
+ }
314
426
  const bytes = new TextEncoder().encode(canonical);
315
427
  const signature = await crypto.subtle.sign('Ed25519', key.key, bytes);
316
428
  return { claims, canonical, header: bytesToBase64Url(bytes), signature: bytesToBase64Url(new Uint8Array(signature)) };
@@ -357,6 +469,8 @@ export const WIRE_REFUSAL_REASONS = [
357
469
  'expired',
358
470
  'method',
359
471
  'target',
472
+ // Version 2 only: the caller row the envelope carries is not the one its target takes (K-66).
473
+ 'caller',
360
474
  'body',
361
475
  'scope',
362
476
  'claim-after-until',
@@ -364,9 +478,10 @@ export const WIRE_REFUSAL_REASONS = [
364
478
  ];
365
479
  export const WIRE_REFUSED = Object.freeze({ ok: false });
366
480
  /**
367
- * Every check a deployment makes on an envelope, in one fixed order: present, well-formed, the
368
- * expected issuer and kind, a listed key id, the signature, then (all over signed bytes) the
369
- * audience, the lifetime, the clock, the method, the target, a call's body, any pinned tenant
481
+ * Every check a deployment makes on an envelope of either version, in one fixed order: present,
482
+ * well-formed, the expected issuer and kind, a listed key id, the signature, then (all over signed
483
+ * bytes) the audience, the lifetime, the clock, the method, the target, version 2's caller row for
484
+ * that target, a call's body, any pinned tenant
370
485
  * and scope, and last a call's nonce when its policy keeps them, so an envelope that fails anything
371
486
  * else never spends a cache entry. A route keeps no nonces. `nowSeconds` is the time the request
372
487
  * arrived, not when its body finished reading.
@@ -439,6 +554,10 @@ export async function verifyWireEnvelope(input) {
439
554
  return refuse('method');
440
555
  if (claims.targetDigest !== (await wireDigest(expected.target)))
441
556
  return refuse('target');
557
+ // Over signed bytes, and the target is the one just matched: the router's call names its caller at
558
+ // the peer invocation and nowhere else. Version 1 carries no caller lines to judge.
559
+ if (claims.v === 2 && callerRowOfClaims(claims) !== wireCallerShapeOf(claims.iss, claims.kind, expected.target))
560
+ return refuse('caller');
442
561
  if (expected.kind === 'call') {
443
562
  // A reader is read here and nowhere earlier. The type requires a call's body; an untyped caller
444
563
  // that leaves it out, or hands over the null of a body read that failed, is refused, never read
@@ -469,6 +588,45 @@ export async function verifyWireEnvelope(input) {
469
588
  }
470
589
  return { ok: true, claims };
471
590
  }
591
+ /**
592
+ * Where the entry leaves what it verified, for the vertical's host in the same isolate to read: a
593
+ * map keyed by the very request the entry hands on. A registry symbol, not a module variable, because
594
+ * the entry and the vertical bundle their own copies of this module. Nothing outside the isolate can
595
+ * write it, which is the point: a header or a body field is the caller's word, and K-66 forbids
596
+ * reading the caller or the actor from either. The key names its value's shape: a change to
597
+ * {@link WireVerifiedCaller} that an older reader would misread takes a new key.
598
+ */
599
+ const VERIFIED_CALLERS = Symbol.for('substrat-run/wire-verified-caller/1');
600
+ function verifiedCallers() {
601
+ const holder = globalThis;
602
+ const existing = holder[VERIFIED_CALLERS];
603
+ if (existing instanceof WeakMap)
604
+ return existing;
605
+ if (existing !== undefined)
606
+ return new WeakMap(); // Something else under the key: read nothing, record nowhere shared.
607
+ const created = new WeakMap();
608
+ Object.defineProperty(globalThis, VERIFIED_CALLERS, { value: created, enumerable: false, writable: false, configurable: false });
609
+ return created;
610
+ }
611
+ /**
612
+ * The entry's half: record what a version 2 call's verified envelope says, on the request it hands
613
+ * the vertical. Only the platform entry calls it, with claims {@link verifyWireEnvelope} accepted. A
614
+ * route and a version 1 envelope carry no caller, so nothing is recorded for them.
615
+ */
616
+ export function recordWireVerifiedCaller(request, claims) {
617
+ if (claims.v !== 2 || claims.kind !== 'call' || claims.actor === null)
618
+ return;
619
+ verifiedCallers().set(request, Object.freeze({ iss: claims.iss, callerApp: claims.callerApp, callerScope: claims.callerScope, actor: claims.actor }));
620
+ }
621
+ /**
622
+ * The receiver's half: what the platform entry verified about the caller of `request`, or null when
623
+ * it verified no version 2 envelope on it (a version 1 envelope, the shared credential alone, a
624
+ * deployment with no entry, a route). A check that needs the caller or the actor refuses on null; it
625
+ * never falls back to a header or a body field (K-66).
626
+ */
627
+ export function wireVerifiedCallerOf(request) {
628
+ return verifiedCallers().get(request) ?? null;
629
+ }
472
630
  /*
473
631
  * What a deployment is given at upload (RFC §5, §6) and what its entry writes per request (§8).
474
632
  * Named here, beside the envelope, so the entry that reads them and the uploader and readiness