@clowder-ai/plugin-contract 0.1.0-beta.2 → 0.1.0-beta.3
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/dist/conformance/index.d.ts +1 -0
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +1 -0
- package/dist/conformance/index.js.map +1 -1
- package/dist/conformance/stdio-harness/child-process-harness.d.ts +59 -0
- package/dist/conformance/stdio-harness/child-process-harness.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/child-process-harness.js +279 -0
- package/dist/conformance/stdio-harness/child-process-harness.js.map +1 -0
- package/dist/conformance/stdio-harness/dual-transport-oracle.d.ts +26 -0
- package/dist/conformance/stdio-harness/dual-transport-oracle.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/dual-transport-oracle.js +32 -0
- package/dist/conformance/stdio-harness/dual-transport-oracle.js.map +1 -0
- package/dist/conformance/stdio-harness/harness-process-spawn.d.ts +27 -0
- package/dist/conformance/stdio-harness/harness-process-spawn.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/harness-process-spawn.js +43 -0
- package/dist/conformance/stdio-harness/harness-process-spawn.js.map +1 -0
- package/dist/conformance/stdio-harness/index.d.ts +5 -0
- package/dist/conformance/stdio-harness/index.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/index.js +4 -0
- package/dist/conformance/stdio-harness/index.js.map +1 -0
- package/dist/conformance/stdio-harness/ndjson-frame.d.ts +26 -0
- package/dist/conformance/stdio-harness/ndjson-frame.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/ndjson-frame.js +119 -0
- package/dist/conformance/stdio-harness/ndjson-frame.js.map +1 -0
- package/dist/conformance/stdio-harness/node-process-tree-runtime.d.ts +15 -0
- package/dist/conformance/stdio-harness/node-process-tree-runtime.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/node-process-tree-runtime.js +78 -0
- package/dist/conformance/stdio-harness/node-process-tree-runtime.js.map +1 -0
- package/dist/conformance/stdio-harness/process-tree-controller.d.ts +51 -0
- package/dist/conformance/stdio-harness/process-tree-controller.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/process-tree-controller.js +162 -0
- package/dist/conformance/stdio-harness/process-tree-controller.js.map +1 -0
- package/dist/conformance/stdio-harness/windows-sentinel.d.ts +15 -0
- package/dist/conformance/stdio-harness/windows-sentinel.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/windows-sentinel.js +160 -0
- package/dist/conformance/stdio-harness/windows-sentinel.js.map +1 -0
- package/dist/conformance/stdio-harness/wire-shape.d.ts +18 -0
- package/dist/conformance/stdio-harness/wire-shape.d.ts.map +1 -0
- package/dist/conformance/stdio-harness/wire-shape.js +2 -0
- package/dist/conformance/stdio-harness/wire-shape.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/wire/constants.d.ts +36 -0
- package/dist/wire/constants.d.ts.map +1 -0
- package/dist/wire/constants.js +36 -0
- package/dist/wire/constants.js.map +1 -0
- package/dist/wire/disposition-fixtures.d.ts +99 -0
- package/dist/wire/disposition-fixtures.d.ts.map +1 -0
- package/dist/wire/disposition-fixtures.js +623 -0
- package/dist/wire/disposition-fixtures.js.map +1 -0
- package/dist/wire/disposition.d.ts +100 -0
- package/dist/wire/disposition.d.ts.map +1 -0
- package/dist/wire/disposition.js +205 -0
- package/dist/wire/disposition.js.map +1 -0
- package/dist/wire/envelope.d.ts +253 -0
- package/dist/wire/envelope.d.ts.map +1 -0
- package/dist/wire/envelope.js +19 -0
- package/dist/wire/envelope.js.map +1 -0
- package/dist/wire/errors.d.ts +222 -0
- package/dist/wire/errors.d.ts.map +1 -0
- package/dist/wire/errors.js +153 -0
- package/dist/wire/errors.js.map +1 -0
- package/dist/wire/grants.d.ts +57 -0
- package/dist/wire/grants.d.ts.map +1 -0
- package/dist/wire/grants.js +59 -0
- package/dist/wire/grants.js.map +1 -0
- package/dist/wire/handshake.d.ts +100 -0
- package/dist/wire/handshake.d.ts.map +1 -0
- package/dist/wire/handshake.js +70 -0
- package/dist/wire/handshake.js.map +1 -0
- package/dist/wire/index.d.ts +26 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +45 -0
- package/dist/wire/index.js.map +1 -0
- package/dist/wire/registry.d.ts +90 -0
- package/dist/wire/registry.d.ts.map +1 -0
- package/dist/wire/registry.js +232 -0
- package/dist/wire/registry.js.map +1 -0
- package/dist/wire/request-id.d.ts +34 -0
- package/dist/wire/request-id.d.ts.map +1 -0
- package/dist/wire/request-id.js +40 -0
- package/dist/wire/request-id.js.map +1 -0
- package/dist/wire/row-shapes.d.ts +212 -0
- package/dist/wire/row-shapes.d.ts.map +1 -0
- package/dist/wire/row-shapes.js +59 -0
- package/dist/wire/row-shapes.js.map +1 -0
- package/dist/wire/wire-uint53.d.ts +26 -0
- package/dist/wire/wire-uint53.d.ts.map +1 -0
- package/dist/wire/wire-uint53.js +32 -0
- package/dist/wire/wire-uint53.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire-protocol error types — application and standard variants.
|
|
3
|
+
* Mechanized verbatim from the #1165 frozen shape.
|
|
4
|
+
*
|
|
5
|
+
* Application errors (R2 co-signed):
|
|
6
|
+
* HANDSHAKE_REJECTED (-32090), DELIVERY_REJECTED (-32091),
|
|
7
|
+
* DOMAIN_ERROR (-32092), DEADLINE_EXPIRED (-32093),
|
|
8
|
+
* SNAPSHOT_UNAVAILABLE (-32094).
|
|
9
|
+
*
|
|
10
|
+
* Standard JSON-RPC errors (R29):
|
|
11
|
+
* Parse error (-32700), Invalid Request (-32600, two id arms),
|
|
12
|
+
* Method not found (-32601), Invalid params (-32602),
|
|
13
|
+
* Internal error (-32603).
|
|
14
|
+
*
|
|
15
|
+
* Total: 5 application classes + 5 standard error body types = 10 error
|
|
16
|
+
* body types. Invalid Request has two id arms at the ENVELOPE level
|
|
17
|
+
* (valid-id echo vs null), but the error body is identical — yielding
|
|
18
|
+
* 11 closed envelope-level variants for byte-proof purposes.
|
|
19
|
+
*
|
|
20
|
+
* This module defines nothing new — every value traces to a frozen
|
|
21
|
+
* #1165 revision.
|
|
22
|
+
*/
|
|
23
|
+
import type { MessagingErrorCode } from '../generated/contract.generated.js';
|
|
24
|
+
/** Handshake rejected by host or plugin. */
|
|
25
|
+
export declare const HANDSHAKE_REJECTED_CODE: -32090;
|
|
26
|
+
/** Delivery rejected — message could not be dispatched to handler. */
|
|
27
|
+
export declare const DELIVERY_REJECTED_CODE: -32091;
|
|
28
|
+
/** Domain-level error surfaced through the messaging layer. */
|
|
29
|
+
export declare const DOMAIN_ERROR_CODE: -32092;
|
|
30
|
+
/** Operation exceeded its time budget. */
|
|
31
|
+
export declare const DEADLINE_EXPIRED_CODE: -32093;
|
|
32
|
+
/** Requested snapshot state is not available. */
|
|
33
|
+
export declare const SNAPSHOT_UNAVAILABLE_CODE: -32094;
|
|
34
|
+
/** Canonical message for HANDSHAKE_REJECTED. */
|
|
35
|
+
export declare const HANDSHAKE_REJECTED_MESSAGE: "handshake rejected";
|
|
36
|
+
/** Canonical message for DELIVERY_REJECTED. */
|
|
37
|
+
export declare const DELIVERY_REJECTED_MESSAGE: "delivery rejected";
|
|
38
|
+
/** Canonical message for DOMAIN_ERROR. */
|
|
39
|
+
export declare const DOMAIN_ERROR_MESSAGE: "domain error";
|
|
40
|
+
/** Canonical message for DEADLINE_EXPIRED. */
|
|
41
|
+
export declare const DEADLINE_EXPIRED_MESSAGE: "deadline expired";
|
|
42
|
+
/** Canonical message for SNAPSHOT_UNAVAILABLE. */
|
|
43
|
+
export declare const SNAPSHOT_UNAVAILABLE_MESSAGE: "snapshot unavailable";
|
|
44
|
+
/** JSON could not be parsed. */
|
|
45
|
+
export declare const PARSE_ERROR_CODE: -32700;
|
|
46
|
+
/** The JSON sent is not a valid Request object. */
|
|
47
|
+
export declare const INVALID_REQUEST_CODE: -32600;
|
|
48
|
+
/** The method does not exist or is not available. */
|
|
49
|
+
export declare const METHOD_NOT_FOUND_CODE: -32601;
|
|
50
|
+
/** Invalid method parameter(s). */
|
|
51
|
+
export declare const INVALID_PARAMS_CODE: -32602;
|
|
52
|
+
/** Internal JSON-RPC error. */
|
|
53
|
+
export declare const INTERNAL_ERROR_CODE: -32603;
|
|
54
|
+
/** Canonical message for Parse error. */
|
|
55
|
+
export declare const PARSE_ERROR_MESSAGE: "Parse error";
|
|
56
|
+
/** Canonical message for Invalid Request. */
|
|
57
|
+
export declare const INVALID_REQUEST_MESSAGE: "Invalid Request";
|
|
58
|
+
/** Canonical message for Method not found. */
|
|
59
|
+
export declare const METHOD_NOT_FOUND_MESSAGE: "Method not found";
|
|
60
|
+
/** Canonical message for Invalid params. */
|
|
61
|
+
export declare const INVALID_PARAMS_MESSAGE: "Invalid params";
|
|
62
|
+
/** Canonical message for Internal error. */
|
|
63
|
+
export declare const INTERNAL_ERROR_MESSAGE: "Internal error";
|
|
64
|
+
/**
|
|
65
|
+
* Maps every wire error code to its canonical error message constant.
|
|
66
|
+
* Covers all 10 distinct codes (Invalid Request's two id-arms share one code).
|
|
67
|
+
*/
|
|
68
|
+
export declare const ERROR_CODE_TO_MESSAGE: {
|
|
69
|
+
readonly [-32090]: "handshake rejected";
|
|
70
|
+
readonly [-32091]: "delivery rejected";
|
|
71
|
+
readonly [-32092]: "domain error";
|
|
72
|
+
readonly [-32093]: "deadline expired";
|
|
73
|
+
readonly [-32094]: "snapshot unavailable";
|
|
74
|
+
readonly [-32700]: "Parse error";
|
|
75
|
+
readonly [-32600]: "Invalid Request";
|
|
76
|
+
readonly [-32601]: "Method not found";
|
|
77
|
+
readonly [-32602]: "Invalid params";
|
|
78
|
+
readonly [-32603]: "Internal error";
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Closed set of reasons a handshake may be rejected.
|
|
82
|
+
* Mechanized from #1165 R2.
|
|
83
|
+
*/
|
|
84
|
+
export declare const HANDSHAKE_REJECT_REASONS: readonly ["MALFORMED_HELLO", "PACKAGE_MISMATCH", "CONTRACT_INCOMPATIBLE", "WIRE_INCOMPATIBLE", "AUTHORITY_VIOLATION", "DEADLINE_EXPIRED", "BINDING_REPLAY"];
|
|
85
|
+
/** Union of all handshake-rejection reasons. */
|
|
86
|
+
export type HandshakeRejectReason = (typeof HANDSHAKE_REJECT_REASONS)[number];
|
|
87
|
+
/**
|
|
88
|
+
* Closed set of reasons a delivery may be rejected.
|
|
89
|
+
* Mechanized from #1165 R2.
|
|
90
|
+
*/
|
|
91
|
+
export declare const DELIVERY_REJECT_REASONS: readonly ["UNSUPPORTED_PAYLOAD", "NO_HANDLER", "PLUGIN_BUSY", "PLUGIN_INTERNAL"];
|
|
92
|
+
/** Union of all delivery-rejection reasons. */
|
|
93
|
+
export type DeliveryRejectReason = (typeof DELIVERY_REJECT_REASONS)[number];
|
|
94
|
+
/**
|
|
95
|
+
* Closed set of reasons a snapshot may be unavailable.
|
|
96
|
+
* Mechanized from #1165 R2.
|
|
97
|
+
*/
|
|
98
|
+
export declare const SNAPSHOT_UNAVAILABLE_REASONS: readonly ["OVERSIZED_ITEM", "VIEW_EXPIRED", "STORE_UNAVAILABLE"];
|
|
99
|
+
/** Union of all snapshot-unavailability reasons. */
|
|
100
|
+
export type SnapshotUnavailableReason = (typeof SNAPSHOT_UNAVAILABLE_REASONS)[number];
|
|
101
|
+
export type { MessagingErrorCode } from '../generated/contract.generated.js';
|
|
102
|
+
/**
|
|
103
|
+
* HANDSHAKE_REJECTED (-32090).
|
|
104
|
+
* Sent when the handshake is refused for a well-typed reason.
|
|
105
|
+
*/
|
|
106
|
+
export type HandshakeRejectedError = {
|
|
107
|
+
readonly code: typeof HANDSHAKE_REJECTED_CODE;
|
|
108
|
+
readonly message: typeof HANDSHAKE_REJECTED_MESSAGE;
|
|
109
|
+
readonly data: {
|
|
110
|
+
readonly reason: HandshakeRejectReason;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* DELIVERY_REJECTED (-32091).
|
|
115
|
+
* Sent when a dispatched message cannot be accepted by the plugin.
|
|
116
|
+
*/
|
|
117
|
+
export type DeliveryRejectedError = {
|
|
118
|
+
readonly code: typeof DELIVERY_REJECTED_CODE;
|
|
119
|
+
readonly message: typeof DELIVERY_REJECTED_MESSAGE;
|
|
120
|
+
readonly data: {
|
|
121
|
+
readonly reason: DeliveryRejectReason;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* DOMAIN_ERROR (-32092).
|
|
126
|
+
* Domain-level failure surfaced through the messaging error taxonomy.
|
|
127
|
+
*/
|
|
128
|
+
export type DomainError = {
|
|
129
|
+
readonly code: typeof DOMAIN_ERROR_CODE;
|
|
130
|
+
readonly message: typeof DOMAIN_ERROR_MESSAGE;
|
|
131
|
+
readonly data: {
|
|
132
|
+
readonly code: MessagingErrorCode;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* DEADLINE_EXPIRED (-32093).
|
|
137
|
+
* The operation's time budget was exhausted. Data is an empty object.
|
|
138
|
+
*/
|
|
139
|
+
export type DeadlineExpiredError = {
|
|
140
|
+
readonly code: typeof DEADLINE_EXPIRED_CODE;
|
|
141
|
+
readonly message: typeof DEADLINE_EXPIRED_MESSAGE;
|
|
142
|
+
readonly data: Record<string, never>;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* SNAPSHOT_UNAVAILABLE (-32094).
|
|
146
|
+
* Requested snapshot state cannot be provided.
|
|
147
|
+
*/
|
|
148
|
+
export type SnapshotUnavailableError = {
|
|
149
|
+
readonly code: typeof SNAPSHOT_UNAVAILABLE_CODE;
|
|
150
|
+
readonly message: typeof SNAPSHOT_UNAVAILABLE_MESSAGE;
|
|
151
|
+
readonly data: {
|
|
152
|
+
readonly reason: SnapshotUnavailableReason;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
/** Union of all 5 application wire errors. */
|
|
156
|
+
export type ApplicationWireError = HandshakeRejectedError | DeliveryRejectedError | DomainError | DeadlineExpiredError | SnapshotUnavailableError;
|
|
157
|
+
/**
|
|
158
|
+
* Parse error (-32700).
|
|
159
|
+
* JSON could not be parsed. id is always null, no data field.
|
|
160
|
+
*/
|
|
161
|
+
export type ParseError = {
|
|
162
|
+
readonly code: typeof PARSE_ERROR_CODE;
|
|
163
|
+
readonly message: typeof PARSE_ERROR_MESSAGE;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Invalid Request (-32600).
|
|
167
|
+
* The JSON sent is not a valid Request object.
|
|
168
|
+
*
|
|
169
|
+
* Two id arms at the envelope level (WireErrorResponse):
|
|
170
|
+
* - valid-id arm: envelope id = byte-equal RequestId echo
|
|
171
|
+
* - no-id arm: envelope id = null (true detection failure)
|
|
172
|
+
* The error body itself is identical for both arms.
|
|
173
|
+
*/
|
|
174
|
+
export type InvalidRequestError = {
|
|
175
|
+
readonly code: typeof INVALID_REQUEST_CODE;
|
|
176
|
+
readonly message: typeof INVALID_REQUEST_MESSAGE;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Method not found (-32601).
|
|
180
|
+
* The requested method does not exist.
|
|
181
|
+
* Envelope id = byte-equal RequestId echo.
|
|
182
|
+
*/
|
|
183
|
+
export type MethodNotFoundError = {
|
|
184
|
+
readonly code: typeof METHOD_NOT_FOUND_CODE;
|
|
185
|
+
readonly message: typeof METHOD_NOT_FOUND_MESSAGE;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Invalid params (-32602).
|
|
189
|
+
* Method parameters are invalid.
|
|
190
|
+
* Envelope id = byte-equal RequestId echo.
|
|
191
|
+
*/
|
|
192
|
+
export type InvalidParamsError = {
|
|
193
|
+
readonly code: typeof INVALID_PARAMS_CODE;
|
|
194
|
+
readonly message: typeof INVALID_PARAMS_MESSAGE;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Internal error (-32603).
|
|
198
|
+
* Internal JSON-RPC processing failure.
|
|
199
|
+
* Envelope id = byte-equal RequestId echo.
|
|
200
|
+
*/
|
|
201
|
+
export type InternalError = {
|
|
202
|
+
readonly code: typeof INTERNAL_ERROR_CODE;
|
|
203
|
+
readonly message: typeof INTERNAL_ERROR_MESSAGE;
|
|
204
|
+
};
|
|
205
|
+
/** Union of all 5 standard wire-error body types. */
|
|
206
|
+
export type StandardWireError = ParseError | InvalidRequestError | MethodNotFoundError | InvalidParamsError | InternalError;
|
|
207
|
+
/**
|
|
208
|
+
* The complete closed union of all wire-protocol error variants.
|
|
209
|
+
* 5 application + 6 standard = 11 variants.
|
|
210
|
+
*
|
|
211
|
+
* This type is exhaustive: any wire error returned on the protocol
|
|
212
|
+
* MUST be narrowable to one of these 11 shapes. Adding a variant
|
|
213
|
+
* requires a contract revision.
|
|
214
|
+
*/
|
|
215
|
+
export type WireError = ApplicationWireError | StandardWireError;
|
|
216
|
+
/** All application error codes. */
|
|
217
|
+
export declare const APPLICATION_ERROR_CODES: readonly [-32090, -32091, -32092, -32093, -32094];
|
|
218
|
+
/** All standard JSON-RPC error codes. */
|
|
219
|
+
export declare const STANDARD_ERROR_CODES: readonly [-32700, -32600, -32601, -32602, -32603];
|
|
220
|
+
/** All wire error codes (application + standard). */
|
|
221
|
+
export declare const ALL_ERROR_CODES: readonly [-32090, -32091, -32092, -32093, -32094, -32700, -32600, -32601, -32602, -32603];
|
|
222
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/wire/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAM7E,4CAA4C;AAC5C,eAAO,MAAM,uBAAuB,EAAG,CAAC,KAAc,CAAC;AAEvD,sEAAsE;AACtE,eAAO,MAAM,s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I,EAAE,OAAO,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,sBAAsB,CAAC;CACjD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,sBAAsB,CAAC;CACjD,CAAC;AAEF,qDAAqD;AACrD,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,GAClB,aAAa,CAAC;AAMlB;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAMjE,mCAAmC;AACnC,eAAO,MAAM,uBAAuB,mDAM1B,CAAC;AAEX,yCAAyC;AACzC,eAAO,MAAM,oBAAoB,mDAMvB,CAAC;AAEX,qDAAqD;AACrD,eAAO,MAAM,eAAe,2FAGlB,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire-protocol error types — application and standard variants.
|
|
3
|
+
* Mechanized verbatim from the #1165 frozen shape.
|
|
4
|
+
*
|
|
5
|
+
* Application errors (R2 co-signed):
|
|
6
|
+
* HANDSHAKE_REJECTED (-32090), DELIVERY_REJECTED (-32091),
|
|
7
|
+
* DOMAIN_ERROR (-32092), DEADLINE_EXPIRED (-32093),
|
|
8
|
+
* SNAPSHOT_UNAVAILABLE (-32094).
|
|
9
|
+
*
|
|
10
|
+
* Standard JSON-RPC errors (R29):
|
|
11
|
+
* Parse error (-32700), Invalid Request (-32600, two id arms),
|
|
12
|
+
* Method not found (-32601), Invalid params (-32602),
|
|
13
|
+
* Internal error (-32603).
|
|
14
|
+
*
|
|
15
|
+
* Total: 5 application classes + 5 standard error body types = 10 error
|
|
16
|
+
* body types. Invalid Request has two id arms at the ENVELOPE level
|
|
17
|
+
* (valid-id echo vs null), but the error body is identical — yielding
|
|
18
|
+
* 11 closed envelope-level variants for byte-proof purposes.
|
|
19
|
+
*
|
|
20
|
+
* This module defines nothing new — every value traces to a frozen
|
|
21
|
+
* #1165 revision.
|
|
22
|
+
*/
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Application error codes (R2)
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
/** Handshake rejected by host or plugin. */
|
|
27
|
+
export const HANDSHAKE_REJECTED_CODE = -32090;
|
|
28
|
+
/** Delivery rejected — message could not be dispatched to handler. */
|
|
29
|
+
export const DELIVERY_REJECTED_CODE = -32091;
|
|
30
|
+
/** Domain-level error surfaced through the messaging layer. */
|
|
31
|
+
export const DOMAIN_ERROR_CODE = -32092;
|
|
32
|
+
/** Operation exceeded its time budget. */
|
|
33
|
+
export const DEADLINE_EXPIRED_CODE = -32093;
|
|
34
|
+
/** Requested snapshot state is not available. */
|
|
35
|
+
export const SNAPSHOT_UNAVAILABLE_CODE = -32094;
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Application error messages (R2, exact const strings)
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
/** Canonical message for HANDSHAKE_REJECTED. */
|
|
40
|
+
export const HANDSHAKE_REJECTED_MESSAGE = 'handshake rejected';
|
|
41
|
+
/** Canonical message for DELIVERY_REJECTED. */
|
|
42
|
+
export const DELIVERY_REJECTED_MESSAGE = 'delivery rejected';
|
|
43
|
+
/** Canonical message for DOMAIN_ERROR. */
|
|
44
|
+
export const DOMAIN_ERROR_MESSAGE = 'domain error';
|
|
45
|
+
/** Canonical message for DEADLINE_EXPIRED. */
|
|
46
|
+
export const DEADLINE_EXPIRED_MESSAGE = 'deadline expired';
|
|
47
|
+
/** Canonical message for SNAPSHOT_UNAVAILABLE. */
|
|
48
|
+
export const SNAPSHOT_UNAVAILABLE_MESSAGE = 'snapshot unavailable';
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Standard JSON-RPC error codes (R29)
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
/** JSON could not be parsed. */
|
|
53
|
+
export const PARSE_ERROR_CODE = -32700;
|
|
54
|
+
/** The JSON sent is not a valid Request object. */
|
|
55
|
+
export const INVALID_REQUEST_CODE = -32600;
|
|
56
|
+
/** The method does not exist or is not available. */
|
|
57
|
+
export const METHOD_NOT_FOUND_CODE = -32601;
|
|
58
|
+
/** Invalid method parameter(s). */
|
|
59
|
+
export const INVALID_PARAMS_CODE = -32602;
|
|
60
|
+
/** Internal JSON-RPC error. */
|
|
61
|
+
export const INTERNAL_ERROR_CODE = -32603;
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Standard JSON-RPC error messages (R29, exact const strings)
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
/** Canonical message for Parse error. */
|
|
66
|
+
export const PARSE_ERROR_MESSAGE = 'Parse error';
|
|
67
|
+
/** Canonical message for Invalid Request. */
|
|
68
|
+
export const INVALID_REQUEST_MESSAGE = 'Invalid Request';
|
|
69
|
+
/** Canonical message for Method not found. */
|
|
70
|
+
export const METHOD_NOT_FOUND_MESSAGE = 'Method not found';
|
|
71
|
+
/** Canonical message for Invalid params. */
|
|
72
|
+
export const INVALID_PARAMS_MESSAGE = 'Invalid params';
|
|
73
|
+
/** Canonical message for Internal error. */
|
|
74
|
+
export const INTERNAL_ERROR_MESSAGE = 'Internal error';
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Code-to-message mapping
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
/**
|
|
79
|
+
* Maps every wire error code to its canonical error message constant.
|
|
80
|
+
* Covers all 10 distinct codes (Invalid Request's two id-arms share one code).
|
|
81
|
+
*/
|
|
82
|
+
export const ERROR_CODE_TO_MESSAGE = {
|
|
83
|
+
[HANDSHAKE_REJECTED_CODE]: HANDSHAKE_REJECTED_MESSAGE,
|
|
84
|
+
[DELIVERY_REJECTED_CODE]: DELIVERY_REJECTED_MESSAGE,
|
|
85
|
+
[DOMAIN_ERROR_CODE]: DOMAIN_ERROR_MESSAGE,
|
|
86
|
+
[DEADLINE_EXPIRED_CODE]: DEADLINE_EXPIRED_MESSAGE,
|
|
87
|
+
[SNAPSHOT_UNAVAILABLE_CODE]: SNAPSHOT_UNAVAILABLE_MESSAGE,
|
|
88
|
+
[PARSE_ERROR_CODE]: PARSE_ERROR_MESSAGE,
|
|
89
|
+
[INVALID_REQUEST_CODE]: INVALID_REQUEST_MESSAGE,
|
|
90
|
+
[METHOD_NOT_FOUND_CODE]: METHOD_NOT_FOUND_MESSAGE,
|
|
91
|
+
[INVALID_PARAMS_CODE]: INVALID_PARAMS_MESSAGE,
|
|
92
|
+
[INTERNAL_ERROR_CODE]: INTERNAL_ERROR_MESSAGE,
|
|
93
|
+
};
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// Reject-reason taxonomies (closed enums, R2)
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
/**
|
|
98
|
+
* Closed set of reasons a handshake may be rejected.
|
|
99
|
+
* Mechanized from #1165 R2.
|
|
100
|
+
*/
|
|
101
|
+
export const HANDSHAKE_REJECT_REASONS = [
|
|
102
|
+
'MALFORMED_HELLO',
|
|
103
|
+
'PACKAGE_MISMATCH',
|
|
104
|
+
'CONTRACT_INCOMPATIBLE',
|
|
105
|
+
'WIRE_INCOMPATIBLE',
|
|
106
|
+
'AUTHORITY_VIOLATION',
|
|
107
|
+
'DEADLINE_EXPIRED',
|
|
108
|
+
'BINDING_REPLAY',
|
|
109
|
+
];
|
|
110
|
+
/**
|
|
111
|
+
* Closed set of reasons a delivery may be rejected.
|
|
112
|
+
* Mechanized from #1165 R2.
|
|
113
|
+
*/
|
|
114
|
+
export const DELIVERY_REJECT_REASONS = [
|
|
115
|
+
'UNSUPPORTED_PAYLOAD',
|
|
116
|
+
'NO_HANDLER',
|
|
117
|
+
'PLUGIN_BUSY',
|
|
118
|
+
'PLUGIN_INTERNAL',
|
|
119
|
+
];
|
|
120
|
+
/**
|
|
121
|
+
* Closed set of reasons a snapshot may be unavailable.
|
|
122
|
+
* Mechanized from #1165 R2.
|
|
123
|
+
*/
|
|
124
|
+
export const SNAPSHOT_UNAVAILABLE_REASONS = [
|
|
125
|
+
'OVERSIZED_ITEM',
|
|
126
|
+
'VIEW_EXPIRED',
|
|
127
|
+
'STORE_UNAVAILABLE',
|
|
128
|
+
];
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
// All error codes collected for iteration
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
/** All application error codes. */
|
|
133
|
+
export const APPLICATION_ERROR_CODES = [
|
|
134
|
+
HANDSHAKE_REJECTED_CODE,
|
|
135
|
+
DELIVERY_REJECTED_CODE,
|
|
136
|
+
DOMAIN_ERROR_CODE,
|
|
137
|
+
DEADLINE_EXPIRED_CODE,
|
|
138
|
+
SNAPSHOT_UNAVAILABLE_CODE,
|
|
139
|
+
];
|
|
140
|
+
/** All standard JSON-RPC error codes. */
|
|
141
|
+
export const STANDARD_ERROR_CODES = [
|
|
142
|
+
PARSE_ERROR_CODE,
|
|
143
|
+
INVALID_REQUEST_CODE,
|
|
144
|
+
METHOD_NOT_FOUND_CODE,
|
|
145
|
+
INVALID_PARAMS_CODE,
|
|
146
|
+
INTERNAL_ERROR_CODE,
|
|
147
|
+
];
|
|
148
|
+
/** All wire error codes (application + standard). */
|
|
149
|
+
export const ALL_ERROR_CODES = [
|
|
150
|
+
...APPLICATION_ERROR_CODES,
|
|
151
|
+
...STANDARD_ERROR_CODES,
|
|
152
|
+
];
|
|
153
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/wire/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAE9E,4CAA4C;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IACd,mBAAmB;CACX,CAAC;AAqJX,8EAA8E;AAC9E,0CAA0C;AAC1C,8EAA8E;AAE9E,mCAAmC;AACnC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,uBAAuB;IACvB,sBAAsB;IACtB,iBAAiB;IACjB,qBAAqB;IACrB,yBAAyB;CACjB,CAAC;AAEX,yCAAyC;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,gBAAgB;IAChB,oBAAoB;IACpB,qBAAqB;IACrB,mBAAmB;IACnB,mBAAmB;CACX,CAAC;AAEX,qDAAqD;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,uBAAuB;IAC1B,GAAG,oBAAoB;CACf,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grant snapshot types — GrantSnapshot for SessionBinding and host.grants.changed.
|
|
3
|
+
* Mechanized verbatim from #1165 frozen shape.
|
|
4
|
+
*
|
|
5
|
+
* GrantSnapshot represents the effective capability set at a point in time.
|
|
6
|
+
* It appears in two locations:
|
|
7
|
+
* - SessionBinding (initial grant state at handshake)
|
|
8
|
+
* - host.grants.changed notification (runtime grant mutations)
|
|
9
|
+
*
|
|
10
|
+
* grantRevision is strictly monotonic per plugin instance — the Host
|
|
11
|
+
* increments it on every grant mutation. A plugin that observes
|
|
12
|
+
* revision N may discard any notification with revision < N.
|
|
13
|
+
*/
|
|
14
|
+
import type { Capability } from '../generated/contract.generated.js';
|
|
15
|
+
/**
|
|
16
|
+
* Maximum number of items in effectiveGrants.
|
|
17
|
+
* Derived from the 17-value Capability enum — a plugin cannot hold
|
|
18
|
+
* more capabilities than exist.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MAX_GRANT_ITEMS: 17;
|
|
21
|
+
/**
|
|
22
|
+
* GrantSnapshot captures a versioned capability set.
|
|
23
|
+
*
|
|
24
|
+
* Used in SessionBinding (handshake) and host.grants.changed (notification).
|
|
25
|
+
* The two fields are always paired and always travel together.
|
|
26
|
+
*/
|
|
27
|
+
export interface GrantSnapshot {
|
|
28
|
+
/**
|
|
29
|
+
* WireUInt53(0, 9_007_199_254_740_991).
|
|
30
|
+
* Monotonically increasing per plugin instance.
|
|
31
|
+
* The Host is the sole writer; plugins observe only.
|
|
32
|
+
*/
|
|
33
|
+
readonly grantRevision: number;
|
|
34
|
+
/**
|
|
35
|
+
* Unique Capability[], 0..17 items.
|
|
36
|
+
* Duplicates are a protocol violation (Host guarantees uniqueness).
|
|
37
|
+
* Empty array is valid (plugin has no capabilities).
|
|
38
|
+
*/
|
|
39
|
+
readonly effectiveGrants: readonly Capability[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Frozen set of all valid Capability values, derived from the generated
|
|
43
|
+
* L0/L1/L2 capability arrays. Used for closed-enum membership checks.
|
|
44
|
+
*/
|
|
45
|
+
export declare const VALID_CAPABILITIES: ReadonlySet<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Validate that effectiveGrants:
|
|
48
|
+
* 1. Does not exceed MAX_GRANT_ITEMS (17).
|
|
49
|
+
* 2. Contains no duplicates.
|
|
50
|
+
* 3. Contains only valid Capability enum members (closed-enum check).
|
|
51
|
+
*
|
|
52
|
+
* Fail-closed: any unrecognized capability value returns false.
|
|
53
|
+
* This is an authorization boundary — fail-open would allow
|
|
54
|
+
* uncontrolled privilege escalation.
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateEffectiveGrants(grants: readonly string[]): boolean;
|
|
57
|
+
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../src/wire/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAWrE;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAG,EAAW,CAAC;AAM3C;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,SAAS,UAAU,EAAE,CAAC;CACjD;AAMD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAIjD,CAAC;AAEH;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAS1E"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grant snapshot types — GrantSnapshot for SessionBinding and host.grants.changed.
|
|
3
|
+
* Mechanized verbatim from #1165 frozen shape.
|
|
4
|
+
*
|
|
5
|
+
* GrantSnapshot represents the effective capability set at a point in time.
|
|
6
|
+
* It appears in two locations:
|
|
7
|
+
* - SessionBinding (initial grant state at handshake)
|
|
8
|
+
* - host.grants.changed notification (runtime grant mutations)
|
|
9
|
+
*
|
|
10
|
+
* grantRevision is strictly monotonic per plugin instance — the Host
|
|
11
|
+
* increments it on every grant mutation. A plugin that observes
|
|
12
|
+
* revision N may discard any notification with revision < N.
|
|
13
|
+
*/
|
|
14
|
+
import { L0_CAPABILITIES, L1_CAPABILITIES, L2_CAPABILITIES, } from '../generated/contract.generated.js';
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Constants
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/**
|
|
19
|
+
* Maximum number of items in effectiveGrants.
|
|
20
|
+
* Derived from the 17-value Capability enum — a plugin cannot hold
|
|
21
|
+
* more capabilities than exist.
|
|
22
|
+
*/
|
|
23
|
+
export const MAX_GRANT_ITEMS = 17;
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// Validators
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
/**
|
|
28
|
+
* Frozen set of all valid Capability values, derived from the generated
|
|
29
|
+
* L0/L1/L2 capability arrays. Used for closed-enum membership checks.
|
|
30
|
+
*/
|
|
31
|
+
export const VALID_CAPABILITIES = new Set([
|
|
32
|
+
...L0_CAPABILITIES,
|
|
33
|
+
...L1_CAPABILITIES,
|
|
34
|
+
...L2_CAPABILITIES,
|
|
35
|
+
]);
|
|
36
|
+
/**
|
|
37
|
+
* Validate that effectiveGrants:
|
|
38
|
+
* 1. Does not exceed MAX_GRANT_ITEMS (17).
|
|
39
|
+
* 2. Contains no duplicates.
|
|
40
|
+
* 3. Contains only valid Capability enum members (closed-enum check).
|
|
41
|
+
*
|
|
42
|
+
* Fail-closed: any unrecognized capability value returns false.
|
|
43
|
+
* This is an authorization boundary — fail-open would allow
|
|
44
|
+
* uncontrolled privilege escalation.
|
|
45
|
+
*/
|
|
46
|
+
export function validateEffectiveGrants(grants) {
|
|
47
|
+
if (grants.length > MAX_GRANT_ITEMS)
|
|
48
|
+
return false;
|
|
49
|
+
const seen = new Set();
|
|
50
|
+
for (const g of grants) {
|
|
51
|
+
if (!VALID_CAPABILITIES.has(g))
|
|
52
|
+
return false; // unknown capability
|
|
53
|
+
if (seen.has(g))
|
|
54
|
+
return false; // duplicate
|
|
55
|
+
seen.add(g);
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../src/wire/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EACL,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,oCAAoC,CAAC;AAE5C,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAW,CAAC;AA2B3C,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAS;IACrE,GAAG,eAAe;IAClB,GAAG,eAAe;IAClB,GAAG,eAAe;CACnB,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAyB;IAC/D,IAAI,MAAM,CAAC,MAAM,GAAG,eAAe;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,qBAAqB;QACnE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC,CAAgB,YAAY;QAC1D,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handshake types — CandidateHello, SessionBinding, BrokerReadyParams.
|
|
3
|
+
* Mechanized verbatim from #1165 frozen shape.
|
|
4
|
+
*
|
|
5
|
+
* Handshake flow:
|
|
6
|
+
* 1. Plugin sends CandidateHello (candidate claims only, no grants/session).
|
|
7
|
+
* 2. Host validates, mints instance/session ids, replies with SessionBinding.
|
|
8
|
+
* 3. Plugin sends broker.ready with the bindingNonce to activate.
|
|
9
|
+
*
|
|
10
|
+
* CandidateHello and BrokerReadyParams REJECT any additional
|
|
11
|
+
* identity/instance/grant/session fields (closed surface).
|
|
12
|
+
*/
|
|
13
|
+
import type { Capability } from '../generated/contract.generated.js';
|
|
14
|
+
/** Exact character length of a sha512 SRI digest. */
|
|
15
|
+
export declare const PACKAGE_DIGEST_LENGTH: 95;
|
|
16
|
+
/**
|
|
17
|
+
* Pattern for a valid sha512 SRI package digest.
|
|
18
|
+
* 85 base64 chars + one of [AQgw] + '==' suffix.
|
|
19
|
+
*/
|
|
20
|
+
export declare const PACKAGE_DIGEST_PATTERN: RegExp;
|
|
21
|
+
/**
|
|
22
|
+
* Compact-JSON encoded byte count for the digest string.
|
|
23
|
+
* 95 chars (all ASCII) + 2 surrounding quotes = 97 bytes.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PACKAGE_DIGEST_ENCODED_BYTES: 97;
|
|
26
|
+
/** Minimum code-point length for bindingNonce. */
|
|
27
|
+
export declare const BINDING_NONCE_MIN_LENGTH: 1;
|
|
28
|
+
/** Maximum code-point length for bindingNonce. */
|
|
29
|
+
export declare const BINDING_NONCE_MAX_LENGTH: 512;
|
|
30
|
+
/**
|
|
31
|
+
* Maximum compact-JSON encoded bytes for bindingNonce.
|
|
32
|
+
* Worst case: every code point is a 6-byte escape (\uXXXX) → 6 * 512 + 2 quotes.
|
|
33
|
+
*/
|
|
34
|
+
export declare const BINDING_NONCE_MAX_ENCODED_BYTES: 3074;
|
|
35
|
+
/**
|
|
36
|
+
* CandidateHello is sent by the plugin at connection open.
|
|
37
|
+
* It carries only the plugin's candidate claims; no instance ids,
|
|
38
|
+
* grant state, or session identifiers may appear.
|
|
39
|
+
*
|
|
40
|
+
* Additional identity/instance/grant/session fields are REJECTED.
|
|
41
|
+
*/
|
|
42
|
+
export interface CandidateHello {
|
|
43
|
+
/** RESERVED (H1) — manifest pluginId, no maximum bound declared. */
|
|
44
|
+
readonly pluginId: string;
|
|
45
|
+
/** CLOSED (H2) — exactly 95 chars, sha512 SRI digest. */
|
|
46
|
+
readonly packageDigest: string;
|
|
47
|
+
/** RESERVED (H3) — SemVer contract version, no maximum bound declared. */
|
|
48
|
+
readonly contractVersion: string;
|
|
49
|
+
/** RESERVED (H4) — wire protocol version, not yet owner-declared. */
|
|
50
|
+
readonly wireVersion: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* SessionBinding is the Host's authoritative response to CandidateHello.
|
|
54
|
+
* It echoes the four hello fields, then adds Host-minted identifiers
|
|
55
|
+
* and the effective grant snapshot.
|
|
56
|
+
*/
|
|
57
|
+
export interface SessionBinding {
|
|
58
|
+
/** Echoed from CandidateHello. */
|
|
59
|
+
readonly pluginId: string;
|
|
60
|
+
/** Echoed from CandidateHello. */
|
|
61
|
+
readonly packageDigest: string;
|
|
62
|
+
/** Echoed from CandidateHello. */
|
|
63
|
+
readonly contractVersion: string;
|
|
64
|
+
/** Echoed from CandidateHello. */
|
|
65
|
+
readonly wireVersion: string;
|
|
66
|
+
/** RESERVED (H5) — Host-minted instance id, grammar pending. */
|
|
67
|
+
readonly pluginInstanceId: string;
|
|
68
|
+
/** RESERVED (H6) — Host-minted session id, grammar pending. */
|
|
69
|
+
readonly brokerSessionId: string;
|
|
70
|
+
/** CLOSED (H7) — WireUInt53(0, 9_007_199_254_740_991), monotonically increasing. */
|
|
71
|
+
readonly grantRevision: number;
|
|
72
|
+
/** CLOSED (H8) — unique Capability[], 0..17 items. */
|
|
73
|
+
readonly effectiveGrants: readonly Capability[];
|
|
74
|
+
/** CLOSED (H9) — opaque nonce, 1..512 code points. */
|
|
75
|
+
readonly bindingNonce: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* BrokerReadyParams is the params object for the broker.ready request.
|
|
79
|
+
* It carries only bindingNonce for activation; it is NOT a resume carrier.
|
|
80
|
+
*
|
|
81
|
+
* Additional identity/instance/grant/session fields are REJECTED.
|
|
82
|
+
*/
|
|
83
|
+
export interface BrokerReadyParams {
|
|
84
|
+
/** CLOSED (H9) — activation-only; echoes the nonce from SessionBinding. */
|
|
85
|
+
readonly bindingNonce: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Validate a string as a conformant sha512 SRI package digest.
|
|
89
|
+
* Checks exact length (95) and pattern match.
|
|
90
|
+
*/
|
|
91
|
+
export declare function validatePackageDigest(value: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Validate a string as a conformant binding nonce.
|
|
94
|
+
* Checks code-point count is within [1, 512].
|
|
95
|
+
*
|
|
96
|
+
* Note: uses spread to count code points (not .length, which counts
|
|
97
|
+
* UTF-16 code units and misreports surrogate pairs).
|
|
98
|
+
*/
|
|
99
|
+
export declare function validateBindingNonce(value: string): boolean;
|
|
100
|
+
//# sourceMappingURL=handshake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/wire/handshake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAMrE,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,EAAG,EAAW,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAuC,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAG,EAAW,CAAC;AAMxD,kDAAkD;AAClD,eAAO,MAAM,wBAAwB,EAAG,CAAU,CAAC;AAEnD,kDAAkD;AAClD,eAAO,MAAM,wBAAwB,EAAG,GAAY,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAG,IAAa,CAAC;AAM7D;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAMD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,kCAAkC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,kCAAkC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,kCAAkC;IAClC,QAAQ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