@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.
- package/README.md +383 -0
- package/dist/chunks/_empty-crypto-Bi0tGx5K.js +8 -0
- package/dist/chunks/boundedTrafficSubscription-1L592xc7.js +1126 -0
- package/dist/chunks/boundedTrafficSubscription-1L592xc7.js.map +1 -0
- package/dist/chunks/hub.interfaces-BzWfsVT2.js +526 -0
- package/dist/chunks/hub.interfaces-BzWfsVT2.js.map +1 -0
- package/dist/chunks/hubAccess-DwTZPiI8.d.ts +79 -0
- package/dist/chunks/hubAccess-DwTZPiI8.d.ts.map +1 -0
- package/dist/chunks/hubFacade-CQflVkVC.js +85 -0
- package/dist/chunks/hubFacade-CQflVkVC.js.map +1 -0
- package/dist/chunks/hubFacade-Dkgw2pTi.d.ts +101 -0
- package/dist/chunks/hubFacade-Dkgw2pTi.d.ts.map +1 -0
- package/dist/chunks/linkRpcConnection-CtlQmetO.d.ts +3623 -0
- package/dist/chunks/linkRpcConnection-CtlQmetO.d.ts.map +1 -0
- package/dist/chunks/rolldown-runtime-4LSo1kEK.js +17 -0
- package/dist/chunks/src-D3NUIwyo.js +7795 -0
- package/dist/chunks/src-D3NUIwyo.js.map +1 -0
- package/dist/hub/client/index.d.ts +50 -0
- package/dist/hub/client/index.d.ts.map +1 -0
- package/dist/hub/client/index.js +97 -0
- package/dist/hub/client/index.js.map +1 -0
- package/dist/hub/common/index.d.ts +1189 -0
- package/dist/hub/common/index.d.ts.map +1 -0
- package/dist/hub/common/index.js +267 -0
- package/dist/hub/common/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/inspection/index.d.ts +66 -0
- package/dist/inspection/index.d.ts.map +1 -0
- package/dist/inspection/index.js +6 -0
- package/dist/node.d.ts +548 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +1087 -0
- package/dist/node.js.map +1 -0
- package/dist/web.d.ts +44 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +58 -0
- package/dist/web.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,50 @@
|
|
|
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 { Ca as JsonValue, Jt as IRequestSender, K as Principal, Pn as SignedCapability, Qt as RawStreamingCall, V as SigningCallCtx, an as IMessageTransport, nn as StreamSendOpts, tn as SendOpts, vt as PublicSigningIdentity } from "../../chunks/linkRpcConnection-CtlQmetO.js";
|
|
6
|
+
import { i as hubFromConnection, n as SlotPrerequest, r as SlotReservation, t as Hub } from "../../chunks/hubFacade-Dkgw2pTi.js";
|
|
7
|
+
import { a as HubAccessResult, i as HubAccessRequest } from "../../chunks/hubAccess-DwTZPiI8.js";
|
|
8
|
+
//#region src/hub/client/hubSigningSender.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* The single connection handle a hub client consumes: a signing request
|
|
11
|
+
* sender (every outbound call is wrapped in a `$hubrpc` signed envelope by the
|
|
12
|
+
* principal) that also surfaces the principal's public identity and its grants.
|
|
13
|
+
*
|
|
14
|
+
* It IS the channel — `sendRequest("svc::iface::member", params)` routes a
|
|
15
|
+
* form-3 hub call. The {@link Principal}'s `capBag` is the live grant list:
|
|
16
|
+
* {@link listGrants} returns its snapshot and {@link requestAccess} grows it.
|
|
17
|
+
*
|
|
18
|
+
* Construct with {@link HubSigningSender.create} from any transport whose peer
|
|
19
|
+
* is (or routes to) a hub — a socket, a websocket, or an in-memory
|
|
20
|
+
* {@link import('@hediet/linkrpc-hub/hub/server').Hub} link.
|
|
21
|
+
*/
|
|
22
|
+
declare class HubSigningSender implements IRequestSender<SigningCallCtx> {
|
|
23
|
+
private readonly _inner;
|
|
24
|
+
private readonly _principal;
|
|
25
|
+
/**
|
|
26
|
+
* Wrap `transport` in a JSON-RPC channel + signing sender bound to
|
|
27
|
+
* `principal`.
|
|
28
|
+
*/
|
|
29
|
+
static create(transport: IMessageTransport, principal: Principal): HubSigningSender;
|
|
30
|
+
private constructor();
|
|
31
|
+
/** Public identity (nodeId) this connection signs as. Never exposes keys. */
|
|
32
|
+
get identity(): PublicSigningIdentity;
|
|
33
|
+
/** Snapshot of the durable capabilities currently held (the cap bag). */
|
|
34
|
+
listGrants(): readonly SignedCapability[];
|
|
35
|
+
/**
|
|
36
|
+
* Request capabilities from the hub through the same signed connection:
|
|
37
|
+
* a `hubAccess::requestAccess` call served at the connection root (never
|
|
38
|
+
* forwarded → never gated, so no `hubAccess` bootstrap cap is needed). Any
|
|
39
|
+
* durable (non-one-shot) caps the hub mints join the principal's cap bag, so
|
|
40
|
+
* subsequent signed calls present them automatically.
|
|
41
|
+
*/
|
|
42
|
+
requestAccess(req: HubAccessRequest): Promise<HubAccessResult>;
|
|
43
|
+
sendRequest(method: string, params: JsonValue | undefined, opts?: SendOpts<SigningCallCtx>): Promise<JsonValue>;
|
|
44
|
+
sendNotification(method: string, params: JsonValue | undefined, opts?: SendOpts<SigningCallCtx>): Promise<void>;
|
|
45
|
+
sendRequestWithStream(method: string, params: JsonValue | undefined, opts?: StreamSendOpts<SigningCallCtx>): RawStreamingCall;
|
|
46
|
+
close(): void;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { Hub, HubSigningSender, type SlotPrerequest, type SlotReservation, hubFromConnection };
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/hub/client/hubSigningSender.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;cAmCa,4BAA4B,eAAe;mBAc/B;mBACA;;;;;SAVP,OACV,WAAW,mBACX,WAAW,YACZ;UAKI;;MAMI,YAAY;;EAKhB,uBAAuB;;;;;;;;EAWjB,cAAc,KAAK,mBAAmB,QAAQ;EAiBpD,YAAY,gBAAgB,QAAQ,uBAAuB,OAAO,SAAS,kBAAkB,QAAQ;EAIrG,iBAAiB,gBAAgB,QAAQ,uBAAuB,OAAO,SAAS,kBAAkB;EAIlG,sBAAsB,gBAAgB,QAAQ,uBAAuB,OAAO,eAAe,kBAAkB;EAI7G"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 { H as JsonRpcChannel, m as SigningSender } from "../../chunks/src-D3NUIwyo.js";
|
|
6
|
+
import { t as hubAccessInterface } from "../../chunks/hub.interfaces-BzWfsVT2.js";
|
|
7
|
+
import { n as hubFromConnection, t as Hub } from "../../chunks/hubFacade-CQflVkVC.js";
|
|
8
|
+
//#region src/hub/client/hubSigningSender.ts
|
|
9
|
+
/**
|
|
10
|
+
* The single connection handle a hub client consumes: a signing request
|
|
11
|
+
* sender (every outbound call is wrapped in a `$hubrpc` signed envelope by the
|
|
12
|
+
* principal) that also surfaces the principal's public identity and its grants.
|
|
13
|
+
*
|
|
14
|
+
* It IS the channel — `sendRequest("svc::iface::member", params)` routes a
|
|
15
|
+
* form-3 hub call. The {@link Principal}'s `capBag` is the live grant list:
|
|
16
|
+
* {@link listGrants} returns its snapshot and {@link requestAccess} grows it.
|
|
17
|
+
*
|
|
18
|
+
* Construct with {@link HubSigningSender.create} from any transport whose peer
|
|
19
|
+
* is (or routes to) a hub — a socket, a websocket, or an in-memory
|
|
20
|
+
* {@link import('@hediet/linkrpc-hub/hub/server').Hub} link.
|
|
21
|
+
*/
|
|
22
|
+
var HubSigningSender = class HubSigningSender {
|
|
23
|
+
_inner;
|
|
24
|
+
_principal;
|
|
25
|
+
/**
|
|
26
|
+
* Wrap `transport` in a JSON-RPC channel + signing sender bound to
|
|
27
|
+
* `principal`.
|
|
28
|
+
*/
|
|
29
|
+
static create(transport, principal) {
|
|
30
|
+
const signed = SigningSender.wrapChannel(JsonRpcChannel.create(transport), { principal });
|
|
31
|
+
return new HubSigningSender(signed.sender, principal);
|
|
32
|
+
}
|
|
33
|
+
constructor(_inner, _principal) {
|
|
34
|
+
this._inner = _inner;
|
|
35
|
+
this._principal = _principal;
|
|
36
|
+
}
|
|
37
|
+
/** Public identity (nodeId) this connection signs as. Never exposes keys. */
|
|
38
|
+
get identity() {
|
|
39
|
+
return this._principal.identity.publicSigningIdentity;
|
|
40
|
+
}
|
|
41
|
+
/** Snapshot of the durable capabilities currently held (the cap bag). */
|
|
42
|
+
listGrants() {
|
|
43
|
+
return this._principal.capBag.capabilities;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Request capabilities from the hub through the same signed connection:
|
|
47
|
+
* a `hubAccess::requestAccess` call served at the connection root (never
|
|
48
|
+
* forwarded → never gated, so no `hubAccess` bootstrap cap is needed). Any
|
|
49
|
+
* durable (non-one-shot) caps the hub mints join the principal's cap bag, so
|
|
50
|
+
* subsequent signed calls present them automatically.
|
|
51
|
+
*/
|
|
52
|
+
async requestAccess(req) {
|
|
53
|
+
const method = `${hubAccessInterface.info.id}::requestAccess`;
|
|
54
|
+
const result = await this._inner.sendRequest(method, {
|
|
55
|
+
consumer: {
|
|
56
|
+
...req.consumer,
|
|
57
|
+
principal: this._principal.id
|
|
58
|
+
},
|
|
59
|
+
permissions: req.permissions,
|
|
60
|
+
...req.duration !== void 0 ? { duration: req.duration } : {}
|
|
61
|
+
});
|
|
62
|
+
if (result.status === "granted") {
|
|
63
|
+
const capabilities = result.capabilities ?? [];
|
|
64
|
+
const durable = capabilities.filter((c) => !_isOneShotCap(c));
|
|
65
|
+
if (durable.length > 0) await this._principal.capBag.add(...durable);
|
|
66
|
+
return {
|
|
67
|
+
status: "granted",
|
|
68
|
+
capabilities,
|
|
69
|
+
addedDurable: durable.length
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
status: result.status,
|
|
74
|
+
reason: result.reason
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
sendRequest(method, params, opts) {
|
|
78
|
+
return this._inner.sendRequest(method, params, opts);
|
|
79
|
+
}
|
|
80
|
+
sendNotification(method, params, opts) {
|
|
81
|
+
return this._inner.sendNotification(method, params, opts);
|
|
82
|
+
}
|
|
83
|
+
sendRequestWithStream(method, params, opts) {
|
|
84
|
+
return this._inner.sendRequestWithStream(method, params, opts);
|
|
85
|
+
}
|
|
86
|
+
close() {
|
|
87
|
+
this._inner.close();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
/** A cap is one-shot when any permission is pinned to a single call via `callBind`. */
|
|
91
|
+
function _isOneShotCap(sc) {
|
|
92
|
+
return sc.permissions.some((p) => p.callBind !== void 0);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { Hub, HubSigningSender, hubFromConnection };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hub/client/hubSigningSender.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport {\n type IMessageTransport,\n type IRequestSender,\n JsonRpcChannel,\n type JsonValue,\n type Principal,\n type PublicSigningIdentity,\n type RawStreamingCall,\n type SendOpts,\n type SignedCapability,\n SigningSender,\n type SigningCallCtx,\n type StreamSendOpts,\n} from '../../index';\nimport { hubAccessInterface } from '../common/hub.interfaces';\nimport type { HubAccessRequest, HubAccessResult } from '../common/hubAccess';\n\n/**\n * The single connection handle a hub client consumes: a signing request\n * sender (every outbound call is wrapped in a `$hubrpc` signed envelope by the\n * principal) that also surfaces the principal's public identity and its grants.\n *\n * It IS the channel — `sendRequest(\"svc::iface::member\", params)` routes a\n * form-3 hub call. The {@link Principal}'s `capBag` is the live grant list:\n * {@link listGrants} returns its snapshot and {@link requestAccess} grows it.\n *\n * Construct with {@link HubSigningSender.create} from any transport whose peer\n * is (or routes to) a hub — a socket, a websocket, or an in-memory\n * {@link import('@hediet/linkrpc-hub/hub/server').Hub} link.\n */\nexport class HubSigningSender implements IRequestSender<SigningCallCtx> {\n /**\n * Wrap `transport` in a JSON-RPC channel + signing sender bound to\n * `principal`.\n */\n public static create(\n transport: IMessageTransport,\n principal: Principal,\n ): HubSigningSender {\n const signed = SigningSender.wrapChannel(JsonRpcChannel.create(transport), { principal });\n return new HubSigningSender(signed.sender, principal);\n }\n\n private constructor(\n private readonly _inner: IRequestSender<SigningCallCtx>,\n private readonly _principal: Principal,\n ) { }\n\n /** Public identity (nodeId) this connection signs as. Never exposes keys. */\n public get identity(): PublicSigningIdentity {\n return this._principal.identity.publicSigningIdentity;\n }\n\n /** Snapshot of the durable capabilities currently held (the cap bag). */\n public listGrants(): readonly SignedCapability[] {\n return this._principal.capBag.capabilities;\n }\n\n /**\n * Request capabilities from the hub through the same signed connection:\n * a `hubAccess::requestAccess` call served at the connection root (never\n * forwarded → never gated, so no `hubAccess` bootstrap cap is needed). Any\n * durable (non-one-shot) caps the hub mints join the principal's cap bag, so\n * subsequent signed calls present them automatically.\n */\n public async requestAccess(req: HubAccessRequest): Promise<HubAccessResult> {\n const method = `${hubAccessInterface.info.id}::requestAccess`;\n const raw = await this._inner.sendRequest(method, {\n consumer: { ...req.consumer, principal: this._principal.id },\n permissions: req.permissions,\n ...(req.duration !== undefined ? { duration: req.duration } : {}),\n } as never);\n const result = raw as unknown as { status: string; capabilities?: SignedCapability[]; reason?: string; };\n if (result.status === 'granted') {\n const capabilities = result.capabilities ?? [];\n const durable = capabilities.filter((c) => !_isOneShotCap(c));\n if (durable.length > 0) await this._principal.capBag.add(...durable);\n return { status: 'granted', capabilities, addedDurable: durable.length };\n }\n return { status: result.status, reason: result.reason };\n }\n\n public sendRequest(method: string, params: JsonValue | undefined, opts?: SendOpts<SigningCallCtx>): Promise<JsonValue> {\n return this._inner.sendRequest(method, params, opts);\n }\n\n public sendNotification(method: string, params: JsonValue | undefined, opts?: SendOpts<SigningCallCtx>): Promise<void> {\n return this._inner.sendNotification(method, params, opts);\n }\n\n public sendRequestWithStream(method: string, params: JsonValue | undefined, opts?: StreamSendOpts<SigningCallCtx>): RawStreamingCall {\n return this._inner.sendRequestWithStream(method, params, opts);\n }\n\n public close(): void {\n this._inner.close();\n }\n}\n\n/** A cap is one-shot when any permission is pinned to a single call via `callBind`. */\nfunction _isOneShotCap(sc: SignedCapability): boolean {\n return sc.permissions.some((p) => p.callBind !== undefined);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,IAAa,mBAAb,MAAa,iBAA2D;CAc/C;CACA;;;;;CAVrB,OAAc,OACV,WACA,WACgB;EAChB,MAAM,SAAS,cAAc,YAAY,eAAe,OAAO,SAAS,GAAG,EAAE,UAAU,CAAC;EACxF,OAAO,IAAI,iBAAiB,OAAO,QAAQ,SAAS;CACxD;CAEA,YACI,QACA,YACF;EAFmB,KAAA,SAAA;EACA,KAAA,aAAA;CACjB;;CAGJ,IAAW,WAAkC;EACzC,OAAO,KAAK,WAAW,SAAS;CACpC;;CAGA,aAAiD;EAC7C,OAAO,KAAK,WAAW,OAAO;CAClC;;;;;;;;CASA,MAAa,cAAc,KAAiD;EACxE,MAAM,SAAS,GAAG,mBAAmB,KAAK,GAAG;EAM7C,MAAM,SAAS,MALG,KAAK,OAAO,YAAY,QAAQ;GAC9C,UAAU;IAAE,GAAG,IAAI;IAAU,WAAW,KAAK,WAAW;GAAG;GAC3D,aAAa,IAAI;GACjB,GAAI,IAAI,aAAa,KAAA,IAAY,EAAE,UAAU,IAAI,SAAS,IAAI,CAAC;EACnE,CAAU;EAEV,IAAI,OAAO,WAAW,WAAW;GAC7B,MAAM,eAAe,OAAO,gBAAgB,CAAC;GAC7C,MAAM,UAAU,aAAa,QAAQ,MAAM,CAAC,cAAc,CAAC,CAAC;GAC5D,IAAI,QAAQ,SAAS,GAAG,MAAM,KAAK,WAAW,OAAO,IAAI,GAAG,OAAO;GACnE,OAAO;IAAE,QAAQ;IAAW;IAAc,cAAc,QAAQ;GAAO;EAC3E;EACA,OAAO;GAAE,QAAQ,OAAO;GAAQ,QAAQ,OAAO;EAAO;CAC1D;CAEA,YAAmB,QAAgB,QAA+B,MAAqD;EACnH,OAAO,KAAK,OAAO,YAAY,QAAQ,QAAQ,IAAI;CACvD;CAEA,iBAAwB,QAAgB,QAA+B,MAAgD;EACnH,OAAO,KAAK,OAAO,iBAAiB,QAAQ,QAAQ,IAAI;CAC5D;CAEA,sBAA6B,QAAgB,QAA+B,MAAyD;EACjI,OAAO,KAAK,OAAO,sBAAsB,QAAQ,QAAQ,IAAI;CACjE;CAEA,QAAqB;EACjB,KAAK,OAAO,MAAM;CACtB;AACJ;;AAGA,SAAS,cAAc,IAA+B;CAClD,OAAO,GAAG,YAAY,MAAM,MAAM,EAAE,aAAa,KAAA,CAAS;AAC9D"}
|