@hediet/linkrpc 0.0.3-next.20261027.1 → 0.0.3-next.20261028.2

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 (66) hide show
  1. package/README.md +1 -0
  2. package/dist/chunks/cryptoProvider-0clBB4cR.js +308 -0
  3. package/dist/chunks/cryptoProvider-0clBB4cR.js.map +1 -0
  4. package/dist/chunks/{hub.interfaces-I-GtB1Ah.js → hub.interfaces-BwJQeVWT.js} +2 -2
  5. package/dist/chunks/{hub.interfaces-I-GtB1Ah.js.map → hub.interfaces-BwJQeVWT.js.map} +1 -1
  6. package/dist/chunks/{hubAccess-bo3stx2g.d.ts → hubAccess-BPQeRMT7.d.ts} +2 -2
  7. package/dist/chunks/{hubAccess-bo3stx2g.d.ts.map → hubAccess-BPQeRMT7.d.ts.map} +1 -1
  8. package/dist/chunks/{hubFacade-ClN2ausU.js → hubFacade-Cd5Nk-7l.js} +2 -2
  9. package/dist/chunks/{hubFacade-ClN2ausU.js.map → hubFacade-Cd5Nk-7l.js.map} +1 -1
  10. package/dist/chunks/{hubFacade-tTbu49Be.d.ts → hubFacade-CwCzQ_jt.d.ts} +2 -2
  11. package/dist/chunks/{hubFacade-tTbu49Be.d.ts.map → hubFacade-CwCzQ_jt.d.ts.map} +1 -1
  12. package/dist/chunks/identity-CR2eVemx.d.ts +232 -0
  13. package/dist/chunks/identity-CR2eVemx.d.ts.map +1 -0
  14. package/dist/chunks/{inspectionHost-BA6ZmC_P.js → inspectionHost-D_TYHZgN.js} +5 -304
  15. package/dist/chunks/inspectionHost-D_TYHZgN.js.map +1 -0
  16. package/dist/chunks/{linkRpcConnection-Dz1FDKh-.js → linkRpcConnection-C--B0EtU.js} +5 -101
  17. package/dist/chunks/linkRpcConnection-C--B0EtU.js.map +1 -0
  18. package/dist/chunks/{linkRpcConnection-Cd_BPueY.d.ts → linkRpcConnection-D2UVcoDo.d.ts} +3 -232
  19. package/dist/chunks/linkRpcConnection-D2UVcoDo.d.ts.map +1 -0
  20. package/dist/chunks/{protocol-CCKuaXeB.d.ts → protocol-46gW3N9s.d.ts} +2 -2
  21. package/dist/chunks/protocol-46gW3N9s.d.ts.map +1 -0
  22. package/dist/chunks/{protocol-CJ_b2cuh.js → protocol-B8VpjTDn.js} +3 -3
  23. package/dist/chunks/{protocol-CJ_b2cuh.js.map → protocol-B8VpjTDn.js.map} +1 -1
  24. package/dist/chunks/{server-B0aZOfD8.d.ts → server-Dxb6O0A6.d.ts} +3 -3
  25. package/dist/chunks/{server-B0aZOfD8.d.ts.map → server-Dxb6O0A6.d.ts.map} +1 -1
  26. package/dist/chunks/signedObject-Bxc0YmLz.js +1955 -0
  27. package/dist/chunks/signedObject-Bxc0YmLz.js.map +1 -0
  28. package/dist/chunks/signedObject-DhA4Ze6E.js +106 -0
  29. package/dist/chunks/signedObject-DhA4Ze6E.js.map +1 -0
  30. package/dist/chunks/{src-BUin-ksi.js → src-BdY35CrA.js} +19 -1945
  31. package/dist/chunks/src-BdY35CrA.js.map +1 -0
  32. package/dist/chunks/{webSocketTransport-Ct4OIdG9.js → webSocketTransport-Boo2KCLq.js} +2 -2
  33. package/dist/chunks/{webSocketTransport-Ct4OIdG9.js.map → webSocketTransport-Boo2KCLq.js.map} +1 -1
  34. package/dist/chunks/{webSocketTransport-BZlwWb8T.d.ts → webSocketTransport-CEp1Ntsd.d.ts} +2 -2
  35. package/dist/chunks/{webSocketTransport-BZlwWb8T.d.ts.map → webSocketTransport-CEp1Ntsd.d.ts.map} +1 -1
  36. package/dist/http/client.d.ts +2 -2
  37. package/dist/http/client.js +3 -3
  38. package/dist/http/server.d.ts +2 -2
  39. package/dist/http/server.js +3 -3
  40. package/dist/hub/client/index.d.ts +4 -3
  41. package/dist/hub/client/index.d.ts.map +1 -1
  42. package/dist/hub/client/index.js +4 -4
  43. package/dist/hub/common/index.d.ts +2 -2
  44. package/dist/hub/common/index.js +4 -3
  45. package/dist/hub/common/index.js.map +1 -1
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.js +6 -3
  48. package/dist/inspection/index.d.ts +1 -1
  49. package/dist/inspection/index.js +1 -1
  50. package/dist/node.d.ts +5 -4
  51. package/dist/node.d.ts.map +1 -1
  52. package/dist/node.js +8 -5
  53. package/dist/node.js.map +1 -1
  54. package/dist/signing.d.ts +34 -0
  55. package/dist/signing.d.ts.map +1 -0
  56. package/dist/signing.js +7 -0
  57. package/dist/web.d.ts +3 -2
  58. package/dist/web.d.ts.map +1 -1
  59. package/dist/web.js +7 -4
  60. package/dist/web.js.map +1 -1
  61. package/package.json +3 -2
  62. package/dist/chunks/inspectionHost-BA6ZmC_P.js.map +0 -1
  63. package/dist/chunks/linkRpcConnection-Cd_BPueY.d.ts.map +0 -1
  64. package/dist/chunks/linkRpcConnection-Dz1FDKh-.js.map +0 -1
  65. package/dist/chunks/protocol-CCKuaXeB.d.ts.map +0 -1
  66. package/dist/chunks/src-BUin-ksi.js.map +0 -1
package/README.md CHANGED
@@ -1001,6 +1001,7 @@ exports so browser bundles never pull in Node built-ins:
1001
1001
  | `@hediet/linkrpc/node` | NDJSON sockets, WebSocket, stdio, `connectToHub`, endpoint-URI parsing |
1002
1002
  | `@hediet/linkrpc/web` | `WindowMessageTransport` (iframe / web worker) |
1003
1003
  | `@hediet/linkrpc/hub/common`, `/hub/client` | hub-facing interfaces and client helpers |
1004
+ | `@hediet/linkrpc/signing` | sign any JSON object with an identity (`signObject`) and verify it against a principal (`verifyObjectByPrincipal`) |
1004
1005
 
1005
1006
  On Node, a single call resolves an endpoint from the environment and dials it:
1006
1007
 
