@hediet/linkrpc 0.0.1

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 (39) hide show
  1. package/README.md +383 -0
  2. package/dist/chunks/_empty-crypto-Bi0tGx5K.js +8 -0
  3. package/dist/chunks/boundedTrafficSubscription-1L592xc7.js +1126 -0
  4. package/dist/chunks/boundedTrafficSubscription-1L592xc7.js.map +1 -0
  5. package/dist/chunks/hub.interfaces-BzWfsVT2.js +526 -0
  6. package/dist/chunks/hub.interfaces-BzWfsVT2.js.map +1 -0
  7. package/dist/chunks/hubAccess-DwTZPiI8.d.ts +79 -0
  8. package/dist/chunks/hubAccess-DwTZPiI8.d.ts.map +1 -0
  9. package/dist/chunks/hubFacade-CQflVkVC.js +85 -0
  10. package/dist/chunks/hubFacade-CQflVkVC.js.map +1 -0
  11. package/dist/chunks/hubFacade-Dkgw2pTi.d.ts +101 -0
  12. package/dist/chunks/hubFacade-Dkgw2pTi.d.ts.map +1 -0
  13. package/dist/chunks/linkRpcConnection-CtlQmetO.d.ts +3623 -0
  14. package/dist/chunks/linkRpcConnection-CtlQmetO.d.ts.map +1 -0
  15. package/dist/chunks/rolldown-runtime-4LSo1kEK.js +17 -0
  16. package/dist/chunks/src-D3NUIwyo.js +7795 -0
  17. package/dist/chunks/src-D3NUIwyo.js.map +1 -0
  18. package/dist/hub/client/index.d.ts +50 -0
  19. package/dist/hub/client/index.d.ts.map +1 -0
  20. package/dist/hub/client/index.js +97 -0
  21. package/dist/hub/client/index.js.map +1 -0
  22. package/dist/hub/common/index.d.ts +1189 -0
  23. package/dist/hub/common/index.d.ts.map +1 -0
  24. package/dist/hub/common/index.js +267 -0
  25. package/dist/hub/common/index.js.map +1 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/index.js +7 -0
  28. package/dist/inspection/index.d.ts +66 -0
  29. package/dist/inspection/index.d.ts.map +1 -0
  30. package/dist/inspection/index.js +6 -0
  31. package/dist/node.d.ts +548 -0
  32. package/dist/node.d.ts.map +1 -0
  33. package/dist/node.js +1087 -0
  34. package/dist/node.js.map +1 -0
  35. package/dist/web.d.ts +44 -0
  36. package/dist/web.d.ts.map +1 -0
  37. package/dist/web.js +58 -0
  38. package/dist/web.js.map +1 -0
  39. package/package.json +59 -0
