@stryke/capnp
Version:
A package to assist in running the Cap'n Proto compiler and creating Cap'n Proto serialization protocol schemas.
230 lines (228 loc) • 7.38 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_src = require('./src-B6FhDNiV.cjs');
//#region schemas/rpc-twoparty.ts
const _capnpFileId = BigInt("0xa184c7885cdaf2a1");
const Side = {
/**
* The object lives on the "server" or "supervisor" end of the connection. Only the
* server/supervisor knows how to interpret the ref; to the client, it is opaque.
*
* Note that containers intending to implement strong confinement should rewrite SturdyRefs
* received from the external network before passing them on to the confined app. The confined
* app thus does not ever receive the raw bits of the SturdyRef (which it could perhaps
* maliciously leak), but instead receives only a thing that it can pass back to the container
* later to restore the ref. See:
* http://www.erights.org/elib/capability/dist-confine.html
*
*/
SERVER: 0,
/**
* The object lives on the "client" or "confined app" end of the connection. Only the client
* knows how to interpret the ref; to the server/supervisor, it is opaque. Most clients do not
* actually know how to persist capabilities at all, so use of this is unusual.
*
*/
CLIENT: 1
};
var VatId = class extends require_src.Struct {
static _capnp = {
displayName: "VatId",
id: "d20b909fee733a8e",
size: new require_src.ObjectSize(8, 0)
};
get side() {
return require_src.utils.getUint16(0, this);
}
set side(value) {
require_src.utils.setUint16(0, value, this);
}
toString() {
return "VatId_" + super.toString();
}
};
/**
* Only used for joins, since three-way introductions never happen on a two-party network.
*
*/
var ProvisionId = class extends require_src.Struct {
static _capnp = {
displayName: "ProvisionId",
id: "b88d09a9c5f39817",
size: new require_src.ObjectSize(8, 0)
};
/**
* The ID from `JoinKeyPart`.
*
*/
get joinId() {
return require_src.utils.getUint32(0, this);
}
set joinId(value) {
require_src.utils.setUint32(0, value, this);
}
toString() {
return "ProvisionId_" + super.toString();
}
};
/**
* Never used, because there are only two parties.
*
*/
var RecipientId = class extends require_src.Struct {
static _capnp = {
displayName: "RecipientId",
id: "89f389b6fd4082c1",
size: new require_src.ObjectSize(0, 0)
};
toString() {
return "RecipientId_" + super.toString();
}
};
/**
* Never used, because there is no third party.
*
*/
var ThirdPartyCapId = class extends require_src.Struct {
static _capnp = {
displayName: "ThirdPartyCapId",
id: "b47f4979672cb59d",
size: new require_src.ObjectSize(0, 0)
};
toString() {
return "ThirdPartyCapId_" + super.toString();
}
};
/**
* Joins in the two-party case are simplified by a few observations.
*
* First, on a two-party network, a Join only ever makes sense if the receiving end is also
* connected to other networks. A vat which is not connected to any other network can safely
* reject all joins.
*
* Second, since a two-party connection bisects the network -- there can be no other connections
* between the networks at either end of the connection -- if one part of a join crosses the
* connection, then _all_ parts must cross it. Therefore, a vat which is receiving a Join request
* off some other network which needs to be forwarded across the two-party connection can
* collect all the parts on its end and only forward them across the two-party connection when all
* have been received.
*
* For example, imagine that Alice and Bob are vats connected over a two-party connection, and
* each is also connected to other networks. At some point, Alice receives one part of a Join
* request off her network. The request is addressed to a capability that Alice received from
* Bob and is proxying to her other network. Alice goes ahead and responds to the Join part as
* if she hosted the capability locally (this is important so that if not all the Join parts end
* up at Alice, the original sender can detect the failed Join without hanging). As other parts
* trickle in, Alice verifies that each part is addressed to a capability from Bob and continues
* to respond to each one. Once the complete set of join parts is received, Alice checks if they
* were all for the exact same capability. If so, she doesn't need to send anything to Bob at
* all. Otherwise, she collects the set of capabilities (from Bob) to which the join parts were
* addressed and essentially initiates a _new_ Join request on those capabilities to Bob. Alice
* does not forward the Join parts she received herself, but essentially forwards the Join as a
* whole.
*
* On Bob's end, since he knows that Alice will always send all parts of a Join together, he
* simply waits until he's received them all, then performs a join on the respective capabilities
* as if it had been requested locally.
*
*/
var JoinKeyPart = class extends require_src.Struct {
static _capnp = {
displayName: "JoinKeyPart",
id: "95b29059097fca83",
size: new require_src.ObjectSize(8, 0)
};
/**
* A number identifying this join, chosen by the sender. May be reused once `Finish` messages are
* sent corresponding to all of the `Join` messages.
*
*/
get joinId() {
return require_src.utils.getUint32(0, this);
}
set joinId(value) {
require_src.utils.setUint32(0, value, this);
}
/**
* The number of capabilities to be joined.
*
*/
get partCount() {
return require_src.utils.getUint16(4, this);
}
set partCount(value) {
require_src.utils.setUint16(4, value, this);
}
/**
* Which part this request targets -- a number in the range [0, partCount).
*
*/
get partNum() {
return require_src.utils.getUint16(6, this);
}
set partNum(value) {
require_src.utils.setUint16(6, value, this);
}
toString() {
return "JoinKeyPart_" + super.toString();
}
};
var JoinResult = class extends require_src.Struct {
static _capnp = {
displayName: "JoinResult",
id: "9d263a3630b7ebee",
size: new require_src.ObjectSize(8, 1)
};
/**
* Matches `JoinKeyPart`.
*
*/
get joinId() {
return require_src.utils.getUint32(0, this);
}
set joinId(value) {
require_src.utils.setUint32(0, value, this);
}
/**
* All JoinResults in the set will have the same value for `succeeded`. The receiver actually
* implements the join by waiting for all the `JoinKeyParts` and then performing its own join on
* them, then going back and answering all the join requests afterwards.
*
*/
get succeeded() {
return require_src.utils.getBit(32, this);
}
set succeeded(value) {
require_src.utils.setBit(32, value, this);
}
_adoptCap(value) {
require_src.utils.adopt(value, require_src.utils.getPointer(0, this));
}
_disownCap() {
return require_src.utils.disown(this.cap);
}
/**
* One of the JoinResults will have a non-null `cap` which is the joined capability.
*
*/
get cap() {
return require_src.utils.getPointer(0, this);
}
_hasCap() {
return !require_src.utils.isNull(require_src.utils.getPointer(0, this));
}
set cap(value) {
require_src.utils.copyFrom(value, require_src.utils.getPointer(0, this));
}
toString() {
return "JoinResult_" + super.toString();
}
};
//#endregion
exports.JoinKeyPart = JoinKeyPart;
exports.JoinResult = JoinResult;
exports.ProvisionId = ProvisionId;
exports.RecipientId = RecipientId;
exports.Side = Side;
exports.ThirdPartyCapId = ThirdPartyCapId;
exports.VatId = VatId;
exports._capnpFileId = _capnpFileId;