@stryke/capnp 0.8.2 → 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.
@@ -0,0 +1,6 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ export {
5
+ __name
6
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+
5
+
6
+ exports.__name = __name;
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-USNT2KNT.cjs');
2
+
3
+ // schemas/cpp.ts
4
+ var _capnpFileId = BigInt("0xbdf87d7bb8304e82");
5
+
6
+
7
+ exports._capnpFileId = _capnpFileId;
@@ -0,0 +1,3 @@
1
+ declare const _capnpFileId: bigint;
2
+
3
+ export { _capnpFileId };
@@ -0,0 +1,3 @@
1
+ declare const _capnpFileId: bigint;
2
+
3
+ export { _capnpFileId };
package/schemas/cpp.js ADDED
@@ -0,0 +1,7 @@
1
+ import "./chunk-SHUYVCID.js";
2
+
3
+ // schemas/cpp.ts
4
+ var _capnpFileId = BigInt("0xbdf87d7bb8304e82");
5
+ export {
6
+ _capnpFileId
7
+ };
@@ -0,0 +1,171 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class; var _class2; var _class3; var _class4;
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ var _chunkGX6VRR3Gcjs = require('./chunk-GX6VRR3G.cjs');
10
+
11
+
12
+ var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
13
+
14
+ // schemas/persistent.ts
15
+ var _capnpFileId = BigInt("0xb8630836983feed7");
16
+ var Persistent_SaveParams = (_class = class extends _chunkGX6VRR3Gcjs.Struct {
17
+ static {
18
+ _chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent_SaveParams");
19
+ }
20
+ static __initStatic() {this._capnp = {
21
+ displayName: "SaveParams",
22
+ id: "f76fba59183073a5",
23
+ size: new (0, _chunkGX6VRR3Gcjs.ObjectSize)(0, 1)
24
+ }}
25
+ _adoptSealFor(value) {
26
+ _chunkGX6VRR3Gcjs.utils.adopt(value, _chunkGX6VRR3Gcjs.utils.getPointer(0, this));
27
+ }
28
+ _disownSealFor() {
29
+ return _chunkGX6VRR3Gcjs.utils.disown(this.sealFor);
30
+ }
31
+ /**
32
+ * Seal the SturdyRef so that it can only be restored by the specified Owner. This is meant
33
+ * to mitigate damage when a SturdyRef is leaked. See comments above.
34
+ *
35
+ * Leaving this value null may or may not be allowed; it is up to the realm to decide. If a
36
+ * realm does allow a null owner, this should indicate that anyone is allowed to restore the
37
+ * ref.
38
+ *
39
+ */
40
+ get sealFor() {
41
+ return _chunkGX6VRR3Gcjs.utils.getPointer(0, this);
42
+ }
43
+ _hasSealFor() {
44
+ return !_chunkGX6VRR3Gcjs.utils.isNull(_chunkGX6VRR3Gcjs.utils.getPointer(0, this));
45
+ }
46
+ set sealFor(value) {
47
+ _chunkGX6VRR3Gcjs.utils.copyFrom(value, _chunkGX6VRR3Gcjs.utils.getPointer(0, this));
48
+ }
49
+ toString() {
50
+ return "Persistent_SaveParams_" + super.toString();
51
+ }
52
+ }, _class.__initStatic(), _class);
53
+ var Persistent_SaveResults = (_class2 = class extends _chunkGX6VRR3Gcjs.Struct {
54
+ static {
55
+ _chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent_SaveResults");
56
+ }
57
+ static __initStatic2() {this._capnp = {
58
+ displayName: "SaveResults",
59
+ id: "b76848c18c40efbf",
60
+ size: new (0, _chunkGX6VRR3Gcjs.ObjectSize)(0, 1)
61
+ }}
62
+ _adoptSturdyRef(value) {
63
+ _chunkGX6VRR3Gcjs.utils.adopt(value, _chunkGX6VRR3Gcjs.utils.getPointer(0, this));
64
+ }
65
+ _disownSturdyRef() {
66
+ return _chunkGX6VRR3Gcjs.utils.disown(this.sturdyRef);
67
+ }
68
+ get sturdyRef() {
69
+ return _chunkGX6VRR3Gcjs.utils.getPointer(0, this);
70
+ }
71
+ _hasSturdyRef() {
72
+ return !_chunkGX6VRR3Gcjs.utils.isNull(_chunkGX6VRR3Gcjs.utils.getPointer(0, this));
73
+ }
74
+ set sturdyRef(value) {
75
+ _chunkGX6VRR3Gcjs.utils.copyFrom(value, _chunkGX6VRR3Gcjs.utils.getPointer(0, this));
76
+ }
77
+ toString() {
78
+ return "Persistent_SaveResults_" + super.toString();
79
+ }
80
+ }, _class2.__initStatic2(), _class2);
81
+ var Persistent_SaveResults$Promise = class {
82
+ static {
83
+ _chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent_SaveResults$Promise");
84
+ }
85
+
86
+ constructor(pipeline) {
87
+ this.pipeline = pipeline;
88
+ }
89
+ async promise() {
90
+ return await this.pipeline.struct();
91
+ }
92
+ };
93
+ var Persistent$Client = (_class3 = class _Persistent$Client {
94
+ static {
95
+ _chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent$Client");
96
+ }
97
+
98
+ static __initStatic3() {this.interfaceId = BigInt("0xc8cb212fcd9f5691")}
99
+ constructor(client) {
100
+ this.client = client;
101
+ }
102
+ static __initStatic4() {this.methods = [
103
+ {
104
+ ParamsClass: Persistent_SaveParams,
105
+ ResultsClass: Persistent_SaveResults,
106
+ interfaceId: _Persistent$Client.interfaceId,
107
+ methodId: 0,
108
+ interfaceName: "packages/capnp/schemas/persistent.capnp:Persistent",
109
+ methodName: "save"
110
+ }
111
+ ]}
112
+ /**
113
+ * Save a capability persistently so that it can be restored by a future connection. Not all
114
+ * capabilities can be saved -- application interfaces should define which capabilities support
115
+ * this and which do not.
116
+ *
117
+ */
118
+ save(paramsFunc) {
119
+ const answer = this.client.call({
120
+ method: _Persistent$Client.methods[0],
121
+ paramsFunc
122
+ });
123
+ const pipeline = new (0, _chunkGX6VRR3Gcjs.Pipeline)(Persistent_SaveResults, answer);
124
+ return new Persistent_SaveResults$Promise(pipeline);
125
+ }
126
+ }, _class3.__initStatic3(), _class3.__initStatic4(), _class3);
127
+ _chunkGX6VRR3Gcjs.Registry.register(Persistent$Client.interfaceId, Persistent$Client);
128
+ var Persistent$Server = class extends _chunkGX6VRR3Gcjs.Server {
129
+ static {
130
+ _chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent$Server");
131
+ }
132
+
133
+ constructor(target) {
134
+ super(target, [
135
+ {
136
+ ...Persistent$Client.methods[0],
137
+ impl: target.save
138
+ }
139
+ ]);
140
+ this.target = target;
141
+ }
142
+ client() {
143
+ return new Persistent$Client(this);
144
+ }
145
+ };
146
+ var Persistent = (_class4 = class extends _chunkGX6VRR3Gcjs.Interface {
147
+ static {
148
+ _chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent");
149
+ }
150
+ static __initStatic5() {this.SaveParams = Persistent_SaveParams}
151
+ static __initStatic6() {this.SaveResults = Persistent_SaveResults}
152
+ static __initStatic7() {this.Client = Persistent$Client}
153
+ static __initStatic8() {this.Server = Persistent$Server}
154
+ static __initStatic9() {this._capnp = {
155
+ displayName: "Persistent",
156
+ id: "c8cb212fcd9f5691",
157
+ size: new (0, _chunkGX6VRR3Gcjs.ObjectSize)(0, 0)
158
+ }}
159
+ toString() {
160
+ return "Persistent_" + super.toString();
161
+ }
162
+ }, _class4.__initStatic5(), _class4.__initStatic6(), _class4.__initStatic7(), _class4.__initStatic8(), _class4.__initStatic9(), _class4);
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ exports.Persistent = Persistent; exports.Persistent$Client = Persistent$Client; exports.Persistent$Server = Persistent$Server; exports.Persistent_SaveParams = Persistent_SaveParams; exports.Persistent_SaveResults = Persistent_SaveResults; exports.Persistent_SaveResults$Promise = Persistent_SaveResults$Promise; exports._capnpFileId = _capnpFileId;
@@ -0,0 +1,147 @@
1
+ import { Struct, ObjectSize, Orphan, Pointer, Pipeline, Client, Method, Server, Interface } from 'capnp-es';
2
+
3
+ declare const _capnpFileId: bigint;
4
+ declare class Persistent_SaveParams extends Struct {
5
+ static readonly _capnp: {
6
+ displayName: string;
7
+ id: string;
8
+ size: ObjectSize;
9
+ };
10
+ _adoptSealFor(value: Orphan<Pointer>): void;
11
+ _disownSealFor(): Orphan<Pointer>;
12
+ /**
13
+ * Seal the SturdyRef so that it can only be restored by the specified Owner. This is meant
14
+ * to mitigate damage when a SturdyRef is leaked. See comments above.
15
+ *
16
+ * Leaving this value null may or may not be allowed; it is up to the realm to decide. If a
17
+ * realm does allow a null owner, this should indicate that anyone is allowed to restore the
18
+ * ref.
19
+ *
20
+ */
21
+ get sealFor(): Pointer;
22
+ _hasSealFor(): boolean;
23
+ set sealFor(value: Pointer);
24
+ toString(): string;
25
+ }
26
+ declare class Persistent_SaveResults extends Struct {
27
+ static readonly _capnp: {
28
+ displayName: string;
29
+ id: string;
30
+ size: ObjectSize;
31
+ };
32
+ _adoptSturdyRef(value: Orphan<Pointer>): void;
33
+ _disownSturdyRef(): Orphan<Pointer>;
34
+ get sturdyRef(): Pointer;
35
+ _hasSturdyRef(): boolean;
36
+ set sturdyRef(value: Pointer);
37
+ toString(): string;
38
+ }
39
+ declare class Persistent_SaveResults$Promise {
40
+ pipeline: Pipeline<any, any, Persistent_SaveResults>;
41
+ constructor(pipeline: Pipeline<any, any, Persistent_SaveResults>);
42
+ promise(): Promise<Persistent_SaveResults>;
43
+ }
44
+ declare class Persistent$Client {
45
+ client: Client;
46
+ static readonly interfaceId: bigint;
47
+ constructor(client: Client);
48
+ static readonly methods: [
49
+ Method<Persistent_SaveParams, Persistent_SaveResults>
50
+ ];
51
+ /**
52
+ * Save a capability persistently so that it can be restored by a future connection. Not all
53
+ * capabilities can be saved -- application interfaces should define which capabilities support
54
+ * this and which do not.
55
+ *
56
+ */
57
+ save(paramsFunc?: (params: Persistent_SaveParams) => void): Persistent_SaveResults$Promise;
58
+ }
59
+ interface Persistent$Server$Target {
60
+ save(params: Persistent_SaveParams, results: Persistent_SaveResults): Promise<void>;
61
+ }
62
+ declare class Persistent$Server extends Server {
63
+ readonly target: Persistent$Server$Target;
64
+ constructor(target: Persistent$Server$Target);
65
+ client(): Persistent$Client;
66
+ }
67
+ /**
68
+ * Interface implemented by capabilities that outlive a single connection. A client may save()
69
+ * the capability, producing a SturdyRef. The SturdyRef can be stored to disk, then later used to
70
+ * obtain a new reference to the capability on a future connection.
71
+ *
72
+ * The exact format of SturdyRef depends on the "realm" in which the SturdyRef appears. A "realm"
73
+ * is an abstract space in which all SturdyRefs have the same format and refer to the same set of
74
+ * resources. Every vat is in exactly one realm. All capability clients within that vat must
75
+ * produce SturdyRefs of the format appropriate for the realm.
76
+ *
77
+ * Similarly, every VatNetwork also resides in a particular realm. Usually, a vat's "realm"
78
+ * corresponds to the realm of its main VatNetwork. However, a Vat can in fact communicate over
79
+ * a VatNetwork in a different realm -- in this case, all SturdyRefs need to be transformed when
80
+ * coming or going through said VatNetwork. The RPC system has hooks for registering
81
+ * transformation callbacks for this purpose.
82
+ *
83
+ * Since the format of SturdyRef is realm-dependent, it is not defined here. An application should
84
+ * choose an appropriate realm for itself as part of its design. Note that under Sandstorm, every
85
+ * application exists in its own realm and is therefore free to define its own SturdyRef format;
86
+ * the Sandstorm platform handles translating between realms.
87
+ *
88
+ * Note that whether a capability is persistent is often orthogonal to its type. In these cases,
89
+ * the capability's interface should NOT inherit `Persistent`; instead, just perform a cast at
90
+ * runtime. It's not type-safe, but trying to be type-safe in these cases will likely lead to
91
+ * tears. In cases where a particular interface only makes sense on persistent capabilities, it
92
+ * still should not explicitly inherit Persistent because the `SturdyRef` and `Owner` types will
93
+ * vary between realms (they may even be different at the call site than they are on the
94
+ * implementation). Instead, mark persistent interfaces with the $persistent annotation (defined
95
+ * below).
96
+ *
97
+ * Sealing
98
+ * -------
99
+ *
100
+ * As an added security measure, SturdyRefs may be "sealed" to a particular owner, such that
101
+ * if the SturdyRef itself leaks to a third party, that party cannot actually restore it because
102
+ * they are not the owner. To restore a sealed capability, you must first prove to its host that
103
+ * you are the rightful owner. The precise mechanism for this authentication is defined by the
104
+ * realm.
105
+ *
106
+ * Sealing is a defense-in-depth mechanism meant to mitigate damage in the case of catastrophic
107
+ * attacks. For example, say an attacker temporarily gains read access to a database full of
108
+ * SturdyRefs: it would be unfortunate if it were then necessary to revoke every single reference
109
+ * in the database to prevent the attacker from using them.
110
+ *
111
+ * In general, an "owner" is a course-grained identity. Because capability-based security is still
112
+ * the primary mechanism of security, it is not necessary nor desirable to have a separate "owner"
113
+ * identity for every single process or object; that is exactly what capabilities are supposed to
114
+ * avoid! Instead, it makes sense for an "owner" to literally identify the owner of the machines
115
+ * where the capability is stored. If untrusted third parties are able to run arbitrary code on
116
+ * said machines, then the sandbox for that code should be designed using Distributed Confinement
117
+ * such that the third-party code never sees the bits of the SturdyRefs and cannot directly
118
+ * exercise the owner's power to restore refs. See:
119
+ *
120
+ * http://www.erights.org/elib/capability/dist-confine.html
121
+ *
122
+ * Resist the urge to represent an Owner as a simple public key. The whole point of sealing is to
123
+ * defend against leaked-storage attacks. Such attacks can easily result in the owner's private
124
+ * key being stolen as well. A better solution is for `Owner` to contain a simple globally unique
125
+ * identifier for the owner, and for everyone to separately maintain a mapping of owner IDs to
126
+ * public keys. If an owner's private key is compromised, then humans will need to communicate
127
+ * and agree on a replacement public key, then update the mapping.
128
+ *
129
+ * As a concrete example, an `Owner` could simply contain a domain name, and restoring a SturdyRef
130
+ * would require signing a request using the domain's private key. Authenticating this key could
131
+ * be accomplished through certificate authorities or web-of-trust techniques.
132
+ *
133
+ */
134
+ declare class Persistent extends Interface {
135
+ static readonly SaveParams: typeof Persistent_SaveParams;
136
+ static readonly SaveResults: typeof Persistent_SaveResults;
137
+ static readonly Client: typeof Persistent$Client;
138
+ static readonly Server: typeof Persistent$Server;
139
+ static readonly _capnp: {
140
+ displayName: string;
141
+ id: string;
142
+ size: ObjectSize;
143
+ };
144
+ toString(): string;
145
+ }
146
+
147
+ export { Persistent, Persistent$Client, Persistent$Server, type Persistent$Server$Target, Persistent_SaveParams, Persistent_SaveResults, Persistent_SaveResults$Promise, _capnpFileId };
@@ -0,0 +1,147 @@
1
+ import { Struct, ObjectSize, Orphan, Pointer, Pipeline, Client, Method, Server, Interface } from 'capnp-es';
2
+
3
+ declare const _capnpFileId: bigint;
4
+ declare class Persistent_SaveParams extends Struct {
5
+ static readonly _capnp: {
6
+ displayName: string;
7
+ id: string;
8
+ size: ObjectSize;
9
+ };
10
+ _adoptSealFor(value: Orphan<Pointer>): void;
11
+ _disownSealFor(): Orphan<Pointer>;
12
+ /**
13
+ * Seal the SturdyRef so that it can only be restored by the specified Owner. This is meant
14
+ * to mitigate damage when a SturdyRef is leaked. See comments above.
15
+ *
16
+ * Leaving this value null may or may not be allowed; it is up to the realm to decide. If a
17
+ * realm does allow a null owner, this should indicate that anyone is allowed to restore the
18
+ * ref.
19
+ *
20
+ */
21
+ get sealFor(): Pointer;
22
+ _hasSealFor(): boolean;
23
+ set sealFor(value: Pointer);
24
+ toString(): string;
25
+ }
26
+ declare class Persistent_SaveResults extends Struct {
27
+ static readonly _capnp: {
28
+ displayName: string;
29
+ id: string;
30
+ size: ObjectSize;
31
+ };
32
+ _adoptSturdyRef(value: Orphan<Pointer>): void;
33
+ _disownSturdyRef(): Orphan<Pointer>;
34
+ get sturdyRef(): Pointer;
35
+ _hasSturdyRef(): boolean;
36
+ set sturdyRef(value: Pointer);
37
+ toString(): string;
38
+ }
39
+ declare class Persistent_SaveResults$Promise {
40
+ pipeline: Pipeline<any, any, Persistent_SaveResults>;
41
+ constructor(pipeline: Pipeline<any, any, Persistent_SaveResults>);
42
+ promise(): Promise<Persistent_SaveResults>;
43
+ }
44
+ declare class Persistent$Client {
45
+ client: Client;
46
+ static readonly interfaceId: bigint;
47
+ constructor(client: Client);
48
+ static readonly methods: [
49
+ Method<Persistent_SaveParams, Persistent_SaveResults>
50
+ ];
51
+ /**
52
+ * Save a capability persistently so that it can be restored by a future connection. Not all
53
+ * capabilities can be saved -- application interfaces should define which capabilities support
54
+ * this and which do not.
55
+ *
56
+ */
57
+ save(paramsFunc?: (params: Persistent_SaveParams) => void): Persistent_SaveResults$Promise;
58
+ }
59
+ interface Persistent$Server$Target {
60
+ save(params: Persistent_SaveParams, results: Persistent_SaveResults): Promise<void>;
61
+ }
62
+ declare class Persistent$Server extends Server {
63
+ readonly target: Persistent$Server$Target;
64
+ constructor(target: Persistent$Server$Target);
65
+ client(): Persistent$Client;
66
+ }
67
+ /**
68
+ * Interface implemented by capabilities that outlive a single connection. A client may save()
69
+ * the capability, producing a SturdyRef. The SturdyRef can be stored to disk, then later used to
70
+ * obtain a new reference to the capability on a future connection.
71
+ *
72
+ * The exact format of SturdyRef depends on the "realm" in which the SturdyRef appears. A "realm"
73
+ * is an abstract space in which all SturdyRefs have the same format and refer to the same set of
74
+ * resources. Every vat is in exactly one realm. All capability clients within that vat must
75
+ * produce SturdyRefs of the format appropriate for the realm.
76
+ *
77
+ * Similarly, every VatNetwork also resides in a particular realm. Usually, a vat's "realm"
78
+ * corresponds to the realm of its main VatNetwork. However, a Vat can in fact communicate over
79
+ * a VatNetwork in a different realm -- in this case, all SturdyRefs need to be transformed when
80
+ * coming or going through said VatNetwork. The RPC system has hooks for registering
81
+ * transformation callbacks for this purpose.
82
+ *
83
+ * Since the format of SturdyRef is realm-dependent, it is not defined here. An application should
84
+ * choose an appropriate realm for itself as part of its design. Note that under Sandstorm, every
85
+ * application exists in its own realm and is therefore free to define its own SturdyRef format;
86
+ * the Sandstorm platform handles translating between realms.
87
+ *
88
+ * Note that whether a capability is persistent is often orthogonal to its type. In these cases,
89
+ * the capability's interface should NOT inherit `Persistent`; instead, just perform a cast at
90
+ * runtime. It's not type-safe, but trying to be type-safe in these cases will likely lead to
91
+ * tears. In cases where a particular interface only makes sense on persistent capabilities, it
92
+ * still should not explicitly inherit Persistent because the `SturdyRef` and `Owner` types will
93
+ * vary between realms (they may even be different at the call site than they are on the
94
+ * implementation). Instead, mark persistent interfaces with the $persistent annotation (defined
95
+ * below).
96
+ *
97
+ * Sealing
98
+ * -------
99
+ *
100
+ * As an added security measure, SturdyRefs may be "sealed" to a particular owner, such that
101
+ * if the SturdyRef itself leaks to a third party, that party cannot actually restore it because
102
+ * they are not the owner. To restore a sealed capability, you must first prove to its host that
103
+ * you are the rightful owner. The precise mechanism for this authentication is defined by the
104
+ * realm.
105
+ *
106
+ * Sealing is a defense-in-depth mechanism meant to mitigate damage in the case of catastrophic
107
+ * attacks. For example, say an attacker temporarily gains read access to a database full of
108
+ * SturdyRefs: it would be unfortunate if it were then necessary to revoke every single reference
109
+ * in the database to prevent the attacker from using them.
110
+ *
111
+ * In general, an "owner" is a course-grained identity. Because capability-based security is still
112
+ * the primary mechanism of security, it is not necessary nor desirable to have a separate "owner"
113
+ * identity for every single process or object; that is exactly what capabilities are supposed to
114
+ * avoid! Instead, it makes sense for an "owner" to literally identify the owner of the machines
115
+ * where the capability is stored. If untrusted third parties are able to run arbitrary code on
116
+ * said machines, then the sandbox for that code should be designed using Distributed Confinement
117
+ * such that the third-party code never sees the bits of the SturdyRefs and cannot directly
118
+ * exercise the owner's power to restore refs. See:
119
+ *
120
+ * http://www.erights.org/elib/capability/dist-confine.html
121
+ *
122
+ * Resist the urge to represent an Owner as a simple public key. The whole point of sealing is to
123
+ * defend against leaked-storage attacks. Such attacks can easily result in the owner's private
124
+ * key being stolen as well. A better solution is for `Owner` to contain a simple globally unique
125
+ * identifier for the owner, and for everyone to separately maintain a mapping of owner IDs to
126
+ * public keys. If an owner's private key is compromised, then humans will need to communicate
127
+ * and agree on a replacement public key, then update the mapping.
128
+ *
129
+ * As a concrete example, an `Owner` could simply contain a domain name, and restoring a SturdyRef
130
+ * would require signing a request using the domain's private key. Authenticating this key could
131
+ * be accomplished through certificate authorities or web-of-trust techniques.
132
+ *
133
+ */
134
+ declare class Persistent extends Interface {
135
+ static readonly SaveParams: typeof Persistent_SaveParams;
136
+ static readonly SaveResults: typeof Persistent_SaveResults;
137
+ static readonly Client: typeof Persistent$Client;
138
+ static readonly Server: typeof Persistent$Server;
139
+ static readonly _capnp: {
140
+ displayName: string;
141
+ id: string;
142
+ size: ObjectSize;
143
+ };
144
+ toString(): string;
145
+ }
146
+
147
+ export { Persistent, Persistent$Client, Persistent$Server, type Persistent$Server$Target, Persistent_SaveParams, Persistent_SaveResults, Persistent_SaveResults$Promise, _capnpFileId };
@@ -0,0 +1,171 @@
1
+ import {
2
+ Interface,
3
+ ObjectSize,
4
+ Pipeline,
5
+ Registry,
6
+ Server,
7
+ Struct,
8
+ utils
9
+ } from "./chunk-BQI46ZE5.js";
10
+ import {
11
+ __name
12
+ } from "./chunk-SHUYVCID.js";
13
+
14
+ // schemas/persistent.ts
15
+ var _capnpFileId = BigInt("0xb8630836983feed7");
16
+ var Persistent_SaveParams = class extends Struct {
17
+ static {
18
+ __name(this, "Persistent_SaveParams");
19
+ }
20
+ static _capnp = {
21
+ displayName: "SaveParams",
22
+ id: "f76fba59183073a5",
23
+ size: new ObjectSize(0, 1)
24
+ };
25
+ _adoptSealFor(value) {
26
+ utils.adopt(value, utils.getPointer(0, this));
27
+ }
28
+ _disownSealFor() {
29
+ return utils.disown(this.sealFor);
30
+ }
31
+ /**
32
+ * Seal the SturdyRef so that it can only be restored by the specified Owner. This is meant
33
+ * to mitigate damage when a SturdyRef is leaked. See comments above.
34
+ *
35
+ * Leaving this value null may or may not be allowed; it is up to the realm to decide. If a
36
+ * realm does allow a null owner, this should indicate that anyone is allowed to restore the
37
+ * ref.
38
+ *
39
+ */
40
+ get sealFor() {
41
+ return utils.getPointer(0, this);
42
+ }
43
+ _hasSealFor() {
44
+ return !utils.isNull(utils.getPointer(0, this));
45
+ }
46
+ set sealFor(value) {
47
+ utils.copyFrom(value, utils.getPointer(0, this));
48
+ }
49
+ toString() {
50
+ return "Persistent_SaveParams_" + super.toString();
51
+ }
52
+ };
53
+ var Persistent_SaveResults = class extends Struct {
54
+ static {
55
+ __name(this, "Persistent_SaveResults");
56
+ }
57
+ static _capnp = {
58
+ displayName: "SaveResults",
59
+ id: "b76848c18c40efbf",
60
+ size: new ObjectSize(0, 1)
61
+ };
62
+ _adoptSturdyRef(value) {
63
+ utils.adopt(value, utils.getPointer(0, this));
64
+ }
65
+ _disownSturdyRef() {
66
+ return utils.disown(this.sturdyRef);
67
+ }
68
+ get sturdyRef() {
69
+ return utils.getPointer(0, this);
70
+ }
71
+ _hasSturdyRef() {
72
+ return !utils.isNull(utils.getPointer(0, this));
73
+ }
74
+ set sturdyRef(value) {
75
+ utils.copyFrom(value, utils.getPointer(0, this));
76
+ }
77
+ toString() {
78
+ return "Persistent_SaveResults_" + super.toString();
79
+ }
80
+ };
81
+ var Persistent_SaveResults$Promise = class {
82
+ static {
83
+ __name(this, "Persistent_SaveResults$Promise");
84
+ }
85
+ pipeline;
86
+ constructor(pipeline) {
87
+ this.pipeline = pipeline;
88
+ }
89
+ async promise() {
90
+ return await this.pipeline.struct();
91
+ }
92
+ };
93
+ var Persistent$Client = class _Persistent$Client {
94
+ static {
95
+ __name(this, "Persistent$Client");
96
+ }
97
+ client;
98
+ static interfaceId = BigInt("0xc8cb212fcd9f5691");
99
+ constructor(client) {
100
+ this.client = client;
101
+ }
102
+ static methods = [
103
+ {
104
+ ParamsClass: Persistent_SaveParams,
105
+ ResultsClass: Persistent_SaveResults,
106
+ interfaceId: _Persistent$Client.interfaceId,
107
+ methodId: 0,
108
+ interfaceName: "packages/capnp/schemas/persistent.capnp:Persistent",
109
+ methodName: "save"
110
+ }
111
+ ];
112
+ /**
113
+ * Save a capability persistently so that it can be restored by a future connection. Not all
114
+ * capabilities can be saved -- application interfaces should define which capabilities support
115
+ * this and which do not.
116
+ *
117
+ */
118
+ save(paramsFunc) {
119
+ const answer = this.client.call({
120
+ method: _Persistent$Client.methods[0],
121
+ paramsFunc
122
+ });
123
+ const pipeline = new Pipeline(Persistent_SaveResults, answer);
124
+ return new Persistent_SaveResults$Promise(pipeline);
125
+ }
126
+ };
127
+ Registry.register(Persistent$Client.interfaceId, Persistent$Client);
128
+ var Persistent$Server = class extends Server {
129
+ static {
130
+ __name(this, "Persistent$Server");
131
+ }
132
+ target;
133
+ constructor(target) {
134
+ super(target, [
135
+ {
136
+ ...Persistent$Client.methods[0],
137
+ impl: target.save
138
+ }
139
+ ]);
140
+ this.target = target;
141
+ }
142
+ client() {
143
+ return new Persistent$Client(this);
144
+ }
145
+ };
146
+ var Persistent = class extends Interface {
147
+ static {
148
+ __name(this, "Persistent");
149
+ }
150
+ static SaveParams = Persistent_SaveParams;
151
+ static SaveResults = Persistent_SaveResults;
152
+ static Client = Persistent$Client;
153
+ static Server = Persistent$Server;
154
+ static _capnp = {
155
+ displayName: "Persistent",
156
+ id: "c8cb212fcd9f5691",
157
+ size: new ObjectSize(0, 0)
158
+ };
159
+ toString() {
160
+ return "Persistent_" + super.toString();
161
+ }
162
+ };
163
+ export {
164
+ Persistent,
165
+ Persistent$Client,
166
+ Persistent$Server,
167
+ Persistent_SaveParams,
168
+ Persistent_SaveResults,
169
+ Persistent_SaveResults$Promise,
170
+ _capnpFileId
171
+ };