@@ -0,0 +1,79 @@
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
+ import { Pn as SignedCapability } from "./linkRpcConnection-CtlQmetO.js";
6
+ //#region src/hub/common/hubAccess.d.ts
7
+ /**
8
+ * The client-facing wire shapes of the hub's capability-negotiation protocol
9
+ * (`hubAccess::requestAccess`, see {@link hubAccessInterface}). Any hub client —
10
+ * the CLI, the MCP server, or an embedder — speaks these shapes to ask a hub
11
+ * for authority in a single consent prompt.
12
+ */
13
+ /** How long a granted capability should live. */
14
+ type HubAccessDuration = 'once' | 'shortLived' | 'longLived' | 'persistent';
15
+ /** A `serviceId` / `interfaceId` / member matcher (wire shape of `TargetPattern`). */
16
+ type HubAccessPattern = {
17
+ readonly exact: string;
18
+ } | {
19
+ readonly prefix: string;
20
+ };
21
+ /** One authority the consumer wants — the wire shape of a `requestAccess` permission. */
22
+ interface HubAccessPermission {
23
+ readonly target: {
24
+ readonly serviceId: HubAccessPattern;
25
+ readonly interfaceId: HubAccessPattern;
26
+ readonly interfaceHash?: string;
27
+ readonly members: readonly HubAccessPattern[];
28
+ };
29
+ /** Default false (fail closed). Set true to actually call the members. */
30
+ readonly canInvoke?: boolean;
31
+ /** Default false. Set true to let the consumer re-delegate this authority. */
32
+ readonly canDelegate?: boolean;
33
+ readonly params?: Record<string, unknown>;
34
+ }
35
+ /** A batched, explicit access request — possibly many permissions in one prompt. */
36
+ interface HubAccessRequest {
37
+ readonly consumer: {
38
+ readonly name: string;
39
+ readonly origin?: string;
40
+ readonly purpose?: string;
41
+ };
42
+ /** One or more authorities to request together (single consent prompt). */
43
+ readonly permissions: readonly HubAccessPermission[];
44
+ /** `once` (short-lived), `session` (this connection), or `persistent` (saved). */
45
+ readonly duration?: HubAccessDuration;
46
+ }
47
+ /**
48
+ * Outcome of a `requestAccess` call. `granted` carries every capability the hub
49
+ * minted plus how many of them were durable and added to the connection's cap
50
+ * bag (a client-side augmentation over the pure wire result).
51
+ */
52
+ type HubAccessResult = {
53
+ readonly status: 'granted';
54
+ /** Every capability the hub minted for this request. */
55
+ readonly capabilities: readonly SignedCapability[];
56
+ /** How many of them were durable and added to the connection's cap bag. */
57
+ readonly addedDurable: number;
58
+ } | {
59
+ readonly status: 'denied';
60
+ readonly reason?: string;
61
+ } | {
62
+ readonly status: string;
63
+ readonly reason?: string;
64
+ };
65
+ /**
66
+ * Return fresh durable capabilities that collectively cover an explicit access
67
+ * request, or `undefined` when the caller must ask the hub for more authority.
68
+ *
69
+ * This is the broad-request counterpart to checking whether a cap bag covers
70
+ * one concrete call. Clients use it before opening consent so persisted grants
71
+ * are reused without weakening any service/interface/member pattern.
72
+ */
73
+ declare function findCoveringCapabilities(capabilities: readonly SignedCapability[], requested: readonly HubAccessPermission[], options?: {
74
+ readonly nowMs?: number;
75
+ readonly freshnessMarginMs?: number;
76
+ }): readonly SignedCapability[] | undefined;
77
+ //#endregion
78
+ export { HubAccessResult as a, HubAccessRequest as i, HubAccessPattern as n, findCoveringCapabilities as o, HubAccessPermission as r, HubAccessDuration as t };
79
+ //# sourceMappingURL=hubAccess-DwTZPiI8.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubAccess-DwTZPiI8.d.ts","names":[],"sources":["../../src/hub/common/hubAccess.ts"],"mappings":";;;;;;;;;;;;;KAqBY;;KAGA;WAA8B;;WAA8B;;;UAGvD;WACJ;aACI,WAAW;aACX,aAAa;aACb;aACA,kBAAkB;;;WAGtB;;WAEA;WACA,SAAS;;;UAIL;WACJ;aAAqB;aAAuB;aAA0B;;;WAEtE,sBAAsB;;WAEtB,WAAW;;;;;;;KAQZ;WAEK;;WAEA,uBAAuB;;WAEvB;;WAEA;WAA2B;;WAC3B;WAAyB;;;;;;;;;;iBAU1B,yBACZ,uBAAuB,oBACvB,oBAAoB,uBACpB;WACa;WACA;aAEL"}
@@ -0,0 +1,85 @@
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
+ import { r as hubGrantedServiceIdInterface } from "./hub.interfaces-BzWfsVT2.js";
6
+ //#region src/hub/client/hubFacade.ts
7
+ /**
8
+ * Thin façade over the hub's own serviceId-routed services
9
+ * (`hubGrantedServiceId`, `hubAccess`, …). The hub is not a single object on
10
+ * the wire — it is a set of services the connection can `get`. This groups the
11
+ * common connection calls so callers don't hand-route interface clients.
12
+ */
13
+ var Hub = class {
14
+ _connection;
15
+ constructor(_connection) {
16
+ this._connection = _connection;
17
+ }
18
+ /** `hubGrantedServiceId::get` — where am I and which serviceId namespace may I claim. */
19
+ getConnectionInfo() {
20
+ return this._connection.get(hubGrantedServiceIdInterface).get({});
21
+ }
22
+ /**
23
+ * Reserve the slots a consumer will need so the user can approve them
24
+ * ahead of the first call. NOT YET IMPLEMENTED by the hub — the
25
+ * returned reservation throws on {@link SlotReservation.resolve}.
26
+ */
27
+ prerequestSlots(_request) {
28
+ return { resolve: async () => {
29
+ throw new Error("not implemented: hub.prerequestSlots / slot resolution");
30
+ } };
31
+ }
32
+ /**
33
+ * Claim a serviceId namespace for this connection so it may register
34
+ * services under it, via `hubGrantedServiceId::register`.
35
+ *
36
+ * The claim is auto-granted from the connection's provenance when
37
+ * `serviceIdNamespace` is at/under the connection's
38
+ * `grantedServiceIdNamespace` (see {@link getConnectionInfo}) — no
39
+ * signature or capability needed. Claims **outside** the granted namespace
40
+ * are rejected here; route those through the admin-gated
41
+ * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.
42
+ *
43
+ * Resolves once the namespace is owned by this connection (idempotent for
44
+ * a namespace this connection already owns). Rejects when the hub denies
45
+ * the claim — e.g. the namespace is owned by another identity, or the
46
+ * caller lacks admin authority outside its granted namespace.
47
+ *
48
+ * `requestPermissionIfDenied` is a hint for the future interactive
49
+ * admin-approval flow; the hub does not yet expose one, so denial always
50
+ * surfaces as a rejection regardless of the flag.
51
+ */
52
+ async registerServiceIdNamespace(serviceIdNamespace, _opts) {
53
+ await this._connection.get(hubGrantedServiceIdInterface).register({ serviceId: serviceIdNamespace });
54
+ }
55
+ /**
56
+ * Claim this connection's provenance-granted serviceId namespace in one
57
+ * step: read `grantedServiceIdNamespace` via {@link getConnectionInfo},
58
+ * then {@link registerServiceIdNamespace} it, returning the claimed
59
+ * `serviceId` so the caller can mount services under it.
60
+ *
61
+ * This is the batteries-included version of the
62
+ * `hubGrantedServiceId::get` → `hubGrantedServiceId::register` dance a
63
+ * service-exposing participant performs right after connecting.
64
+ *
65
+ * Throws when the hub granted this connection no namespace (an empty
66
+ * `grantedServiceIdNamespace`, meaning "claim nothing freely") — there is
67
+ * nothing to register, and any service prefix would have to be claimed
68
+ * through the admin-gated
69
+ * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.
70
+ */
71
+ async claimGrantedServiceIdNamespace() {
72
+ const { grantedServiceIdNamespace } = await this.getConnectionInfo();
73
+ if (!grantedServiceIdNamespace) throw new Error("hubGrantedServiceId::get returned an empty granted namespace; nothing to claim (register a prefix through the admin-gated hubServiceIdRegistry::registerServiceId door instead)");
74
+ await this.registerServiceIdNamespace(grantedServiceIdNamespace);
75
+ return { serviceId: grantedServiceIdNamespace };
76
+ }
77
+ };
78
+ /** Wrap a connection in a {@link Hub} façade. */
79
+ function hubFromConnection(connection) {
80
+ return new Hub(connection);
81
+ }
82
+ //#endregion
83
+ export { hubFromConnection as n, Hub as t };
84
+
85
+ //# sourceMappingURL=hubFacade-CQflVkVC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubFacade-CQflVkVC.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"}
@@ -0,0 +1,101 @@
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
+ import { a as LinkRpcConnection } from "./linkRpcConnection-CtlQmetO.js";
6
+ //#region src/hub/client/hubFacade.d.ts
7
+ /**
8
+ * Description of the services a consumer will need, presented to the user
9
+ * up-front so access can be approved before the first call. Each named
10
+ * *dependency* ("slot") lists the interfaces the chosen service must
11
+ * implement and the members the consumer intends to call.
12
+ */
13
+ interface SlotPrerequest {
14
+ readonly consumer: {
15
+ readonly name: string;
16
+ readonly purpose: string;
17
+ };
18
+ readonly dependencies: Readonly<Record<string, {
19
+ readonly interfaces: readonly {
20
+ readonly id: string;
21
+ }[];
22
+ readonly members: readonly {
23
+ readonly interfaceId: string;
24
+ readonly member: {
25
+ readonly exact: string;
26
+ };
27
+ }[];
28
+ }>>;
29
+ }
30
+ /** Handle for a set of slots reserved via {@link Hub.prerequestSlots}. */
31
+ interface SlotReservation {
32
+ /** Resolve the reserved slots into connected service clients. */
33
+ resolve(): Promise<never>;
34
+ }
35
+ /**
36
+ * Thin façade over the hub's own serviceId-routed services
37
+ * (`hubGrantedServiceId`, `hubAccess`, …). The hub is not a single object on
38
+ * the wire — it is a set of services the connection can `get`. This groups the
39
+ * common connection calls so callers don't hand-route interface clients.
40
+ */
41
+ declare class Hub {
42
+ private readonly _connection;
43
+ constructor(_connection: LinkRpcConnection);
44
+ /** `hubGrantedServiceId::get` — where am I and which serviceId namespace may I claim. */
45
+ getConnectionInfo(): Promise<{
46
+ grantedServiceIdNamespace: string;
47
+ }>;
48
+ /**
49
+ * Reserve the slots a consumer will need so the user can approve them
50
+ * ahead of the first call. NOT YET IMPLEMENTED by the hub — the
51
+ * returned reservation throws on {@link SlotReservation.resolve}.
52
+ */
53
+ prerequestSlots(_request: SlotPrerequest): SlotReservation;
54
+ /**
55
+ * Claim a serviceId namespace for this connection so it may register
56
+ * services under it, via `hubGrantedServiceId::register`.
57
+ *
58
+ * The claim is auto-granted from the connection's provenance when
59
+ * `serviceIdNamespace` is at/under the connection's
60
+ * `grantedServiceIdNamespace` (see {@link getConnectionInfo}) — no
61
+ * signature or capability needed. Claims **outside** the granted namespace
62
+ * are rejected here; route those through the admin-gated
63
+ * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.
64
+ *
65
+ * Resolves once the namespace is owned by this connection (idempotent for
66
+ * a namespace this connection already owns). Rejects when the hub denies
67
+ * the claim — e.g. the namespace is owned by another identity, or the
68
+ * caller lacks admin authority outside its granted namespace.
69
+ *
70
+ * `requestPermissionIfDenied` is a hint for the future interactive
71
+ * admin-approval flow; the hub does not yet expose one, so denial always
72
+ * surfaces as a rejection regardless of the flag.
73
+ */
74
+ registerServiceIdNamespace(serviceIdNamespace: string, _opts?: {
75
+ readonly requestPermissionIfDenied?: boolean;
76
+ }): Promise<void>;
77
+ /**
78
+ * Claim this connection's provenance-granted serviceId namespace in one
79
+ * step: read `grantedServiceIdNamespace` via {@link getConnectionInfo},
80
+ * then {@link registerServiceIdNamespace} it, returning the claimed
81
+ * `serviceId` so the caller can mount services under it.
82
+ *
83
+ * This is the batteries-included version of the
84
+ * `hubGrantedServiceId::get` → `hubGrantedServiceId::register` dance a
85
+ * service-exposing participant performs right after connecting.
86
+ *
87
+ * Throws when the hub granted this connection no namespace (an empty
88
+ * `grantedServiceIdNamespace`, meaning "claim nothing freely") — there is
89
+ * nothing to register, and any service prefix would have to be claimed
90
+ * through the admin-gated
91
+ * `<hubServiceId>::hubServiceIdRegistry::registerServiceId` door instead.
92
+ */
93
+ claimGrantedServiceIdNamespace(): Promise<{
94
+ readonly serviceId: string;
95
+ }>;
96
+ }
97
+ /** Wrap a connection in a {@link Hub} façade. */
98
+ declare function hubFromConnection(connection: LinkRpcConnection): Hub;
99
+ //#endregion
100
+ export { hubFromConnection as i, SlotPrerequest as n, SlotReservation as r, Hub as t };
101
+ //# sourceMappingURL=hubFacade-Dkgw2pTi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubFacade-Dkgw2pTi.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"}