@stryke/capnp 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/capnpc.cjs +7 -7
- package/bin/capnpc.js +7 -7
- package/dist/{chunk-FEGBNCWN.js → chunk-SYR4C2FT.js} +9 -7
- package/dist/{chunk-R5CS6CYK.cjs → chunk-XQV7WBWM.cjs} +9 -7
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/rpc.cjs +2 -2
- package/dist/rpc.js +1 -1
- package/dts/index.d.ts +4393 -0
- package/package.json +4 -3
- package/schemas/chunk-BQI46ZE5.js +4086 -0
- package/schemas/chunk-GX6VRR3G.cjs +4086 -0
- package/schemas/chunk-SHUYVCID.js +6 -0
- package/schemas/chunk-USNT2KNT.cjs +6 -0
- package/schemas/cpp.cjs +7 -0
- package/schemas/cpp.d.cts +3 -0
- package/schemas/cpp.d.ts +3 -0
- package/schemas/cpp.js +7 -0
- package/schemas/persistent.cjs +171 -0
- package/schemas/persistent.d.cts +147 -0
- package/schemas/persistent.d.ts +147 -0
- package/schemas/persistent.js +171 -0
- package/schemas/rpc-twoparty.cjs +209 -0
- package/schemas/rpc-twoparty.d.cts +171 -0
- package/schemas/rpc-twoparty.d.ts +171 -0
- package/schemas/rpc-twoparty.js +209 -0
- package/schemas/rpc.cjs +2563 -0
- package/schemas/rpc.d.cts +2004 -0
- package/schemas/rpc.d.ts +2004 -0
- package/schemas/rpc.js +2563 -0
- package/schemas/schema.cjs +2718 -0
- package/schemas/schema.d.cts +1454 -0
- package/schemas/schema.d.ts +1454 -0
- package/schemas/schema.js +2718 -0
- package/schemas/ts.cjs +7 -0
- package/schemas/ts.d.cts +3 -0
- package/schemas/ts.d.ts +3 -0
- package/schemas/ts.js +7 -0
|
@@ -0,0 +1,2004 @@
|
|
|
1
|
+
import { Struct, ObjectSize, Orphan, Pointer, ListCtor, List } from 'capnp-es';
|
|
2
|
+
|
|
3
|
+
declare const _capnpFileId: bigint;
|
|
4
|
+
declare const Message_Which: {
|
|
5
|
+
/**
|
|
6
|
+
* The sender previously received this message from the peer but didn't understand it or doesn't
|
|
7
|
+
* yet implement the functionality that was requested. So, the sender is echoing the message
|
|
8
|
+
* back. In some cases, the receiver may be able to recover from this by pretending the sender
|
|
9
|
+
* had taken some appropriate "null" action.
|
|
10
|
+
*
|
|
11
|
+
* For example, say `resolve` is received by a level 0 implementation (because a previous call
|
|
12
|
+
* or return happened to contain a promise). The level 0 implementation will echo it back as
|
|
13
|
+
* `unimplemented`. The original sender can then simply release the cap to which the promise
|
|
14
|
+
* had resolved, thus avoiding a leak.
|
|
15
|
+
*
|
|
16
|
+
* For any message type that introduces a question, if the message comes back unimplemented,
|
|
17
|
+
* the original sender may simply treat it as if the question failed with an exception.
|
|
18
|
+
*
|
|
19
|
+
* In cases where there is no sensible way to react to an `unimplemented` message (without
|
|
20
|
+
* resource leaks or other serious problems), the connection may need to be aborted. This is
|
|
21
|
+
* a gray area; different implementations may take different approaches.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
readonly UNIMPLEMENTED: 0;
|
|
25
|
+
/**
|
|
26
|
+
* Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
|
|
27
|
+
* because the sender received an invalid or nonsensical message or because the sender had an
|
|
28
|
+
* internal error. The sender will shut down the outgoing half of the connection after `abort`
|
|
29
|
+
* and will completely close the connection shortly thereafter (it's up to the sender how much
|
|
30
|
+
* of a time buffer they want to offer for the client to receive the `abort` before the
|
|
31
|
+
* connection is reset).
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
readonly ABORT: 1;
|
|
35
|
+
/**
|
|
36
|
+
* Request the peer's bootstrap interface.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
readonly BOOTSTRAP: 8;
|
|
40
|
+
/**
|
|
41
|
+
* Begin a method call.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
readonly CALL: 2;
|
|
45
|
+
/**
|
|
46
|
+
* Complete a method call.
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
readonly RETURN: 3;
|
|
50
|
+
/**
|
|
51
|
+
* Release a returned answer / cancel a call.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
readonly FINISH: 4;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve a previously-sent promise.
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
readonly RESOLVE: 5;
|
|
60
|
+
/**
|
|
61
|
+
* Release a capability so that the remote object can be deallocated.
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
readonly RELEASE: 6;
|
|
65
|
+
/**
|
|
66
|
+
* Lift an embargo used to enforce E-order over promise resolution.
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
readonly DISEMBARGO: 13;
|
|
70
|
+
/**
|
|
71
|
+
* Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
|
|
72
|
+
* by the `Persistent` interface defined in `persistent.capnp`. This operation was never
|
|
73
|
+
* implemented.
|
|
74
|
+
*
|
|
75
|
+
*/
|
|
76
|
+
readonly OBSOLETE_SAVE: 7;
|
|
77
|
+
/**
|
|
78
|
+
* Obsolete way to delete a SturdyRef. This operation was never implemented.
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
readonly OBSOLETE_DELETE: 9;
|
|
82
|
+
/**
|
|
83
|
+
* Provide a capability to a third party.
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
readonly PROVIDE: 10;
|
|
87
|
+
/**
|
|
88
|
+
* Accept a capability provided by a third party.
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
readonly ACCEPT: 11;
|
|
92
|
+
/**
|
|
93
|
+
* Directly connect to the common root of two or more proxied caps.
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
readonly JOIN: 12;
|
|
97
|
+
};
|
|
98
|
+
type Message_Which = (typeof Message_Which)[keyof typeof Message_Which];
|
|
99
|
+
/**
|
|
100
|
+
* An RPC connection is a bi-directional stream of Messages.
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
declare class Message extends Struct {
|
|
104
|
+
static readonly UNIMPLEMENTED: 0;
|
|
105
|
+
static readonly ABORT: 1;
|
|
106
|
+
static readonly BOOTSTRAP: 8;
|
|
107
|
+
static readonly CALL: 2;
|
|
108
|
+
static readonly RETURN: 3;
|
|
109
|
+
static readonly FINISH: 4;
|
|
110
|
+
static readonly RESOLVE: 5;
|
|
111
|
+
static readonly RELEASE: 6;
|
|
112
|
+
static readonly DISEMBARGO: 13;
|
|
113
|
+
static readonly OBSOLETE_SAVE: 7;
|
|
114
|
+
static readonly OBSOLETE_DELETE: 9;
|
|
115
|
+
static readonly PROVIDE: 10;
|
|
116
|
+
static readonly ACCEPT: 11;
|
|
117
|
+
static readonly JOIN: 12;
|
|
118
|
+
static readonly _capnp: {
|
|
119
|
+
displayName: string;
|
|
120
|
+
id: string;
|
|
121
|
+
size: ObjectSize;
|
|
122
|
+
};
|
|
123
|
+
_adoptUnimplemented(value: Orphan<Message>): void;
|
|
124
|
+
_disownUnimplemented(): Orphan<Message>;
|
|
125
|
+
/**
|
|
126
|
+
* The sender previously received this message from the peer but didn't understand it or doesn't
|
|
127
|
+
* yet implement the functionality that was requested. So, the sender is echoing the message
|
|
128
|
+
* back. In some cases, the receiver may be able to recover from this by pretending the sender
|
|
129
|
+
* had taken some appropriate "null" action.
|
|
130
|
+
*
|
|
131
|
+
* For example, say `resolve` is received by a level 0 implementation (because a previous call
|
|
132
|
+
* or return happened to contain a promise). The level 0 implementation will echo it back as
|
|
133
|
+
* `unimplemented`. The original sender can then simply release the cap to which the promise
|
|
134
|
+
* had resolved, thus avoiding a leak.
|
|
135
|
+
*
|
|
136
|
+
* For any message type that introduces a question, if the message comes back unimplemented,
|
|
137
|
+
* the original sender may simply treat it as if the question failed with an exception.
|
|
138
|
+
*
|
|
139
|
+
* In cases where there is no sensible way to react to an `unimplemented` message (without
|
|
140
|
+
* resource leaks or other serious problems), the connection may need to be aborted. This is
|
|
141
|
+
* a gray area; different implementations may take different approaches.
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
get unimplemented(): Message;
|
|
145
|
+
_hasUnimplemented(): boolean;
|
|
146
|
+
_initUnimplemented(): Message;
|
|
147
|
+
get _isUnimplemented(): boolean;
|
|
148
|
+
set unimplemented(value: Message);
|
|
149
|
+
_adoptAbort(value: Orphan<Exception>): void;
|
|
150
|
+
_disownAbort(): Orphan<Exception>;
|
|
151
|
+
/**
|
|
152
|
+
* Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
|
|
153
|
+
* because the sender received an invalid or nonsensical message or because the sender had an
|
|
154
|
+
* internal error. The sender will shut down the outgoing half of the connection after `abort`
|
|
155
|
+
* and will completely close the connection shortly thereafter (it's up to the sender how much
|
|
156
|
+
* of a time buffer they want to offer for the client to receive the `abort` before the
|
|
157
|
+
* connection is reset).
|
|
158
|
+
*
|
|
159
|
+
*/
|
|
160
|
+
get abort(): Exception;
|
|
161
|
+
_hasAbort(): boolean;
|
|
162
|
+
_initAbort(): Exception;
|
|
163
|
+
get _isAbort(): boolean;
|
|
164
|
+
set abort(value: Exception);
|
|
165
|
+
_adoptBootstrap(value: Orphan<Bootstrap>): void;
|
|
166
|
+
_disownBootstrap(): Orphan<Bootstrap>;
|
|
167
|
+
/**
|
|
168
|
+
* Request the peer's bootstrap interface.
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
get bootstrap(): Bootstrap;
|
|
172
|
+
_hasBootstrap(): boolean;
|
|
173
|
+
_initBootstrap(): Bootstrap;
|
|
174
|
+
get _isBootstrap(): boolean;
|
|
175
|
+
set bootstrap(value: Bootstrap);
|
|
176
|
+
_adoptCall(value: Orphan<Call>): void;
|
|
177
|
+
_disownCall(): Orphan<Call>;
|
|
178
|
+
/**
|
|
179
|
+
* Begin a method call.
|
|
180
|
+
*
|
|
181
|
+
*/
|
|
182
|
+
get call(): Call;
|
|
183
|
+
_hasCall(): boolean;
|
|
184
|
+
_initCall(): Call;
|
|
185
|
+
get _isCall(): boolean;
|
|
186
|
+
set call(value: Call);
|
|
187
|
+
_adoptReturn(value: Orphan<Return>): void;
|
|
188
|
+
_disownReturn(): Orphan<Return>;
|
|
189
|
+
/**
|
|
190
|
+
* Complete a method call.
|
|
191
|
+
*
|
|
192
|
+
*/
|
|
193
|
+
get return(): Return;
|
|
194
|
+
_hasReturn(): boolean;
|
|
195
|
+
_initReturn(): Return;
|
|
196
|
+
get _isReturn(): boolean;
|
|
197
|
+
set return(value: Return);
|
|
198
|
+
_adoptFinish(value: Orphan<Finish>): void;
|
|
199
|
+
_disownFinish(): Orphan<Finish>;
|
|
200
|
+
/**
|
|
201
|
+
* Release a returned answer / cancel a call.
|
|
202
|
+
*
|
|
203
|
+
*/
|
|
204
|
+
get finish(): Finish;
|
|
205
|
+
_hasFinish(): boolean;
|
|
206
|
+
_initFinish(): Finish;
|
|
207
|
+
get _isFinish(): boolean;
|
|
208
|
+
set finish(value: Finish);
|
|
209
|
+
_adoptResolve(value: Orphan<Resolve>): void;
|
|
210
|
+
_disownResolve(): Orphan<Resolve>;
|
|
211
|
+
/**
|
|
212
|
+
* Resolve a previously-sent promise.
|
|
213
|
+
*
|
|
214
|
+
*/
|
|
215
|
+
get resolve(): Resolve;
|
|
216
|
+
_hasResolve(): boolean;
|
|
217
|
+
_initResolve(): Resolve;
|
|
218
|
+
get _isResolve(): boolean;
|
|
219
|
+
set resolve(value: Resolve);
|
|
220
|
+
_adoptRelease(value: Orphan<Release>): void;
|
|
221
|
+
_disownRelease(): Orphan<Release>;
|
|
222
|
+
/**
|
|
223
|
+
* Release a capability so that the remote object can be deallocated.
|
|
224
|
+
*
|
|
225
|
+
*/
|
|
226
|
+
get release(): Release;
|
|
227
|
+
_hasRelease(): boolean;
|
|
228
|
+
_initRelease(): Release;
|
|
229
|
+
get _isRelease(): boolean;
|
|
230
|
+
set release(value: Release);
|
|
231
|
+
_adoptDisembargo(value: Orphan<Disembargo>): void;
|
|
232
|
+
_disownDisembargo(): Orphan<Disembargo>;
|
|
233
|
+
/**
|
|
234
|
+
* Lift an embargo used to enforce E-order over promise resolution.
|
|
235
|
+
*
|
|
236
|
+
*/
|
|
237
|
+
get disembargo(): Disembargo;
|
|
238
|
+
_hasDisembargo(): boolean;
|
|
239
|
+
_initDisembargo(): Disembargo;
|
|
240
|
+
get _isDisembargo(): boolean;
|
|
241
|
+
set disembargo(value: Disembargo);
|
|
242
|
+
_adoptObsoleteSave(value: Orphan<Pointer>): void;
|
|
243
|
+
_disownObsoleteSave(): Orphan<Pointer>;
|
|
244
|
+
/**
|
|
245
|
+
* Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
|
|
246
|
+
* by the `Persistent` interface defined in `persistent.capnp`. This operation was never
|
|
247
|
+
* implemented.
|
|
248
|
+
*
|
|
249
|
+
*/
|
|
250
|
+
get obsoleteSave(): Pointer;
|
|
251
|
+
_hasObsoleteSave(): boolean;
|
|
252
|
+
get _isObsoleteSave(): boolean;
|
|
253
|
+
set obsoleteSave(value: Pointer);
|
|
254
|
+
_adoptObsoleteDelete(value: Orphan<Pointer>): void;
|
|
255
|
+
_disownObsoleteDelete(): Orphan<Pointer>;
|
|
256
|
+
/**
|
|
257
|
+
* Obsolete way to delete a SturdyRef. This operation was never implemented.
|
|
258
|
+
*
|
|
259
|
+
*/
|
|
260
|
+
get obsoleteDelete(): Pointer;
|
|
261
|
+
_hasObsoleteDelete(): boolean;
|
|
262
|
+
get _isObsoleteDelete(): boolean;
|
|
263
|
+
set obsoleteDelete(value: Pointer);
|
|
264
|
+
_adoptProvide(value: Orphan<Provide>): void;
|
|
265
|
+
_disownProvide(): Orphan<Provide>;
|
|
266
|
+
/**
|
|
267
|
+
* Provide a capability to a third party.
|
|
268
|
+
*
|
|
269
|
+
*/
|
|
270
|
+
get provide(): Provide;
|
|
271
|
+
_hasProvide(): boolean;
|
|
272
|
+
_initProvide(): Provide;
|
|
273
|
+
get _isProvide(): boolean;
|
|
274
|
+
set provide(value: Provide);
|
|
275
|
+
_adoptAccept(value: Orphan<Accept>): void;
|
|
276
|
+
_disownAccept(): Orphan<Accept>;
|
|
277
|
+
/**
|
|
278
|
+
* Accept a capability provided by a third party.
|
|
279
|
+
*
|
|
280
|
+
*/
|
|
281
|
+
get accept(): Accept;
|
|
282
|
+
_hasAccept(): boolean;
|
|
283
|
+
_initAccept(): Accept;
|
|
284
|
+
get _isAccept(): boolean;
|
|
285
|
+
set accept(value: Accept);
|
|
286
|
+
_adoptJoin(value: Orphan<Join>): void;
|
|
287
|
+
_disownJoin(): Orphan<Join>;
|
|
288
|
+
/**
|
|
289
|
+
* Directly connect to the common root of two or more proxied caps.
|
|
290
|
+
*
|
|
291
|
+
*/
|
|
292
|
+
get join(): Join;
|
|
293
|
+
_hasJoin(): boolean;
|
|
294
|
+
_initJoin(): Join;
|
|
295
|
+
get _isJoin(): boolean;
|
|
296
|
+
set join(value: Join);
|
|
297
|
+
toString(): string;
|
|
298
|
+
which(): Message_Which;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* **(level 0)**
|
|
302
|
+
*
|
|
303
|
+
* Get the "bootstrap" interface exported by the remote vat.
|
|
304
|
+
*
|
|
305
|
+
* For level 0, 1, and 2 implementations, the "bootstrap" interface is simply the main interface
|
|
306
|
+
* exported by a vat. If the vat acts as a server fielding connections from clients, then the
|
|
307
|
+
* bootstrap interface defines the basic functionality available to a client when it connects.
|
|
308
|
+
* The exact interface definition obviously depends on the application.
|
|
309
|
+
*
|
|
310
|
+
* We call this a "bootstrap" because in an ideal Cap'n Proto world, bootstrap interfaces would
|
|
311
|
+
* never be used. In such a world, any time you connect to a new vat, you do so because you
|
|
312
|
+
* received an introduction from some other vat (see `ThirdPartyCapId`). Thus, the first message
|
|
313
|
+
* you send is `Accept`, and further communications derive from there. `Bootstrap` is not used.
|
|
314
|
+
*
|
|
315
|
+
* In such an ideal world, DNS itself would support Cap'n Proto -- performing a DNS lookup would
|
|
316
|
+
* actually return a new Cap'n Proto capability, thus introducing you to the target system via
|
|
317
|
+
* level 3 RPC. Applications would receive the capability to talk to DNS in the first place as
|
|
318
|
+
* an initial endowment or part of a Powerbox interaction. Therefore, an app can form arbitrary
|
|
319
|
+
* connections without ever using `Bootstrap`.
|
|
320
|
+
*
|
|
321
|
+
* Of course, in the real world, DNS is not Cap'n-Proto-based, and we don't want Cap'n Proto to
|
|
322
|
+
* require a whole new internet infrastructure to be useful. Therefore, we offer bootstrap
|
|
323
|
+
* interfaces as a way to get up and running without a level 3 introduction. Thus, bootstrap
|
|
324
|
+
* interfaces are used to "bootstrap" from other, non-Cap'n-Proto-based means of service discovery,
|
|
325
|
+
* such as legacy DNS.
|
|
326
|
+
*
|
|
327
|
+
* Note that a vat need not provide a bootstrap interface, and in fact many vats (especially those
|
|
328
|
+
* acting as clients) do not. In this case, the vat should either reply to `Bootstrap` with a
|
|
329
|
+
* `Return` indicating an exception, or should return a dummy capability with no methods.
|
|
330
|
+
*
|
|
331
|
+
*/
|
|
332
|
+
declare class Bootstrap extends Struct {
|
|
333
|
+
static readonly _capnp: {
|
|
334
|
+
displayName: string;
|
|
335
|
+
id: string;
|
|
336
|
+
size: ObjectSize;
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* A new question ID identifying this request, which will eventually receive a Return message
|
|
340
|
+
* containing the restored capability.
|
|
341
|
+
*
|
|
342
|
+
*/
|
|
343
|
+
get questionId(): number;
|
|
344
|
+
set questionId(value: number);
|
|
345
|
+
_adoptDeprecatedObjectId(value: Orphan<Pointer>): void;
|
|
346
|
+
_disownDeprecatedObjectId(): Orphan<Pointer>;
|
|
347
|
+
/**
|
|
348
|
+
* ** DEPRECATED **
|
|
349
|
+
*
|
|
350
|
+
* A Vat may export multiple bootstrap interfaces. In this case, `deprecatedObjectId` specifies
|
|
351
|
+
* which one to return. If this pointer is null, then the default bootstrap interface is returned.
|
|
352
|
+
*
|
|
353
|
+
* As of version 0.5, use of this field is deprecated. If a service wants to export multiple
|
|
354
|
+
* bootstrap interfaces, it should instead define a single bootstrap interface that has methods
|
|
355
|
+
* that return each of the other interfaces.
|
|
356
|
+
*
|
|
357
|
+
* **History**
|
|
358
|
+
*
|
|
359
|
+
* In the first version of Cap'n Proto RPC (0.4.x) the `Bootstrap` message was called `Restore`.
|
|
360
|
+
* At the time, it was thought that this would eventually serve as the way to restore SturdyRefs
|
|
361
|
+
* (level 2). Meanwhile, an application could offer its "main" interface on a well-known
|
|
362
|
+
* (non-secret) SturdyRef.
|
|
363
|
+
*
|
|
364
|
+
* Since level 2 RPC was not implemented at the time, the `Restore` message was in practice only
|
|
365
|
+
* used to obtain the main interface. Since most applications had only one main interface that
|
|
366
|
+
* they wanted to restore, they tended to designate this with a null `objectId`.
|
|
367
|
+
*
|
|
368
|
+
* Unfortunately, the earliest version of the EZ RPC interfaces set a precedent of exporting
|
|
369
|
+
* multiple main interfaces by allowing them to be exported under string names. In this case,
|
|
370
|
+
* `objectId` was a Text value specifying the name.
|
|
371
|
+
*
|
|
372
|
+
* All of this proved problematic for several reasons:
|
|
373
|
+
*
|
|
374
|
+
* - The arrangement assumed that a client wishing to restore a SturdyRef would know exactly what
|
|
375
|
+
* machine to connect to and would be able to immediately restore a SturdyRef on connection.
|
|
376
|
+
* However, in practice, the ability to restore SturdyRefs is itself a capability that may
|
|
377
|
+
* require going through an authentication process to obtain. Thus, it makes more sense to
|
|
378
|
+
* define a "restorer service" as a full Cap'n Proto interface. If this restorer interface is
|
|
379
|
+
* offered as the vat's bootstrap interface, then this is equivalent to the old arrangement.
|
|
380
|
+
*
|
|
381
|
+
* - Overloading "Restore" for the purpose of obtaining well-known capabilities encouraged the
|
|
382
|
+
* practice of exporting singleton services with string names. If singleton services are desired,
|
|
383
|
+
* it is better to have one main interface that has methods that can be used to obtain each
|
|
384
|
+
* service, in order to get all the usual benefits of schemas and type checking.
|
|
385
|
+
*
|
|
386
|
+
* - Overloading "Restore" also had a security problem: Often, "main" or "well-known"
|
|
387
|
+
* capabilities exported by a vat are in fact not public: they are intended to be accessed only
|
|
388
|
+
* by clients who are capable of forming a connection to the vat. This can lead to trouble if
|
|
389
|
+
* the client itself has other clients and wishes to forward some `Restore` requests from those
|
|
390
|
+
* external clients -- it has to be very careful not to allow through `Restore` requests
|
|
391
|
+
* addressing the default capability.
|
|
392
|
+
*
|
|
393
|
+
* For example, consider the case of a sandboxed Sandstorm application and its supervisor. The
|
|
394
|
+
* application exports a default capability to its supervisor that provides access to
|
|
395
|
+
* functionality that only the supervisor is supposed to access. Meanwhile, though, applications
|
|
396
|
+
* may publish other capabilities that may be persistent, in which case the application needs
|
|
397
|
+
* to field `Restore` requests that could come from anywhere. These requests of course have to
|
|
398
|
+
* pass through the supervisor, as all communications with the outside world must. But, the
|
|
399
|
+
* supervisor has to be careful not to honor an external request addressing the application's
|
|
400
|
+
* default capability, since this capability is privileged. Unfortunately, the default
|
|
401
|
+
* capability cannot be given an unguessable name, because then the supervisor itself would not
|
|
402
|
+
* be able to address it!
|
|
403
|
+
*
|
|
404
|
+
* As of Cap'n Proto 0.5, `Restore` has been renamed to `Bootstrap` and is no longer planned for
|
|
405
|
+
* use in restoring SturdyRefs.
|
|
406
|
+
*
|
|
407
|
+
* Note that 0.4 also defined a message type called `Delete` that, like `Restore`, addressed a
|
|
408
|
+
* SturdyRef, but indicated that the client would not restore the ref again in the future. This
|
|
409
|
+
* operation was never implemented, so it was removed entirely. If a "delete" operation is desired,
|
|
410
|
+
* it should exist as a method on the same interface that handles restoring SturdyRefs. However,
|
|
411
|
+
* the utility of such an operation is questionable. You wouldn't be able to rely on it for
|
|
412
|
+
* garbage collection since a client could always disappear permanently without remembering to
|
|
413
|
+
* delete all its SturdyRefs, thus leaving them dangling forever. Therefore, it is advisable to
|
|
414
|
+
* design systems such that SturdyRefs never represent "owned" pointers.
|
|
415
|
+
*
|
|
416
|
+
* For example, say a SturdyRef points to an image file hosted on some server. That image file
|
|
417
|
+
* should also live inside a collection (a gallery, perhaps) hosted on the same server, owned by
|
|
418
|
+
* a user who can delete the image at any time. If the user deletes the image, the SturdyRef
|
|
419
|
+
* stops working. On the other hand, if the SturdyRef is discarded, this has no effect on the
|
|
420
|
+
* existence of the image in its collection.
|
|
421
|
+
*
|
|
422
|
+
*/
|
|
423
|
+
get deprecatedObjectId(): Pointer;
|
|
424
|
+
_hasDeprecatedObjectId(): boolean;
|
|
425
|
+
set deprecatedObjectId(value: Pointer);
|
|
426
|
+
toString(): string;
|
|
427
|
+
}
|
|
428
|
+
declare const Call_SendResultsTo_Which: {
|
|
429
|
+
/**
|
|
430
|
+
* Send the return message back to the caller (the usual).
|
|
431
|
+
*
|
|
432
|
+
*/
|
|
433
|
+
readonly CALLER: 0;
|
|
434
|
+
/**
|
|
435
|
+
* **(level 1)**
|
|
436
|
+
*
|
|
437
|
+
* Don't actually return the results to the sender. Instead, hold on to them and await
|
|
438
|
+
* instructions from the sender regarding what to do with them. In particular, the sender
|
|
439
|
+
* may subsequently send a `Return` for some other call (which the receiver had previously made
|
|
440
|
+
* to the sender) with `takeFromOtherQuestion` set. The results from this call are then used
|
|
441
|
+
* as the results of the other call.
|
|
442
|
+
*
|
|
443
|
+
* When `yourself` is used, the receiver must still send a `Return` for the call, but sets the
|
|
444
|
+
* field `resultsSentElsewhere` in that `Return` rather than including the results.
|
|
445
|
+
*
|
|
446
|
+
* This feature can be used to implement tail calls in which a call from Vat A to Vat B ends up
|
|
447
|
+
* returning the result of a call from Vat B back to Vat A.
|
|
448
|
+
*
|
|
449
|
+
* In particular, the most common use case for this feature is when Vat A makes a call to a
|
|
450
|
+
* promise in Vat B, and then that promise ends up resolving to a capability back in Vat A.
|
|
451
|
+
* Vat B must forward all the queued calls on that promise back to Vat A, but can set `yourself`
|
|
452
|
+
* in the calls so that the results need not pass back through Vat B.
|
|
453
|
+
*
|
|
454
|
+
* For example:
|
|
455
|
+
* - Alice, in Vat A, calls foo() on Bob in Vat B.
|
|
456
|
+
* - Alice makes a pipelined call bar() on the promise returned by foo().
|
|
457
|
+
* - Later on, Bob resolves the promise from foo() to point at Carol, who lives in Vat A (next
|
|
458
|
+
* to Alice).
|
|
459
|
+
* - Vat B dutifully forwards the bar() call to Carol. Let us call this forwarded call bar'().
|
|
460
|
+
* Notice that bar() and bar'() are travelling in opposite directions on the same network
|
|
461
|
+
* link.
|
|
462
|
+
* - The `Call` for bar'() has `sendResultsTo` set to `yourself`.
|
|
463
|
+
* - Vat B sends a `Return` for bar() with `takeFromOtherQuestion` set in place of the results,
|
|
464
|
+
* with the value set to the question ID of bar'(). Vat B does not wait for bar'() to return,
|
|
465
|
+
* as doing so would introduce unnecessary round trip latency.
|
|
466
|
+
* - Vat A receives bar'() and delivers it to Carol.
|
|
467
|
+
* - When bar'() returns, Vat A sends a `Return` for bar'() to Vat B, with `resultsSentElsewhere`
|
|
468
|
+
* set in place of results.
|
|
469
|
+
* - Vat A sends a `Finish` for the bar() call to Vat B.
|
|
470
|
+
* - Vat B receives the `Finish` for bar() and sends a `Finish` for bar'().
|
|
471
|
+
*
|
|
472
|
+
*/
|
|
473
|
+
readonly YOURSELF: 1;
|
|
474
|
+
/**
|
|
475
|
+
* **(level 3)**
|
|
476
|
+
*
|
|
477
|
+
* The call's result should be returned to a different vat. The receiver (the callee) expects
|
|
478
|
+
* to receive an `Accept` message from the indicated vat, and should return the call's result
|
|
479
|
+
* to it, rather than to the sender of the `Call`.
|
|
480
|
+
*
|
|
481
|
+
* This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
|
|
482
|
+
* messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
|
|
483
|
+
* Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
|
|
484
|
+
* an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
|
|
485
|
+
* also sends a `Return` to Vat B with `resultsSentElsewhere`.
|
|
486
|
+
*
|
|
487
|
+
*/
|
|
488
|
+
readonly THIRD_PARTY: 2;
|
|
489
|
+
};
|
|
490
|
+
type Call_SendResultsTo_Which = (typeof Call_SendResultsTo_Which)[keyof typeof Call_SendResultsTo_Which];
|
|
491
|
+
/**
|
|
492
|
+
* Where should the return message be sent?
|
|
493
|
+
*
|
|
494
|
+
*/
|
|
495
|
+
declare class Call_SendResultsTo extends Struct {
|
|
496
|
+
static readonly CALLER: 0;
|
|
497
|
+
static readonly YOURSELF: 1;
|
|
498
|
+
static readonly THIRD_PARTY: 2;
|
|
499
|
+
static readonly _capnp: {
|
|
500
|
+
displayName: string;
|
|
501
|
+
id: string;
|
|
502
|
+
size: ObjectSize;
|
|
503
|
+
};
|
|
504
|
+
get _isCaller(): boolean;
|
|
505
|
+
set caller(_: true);
|
|
506
|
+
get _isYourself(): boolean;
|
|
507
|
+
set yourself(_: true);
|
|
508
|
+
_adoptThirdParty(value: Orphan<Pointer>): void;
|
|
509
|
+
_disownThirdParty(): Orphan<Pointer>;
|
|
510
|
+
/**
|
|
511
|
+
* **(level 3)**
|
|
512
|
+
*
|
|
513
|
+
* The call's result should be returned to a different vat. The receiver (the callee) expects
|
|
514
|
+
* to receive an `Accept` message from the indicated vat, and should return the call's result
|
|
515
|
+
* to it, rather than to the sender of the `Call`.
|
|
516
|
+
*
|
|
517
|
+
* This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
|
|
518
|
+
* messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
|
|
519
|
+
* Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
|
|
520
|
+
* an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
|
|
521
|
+
* also sends a `Return` to Vat B with `resultsSentElsewhere`.
|
|
522
|
+
*
|
|
523
|
+
*/
|
|
524
|
+
get thirdParty(): Pointer;
|
|
525
|
+
_hasThirdParty(): boolean;
|
|
526
|
+
get _isThirdParty(): boolean;
|
|
527
|
+
set thirdParty(value: Pointer);
|
|
528
|
+
toString(): string;
|
|
529
|
+
which(): Call_SendResultsTo_Which;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* **(level 0)**
|
|
533
|
+
*
|
|
534
|
+
* Message type initiating a method call on a capability.
|
|
535
|
+
*
|
|
536
|
+
*/
|
|
537
|
+
declare class Call extends Struct {
|
|
538
|
+
static readonly _capnp: {
|
|
539
|
+
displayName: string;
|
|
540
|
+
id: string;
|
|
541
|
+
size: ObjectSize;
|
|
542
|
+
defaultAllowThirdPartyTailCall: DataView<ArrayBufferLike>;
|
|
543
|
+
defaultNoPromisePipelining: DataView<ArrayBufferLike>;
|
|
544
|
+
defaultOnlyPromisePipeline: DataView<ArrayBufferLike>;
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* A number, chosen by the caller, that identifies this call in future messages. This number
|
|
548
|
+
* must be different from all other calls originating from the same end of the connection (but
|
|
549
|
+
* may overlap with question IDs originating from the opposite end). A fine strategy is to use
|
|
550
|
+
* sequential question IDs, but the recipient should not assume this.
|
|
551
|
+
*
|
|
552
|
+
* A question ID can be reused once both:
|
|
553
|
+
* - A matching Return has been received from the callee.
|
|
554
|
+
* - A matching Finish has been sent from the caller.
|
|
555
|
+
*
|
|
556
|
+
*/
|
|
557
|
+
get questionId(): number;
|
|
558
|
+
set questionId(value: number);
|
|
559
|
+
_adoptTarget(value: Orphan<MessageTarget>): void;
|
|
560
|
+
_disownTarget(): Orphan<MessageTarget>;
|
|
561
|
+
/**
|
|
562
|
+
* The object that should receive this call.
|
|
563
|
+
*
|
|
564
|
+
*/
|
|
565
|
+
get target(): MessageTarget;
|
|
566
|
+
_hasTarget(): boolean;
|
|
567
|
+
_initTarget(): MessageTarget;
|
|
568
|
+
set target(value: MessageTarget);
|
|
569
|
+
/**
|
|
570
|
+
* The type ID of the interface being called. Each capability may implement multiple interfaces.
|
|
571
|
+
*
|
|
572
|
+
*/
|
|
573
|
+
get interfaceId(): bigint;
|
|
574
|
+
set interfaceId(value: bigint);
|
|
575
|
+
/**
|
|
576
|
+
* The ordinal number of the method to call within the requested interface.
|
|
577
|
+
*
|
|
578
|
+
*/
|
|
579
|
+
get methodId(): number;
|
|
580
|
+
set methodId(value: number);
|
|
581
|
+
/**
|
|
582
|
+
* Indicates whether or not the receiver is allowed to send a `Return` containing
|
|
583
|
+
* `acceptFromThirdParty`. Level 3 implementations should set this true. Otherwise, the callee
|
|
584
|
+
* will have to proxy the return in the case of a tail call to a third-party vat.
|
|
585
|
+
*
|
|
586
|
+
*/
|
|
587
|
+
get allowThirdPartyTailCall(): boolean;
|
|
588
|
+
set allowThirdPartyTailCall(value: boolean);
|
|
589
|
+
/**
|
|
590
|
+
* If true, the sender promises that it won't make any promise-pipelined calls on the results of
|
|
591
|
+
* this call. If it breaks this promise, the receiver may throw an arbitrary error from such
|
|
592
|
+
* calls.
|
|
593
|
+
*
|
|
594
|
+
* The receiver may use this as an optimization, by skipping the bookkeeping needed for pipelining
|
|
595
|
+
* when no pipelined calls are expected. The sender typically sets this to false when the method's
|
|
596
|
+
* schema does not specify any return capabilities.
|
|
597
|
+
*
|
|
598
|
+
*/
|
|
599
|
+
get noPromisePipelining(): boolean;
|
|
600
|
+
set noPromisePipelining(value: boolean);
|
|
601
|
+
/**
|
|
602
|
+
* If true, the sender only plans to use this call to make pipelined calls. The receiver need not
|
|
603
|
+
* send a `Return` message (but is still allowed to do so).
|
|
604
|
+
*
|
|
605
|
+
* Since the sender does not know whether a `Return` will be sent, it must release all state
|
|
606
|
+
* related to the call when it sends `Finish`. However, in the case that the callee does not
|
|
607
|
+
* recognize this hint and chooses to send a `Return`, then technically the caller is not allowed
|
|
608
|
+
* to reuse the question ID until it receives said `Return`. This creates a conundrum: How does
|
|
609
|
+
* the caller decide when it's OK to reuse the ID? To sidestep the problem, the C++ implementation
|
|
610
|
+
* uses high-numbered IDs (with the high-order bit set) for such calls, and cycles through the
|
|
611
|
+
* IDs in order. If all 2^31 IDs in this space are used without ever seeing a `Return`, then the
|
|
612
|
+
* implementation assumes that the other end is in fact honoring the hint, and the ID counter is
|
|
613
|
+
* allowed to loop around. If a `Return` is ever seen when `onlyPromisePipeline` was set, then
|
|
614
|
+
* the implementation stops using this hint.
|
|
615
|
+
*
|
|
616
|
+
*/
|
|
617
|
+
get onlyPromisePipeline(): boolean;
|
|
618
|
+
set onlyPromisePipeline(value: boolean);
|
|
619
|
+
_adoptParams(value: Orphan<Payload>): void;
|
|
620
|
+
_disownParams(): Orphan<Payload>;
|
|
621
|
+
/**
|
|
622
|
+
* The call parameters. `params.content` is a struct whose fields correspond to the parameters of
|
|
623
|
+
* the method.
|
|
624
|
+
*
|
|
625
|
+
*/
|
|
626
|
+
get params(): Payload;
|
|
627
|
+
_hasParams(): boolean;
|
|
628
|
+
_initParams(): Payload;
|
|
629
|
+
set params(value: Payload);
|
|
630
|
+
/**
|
|
631
|
+
* Where should the return message be sent?
|
|
632
|
+
*
|
|
633
|
+
*/
|
|
634
|
+
get sendResultsTo(): Call_SendResultsTo;
|
|
635
|
+
_initSendResultsTo(): Call_SendResultsTo;
|
|
636
|
+
toString(): string;
|
|
637
|
+
}
|
|
638
|
+
declare const Return_Which: {
|
|
639
|
+
/**
|
|
640
|
+
* Equal to the QuestionId of the corresponding `Call` message.
|
|
641
|
+
*
|
|
642
|
+
*/
|
|
643
|
+
readonly RESULTS: 0;
|
|
644
|
+
/**
|
|
645
|
+
* If true, all capabilities that were in the params should be considered released. The sender
|
|
646
|
+
* must not send separate `Release` messages for them. Level 0 implementations in particular
|
|
647
|
+
* should always set this true. This defaults true because if level 0 implementations forget to
|
|
648
|
+
* set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
|
|
649
|
+
* to set it to false they'll quickly get errors.
|
|
650
|
+
*
|
|
651
|
+
* The receiver should act as if the sender had sent a release message with count=1 for each
|
|
652
|
+
* CapDescriptor in the original Call message.
|
|
653
|
+
*
|
|
654
|
+
*/
|
|
655
|
+
readonly EXCEPTION: 1;
|
|
656
|
+
/**
|
|
657
|
+
* The result.
|
|
658
|
+
*
|
|
659
|
+
* For regular method calls, `results.content` points to the result struct.
|
|
660
|
+
*
|
|
661
|
+
* For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
|
|
662
|
+
* capability (rather than a struct), and `results.content` is just a capability pointer with
|
|
663
|
+
* index 0. A `Finish` is still required in this case.
|
|
664
|
+
*
|
|
665
|
+
*/
|
|
666
|
+
readonly CANCELED: 2;
|
|
667
|
+
/**
|
|
668
|
+
* Indicates that the call failed and explains why.
|
|
669
|
+
*
|
|
670
|
+
*/
|
|
671
|
+
readonly RESULTS_SENT_ELSEWHERE: 3;
|
|
672
|
+
/**
|
|
673
|
+
* Indicates that the call was canceled due to the caller sending a Finish message
|
|
674
|
+
* before the call had completed.
|
|
675
|
+
*
|
|
676
|
+
*/
|
|
677
|
+
readonly TAKE_FROM_OTHER_QUESTION: 4;
|
|
678
|
+
/**
|
|
679
|
+
* This is set when returning from a `Call` that had `sendResultsTo` set to something other
|
|
680
|
+
* than `caller`.
|
|
681
|
+
*
|
|
682
|
+
* It doesn't matter too much when this is sent, as the receiver doesn't need to do anything
|
|
683
|
+
* with it, but the C++ implementation appears to wait for the call to finish before sending
|
|
684
|
+
* this.
|
|
685
|
+
*
|
|
686
|
+
*/
|
|
687
|
+
readonly ACCEPT_FROM_THIRD_PARTY: 5;
|
|
688
|
+
};
|
|
689
|
+
type Return_Which = (typeof Return_Which)[keyof typeof Return_Which];
|
|
690
|
+
/**
|
|
691
|
+
* **(level 0)**
|
|
692
|
+
*
|
|
693
|
+
* Message type sent from callee to caller indicating that the call has completed.
|
|
694
|
+
*
|
|
695
|
+
*/
|
|
696
|
+
declare class Return extends Struct {
|
|
697
|
+
static readonly RESULTS: 0;
|
|
698
|
+
static readonly EXCEPTION: 1;
|
|
699
|
+
static readonly CANCELED: 2;
|
|
700
|
+
static readonly RESULTS_SENT_ELSEWHERE: 3;
|
|
701
|
+
static readonly TAKE_FROM_OTHER_QUESTION: 4;
|
|
702
|
+
static readonly ACCEPT_FROM_THIRD_PARTY: 5;
|
|
703
|
+
static readonly _capnp: {
|
|
704
|
+
displayName: string;
|
|
705
|
+
id: string;
|
|
706
|
+
size: ObjectSize;
|
|
707
|
+
defaultReleaseParamCaps: DataView<ArrayBufferLike>;
|
|
708
|
+
defaultNoFinishNeeded: DataView<ArrayBufferLike>;
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Equal to the QuestionId of the corresponding `Call` message.
|
|
712
|
+
*
|
|
713
|
+
*/
|
|
714
|
+
get answerId(): number;
|
|
715
|
+
set answerId(value: number);
|
|
716
|
+
/**
|
|
717
|
+
* If true, all capabilities that were in the params should be considered released. The sender
|
|
718
|
+
* must not send separate `Release` messages for them. Level 0 implementations in particular
|
|
719
|
+
* should always set this true. This defaults true because if level 0 implementations forget to
|
|
720
|
+
* set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
|
|
721
|
+
* to set it to false they'll quickly get errors.
|
|
722
|
+
*
|
|
723
|
+
* The receiver should act as if the sender had sent a release message with count=1 for each
|
|
724
|
+
* CapDescriptor in the original Call message.
|
|
725
|
+
*
|
|
726
|
+
*/
|
|
727
|
+
get releaseParamCaps(): boolean;
|
|
728
|
+
set releaseParamCaps(value: boolean);
|
|
729
|
+
/**
|
|
730
|
+
* If true, the sender does not need the receiver to send a `Finish` message; its answer table
|
|
731
|
+
* entry has already been cleaned up. This implies that the results do not contain any
|
|
732
|
+
* capabilities, since the `Finish` message would normally release those capabilities from
|
|
733
|
+
* promise pipelining responsibility. The caller may still send a `Finish` message if it wants,
|
|
734
|
+
* which will be silently ignored by the callee.
|
|
735
|
+
*
|
|
736
|
+
*/
|
|
737
|
+
get noFinishNeeded(): boolean;
|
|
738
|
+
set noFinishNeeded(value: boolean);
|
|
739
|
+
_adoptResults(value: Orphan<Payload>): void;
|
|
740
|
+
_disownResults(): Orphan<Payload>;
|
|
741
|
+
/**
|
|
742
|
+
* The result.
|
|
743
|
+
*
|
|
744
|
+
* For regular method calls, `results.content` points to the result struct.
|
|
745
|
+
*
|
|
746
|
+
* For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
|
|
747
|
+
* capability (rather than a struct), and `results.content` is just a capability pointer with
|
|
748
|
+
* index 0. A `Finish` is still required in this case.
|
|
749
|
+
*
|
|
750
|
+
*/
|
|
751
|
+
get results(): Payload;
|
|
752
|
+
_hasResults(): boolean;
|
|
753
|
+
_initResults(): Payload;
|
|
754
|
+
get _isResults(): boolean;
|
|
755
|
+
set results(value: Payload);
|
|
756
|
+
_adoptException(value: Orphan<Exception>): void;
|
|
757
|
+
_disownException(): Orphan<Exception>;
|
|
758
|
+
/**
|
|
759
|
+
* Indicates that the call failed and explains why.
|
|
760
|
+
*
|
|
761
|
+
*/
|
|
762
|
+
get exception(): Exception;
|
|
763
|
+
_hasException(): boolean;
|
|
764
|
+
_initException(): Exception;
|
|
765
|
+
get _isException(): boolean;
|
|
766
|
+
set exception(value: Exception);
|
|
767
|
+
get _isCanceled(): boolean;
|
|
768
|
+
set canceled(_: true);
|
|
769
|
+
get _isResultsSentElsewhere(): boolean;
|
|
770
|
+
set resultsSentElsewhere(_: true);
|
|
771
|
+
/**
|
|
772
|
+
* The sender has also sent (before this message) a `Call` with the given question ID and with
|
|
773
|
+
* `sendResultsTo.yourself` set, and the results of that other call should be used as the
|
|
774
|
+
* results here. `takeFromOtherQuestion` can only used once per question.
|
|
775
|
+
*
|
|
776
|
+
*/
|
|
777
|
+
get takeFromOtherQuestion(): number;
|
|
778
|
+
get _isTakeFromOtherQuestion(): boolean;
|
|
779
|
+
set takeFromOtherQuestion(value: number);
|
|
780
|
+
_adoptAcceptFromThirdParty(value: Orphan<Pointer>): void;
|
|
781
|
+
_disownAcceptFromThirdParty(): Orphan<Pointer>;
|
|
782
|
+
/**
|
|
783
|
+
* **(level 3)**
|
|
784
|
+
*
|
|
785
|
+
* The caller should contact a third-party vat to pick up the results. An `Accept` message
|
|
786
|
+
* sent to the vat will return the result. This pairs with `Call.sendResultsTo.thirdParty`.
|
|
787
|
+
* It should only be used if the corresponding `Call` had `allowThirdPartyTailCall` set.
|
|
788
|
+
*
|
|
789
|
+
*/
|
|
790
|
+
get acceptFromThirdParty(): Pointer;
|
|
791
|
+
_hasAcceptFromThirdParty(): boolean;
|
|
792
|
+
get _isAcceptFromThirdParty(): boolean;
|
|
793
|
+
set acceptFromThirdParty(value: Pointer);
|
|
794
|
+
toString(): string;
|
|
795
|
+
which(): Return_Which;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* **(level 0)**
|
|
799
|
+
*
|
|
800
|
+
* Message type sent from the caller to the callee to indicate:
|
|
801
|
+
* 1) The questionId will no longer be used in any messages sent by the callee (no further
|
|
802
|
+
* pipelined requests).
|
|
803
|
+
* 2) If the call has not returned yet, the caller no longer cares about the result. If nothing
|
|
804
|
+
* else cares about the result either (e.g. there are no other outstanding calls pipelined on
|
|
805
|
+
* the result of this one) then the callee may wish to immediately cancel the operation and
|
|
806
|
+
* send back a Return message with "canceled" set. However, implementations are not required
|
|
807
|
+
* to support premature cancellation -- instead, the implementation may wait until the call
|
|
808
|
+
* actually completes and send a normal `Return` message.
|
|
809
|
+
*
|
|
810
|
+
* TODO(someday): Should we separate (1) and implicitly releasing result capabilities? It would be
|
|
811
|
+
* possible and useful to notify the server that it doesn't need to keep around the response to
|
|
812
|
+
* service pipeline requests even though the caller still wants to receive it / hasn't yet
|
|
813
|
+
* finished processing it. It could also be useful to notify the server that it need not marshal
|
|
814
|
+
* the results because the caller doesn't want them anyway, even if the caller is still sending
|
|
815
|
+
* pipelined calls, although this seems less useful (just saving some bytes on the wire).
|
|
816
|
+
*
|
|
817
|
+
*/
|
|
818
|
+
declare class Finish extends Struct {
|
|
819
|
+
static readonly _capnp: {
|
|
820
|
+
displayName: string;
|
|
821
|
+
id: string;
|
|
822
|
+
size: ObjectSize;
|
|
823
|
+
defaultReleaseResultCaps: DataView<ArrayBufferLike>;
|
|
824
|
+
defaultRequireEarlyCancellationWorkaround: DataView<ArrayBufferLike>;
|
|
825
|
+
};
|
|
826
|
+
/**
|
|
827
|
+
* ID of the call whose result is to be released.
|
|
828
|
+
*
|
|
829
|
+
*/
|
|
830
|
+
get questionId(): number;
|
|
831
|
+
set questionId(value: number);
|
|
832
|
+
/**
|
|
833
|
+
* If true, all capabilities that were in the results should be considered released. The sender
|
|
834
|
+
* must not send separate `Release` messages for them. Level 0 implementations in particular
|
|
835
|
+
* should always set this true. This defaults true because if level 0 implementations forget to
|
|
836
|
+
* set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
|
|
837
|
+
* set it false they'll quickly get errors.
|
|
838
|
+
*
|
|
839
|
+
*/
|
|
840
|
+
get releaseResultCaps(): boolean;
|
|
841
|
+
set releaseResultCaps(value: boolean);
|
|
842
|
+
/**
|
|
843
|
+
* If true, if the RPC system receives this Finish message before the original call has even been
|
|
844
|
+
* delivered, it should defer cancellation util after delivery. In particular, this gives the
|
|
845
|
+
* destination object a chance to opt out of cancellation, e.g. as controlled by the
|
|
846
|
+
* `allowCancellation` annotation defined in `c++.capnp`.
|
|
847
|
+
*
|
|
848
|
+
* This is a work-around. Versions 1.0 and up of Cap'n Proto always set this to false. However,
|
|
849
|
+
* older versions of Cap'n Proto unintentionally exhibited this errant behavior by default, and
|
|
850
|
+
* as a result programs built with older versions could be inadvertently relying on their peers
|
|
851
|
+
* to implement the behavior. The purpose of this flag is to let newer versions know when the
|
|
852
|
+
* peer is an older version, so that it can attempt to work around the issue.
|
|
853
|
+
*
|
|
854
|
+
* See also comments in handleFinish() in rpc.c++ for more details.
|
|
855
|
+
*
|
|
856
|
+
*/
|
|
857
|
+
get requireEarlyCancellationWorkaround(): boolean;
|
|
858
|
+
set requireEarlyCancellationWorkaround(value: boolean);
|
|
859
|
+
toString(): string;
|
|
860
|
+
}
|
|
861
|
+
declare const Resolve_Which: {
|
|
862
|
+
/**
|
|
863
|
+
* The ID of the promise to be resolved.
|
|
864
|
+
*
|
|
865
|
+
* Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
|
|
866
|
+
* _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
|
|
867
|
+
* will release the export soon after receiving `Resolve`, and the sender will not send this
|
|
868
|
+
* `ExportId` again until it has been released and recycled.
|
|
869
|
+
*
|
|
870
|
+
* When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
|
|
871
|
+
* this indicates that the sender will follow up at some point with a `Resolve` message. If the
|
|
872
|
+
* same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
|
|
873
|
+
* same ID is sent again later _after_ a `Resolve`, it can only be because the export's
|
|
874
|
+
* reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
|
|
875
|
+
* this later promise does _not_ correspond to the earlier `Resolve`.
|
|
876
|
+
*
|
|
877
|
+
* If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
|
|
878
|
+
* message may or may not still be sent (the `Resolve` may have already been in-flight when
|
|
879
|
+
* `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
|
|
880
|
+
* any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
|
|
881
|
+
* the receiver has no knowledge, because it already released it earlier. In this case, the
|
|
882
|
+
* receiver should simply release the capability to which the promise resolved.
|
|
883
|
+
*
|
|
884
|
+
*/
|
|
885
|
+
readonly CAP: 0;
|
|
886
|
+
/**
|
|
887
|
+
* The object to which the promise resolved.
|
|
888
|
+
*
|
|
889
|
+
* The sender promises that from this point forth, until `promiseId` is released, it shall
|
|
890
|
+
* simply forward all messages to the capability designated by `cap`. This is true even if
|
|
891
|
+
* `cap` itself happens to designate another promise, and that other promise later resolves --
|
|
892
|
+
* messages sent to `promiseId` shall still go to that other promise, not to its resolution.
|
|
893
|
+
* This is important in the case that the receiver of the `Resolve` ends up sending a
|
|
894
|
+
* `Disembargo` message towards `promiseId` in order to control message ordering -- that
|
|
895
|
+
* `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
|
|
896
|
+
* if that object is itself a promise.
|
|
897
|
+
*
|
|
898
|
+
*/
|
|
899
|
+
readonly EXCEPTION: 1;
|
|
900
|
+
};
|
|
901
|
+
type Resolve_Which = (typeof Resolve_Which)[keyof typeof Resolve_Which];
|
|
902
|
+
/**
|
|
903
|
+
* **(level 1)**
|
|
904
|
+
*
|
|
905
|
+
* Message type sent to indicate that a previously-sent promise has now been resolved to some other
|
|
906
|
+
* object (possibly another promise) -- or broken, or canceled.
|
|
907
|
+
*
|
|
908
|
+
* Keep in mind that it's possible for a `Resolve` to be sent to a level 0 implementation that
|
|
909
|
+
* doesn't implement it. For example, a method call or return might contain a capability in the
|
|
910
|
+
* payload. Normally this is fine even if the receiver is level 0, because they will implicitly
|
|
911
|
+
* release all such capabilities on return / finish. But if the cap happens to be a promise, then
|
|
912
|
+
* a follow-up `Resolve` may be sent regardless of this release. The level 0 receiver will reply
|
|
913
|
+
* with an `unimplemented` message, and the sender (of the `Resolve`) can respond to this as if the
|
|
914
|
+
* receiver had immediately released any capability to which the promise resolved.
|
|
915
|
+
*
|
|
916
|
+
* When implementing promise resolution, it's important to understand how embargos work and the
|
|
917
|
+
* tricky case of the Tribble 4-way race condition. See the comments for the Disembargo message,
|
|
918
|
+
* below.
|
|
919
|
+
*
|
|
920
|
+
*/
|
|
921
|
+
declare class Resolve extends Struct {
|
|
922
|
+
static readonly CAP: 0;
|
|
923
|
+
static readonly EXCEPTION: 1;
|
|
924
|
+
static readonly _capnp: {
|
|
925
|
+
displayName: string;
|
|
926
|
+
id: string;
|
|
927
|
+
size: ObjectSize;
|
|
928
|
+
};
|
|
929
|
+
/**
|
|
930
|
+
* The ID of the promise to be resolved.
|
|
931
|
+
*
|
|
932
|
+
* Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
|
|
933
|
+
* _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
|
|
934
|
+
* will release the export soon after receiving `Resolve`, and the sender will not send this
|
|
935
|
+
* `ExportId` again until it has been released and recycled.
|
|
936
|
+
*
|
|
937
|
+
* When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
|
|
938
|
+
* this indicates that the sender will follow up at some point with a `Resolve` message. If the
|
|
939
|
+
* same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
|
|
940
|
+
* same ID is sent again later _after_ a `Resolve`, it can only be because the export's
|
|
941
|
+
* reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
|
|
942
|
+
* this later promise does _not_ correspond to the earlier `Resolve`.
|
|
943
|
+
*
|
|
944
|
+
* If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
|
|
945
|
+
* message may or may not still be sent (the `Resolve` may have already been in-flight when
|
|
946
|
+
* `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
|
|
947
|
+
* any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
|
|
948
|
+
* the receiver has no knowledge, because it already released it earlier. In this case, the
|
|
949
|
+
* receiver should simply release the capability to which the promise resolved.
|
|
950
|
+
*
|
|
951
|
+
*/
|
|
952
|
+
get promiseId(): number;
|
|
953
|
+
set promiseId(value: number);
|
|
954
|
+
_adoptCap(value: Orphan<CapDescriptor>): void;
|
|
955
|
+
_disownCap(): Orphan<CapDescriptor>;
|
|
956
|
+
/**
|
|
957
|
+
* The object to which the promise resolved.
|
|
958
|
+
*
|
|
959
|
+
* The sender promises that from this point forth, until `promiseId` is released, it shall
|
|
960
|
+
* simply forward all messages to the capability designated by `cap`. This is true even if
|
|
961
|
+
* `cap` itself happens to designate another promise, and that other promise later resolves --
|
|
962
|
+
* messages sent to `promiseId` shall still go to that other promise, not to its resolution.
|
|
963
|
+
* This is important in the case that the receiver of the `Resolve` ends up sending a
|
|
964
|
+
* `Disembargo` message towards `promiseId` in order to control message ordering -- that
|
|
965
|
+
* `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
|
|
966
|
+
* if that object is itself a promise.
|
|
967
|
+
*
|
|
968
|
+
*/
|
|
969
|
+
get cap(): CapDescriptor;
|
|
970
|
+
_hasCap(): boolean;
|
|
971
|
+
_initCap(): CapDescriptor;
|
|
972
|
+
get _isCap(): boolean;
|
|
973
|
+
set cap(value: CapDescriptor);
|
|
974
|
+
_adoptException(value: Orphan<Exception>): void;
|
|
975
|
+
_disownException(): Orphan<Exception>;
|
|
976
|
+
/**
|
|
977
|
+
* Indicates that the promise was broken.
|
|
978
|
+
*
|
|
979
|
+
*/
|
|
980
|
+
get exception(): Exception;
|
|
981
|
+
_hasException(): boolean;
|
|
982
|
+
_initException(): Exception;
|
|
983
|
+
get _isException(): boolean;
|
|
984
|
+
set exception(value: Exception);
|
|
985
|
+
toString(): string;
|
|
986
|
+
which(): Resolve_Which;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* **(level 1)**
|
|
990
|
+
*
|
|
991
|
+
* Message type sent to indicate that the sender is done with the given capability and the receiver
|
|
992
|
+
* can free resources allocated to it.
|
|
993
|
+
*
|
|
994
|
+
*/
|
|
995
|
+
declare class Release extends Struct {
|
|
996
|
+
static readonly _capnp: {
|
|
997
|
+
displayName: string;
|
|
998
|
+
id: string;
|
|
999
|
+
size: ObjectSize;
|
|
1000
|
+
};
|
|
1001
|
+
/**
|
|
1002
|
+
* What to release.
|
|
1003
|
+
*
|
|
1004
|
+
*/
|
|
1005
|
+
get id(): number;
|
|
1006
|
+
set id(value: number);
|
|
1007
|
+
/**
|
|
1008
|
+
* The amount by which to decrement the reference count. The export is only actually released
|
|
1009
|
+
* when the reference count reaches zero.
|
|
1010
|
+
*
|
|
1011
|
+
*/
|
|
1012
|
+
get referenceCount(): number;
|
|
1013
|
+
set referenceCount(value: number);
|
|
1014
|
+
toString(): string;
|
|
1015
|
+
}
|
|
1016
|
+
declare const Disembargo_Context_Which: {
|
|
1017
|
+
/**
|
|
1018
|
+
* The sender is requesting a disembargo on a promise that is known to resolve back to a
|
|
1019
|
+
* capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
|
|
1020
|
+
* on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
|
|
1021
|
+
* set to the same value as `senderLoopback`. This value is chosen by the sender, and since
|
|
1022
|
+
* it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
|
|
1023
|
+
* the value is unambiguous.
|
|
1024
|
+
*
|
|
1025
|
+
* The receiver must verify that the target capability actually resolves back to the sender's
|
|
1026
|
+
* vat. Otherwise, the sender has committed a protocol error and should be disconnected.
|
|
1027
|
+
*
|
|
1028
|
+
*/
|
|
1029
|
+
readonly SENDER_LOOPBACK: 0;
|
|
1030
|
+
/**
|
|
1031
|
+
* The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
|
|
1032
|
+
* this capability, and that Disembargo is now being echoed back.
|
|
1033
|
+
*
|
|
1034
|
+
*/
|
|
1035
|
+
readonly RECEIVER_LOOPBACK: 1;
|
|
1036
|
+
/**
|
|
1037
|
+
* **(level 3)**
|
|
1038
|
+
*
|
|
1039
|
+
* The sender is requesting a disembargo on a promise that is known to resolve to a third-party
|
|
1040
|
+
* capability that the sender is currently in the process of accepting (using `Accept`).
|
|
1041
|
+
* The receiver of this `Disembargo` has an outstanding `Provide` on said capability. The
|
|
1042
|
+
* receiver should now send a `Disembargo` with `provide` set to the question ID of that
|
|
1043
|
+
* `Provide` message.
|
|
1044
|
+
*
|
|
1045
|
+
* See `Accept.embargo` for an example.
|
|
1046
|
+
*
|
|
1047
|
+
*/
|
|
1048
|
+
readonly ACCEPT: 2;
|
|
1049
|
+
/**
|
|
1050
|
+
* **(level 3)**
|
|
1051
|
+
*
|
|
1052
|
+
* The sender is requesting a disembargo on a capability currently being provided to a third
|
|
1053
|
+
* party. The question ID identifies the `Provide` message previously sent by the sender to
|
|
1054
|
+
* this capability. On receipt, the receiver (the capability host) shall release the embargo
|
|
1055
|
+
* on the `Accept` message that it has received from the third party. See `Accept.embargo` for
|
|
1056
|
+
* an example.
|
|
1057
|
+
*
|
|
1058
|
+
*/
|
|
1059
|
+
readonly PROVIDE: 3;
|
|
1060
|
+
};
|
|
1061
|
+
type Disembargo_Context_Which = (typeof Disembargo_Context_Which)[keyof typeof Disembargo_Context_Which];
|
|
1062
|
+
declare class Disembargo_Context extends Struct {
|
|
1063
|
+
static readonly SENDER_LOOPBACK: 0;
|
|
1064
|
+
static readonly RECEIVER_LOOPBACK: 1;
|
|
1065
|
+
static readonly ACCEPT: 2;
|
|
1066
|
+
static readonly PROVIDE: 3;
|
|
1067
|
+
static readonly _capnp: {
|
|
1068
|
+
displayName: string;
|
|
1069
|
+
id: string;
|
|
1070
|
+
size: ObjectSize;
|
|
1071
|
+
};
|
|
1072
|
+
/**
|
|
1073
|
+
* The sender is requesting a disembargo on a promise that is known to resolve back to a
|
|
1074
|
+
* capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
|
|
1075
|
+
* on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
|
|
1076
|
+
* set to the same value as `senderLoopback`. This value is chosen by the sender, and since
|
|
1077
|
+
* it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
|
|
1078
|
+
* the value is unambiguous.
|
|
1079
|
+
*
|
|
1080
|
+
* The receiver must verify that the target capability actually resolves back to the sender's
|
|
1081
|
+
* vat. Otherwise, the sender has committed a protocol error and should be disconnected.
|
|
1082
|
+
*
|
|
1083
|
+
*/
|
|
1084
|
+
get senderLoopback(): number;
|
|
1085
|
+
get _isSenderLoopback(): boolean;
|
|
1086
|
+
set senderLoopback(value: number);
|
|
1087
|
+
/**
|
|
1088
|
+
* The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
|
|
1089
|
+
* this capability, and that Disembargo is now being echoed back.
|
|
1090
|
+
*
|
|
1091
|
+
*/
|
|
1092
|
+
get receiverLoopback(): number;
|
|
1093
|
+
get _isReceiverLoopback(): boolean;
|
|
1094
|
+
set receiverLoopback(value: number);
|
|
1095
|
+
get _isAccept(): boolean;
|
|
1096
|
+
set accept(_: true);
|
|
1097
|
+
/**
|
|
1098
|
+
* **(level 3)**
|
|
1099
|
+
*
|
|
1100
|
+
* The sender is requesting a disembargo on a capability currently being provided to a third
|
|
1101
|
+
* party. The question ID identifies the `Provide` message previously sent by the sender to
|
|
1102
|
+
* this capability. On receipt, the receiver (the capability host) shall release the embargo
|
|
1103
|
+
* on the `Accept` message that it has received from the third party. See `Accept.embargo` for
|
|
1104
|
+
* an example.
|
|
1105
|
+
*
|
|
1106
|
+
*/
|
|
1107
|
+
get provide(): number;
|
|
1108
|
+
get _isProvide(): boolean;
|
|
1109
|
+
set provide(value: number);
|
|
1110
|
+
toString(): string;
|
|
1111
|
+
which(): Disembargo_Context_Which;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* **(level 1)**
|
|
1115
|
+
*
|
|
1116
|
+
* Message sent to indicate that an embargo on a recently-resolved promise may now be lifted.
|
|
1117
|
+
*
|
|
1118
|
+
* Embargos are used to enforce E-order in the presence of promise resolution. That is, if an
|
|
1119
|
+
* application makes two calls foo() and bar() on the same capability reference, in that order,
|
|
1120
|
+
* the calls should be delivered in the order in which they were made. But if foo() is called
|
|
1121
|
+
* on a promise, and that promise happens to resolve before bar() is called, then the two calls
|
|
1122
|
+
* may travel different paths over the network, and thus could arrive in the wrong order. In
|
|
1123
|
+
* this case, the call to `bar()` must be embargoed, and a `Disembargo` message must be sent along
|
|
1124
|
+
* the same path as `foo()` to ensure that the `Disembargo` arrives after `foo()`. Once the
|
|
1125
|
+
* `Disembargo` arrives, `bar()` can then be delivered.
|
|
1126
|
+
*
|
|
1127
|
+
* There are two particular cases where embargos are important. Consider object Alice, in Vat A,
|
|
1128
|
+
* who holds a promise P, pointing towards Vat B, that eventually resolves to Carol. The two
|
|
1129
|
+
* cases are:
|
|
1130
|
+
* - Carol lives in Vat A, i.e. next to Alice. In this case, Vat A needs to send a `Disembargo`
|
|
1131
|
+
* message that echos through Vat B and back, to ensure that all pipelined calls on the promise
|
|
1132
|
+
* have been delivered.
|
|
1133
|
+
* - Carol lives in a different Vat C. When the promise resolves, a three-party handoff occurs
|
|
1134
|
+
* (see `Provide` and `Accept`, which constitute level 3 of the protocol). In this case, we
|
|
1135
|
+
* piggyback on the state that has already been set up to handle the handoff: the `Accept`
|
|
1136
|
+
* message (from Vat A to Vat C) is embargoed, as are all pipelined messages sent to it, while
|
|
1137
|
+
* a `Disembargo` message is sent from Vat A through Vat B to Vat C. See `Accept.embargo` for
|
|
1138
|
+
* an example.
|
|
1139
|
+
*
|
|
1140
|
+
* Note that in the case where Carol actually lives in Vat B (i.e., the same vat that the promise
|
|
1141
|
+
* already pointed at), no embargo is needed, because the pipelined calls are delivered over the
|
|
1142
|
+
* same path as the later direct calls.
|
|
1143
|
+
*
|
|
1144
|
+
* Keep in mind that promise resolution happens both in the form of Resolve messages as well as
|
|
1145
|
+
* Return messages (which resolve PromisedAnswers). Embargos apply in both cases.
|
|
1146
|
+
*
|
|
1147
|
+
* An alternative strategy for enforcing E-order over promise resolution could be for Vat A to
|
|
1148
|
+
* implement the embargo internally. When Vat A is notified of promise resolution, it could
|
|
1149
|
+
* send a dummy no-op call to promise P and wait for it to complete. Until that call completes,
|
|
1150
|
+
* all calls to the capability are queued locally. This strategy works, but is pessimistic:
|
|
1151
|
+
* in the three-party case, it requires an A -> B -> C -> B -> A round trip before calls can start
|
|
1152
|
+
* being delivered directly to from Vat A to Vat C. The `Disembargo` message allows latency to be
|
|
1153
|
+
* reduced. (In the two-party loopback case, the `Disembargo` message is just a more explicit way
|
|
1154
|
+
* of accomplishing the same thing as a no-op call, but isn't any faster.)
|
|
1155
|
+
*
|
|
1156
|
+
* *The Tribble 4-way Race Condition*
|
|
1157
|
+
*
|
|
1158
|
+
* Any implementation of promise resolution and embargos must be aware of what we call the
|
|
1159
|
+
* "Tribble 4-way race condition", after Dean Tribble, who explained the problem in a lively
|
|
1160
|
+
* Friam meeting.
|
|
1161
|
+
*
|
|
1162
|
+
* Embargos are designed to work in the case where a two-hop path is being shortened to one hop.
|
|
1163
|
+
* But sometimes there are more hops. Imagine that Alice has a reference to a remote promise P1
|
|
1164
|
+
* that eventually resolves to _another_ remote promise P2 (in a third vat), which _at the same
|
|
1165
|
+
* time_ happens to resolve to Bob (in a fourth vat). In this case, we're shortening from a 3-hop
|
|
1166
|
+
* path (with four parties) to a 1-hop path (Alice -> Bob).
|
|
1167
|
+
*
|
|
1168
|
+
* Extending the embargo/disembargo protocol to be able to shorted multiple hops at once seems
|
|
1169
|
+
* difficult. Instead, we make a rule that prevents this case from coming up:
|
|
1170
|
+
*
|
|
1171
|
+
* One a promise P has been resolved to a remote object reference R, then all further messages
|
|
1172
|
+
* received addressed to P will be forwarded strictly to R. Even if it turns out later that R is
|
|
1173
|
+
* itself a promise, and has resolved to some other object Q, messages sent to P will still be
|
|
1174
|
+
* forwarded to R, not directly to Q (R will of course further forward the messages to Q).
|
|
1175
|
+
*
|
|
1176
|
+
* This rule does not cause a significant performance burden because once P has resolved to R, it
|
|
1177
|
+
* is expected that people sending messages to P will shortly start sending them to R instead and
|
|
1178
|
+
* drop P. P is at end-of-life anyway, so it doesn't matter if it ignores chances to further
|
|
1179
|
+
* optimize its path.
|
|
1180
|
+
*
|
|
1181
|
+
* Note well: the Tribble 4-way race condition does not require each vat to be *distinct*; as long
|
|
1182
|
+
* as each resolution crosses a network boundary the race can occur -- so this concerns even level
|
|
1183
|
+
* 1 implementations, not just level 3 implementations.
|
|
1184
|
+
*
|
|
1185
|
+
*/
|
|
1186
|
+
declare class Disembargo extends Struct {
|
|
1187
|
+
static readonly _capnp: {
|
|
1188
|
+
displayName: string;
|
|
1189
|
+
id: string;
|
|
1190
|
+
size: ObjectSize;
|
|
1191
|
+
};
|
|
1192
|
+
_adoptTarget(value: Orphan<MessageTarget>): void;
|
|
1193
|
+
_disownTarget(): Orphan<MessageTarget>;
|
|
1194
|
+
/**
|
|
1195
|
+
* What is to be disembargoed.
|
|
1196
|
+
*
|
|
1197
|
+
*/
|
|
1198
|
+
get target(): MessageTarget;
|
|
1199
|
+
_hasTarget(): boolean;
|
|
1200
|
+
_initTarget(): MessageTarget;
|
|
1201
|
+
set target(value: MessageTarget);
|
|
1202
|
+
get context(): Disembargo_Context;
|
|
1203
|
+
_initContext(): Disembargo_Context;
|
|
1204
|
+
toString(): string;
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* **(level 3)**
|
|
1208
|
+
*
|
|
1209
|
+
* Message type sent to indicate that the sender wishes to make a particular capability implemented
|
|
1210
|
+
* by the receiver available to a third party for direct access (without the need for the third
|
|
1211
|
+
* party to proxy through the sender).
|
|
1212
|
+
*
|
|
1213
|
+
* (In CapTP, `Provide` and `Accept` are methods of the global `NonceLocator` object exported by
|
|
1214
|
+
* every vat. In Cap'n Proto, we bake this into the core protocol.)
|
|
1215
|
+
*
|
|
1216
|
+
*/
|
|
1217
|
+
declare class Provide extends Struct {
|
|
1218
|
+
static readonly _capnp: {
|
|
1219
|
+
displayName: string;
|
|
1220
|
+
id: string;
|
|
1221
|
+
size: ObjectSize;
|
|
1222
|
+
};
|
|
1223
|
+
/**
|
|
1224
|
+
* Question ID to be held open until the recipient has received the capability. A result will be
|
|
1225
|
+
* returned once the third party has successfully received the capability. The sender must at some
|
|
1226
|
+
* point send a `Finish` message as with any other call, and that message can be used to cancel the
|
|
1227
|
+
* whole operation.
|
|
1228
|
+
*
|
|
1229
|
+
*/
|
|
1230
|
+
get questionId(): number;
|
|
1231
|
+
set questionId(value: number);
|
|
1232
|
+
_adoptTarget(value: Orphan<MessageTarget>): void;
|
|
1233
|
+
_disownTarget(): Orphan<MessageTarget>;
|
|
1234
|
+
/**
|
|
1235
|
+
* What is to be provided to the third party.
|
|
1236
|
+
*
|
|
1237
|
+
*/
|
|
1238
|
+
get target(): MessageTarget;
|
|
1239
|
+
_hasTarget(): boolean;
|
|
1240
|
+
_initTarget(): MessageTarget;
|
|
1241
|
+
set target(value: MessageTarget);
|
|
1242
|
+
_adoptRecipient(value: Orphan<Pointer>): void;
|
|
1243
|
+
_disownRecipient(): Orphan<Pointer>;
|
|
1244
|
+
/**
|
|
1245
|
+
* Identity of the third party that is expected to pick up the capability.
|
|
1246
|
+
*
|
|
1247
|
+
*/
|
|
1248
|
+
get recipient(): Pointer;
|
|
1249
|
+
_hasRecipient(): boolean;
|
|
1250
|
+
set recipient(value: Pointer);
|
|
1251
|
+
toString(): string;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* **(level 3)**
|
|
1255
|
+
*
|
|
1256
|
+
* Message type sent to pick up a capability hosted by the receiving vat and provided by a third
|
|
1257
|
+
* party. The third party previously designated the capability using `Provide`.
|
|
1258
|
+
*
|
|
1259
|
+
* This message is also used to pick up a redirected return -- see `Return.acceptFromThirdParty`.
|
|
1260
|
+
*
|
|
1261
|
+
*/
|
|
1262
|
+
declare class Accept extends Struct {
|
|
1263
|
+
static readonly _capnp: {
|
|
1264
|
+
displayName: string;
|
|
1265
|
+
id: string;
|
|
1266
|
+
size: ObjectSize;
|
|
1267
|
+
};
|
|
1268
|
+
/**
|
|
1269
|
+
* A new question ID identifying this accept message, which will eventually receive a Return
|
|
1270
|
+
* message containing the provided capability (or the call result in the case of a redirected
|
|
1271
|
+
* return).
|
|
1272
|
+
*
|
|
1273
|
+
*/
|
|
1274
|
+
get questionId(): number;
|
|
1275
|
+
set questionId(value: number);
|
|
1276
|
+
_adoptProvision(value: Orphan<Pointer>): void;
|
|
1277
|
+
_disownProvision(): Orphan<Pointer>;
|
|
1278
|
+
/**
|
|
1279
|
+
* Identifies the provided object to be picked up.
|
|
1280
|
+
*
|
|
1281
|
+
*/
|
|
1282
|
+
get provision(): Pointer;
|
|
1283
|
+
_hasProvision(): boolean;
|
|
1284
|
+
set provision(value: Pointer);
|
|
1285
|
+
/**
|
|
1286
|
+
* If true, this accept shall be temporarily embargoed. The resulting `Return` will not be sent,
|
|
1287
|
+
* and any pipelined calls will not be delivered, until the embargo is released. The receiver
|
|
1288
|
+
* (the capability host) will expect the provider (the vat that sent the `Provide` message) to
|
|
1289
|
+
* eventually send a `Disembargo` message with the field `context.provide` set to the question ID
|
|
1290
|
+
* of the original `Provide` message. At that point, the embargo is released and the queued
|
|
1291
|
+
* messages are delivered.
|
|
1292
|
+
*
|
|
1293
|
+
* For example:
|
|
1294
|
+
* - Alice, in Vat A, holds a promise P, which currently points toward Vat B.
|
|
1295
|
+
* - Alice calls foo() on P. The `Call` message is sent to Vat B.
|
|
1296
|
+
* - The promise P in Vat B ends up resolving to Carol, in Vat C.
|
|
1297
|
+
* - Vat B sends a `Provide` message to Vat C, identifying Vat A as the recipient.
|
|
1298
|
+
* - Vat B sends a `Resolve` message to Vat A, indicating that the promise has resolved to a
|
|
1299
|
+
* `ThirdPartyCapId` identifying Carol in Vat C.
|
|
1300
|
+
* - Vat A sends an `Accept` message to Vat C to pick up the capability. Since Vat A knows that
|
|
1301
|
+
* it has an outstanding call to the promise, it sets `embargo` to `true` in the `Accept`
|
|
1302
|
+
* message.
|
|
1303
|
+
* - Vat A sends a `Disembargo` message to Vat B on promise P, with `context.accept` set.
|
|
1304
|
+
* - Alice makes a call bar() to promise P, which is now pointing towards Vat C. Alice doesn't
|
|
1305
|
+
* know anything about the mechanics of promise resolution happening under the hood, but she
|
|
1306
|
+
* expects that bar() will be delivered after foo() because that is the order in which she
|
|
1307
|
+
* initiated the calls.
|
|
1308
|
+
* - Vat A sends the bar() call to Vat C, as a pipelined call on the result of the `Accept` (which
|
|
1309
|
+
* hasn't returned yet, due to the embargo). Since calls to the newly-accepted capability
|
|
1310
|
+
* are embargoed, Vat C does not deliver the call yet.
|
|
1311
|
+
* - At some point, Vat B forwards the foo() call from the beginning of this example on to Vat C.
|
|
1312
|
+
* - Vat B forwards the `Disembargo` from Vat A on to vat C. It sets `context.provide` to the
|
|
1313
|
+
* question ID of the `Provide` message it had sent previously.
|
|
1314
|
+
* - Vat C receives foo() before `Disembargo`, thus allowing it to correctly deliver foo()
|
|
1315
|
+
* before delivering bar().
|
|
1316
|
+
* - Vat C receives `Disembargo` from Vat B. It can now send a `Return` for the `Accept` from
|
|
1317
|
+
* Vat A, as well as deliver bar().
|
|
1318
|
+
*
|
|
1319
|
+
*/
|
|
1320
|
+
get embargo(): boolean;
|
|
1321
|
+
set embargo(value: boolean);
|
|
1322
|
+
toString(): string;
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* **(level 4)**
|
|
1326
|
+
*
|
|
1327
|
+
* Message type sent to implement E.join(), which, given a number of capabilities that are
|
|
1328
|
+
* expected to be equivalent, finds the underlying object upon which they all agree and forms a
|
|
1329
|
+
* direct connection to it, skipping any proxies that may have been constructed by other vats
|
|
1330
|
+
* while transmitting the capability. See:
|
|
1331
|
+
* http://erights.org/elib/equality/index.html
|
|
1332
|
+
*
|
|
1333
|
+
* Note that this should only serve to bypass fully-transparent proxies -- proxies that were
|
|
1334
|
+
* created merely for convenience, without any intention of hiding the underlying object.
|
|
1335
|
+
*
|
|
1336
|
+
* For example, say Bob holds two capabilities hosted by Alice and Carol, but he expects that both
|
|
1337
|
+
* are simply proxies for a capability hosted elsewhere. He then issues a join request, which
|
|
1338
|
+
* operates as follows:
|
|
1339
|
+
* - Bob issues Join requests on both Alice and Carol. Each request contains a different piece
|
|
1340
|
+
* of the JoinKey.
|
|
1341
|
+
* - Alice is proxying a capability hosted by Dana, so forwards the request to Dana's cap.
|
|
1342
|
+
* - Dana receives the first request and sees that the JoinKeyPart is one of two. She notes that
|
|
1343
|
+
* she doesn't have the other part yet, so she records the request and responds with a
|
|
1344
|
+
* JoinResult.
|
|
1345
|
+
* - Alice relays the JoinAnswer back to Bob.
|
|
1346
|
+
* - Carol is also proxying a capability from Dana, and so forwards her Join request to Dana as
|
|
1347
|
+
* well.
|
|
1348
|
+
* - Dana receives Carol's request and notes that she now has both parts of a JoinKey. She
|
|
1349
|
+
* combines them in order to form information needed to form a secure connection to Bob. She
|
|
1350
|
+
* also responds with another JoinResult.
|
|
1351
|
+
* - Bob receives the responses from Alice and Carol. He uses the returned JoinResults to
|
|
1352
|
+
* determine how to connect to Dana and attempts to form the connection. Since Bob and Dana now
|
|
1353
|
+
* agree on a secret key that neither Alice nor Carol ever saw, this connection can be made
|
|
1354
|
+
* securely even if Alice or Carol is conspiring against the other. (If Alice and Carol are
|
|
1355
|
+
* conspiring _together_, they can obviously reproduce the key, but this doesn't matter because
|
|
1356
|
+
* the whole point of the join is to verify that Alice and Carol agree on what capability they
|
|
1357
|
+
* are proxying.)
|
|
1358
|
+
*
|
|
1359
|
+
* If the two capabilities aren't actually proxies of the same object, then the join requests
|
|
1360
|
+
* will come back with conflicting `hostId`s and the join will fail before attempting to form any
|
|
1361
|
+
* connection.
|
|
1362
|
+
*
|
|
1363
|
+
*/
|
|
1364
|
+
declare class Join extends Struct {
|
|
1365
|
+
static readonly _capnp: {
|
|
1366
|
+
displayName: string;
|
|
1367
|
+
id: string;
|
|
1368
|
+
size: ObjectSize;
|
|
1369
|
+
};
|
|
1370
|
+
/**
|
|
1371
|
+
* Question ID used to respond to this Join. (Note that this ID only identifies one part of the
|
|
1372
|
+
* request for one hop; each part has a different ID and relayed copies of the request have
|
|
1373
|
+
* (probably) different IDs still.)
|
|
1374
|
+
*
|
|
1375
|
+
* The receiver will reply with a `Return` whose `results` is a JoinResult. This `JoinResult`
|
|
1376
|
+
* is relayed from the joined object's host, possibly with transformation applied as needed
|
|
1377
|
+
* by the network.
|
|
1378
|
+
*
|
|
1379
|
+
* Like any return, the result must be released using a `Finish`. However, this release
|
|
1380
|
+
* should not occur until the joiner has either successfully connected to the joined object.
|
|
1381
|
+
* Vats relaying a `Join` message similarly must not release the result they receive until the
|
|
1382
|
+
* return they relayed back towards the joiner has itself been released. This allows the
|
|
1383
|
+
* joined object's host to detect when the Join operation is canceled before completing -- if
|
|
1384
|
+
* it receives a `Finish` for one of the join results before the joiner successfully
|
|
1385
|
+
* connects. It can then free any resources it had allocated as part of the join.
|
|
1386
|
+
*
|
|
1387
|
+
*/
|
|
1388
|
+
get questionId(): number;
|
|
1389
|
+
set questionId(value: number);
|
|
1390
|
+
_adoptTarget(value: Orphan<MessageTarget>): void;
|
|
1391
|
+
_disownTarget(): Orphan<MessageTarget>;
|
|
1392
|
+
/**
|
|
1393
|
+
* The capability to join.
|
|
1394
|
+
*
|
|
1395
|
+
*/
|
|
1396
|
+
get target(): MessageTarget;
|
|
1397
|
+
_hasTarget(): boolean;
|
|
1398
|
+
_initTarget(): MessageTarget;
|
|
1399
|
+
set target(value: MessageTarget);
|
|
1400
|
+
_adoptKeyPart(value: Orphan<Pointer>): void;
|
|
1401
|
+
_disownKeyPart(): Orphan<Pointer>;
|
|
1402
|
+
/**
|
|
1403
|
+
* A part of the join key. These combine to form the complete join key, which is used to establish
|
|
1404
|
+
* a direct connection.
|
|
1405
|
+
*
|
|
1406
|
+
*/
|
|
1407
|
+
get keyPart(): Pointer;
|
|
1408
|
+
_hasKeyPart(): boolean;
|
|
1409
|
+
set keyPart(value: Pointer);
|
|
1410
|
+
toString(): string;
|
|
1411
|
+
}
|
|
1412
|
+
declare const MessageTarget_Which: {
|
|
1413
|
+
/**
|
|
1414
|
+
* This message is to a capability or promise previously imported by the caller (exported by
|
|
1415
|
+
* the receiver).
|
|
1416
|
+
*
|
|
1417
|
+
*/
|
|
1418
|
+
readonly IMPORTED_CAP: 0;
|
|
1419
|
+
/**
|
|
1420
|
+
* This message is to a capability that is expected to be returned by another call that has not
|
|
1421
|
+
* yet been completed.
|
|
1422
|
+
*
|
|
1423
|
+
* At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
|
|
1424
|
+
* that initial startup doesn't require a round trip.
|
|
1425
|
+
*
|
|
1426
|
+
*/
|
|
1427
|
+
readonly PROMISED_ANSWER: 1;
|
|
1428
|
+
};
|
|
1429
|
+
type MessageTarget_Which = (typeof MessageTarget_Which)[keyof typeof MessageTarget_Which];
|
|
1430
|
+
/**
|
|
1431
|
+
* The target of a `Call` or other messages that target a capability.
|
|
1432
|
+
*
|
|
1433
|
+
*/
|
|
1434
|
+
declare class MessageTarget extends Struct {
|
|
1435
|
+
static readonly IMPORTED_CAP: 0;
|
|
1436
|
+
static readonly PROMISED_ANSWER: 1;
|
|
1437
|
+
static readonly _capnp: {
|
|
1438
|
+
displayName: string;
|
|
1439
|
+
id: string;
|
|
1440
|
+
size: ObjectSize;
|
|
1441
|
+
};
|
|
1442
|
+
/**
|
|
1443
|
+
* This message is to a capability or promise previously imported by the caller (exported by
|
|
1444
|
+
* the receiver).
|
|
1445
|
+
*
|
|
1446
|
+
*/
|
|
1447
|
+
get importedCap(): number;
|
|
1448
|
+
get _isImportedCap(): boolean;
|
|
1449
|
+
set importedCap(value: number);
|
|
1450
|
+
_adoptPromisedAnswer(value: Orphan<PromisedAnswer>): void;
|
|
1451
|
+
_disownPromisedAnswer(): Orphan<PromisedAnswer>;
|
|
1452
|
+
/**
|
|
1453
|
+
* This message is to a capability that is expected to be returned by another call that has not
|
|
1454
|
+
* yet been completed.
|
|
1455
|
+
*
|
|
1456
|
+
* At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
|
|
1457
|
+
* that initial startup doesn't require a round trip.
|
|
1458
|
+
*
|
|
1459
|
+
*/
|
|
1460
|
+
get promisedAnswer(): PromisedAnswer;
|
|
1461
|
+
_hasPromisedAnswer(): boolean;
|
|
1462
|
+
_initPromisedAnswer(): PromisedAnswer;
|
|
1463
|
+
get _isPromisedAnswer(): boolean;
|
|
1464
|
+
set promisedAnswer(value: PromisedAnswer);
|
|
1465
|
+
toString(): string;
|
|
1466
|
+
which(): MessageTarget_Which;
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Represents some data structure that might contain capabilities.
|
|
1470
|
+
*
|
|
1471
|
+
*/
|
|
1472
|
+
declare class Payload extends Struct {
|
|
1473
|
+
static readonly _capnp: {
|
|
1474
|
+
displayName: string;
|
|
1475
|
+
id: string;
|
|
1476
|
+
size: ObjectSize;
|
|
1477
|
+
};
|
|
1478
|
+
static _CapTable: ListCtor<CapDescriptor>;
|
|
1479
|
+
_adoptContent(value: Orphan<Pointer>): void;
|
|
1480
|
+
_disownContent(): Orphan<Pointer>;
|
|
1481
|
+
/**
|
|
1482
|
+
* Some Cap'n Proto data structure. Capability pointers embedded in this structure index into
|
|
1483
|
+
* `capTable`.
|
|
1484
|
+
*
|
|
1485
|
+
*/
|
|
1486
|
+
get content(): Pointer;
|
|
1487
|
+
_hasContent(): boolean;
|
|
1488
|
+
set content(value: Pointer);
|
|
1489
|
+
_adoptCapTable(value: Orphan<List<CapDescriptor>>): void;
|
|
1490
|
+
_disownCapTable(): Orphan<List<CapDescriptor>>;
|
|
1491
|
+
/**
|
|
1492
|
+
* Descriptors corresponding to the cap pointers in `content`.
|
|
1493
|
+
*
|
|
1494
|
+
*/
|
|
1495
|
+
get capTable(): List<CapDescriptor>;
|
|
1496
|
+
_hasCapTable(): boolean;
|
|
1497
|
+
_initCapTable(length: number): List<CapDescriptor>;
|
|
1498
|
+
set capTable(value: List<CapDescriptor>);
|
|
1499
|
+
toString(): string;
|
|
1500
|
+
}
|
|
1501
|
+
declare const CapDescriptor_Which: {
|
|
1502
|
+
/**
|
|
1503
|
+
* There is no capability here. This `CapDescriptor` should not appear in the payload content.
|
|
1504
|
+
* A `none` CapDescriptor can be generated when an application inserts a capability into a
|
|
1505
|
+
* message and then later changes its mind and removes it -- rewriting all of the other
|
|
1506
|
+
* capability pointers may be hard, so instead a tombstone is left, similar to the way a removed
|
|
1507
|
+
* struct or list instance is zeroed out of the message but the space is not reclaimed.
|
|
1508
|
+
* Hopefully this is unusual.
|
|
1509
|
+
*
|
|
1510
|
+
*/
|
|
1511
|
+
readonly NONE: 0;
|
|
1512
|
+
/**
|
|
1513
|
+
* The ID of a capability in the sender's export table (receiver's import table). It may be a
|
|
1514
|
+
* newly allocated table entry, or an existing entry (increments the reference count).
|
|
1515
|
+
*
|
|
1516
|
+
*/
|
|
1517
|
+
readonly SENDER_HOSTED: 1;
|
|
1518
|
+
/**
|
|
1519
|
+
* A promise that the sender will resolve later. The sender will send exactly one Resolve
|
|
1520
|
+
* message at a future point in time to replace this promise. Note that even if the same
|
|
1521
|
+
* `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
|
|
1522
|
+
* them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
|
|
1523
|
+
* `CapDescriptor`) may choose not to send the `Resolve` at all.
|
|
1524
|
+
*
|
|
1525
|
+
*/
|
|
1526
|
+
readonly SENDER_PROMISE: 2;
|
|
1527
|
+
/**
|
|
1528
|
+
* A capability (or promise) previously exported by the receiver (imported by the sender).
|
|
1529
|
+
*
|
|
1530
|
+
*/
|
|
1531
|
+
readonly RECEIVER_HOSTED: 3;
|
|
1532
|
+
/**
|
|
1533
|
+
* A capability expected to be returned in the results of a currently-outstanding call posed
|
|
1534
|
+
* by the sender.
|
|
1535
|
+
*
|
|
1536
|
+
*/
|
|
1537
|
+
readonly RECEIVER_ANSWER: 4;
|
|
1538
|
+
/**
|
|
1539
|
+
* **(level 3)**
|
|
1540
|
+
*
|
|
1541
|
+
* A capability that lives in neither the sender's nor the receiver's vat. The sender needs
|
|
1542
|
+
* to form a direct connection to a third party to pick up the capability.
|
|
1543
|
+
*
|
|
1544
|
+
* Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
|
|
1545
|
+
* `vine` instead.
|
|
1546
|
+
*
|
|
1547
|
+
*/
|
|
1548
|
+
readonly THIRD_PARTY_HOSTED: 5;
|
|
1549
|
+
};
|
|
1550
|
+
type CapDescriptor_Which = (typeof CapDescriptor_Which)[keyof typeof CapDescriptor_Which];
|
|
1551
|
+
/**
|
|
1552
|
+
* **(level 1)**
|
|
1553
|
+
*
|
|
1554
|
+
* When an application-defined type contains an interface pointer, that pointer contains an index
|
|
1555
|
+
* into the message's capability table -- i.e. the `capTable` part of the `Payload`. Each
|
|
1556
|
+
* capability in the table is represented as a `CapDescriptor`. The runtime API should not reveal
|
|
1557
|
+
* the CapDescriptor directly to the application, but should instead wrap it in some kind of
|
|
1558
|
+
* callable object with methods corresponding to the interface that the capability implements.
|
|
1559
|
+
*
|
|
1560
|
+
* Keep in mind that `ExportIds` in a `CapDescriptor` are subject to reference counting. See the
|
|
1561
|
+
* description of `ExportId`.
|
|
1562
|
+
*
|
|
1563
|
+
* Note that it is currently not possible to include a broken capability in the CapDescriptor
|
|
1564
|
+
* table. Instead, create a new export (`senderPromise`) for each broken capability and then
|
|
1565
|
+
* immediately follow the payload-bearing Call or Return message with one Resolve message for each
|
|
1566
|
+
* broken capability, resolving it to an exception.
|
|
1567
|
+
*
|
|
1568
|
+
*/
|
|
1569
|
+
declare class CapDescriptor extends Struct {
|
|
1570
|
+
static readonly NONE: 0;
|
|
1571
|
+
static readonly SENDER_HOSTED: 1;
|
|
1572
|
+
static readonly SENDER_PROMISE: 2;
|
|
1573
|
+
static readonly RECEIVER_HOSTED: 3;
|
|
1574
|
+
static readonly RECEIVER_ANSWER: 4;
|
|
1575
|
+
static readonly THIRD_PARTY_HOSTED: 5;
|
|
1576
|
+
static readonly _capnp: {
|
|
1577
|
+
displayName: string;
|
|
1578
|
+
id: string;
|
|
1579
|
+
size: ObjectSize;
|
|
1580
|
+
defaultAttachedFd: DataView<ArrayBufferLike>;
|
|
1581
|
+
};
|
|
1582
|
+
get _isNone(): boolean;
|
|
1583
|
+
set none(_: true);
|
|
1584
|
+
/**
|
|
1585
|
+
* The ID of a capability in the sender's export table (receiver's import table). It may be a
|
|
1586
|
+
* newly allocated table entry, or an existing entry (increments the reference count).
|
|
1587
|
+
*
|
|
1588
|
+
*/
|
|
1589
|
+
get senderHosted(): number;
|
|
1590
|
+
get _isSenderHosted(): boolean;
|
|
1591
|
+
set senderHosted(value: number);
|
|
1592
|
+
/**
|
|
1593
|
+
* A promise that the sender will resolve later. The sender will send exactly one Resolve
|
|
1594
|
+
* message at a future point in time to replace this promise. Note that even if the same
|
|
1595
|
+
* `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
|
|
1596
|
+
* them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
|
|
1597
|
+
* `CapDescriptor`) may choose not to send the `Resolve` at all.
|
|
1598
|
+
*
|
|
1599
|
+
*/
|
|
1600
|
+
get senderPromise(): number;
|
|
1601
|
+
get _isSenderPromise(): boolean;
|
|
1602
|
+
set senderPromise(value: number);
|
|
1603
|
+
/**
|
|
1604
|
+
* A capability (or promise) previously exported by the receiver (imported by the sender).
|
|
1605
|
+
*
|
|
1606
|
+
*/
|
|
1607
|
+
get receiverHosted(): number;
|
|
1608
|
+
get _isReceiverHosted(): boolean;
|
|
1609
|
+
set receiverHosted(value: number);
|
|
1610
|
+
_adoptReceiverAnswer(value: Orphan<PromisedAnswer>): void;
|
|
1611
|
+
_disownReceiverAnswer(): Orphan<PromisedAnswer>;
|
|
1612
|
+
/**
|
|
1613
|
+
* A capability expected to be returned in the results of a currently-outstanding call posed
|
|
1614
|
+
* by the sender.
|
|
1615
|
+
*
|
|
1616
|
+
*/
|
|
1617
|
+
get receiverAnswer(): PromisedAnswer;
|
|
1618
|
+
_hasReceiverAnswer(): boolean;
|
|
1619
|
+
_initReceiverAnswer(): PromisedAnswer;
|
|
1620
|
+
get _isReceiverAnswer(): boolean;
|
|
1621
|
+
set receiverAnswer(value: PromisedAnswer);
|
|
1622
|
+
_adoptThirdPartyHosted(value: Orphan<ThirdPartyCapDescriptor>): void;
|
|
1623
|
+
_disownThirdPartyHosted(): Orphan<ThirdPartyCapDescriptor>;
|
|
1624
|
+
/**
|
|
1625
|
+
* **(level 3)**
|
|
1626
|
+
*
|
|
1627
|
+
* A capability that lives in neither the sender's nor the receiver's vat. The sender needs
|
|
1628
|
+
* to form a direct connection to a third party to pick up the capability.
|
|
1629
|
+
*
|
|
1630
|
+
* Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
|
|
1631
|
+
* `vine` instead.
|
|
1632
|
+
*
|
|
1633
|
+
*/
|
|
1634
|
+
get thirdPartyHosted(): ThirdPartyCapDescriptor;
|
|
1635
|
+
_hasThirdPartyHosted(): boolean;
|
|
1636
|
+
_initThirdPartyHosted(): ThirdPartyCapDescriptor;
|
|
1637
|
+
get _isThirdPartyHosted(): boolean;
|
|
1638
|
+
set thirdPartyHosted(value: ThirdPartyCapDescriptor);
|
|
1639
|
+
/**
|
|
1640
|
+
* If the RPC message in which this CapDescriptor was delivered also had file descriptors
|
|
1641
|
+
* attached, and `fd` is a valid index into the list of attached file descriptors, then
|
|
1642
|
+
* that file descriptor should be attached to this capability. If `attachedFd` is out-of-bounds
|
|
1643
|
+
* for said list, then no FD is attached.
|
|
1644
|
+
*
|
|
1645
|
+
* For example, if the RPC message arrived over a Unix socket, then file descriptors may be
|
|
1646
|
+
* attached by sending an SCM_RIGHTS ancillary message attached to the data bytes making up the
|
|
1647
|
+
* raw message. Receivers who wish to opt into FD passing should arrange to receive SCM_RIGHTS
|
|
1648
|
+
* whenever receiving an RPC message. Senders who wish to send FDs need not verify whether the
|
|
1649
|
+
* receiver knows how to receive them, because the operating system will automatically discard
|
|
1650
|
+
* ancillary messages like SCM_RIGHTS if the receiver doesn't ask to receive them, including
|
|
1651
|
+
* automatically closing any FDs.
|
|
1652
|
+
*
|
|
1653
|
+
* It is up to the application protocol to define what capabilities are expected to have file
|
|
1654
|
+
* descriptors attached, and what those FDs mean. But, for example, an application could use this
|
|
1655
|
+
* to open a file on disk and then transmit the open file descriptor to a sandboxed process that
|
|
1656
|
+
* does not otherwise have permission to access the filesystem directly. This is usually an
|
|
1657
|
+
* optimization: the sending process could instead provide an RPC interface supporting all the
|
|
1658
|
+
* operations needed (such as reading and writing a file), but by passing the file descriptor
|
|
1659
|
+
* directly, the recipient can often perform operations much more efficiently. Application
|
|
1660
|
+
* designers are encouraged to provide such RPC interfaces and automatically fall back to them
|
|
1661
|
+
* when FD passing is not available, so that the application can still work when the parties are
|
|
1662
|
+
* remote over a network.
|
|
1663
|
+
*
|
|
1664
|
+
* An attached FD is most often associated with a `senderHosted` descriptor. It could also make
|
|
1665
|
+
* sense in the case of `thirdPartyHosted`: in this case, the sender is forwarding the FD that
|
|
1666
|
+
* they received from the third party, so that the receiver can start using it without first
|
|
1667
|
+
* interacting with the third party. This is an optional optimization -- the middleman may choose
|
|
1668
|
+
* not to forward capabilities, in which case the receiver will need to complete the handshake
|
|
1669
|
+
* with the third party directly before receiving the FD. If an implementation receives a second
|
|
1670
|
+
* attached FD after having already received one previously (e.g. both in a `thirdPartyHosted`
|
|
1671
|
+
* CapDescriptor and then later again when receiving the final capability directly from the
|
|
1672
|
+
* third party), the implementation should discard the later FD and stick with the original. At
|
|
1673
|
+
* present, there is no known reason why other capability types (e.g. `receiverHosted`) would want
|
|
1674
|
+
* to carry an attached FD, but we reserve the right to define a meaning for this in the future.
|
|
1675
|
+
*
|
|
1676
|
+
* Each file descriptor attached to the message must be used in no more than one CapDescriptor,
|
|
1677
|
+
* so that the receiver does not need to use dup() or refcounting to handle the possibility of
|
|
1678
|
+
* multiple capabilities using the same descriptor. If multiple CapDescriptors do point to the
|
|
1679
|
+
* same FD index, then the receiver can arbitrarily choose which capability ends up having the
|
|
1680
|
+
* FD attached.
|
|
1681
|
+
*
|
|
1682
|
+
* To mitigate DoS attacks, RPC implementations should limit the number of FDs they are willing to
|
|
1683
|
+
* receive in a single message to a small value. If a message happens to contain more than that,
|
|
1684
|
+
* the list is truncated. Moreover, in some cases, FD passing needs to be blocked entirely for
|
|
1685
|
+
* security or implementation reasons, in which case the list may be truncated to zero. Hence,
|
|
1686
|
+
* `attachedFd` might point past the end of the list, which the implementation should treat as if
|
|
1687
|
+
* no FD was attached at all.
|
|
1688
|
+
*
|
|
1689
|
+
* The type of this field was chosen to be UInt8 because Linux supports sending only a maximum
|
|
1690
|
+
* of 253 file descriptors in an SCM_RIGHTS message anyway, and CapDescriptor had two bytes of
|
|
1691
|
+
* padding left -- so after adding this, there is still one byte for a future feature.
|
|
1692
|
+
* Conveniently, this also means we're able to use 0xff as the default value, which will always
|
|
1693
|
+
* be out-of-range (of course, the implementation should explicitly enforce that 255 descriptors
|
|
1694
|
+
* cannot be sent at once, rather than relying on Linux to do so).
|
|
1695
|
+
*
|
|
1696
|
+
*/
|
|
1697
|
+
get attachedFd(): number;
|
|
1698
|
+
set attachedFd(value: number);
|
|
1699
|
+
toString(): string;
|
|
1700
|
+
which(): CapDescriptor_Which;
|
|
1701
|
+
}
|
|
1702
|
+
declare const PromisedAnswer_Op_Which: {
|
|
1703
|
+
/**
|
|
1704
|
+
* Does nothing. This member is mostly defined so that we can make `Op` a union even
|
|
1705
|
+
* though (as of this writing) only one real operation is defined.
|
|
1706
|
+
*
|
|
1707
|
+
*/
|
|
1708
|
+
readonly NOOP: 0;
|
|
1709
|
+
/**
|
|
1710
|
+
* Get a pointer field within a struct. The number is an index into the pointer section, NOT
|
|
1711
|
+
* a field ordinal, so that the receiver does not need to understand the schema.
|
|
1712
|
+
*
|
|
1713
|
+
*/
|
|
1714
|
+
readonly GET_POINTER_FIELD: 1;
|
|
1715
|
+
};
|
|
1716
|
+
type PromisedAnswer_Op_Which = (typeof PromisedAnswer_Op_Which)[keyof typeof PromisedAnswer_Op_Which];
|
|
1717
|
+
declare class PromisedAnswer_Op extends Struct {
|
|
1718
|
+
static readonly NOOP: 0;
|
|
1719
|
+
static readonly GET_POINTER_FIELD: 1;
|
|
1720
|
+
static readonly _capnp: {
|
|
1721
|
+
displayName: string;
|
|
1722
|
+
id: string;
|
|
1723
|
+
size: ObjectSize;
|
|
1724
|
+
};
|
|
1725
|
+
get _isNoop(): boolean;
|
|
1726
|
+
set noop(_: true);
|
|
1727
|
+
/**
|
|
1728
|
+
* Get a pointer field within a struct. The number is an index into the pointer section, NOT
|
|
1729
|
+
* a field ordinal, so that the receiver does not need to understand the schema.
|
|
1730
|
+
*
|
|
1731
|
+
*/
|
|
1732
|
+
get getPointerField(): number;
|
|
1733
|
+
get _isGetPointerField(): boolean;
|
|
1734
|
+
set getPointerField(value: number);
|
|
1735
|
+
toString(): string;
|
|
1736
|
+
which(): PromisedAnswer_Op_Which;
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* **(mostly level 1)**
|
|
1740
|
+
*
|
|
1741
|
+
* Specifies how to derive a promise from an unanswered question, by specifying the path of fields
|
|
1742
|
+
* to follow from the root of the eventual result struct to get to the desired capability. Used
|
|
1743
|
+
* to address method calls to a not-yet-returned capability or to pass such a capability as an
|
|
1744
|
+
* input to some other method call.
|
|
1745
|
+
*
|
|
1746
|
+
* Level 0 implementations must support `PromisedAnswer` only for the case where the answer is
|
|
1747
|
+
* to a `Bootstrap` message. In this case, `path` is always empty since `Bootstrap` always returns
|
|
1748
|
+
* a raw capability.
|
|
1749
|
+
*
|
|
1750
|
+
*/
|
|
1751
|
+
declare class PromisedAnswer extends Struct {
|
|
1752
|
+
static readonly Op: typeof PromisedAnswer_Op;
|
|
1753
|
+
static readonly _capnp: {
|
|
1754
|
+
displayName: string;
|
|
1755
|
+
id: string;
|
|
1756
|
+
size: ObjectSize;
|
|
1757
|
+
};
|
|
1758
|
+
static _Transform: ListCtor<PromisedAnswer_Op>;
|
|
1759
|
+
/**
|
|
1760
|
+
* ID of the question (in the sender's question table / receiver's answer table) whose answer is
|
|
1761
|
+
* expected to contain the capability.
|
|
1762
|
+
*
|
|
1763
|
+
*/
|
|
1764
|
+
get questionId(): number;
|
|
1765
|
+
set questionId(value: number);
|
|
1766
|
+
_adoptTransform(value: Orphan<List<PromisedAnswer_Op>>): void;
|
|
1767
|
+
_disownTransform(): Orphan<List<PromisedAnswer_Op>>;
|
|
1768
|
+
/**
|
|
1769
|
+
* Operations / transformations to apply to the result in order to get the capability actually
|
|
1770
|
+
* being addressed. E.g. if the result is a struct and you want to call a method on a capability
|
|
1771
|
+
* pointed to by a field of the struct, you need a `getPointerField` op.
|
|
1772
|
+
*
|
|
1773
|
+
*/
|
|
1774
|
+
get transform(): List<PromisedAnswer_Op>;
|
|
1775
|
+
_hasTransform(): boolean;
|
|
1776
|
+
_initTransform(length: number): List<PromisedAnswer_Op>;
|
|
1777
|
+
set transform(value: List<PromisedAnswer_Op>);
|
|
1778
|
+
toString(): string;
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* **(level 3)**
|
|
1782
|
+
*
|
|
1783
|
+
* Identifies a capability in a third-party vat that the sender wants the receiver to pick up.
|
|
1784
|
+
*
|
|
1785
|
+
*/
|
|
1786
|
+
declare class ThirdPartyCapDescriptor extends Struct {
|
|
1787
|
+
static readonly _capnp: {
|
|
1788
|
+
displayName: string;
|
|
1789
|
+
id: string;
|
|
1790
|
+
size: ObjectSize;
|
|
1791
|
+
};
|
|
1792
|
+
_adoptId(value: Orphan<Pointer>): void;
|
|
1793
|
+
_disownId(): Orphan<Pointer>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Identifies the third-party host and the specific capability to accept from it.
|
|
1796
|
+
*
|
|
1797
|
+
*/
|
|
1798
|
+
get id(): Pointer;
|
|
1799
|
+
_hasId(): boolean;
|
|
1800
|
+
set id(value: Pointer);
|
|
1801
|
+
/**
|
|
1802
|
+
* A proxy for the third-party object exported by the sender. In CapTP terminology this is called
|
|
1803
|
+
* a "vine", because it is an indirect reference to the third-party object that snakes through the
|
|
1804
|
+
* sender vat. This serves two purposes:
|
|
1805
|
+
*
|
|
1806
|
+
* * Level 1 and 2 implementations that don't understand how to connect to a third party may
|
|
1807
|
+
* simply send calls to the vine. Such calls will be forwarded to the third-party by the
|
|
1808
|
+
* sender.
|
|
1809
|
+
*
|
|
1810
|
+
* * Level 3 implementations must release the vine only once they have successfully picked up the
|
|
1811
|
+
* object from the third party. This ensures that the capability is not released by the sender
|
|
1812
|
+
* prematurely.
|
|
1813
|
+
*
|
|
1814
|
+
* The sender will close the `Provide` request that it has sent to the third party as soon as
|
|
1815
|
+
* it receives either a `Call` or a `Release` message directed at the vine.
|
|
1816
|
+
*
|
|
1817
|
+
*/
|
|
1818
|
+
get vineId(): number;
|
|
1819
|
+
set vineId(value: number);
|
|
1820
|
+
toString(): string;
|
|
1821
|
+
}
|
|
1822
|
+
declare const Exception_Type: {
|
|
1823
|
+
/**
|
|
1824
|
+
* A generic problem occurred, and it is believed that if the operation were repeated without
|
|
1825
|
+
* any change in the state of the world, the problem would occur again.
|
|
1826
|
+
*
|
|
1827
|
+
* A client might respond to this error by logging it for investigation by the developer and/or
|
|
1828
|
+
* displaying it to the user.
|
|
1829
|
+
*
|
|
1830
|
+
*/
|
|
1831
|
+
readonly FAILED: 0;
|
|
1832
|
+
/**
|
|
1833
|
+
* The request was rejected due to a temporary lack of resources.
|
|
1834
|
+
*
|
|
1835
|
+
* Examples include:
|
|
1836
|
+
* - There's not enough CPU time to keep up with incoming requests, so some are rejected.
|
|
1837
|
+
* - The server ran out of RAM or disk space during the request.
|
|
1838
|
+
* - The operation timed out (took significantly longer than it should have).
|
|
1839
|
+
*
|
|
1840
|
+
* A client might respond to this error by scheduling to retry the operation much later. The
|
|
1841
|
+
* client should NOT retry again immediately since this would likely exacerbate the problem.
|
|
1842
|
+
*
|
|
1843
|
+
*/
|
|
1844
|
+
readonly OVERLOADED: 1;
|
|
1845
|
+
/**
|
|
1846
|
+
* The method failed because a connection to some necessary capability was lost.
|
|
1847
|
+
*
|
|
1848
|
+
* Examples include:
|
|
1849
|
+
* - The client introduced the server to a third-party capability, the connection to that third
|
|
1850
|
+
* party was subsequently lost, and then the client requested that the server use the dead
|
|
1851
|
+
* capability for something.
|
|
1852
|
+
* - The client previously requested that the server obtain a capability from some third party.
|
|
1853
|
+
* The server returned a capability to an object wrapping the third-party capability. Later,
|
|
1854
|
+
* the server's connection to the third party was lost.
|
|
1855
|
+
* - The capability has been revoked. Revocation does not necessarily mean that the client is
|
|
1856
|
+
* no longer authorized to use the capability; it is often used simply as a way to force the
|
|
1857
|
+
* client to repeat the setup process, perhaps to efficiently move them to a new back-end or
|
|
1858
|
+
* get them to recognize some other change that has occurred.
|
|
1859
|
+
*
|
|
1860
|
+
* A client should normally respond to this error by releasing all capabilities it is currently
|
|
1861
|
+
* holding related to the one it called and then re-creating them by restoring SturdyRefs and/or
|
|
1862
|
+
* repeating the method calls used to create them originally. In other words, disconnect and
|
|
1863
|
+
* start over. This should in turn cause the server to obtain a new copy of the capability that
|
|
1864
|
+
* it lost, thus making everything work.
|
|
1865
|
+
*
|
|
1866
|
+
* If the client receives another `disconnected` error in the process of rebuilding the
|
|
1867
|
+
* capability and retrying the call, it should treat this as an `overloaded` error: the network
|
|
1868
|
+
* is currently unreliable, possibly due to load or other temporary issues.
|
|
1869
|
+
*
|
|
1870
|
+
*/
|
|
1871
|
+
readonly DISCONNECTED: 2;
|
|
1872
|
+
/**
|
|
1873
|
+
* The server doesn't implement the requested method. If there is some other method that the
|
|
1874
|
+
* client could call (perhaps an older and/or slower interface), it should try that instead.
|
|
1875
|
+
* Otherwise, this should be treated like `failed`.
|
|
1876
|
+
*
|
|
1877
|
+
*/
|
|
1878
|
+
readonly UNIMPLEMENTED: 3;
|
|
1879
|
+
};
|
|
1880
|
+
type Exception_Type = (typeof Exception_Type)[keyof typeof Exception_Type];
|
|
1881
|
+
/**
|
|
1882
|
+
* **(level 0)**
|
|
1883
|
+
*
|
|
1884
|
+
* Describes an arbitrary error that prevented an operation (e.g. a call) from completing.
|
|
1885
|
+
*
|
|
1886
|
+
* Cap'n Proto exceptions always indicate that something went wrong. In other words, in a fantasy
|
|
1887
|
+
* world where everything always works as expected, no exceptions would ever be thrown. Clients
|
|
1888
|
+
* should only ever catch exceptions as a means to implement fault-tolerance, where "fault" can
|
|
1889
|
+
* mean:
|
|
1890
|
+
* - Bugs.
|
|
1891
|
+
* - Invalid input.
|
|
1892
|
+
* - Configuration errors.
|
|
1893
|
+
* - Network problems.
|
|
1894
|
+
* - Insufficient resources.
|
|
1895
|
+
* - Version skew (unimplemented functionality).
|
|
1896
|
+
* - Other logistical problems.
|
|
1897
|
+
*
|
|
1898
|
+
* Exceptions should NOT be used to flag application-specific conditions that a client is expected
|
|
1899
|
+
* to handle in an application-specific way. Put another way, in the Cap'n Proto world,
|
|
1900
|
+
* "checked exceptions" (where an interface explicitly defines the exceptions it throws and
|
|
1901
|
+
* clients are forced by the type system to handle those exceptions) do NOT make sense.
|
|
1902
|
+
*
|
|
1903
|
+
*/
|
|
1904
|
+
declare class Exception extends Struct {
|
|
1905
|
+
static readonly Type: {
|
|
1906
|
+
/**
|
|
1907
|
+
* A generic problem occurred, and it is believed that if the operation were repeated without
|
|
1908
|
+
* any change in the state of the world, the problem would occur again.
|
|
1909
|
+
*
|
|
1910
|
+
* A client might respond to this error by logging it for investigation by the developer and/or
|
|
1911
|
+
* displaying it to the user.
|
|
1912
|
+
*
|
|
1913
|
+
*/
|
|
1914
|
+
readonly FAILED: 0;
|
|
1915
|
+
/**
|
|
1916
|
+
* The request was rejected due to a temporary lack of resources.
|
|
1917
|
+
*
|
|
1918
|
+
* Examples include:
|
|
1919
|
+
* - There's not enough CPU time to keep up with incoming requests, so some are rejected.
|
|
1920
|
+
* - The server ran out of RAM or disk space during the request.
|
|
1921
|
+
* - The operation timed out (took significantly longer than it should have).
|
|
1922
|
+
*
|
|
1923
|
+
* A client might respond to this error by scheduling to retry the operation much later. The
|
|
1924
|
+
* client should NOT retry again immediately since this would likely exacerbate the problem.
|
|
1925
|
+
*
|
|
1926
|
+
*/
|
|
1927
|
+
readonly OVERLOADED: 1;
|
|
1928
|
+
/**
|
|
1929
|
+
* The method failed because a connection to some necessary capability was lost.
|
|
1930
|
+
*
|
|
1931
|
+
* Examples include:
|
|
1932
|
+
* - The client introduced the server to a third-party capability, the connection to that third
|
|
1933
|
+
* party was subsequently lost, and then the client requested that the server use the dead
|
|
1934
|
+
* capability for something.
|
|
1935
|
+
* - The client previously requested that the server obtain a capability from some third party.
|
|
1936
|
+
* The server returned a capability to an object wrapping the third-party capability. Later,
|
|
1937
|
+
* the server's connection to the third party was lost.
|
|
1938
|
+
* - The capability has been revoked. Revocation does not necessarily mean that the client is
|
|
1939
|
+
* no longer authorized to use the capability; it is often used simply as a way to force the
|
|
1940
|
+
* client to repeat the setup process, perhaps to efficiently move them to a new back-end or
|
|
1941
|
+
* get them to recognize some other change that has occurred.
|
|
1942
|
+
*
|
|
1943
|
+
* A client should normally respond to this error by releasing all capabilities it is currently
|
|
1944
|
+
* holding related to the one it called and then re-creating them by restoring SturdyRefs and/or
|
|
1945
|
+
* repeating the method calls used to create them originally. In other words, disconnect and
|
|
1946
|
+
* start over. This should in turn cause the server to obtain a new copy of the capability that
|
|
1947
|
+
* it lost, thus making everything work.
|
|
1948
|
+
*
|
|
1949
|
+
* If the client receives another `disconnected` error in the process of rebuilding the
|
|
1950
|
+
* capability and retrying the call, it should treat this as an `overloaded` error: the network
|
|
1951
|
+
* is currently unreliable, possibly due to load or other temporary issues.
|
|
1952
|
+
*
|
|
1953
|
+
*/
|
|
1954
|
+
readonly DISCONNECTED: 2;
|
|
1955
|
+
/**
|
|
1956
|
+
* The server doesn't implement the requested method. If there is some other method that the
|
|
1957
|
+
* client could call (perhaps an older and/or slower interface), it should try that instead.
|
|
1958
|
+
* Otherwise, this should be treated like `failed`.
|
|
1959
|
+
*
|
|
1960
|
+
*/
|
|
1961
|
+
readonly UNIMPLEMENTED: 3;
|
|
1962
|
+
};
|
|
1963
|
+
static readonly _capnp: {
|
|
1964
|
+
displayName: string;
|
|
1965
|
+
id: string;
|
|
1966
|
+
size: ObjectSize;
|
|
1967
|
+
};
|
|
1968
|
+
/**
|
|
1969
|
+
* Human-readable failure description.
|
|
1970
|
+
*
|
|
1971
|
+
*/
|
|
1972
|
+
get reason(): string;
|
|
1973
|
+
set reason(value: string);
|
|
1974
|
+
/**
|
|
1975
|
+
* The type of the error. The purpose of this enum is not to describe the error itself, but
|
|
1976
|
+
* rather to describe how the client might want to respond to the error.
|
|
1977
|
+
*
|
|
1978
|
+
*/
|
|
1979
|
+
get type(): Exception_Type;
|
|
1980
|
+
set type(value: Exception_Type);
|
|
1981
|
+
/**
|
|
1982
|
+
* OBSOLETE. Ignore.
|
|
1983
|
+
*
|
|
1984
|
+
*/
|
|
1985
|
+
get obsoleteIsCallersFault(): boolean;
|
|
1986
|
+
set obsoleteIsCallersFault(value: boolean);
|
|
1987
|
+
/**
|
|
1988
|
+
* OBSOLETE. See `type` instead.
|
|
1989
|
+
*
|
|
1990
|
+
*/
|
|
1991
|
+
get obsoleteDurability(): number;
|
|
1992
|
+
set obsoleteDurability(value: number);
|
|
1993
|
+
/**
|
|
1994
|
+
* Stack trace text from the remote server. The format is not specified. By default,
|
|
1995
|
+
* implementations do not provide stack traces; the application must explicitly enable them
|
|
1996
|
+
* when desired.
|
|
1997
|
+
*
|
|
1998
|
+
*/
|
|
1999
|
+
get trace(): string;
|
|
2000
|
+
set trace(value: string);
|
|
2001
|
+
toString(): string;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
export { Accept, Bootstrap, Call, Call_SendResultsTo, Call_SendResultsTo_Which, CapDescriptor, CapDescriptor_Which, Disembargo, Disembargo_Context, Disembargo_Context_Which, Exception, Exception_Type, Finish, Join, Message, MessageTarget, MessageTarget_Which, Message_Which, Payload, PromisedAnswer, PromisedAnswer_Op, PromisedAnswer_Op_Which, Provide, Release, Resolve, Resolve_Which, Return, Return_Which, ThirdPartyCapDescriptor, _capnpFileId };
|