@@ -0,0 +1,308 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ //#region src/protocol/jcs.ts
6
+ /**
7
+ * RFC 8785 JSON Canonicalization Scheme (JCS).
8
+ *
9
+ * Used as the byte-deterministic encoding under every linkrpc signature
10
+ * (RPC calls, capabilities, hub-signed previews). Both signer and verifier
11
+ * canonicalize the same value object and obtain byte-identical UTF-8 bytes.
12
+ *
13
+ * Implementation inlined from the `canonicalize` npm package (Apache-2.0,
14
+ * https://github.com/erdtman/canonicalize) so this module stays
15
+ * zero-dependency for browser bundlers that don't resolve transitive
16
+ * npm specifiers (e.g. the in-house app-bundler).
17
+ */
18
+ /** RFC 8785 canonical JSON string for `value`. */
19
+ function jcsCanonicalize(value) {
20
+ const out = _canonicalize(value);
21
+ if (out === void 0) throw new Error("jcsCanonicalize: value is not JSON-representable");
22
+ return out;
23
+ }
24
+ const _encoder = new TextEncoder();
25
+ /** UTF-8 bytes of the RFC 8785 canonical JSON for `value`. The thing actually signed / hashed. */
26
+ function jcsCanonicalizeBytes(value) {
27
+ return _encoder.encode(jcsCanonicalize(value));
28
+ }
29
+ function _canonicalize(object, seen = /* @__PURE__ */ new Set()) {
30
+ if (typeof object === "number" && Number.isNaN(object)) throw new Error("NaN is not allowed");
31
+ if (typeof object === "number" && !Number.isFinite(object)) throw new Error("Infinity is not allowed");
32
+ if (object === null || typeof object !== "object") return JSON.stringify(object);
33
+ const obj = object;
34
+ if (typeof obj.toJSON === "function") {
35
+ if (seen.has(obj)) throw new Error("Circular reference detected");
36
+ seen.add(obj);
37
+ const result = _canonicalize(obj.toJSON(), seen);
38
+ seen.delete(obj);
39
+ return result;
40
+ }
41
+ if (seen.has(obj)) throw new Error("Circular reference detected");
42
+ seen.add(obj);
43
+ let result;
44
+ if (Array.isArray(obj)) result = `[${obj.map((cv) => {
45
+ return _canonicalize(cv === void 0 || typeof cv === "symbol" ? null : cv, seen);
46
+ }).join(",")}]`;
47
+ else {
48
+ const parts = [];
49
+ for (const key of Object.keys(obj).sort()) {
50
+ const v = obj[key];
51
+ if (v === void 0 || typeof v === "symbol") continue;
52
+ parts.push(`${JSON.stringify(key)}:${_canonicalize(v, seen)}`);
53
+ }
54
+ result = `{${parts.join(",")}}`;
55
+ }
56
+ seen.delete(obj);
57
+ return result;
58
+ }
59
+ //#endregion
60
+ //#region src/crypto/sha256.ts
61
+ /**
62
+ * Pure-JS SHA-256 (RFC 6234 / FIPS 180-4). Synchronous, dependency-free,
63
+ * isomorphic. Used internally by linkrpc for content-hashing interface
64
+ * schemas and deriving identity slot names; also surfaced through the
65
+ * `crypto` API as `crypto.sha256`. For signature work we go through the
66
+ * `crypto` module (`./identity/crypto`).
67
+ *
68
+ * Replaces the previous `@noble/hashes/sha2` import so the bundle has
69
+ * no runtime npm dependencies. Trades the well-vetted dep for ~80 lines
70
+ * of straight-line code that has no branching on input contents and is
71
+ * exercised by the existing test vectors plus `sha256.test.ts`.
72
+ */
73
+ const K = new Uint32Array([
74
+ 1116352408,
75
+ 1899447441,
76
+ 3049323471,
77
+ 3921009573,
78
+ 961987163,
79
+ 1508970993,
80
+ 2453635748,
81
+ 2870763221,
82
+ 3624381080,
83
+ 310598401,
84
+ 607225278,
85
+ 1426881987,
86
+ 1925078388,
87
+ 2162078206,
88
+ 2614888103,
89
+ 3248222580,
90
+ 3835390401,
91
+ 4022224774,
92
+ 264347078,
93
+ 604807628,
94
+ 770255983,
95
+ 1249150122,
96
+ 1555081692,
97
+ 1996064986,
98
+ 2554220882,
99
+ 2821834349,
100
+ 2952996808,
101
+ 3210313671,
102
+ 3336571891,
103
+ 3584528711,
104
+ 113926993,
105
+ 338241895,
106
+ 666307205,
107
+ 773529912,
108
+ 1294757372,
109
+ 1396182291,
110
+ 1695183700,
111
+ 1986661051,
112
+ 2177026350,
113
+ 2456956037,
114
+ 2730485921,
115
+ 2820302411,
116
+ 3259730800,
117
+ 3345764771,
118
+ 3516065817,
119
+ 3600352804,
120
+ 4094571909,
121
+ 275423344,
122
+ 430227734,
123
+ 506948616,
124
+ 659060556,
125
+ 883997877,
126
+ 958139571,
127
+ 1322822218,
128
+ 1537002063,
129
+ 1747873779,
130
+ 1955562222,
131
+ 2024104815,
132
+ 2227730452,
133
+ 2361852424,
134
+ 2428436474,
135
+ 2756734187,
136
+ 3204031479,
137
+ 3329325298
138
+ ]);
139
+ function _rotr(x, n) {
140
+ return x >>> n | x << 32 - n;
141
+ }
142
+ function sha256(data) {
143
+ const inputLen = data.length;
144
+ const bitLen = inputLen * 8;
145
+ const paddedLen = inputLen + 9 + 63 & -64;
146
+ const padded = new Uint8Array(paddedLen);
147
+ padded.set(data);
148
+ padded[inputLen] = 128;
149
+ const view = new DataView(padded.buffer);
150
+ view.setUint32(paddedLen - 8, Math.floor(bitLen / 4294967296), false);
151
+ view.setUint32(paddedLen - 4, bitLen >>> 0, false);
152
+ const H = new Uint32Array([
153
+ 1779033703,
154
+ 3144134277,
155
+ 1013904242,
156
+ 2773480762,
157
+ 1359893119,
158
+ 2600822924,
159
+ 528734635,
160
+ 1541459225
161
+ ]);
162
+ const W = /* @__PURE__ */ new Uint32Array(64);
163
+ for (let block = 0; block < paddedLen; block += 64) {
164
+ for (let t = 0; t < 16; t++) W[t] = view.getUint32(block + t * 4, false);
165
+ for (let t = 16; t < 64; t++) {
166
+ const w15 = W[t - 15];
167
+ const w2 = W[t - 2];
168
+ const s0 = _rotr(w15, 7) ^ _rotr(w15, 18) ^ w15 >>> 3;
169
+ const s1 = _rotr(w2, 17) ^ _rotr(w2, 19) ^ w2 >>> 10;
170
+ W[t] = W[t - 16] + s0 + W[t - 7] + s1 >>> 0;
171
+ }
172
+ let a = H[0], b = H[1], c = H[2], d = H[3];
173
+ let e = H[4], f = H[5], g = H[6], h = H[7];
174
+ for (let t = 0; t < 64; t++) {
175
+ const S1 = _rotr(e, 6) ^ _rotr(e, 11) ^ _rotr(e, 25);
176
+ const ch = e & f ^ ~e & g;
177
+ const temp1 = h + S1 + ch + K[t] + W[t] >>> 0;
178
+ const temp2 = (_rotr(a, 2) ^ _rotr(a, 13) ^ _rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
179
+ h = g;
180
+ g = f;
181
+ f = e;
182
+ e = d + temp1 >>> 0;
183
+ d = c;
184
+ c = b;
185
+ b = a;
186
+ a = temp1 + temp2 >>> 0;
187
+ }
188
+ H[0] = H[0] + a >>> 0;
189
+ H[1] = H[1] + b >>> 0;
190
+ H[2] = H[2] + c >>> 0;
191
+ H[3] = H[3] + d >>> 0;
192
+ H[4] = H[4] + e >>> 0;
193
+ H[5] = H[5] + f >>> 0;
194
+ H[6] = H[6] + g >>> 0;
195
+ H[7] = H[7] + h >>> 0;
196
+ }
197
+ const out = /* @__PURE__ */ new Uint8Array(32);
198
+ const outView = new DataView(out.buffer);
199
+ for (let i = 0; i < 8; i++) outView.setUint32(i * 4, H[i], false);
200
+ return out;
201
+ }
202
+ //#endregion
203
+ //#region src/crypto/cryptoProvider.ts
204
+ const _b64UrlAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
205
+ const _b64UrlReverse = (() => {
206
+ const m = {};
207
+ for (let i = 0; i < 64; i++) m[_b64UrlAlphabet[i]] = i;
208
+ return m;
209
+ })();
210
+ function bytesToBase64Url(bytes) {
211
+ let out = "";
212
+ let i = 0;
213
+ for (; i + 3 <= bytes.length; i += 3) {
214
+ const n = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
215
+ out += _b64UrlAlphabet[n >> 18 & 63] + _b64UrlAlphabet[n >> 12 & 63] + _b64UrlAlphabet[n >> 6 & 63] + _b64UrlAlphabet[n & 63];
216
+ }
217
+ const rem = bytes.length - i;
218
+ if (rem === 1) {
219
+ const n = bytes[i] << 16;
220
+ out += _b64UrlAlphabet[n >> 18 & 63] + _b64UrlAlphabet[n >> 12 & 63];
221
+ } else if (rem === 2) {
222
+ const n = bytes[i] << 16 | bytes[i + 1] << 8;
223
+ out += _b64UrlAlphabet[n >> 18 & 63] + _b64UrlAlphabet[n >> 12 & 63] + _b64UrlAlphabet[n >> 6 & 63];
224
+ }
225
+ return out;
226
+ }
227
+ function base64UrlToBytes(s) {
228
+ const len = s.length;
229
+ const fullGroups = Math.floor(len / 4);
230
+ const rem = len % 4;
231
+ if (rem === 1) throw new Error("base64UrlToBytes: invalid length");
232
+ const outLen = fullGroups * 3 + (rem === 0 ? 0 : rem - 1);
233
+ const out = new Uint8Array(outLen);
234
+ let oi = 0;
235
+ let i = 0;
236
+ for (let g = 0; g < fullGroups; g++, i += 4) {
237
+ const n = _lookup(s, i) << 18 | _lookup(s, i + 1) << 12 | _lookup(s, i + 2) << 6 | _lookup(s, i + 3);
238
+ out[oi++] = n >> 16 & 255;
239
+ out[oi++] = n >> 8 & 255;
240
+ out[oi++] = n & 255;
241
+ }
242
+ if (rem === 2) {
243
+ const n = _lookup(s, i) << 18 | _lookup(s, i + 1) << 12;
244
+ out[oi++] = n >> 16 & 255;
245
+ } else if (rem === 3) {
246
+ const n = _lookup(s, i) << 18 | _lookup(s, i + 1) << 12 | _lookup(s, i + 2) << 6;
247
+ out[oi++] = n >> 16 & 255;
248
+ out[oi++] = n >> 8 & 255;
249
+ }
250
+ return out;
251
+ }
252
+ function _lookup(s, i) {
253
+ const v = _b64UrlReverse[s[i]];
254
+ if (v === void 0) throw new Error(`base64UrlToBytes: invalid char at ${i}`);
255
+ return v;
256
+ }
257
+ /** Role-tag prefix on a {@link KeyId}'s inline-key form. */
258
+ const KEY_ID_PREFIX = "key:";
259
+ /** Role-tag prefix that wraps a genesis {@link KeyId} into a {@link PrincipalId}. */
260
+ const PRINCIPAL_PREFIX = "id:";
261
+ /** The inline {@link KeyId} for a raw public key: `"key:" + b64url(pk)`. */
262
+ function keyIdForPublicKey(pk) {
263
+ return KEY_ID_PREFIX + bytesToBase64Url(pk);
264
+ }
265
+ /** The perpetual {@link PrincipalId} for a raw public key: `"id:key:" + b64url(pk)`. */
266
+ function principalForPublicKey(pk) {
267
+ return "id:" + keyIdForPublicKey(pk);
268
+ }
269
+ /**
270
+ * The genesis {@link KeyId} embedded in a perpetual {@link PrincipalId}
271
+ * (`"id:" + keyId`). Throws if `principal` is not a well-formed `id:` name.
272
+ */
273
+ function keyIdForPrincipal(principal) {
274
+ if (!principal.startsWith("id:")) throw new Error(`malformed principal (missing "id:" prefix): ${principal}`);
275
+ return principal.slice(3);
276
+ }
277
+ /**
278
+ * The raw public key carried inline by a `"key:"` {@link KeyId}. Throws on a
279
+ * missing prefix or malformed base64url.
280
+ */
281
+ function publicKeyForKeyId(keyId) {
282
+ if (!keyId.startsWith("key:")) throw new Error(`unsupported keyId (expected "${KEY_ID_PREFIX}" prefix): ${keyId}`);
283
+ return base64UrlToBytes(keyId.slice(4));
284
+ }
285
+ /**
286
+ * Resolve the verifying public key for `(principal, keyId)`, or `undefined`
287
+ * to **reject** (fail closed). This is the single seam every verifier goes
288
+ * through, replacing the old "the id *is* the key" decode.
289
+ *
290
+ * Phase 1 supports only inline genesis keys: the `keyId` must be a `"key:"`
291
+ * form and the principal must be exactly `"id:" + keyId` (genesis
292
+ * self-certification by string equality). `keydoc:`/rotation forms resolve
293
+ * through `bindings`/`timeMs` later and are intentionally not handled here.
294
+ */
295
+ function resolveSigningKey(args) {
296
+ const { principal, keyId } = args;
297
+ if (!keyId.startsWith("key:")) return;
298
+ if ("id:" + keyId !== principal) return;
299
+ try {
300
+ return { publicKey: base64UrlToBytes(keyId.slice(4)) };
301
+ } catch {
302
+ return;
303
+ }
304
+ }
305
+ //#endregion
306
+ export { keyIdForPrincipal as a, publicKeyForKeyId as c, jcsCanonicalize as d, jcsCanonicalizeBytes as f, bytesToBase64Url as i, resolveSigningKey as l, PRINCIPAL_PREFIX as n, keyIdForPublicKey as o, base64UrlToBytes as r, principalForPublicKey as s, KEY_ID_PREFIX as t, sha256 as u };
307
+
308
+ //# sourceMappingURL=cryptoProvider-0clBB4cR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cryptoProvider-0clBB4cR.js","names":[],"sources":["../../src/protocol/jcs.ts","../../src/crypto/sha256.ts","../../src/crypto/cryptoProvider.ts"],"sourcesContent":["/**\n * RFC 8785 JSON Canonicalization Scheme (JCS).\n *\n * Used as the byte-deterministic encoding under every linkrpc signature\n * (RPC calls, capabilities, hub-signed previews). Both signer and verifier\n * canonicalize the same value object and obtain byte-identical UTF-8 bytes.\n *\n * Implementation inlined from the `canonicalize` npm package (Apache-2.0,\n * https://github.com/erdtman/canonicalize) so this module stays\n * zero-dependency for browser bundlers that don't resolve transitive\n * npm specifiers (e.g. the in-house app-bundler).\n */\n\n\n/** RFC 8785 canonical JSON string for `value`. */\nexport function jcsCanonicalize(value: unknown): string {\n const out = _canonicalize(value);\n if (out === undefined) {\n throw new Error(\"jcsCanonicalize: value is not JSON-representable\");\n }\n return out;\n}\n\nconst _encoder = new TextEncoder();\n\n/** UTF-8 bytes of the RFC 8785 canonical JSON for `value`. The thing actually signed / hashed. */\nexport function jcsCanonicalizeBytes(value: unknown): Uint8Array {\n return _encoder.encode(jcsCanonicalize(value));\n}\n\nfunction _canonicalize(object: unknown, seen: Set<object> = new Set()): string | undefined {\n if (typeof object === \"number\" && Number.isNaN(object)) {\n throw new Error(\"NaN is not allowed\");\n }\n if (typeof object === \"number\" && !Number.isFinite(object)) {\n throw new Error(\"Infinity is not allowed\");\n }\n if (object === null || typeof object !== \"object\") {\n return JSON.stringify(object);\n }\n\n const obj = object as { toJSON?: () => unknown } & Record<string, unknown>;\n\n if (typeof obj.toJSON === \"function\") {\n if (seen.has(obj)) throw new Error(\"Circular reference detected\");\n seen.add(obj);\n const result = _canonicalize(obj.toJSON(), seen);\n seen.delete(obj);\n return result;\n }\n\n if (seen.has(obj)) throw new Error(\"Circular reference detected\");\n seen.add(obj);\n\n let result: string;\n if (Array.isArray(obj)) {\n const values = obj.map((cv) => {\n const value = cv === undefined || typeof cv === \"symbol\" ? null : cv;\n return _canonicalize(value, seen);\n });\n result = `[${values.join(\",\")}]`;\n } else {\n const parts: string[] = [];\n for (const key of Object.keys(obj).sort()) {\n const v = obj[key];\n if (v === undefined || typeof v === \"symbol\") continue;\n parts.push(`${JSON.stringify(key)}:${_canonicalize(v, seen)}`);\n }\n result = `{${parts.join(\",\")}}`;\n }\n\n seen.delete(obj);\n return result;\n}\n","/**\n * Pure-JS SHA-256 (RFC 6234 / FIPS 180-4). Synchronous, dependency-free,\n * isomorphic. Used internally by linkrpc for content-hashing interface\n * schemas and deriving identity slot names; also surfaced through the\n * `crypto` API as `crypto.sha256`. For signature work we go through the\n * `crypto` module (`./identity/crypto`).\n *\n * Replaces the previous `@noble/hashes/sha2` import so the bundle has\n * no runtime npm dependencies. Trades the well-vetted dep for ~80 lines\n * of straight-line code that has no branching on input contents and is\n * exercised by the existing test vectors plus `sha256.test.ts`.\n */\n\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\nfunction _rotr(x: number, n: number): number {\n return (x >>> n) | (x << (32 - n));\n}\n\nexport function sha256(data: Uint8Array): Uint8Array {\n const inputLen = data.length;\n const bitLen = inputLen * 8;\n // Round up to next 64-byte block leaving room for 0x80 marker + 8-byte length.\n const paddedLen = (inputLen + 9 + 63) & ~63;\n const padded = new Uint8Array(paddedLen);\n padded.set(data);\n padded[inputLen] = 0x80;\n\n const view = new DataView(padded.buffer);\n // Big-endian 64-bit bit length. Bottom 32 bits hold values < 2^32 bits = 2^29 bytes (~512 MiB).\n view.setUint32(paddedLen - 8, Math.floor(bitLen / 0x1_0000_0000), false);\n view.setUint32(paddedLen - 4, bitLen >>> 0, false);\n\n const H = new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,\n 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n ]);\n const W = new Uint32Array(64);\n\n for (let block = 0; block < paddedLen; block += 64) {\n for (let t = 0; t < 16; t++) {\n W[t] = view.getUint32(block + t * 4, false);\n }\n for (let t = 16; t < 64; t++) {\n const w15 = W[t - 15];\n const w2 = W[t - 2];\n const s0 = _rotr(w15, 7) ^ _rotr(w15, 18) ^ (w15 >>> 3);\n const s1 = _rotr(w2, 17) ^ _rotr(w2, 19) ^ (w2 >>> 10);\n W[t] = (W[t - 16] + s0 + W[t - 7] + s1) >>> 0;\n }\n\n let a = H[0], b = H[1], c = H[2], d = H[3];\n let e = H[4], f = H[5], g = H[6], h = H[7];\n for (let t = 0; t < 64; t++) {\n const S1 = _rotr(e, 6) ^ _rotr(e, 11) ^ _rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const temp1 = (h + S1 + ch + K[t] + W[t]) >>> 0;\n const S0 = _rotr(a, 2) ^ _rotr(a, 13) ^ _rotr(a, 22);\n const mj = (a & b) ^ (a & c) ^ (b & c);\n const temp2 = (S0 + mj) >>> 0;\n h = g;\n g = f;\n f = e;\n e = (d + temp1) >>> 0;\n d = c;\n c = b;\n b = a;\n a = (temp1 + temp2) >>> 0;\n }\n H[0] = (H[0] + a) >>> 0;\n H[1] = (H[1] + b) >>> 0;\n H[2] = (H[2] + c) >>> 0;\n H[3] = (H[3] + d) >>> 0;\n H[4] = (H[4] + e) >>> 0;\n H[5] = (H[5] + f) >>> 0;\n H[6] = (H[6] + g) >>> 0;\n H[7] = (H[7] + h) >>> 0;\n }\n\n const out = new Uint8Array(32);\n const outView = new DataView(out.buffer);\n for (let i = 0; i < 8; i++) outView.setUint32(i * 4, H[i], false);\n return out;\n}\n","/**\n * Identity primitives. linkrpc itself is identity-agnostic; this module\n * defines the shared types. No crypto code lives here — the crypto API is\n * `./crypto` (backed by the Web Crypto implementation in\n * `./ed25519CryptoProvider`).\n */\n\n/** Raw Ed25519 public key (32 bytes). */\nexport type PublicKey = Uint8Array;\n\n/** Raw Ed25519 private key (32 bytes — seed form). */\nexport type PrivateKey = Uint8Array;\n\n/** Raw Ed25519 signature (64 bytes). */\nexport type Signature = Uint8Array;\n\n/**\n * A **principal**: an identity's stable, opaque name. In Phase 1 every\n * principal is *perpetual* and self-describing — its genesis signing key is\n * embedded verbatim:\n *\n * principal = \"id:\" + keyId (e.g. \"id:key:<b64url(pubKey)>\")\n *\n * So the genesis check is pure string equality (`\"id:\" + keyId === principal`)\n * and no key-binding records are ever needed. Treat as opaque; construct via\n * {@link principalForPublicKey} and resolve a verifying key via\n * {@link resolveSigningKey}.\n */\nexport type PrincipalId = string;\n\n/**\n * A **keyId**: names the signing key that produced a signature. In Phase 1 the\n * only form is an *inline* key — the public key encoded verbatim:\n *\n * keyId = \"key:\" + b64url(pubKey)\n *\n * (Future forms, e.g. `\"keydoc:\" + b64url(sha256(jcs(doc)))`, are resolved\n * through bindings — see the design doc — but Phase 1 needs none.)\n */\nexport type KeyId = string;\n\nexport interface Keypair {\n readonly publicKey: PublicKey;\n readonly privateKey: PrivateKey;\n}\n\n/** Raw X25519 keypair. Both halves are 32 bytes. */\nexport interface X25519Keypair {\n readonly publicKey: Uint8Array;\n readonly privateKey: Uint8Array;\n}\n\n// ---- base64url codec (no padding) ----------------------------------------\n\nconst _b64UrlAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\";\nconst _b64UrlReverse: Record<string, number> = (() => {\n const m: Record<string, number> = {};\n for (let i = 0; i < _b64UrlAlphabet.length; i++) m[_b64UrlAlphabet[i]] = i;\n return m;\n})();\n\nexport function bytesToBase64Url(bytes: Uint8Array): string {\n let out = \"\";\n let i = 0;\n for (; i + 3 <= bytes.length; i += 3) {\n const n = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];\n out += _b64UrlAlphabet[(n >> 18) & 63]\n + _b64UrlAlphabet[(n >> 12) & 63]\n + _b64UrlAlphabet[(n >> 6) & 63]\n + _b64UrlAlphabet[n & 63];\n }\n const rem = bytes.length - i;\n if (rem === 1) {\n const n = bytes[i] << 16;\n out += _b64UrlAlphabet[(n >> 18) & 63] + _b64UrlAlphabet[(n >> 12) & 63];\n } else if (rem === 2) {\n const n = (bytes[i] << 16) | (bytes[i + 1] << 8);\n out += _b64UrlAlphabet[(n >> 18) & 63]\n + _b64UrlAlphabet[(n >> 12) & 63]\n + _b64UrlAlphabet[(n >> 6) & 63];\n }\n return out;\n}\n\nexport function base64UrlToBytes(s: string): Uint8Array {\n const len = s.length;\n const fullGroups = Math.floor(len / 4);\n const rem = len % 4;\n if (rem === 1) throw new Error(\"base64UrlToBytes: invalid length\");\n const outLen = fullGroups * 3 + (rem === 0 ? 0 : rem - 1);\n const out = new Uint8Array(outLen);\n let oi = 0;\n let i = 0;\n for (let g = 0; g < fullGroups; g++, i += 4) {\n const n = (_lookup(s, i) << 18) | (_lookup(s, i + 1) << 12) | (_lookup(s, i + 2) << 6) | _lookup(s, i + 3);\n out[oi++] = (n >> 16) & 0xff;\n out[oi++] = (n >> 8) & 0xff;\n out[oi++] = n & 0xff;\n }\n if (rem === 2) {\n const n = (_lookup(s, i) << 18) | (_lookup(s, i + 1) << 12);\n out[oi++] = (n >> 16) & 0xff;\n } else if (rem === 3) {\n const n = (_lookup(s, i) << 18) | (_lookup(s, i + 1) << 12) | (_lookup(s, i + 2) << 6);\n out[oi++] = (n >> 16) & 0xff;\n out[oi++] = (n >> 8) & 0xff;\n }\n return out;\n}\n\nfunction _lookup(s: string, i: number): number {\n const v = _b64UrlReverse[s[i]];\n if (v === undefined) throw new Error(`base64UrlToBytes: invalid char at ${i}`);\n return v;\n}\n\n// ---- principals & keyIds (the identity ⇄ key seam) -----------------------\n\n/** Role-tag prefix on a {@link KeyId}'s inline-key form. */\nexport const KEY_ID_PREFIX = \"key:\";\n\n/** Role-tag prefix that wraps a genesis {@link KeyId} into a {@link PrincipalId}. */\nexport const PRINCIPAL_PREFIX = \"id:\";\n\n/** The inline {@link KeyId} for a raw public key: `\"key:\" + b64url(pk)`. */\nexport function keyIdForPublicKey(pk: PublicKey): KeyId {\n return KEY_ID_PREFIX + bytesToBase64Url(pk);\n}\n\n/** The perpetual {@link PrincipalId} for a raw public key: `\"id:key:\" + b64url(pk)`. */\nexport function principalForPublicKey(pk: PublicKey): PrincipalId {\n return PRINCIPAL_PREFIX + keyIdForPublicKey(pk);\n}\n\n/**\n * The genesis {@link KeyId} embedded in a perpetual {@link PrincipalId}\n * (`\"id:\" + keyId`). Throws if `principal` is not a well-formed `id:` name.\n */\nexport function keyIdForPrincipal(principal: PrincipalId): KeyId {\n if (!principal.startsWith(PRINCIPAL_PREFIX)) {\n throw new Error(`malformed principal (missing \"${PRINCIPAL_PREFIX}\" prefix): ${principal}`);\n }\n return principal.slice(PRINCIPAL_PREFIX.length);\n}\n\n/**\n * The raw public key carried inline by a `\"key:\"` {@link KeyId}. Throws on a\n * missing prefix or malformed base64url.\n */\nexport function publicKeyForKeyId(keyId: KeyId): PublicKey {\n if (!keyId.startsWith(KEY_ID_PREFIX)) {\n throw new Error(`unsupported keyId (expected \"${KEY_ID_PREFIX}\" prefix): ${keyId}`);\n }\n return base64UrlToBytes(keyId.slice(KEY_ID_PREFIX.length));\n}\n\n/** Arguments to {@link resolveSigningKey}. */\nexport interface ResolveSigningKeyArgs {\n /** The identity the signature claims to be from. */\n readonly principal: PrincipalId;\n /** Which key (per `$hubrpcSignature[domain].keyId`) is claimed to have signed. */\n readonly keyId: KeyId;\n /** Presented key-binding records. Unused in Phase 1 (perpetual ids need none). */\n readonly bindings?: Record<KeyId, unknown>;\n /** Time the signature was made (e.g. `signedAtMs`). Unused in Phase 1. */\n readonly timeMs?: number;\n}\n\n/**\n * Resolve the verifying public key for `(principal, keyId)`, or `undefined`\n * to **reject** (fail closed). This is the single seam every verifier goes\n * through, replacing the old \"the id *is* the key\" decode.\n *\n * Phase 1 supports only inline genesis keys: the `keyId` must be a `\"key:\"`\n * form and the principal must be exactly `\"id:\" + keyId` (genesis\n * self-certification by string equality). `keydoc:`/rotation forms resolve\n * through `bindings`/`timeMs` later and are intentionally not handled here.\n */\nexport function resolveSigningKey(args: ResolveSigningKeyArgs): { publicKey: PublicKey } | undefined {\n const { principal, keyId } = args;\n if (!keyId.startsWith(KEY_ID_PREFIX)) {\n return undefined; // keydoc:/rotation — deferred\n }\n if (PRINCIPAL_PREFIX + keyId !== principal) {\n return undefined; // not this principal's genesis key\n }\n try {\n return { publicKey: base64UrlToBytes(keyId.slice(KEY_ID_PREFIX.length)) };\n } catch {\n return undefined; // malformed base64url\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,SAAgB,gBAAgB,OAAwB;CACpD,MAAM,MAAM,cAAc,KAAK;CAC/B,IAAI,QAAQ,KAAA,GACR,MAAM,IAAI,MAAM,kDAAkD;CAEtE,OAAO;AACX;AAEA,MAAM,WAAW,IAAI,YAAY;;AAGjC,SAAgB,qBAAqB,OAA4B;CAC7D,OAAO,SAAS,OAAO,gBAAgB,KAAK,CAAC;AACjD;AAEA,SAAS,cAAc,QAAiB,uBAAoB,IAAI,IAAI,GAAuB;CACvF,IAAI,OAAO,WAAW,YAAY,OAAO,MAAM,MAAM,GACjD,MAAM,IAAI,MAAM,oBAAoB;CAExC,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,SAAS,MAA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,IAAI;EACA,OAAO,EAAE,WAAW,iBAAiB,MAAM,MAAM,CAAoB,CAAC,EAAE;CAC5E,QAAQ;EACJ;CACJ;AACJ"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { mt as requestType, z as defineInterface } from "./inspectionHost-BA6ZmC_P.js";
5
+ import { A as defineInterface, nt as requestType } from "./inspectionHost-D_TYHZgN.js";
6
6
  import { array, boolean, discriminatedUnion, enum as enum$1, extend, literal, minLength, number, object, optional, record, string, union, unknown } from "zod/mini";
7
7
  //#region src/hub/common/hub.interfaces.ts
8
8
  const zMemberPattern = union([object({ exact: string() }), object({ prefix: string() })]);
@@ -523,4 +523,4 @@ const hubAccessManifestInterface = defineInterface({
523
523
  //#endregion
524
524
  export { hubServiceIdRegistryInterface as i, hubAccessManifestInterface as n, hubGrantedServiceIdInterface as r, hubAccessInterface as t };
525
525
 
526
- //# sourceMappingURL=hub.interfaces-I-GtB1Ah.js.map
526
+ //# sourceMappingURL=hub.interfaces-BwJQeVWT.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hub.interfaces-I-GtB1Ah.js","names":["zEnum"],"sources":["../../src/hub/common/hub.interfaces.ts"],"sourcesContent":["import { array, boolean, discriminatedUnion, enum as zEnum, extend, literal, minLength, number, object, optional, record, string, union, unknown } from 'zod/mini';\nimport { defineInterface, requestType, type InterfaceClient } from '../../index';\n\nconst zMemberPattern = union([\n object({ exact: string() }),\n object({ prefix: string() }),\n]);\n\n/**\n * Optional per-permission invocation preview the requester suggests for\n * \"Allow once\" consent UX. When present, the user can bind the resulting\n * capability to this exact (method, params, interfaceHash) tuple.\n *\n * `nonce` and `signedAtMs` are consumer-chosen and identify the exact call\n * attempt the cap will authorise. The host hashes the same canonical\n * bytes the consumer will sign; the gate re-derives the hash from the\n * inbound call and compares. The consumer MUST use the same\n * nonce+signedAtMs when it actually issues the call (`@hediet/linkrpc`'s\n * {@link JsonRpcChannel.setCapProvider} hook does this automatically).\n *\n * Everything in `params` is shown to the user verbatim.\n */\nconst zCallIntent = object({\n /** Fully-qualified method name the requester intends to call. */\n method: string(),\n /** Exact params the requester intends to send. */\n params: optional(unknown()),\n /** Optional schema hash assertion the call carries inside the signed payload. */\n interfaceHash: optional(string()),\n /** base64url-encoded nonce bytes the consumer will sign with. */\n nonce: string(),\n /** Unix milliseconds the consumer will sign with. */\n signedAtMs: number(),\n /** Optional one-line summary the shell displays next to params. */\n summary: optional(string()),\n /** Requester's preferred default action (`once` if omitted). */\n suggestion: optional(zEnum(['once', 'shortLived', 'longLived', 'persistent'])),\n});\n\nconst zParamMatcher = union([\n object({ exact: unknown() }),\n object({ enum: array(unknown()) }),\n object({ prefix: string() }),\n object({ subsetOf: array(string()) }),\n object({ any: literal(true) }),\n]);\n\nconst zCallBindHash = object({\n alg: literal('sha256'),\n payloadHash: string(),\n});\n\n/** Wire shape of `TargetPattern` from `@hediet/linkrpc`. */\nconst zTargetPattern = object({\n serviceId: zMemberPattern,\n interfaceId: zMemberPattern,\n interfaceHash: optional(string()),\n members: array(zMemberPattern),\n});\n\n/**\n * Wire shape of `Permission` from `@hediet/linkrpc/identity/capability`.\n * Used by `hubAccess::requestAccess` so the consumer can describe exactly\n * what authority it wants — including wildcard service ids\n * (`target.serviceId: { prefix: \"\" }`). `canInvoke`/`canDelegate` default\n * to `false` (fail closed).\n */\nconst zPermission = object({\n target: zTargetPattern,\n canInvoke: optional(boolean()),\n canDelegate: optional(boolean()),\n params: optional(record(string(), zParamMatcher)),\n callBind: optional(zCallBindHash),\n});\n\n/**\n * A `requestAccess` permission carrying the consent-only {@link zCallIntent}\n * preview alongside the authority it requests. The host strips `callIntent`\n * before minting the signed capability.\n */\nconst zRequestPermission = extend(zPermission, {\n callIntent: optional(zCallIntent),\n});\n\n/**\n * Who is asking, plus the `principal` that becomes the minted capability's\n * `audience`/target. The hub uses `principal` directly (it is no longer derived\n * from the call's verified signer): a cap minted for a `principal` is only usable\n * by the holder of that principal's key, enforced at call time\n * (`permits` checks `audience === call.signer`).\n */\nconst zConsumer = object({\n name: string(),\n /** Capability audience/target — the consumer's own PrincipalId. */\n principal: string(),\n origin: optional(string()),\n purpose: optional(string()),\n});\n\n/**\n * Wire shape of `SignedCapability` from `@hediet/linkrpc`. Mirrors the\n * structural type without pulling zod into the identity package. Keep in\n * sync with `Capability` / `SignedCapability` there.\n *\n * A capability is now a flat object (its fields) plus a `$hubrpcSignature`\n * map carrying the issuer's `capability` signature. Delegation links to a\n * single `parentHash` (the parent's `signedHash(\"capability\", ...)`).\n */\nconst zSignedCapability = object({\n issuer: string(),\n audience: string(),\n permissions: array(zPermission),\n expiresAtMs: optional(number()),\n parentHash: optional(string()),\n nonce: string(),\n $hubrpcSignature: object({\n capability: optional(object({ keyId: string(), sig: string() })),\n call: optional(object({ keyId: string(), sig: string() })),\n }),\n});\n\n/** Lifetime hint for a minted capability. Shared across hubAccess + the manifest. */\nconst zDuration = zEnum(['once', 'shortLived', 'longLived', 'persistent']);\n\n// ---- discovery slot shapes (shared by hubAccess.request and hubAccessManifest) ----\n\n/** One interface a slot's chosen service must implement. */\nconst zInterfaceRef = object({\n id: string(),\n hash: optional(string()),\n /** Default true. */\n required: optional(boolean()),\n});\n\n/** One member (method) the consumer intends to call on a slot's interface. */\nconst zMemberRequest = object({\n interfaceId: string(),\n member: zMemberPattern,\n /** Default true. */\n required: optional(boolean()),\n});\n\n/**\n * A consumer's need for ONE service: the interfaces it must speak and the\n * members it intends to call. The discovery side of both `hubAccess::request`\n * (sent as a call param) and `hubAccessManifest` (published as state).\n */\nconst zSlotRequest = object({\n interfaces: array(zInterfaceRef),\n members: optional(array(zMemberRequest)),\n});\n\n/** The resolution of one slot: exactly one chosen service. */\nconst zResolvedSlot = object({\n serviceId: string(),\n satisfiedInterfaces: array(string()),\n});\n\n/**\n * Minimal JSON-document patch op, addressed by an RFC 6901 JSON Pointer.\n * `path: \"\"` targets the whole document; a pointer like `/granted/secretStore`\n * targets one entry. Used by `hubAccessManifest::setCurrent` to replace the\n * entire granted document or a single entry.\n */\nconst zManifestPatch = discriminatedUnion('op', [\n object({ op: literal('set'), path: string(), value: unknown() }),\n object({ op: literal('remove'), path: string() }),\n]);\n\n/**\n * `hubServiceIdRegistry::registerServiceId` — a participant claims a prefix\n * **outside** its provenance-granted namespace.\n *\n * Reached under the hub's own service id (form-3\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId`) and gated by an\n * admin-rooted capability. For claims **within** the connection's granted\n * namespace, use the cheaper, capability-free `hubGrantedServiceId::register`\n * instead.\n */\nexport const hubServiceIdRegistryInterface = defineInterface(\n {\n id: 'hubServiceIdRegistry',\n description: 'Claim a serviceId prefix on the hub.',\n },\n {\n registerServiceId: requestType(\n object({\n requestedPrefix: string().check(minLength(1)),\n }),\n object({}),\n ),\n },\n);\n\n\n/**\n * `hubGrantedServiceId` — the ungated connection surface, served at the\n * connection root on each participant's overlay (so it is reachable directly,\n * never forwarded, and needs no capability of its own). Two jobs:\n *\n * - `get` (unsigned) reports the topology facts the hub decided for this\n * connection — where it is and what it may claim.\n * - `register` (provenance-gated) claims a prefix **within**\n * this connection's granted namespace — the capability-free claim path.\n * Claims outside the namespace go through the admin-gated\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.\n * - `getHubServiceId` (unsigned) reports the serviceId prefix the hub mounts\n * its own global services under — the prefix to address the admin-gated\n * registry and reflection endpoints through. Served at the connection root\n * so a participant can discover it **before** it knows where the hub lives.\n *\n * The hub's consent front door (`hubAccess::*`) is served at the connection\n * root too, so it needs no bootstrap capability and is reached directly.\n */\nexport const hubGrantedServiceIdInterface = defineInterface(\n {\n id: 'hubGrantedServiceId',\n description: 'Connection facts and capability-free serviceId claims.',\n },\n {\n /**\n * Connection facts (unsigned). The participant pulls, on each\n * (re)connect, the topology facts the hub has decided for this\n * connection:\n *\n * - `grantedServiceIdNamespace` — the absolute serviceId region this\n * connection's provenance may claim (anything at/under it). May be\n * the empty string, meaning \"claim nothing freely\".\n */\n get: requestType(\n object({}),\n object({\n grantedServiceIdNamespace: string(),\n }),\n ),\n\n /**\n * The serviceId prefix the hub mounts its own global services under\n * (default `'hub'`). Use it to address the admin-gated\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door and the\n * hub's reflection endpoints. Served at the connection root (unsigned),\n * so a participant can learn it without first knowing where the hub\n * lives.\n */\n getHubServiceId: requestType(\n object({}),\n object({\n hubServiceId: string(),\n }),\n ),\n\n /**\n * Claim a serviceId prefix **within** this connection's provenance-\n * granted namespace (see `get().grantedServiceIdNamespace`). No\n * capability needed — the grant already happened out-of-band at attach\n * time. The requested `serviceId` must equal the granted namespace or be\n * nested beneath it; anything else is rejected (claim it through the\n * admin-gated `<hubServiceId>::hubServiceIdRegistry::registerServiceId`\n * door instead).\n */\n register: requestType(\n object({ serviceId: string().check(minLength(1)) }),\n object({}),\n ),\n },\n);\n\n/**\n * `hubAccess::request` — a consumer (e.g. a sandboxed web editor) asks the\n * hub for scoped access to one or more services.\n *\n * Consumers describe their needs as named *dependencies* (\"slots\"): each\n * slot lists the interfaces the chosen service must implement and the\n * methods the consumer wants to call. The hub resolves candidate services\n * from its participant directory, then forwards the bundle to a host-\n * supplied handler (see `Hub` options) that shows the user a single\n * prompt. The handler picks a concrete service per slot and approves a\n * subset of the requested methods.\n *\n * In v1 the response carries only the resolution (which serviceId was\n * chosen per slot). Once the hub holds a signing identity it will also\n * return a `SignedCapability` the consumer attaches to subsequent calls.\n * Until then, dispatch is not gated on the grant — see plan-access.md.\n */\nexport const hubAccessInterface = defineInterface(\n {\n id: 'hubAccess',\n description: 'Consumer requests scoped access to services on the hub.',\n },\n {\n request: requestType(\n object({\n consumer: zConsumer,\n dependencies: record(string(), zSlotRequest),\n duration: optional(zDuration),\n }),\n discriminatedUnion('status', [\n object({\n status: literal('granted'),\n slots: record(string(), zResolvedSlot),\n /**\n * One or more `SignedCapability`s issued by the hub\n * (audience = consumer NodeId). Consumers attach them\n * via `$hubrpc.capabilities` on subsequent calls. Empty\n * array is legal (hub with no signing identity / tests).\n *\n * Plural so a handler can return per-slot caps with\n * different `exp`/caveats; typical handlers return a\n * single cap covering every granted member.\n */\n capabilities: array(zSignedCapability),\n }),\n object({\n status: literal('denied'),\n reason: optional(string()),\n }),\n object({\n status: literal('noCandidates'),\n /** Slot ids that have zero matching candidates. */\n slots: array(string()),\n }),\n ]),\n ),\n\n /**\n * Service-pinned widening of an existing grant. The consumer asks\n * the hub for additional members on a `serviceId` they already\n * deal with — same audience (their NodeId) and (intended) same\n * `rootIssuer` as the prior grant. The hub never picks the service\n * for the consumer here: `serviceId` is an input, not a result.\n *\n * On grant the response carries a fresh `SignedCapability` whose\n * attenuations cover **only** the granted delta. Bag-compatible\n * with the prior cap; combine via `merge` (when it exists) or\n * just keep both in `$hubrpc.capabilities`.\n *\n * Distinguished from `request` so the consent UI can render a\n * different affordance (\"X already has read access on `github`,\n * grant `update` as well?\" instead of from-zero selection).\n *\n * TODO(hub-ledger): enforce \"consumer has prior history on this\n * service\" — see `hub.ts:_handleAccessExtend`. v1 forwards\n * directly to the host's `onAccessExtend` without consulting the\n * `_grants` ledger; this is by design while we settle on the\n * persistence model.\n */\n extend: requestType(\n object({\n consumer: zConsumer,\n /**\n * Service to widen the grant on. MUST equal the\n * `serviceId` of a previously-issued attenuation for this\n * consumer NodeId. v1 does not validate this.\n */\n serviceId: string(),\n /**\n * The delta. Same shape as `request`'s slot.members. Each\n * entry MUST refer to an interface the consumer has been\n * introduced to on `serviceId` via a prior `request`.\n */\n added: array(zMemberRequest),\n duration: optional(zDuration),\n }),\n discriminatedUnion('status', [\n object({\n status: literal('granted'),\n serviceId: string(),\n /** Members actually granted (handler may approve a subset). */\n granted: array(\n object({\n interfaceId: string(),\n member: zMemberPattern,\n }),\n ),\n /**\n * Capability covering only the granted delta. Audience\n * = consumer NodeId. Bag-compatible with the prior\n * cap on this service.\n */\n capabilities: optional(array(zSignedCapability)),\n }),\n object({\n status: literal('denied'),\n reason: optional(string()),\n }),\n // TODO(hub-ledger): additional variants once the host's\n // grant ledger is persisted:\n // - { status: \"unknownService\", serviceId }\n // - { status: \"unknownInterface\", serviceId, interfaceIds }\n // Reject without ever prompting the user when the consumer\n // is asking to widen a service it has no prior grant on.\n ]),\n ),\n\n /**\n * `hubAccess::requestAccess` — direct capability request. The\n * consumer specifies the exact attenuations it wants. No\n * service-discovery, no candidate resolution: the consumer\n * already knows which `(serviceId, interfaceId, members)` it\n * needs, including wildcards (e.g. `serviceId: { prefix: \"\" }`\n * to ask for an interface anywhere).\n *\n * Compared to `request`:\n * - `request` does directory-based discovery, picks one service\n * per slot, and returns a cap pinned to that service. Use\n * when the consumer says \"give me SOME service that does X\".\n * - `requestAccess` is verbatim. Use when the consumer says\n * \"give me exactly these attenuations\". Especially useful for\n * reflection (`hubrpc.directory::list` on any service) and\n * for on-demand per-method grants from an explorer-style UI.\n *\n * The user prompt shows the exact `Capability` the hub will sign\n * on Allow, same byte-equality guarantee as `request`/`extend`.\n */\n requestAccess: requestType(\n object({\n consumer: zConsumer,\n permissions: array(zRequestPermission).check(minLength(1)),\n duration: optional(zDuration),\n }),\n discriminatedUnion('status', [\n object({\n status: literal('granted'),\n capabilities: array(zSignedCapability),\n }),\n object({\n status: literal('denied'),\n reason: optional(string()),\n }),\n ]),\n ),\n },\n);\n\n// ════════════════════════════════════════════════════════════════════════\n// hubAccessManifest — the declarative twin of `hubAccess`.\n// ════════════════════════════════════════════════════════════════════════\n\n/**\n * The root issuer(s) whose signature the participant will accept on the minted\n * capability. A capability is only usable by its holder if it chains to a root\n * that the *target* service trusts — and not every service trusts every root.\n * So the participant declares, per entry, which minting root(s) would produce a\n * cap it can actually use; the admin must mint with one of them (or decline).\n *\n * Tri-state, by design:\n * - **omitted** (`undefined`) — unspecified. The participant doesn't know /\n * doesn't constrain the root; the admin picks. (The common, lenient default.)\n * - **non-empty** (`[\"id:abc\", …]`) — mint with one of *these* roots; a cap\n * rooted elsewhere is useless to the participant.\n * - **empty** (`[]`) — \"no root is acceptable\", i.e. nothing can satisfy this.\n * Almost certainly a bug (it can never be granted); kept representable so a\n * tool can detect and flag it rather than silently treating it as \"any\".\n */\nconst zAcceptableRootIds = array(string());\n\n/**\n * A desired access entry the participant publishes. Two kinds, mirroring the\n * two discovery-vs-verbatim halves of `hubAccess`:\n *\n * - `discover` — \"find me a service implementing X\" (same shape as a\n * `hubAccess::request` slot). The admin resolves one concrete service.\n * - `direct` — \"grant exactly these permissions\" (same shape as\n * `hubAccess::requestAccess`). The serviceId is already in each permission's\n * target; no discovery.\n */\nconst zManifestRequest = discriminatedUnion('kind', [\n extend(zSlotRequest, {\n kind: literal('discover'),\n /** Who is asking; `principal` is the audience minted caps must target. */\n consumer: zConsumer,\n /** Human rationale shown to the admin (\"seal tokens at rest\"). */\n reason: optional(string()),\n duration: optional(zDuration),\n /** Root issuer(s) that must mint this cap. See {@link zAcceptableRootIds}. */\n acceptableRootIds: optional(zAcceptableRootIds),\n /**\n * Host-authored provenance bag, stamped at `registerHubAccessAtRoot`\n * (NOT taken from the consumer's request params — so it cannot be\n * spoofed). An open `record<string, unknown>` so a host can attach\n * whatever origin info it observed about the requesting transport (e.g.\n * `{ sourceTransportId }` to route a local consent UI). Meaningful only\n * to a consumer that KNOWS this manifest is local; an aggregating\n * manifest MUST re-scope or omit it.\n */\n origin: optional(record(string(), unknown())),\n }),\n object({\n kind: literal('direct'),\n /** Who is asking; `principal` is the audience minted caps must target. */\n consumer: zConsumer,\n reason: optional(string()),\n permissions: array(zRequestPermission).check(minLength(1)),\n duration: optional(zDuration),\n /** Root issuer(s) that must mint this cap. See {@link zAcceptableRootIds}. */\n acceptableRootIds: optional(zAcceptableRootIds),\n /** Host-authored provenance bag. See the `discover` variant. */\n origin: optional(record(string(), unknown())),\n }),\n]);\n\n/**\n * The current (granted) value of one entry. For `discover` it carries the single\n * chosen service (mirroring `hubAccess::request`'s resolved slot) plus the caps;\n * for `direct` just the caps (the serviceId is in each permission's target).\n */\nconst zGrantedEntry = discriminatedUnion('kind', [\n extend(zResolvedSlot, {\n kind: literal('discover'),\n capabilities: array(zSignedCapability),\n }),\n object({\n kind: literal('direct'),\n capabilities: array(zSignedCapability),\n }),\n]);\n\n/**\n * The current value of one entry: `granted` (caps, plus the chosen service for\n * `discover`) or `denied` (with an optional reason). An entry *absent* from the\n * current document is **undecided** — distinct from a terminal `denied`, which\n * lets an approver say \"no\" (and why) instead of silently withholding.\n */\nconst zCurrentEntry = discriminatedUnion('status', [\n object({ status: literal('granted'), granted: zGrantedEntry }),\n object({ status: literal('denied'), reason: optional(string()) }),\n]);\n\n/**\n * `hubAccessManifest` — the declarative twin of {@link hubAccessInterface}.\n *\n * Where `hubAccess` is the imperative, just-in-time door a consumer *calls* (and\n * the hub serves at the connection root), `hubAccessManifest` is **served by the\n * participant** under its own serviceId, so it appears in `hubrpc.directory::list`\n * — its very presence is the request. A participant publishes its DESIRED access\n * entries (keyed by id, like `request`'s `dependencies`); an admin discovers\n * them via the directory, mints capabilities **with its own identity** (a\n * configured hub capability root), and writes the CURRENT/granted state back via\n * patches. The participant reads the granted entries and attaches the caps to\n * its later calls.\n *\n * Reconcile model (desired vs. current), aligned with the hub's other surfaces:\n * - `getDesired` / `watchDesired` — the participant's declared needs.\n * - `getCurrent` / `setCurrent` / `watchCurrent` — the admin-written grants.\n *\n * `watch*` follows the coarse empty-tick convention of `hubrpc.directory::watch`:\n * a tick means \"re-`get` now\", keeping the server stateless (no per-item deltas).\n */\nexport const hubAccessManifestInterface = defineInterface(\n {\n id: 'hubAccessManifest',\n description:\n 'Participant-served declarative access: publish DESIRED access entries '\n + '(discover | direct), an admin mints capabilities and writes the CURRENT '\n + 'granted state back. The reconcile twin of hubAccess::{request,requestAccess}.',\n },\n {\n // ---- desired (participant-authored; the admin reads) ----------------\n /** The full desired document: who is asking and the entries it wants. */\n getDesired: requestType(\n object({}),\n object({\n /**\n * entryId → desired entry, each carrying its own `consumer`. A\n * per-participant manifest's entries all share one consumer; a hub\n * broker aggregates entries from many consumers in one flat map.\n */\n requested: record(string(), zManifestRequest),\n /** Bumped whenever `requested` changes; lets watchers dedupe ticks. */\n revision: number(),\n }),\n ).withStream({ client: object({}) }),\n /**\n * Coarse change tap on the desired document. Emits an empty tick when\n * `requested` may have changed; the caller re-`getDesired`. Resolves when\n * the caller cancels. Mirrors `hubrpc.directory::watch`.\n */\n watchDesired: requestType(\n object({}),\n object({}),\n ).withStream({ server: object({}) }),\n\n // ---- current / granted (admin-authored; the participant reads) ------\n /** The full current document: entryId → granted/denied (absent ⇒ undecided). */\n getCurrent: requestType(\n object({}),\n object({\n /** entryId → current value (granted | denied). */\n current: record(string(), zCurrentEntry),\n /** Bumped on every successful `setCurrent`. */\n revision: number(),\n }),\n ),\n /**\n * Apply patches to the current document. Replace the whole document with\n * `{ op: 'set', path: '', value }`, or a single entry with\n * `{ op: 'set', path: '/current/<entryId>', value }` (a `zCurrentEntry`:\n * granted or denied). Admin-only in practice (gated by a capability\n * rooted at an accepted issuer).\n */\n setCurrent: requestType(\n object({ patches: array(zManifestPatch) }),\n object({ revision: number() }),\n ).withStream({ client: object({}) }),\n /**\n * Coarse change tap on the current document. Emits an empty tick when\n * `current` may have changed; the participant re-`getCurrent` and applies\n * any new capabilities. Resolves when the caller cancels.\n */\n watchCurrent: requestType(\n object({}),\n object({}),\n ).withStream({ server: object({}) }),\n },\n);\n\n/**\n * The typed client shape of {@link hubAccessManifestInterface} — the exact\n * object `connection.get(hubAccessManifestInterface)` (or\n * `connection.service(id).get(...)`) returns. Approvers depend on this contract,\n * not on a concrete connection: the same approver runs against a local in-memory\n * host (loopback connection), a remote hub's served manifest, or a future\n * aggregating implementation with no code change.\n */\nexport type IHubAccessManifest = InterfaceClient<typeof hubAccessManifestInterface>;\n\n/** One typed entry from `hubAccessManifest::getDesired().requested`. */\nexport type HubAccessManifestRequest =\n Awaited<ReturnType<IHubAccessManifest['getDesired']>>['requested'][string];\n\n/** One typed value accepted at `/current/<entryId>` by `setCurrent`. */\nexport type HubAccessManifestDecision =\n Awaited<ReturnType<IHubAccessManifest['getCurrent']>>['current'][string];\n"],"mappings":";;;;;;;AAGA,MAAM,iBAAiB,MAAM,CACzB,OAAO,EAAE,OAAO,OAAO,EAAE,CAAC,GAC1B,OAAO,EAAE,QAAQ,OAAO,EAAE,CAAC,CAC/B,CAAC;;;;;;;;;;;;;;;AAgBD,MAAM,cAAc,OAAO;;CAEvB,QAAQ,OAAO;;CAEf,QAAQ,SAAS,QAAQ,CAAC;;CAE1B,eAAe,SAAS,OAAO,CAAC;;CAEhC,OAAO,OAAO;;CAEd,YAAY,OAAO;;CAEnB,SAAS,SAAS,OAAO,CAAC;;CAE1B,YAAY,SAASA,OAAM;EAAC;EAAQ;EAAc;EAAa;CAAY,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,gBAAgB,MAAM;CACxB,OAAO,EAAE,OAAO,QAAQ,EAAE,CAAC;CAC3B,OAAO,EAAE,MAAM,MAAM,QAAQ,CAAC,EAAE,CAAC;CACjC,OAAO,EAAE,QAAQ,OAAO,EAAE,CAAC;CAC3B,OAAO,EAAE,UAAU,MAAM,OAAO,CAAC,EAAE,CAAC;CACpC,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,gBAAgB,OAAO;CACzB,KAAK,QAAQ,QAAQ;CACrB,aAAa,OAAO;AACxB,CAAC;;AAGD,MAAM,iBAAiB,OAAO;CAC1B,WAAW;CACX,aAAa;CACb,eAAe,SAAS,OAAO,CAAC;CAChC,SAAS,MAAM,cAAc;AACjC,CAAC;;;;;;;;AASD,MAAM,cAAc,OAAO;CACvB,QAAQ;CACR,WAAW,SAAS,QAAQ,CAAC;CAC7B,aAAa,SAAS,QAAQ,CAAC;CAC/B,QAAQ,SAAS,OAAO,OAAO,GAAG,aAAa,CAAC;CAChD,UAAU,SAAS,aAAa;AACpC,CAAC;;;;;;AAO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Q,OAAO,CAAC,CAAC,EAAE,CAAC;;;;;;CAMnC,cAAc,YACV,OAAO,CAAC,CAAC,GACT,OAAO,CAAC,CAAC,CACb,CAAC,CAAC,WAAW,EAAE,QAAQ,OAAO,CAAC,CAAC,EAAE,CAAC;AACvC,CACJ"}
1
+ {"version":3,"file":"hub.interfaces-BwJQeVWT.js","names":["zEnum"],"sources":["../../src/hub/common/hub.interfaces.ts"],"sourcesContent":["import { array, boolean, discriminatedUnion, enum as zEnum, extend, literal, minLength, number, object, optional, record, string, union, unknown } from 'zod/mini';\nimport { defineInterface, requestType, type InterfaceClient } from '../../index';\n\nconst zMemberPattern = union([\n object({ exact: string() }),\n object({ prefix: string() }),\n]);\n\n/**\n * Optional per-permission invocation preview the requester suggests for\n * \"Allow once\" consent UX. When present, the user can bind the resulting\n * capability to this exact (method, params, interfaceHash) tuple.\n *\n * `nonce` and `signedAtMs` are consumer-chosen and identify the exact call\n * attempt the cap will authorise. The host hashes the same canonical\n * bytes the consumer will sign; the gate re-derives the hash from the\n * inbound call and compares. The consumer MUST use the same\n * nonce+signedAtMs when it actually issues the call (`@hediet/linkrpc`'s\n * {@link JsonRpcChannel.setCapProvider} hook does this automatically).\n *\n * Everything in `params` is shown to the user verbatim.\n */\nconst zCallIntent = object({\n /** Fully-qualified method name the requester intends to call. */\n method: string(),\n /** Exact params the requester intends to send. */\n params: optional(unknown()),\n /** Optional schema hash assertion the call carries inside the signed payload. */\n interfaceHash: optional(string()),\n /** base64url-encoded nonce bytes the consumer will sign with. */\n nonce: string(),\n /** Unix milliseconds the consumer will sign with. */\n signedAtMs: number(),\n /** Optional one-line summary the shell displays next to params. */\n summary: optional(string()),\n /** Requester's preferred default action (`once` if omitted). */\n suggestion: optional(zEnum(['once', 'shortLived', 'longLived', 'persistent'])),\n});\n\nconst zParamMatcher = union([\n object({ exact: unknown() }),\n object({ enum: array(unknown()) }),\n object({ prefix: string() }),\n object({ subsetOf: array(string()) }),\n object({ any: literal(true) }),\n]);\n\nconst zCallBindHash = object({\n alg: literal('sha256'),\n payloadHash: string(),\n});\n\n/** Wire shape of `TargetPattern` from `@hediet/linkrpc`. */\nconst zTargetPattern = object({\n serviceId: zMemberPattern,\n interfaceId: zMemberPattern,\n interfaceHash: optional(string()),\n members: array(zMemberPattern),\n});\n\n/**\n * Wire shape of `Permission` from `@hediet/linkrpc/identity/capability`.\n * Used by `hubAccess::requestAccess` so the consumer can describe exactly\n * what authority it wants — including wildcard service ids\n * (`target.serviceId: { prefix: \"\" }`). `canInvoke`/`canDelegate` default\n * to `false` (fail closed).\n */\nconst zPermission = object({\n target: zTargetPattern,\n canInvoke: optional(boolean()),\n canDelegate: optional(boolean()),\n params: optional(record(string(), zParamMatcher)),\n callBind: optional(zCallBindHash),\n});\n\n/**\n * A `requestAccess` permission carrying the consent-only {@link zCallIntent}\n * preview alongside the authority it requests. The host strips `callIntent`\n * before minting the signed capability.\n */\nconst zRequestPermission = extend(zPermission, {\n callIntent: optional(zCallIntent),\n});\n\n/**\n * Who is asking, plus the `principal` that becomes the minted capability's\n * `audience`/target. The hub uses `principal` directly (it is no longer derived\n * from the call's verified signer): a cap minted for a `principal` is only usable\n * by the holder of that principal's key, enforced at call time\n * (`permits` checks `audience === call.signer`).\n */\nconst zConsumer = object({\n name: string(),\n /** Capability audience/target — the consumer's own PrincipalId. */\n principal: string(),\n origin: optional(string()),\n purpose: optional(string()),\n});\n\n/**\n * Wire shape of `SignedCapability` from `@hediet/linkrpc`. Mirrors the\n * structural type without pulling zod into the identity package. Keep in\n * sync with `Capability` / `SignedCapability` there.\n *\n * A capability is now a flat object (its fields) plus a `$hubrpcSignature`\n * map carrying the issuer's `capability` signature. Delegation links to a\n * single `parentHash` (the parent's `signedHash(\"capability\", ...)`).\n */\nconst zSignedCapability = object({\n issuer: string(),\n audience: string(),\n permissions: array(zPermission),\n expiresAtMs: optional(number()),\n parentHash: optional(string()),\n nonce: string(),\n $hubrpcSignature: object({\n capability: optional(object({ keyId: string(), sig: string() })),\n call: optional(object({ keyId: string(), sig: string() })),\n }),\n});\n\n/** Lifetime hint for a minted capability. Shared across hubAccess + the manifest. */\nconst zDuration = zEnum(['once', 'shortLived', 'longLived', 'persistent']);\n\n// ---- discovery slot shapes (shared by hubAccess.request and hubAccessManifest) ----\n\n/** One interface a slot's chosen service must implement. */\nconst zInterfaceRef = object({\n id: string(),\n hash: optional(string()),\n /** Default true. */\n required: optional(boolean()),\n});\n\n/** One member (method) the consumer intends to call on a slot's interface. */\nconst zMemberRequest = object({\n interfaceId: string(),\n member: zMemberPattern,\n /** Default true. */\n required: optional(boolean()),\n});\n\n/**\n * A consumer's need for ONE service: the interfaces it must speak and the\n * members it intends to call. The discovery side of both `hubAccess::request`\n * (sent as a call param) and `hubAccessManifest` (published as state).\n */\nconst zSlotRequest = object({\n interfaces: array(zInterfaceRef),\n members: optional(array(zMemberRequest)),\n});\n\n/** The resolution of one slot: exactly one chosen service. */\nconst zResolvedSlot = object({\n serviceId: string(),\n satisfiedInterfaces: array(string()),\n});\n\n/**\n * Minimal JSON-document patch op, addressed by an RFC 6901 JSON Pointer.\n * `path: \"\"` targets the whole document; a pointer like `/granted/secretStore`\n * targets one entry. Used by `hubAccessManifest::setCurrent` to replace the\n * entire granted document or a single entry.\n */\nconst zManifestPatch = discriminatedUnion('op', [\n object({ op: literal('set'), path: string(), value: unknown() }),\n object({ op: literal('remove'), path: string() }),\n]);\n\n/**\n * `hubServiceIdRegistry::registerServiceId` — a participant claims a prefix\n * **outside** its provenance-granted namespace.\n *\n * Reached under the hub's own service id (form-3\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId`) and gated by an\n * admin-rooted capability. For claims **within** the connection's granted\n * namespace, use the cheaper, capability-free `hubGrantedServiceId::register`\n * instead.\n */\nexport const hubServiceIdRegistryInterface = defineInterface(\n {\n id: 'hubServiceIdRegistry',\n description: 'Claim a serviceId prefix on the hub.',\n },\n {\n registerServiceId: requestType(\n object({\n requestedPrefix: string().check(minLength(1)),\n }),\n object({}),\n ),\n },\n);\n\n\n/**\n * `hubGrantedServiceId` — the ungated connection surface, served at the\n * connection root on each participant's overlay (so it is reachable directly,\n * never forwarded, and needs no capability of its own). Two jobs:\n *\n * - `get` (unsigned) reports the topology facts the hub decided for this\n * connection — where it is and what it may claim.\n * - `register` (provenance-gated) claims a prefix **within**\n * this connection's granted namespace — the capability-free claim path.\n * Claims outside the namespace go through the admin-gated\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.\n * - `getHubServiceId` (unsigned) reports the serviceId prefix the hub mounts\n * its own global services under — the prefix to address the admin-gated\n * registry and reflection endpoints through. Served at the connection root\n * so a participant can discover it **before** it knows where the hub lives.\n *\n * The hub's consent front door (`hubAccess::*`) is served at the connection\n * root too, so it needs no bootstrap capability and is reached directly.\n */\nexport const hubGrantedServiceIdInterface = defineInterface(\n {\n id: 'hubGrantedServiceId',\n description: 'Connection facts and capability-free serviceId claims.',\n },\n {\n /**\n * Connection facts (unsigned). The participant pulls, on each\n * (re)connect, the topology facts the hub has decided for this\n * connection:\n *\n * - `grantedServiceIdNamespace` — the absolute serviceId region this\n * connection's provenance may claim (anything at/under it). May be\n * the empty string, meaning \"claim nothing freely\".\n */\n get: requestType(\n object({}),\n object({\n grantedServiceIdNamespace: string(),\n }),\n ),\n\n /**\n * The serviceId prefix the hub mounts its own global services under\n * (default `'hub'`). Use it to address the admin-gated\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door and the\n * hub's reflection endpoints. Served at the connection root (unsigned),\n * so a participant can learn it without first knowing where the hub\n * lives.\n */\n getHubServiceId: requestType(\n object({}),\n object({\n hubServiceId: string(),\n }),\n ),\n\n /**\n * Claim a serviceId prefix **within** this connection's provenance-\n * granted namespace (see `get().grantedServiceIdNamespace`). No\n * capability needed — the grant already happened out-of-band at attach\n * time. The requested `serviceId` must equal the granted namespace or be\n * nested beneath it; anything else is rejected (claim it through the\n * admin-gated `<hubServiceId>::hubServiceIdRegistry::registerServiceId`\n * door instead).\n */\n register: requestType(\n object({ serviceId: string().check(minLength(1)) }),\n object({}),\n ),\n },\n);\n\n/**\n * `hubAccess::request` — a consumer (e.g. a sandboxed web editor) asks the\n * hub for scoped access to one or more services.\n *\n * Consumers describe their needs as named *dependencies* (\"slots\"): each\n * slot lists the interfaces the chosen service must implement and the\n * methods the consumer wants to call. The hub resolves candidate services\n * from its participant directory, then forwards the bundle to a host-\n * supplied handler (see `Hub` options) that shows the user a single\n * prompt. The handler picks a concrete service per slot and approves a\n * subset of the requested methods.\n *\n * In v1 the response carries only the resolution (which serviceId was\n * chosen per slot). Once the hub holds a signing identity it will also\n * return a `SignedCapability` the consumer attaches to subsequent calls.\n * Until then, dispatch is not gated on the grant — see plan-access.md.\n */\nexport const hubAccessInterface = defineInterface(\n {\n id: 'hubAccess',\n description: 'Consumer requests scoped access to services on the hub.',\n },\n {\n request: requestType(\n object({\n consumer: zConsumer,\n dependencies: record(string(), zSlotRequest),\n duration: optional(zDuration),\n }),\n discriminatedUnion('status', [\n object({\n status: literal('granted'),\n slots: record(string(), zResolvedSlot),\n /**\n * One or more `SignedCapability`s issued by the hub\n * (audience = consumer NodeId). Consumers attach them\n * via `$hubrpc.capabilities` on subsequent calls. Empty\n * array is legal (hub with no signing identity / tests).\n *\n * Plural so a handler can return per-slot caps with\n * different `exp`/caveats; typical handlers return a\n * single cap covering every granted member.\n */\n capabilities: array(zSignedCapability),\n }),\n object({\n status: literal('denied'),\n reason: optional(string()),\n }),\n object({\n status: literal('noCandidates'),\n /** Slot ids that have zero matching candidates. */\n slots: array(string()),\n }),\n ]),\n ),\n\n /**\n * Service-pinned widening of an existing grant. The consumer asks\n * the hub for additional members on a `serviceId` they already\n * deal with — same audience (their NodeId) and (intended) same\n * `rootIssuer` as the prior grant. The hub never picks the service\n * for the consumer here: `serviceId` is an input, not a result.\n *\n * On grant the response carries a fresh `SignedCapability` whose\n * attenuations cover **only** the granted delta. Bag-compatible\n * with the prior cap; combine via `merge` (when it exists) or\n * just keep both in `$hubrpc.capabilities`.\n *\n * Distinguished from `request` so the consent UI can render a\n * different affordance (\"X already has read access on `github`,\n * grant `update` as well?\" instead of from-zero selection).\n *\n * TODO(hub-ledger): enforce \"consumer has prior history on this\n * service\" — see `hub.ts:_handleAccessExtend`. v1 forwards\n * directly to the host's `onAccessExtend` without consulting the\n * `_grants` ledger; this is by design while we settle on the\n * persistence model.\n */\n extend: requestType(\n object({\n consumer: zConsumer,\n /**\n * Service to widen the grant on. MUST equal the\n * `serviceId` of a previously-issued attenuation for this\n * consumer NodeId. v1 does not validate this.\n */\n serviceId: string(),\n /**\n * The delta. Same shape as `request`'s slot.members. Each\n * entry MUST refer to an interface the consumer has been\n * introduced to on `serviceId` via a prior `request`.\n */\n added: array(zMemberRequest),\n duration: optional(zDuration),\n }),\n discriminatedUnion('status', [\n object({\n status: literal('granted'),\n serviceId: string(),\n /** Members actually granted (handler may approve a subset). */\n granted: array(\n object({\n interfaceId: string(),\n member: zMemberPattern,\n }),\n ),\n /**\n * Capability covering only the granted delta. Audience\n * = consumer NodeId. Bag-compatible with the prior\n * cap on this service.\n */\n capabilities: optional(array(zSignedCapability)),\n }),\n object({\n status: literal('denied'),\n reason: optional(string()),\n }),\n // TODO(hub-ledger): additional variants once the host's\n // grant ledger is persisted:\n // - { status: \"unknownService\", serviceId }\n // - { status: \"unknownInterface\", serviceId, interfaceIds }\n // Reject without ever prompting the user when the consumer\n // is asking to widen a service it has no prior grant on.\n ]),\n ),\n\n /**\n * `hubAccess::requestAccess` — direct capability request. The\n * consumer specifies the exact attenuations it wants. No\n * service-discovery, no candidate resolution: the consumer\n * already knows which `(serviceId, interfaceId, members)` it\n * needs, including wildcards (e.g. `serviceId: { prefix: \"\" }`\n * to ask for an interface anywhere).\n *\n * Compared to `request`:\n * - `request` does directory-based discovery, picks one service\n * per slot, and returns a cap pinned to that service. Use\n * when the consumer says \"give me SOME service that does X\".\n * - `requestAccess` is verbatim. Use when the consumer says\n * \"give me exactly these attenuations\". Especially useful for\n * reflection (`hubrpc.directory::list` on any service) and\n * for on-demand per-method grants from an explorer-style UI.\n *\n * The user prompt shows the exact `Capability` the hub will sign\n * on Allow, same byte-equality guarantee as `request`/`extend`.\n */\n requestAccess: requestType(\n object({\n consumer: zConsumer,\n permissions: array(zRequestPermission).check(minLength(1)),\n duration: optional(zDuration),\n }),\n discriminatedUnion('status', [\n object({\n status: literal('granted'),\n capabilities: array(zSignedCapability),\n }),\n object({\n status: literal('denied'),\n reason: optional(string()),\n }),\n ]),\n ),\n },\n);\n\n// ════════════════════════════════════════════════════════════════════════\n// hubAccessManifest — the declarative twin of `hubAccess`.\n// ════════════════════════════════════════════════════════════════════════\n\n/**\n * The root issuer(s) whose signature the participant will accept on the minted\n * capability. A capability is only usable by its holder if it chains to a root\n * that the *target* service trusts — and not every service trusts every root.\n * So the participant declares, per entry, which minting root(s) would produce a\n * cap it can actually use; the admin must mint with one of them (or decline).\n *\n * Tri-state, by design:\n * - **omitted** (`undefined`) — unspecified. The participant doesn't know /\n * doesn't constrain the root; the admin picks. (The common, lenient default.)\n * - **non-empty** (`[\"id:abc\", …]`) — mint with one of *these* roots; a cap\n * rooted elsewhere is useless to the participant.\n * - **empty** (`[]`) — \"no root is acceptable\", i.e. nothing can satisfy this.\n * Almost certainly a bug (it can never be granted); kept representable so a\n * tool can detect and flag it rather than silently treating it as \"any\".\n */\nconst zAcceptableRootIds = array(string());\n\n/**\n * A desired access entry the participant publishes. Two kinds, mirroring the\n * two discovery-vs-verbatim halves of `hubAccess`:\n *\n * - `discover` — \"find me a service implementing X\" (same shape as a\n * `hubAccess::request` slot). The admin resolves one concrete service.\n * - `direct` — \"grant exactly these permissions\" (same shape as\n * `hubAccess::requestAccess`). The serviceId is already in each permission's\n * target; no discovery.\n */\nconst zManifestRequest = discriminatedUnion('kind', [\n extend(zSlotRequest, {\n kind: literal('discover'),\n /** Who is asking; `principal` is the audience minted caps must target. */\n consumer: zConsumer,\n /** Human rationale shown to the admin (\"seal tokens at rest\"). */\n reason: optional(string()),\n duration: optional(zDuration),\n /** Root issuer(s) that must mint this cap. See {@link zAcceptableRootIds}. */\n acceptableRootIds: optional(zAcceptableRootIds),\n /**\n * Host-authored provenance bag, stamped at `registerHubAccessAtRoot`\n * (NOT taken from the consumer's request params — so it cannot be\n * spoofed). An open `record<string, unknown>` so a host can attach\n * whatever origin info it observed about the requesting transport (e.g.\n * `{ sourceTransportId }` to route a local consent UI). Meaningful only\n * to a consumer that KNOWS this manifest is local; an aggregating\n * manifest MUST re-scope or omit it.\n */\n origin: optional(record(string(), unknown())),\n }),\n object({\n kind: literal('direct'),\n /** Who is asking; `principal` is the audience minted caps must target. */\n consumer: zConsumer,\n reason: optional(string()),\n permissions: array(zRequestPermission).check(minLength(1)),\n duration: optional(zDuration),\n /** Root issuer(s) that must mint this cap. See {@link zAcceptableRootIds}. */\n acceptableRootIds: optional(zAcceptableRootIds),\n /** Host-authored provenance bag. See the `discover` variant. */\n origin: optional(record(string(), unknown())),\n }),\n]);\n\n/**\n * The current (granted) value of one entry. For `discover` it carries the single\n * chosen service (mirroring `hubAccess::request`'s resolved slot) plus the caps;\n * for `direct` just the caps (the serviceId is in each permission's target).\n */\nconst zGrantedEntry = discriminatedUnion('kind', [\n extend(zResolvedSlot, {\n kind: literal('discover'),\n capabilities: array(zSignedCapability),\n }),\n object({\n kind: literal('direct'),\n capabilities: array(zSignedCapability),\n }),\n]);\n\n/**\n * The current value of one entry: `granted` (caps, plus the chosen service for\n * `discover`) or `denied` (with an optional reason). An entry *absent* from the\n * current document is **undecided** — distinct from a terminal `denied`, which\n * lets an approver say \"no\" (and why) instead of silently withholding.\n */\nconst zCurrentEntry = discriminatedUnion('status', [\n object({ status: literal('granted'), granted: zGrantedEntry }),\n object({ status: literal('denied'), reason: optional(string()) }),\n]);\n\n/**\n * `hubAccessManifest` — the declarative twin of {@link hubAccessInterface}.\n *\n * Where `hubAccess` is the imperative, just-in-time door a consumer *calls* (and\n * the hub serves at the connection root), `hubAccessManifest` is **served by the\n * participant** under its own serviceId, so it appears in `hubrpc.directory::list`\n * — its very presence is the request. A participant publishes its DESIRED access\n * entries (keyed by id, like `request`'s `dependencies`); an admin discovers\n * them via the directory, mints capabilities **with its own identity** (a\n * configured hub capability root), and writes the CURRENT/granted state back via\n * patches. The participant reads the granted entries and attaches the caps to\n * its later calls.\n *\n * Reconcile model (desired vs. current), aligned with the hub's other surfaces:\n * - `getDesired` / `watchDesired` — the participant's declared needs.\n * - `getCurrent` / `setCurrent` / `watchCurrent` — the admin-written grants.\n *\n * `watch*` follows the coarse empty-tick convention of `hubrpc.directory::watch`:\n * a tick means \"re-`get` now\", keeping the server stateless (no per-item deltas).\n */\nexport const hubAccessManifestInterface = defineInterface(\n {\n id: 'hubAccessManifest',\n description:\n 'Participant-served declarative access: publish DESIRED access entries '\n + '(discover | direct), an admin mints capabilities and writes the CURRENT '\n + 'granted state back. The reconcile twin of hubAccess::{request,requestAccess}.',\n },\n {\n // ---- desired (participant-authored; the admin reads) ----------------\n /** The full desired document: who is asking and the entries it wants. */\n getDesired: requestType(\n object({}),\n object({\n /**\n * entryId → desired entry, each carrying its own `consumer`. A\n * per-participant manifest's entries all share one consumer; a hub\n * broker aggregates entries from many consumers in one flat map.\n */\n requested: record(string(), zManifestRequest),\n /** Bumped whenever `requested` changes; lets watchers dedupe ticks. */\n revision: number(),\n }),\n ).withStream({ client: object({}) }),\n /**\n * Coarse change tap on the desired document. Emits an empty tick when\n * `requested` may have changed; the caller re-`getDesired`. Resolves when\n * the caller cancels. Mirrors `hubrpc.directory::watch`.\n */\n watchDesired: requestType(\n object({}),\n object({}),\n ).withStream({ server: object({}) }),\n\n // ---- current / granted (admin-authored; the participant reads) ------\n /** The full current document: entryId → granted/denied (absent ⇒ undecided). */\n getCurrent: requestType(\n object({}),\n object({\n /** entryId → current value (granted | denied). */\n current: record(string(), zCurrentEntry),\n /** Bumped on every successful `setCurrent`. */\n revision: number(),\n }),\n ),\n /**\n * Apply patches to the current document. Replace the whole document with\n * `{ op: 'set', path: '', value }`, or a single entry with\n * `{ op: 'set', path: '/current/<entryId>', value }` (a `zCurrentEntry`:\n * granted or denied). Admin-only in practice (gated by a capability\n * rooted at an accepted issuer).\n */\n setCurrent: requestType(\n object({ patches: array(zManifestPatch) }),\n object({ revision: number() }),\n ).withStream({ client: object({}) }),\n /**\n * Coarse change tap on the current document. Emits an empty tick when\n * `current` may have changed; the participant re-`getCurrent` and applies\n * any new capabilities. Resolves when the caller cancels.\n */\n watchCurrent: requestType(\n object({}),\n object({}),\n ).withStream({ server: object({}) }),\n },\n);\n\n/**\n * The typed client shape of {@link hubAccessManifestInterface} — the exact\n * object `connection.get(hubAccessManifestInterface)` (or\n * `connection.service(id).get(...)`) returns. Approvers depend on this contract,\n * not on a concrete connection: the same approver runs against a local in-memory\n * host (loopback connection), a remote hub's served manifest, or a future\n * aggregating implementation with no code change.\n */\nexport type IHubAccessManifest = InterfaceClient<typeof hubAccessManifestInterface>;\n\n/** One typed entry from `hubAccessManifest::getDesired().requested`. */\nexport type HubAccessManifestRequest =\n Awaited<ReturnType<IHubAccessManifest['getDesired']>>['requested'][string];\n\n/** One typed value accepted at `/current/<entryId>` by `setCurrent`. */\nexport type HubAccessManifestDecision =\n Awaited<ReturnType<IHubAccessManifest['getCurrent']>>['current'][string];\n"],"mappings":";;;;;;;AAGA,MAAM,iBAAiB,MAAM,CACzB,OAAO,EAAE,OAAO,OAAO,EAAE,CAAC,GAC1B,OAAO,EAAE,QAAQ,OAAO,EAAE,CAAC,CAC/B,CAAC;;;;;;;;;;;;;;;AAgBD,MAAM,cAAc,OAAO;;CAEvB,QAAQ,OAAO;;CAEf,QAAQ,SAAS,QAAQ,CAAC;;CAE1B,eAAe,SAAS,OAAO,CAAC;;CAEhC,OAAO,OAAO;;CAEd,YAAY,OAAO;;CAEnB,SAAS,SAAS,OAAO,CAAC;;CAE1B,YAAY,SAASA,OAAM;EAAC;EAAQ;EAAc;EAAa;CAAY,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,g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AC;;;;;;;;;;;;;;;;;;;;;AAsBD,MAAa,6BAA6B,gBACtC;CACI,IAAI;CACJ,aACI;AAGR,GACA;;CAGI,YAAY,YACR,OAAO,CAAC,CAAC,GACT,OAAO;;;;;;EAMH,WAAW,OAAO,OAAO,GAAG,gBAAgB;;EAE5C,UAAU,OAAO;CACrB,CAAC,CACL,CAAC,CAAC,WAAW,EAAE,QAAQ,OAAO,CAAC,CAAC,EAAE,CAAC;;;;;;CAMnC,cAAc,YACV,OAAO,CAAC,CAAC,GACT,OAAO,CAAC,CAAC,CACb,CAAC,CAAC,WAAW,EAAE,QAAQ,OAAO,CAAC,CAAC,EAAE,CAAC;;CAInC,YAAY,YACR,OAAO,CAAC,CAAC,GACT,OAAO;;EAEH,SAAS,OAAO,OAAO,GAAG,aAAa;;EAEvC,UAAU,OAAO;CACrB,CAAC,CACL;;;;;;;;CAQA,YAAY,YACR,OAAO,EAAE,SAAS,MAAM,cAAc,EAAE,CAAC,GACzC,OAAO,EAAE,UAAU,OAAO,EAAE,CAAC,CACjC,CAAC,CAAC,WAAW,EAAE,QAAQ,OAAO,CAAC,CAAC,EAAE,CAAC;;;;;;CAMnC,cAAc,YACV,OAAO,CAAC,CAAC,GACT,OAAO,CAAC,CAAC,CACb,CAAC,CAAC,WAAW,EAAE,QAAQ,OAAO,CAAC,CAAC,EAAE,CAAC;AACvC,CACJ"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { Hr as SignedCapability, zr as ParamMatcher } from "./linkRpcConnection-Cd_BPueY.js";
5
+ import { Pr as SignedCapability, jr as ParamMatcher } from "./linkRpcConnection-D2UVcoDo.js";
6
6
  //#region src/hub/common/hubAccess.d.ts
7
7
  /**
8
8
  * The client-facing wire shapes of the hub's capability-negotiation protocol
@@ -81,4 +81,4 @@ declare function findCoveringCapabilities(capabilities: readonly SignedCapabilit
81
81
  }): readonly SignedCapability[] | undefined;
82
82
  //#endregion
83
83
  export { HubAccessResult as a, HubAccessRequest as i, HubAccessPattern as n, findCoveringCapabilities as o, HubAccessPermission as r, HubAccessDuration as t };
84
- //# sourceMappingURL=hubAccess-bo3stx2g.d.ts.map
84
+ //# sourceMappingURL=hubAccess-BPQeRMT7.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hubAccess-bo3stx2g.d.ts","names":[],"sources":["../../src/hub/common/hubAccess.ts"],"mappings":";;;;;;;;;;;;;KAsBY;;KAGA;WAA8B;;WAA8B;;;UAGvD;WACJ;aACI,WAAW;aACX,aAAa;aACb;aACA,kBAAkB;;;WAGtB;;WAEA;WACA,SAAS,eAAe;;;UAIpB;WACJ;aAAqB;aAAuB;aAA0B;;;WAEtE,sBAAsB;;WAEtB,WAAW;;;;;;;KAQZ;WAEK;;WAEA,uBAAuB;;WAEvB;;WAEA;WAA2B;;WAC3B;WAAyB;;;;;;;;;;;;;iBAa1B,yBACZ,uBAAuB,oBACvB,oBAAoB,uBACpB;WACa;WACA;;WAEA;aAEL"}
1
+ {"version":3,"file":"hubAccess-BPQeRMT7.d.ts","names":[],"sources":["../../src/hub/common/hubAccess.ts"],"mappings":";;;;;;;;;;;;;KAsBY;;KAGA;WAA8B;;WAA8B;;;UAGvD;WACJ;aACI,WAAW;aACX,aAAa;aACb;aACA,kBAAkB;;;WAGtB;;WAEA;WACA,SAAS,eAAe;;;UAIpB;WACJ;aAAqB;aAAuB;aAA0B;;;WAEtE,sBAAsB;;WAEtB,WAAW;;;;;;;KAQZ;WAEK;;WAEA,uBAAuB;;WAEvB;;WAEA;WAA2B;;WAC3B;WAAyB;;;;;;;;;;;;;iBAa1B,yBACZ,uBAAuB,oBACvB,oBAAoB,uBACpB;WACa;WACA;;WAEA;aAEL"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { r as hubGrantedServiceIdInterface } from "./hub.interfaces-I-GtB1Ah.js";
5
+ import { r as hubGrantedServiceIdInterface } from "./hub.interfaces-BwJQeVWT.js";
6
6
  //#region src/hub/client/hubFacade.ts
7
7
  /**
8
8
  * Thin façade over the hub's own serviceId-routed services
@@ -82,4 +82,4 @@ function hubFromConnection(connection) {
82
82
  //#endregion
83
83
  export { hubFromConnection as n, Hub as t };
84
84
 
85
- //# sourceMappingURL=hubFacade-ClN2ausU.js.map
85
+ //# sourceMappingURL=hubFacade-Cd5Nk-7l.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hubFacade-ClN2ausU.js","names":[],"sources":["../../src/hub/client/hubFacade.ts"],"sourcesContent":["import type { LinkRpcConnection } from '../../connection/linkRpcConnection';\nimport { hubGrantedServiceIdInterface } from '../common/hub.interfaces';\n\n/**\n * Description of the services a consumer will need, presented to the user\n * up-front so access can be approved before the first call. Each named\n * *dependency* (\"slot\") lists the interfaces the chosen service must\n * implement and the members the consumer intends to call.\n */\nexport interface SlotPrerequest {\n readonly consumer: { readonly name: string; readonly purpose: string; };\n readonly dependencies: Readonly<\n Record<string, {\n readonly interfaces: readonly { readonly id: string; }[];\n readonly members: readonly {\n readonly interfaceId: string;\n readonly member: { readonly exact: string; };\n }[];\n }>\n >;\n}\n\n/** Handle for a set of slots reserved via {@link Hub.prerequestSlots}. */\nexport interface SlotReservation {\n /** Resolve the reserved slots into connected service clients. */\n resolve(): Promise<never>;\n}\n\n/**\n * Thin façade over the hub's own serviceId-routed services\n * (`hubGrantedServiceId`, `hubAccess`, …). The hub is not a single object on\n * the wire — it is a set of services the connection can `get`. This groups the\n * common connection calls so callers don't hand-route interface clients.\n */\nexport class Hub {\n constructor(private readonly _connection: LinkRpcConnection) { }\n\n /** `hubGrantedServiceId::get` — where am I and which serviceId namespace may I claim. */\n public getConnectionInfo() {\n return this._connection.get(hubGrantedServiceIdInterface).get({});\n }\n\n /**\n * Reserve the slots a consumer will need so the user can approve them\n * ahead of the first call. NOT YET IMPLEMENTED by the hub — the\n * returned reservation throws on {@link SlotReservation.resolve}.\n */\n public prerequestSlots(_request: SlotPrerequest): SlotReservation {\n return {\n resolve: async (): Promise<never> => {\n throw new Error('not implemented: hub.prerequestSlots / slot resolution');\n },\n };\n }\n\n /**\n * Claim a serviceId namespace for this connection so it may register\n * services under it, via `hubGrantedServiceId::register`.\n *\n * The claim is auto-granted from the connection's provenance when\n * `serviceIdNamespace` is at/under the connection's\n * `grantedServiceIdNamespace` (see {@link getConnectionInfo}) — no\n * signature or capability needed. Claims **outside** the granted namespace\n * are rejected here; route those through the admin-gated\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.\n *\n * Resolves once the namespace is owned by this connection (idempotent for\n * a namespace this connection already owns). Rejects when the hub denies\n * the claim — e.g. the namespace is owned by another identity, or the\n * caller lacks admin authority outside its granted namespace.\n *\n * `requestPermissionIfDenied` is a hint for the future interactive\n * admin-approval flow; the hub does not yet expose one, so denial always\n * surfaces as a rejection regardless of the flag.\n */\n public async registerServiceIdNamespace(\n serviceIdNamespace: string,\n _opts?: { readonly requestPermissionIfDenied?: boolean; },\n ): Promise<void> {\n await this._connection\n .get(hubGrantedServiceIdInterface)\n .register({ serviceId: serviceIdNamespace });\n }\n\n /**\n * Claim this connection's provenance-granted serviceId namespace in one\n * step: read `grantedServiceIdNamespace` via {@link getConnectionInfo},\n * then {@link registerServiceIdNamespace} it, returning the claimed\n * `serviceId` so the caller can mount services under it.\n *\n * This is the batteries-included version of the\n * `hubGrantedServiceId::get` → `hubGrantedServiceId::register` dance a\n * service-exposing participant performs right after connecting.\n *\n * Throws when the hub granted this connection no namespace (an empty\n * `grantedServiceIdNamespace`, meaning \"claim nothing freely\") — there is\n * nothing to register, and any service prefix would have to be claimed\n * through the admin-gated\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.\n */\n public async claimGrantedServiceIdNamespace(): Promise<{ readonly serviceId: string; }> {\n const { grantedServiceIdNamespace } = await this.getConnectionInfo();\n if (!grantedServiceIdNamespace) {\n throw new Error(\n 'hubGrantedServiceId::get returned an empty granted namespace; ' +\n 'nothing to claim (register a prefix through the admin-gated ' +\n 'hubServiceIdRegistry::registerServiceId door instead)',\n );\n }\n await this.registerServiceIdNamespace(grantedServiceIdNamespace);\n return { serviceId: grantedServiceIdNamespace };\n }\n}\n\n/** Wrap a connection in a {@link Hub} façade. */\nexport function hubFromConnection(connection: LinkRpcConnection): Hub {\n return new Hub(connection);\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,IAAa,MAAb,MAAiB;CACgB;CAA7B,YAAY,aAAiD;EAAhC,KAAA,cAAA;CAAkC;;CAG/D,oBAA2B;EACvB,OAAO,KAAK,YAAY,IAAI,4BAA4B,CAAC,CAAC,IAAI,CAAC,CAAC;CACpE;;;;;;CAOA,gBAAuB,UAA2C;EAC9D,OAAO,EACH,SAAS,YAA4B;GACjC,MAAM,IAAI,MAAM,wDAAwD;EAC5E,EACJ;CACJ;;;;;;;;;;;;;;;;;;;;;CAsBA,MAAa,2BACT,oBACA,OACa;EACb,MAAM,KAAK,YACN,IAAI,4BAA4B,CAAC,CACjC,SAAS,EAAE,WAAW,mBAAmB,CAAC;CACnD;;;;;;;;;;;;;;;;;CAkBA,MAAa,iCAA2E;EACpF,MAAM,EAAE,8BAA8B,MAAM,KAAK,kBAAkB;EACnE,IAAI,CAAC,2BACD,MAAM,IAAI,MACN,iLAGJ;EAEJ,MAAM,KAAK,2BAA2B,yBAAyB;EAC/D,OAAO,EAAE,WAAW,0BAA0B;CAClD;AACJ;;AAGA,SAAgB,kBAAkB,YAAoC;CAClE,OAAO,IAAI,IAAI,UAAU;AAC7B"}
1
+ {"version":3,"file":"hubFacade-Cd5Nk-7l.js","names":[],"sources":["../../src/hub/client/hubFacade.ts"],"sourcesContent":["import type { LinkRpcConnection } from '../../connection/linkRpcConnection';\nimport { hubGrantedServiceIdInterface } from '../common/hub.interfaces';\n\n/**\n * Description of the services a consumer will need, presented to the user\n * up-front so access can be approved before the first call. Each named\n * *dependency* (\"slot\") lists the interfaces the chosen service must\n * implement and the members the consumer intends to call.\n */\nexport interface SlotPrerequest {\n readonly consumer: { readonly name: string; readonly purpose: string; };\n readonly dependencies: Readonly<\n Record<string, {\n readonly interfaces: readonly { readonly id: string; }[];\n readonly members: readonly {\n readonly interfaceId: string;\n readonly member: { readonly exact: string; };\n }[];\n }>\n >;\n}\n\n/** Handle for a set of slots reserved via {@link Hub.prerequestSlots}. */\nexport interface SlotReservation {\n /** Resolve the reserved slots into connected service clients. */\n resolve(): Promise<never>;\n}\n\n/**\n * Thin façade over the hub's own serviceId-routed services\n * (`hubGrantedServiceId`, `hubAccess`, …). The hub is not a single object on\n * the wire — it is a set of services the connection can `get`. This groups the\n * common connection calls so callers don't hand-route interface clients.\n */\nexport class Hub {\n constructor(private readonly _connection: LinkRpcConnection) { }\n\n /** `hubGrantedServiceId::get` — where am I and which serviceId namespace may I claim. */\n public getConnectionInfo() {\n return this._connection.get(hubGrantedServiceIdInterface).get({});\n }\n\n /**\n * Reserve the slots a consumer will need so the user can approve them\n * ahead of the first call. NOT YET IMPLEMENTED by the hub — the\n * returned reservation throws on {@link SlotReservation.resolve}.\n */\n public prerequestSlots(_request: SlotPrerequest): SlotReservation {\n return {\n resolve: async (): Promise<never> => {\n throw new Error('not implemented: hub.prerequestSlots / slot resolution');\n },\n };\n }\n\n /**\n * Claim a serviceId namespace for this connection so it may register\n * services under it, via `hubGrantedServiceId::register`.\n *\n * The claim is auto-granted from the connection's provenance when\n * `serviceIdNamespace` is at/under the connection's\n * `grantedServiceIdNamespace` (see {@link getConnectionInfo}) — no\n * signature or capability needed. Claims **outside** the granted namespace\n * are rejected here; route those through the admin-gated\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.\n *\n * Resolves once the namespace is owned by this connection (idempotent for\n * a namespace this connection already owns). Rejects when the hub denies\n * the claim — e.g. the namespace is owned by another identity, or the\n * caller lacks admin authority outside its granted namespace.\n *\n * `requestPermissionIfDenied` is a hint for the future interactive\n * admin-approval flow; the hub does not yet expose one, so denial always\n * surfaces as a rejection regardless of the flag.\n */\n public async registerServiceIdNamespace(\n serviceIdNamespace: string,\n _opts?: { readonly requestPermissionIfDenied?: boolean; },\n ): Promise<void> {\n await this._connection\n .get(hubGrantedServiceIdInterface)\n .register({ serviceId: serviceIdNamespace });\n }\n\n /**\n * Claim this connection's provenance-granted serviceId namespace in one\n * step: read `grantedServiceIdNamespace` via {@link getConnectionInfo},\n * then {@link registerServiceIdNamespace} it, returning the claimed\n * `serviceId` so the caller can mount services under it.\n *\n * This is the batteries-included version of the\n * `hubGrantedServiceId::get` → `hubGrantedServiceId::register` dance a\n * service-exposing participant performs right after connecting.\n *\n * Throws when the hub granted this connection no namespace (an empty\n * `grantedServiceIdNamespace`, meaning \"claim nothing freely\") — there is\n * nothing to register, and any service prefix would have to be claimed\n * through the admin-gated\n * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.\n */\n public async claimGrantedServiceIdNamespace(): Promise<{ readonly serviceId: string; }> {\n const { grantedServiceIdNamespace } = await this.getConnectionInfo();\n if (!grantedServiceIdNamespace) {\n throw new Error(\n 'hubGrantedServiceId::get returned an empty granted namespace; ' +\n 'nothing to claim (register a prefix through the admin-gated ' +\n 'hubServiceIdRegistry::registerServiceId door instead)',\n );\n }\n await this.registerServiceIdNamespace(grantedServiceIdNamespace);\n return { serviceId: grantedServiceIdNamespace };\n }\n}\n\n/** Wrap a connection in a {@link Hub} façade. */\nexport function hubFromConnection(connection: LinkRpcConnection): Hub {\n return new Hub(connection);\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,IAAa,MAAb,MAAiB;CACgB;CAA7B,YAAY,aAAiD;EAAhC,KAAA,cAAA;CAAkC;;CAG/D,oBAA2B;EACvB,OAAO,KAAK,YAAY,IAAI,4BAA4B,CAAC,CAAC,IAAI,CAAC,CAAC;CACpE;;;;;;CAOA,gBAAuB,UAA2C;EAC9D,OAAO,EACH,SAAS,YAA4B;GACjC,MAAM,IAAI,MAAM,wDAAwD;EAC5E,EACJ;CACJ;;;;;;;;;;;;;;;;;;;;;CAsBA,MAAa,2BACT,oBACA,OACa;EACb,MAAM,KAAK,YACN,IAAI,4BAA4B,CAAC,CACjC,SAAS,EAAE,WAAW,mBAAmB,CAAC;CACnD;;;;;;;;;;;;;;;;;CAkBA,MAAa,iCAA2E;EACpF,MAAM,EAAE,8BAA8B,MAAM,KAAK,kBAAkB;EACnE,IAAI,CAAC,2BACD,MAAM,IAAI,MACN,iLAGJ;EAEJ,MAAM,KAAK,2BAA2B,yBAAyB;EAC/D,OAAO,EAAE,WAAW,0BAA0B;CAClD;AACJ;;AAGA,SAAgB,kBAAkB,YAAoC;CAClE,OAAO,IAAI,IAAI,UAAU;AAC7B"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { a as LinkRpcConnection } from "./linkRpcConnection-Cd_BPueY.js";
5
+ import { a as LinkRpcConnection } from "./linkRpcConnection-D2UVcoDo.js";
6
6
  //#region src/hub/client/hubFacade.d.ts
7
7
  /**
8
8
  * Description of the services a consumer will need, presented to the user
@@ -98,4 +98,4 @@ declare class Hub {
98
98
  declare function hubFromConnection(connection: LinkRpcConnection): Hub;
99
99
  //#endregion
100
100
  export { hubFromConnection as i, SlotPrerequest as n, SlotReservation as r, Hub as t };
101
- //# sourceMappingURL=hubFacade-tTbu49Be.d.ts.map
101
+ //# sourceMappingURL=hubFacade-CwCzQ_jt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hubFacade-tTbu49Be.d.ts","names":[],"sources":["../../src/hub/client/hubFacade.ts"],"mappings":";;;;;;;;;;;;UASiB;WACJ;aAAqB;aAAuB;;WAC5C,cAAc,SACnB;aACa;eAAgC;;aAChC;eACI;eACA;iBAAmB;;;;;;UAO3B;;EAEb,WAAW;;;;;;;;cASF;mBACoB;EAAA,YAAA,aAAa;;EAGnC,qBAAiB;;;;;;;;EASjB,gBAAgB,UAAU,iBAAiB;;;;;;;;;;;;;;;;;;;;;EA4BrC,2BACT,4BACA;aAAmB;MACpB;;;;;;;;;;;;;;;;;EAsBU,kCAAkC;aAAmB;;;;iBAetD,kBAAkB,YAAY,oBAAoB"}
1
+ {"version":3,"file":"hubFacade-CwCzQ_jt.d.ts","names":[],"sources":["../../src/hub/client/hubFacade.ts"],"mappings":";;;;;;;;;;;;UASiB;WACJ;aAAqB;aAAuB;;WAC5C,cAAc,SACnB;aACa;eAAgC;;aAChC;eACI;eACA;iBAAmB;;;;;;UAO3B;;EAEb,WAAW;;;;;;;;cASF;mBACoB;EAAA,YAAA,aAAa;;EAGnC,qBAAiB;;;;;;;;EASjB,gBAAgB,UAAU,iBAAiB;;;;;;;;;;;;;;;;;;;;;EA4BrC,2BACT,4BACA;aAAmB;MACpB;;;;;;;;;;;;;;;;;EAsBU,kCAAkC;aAAmB;;;;iBAetD,kBAAkB,YAAY,oBAAoB"}