UNPKG

@stryke/capnp

Version:

A package to assist in running the Cap'n Proto compiler and creating Cap'n Proto serialization protocol schemas.

1 lines 9.87 kB
{"version":3,"file":"rpc-twoparty.mjs","names":["$.Struct","$.ObjectSize"],"sources":["../../schemas/rpc-twoparty.ts"],"sourcesContent":["/* eslint-disable */\n// biome-ignore lint: disable\n// Generated by storm-capnpc\n// Note: Do not edit this file manually - it will be overwritten automatically\nimport * as $ from \"@stryke/capnp\";\nexport const _capnpFileId = BigInt(\"0xa184c7885cdaf2a1\");\nexport const Side = {\n /**\n* The object lives on the \"server\" or \"supervisor\" end of the connection. Only the\n* server/supervisor knows how to interpret the ref; to the client, it is opaque.\n*\n* Note that containers intending to implement strong confinement should rewrite SturdyRefs\n* received from the external network before passing them on to the confined app. The confined\n* app thus does not ever receive the raw bits of the SturdyRef (which it could perhaps\n* maliciously leak), but instead receives only a thing that it can pass back to the container\n* later to restore the ref. See:\n* http://www.erights.org/elib/capability/dist-confine.html\n*\n*/\n SERVER: 0,\n /**\n* The object lives on the \"client\" or \"confined app\" end of the connection. Only the client\n* knows how to interpret the ref; to the server/supervisor, it is opaque. Most clients do not\n* actually know how to persist capabilities at all, so use of this is unusual.\n*\n*/\n CLIENT: 1\n} as const;\nexport type Side = (typeof Side)[keyof typeof Side];\nexport class VatId extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"VatId\",\n id: \"d20b909fee733a8e\",\n size: new $.ObjectSize(8, 0),\n };\n get side(): Side {\n return $.utils.getUint16(0, this) as Side;\n }\n set side(value: Side) {\n $.utils.setUint16(0, value, this);\n }\n public override toString(): string { return \"VatId_\" + super.toString(); }\n}\n/**\n* Only used for joins, since three-way introductions never happen on a two-party network.\n*\n*/\nexport class ProvisionId extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"ProvisionId\",\n id: \"b88d09a9c5f39817\",\n size: new $.ObjectSize(8, 0),\n };\n /**\n* The ID from `JoinKeyPart`.\n*\n*/\n get joinId(): number {\n return $.utils.getUint32(0, this);\n }\n set joinId(value: number) {\n $.utils.setUint32(0, value, this);\n }\n public override toString(): string { return \"ProvisionId_\" + super.toString(); }\n}\n/**\n* Never used, because there are only two parties.\n*\n*/\nexport class RecipientId extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"RecipientId\",\n id: \"89f389b6fd4082c1\",\n size: new $.ObjectSize(0, 0),\n };\n public override toString(): string { return \"RecipientId_\" + super.toString(); }\n}\n/**\n* Never used, because there is no third party.\n*\n*/\nexport class ThirdPartyCapId extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"ThirdPartyCapId\",\n id: \"b47f4979672cb59d\",\n size: new $.ObjectSize(0, 0),\n };\n public override toString(): string { return \"ThirdPartyCapId_\" + super.toString(); }\n}\n/**\n* Joins in the two-party case are simplified by a few observations.\n*\n* First, on a two-party network, a Join only ever makes sense if the receiving end is also\n* connected to other networks. A vat which is not connected to any other network can safely\n* reject all joins.\n*\n* Second, since a two-party connection bisects the network -- there can be no other connections\n* between the networks at either end of the connection -- if one part of a join crosses the\n* connection, then _all_ parts must cross it. Therefore, a vat which is receiving a Join request\n* off some other network which needs to be forwarded across the two-party connection can\n* collect all the parts on its end and only forward them across the two-party connection when all\n* have been received.\n*\n* For example, imagine that Alice and Bob are vats connected over a two-party connection, and\n* each is also connected to other networks. At some point, Alice receives one part of a Join\n* request off her network. The request is addressed to a capability that Alice received from\n* Bob and is proxying to her other network. Alice goes ahead and responds to the Join part as\n* if she hosted the capability locally (this is important so that if not all the Join parts end\n* up at Alice, the original sender can detect the failed Join without hanging). As other parts\n* trickle in, Alice verifies that each part is addressed to a capability from Bob and continues\n* to respond to each one. Once the complete set of join parts is received, Alice checks if they\n* were all for the exact same capability. If so, she doesn't need to send anything to Bob at\n* all. Otherwise, she collects the set of capabilities (from Bob) to which the join parts were\n* addressed and essentially initiates a _new_ Join request on those capabilities to Bob. Alice\n* does not forward the Join parts she received herself, but essentially forwards the Join as a\n* whole.\n*\n* On Bob's end, since he knows that Alice will always send all parts of a Join together, he\n* simply waits until he's received them all, then performs a join on the respective capabilities\n* as if it had been requested locally.\n*\n*/\nexport class JoinKeyPart extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"JoinKeyPart\",\n id: \"95b29059097fca83\",\n size: new $.ObjectSize(8, 0),\n };\n /**\n* A number identifying this join, chosen by the sender. May be reused once `Finish` messages are\n* sent corresponding to all of the `Join` messages.\n*\n*/\n get joinId(): number {\n return $.utils.getUint32(0, this);\n }\n set joinId(value: number) {\n $.utils.setUint32(0, value, this);\n }\n /**\n* The number of capabilities to be joined.\n*\n*/\n get partCount(): number {\n return $.utils.getUint16(4, this);\n }\n set partCount(value: number) {\n $.utils.setUint16(4, value, this);\n }\n /**\n* Which part this request targets -- a number in the range [0, partCount).\n*\n*/\n get partNum(): number {\n return $.utils.getUint16(6, this);\n }\n set partNum(value: number) {\n $.utils.setUint16(6, value, this);\n }\n public override toString(): string { return \"JoinKeyPart_\" + super.toString(); }\n}\nexport class JoinResult extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"JoinResult\",\n id: \"9d263a3630b7ebee\",\n size: new $.ObjectSize(8, 1),\n };\n /**\n* Matches `JoinKeyPart`.\n*\n*/\n get joinId(): number {\n return $.utils.getUint32(0, this);\n }\n set joinId(value: number) {\n $.utils.setUint32(0, value, this);\n }\n /**\n* All JoinResults in the set will have the same value for `succeeded`. The receiver actually\n* implements the join by waiting for all the `JoinKeyParts` and then performing its own join on\n* them, then going back and answering all the join requests afterwards.\n*\n*/\n get succeeded(): boolean {\n return $.utils.getBit(32, this);\n }\n set succeeded(value: boolean) {\n $.utils.setBit(32, value, this);\n }\n _adoptCap(value: $.Orphan<$.Pointer>): void {\n $.utils.adopt(value, $.utils.getPointer(0, this));\n }\n _disownCap(): $.Orphan<$.Pointer> {\n return $.utils.disown(this.cap);\n }\n /**\n* One of the JoinResults will have a non-null `cap` which is the joined capability.\n*\n*/\n get cap(): $.Pointer {\n return $.utils.getPointer(0, this);\n }\n _hasCap(): boolean {\n return !$.utils.isNull($.utils.getPointer(0, this));\n }\n set cap(value: $.Pointer) {\n $.utils.copyFrom(value, $.utils.getPointer(0, this));\n }\n public override toString(): string { return \"JoinResult_\" + super.toString(); }\n}\n"],"mappings":";;;AAKA,MAAa,eAAe,OAAO,qBAAqB;AACxD,MAAa,OAAO;;;;;;;;;;;;;CAalB,QAAQ;;;;;;;CAOR,QAAQ;CACT;AAED,IAAa,QAAb,cAA2BA,OAAS;CAClC,OAAgC,SAAS;EACvC,aAAa;EACb,IAAI;EACJ,MAAM,IAAIC,WAAa,GAAG,EAAE;EAC7B;CACD,IAAI,OAAa;AACf,eAAe,UAAU,GAAG,KAAK;;CAEnC,IAAI,KAAK,OAAa;AACpB,QAAQ,UAAU,GAAG,OAAO,KAAK;;CAEnC,AAAgB,WAAmB;AAAE,SAAO,WAAW,MAAM,UAAU;;;;;;;AAMzE,IAAa,cAAb,cAAiCD,OAAS;CACxC,OAAgC,SAAS;EACvC,aAAa;EACb,IAAI;EACJ,MAAM,IAAIC,WAAa,GAAG,EAAE;EAC7B;;;;;CAKD,IAAI,SAAiB;AACnB,eAAe,UAAU,GAAG,KAAK;;CAEnC,IAAI,OAAO,OAAe;AACxB,QAAQ,UAAU,GAAG,OAAO,KAAK;;CAEnC,AAAgB,WAAmB;AAAE,SAAO,iBAAiB,MAAM,UAAU;;;;;;;AAM/E,IAAa,cAAb,cAAiCD,OAAS;CACxC,OAAgC,SAAS;EACvC,aAAa;EACb,IAAI;EACJ,MAAM,IAAIC,WAAa,GAAG,EAAE;EAC7B;CACD,AAAgB,WAAmB;AAAE,SAAO,iBAAiB,MAAM,UAAU;;;;;;;AAM/E,IAAa,kBAAb,cAAqCD,OAAS;CAC5C,OAAgC,SAAS;EACvC,aAAa;EACb,IAAI;EACJ,MAAM,IAAIC,WAAa,GAAG,EAAE;EAC7B;CACD,AAAgB,WAAmB;AAAE,SAAO,qBAAqB,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCnF,IAAa,c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