@peerbit/rpc 4.0.7 → 5.0.0-55cebfe
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/{lib/esm → dist/src}/controller.d.ts +4 -3
- package/dist/src/controller.d.ts.map +1 -0
- package/{lib/esm → dist/src}/controller.js +17 -16
- package/dist/src/controller.js.map +1 -0
- package/{lib/esm → dist/src}/encoding.d.ts +1 -0
- package/dist/src/encoding.d.ts.map +1 -0
- package/{lib/esm → dist/src}/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/{lib/esm → dist/src}/io.d.ts +3 -2
- package/dist/src/io.d.ts.map +1 -0
- package/{lib/esm → dist/src}/utils.d.ts +5 -4
- package/dist/src/utils.d.ts.map +1 -0
- package/{lib/esm → dist/src}/utils.js +5 -2
- package/dist/src/utils.js.map +1 -0
- package/package.json +68 -42
- package/src/controller.ts +63 -63
- package/src/io.ts +4 -4
- package/src/utils.ts +14 -12
- package/LICENSE +0 -202
- package/lib/esm/controller.js.map +0 -1
- package/lib/esm/utils.js.map +0 -1
- /package/{lib/esm → dist/src}/encoding.js +0 -0
- /package/{lib/esm → dist/src}/encoding.js.map +0 -0
- /package/{lib/esm → dist/src}/index.js +0 -0
- /package/{lib/esm → dist/src}/index.js.map +0 -0
- /package/{lib/esm → dist/src}/io.js +0 -0
- /package/{lib/esm → dist/src}/io.js.map +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AbstractType } from "@dao-xyz/borsh";
|
|
1
|
+
import { type AbstractType } from "@dao-xyz/borsh";
|
|
2
2
|
import { PublicSignKey } from "@peerbit/crypto";
|
|
3
|
-
import { RPCResponse, EncryptionOptions, RPCRequestOptions } from "./io.js";
|
|
4
3
|
import { Program } from "@peerbit/program";
|
|
5
|
-
import { PriorityOptions, WithMode } from "@peerbit/stream-interface";
|
|
4
|
+
import { type PriorityOptions, type WithMode } from "@peerbit/stream-interface";
|
|
5
|
+
import { type EncryptionOptions, type RPCRequestOptions, type RPCResponse } from "./io.js";
|
|
6
6
|
export type RPCSetupOptions<Q, R> = {
|
|
7
7
|
topic: string;
|
|
8
8
|
queryType: AbstractType<Q>;
|
|
@@ -52,3 +52,4 @@ export declare class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
52
52
|
get topic(): string;
|
|
53
53
|
getTopics(): string[];
|
|
54
54
|
}
|
|
55
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAKjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAIN,aAAa,EAKb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3C,OAAO,EAEN,KAAK,eAAe,EAEpB,KAAK,QAAQ,EAEb,MAAM,2BAA2B,CAAC;AAInC,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEhB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC9B,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACxC,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CACnC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,cAAc,KACnB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,GA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K,IAAI,MAAM,CAKzB;IAED,SAAS,IAAI,MAAM,EAAE;CAGrB"}
|
|
@@ -4,14 +4,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { BorshError, deserialize, serialize, variant } from "@dao-xyz/borsh";
|
|
8
|
-
import { DecryptedThing,
|
|
9
|
-
import { RequestV0, ResponseV0, RPCMessage } from "./encoding.js";
|
|
10
|
-
import { logger } from "./io.js";
|
|
7
|
+
import { BorshError, deserialize, serialize, variant, } from "@dao-xyz/borsh";
|
|
8
|
+
import { AccessError, DecryptedThing, MaybeEncrypted, PublicSignKey, X25519Keypair, X25519PublicKey, randomBytes, toBase64, } from "@peerbit/crypto";
|
|
11
9
|
import { Program } from "@peerbit/program";
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
10
|
+
import { DataEvent, } from "@peerbit/pubsub-interface";
|
|
11
|
+
import { DataMessage, SilentDelivery, deliveryModeHasReceiver, } from "@peerbit/stream-interface";
|
|
14
12
|
import { AbortError, TimeoutError } from "@peerbit/time";
|
|
13
|
+
import pDefer, {} from "p-defer";
|
|
14
|
+
import { RPCMessage, RequestV0, ResponseV0 } from "./encoding.js";
|
|
15
|
+
import { logger, } from "./io.js";
|
|
15
16
|
const createValueResolver = (type) => {
|
|
16
17
|
if (type === Uint8Array) {
|
|
17
18
|
return (decrypted) => decrypted._data;
|
|
@@ -91,7 +92,7 @@ let RPC = class RPC extends Program {
|
|
|
91
92
|
const decrypted = await maybeEncrypted.decrypt(this.node.services.keychain);
|
|
92
93
|
const response = await this._responseHandler(this._getRequestValueFn(decrypted), {
|
|
93
94
|
from: message.header.signatures.publicKeys[0],
|
|
94
|
-
timestamp: message.header.timestamp
|
|
95
|
+
timestamp: message.header.timestamp,
|
|
95
96
|
});
|
|
96
97
|
if (response && rpcMessage.respondTo) {
|
|
97
98
|
// send query and wait for replies in a generator like behaviour
|
|
@@ -101,21 +102,21 @@ let RPC = class RPC extends Program {
|
|
|
101
102
|
// that is now known in the .pubsub network, hence the message might not be delivired if we
|
|
102
103
|
// send with { to: [RECIEVER] } param
|
|
103
104
|
const decryptedMessage = new DecryptedThing({
|
|
104
|
-
data: serializedResponse
|
|
105
|
+
data: serializedResponse,
|
|
105
106
|
});
|
|
106
107
|
let maybeEncryptedMessage = decryptedMessage;
|
|
107
108
|
maybeEncryptedMessage = await decryptedMessage.encrypt(this._keypair, [rpcMessage.respondTo]);
|
|
108
109
|
await this.node.services.pubsub.publish(serialize(new ResponseV0({
|
|
109
110
|
response: maybeEncryptedMessage,
|
|
110
|
-
requestId: message.id
|
|
111
|
+
requestId: message.id,
|
|
111
112
|
})), {
|
|
112
113
|
topics: [this.topic],
|
|
113
114
|
priority: message.header.priority, // send back with same priority. TODO, make this better in the future
|
|
114
115
|
/// TODO make redundancy parameter configurable?
|
|
115
116
|
mode: new SilentDelivery({
|
|
116
117
|
to: [message.header.signatures.publicKeys[0]],
|
|
117
|
-
redundancy: 1
|
|
118
|
-
})
|
|
118
|
+
redundancy: 1,
|
|
119
|
+
}),
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
}
|
|
@@ -126,7 +127,7 @@ let RPC = class RPC extends Program {
|
|
|
126
127
|
// TODO evaluate when and how handler can be missing
|
|
127
128
|
handler?.({
|
|
128
129
|
message,
|
|
129
|
-
response: rpcMessage
|
|
130
|
+
response: rpcMessage,
|
|
130
131
|
});
|
|
131
132
|
}
|
|
132
133
|
}
|
|
@@ -149,7 +150,7 @@ let RPC = class RPC extends Program {
|
|
|
149
150
|
? request
|
|
150
151
|
: serialize(request);
|
|
151
152
|
const decryptedMessage = new DecryptedThing({
|
|
152
|
-
data: requestData
|
|
153
|
+
data: requestData,
|
|
153
154
|
});
|
|
154
155
|
let maybeEncryptedMessage = decryptedMessage;
|
|
155
156
|
if (options?.encryption?.responders &&
|
|
@@ -158,7 +159,7 @@ let RPC = class RPC extends Program {
|
|
|
158
159
|
}
|
|
159
160
|
const requestMessage = new RequestV0({
|
|
160
161
|
request: maybeEncryptedMessage,
|
|
161
|
-
respondTo
|
|
162
|
+
respondTo,
|
|
162
163
|
});
|
|
163
164
|
return requestMessage;
|
|
164
165
|
}
|
|
@@ -167,7 +168,7 @@ let RPC = class RPC extends Program {
|
|
|
167
168
|
id,
|
|
168
169
|
priority: options?.priority,
|
|
169
170
|
mode: options?.mode,
|
|
170
|
-
topics: [this.topic]
|
|
171
|
+
topics: [this.topic],
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
174
|
/**
|
|
@@ -216,7 +217,7 @@ let RPC = class RPC extends Program {
|
|
|
216
217
|
logger.debug("Namespace error");
|
|
217
218
|
return; // Name space conflict most likely
|
|
218
219
|
}
|
|
219
|
-
|
|
220
|
+
logger.error("failed ot deserialize query response: " + error?.message);
|
|
220
221
|
promise.reject(error);
|
|
221
222
|
}
|
|
222
223
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/controller.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEN,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,GACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,QAAQ,GACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACN,SAAS,GAET,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,WAAW,EAEX,cAAc,EAEd,uBAAuB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC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AC;KACtB;CAKD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PriorityOptions, WithMode } from "@peerbit/stream-interface";
|
|
1
|
+
import type { Ed25519PublicKey, PublicSignKey, X25519Keypair, X25519PublicKey } from "@peerbit/crypto";
|
|
2
|
+
import type { PriorityOptions, WithMode } from "@peerbit/stream-interface";
|
|
3
3
|
export declare const logger: import("pino").Logger<never>;
|
|
4
4
|
export type RPCRequestResponseOptions<R> = {
|
|
5
5
|
amount?: number;
|
|
@@ -19,3 +19,4 @@ export type RPCResponse<R> = {
|
|
|
19
19
|
response: R;
|
|
20
20
|
from?: PublicSignKey;
|
|
21
21
|
};
|
|
22
|
+
//# sourceMappingURL=io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,eAAe,EACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE3E,eAAO,MAAM,MAAM,8BAA8B,CAAC;AAClD,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACzD,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,yBAAyB,CAAC,CAAC,CAAC,GAC9D,iBAAiB,GACjB,QAAQ,GACR,eAAe,CAAC;AAEjB,MAAM,MAAM,iBAAiB,GAAG;IAC/B,UAAU,CAAC,EAAE;QACZ,GAAG,EAAE,aAAa,CAAC;QACnB,UAAU,CAAC,EAAE,CAAC,eAAe,GAAG,gBAAgB,CAAC,EAAE,CAAC;KACpD,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,aAAa,CAAA;CAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { type Constructor } from "@dao-xyz/borsh";
|
|
2
|
+
import { type DeliveryMode, type PriorityOptions } from "@peerbit/stream-interface";
|
|
3
|
+
import { type RPC } from "./controller.js";
|
|
4
|
+
import type { EncryptionOptions, RPCRequestResponseOptions, RPCResponse } from "./io.js";
|
|
5
5
|
export declare class MissingResponsesError extends Error {
|
|
6
6
|
constructor(message: string);
|
|
7
7
|
}
|
|
@@ -9,3 +9,4 @@ export type RPCRequestAllOptions<R> = RPCRequestResponseOptions<R> & EncryptionO
|
|
|
9
9
|
mode?: Constructor<DeliveryMode>;
|
|
10
10
|
} & PriorityOptions;
|
|
11
11
|
export declare const queryAll: <Q, R>(rpc: RPC<Q, R>, groups: string[][], request: Q, responseHandler: (response: RPCResponse<R>[]) => Promise<void> | void, options?: RPCRequestAllOptions<R> | undefined) => Promise<void>;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EAEpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EACX,iBAAiB,EACjB,yBAAyB,EACzB,WAAW,EACX,MAAM,SAAS,CAAC;AAEjB,qBAAa,qBAAsB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAG3B;AACD,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,yBAAyB,CAAC,CAAC,CAAC,GACjE,iBAAiB,GAAG;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;CAAE,GAAG,eAAe,CAAC;AAE5E,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,CAAC,OACvB,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,UACN,MAAM,EAAE,EAAE,WACT,CAAC,mBACO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,YAC3D,oBAAoB,CAAC,CAAC,CAAC,GAAG,SAAS,kBA8D7C,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from "@dao-xyz/borsh";
|
|
2
|
+
import { SilentDelivery, } from "@peerbit/stream-interface";
|
|
3
|
+
import {} from "./controller.js";
|
|
2
4
|
export class MissingResponsesError extends Error {
|
|
3
5
|
constructor(message) {
|
|
4
6
|
super(message);
|
|
@@ -25,7 +27,8 @@ export const queryAll = (rpc, groups, request, responseHandler, options) => {
|
|
|
25
27
|
if (peersToQuery.length > 0) {
|
|
26
28
|
const results = await rpc.request(request, {
|
|
27
29
|
...options,
|
|
28
|
-
|
|
30
|
+
// eslint-disable-next-line new-cap
|
|
31
|
+
mode: new sendModeType({ to: peersToQuery, redundancy: 1 }), // TODO configuration redundancy?
|
|
29
32
|
});
|
|
30
33
|
for (const result of results) {
|
|
31
34
|
if (!result.from) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAGN,cAAc,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAY,MAAM,iBAAiB,CAAC;AAO3C,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;IAChB,CAAC;CACD;AAID,MAAM,CAAC,MAAM,QAAQ,GAAG,CACvB,GAAc,EACd,MAAkB,EAClB,OAAU,EACV,eAAqE,EACrE,OAA6C,EAC5C,EAAE;IACH,0CAA0C;IAC1C,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,CAC1B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CACnE,CAAC;IAEF,MAAM,YAAY,GAAG,OAAO,EAAE,IAAI,IAAI,cAAc,CAAC;IACrD,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,GAAG,CAAC;IACrB,MAAM,EAAE,GAAG,KAAK,IAAI,EAAE;QACrB,IAAI,eAAe,GAAG,KAAK,CAAC;QAC5B,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,YAAY,GAAa,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACxD,I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PC calls for peers",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "./dist/src/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
"*": {
|
|
10
|
+
"*": [
|
|
11
|
+
"*",
|
|
12
|
+
"dist/*",
|
|
13
|
+
"dist/src/*",
|
|
14
|
+
"dist/src/*/index"
|
|
15
|
+
],
|
|
16
|
+
"src/*": [
|
|
17
|
+
"*",
|
|
18
|
+
"dist/*",
|
|
19
|
+
"dist/src/*",
|
|
20
|
+
"dist/src/*/index"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"dist",
|
|
27
|
+
"!dist/e2e",
|
|
28
|
+
"!dist/test",
|
|
29
|
+
"!**/*.tsbuildinfo"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/src/index.d.ts",
|
|
34
|
+
"import": "./dist/src/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"eslintConfig": {
|
|
38
|
+
"extends": "peerbit",
|
|
39
|
+
"parserOptions": {
|
|
40
|
+
"project": true,
|
|
41
|
+
"sourceType": "module"
|
|
42
|
+
},
|
|
43
|
+
"ignorePatterns": [
|
|
44
|
+
"!.aegir.js",
|
|
45
|
+
"test/ts-use",
|
|
46
|
+
"*.d.ts"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"clean": "aegir clean",
|
|
54
|
+
"build": "aegir build --no-bundle",
|
|
55
|
+
"test": "aegir test --target=node",
|
|
56
|
+
"lint": "aegir lint"
|
|
57
|
+
},
|
|
58
|
+
"author": "dao.xyz",
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@dao-xyz/borsh": "^5.2.3",
|
|
62
|
+
"@peerbit/crypto": "2.3.0-55cebfe",
|
|
63
|
+
"@peerbit/logger": "1.0.3-55cebfe",
|
|
64
|
+
"@peerbit/program": "5.0.0-55cebfe",
|
|
65
|
+
"@peerbit/time": "2.0.7-55cebfe"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@peerbit/test-utils": "2.0.34-55cebfe"
|
|
69
|
+
}
|
|
44
70
|
}
|
package/src/controller.ts
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AbstractType,
|
|
2
|
+
type AbstractType,
|
|
3
3
|
BorshError,
|
|
4
4
|
deserialize,
|
|
5
5
|
serialize,
|
|
6
|
-
variant
|
|
6
|
+
variant,
|
|
7
7
|
} from "@dao-xyz/borsh";
|
|
8
8
|
import {
|
|
9
|
+
AccessError,
|
|
9
10
|
DecryptedThing,
|
|
10
11
|
MaybeEncrypted,
|
|
11
12
|
PublicSignKey,
|
|
12
|
-
toBase64,
|
|
13
|
-
AccessError,
|
|
14
|
-
X25519PublicKey,
|
|
15
13
|
X25519Keypair,
|
|
16
|
-
|
|
14
|
+
X25519PublicKey,
|
|
15
|
+
randomBytes,
|
|
16
|
+
toBase64,
|
|
17
17
|
} from "@peerbit/crypto";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
logger,
|
|
21
|
-
RPCResponse,
|
|
22
|
-
EncryptionOptions,
|
|
23
|
-
RPCRequestOptions
|
|
24
|
-
} from "./io.js";
|
|
18
|
+
import { Program } from "@peerbit/program";
|
|
25
19
|
import {
|
|
26
20
|
DataEvent,
|
|
27
|
-
PublishOptions as PubSubPublishOptions
|
|
21
|
+
type PublishOptions as PubSubPublishOptions,
|
|
28
22
|
} from "@peerbit/pubsub-interface";
|
|
29
|
-
import { Program } from "@peerbit/program";
|
|
30
23
|
import {
|
|
31
24
|
DataMessage,
|
|
32
|
-
|
|
33
|
-
PriorityOptions,
|
|
25
|
+
type PriorityOptions,
|
|
34
26
|
SilentDelivery,
|
|
35
|
-
WithMode,
|
|
36
|
-
deliveryModeHasReceiver
|
|
27
|
+
type WithMode,
|
|
28
|
+
deliveryModeHasReceiver,
|
|
37
29
|
} from "@peerbit/stream-interface";
|
|
38
|
-
import
|
|
39
|
-
import {
|
|
30
|
+
import { AbortError, TimeoutError } from "@peerbit/time";
|
|
31
|
+
import pDefer, { type DeferredPromise } from "p-defer";
|
|
32
|
+
import { RPCMessage, RequestV0, ResponseV0 } from "./encoding.js";
|
|
33
|
+
import {
|
|
34
|
+
type EncryptionOptions,
|
|
35
|
+
type RPCRequestOptions,
|
|
36
|
+
type RPCResponse,
|
|
37
|
+
logger,
|
|
38
|
+
} from "./io.js";
|
|
40
39
|
|
|
41
40
|
export type RPCSetupOptions<Q, R> = {
|
|
42
41
|
topic: string;
|
|
@@ -50,11 +49,11 @@ export type RequestContext = {
|
|
|
50
49
|
};
|
|
51
50
|
export type ResponseHandler<Q, R> = (
|
|
52
51
|
query: Q,
|
|
53
|
-
context: RequestContext
|
|
52
|
+
context: RequestContext,
|
|
54
53
|
) => Promise<R | undefined> | R | undefined;
|
|
55
54
|
|
|
56
55
|
const createValueResolver = <T>(
|
|
57
|
-
type: AbstractType<T> | Uint8Array
|
|
56
|
+
type: AbstractType<T> | Uint8Array,
|
|
58
57
|
): ((decryptedThings: DecryptedThing<T>) => T) => {
|
|
59
58
|
if ((type as any) === Uint8Array) {
|
|
60
59
|
return (decrypted) => decrypted._data as T;
|
|
@@ -67,20 +66,19 @@ const createValueResolver = <T>(
|
|
|
67
66
|
export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
68
67
|
private _subscribed = false;
|
|
69
68
|
private _responseHandler?: ResponseHandler<Q, (R | undefined) | R>;
|
|
70
|
-
private _responseResolver
|
|
69
|
+
private _responseResolver!: Map<
|
|
71
70
|
string,
|
|
72
71
|
(properties: { response: ResponseV0; message: DataMessage }) => any
|
|
73
72
|
>;
|
|
74
|
-
private _requestType
|
|
75
|
-
private _requestTypeIsUint8Array
|
|
76
|
-
private _responseType
|
|
77
|
-
private _rpcTopic
|
|
73
|
+
private _requestType!: AbstractType<Q> | Uint8ArrayConstructor;
|
|
74
|
+
private _requestTypeIsUint8Array!: boolean;
|
|
75
|
+
private _responseType!: AbstractType<R>;
|
|
76
|
+
private _rpcTopic!: string;
|
|
78
77
|
private _onMessageBinded: ((arg: any) => any) | undefined = undefined;
|
|
78
|
+
private _keypair!: X25519Keypair;
|
|
79
|
+
private _getResponseValueFn!: (decrypted: DecryptedThing<R>) => R;
|
|
80
|
+
private _getRequestValueFn!: (decrypted: DecryptedThing<Q>) => Q;
|
|
79
81
|
|
|
80
|
-
private _keypair: X25519Keypair;
|
|
81
|
-
|
|
82
|
-
private _getResponseValueFn: (decrypted: DecryptedThing<R>) => R;
|
|
83
|
-
private _getRequestValueFn: (decrypted: DecryptedThing<Q>) => Q;
|
|
84
82
|
async open(args: RPCSetupOptions<Q, R>): Promise<void> {
|
|
85
83
|
this._rpcTopic = args.topic ?? this._rpcTopic;
|
|
86
84
|
this._responseHandler = args.responseHandler;
|
|
@@ -100,7 +98,7 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
100
98
|
await this.node.services.pubsub.unsubscribe(this.topic);
|
|
101
99
|
await this.node.services.pubsub.removeEventListener(
|
|
102
100
|
"data",
|
|
103
|
-
this._onMessageBinded
|
|
101
|
+
this._onMessageBinded,
|
|
104
102
|
);
|
|
105
103
|
this._subscribed = false;
|
|
106
104
|
}
|
|
@@ -123,7 +121,7 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
123
121
|
return true;
|
|
124
122
|
}
|
|
125
123
|
|
|
126
|
-
private _subscribing: Promise<void> | void;
|
|
124
|
+
private _subscribing: Promise<void> | void | undefined;
|
|
127
125
|
async subscribe(): Promise<void> {
|
|
128
126
|
await this._subscribing;
|
|
129
127
|
if (this._subscribed) {
|
|
@@ -152,14 +150,14 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
152
150
|
if (this._responseHandler) {
|
|
153
151
|
const maybeEncrypted = rpcMessage.request;
|
|
154
152
|
const decrypted = await maybeEncrypted.decrypt(
|
|
155
|
-
this.node.services.keychain
|
|
153
|
+
this.node.services.keychain,
|
|
156
154
|
);
|
|
157
155
|
const response = await this._responseHandler(
|
|
158
156
|
this._getRequestValueFn(decrypted),
|
|
159
157
|
{
|
|
160
158
|
from: message.header.signatures!.publicKeys[0],
|
|
161
|
-
timestamp: message.header.timestamp
|
|
162
|
-
}
|
|
159
|
+
timestamp: message.header.timestamp,
|
|
160
|
+
},
|
|
163
161
|
);
|
|
164
162
|
if (response && rpcMessage.respondTo) {
|
|
165
163
|
// send query and wait for replies in a generator like behaviour
|
|
@@ -171,22 +169,22 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
171
169
|
// send with { to: [RECIEVER] } param
|
|
172
170
|
|
|
173
171
|
const decryptedMessage = new DecryptedThing<Uint8Array>({
|
|
174
|
-
data: serializedResponse
|
|
172
|
+
data: serializedResponse,
|
|
175
173
|
});
|
|
176
174
|
let maybeEncryptedMessage: MaybeEncrypted<Uint8Array> =
|
|
177
175
|
decryptedMessage;
|
|
178
176
|
|
|
179
177
|
maybeEncryptedMessage = await decryptedMessage.encrypt(
|
|
180
178
|
this._keypair,
|
|
181
|
-
[rpcMessage.respondTo]
|
|
179
|
+
[rpcMessage.respondTo],
|
|
182
180
|
);
|
|
183
181
|
|
|
184
182
|
await this.node.services.pubsub.publish(
|
|
185
183
|
serialize(
|
|
186
184
|
new ResponseV0({
|
|
187
185
|
response: maybeEncryptedMessage,
|
|
188
|
-
requestId: message.id
|
|
189
|
-
})
|
|
186
|
+
requestId: message.id,
|
|
187
|
+
}),
|
|
190
188
|
),
|
|
191
189
|
{
|
|
192
190
|
topics: [this.topic],
|
|
@@ -195,9 +193,9 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
195
193
|
/// TODO make redundancy parameter configurable?
|
|
196
194
|
mode: new SilentDelivery({
|
|
197
195
|
to: [message.header.signatures!.publicKeys[0]],
|
|
198
|
-
redundancy: 1
|
|
199
|
-
})
|
|
200
|
-
}
|
|
196
|
+
redundancy: 1,
|
|
197
|
+
}),
|
|
198
|
+
},
|
|
201
199
|
);
|
|
202
200
|
}
|
|
203
201
|
}
|
|
@@ -207,7 +205,7 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
207
205
|
// TODO evaluate when and how handler can be missing
|
|
208
206
|
handler?.({
|
|
209
207
|
message,
|
|
210
|
-
response: rpcMessage
|
|
208
|
+
response: rpcMessage,
|
|
211
209
|
});
|
|
212
210
|
}
|
|
213
211
|
} catch (error: any) {
|
|
@@ -223,7 +221,7 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
223
221
|
|
|
224
222
|
logger.error(
|
|
225
223
|
"Error handling query: " +
|
|
226
|
-
(error?.message ? error?.message?.toString() : error)
|
|
224
|
+
(error?.message ? error?.message?.toString() : error),
|
|
227
225
|
);
|
|
228
226
|
}
|
|
229
227
|
}
|
|
@@ -232,14 +230,14 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
232
230
|
private async seal(
|
|
233
231
|
request: Q,
|
|
234
232
|
respondTo?: X25519PublicKey,
|
|
235
|
-
options?: EncryptionOptions
|
|
233
|
+
options?: EncryptionOptions,
|
|
236
234
|
) {
|
|
237
235
|
const requestData = this._requestTypeIsUint8Array
|
|
238
236
|
? (request as Uint8Array)
|
|
239
237
|
: serialize(request);
|
|
240
238
|
|
|
241
239
|
const decryptedMessage = new DecryptedThing<Uint8Array>({
|
|
242
|
-
data: requestData
|
|
240
|
+
data: requestData,
|
|
243
241
|
});
|
|
244
242
|
|
|
245
243
|
let maybeEncryptedMessage: MaybeEncrypted<Uint8Array> = decryptedMessage;
|
|
@@ -250,13 +248,13 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
250
248
|
) {
|
|
251
249
|
maybeEncryptedMessage = await decryptedMessage.encrypt(
|
|
252
250
|
options.encryption.key,
|
|
253
|
-
options.encryption.responders
|
|
251
|
+
options.encryption.responders,
|
|
254
252
|
);
|
|
255
253
|
}
|
|
256
254
|
|
|
257
255
|
const requestMessage = new RequestV0({
|
|
258
256
|
request: maybeEncryptedMessage,
|
|
259
|
-
respondTo
|
|
257
|
+
respondTo,
|
|
260
258
|
});
|
|
261
259
|
|
|
262
260
|
return requestMessage;
|
|
@@ -264,13 +262,13 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
264
262
|
|
|
265
263
|
private getPublishOptions(
|
|
266
264
|
id?: Uint8Array,
|
|
267
|
-
options?: EncryptionOptions & WithMode & PriorityOptions
|
|
265
|
+
options?: EncryptionOptions & WithMode & PriorityOptions,
|
|
268
266
|
): PubSubPublishOptions {
|
|
269
267
|
return {
|
|
270
268
|
id,
|
|
271
269
|
priority: options?.priority,
|
|
272
270
|
mode: options?.mode,
|
|
273
|
-
topics: [this.topic]
|
|
271
|
+
topics: [this.topic],
|
|
274
272
|
};
|
|
275
273
|
}
|
|
276
274
|
|
|
@@ -281,11 +279,11 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
281
279
|
*/
|
|
282
280
|
public async send(
|
|
283
281
|
message: Q,
|
|
284
|
-
options?: EncryptionOptions & WithMode & PriorityOptions
|
|
282
|
+
options?: EncryptionOptions & WithMode & PriorityOptions,
|
|
285
283
|
): Promise<void> {
|
|
286
284
|
await this.node.services.pubsub.publish(
|
|
287
285
|
serialize(await this.seal(message, undefined, options)),
|
|
288
|
-
this.getPublishOptions(undefined, options)
|
|
286
|
+
this.getPublishOptions(undefined, options),
|
|
289
287
|
);
|
|
290
288
|
}
|
|
291
289
|
|
|
@@ -295,7 +293,7 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
295
293
|
allResults: RPCResponse<R>[],
|
|
296
294
|
responders: Set<string>,
|
|
297
295
|
expectedResponders?: Set<string>,
|
|
298
|
-
options?: RPCRequestOptions<R
|
|
296
|
+
options?: RPCRequestOptions<R>,
|
|
299
297
|
) {
|
|
300
298
|
return async (properties: {
|
|
301
299
|
response: ResponseV0;
|
|
@@ -332,7 +330,7 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
332
330
|
promise.resolve();
|
|
333
331
|
}
|
|
334
332
|
}
|
|
335
|
-
} catch (error) {
|
|
333
|
+
} catch (error: any) {
|
|
336
334
|
if (error instanceof AccessError) {
|
|
337
335
|
return; // Ignore things we can not open
|
|
338
336
|
}
|
|
@@ -342,7 +340,7 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
342
340
|
return; // Name space conflict most likely
|
|
343
341
|
}
|
|
344
342
|
|
|
345
|
-
|
|
343
|
+
logger.error("failed ot deserialize query response: " + error?.message);
|
|
346
344
|
promise.reject(error);
|
|
347
345
|
}
|
|
348
346
|
};
|
|
@@ -356,7 +354,7 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
356
354
|
*/
|
|
357
355
|
public async request(
|
|
358
356
|
request: Q,
|
|
359
|
-
options?: RPCRequestOptions<R
|
|
357
|
+
options?: RPCRequestOptions<R>,
|
|
360
358
|
): Promise<RPCResponse<R>[]> {
|
|
361
359
|
// We are generatinga new encryption keypair for each send, so we now that when we get the responses, they are encrypted specifcally for me, and for this request
|
|
362
360
|
// this allows us to easily disregard a bunch of message just beacuse they are for a different receiver!
|
|
@@ -376,11 +374,13 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
376
374
|
() => {
|
|
377
375
|
deferredPromise.resolve();
|
|
378
376
|
},
|
|
379
|
-
options?.timeout || 10 * 1000
|
|
377
|
+
options?.timeout || 10 * 1000,
|
|
380
378
|
);
|
|
381
379
|
|
|
382
380
|
const abortListener = (err: Event) => {
|
|
383
|
-
deferredPromise.reject(
|
|
381
|
+
deferredPromise.reject(
|
|
382
|
+
(err.target as any)?.["reason"] || new AbortError(),
|
|
383
|
+
);
|
|
384
384
|
};
|
|
385
385
|
options?.signal?.addEventListener("abort", abortListener);
|
|
386
386
|
|
|
@@ -411,14 +411,14 @@ export class RPC<Q, R> extends Program<RPCSetupOptions<Q, R>> {
|
|
|
411
411
|
allResults,
|
|
412
412
|
responders,
|
|
413
413
|
expectedResponders,
|
|
414
|
-
options
|
|
415
|
-
)
|
|
414
|
+
options,
|
|
415
|
+
),
|
|
416
416
|
);
|
|
417
417
|
|
|
418
418
|
try {
|
|
419
419
|
await this.node.services.pubsub.publish(
|
|
420
420
|
requestBytes,
|
|
421
|
-
this.getPublishOptions(messageId, options)
|
|
421
|
+
this.getPublishOptions(messageId, options),
|
|
422
422
|
);
|
|
423
423
|
await deferredPromise.promise;
|
|
424
424
|
} catch (error: any) {
|
package/src/io.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
X25519PublicKey,
|
|
1
|
+
import type {
|
|
3
2
|
Ed25519PublicKey,
|
|
4
3
|
PublicSignKey,
|
|
5
|
-
X25519Keypair
|
|
4
|
+
X25519Keypair,
|
|
5
|
+
X25519PublicKey,
|
|
6
6
|
} from "@peerbit/crypto";
|
|
7
7
|
import { logger as loggerFn } from "@peerbit/logger";
|
|
8
|
-
import { PriorityOptions, WithMode } from "@peerbit/stream-interface";
|
|
8
|
+
import type { PriorityOptions, WithMode } from "@peerbit/stream-interface";
|
|
9
9
|
|
|
10
10
|
export const logger = loggerFn({ module: "rpc" });
|
|
11
11
|
export type RPCRequestResponseOptions<R> = {
|
package/src/utils.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { type Constructor } from "@dao-xyz/borsh";
|
|
1
2
|
import {
|
|
2
|
-
DeliveryMode,
|
|
3
|
-
PriorityOptions,
|
|
4
|
-
SilentDelivery
|
|
3
|
+
type DeliveryMode,
|
|
4
|
+
type PriorityOptions,
|
|
5
|
+
SilentDelivery,
|
|
5
6
|
} from "@peerbit/stream-interface";
|
|
6
|
-
import { RPC } from "./controller";
|
|
7
|
-
import {
|
|
7
|
+
import { type RPC } from "./controller.js";
|
|
8
|
+
import type {
|
|
8
9
|
EncryptionOptions,
|
|
9
10
|
RPCRequestResponseOptions,
|
|
10
|
-
RPCResponse
|
|
11
|
-
} from "./io";
|
|
12
|
-
|
|
11
|
+
RPCResponse,
|
|
12
|
+
} from "./io.js";
|
|
13
|
+
|
|
13
14
|
export class MissingResponsesError extends Error {
|
|
14
15
|
constructor(message: string) {
|
|
15
16
|
super(message);
|
|
@@ -23,11 +24,11 @@ export const queryAll = <Q, R>(
|
|
|
23
24
|
groups: string[][],
|
|
24
25
|
request: Q,
|
|
25
26
|
responseHandler: (response: RPCResponse<R>[]) => Promise<void> | void,
|
|
26
|
-
options?: RPCRequestAllOptions<R> | undefined
|
|
27
|
+
options?: RPCRequestAllOptions<R> | undefined,
|
|
27
28
|
) => {
|
|
28
29
|
// In each shard/group only query a subset
|
|
29
30
|
groups = [...groups].filter(
|
|
30
|
-
(x) => !x.find((y) => y === rpc.node.identity.publicKey.hashcode())
|
|
31
|
+
(x) => !x.find((y) => y === rpc.node.identity.publicKey.hashcode()),
|
|
31
32
|
);
|
|
32
33
|
|
|
33
34
|
const sendModeType = options?.mode || SilentDelivery;
|
|
@@ -48,7 +49,8 @@ export const queryAll = <Q, R>(
|
|
|
48
49
|
if (peersToQuery.length > 0) {
|
|
49
50
|
const results = await rpc.request(request, {
|
|
50
51
|
...options,
|
|
51
|
-
|
|
52
|
+
// eslint-disable-next-line new-cap
|
|
53
|
+
mode: new sendModeType({ to: peersToQuery, redundancy: 1 }), // TODO configuration redundancy?
|
|
52
54
|
});
|
|
53
55
|
|
|
54
56
|
for (const result of results) {
|
|
@@ -79,7 +81,7 @@ export const queryAll = <Q, R>(
|
|
|
79
81
|
}
|
|
80
82
|
if (missingReponses) {
|
|
81
83
|
throw new MissingResponsesError(
|
|
82
|
-
"Did not receive responses from all shards"
|
|
84
|
+
"Did not receive responses from all shards",
|
|
83
85
|
);
|
|
84
86
|
}
|
|
85
87
|
};
|
package/LICENSE
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright 2022 dao.xyz
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/controller.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEN,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,cAAc,EAGd,QAAQ,EACR,WAAW,EAEX,aAAa,EACb,WAAW,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EACN,MAAM,EAIN,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAIN,cAAc,EAEd,uBAAuB,EACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,MAA2B,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAW,MAAM,eAAe,CAAC;AAiBlE,MAAM,mBAAmB,GAAG,CAC3B,IAAkC,EACY,EAAE;IAChD,IAAK,IAAY,KAAK,UAAU,EAAE,CAAC;QAClC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,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AAC,CAAC;gBAE5D,GAAG,IAAI,CAAC,CAAC;gBACT,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE;oBAChC,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;wBACzB,MAAM,SAAS,GAAG,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;wBACjC,IAAI,GAAG,KAAK,QAAQ,IAAI,SAAS,KAAK,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;4BAC3D,8BAA8B;4BAC9B,eAAe,GAAG,IAAI,CAAC;4BACvB,OAAO,KAAK,CAAC;wBACd,CAAC;wBACD,OAAO,IAAI,CAAC;oBACb,CAAC;oBACD,OAAO,KAAK,CAAC;gBACd,CAAC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QACD,IAAI,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,qBAAqB,CAC9B,2CAA2C,CAC3C,CAAC;QACH,CAAC;IACF,CAAC,CAAC;IACF,OAAO,EAAE,EAAE,CAAC;AACb,CAAC,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|