@reclaimprotocol/attestor-core 5.0.1-beta.9 → 5.0.2-beta.1
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/browser/resources/attestor-browser.min.mjs +4513 -0
- package/lib/client/tunnels/make-rpc-tls-tunnel.d.ts +1 -1
- package/lib/external-rpc/index.js +10397 -3
- package/lib/index.js +8325 -10
- package/lib/server/utils/generics.d.ts +1 -1
- package/lib/server/utils/proxy-session.d.ts +1 -1
- package/lib/types/general.d.ts +0 -1
- package/lib/types/providers.d.ts +3 -2
- package/lib/types/signatures.d.ts +1 -2
- package/lib/utils/generics.d.ts +1 -6
- package/lib/utils/index.d.ts +0 -1
- package/package.json +9 -11
- package/lib/avs/abis/avsDirectoryABI.js +0 -343
- package/lib/avs/abis/delegationABI.js +0 -4
- package/lib/avs/abis/registryABI.js +0 -728
- package/lib/avs/client/create-claim-on-avs.js +0 -168
- package/lib/avs/config.js +0 -26
- package/lib/avs/contracts/ReclaimServiceManager.js +0 -0
- package/lib/avs/contracts/common.js +0 -0
- package/lib/avs/contracts/factories/ReclaimServiceManager__factory.js +0 -1183
- package/lib/avs/contracts/factories/index.js +0 -4
- package/lib/avs/contracts/index.js +0 -6
- package/lib/avs/types/index.js +0 -0
- package/lib/avs/utils/contracts.js +0 -53
- package/lib/avs/utils/register.js +0 -74
- package/lib/avs/utils/tasks.js +0 -48
- package/lib/browser/avs/abis/avsDirectoryABI.d.ts +0 -60
- package/lib/browser/avs/abis/avsDirectoryABI.js +0 -343
- package/lib/browser/avs/abis/delegationABI.d.ts +0 -126
- package/lib/browser/avs/abis/delegationABI.js +0 -4
- package/lib/browser/avs/abis/registryABI.d.ts +0 -136
- package/lib/browser/avs/abis/registryABI.js +0 -728
- package/lib/browser/avs/client/create-claim-on-avs.d.ts +0 -12
- package/lib/browser/avs/client/create-claim-on-avs.js +0 -168
- package/lib/browser/avs/config.d.ts +0 -7
- package/lib/browser/avs/config.js +0 -26
- package/lib/browser/avs/contracts/ReclaimServiceManager.d.ts +0 -601
- package/lib/browser/avs/contracts/ReclaimServiceManager.js +0 -0
- package/lib/browser/avs/contracts/common.d.ts +0 -50
- package/lib/browser/avs/contracts/common.js +0 -0
- package/lib/browser/avs/contracts/factories/ReclaimServiceManager__factory.d.ts +0 -890
- package/lib/browser/avs/contracts/factories/ReclaimServiceManager__factory.js +0 -1183
- package/lib/browser/avs/contracts/factories/index.d.ts +0 -1
- package/lib/browser/avs/contracts/factories/index.js +0 -4
- package/lib/browser/avs/contracts/index.d.ts +0 -3
- package/lib/browser/avs/contracts/index.js +0 -6
- package/lib/browser/avs/types/index.d.ts +0 -55
- package/lib/browser/avs/types/index.js +0 -0
- package/lib/browser/avs/utils/contracts.d.ts +0 -21
- package/lib/browser/avs/utils/contracts.js +0 -53
- package/lib/browser/avs/utils/register.d.ts +0 -27
- package/lib/browser/avs/utils/register.js +0 -74
- package/lib/browser/avs/utils/tasks.d.ts +0 -22
- package/lib/browser/avs/utils/tasks.js +0 -48
- package/lib/browser/client/create-claim.d.ts +0 -5
- package/lib/browser/client/create-claim.js +0 -461
- package/lib/browser/client/index.d.ts +0 -3
- package/lib/browser/client/index.js +0 -3
- package/lib/browser/client/tunnels/make-rpc-tcp-tunnel.d.ts +0 -16
- package/lib/browser/client/tunnels/make-rpc-tcp-tunnel.js +0 -53
- package/lib/browser/client/tunnels/make-rpc-tls-tunnel.d.ts +0 -26
- package/lib/browser/client/tunnels/make-rpc-tls-tunnel.js +0 -127
- package/lib/browser/client/utils/attestor-pool.d.ts +0 -8
- package/lib/browser/client/utils/attestor-pool.js +0 -24
- package/lib/browser/client/utils/client-socket.d.ts +0 -11
- package/lib/browser/client/utils/client-socket.js +0 -120
- package/lib/browser/client/utils/message-handler.d.ts +0 -4
- package/lib/browser/client/utils/message-handler.js +0 -97
- package/lib/browser/config/index.d.ts +0 -31
- package/lib/browser/config/index.js +0 -62
- package/lib/browser/external-rpc/benchmark.d.ts +0 -1
- package/lib/browser/external-rpc/benchmark.js +0 -82
- package/lib/browser/external-rpc/event-bus.d.ts +0 -7
- package/lib/browser/external-rpc/event-bus.js +0 -17
- package/lib/browser/external-rpc/global.d.js +0 -0
- package/lib/browser/external-rpc/handle-incoming-msg.d.ts +0 -2
- package/lib/browser/external-rpc/handle-incoming-msg.js +0 -241
- package/lib/browser/external-rpc/index.d.ts +0 -3
- package/lib/browser/external-rpc/index.js +0 -3
- package/lib/browser/external-rpc/jsc-polyfills/1.d.ts +0 -14
- package/lib/browser/external-rpc/jsc-polyfills/1.js +0 -80
- package/lib/browser/external-rpc/jsc-polyfills/2.d.ts +0 -1
- package/lib/browser/external-rpc/jsc-polyfills/2.js +0 -15
- package/lib/browser/external-rpc/jsc-polyfills/event.d.ts +0 -10
- package/lib/browser/external-rpc/jsc-polyfills/event.js +0 -19
- package/lib/browser/external-rpc/jsc-polyfills/index.d.ts +0 -2
- package/lib/browser/external-rpc/jsc-polyfills/index.js +0 -2
- package/lib/browser/external-rpc/jsc-polyfills/ws.d.ts +0 -21
- package/lib/browser/external-rpc/jsc-polyfills/ws.js +0 -83
- package/lib/browser/external-rpc/setup-browser.d.ts +0 -6
- package/lib/browser/external-rpc/setup-browser.js +0 -33
- package/lib/browser/external-rpc/setup-jsc.d.ts +0 -24
- package/lib/browser/external-rpc/setup-jsc.js +0 -22
- package/lib/browser/external-rpc/types.d.ts +0 -213
- package/lib/browser/external-rpc/types.js +0 -0
- package/lib/browser/external-rpc/utils.d.ts +0 -20
- package/lib/browser/external-rpc/utils.js +0 -100
- package/lib/browser/external-rpc/zk.d.ts +0 -14
- package/lib/browser/external-rpc/zk.js +0 -58
- package/lib/browser/index.browser.js +0 -13
- package/lib/browser/index.d.ts +0 -9
- package/lib/browser/index.js +0 -13
- package/lib/browser/mechain/abis/governanceABI.d.ts +0 -50
- package/lib/browser/mechain/abis/governanceABI.js +0 -461
- package/lib/browser/mechain/abis/taskABI.d.ts +0 -157
- package/lib/browser/mechain/abis/taskABI.js +0 -512
- package/lib/browser/mechain/client/create-claim-on-mechain.d.ts +0 -10
- package/lib/browser/mechain/client/create-claim-on-mechain.js +0 -33
- package/lib/browser/mechain/client/index.d.ts +0 -1
- package/lib/browser/mechain/client/index.js +0 -1
- package/lib/browser/mechain/constants/index.d.ts +0 -3
- package/lib/browser/mechain/constants/index.js +0 -8
- package/lib/browser/mechain/index.d.ts +0 -2
- package/lib/browser/mechain/index.js +0 -2
- package/lib/browser/mechain/types/index.d.ts +0 -23
- package/lib/browser/mechain/types/index.js +0 -0
- package/lib/browser/proto/api.d.ts +0 -651
- package/lib/browser/proto/api.js +0 -4250
- package/lib/browser/proto/tee-bundle.d.ts +0 -156
- package/lib/browser/proto/tee-bundle.js +0 -1296
- package/lib/browser/providers/http/index.d.ts +0 -18
- package/lib/browser/providers/http/index.js +0 -640
- package/lib/browser/providers/http/patch-parse5-tree.d.ts +0 -6
- package/lib/browser/providers/http/patch-parse5-tree.js +0 -34
- package/lib/browser/providers/http/utils.d.ts +0 -77
- package/lib/browser/providers/http/utils.js +0 -283
- package/lib/browser/providers/index.d.ts +0 -4
- package/lib/browser/providers/index.js +0 -7
- package/lib/browser/types/bgp.d.ts +0 -11
- package/lib/browser/types/bgp.js +0 -0
- package/lib/browser/types/claims.d.ts +0 -70
- package/lib/browser/types/claims.js +0 -0
- package/lib/browser/types/client.d.ts +0 -163
- package/lib/browser/types/client.js +0 -0
- package/lib/browser/types/general.d.ts +0 -77
- package/lib/browser/types/general.js +0 -0
- package/lib/browser/types/handlers.d.ts +0 -10
- package/lib/browser/types/handlers.js +0 -0
- package/lib/browser/types/index.d.ts +0 -10
- package/lib/browser/types/index.js +0 -10
- package/lib/browser/types/providers.d.ts +0 -161
- package/lib/browser/types/providers.gen.d.ts +0 -443
- package/lib/browser/types/providers.gen.js +0 -16
- package/lib/browser/types/providers.js +0 -0
- package/lib/browser/types/rpc.d.ts +0 -35
- package/lib/browser/types/rpc.js +0 -0
- package/lib/browser/types/signatures.d.ts +0 -28
- package/lib/browser/types/signatures.js +0 -0
- package/lib/browser/types/tunnel.d.ts +0 -18
- package/lib/browser/types/tunnel.js +0 -0
- package/lib/browser/types/zk.d.ts +0 -38
- package/lib/browser/types/zk.js +0 -0
- package/lib/browser/utils/auth.d.ts +0 -8
- package/lib/browser/utils/auth.js +0 -71
- package/lib/browser/utils/b64-json.d.ts +0 -2
- package/lib/browser/utils/b64-json.js +0 -17
- package/lib/browser/utils/claims.d.ts +0 -33
- package/lib/browser/utils/claims.js +0 -89
- package/lib/browser/utils/env.d.ts +0 -3
- package/lib/browser/utils/env.js +0 -19
- package/lib/browser/utils/error.d.ts +0 -26
- package/lib/browser/utils/error.js +0 -54
- package/lib/browser/utils/generics.d.ts +0 -119
- package/lib/browser/utils/generics.js +0 -272
- package/lib/browser/utils/http-parser.d.ts +0 -59
- package/lib/browser/utils/http-parser.js +0 -201
- package/lib/browser/utils/index.browser.js +0 -13
- package/lib/browser/utils/index.d.ts +0 -13
- package/lib/browser/utils/index.js +0 -13
- package/lib/browser/utils/logger.browser.js +0 -88
- package/lib/browser/utils/logger.d.ts +0 -14
- package/lib/browser/utils/logger.js +0 -88
- package/lib/browser/utils/prepare-packets.d.ts +0 -16
- package/lib/browser/utils/prepare-packets.js +0 -69
- package/lib/browser/utils/redactions.d.ts +0 -73
- package/lib/browser/utils/redactions.js +0 -135
- package/lib/browser/utils/retries.d.ts +0 -12
- package/lib/browser/utils/retries.js +0 -26
- package/lib/browser/utils/signatures/eth.d.ts +0 -2
- package/lib/browser/utils/signatures/eth.js +0 -31
- package/lib/browser/utils/signatures/index.d.ts +0 -5
- package/lib/browser/utils/signatures/index.js +0 -12
- package/lib/browser/utils/socket-base.d.ts +0 -23
- package/lib/browser/utils/socket-base.js +0 -96
- package/lib/browser/utils/tls-imports.d.ts +0 -21
- package/lib/browser/utils/tls-imports.js +0 -71
- package/lib/browser/utils/tls.d.ts +0 -2
- package/lib/browser/utils/tls.js +0 -58
- package/lib/browser/utils/ws.d.ts +0 -7
- package/lib/browser/utils/ws.js +0 -22
- package/lib/browser/utils/zk.d.ts +0 -71
- package/lib/browser/utils/zk.js +0 -625
- package/lib/client/create-claim.js +0 -461
- package/lib/client/index.js +0 -3
- package/lib/client/tunnels/make-rpc-tcp-tunnel.js +0 -53
- package/lib/client/tunnels/make-rpc-tls-tunnel.js +0 -127
- package/lib/client/utils/attestor-pool.js +0 -24
- package/lib/client/utils/client-socket.js +0 -120
- package/lib/client/utils/message-handler.js +0 -97
- package/lib/config/index.js +0 -62
- package/lib/external-rpc/benchmark.js +0 -82
- package/lib/external-rpc/event-bus.js +0 -17
- package/lib/external-rpc/global.d.js +0 -0
- package/lib/external-rpc/handle-incoming-msg.js +0 -241
- package/lib/external-rpc/jsc-polyfills/1.js +0 -80
- package/lib/external-rpc/jsc-polyfills/2.js +0 -15
- package/lib/external-rpc/jsc-polyfills/event.js +0 -19
- package/lib/external-rpc/jsc-polyfills/index.js +0 -2
- package/lib/external-rpc/jsc-polyfills/ws.js +0 -83
- package/lib/external-rpc/setup-browser.js +0 -33
- package/lib/external-rpc/setup-jsc.js +0 -22
- package/lib/external-rpc/types.js +0 -0
- package/lib/external-rpc/utils.js +0 -100
- package/lib/external-rpc/zk.js +0 -58
- package/lib/index.browser.d.ts +0 -9
- package/lib/mechain/abis/governanceABI.js +0 -461
- package/lib/mechain/abis/taskABI.js +0 -512
- package/lib/mechain/client/create-claim-on-mechain.js +0 -33
- package/lib/mechain/client/index.js +0 -1
- package/lib/mechain/constants/index.js +0 -8
- package/lib/mechain/index.js +0 -2
- package/lib/mechain/types/index.js +0 -0
- package/lib/proto/api.js +0 -4250
- package/lib/proto/tee-bundle.js +0 -1296
- package/lib/providers/http/index.js +0 -640
- package/lib/providers/http/patch-parse5-tree.js +0 -34
- package/lib/providers/http/utils.js +0 -283
- package/lib/providers/index.js +0 -7
- package/lib/scripts/check-avs-registration.js +0 -28
- package/lib/scripts/fallbacks/crypto.js +0 -4
- package/lib/scripts/fallbacks/empty.js +0 -4
- package/lib/scripts/fallbacks/re2.js +0 -7
- package/lib/scripts/fallbacks/snarkjs.js +0 -10
- package/lib/scripts/fallbacks/stwo.js +0 -159
- package/lib/scripts/generate-provider-types.js +0 -101
- package/lib/scripts/generate-receipt.js +0 -101
- package/lib/scripts/generate-toprf-keys.js +0 -24
- package/lib/scripts/jsc-cli-rpc.js +0 -35
- package/lib/scripts/register-avs-operator.js +0 -3
- package/lib/scripts/start-server.js +0 -11
- package/lib/scripts/update-avs-metadata.js +0 -20
- package/lib/scripts/utils.js +0 -10
- package/lib/scripts/whitelist-operator.js +0 -16
- package/lib/server/create-server.js +0 -105
- package/lib/server/handlers/claimTeeBundle.js +0 -232
- package/lib/server/handlers/claimTunnel.js +0 -80
- package/lib/server/handlers/completeClaimOnChain.js +0 -29
- package/lib/server/handlers/createClaimOnChain.js +0 -32
- package/lib/server/handlers/createTaskOnMechain.js +0 -57
- package/lib/server/handlers/createTunnel.js +0 -98
- package/lib/server/handlers/disconnectTunnel.js +0 -8
- package/lib/server/handlers/fetchCertificateBytes.js +0 -57
- package/lib/server/handlers/index.js +0 -25
- package/lib/server/handlers/init.js +0 -33
- package/lib/server/handlers/toprf.js +0 -19
- package/lib/server/index.js +0 -4
- package/lib/server/socket.js +0 -112
- package/lib/server/tunnels/make-tcp-tunnel.js +0 -202
- package/lib/server/utils/apm.js +0 -29
- package/lib/server/utils/assert-valid-claim-request.js +0 -354
- package/lib/server/utils/config-env.js +0 -4
- package/lib/server/utils/dns.js +0 -24
- package/lib/server/utils/gcp-attestation.js +0 -237
- package/lib/server/utils/generics.js +0 -45
- package/lib/server/utils/iso.js +0 -259
- package/lib/server/utils/keep-alive.js +0 -38
- package/lib/server/utils/nitro-attestation.js +0 -249
- package/lib/server/utils/oprf-raw.js +0 -61
- package/lib/server/utils/process-handshake.js +0 -233
- package/lib/server/utils/proxy-session.js +0 -4
- package/lib/server/utils/tee-oprf-mpc-verification.js +0 -86
- package/lib/server/utils/tee-oprf-verification.js +0 -151
- package/lib/server/utils/tee-transcript-reconstruction.js +0 -140
- package/lib/server/utils/tee-verification.js +0 -358
- package/lib/server/utils/validation.js +0 -45
- package/lib/types/bgp.js +0 -0
- package/lib/types/claims.js +0 -0
- package/lib/types/client.js +0 -0
- package/lib/types/general.js +0 -0
- package/lib/types/handlers.js +0 -0
- package/lib/types/index.js +0 -10
- package/lib/types/providers.gen.js +0 -16
- package/lib/types/providers.js +0 -0
- package/lib/types/rpc.js +0 -0
- package/lib/types/signatures.js +0 -0
- package/lib/types/tunnel.js +0 -0
- package/lib/types/zk.js +0 -0
- package/lib/utils/auth.js +0 -71
- package/lib/utils/b64-json.js +0 -17
- package/lib/utils/bgp-listener.js +0 -123
- package/lib/utils/claims.js +0 -89
- package/lib/utils/env.js +0 -19
- package/lib/utils/error.js +0 -54
- package/lib/utils/generics.js +0 -272
- package/lib/utils/http-parser.js +0 -201
- package/lib/utils/index.browser.d.ts +0 -13
- package/lib/utils/index.js +0 -14
- package/lib/utils/logger.browser.d.ts +0 -14
- package/lib/utils/logger.js +0 -82
- package/lib/utils/prepare-packets.js +0 -69
- package/lib/utils/redactions.js +0 -135
- package/lib/utils/retries.js +0 -26
- package/lib/utils/signatures/eth.js +0 -31
- package/lib/utils/signatures/index.js +0 -12
- package/lib/utils/socket-base.js +0 -96
- package/lib/utils/tls-imports.d.ts +0 -21
- package/lib/utils/tls-imports.js +0 -71
- package/lib/utils/tls.js +0 -58
- package/lib/utils/ws.js +0 -22
- package/lib/utils/zk.js +0 -625
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { AttestorClient } from "../../client/utils/client-socket.js";
|
|
2
|
-
const POOL = {};
|
|
3
|
-
function getAttestorClientFromPool(url, getCreateOpts = () => ({})) {
|
|
4
|
-
const key = url.toString();
|
|
5
|
-
let client = POOL[key];
|
|
6
|
-
let createReason;
|
|
7
|
-
if (client?.isClosed) {
|
|
8
|
-
createReason = "closed";
|
|
9
|
-
} else if (!client) {
|
|
10
|
-
createReason = "non-existent";
|
|
11
|
-
}
|
|
12
|
-
if (createReason) {
|
|
13
|
-
const createOpts = getCreateOpts();
|
|
14
|
-
createOpts?.logger?.info(
|
|
15
|
-
{ key, createReason },
|
|
16
|
-
"creating new client"
|
|
17
|
-
);
|
|
18
|
-
client = POOL[key] = new AttestorClient({ ...createOpts, url });
|
|
19
|
-
}
|
|
20
|
-
return client;
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
getAttestorClientFromPool
|
|
24
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { InitResponse } from '#src/proto/api.ts';
|
|
2
|
-
import type { IAttestorClient, IAttestorClientCreateOpts, RPCRequestData, RPCResponseData, RPCType } from '#src/types/index.ts';
|
|
3
|
-
import { AttestorSocket } from '#src/utils/socket-base.ts';
|
|
4
|
-
export declare class AttestorClient extends AttestorSocket implements IAttestorClient {
|
|
5
|
-
private waitForInitPromise;
|
|
6
|
-
initResponse?: InitResponse;
|
|
7
|
-
constructor({ url, initMessages, signatureType, logger, authRequest, makeWebSocket }: IAttestorClientCreateOpts);
|
|
8
|
-
rpc<T extends RPCType>(type: T, request: Partial<RPCRequestData<T>>, timeoutMs?: number): Promise<Exclude<import("#src/proto/api.ts").RPCMessage[`${T}Response`], undefined>>;
|
|
9
|
-
waitForResponse<T extends RPCType>(id: number, timeoutMs?: number): Promise<RPCResponseData<T>>;
|
|
10
|
-
waitForInit: () => Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { encodeBase64 } from "ethers";
|
|
2
|
-
import { DEFAULT_METADATA, DEFAULT_RPC_TIMEOUT_MS } from "../../config/index.js";
|
|
3
|
-
import { RPCMessages } from "../../proto/api.js";
|
|
4
|
-
import { AttestorError, generateRpcMessageId, getRpcRequestType, logger as LOGGER, packRpcMessages } from "../../utils/index.js";
|
|
5
|
-
import { AttestorSocket } from "../../utils/socket-base.js";
|
|
6
|
-
import { makeWebSocket as defaultMakeWebSocket } from "../../utils/ws.js";
|
|
7
|
-
class AttestorClient extends AttestorSocket {
|
|
8
|
-
waitForInitPromise;
|
|
9
|
-
initResponse;
|
|
10
|
-
constructor({
|
|
11
|
-
url,
|
|
12
|
-
initMessages = [],
|
|
13
|
-
signatureType = DEFAULT_METADATA.signatureType,
|
|
14
|
-
logger = LOGGER,
|
|
15
|
-
authRequest,
|
|
16
|
-
makeWebSocket = defaultMakeWebSocket
|
|
17
|
-
}) {
|
|
18
|
-
const initRequest = {
|
|
19
|
-
...DEFAULT_METADATA,
|
|
20
|
-
signatureType,
|
|
21
|
-
auth: authRequest
|
|
22
|
-
};
|
|
23
|
-
const msg = packRpcMessages({ initRequest }, ...initMessages);
|
|
24
|
-
const initRequestBytes = RPCMessages.encode(msg).finish();
|
|
25
|
-
const initRequestB64 = encodeBase64(initRequestBytes);
|
|
26
|
-
url = new URL(url.toString());
|
|
27
|
-
url.searchParams.set("messages", initRequestB64);
|
|
28
|
-
super(
|
|
29
|
-
makeWebSocket(url),
|
|
30
|
-
initRequest,
|
|
31
|
-
logger
|
|
32
|
-
);
|
|
33
|
-
const initReqId = msg.messages[0].id;
|
|
34
|
-
this.waitForInitPromise = this.waitForResponse(initReqId, DEFAULT_RPC_TIMEOUT_MS).then((res) => {
|
|
35
|
-
logger.info("client initialised");
|
|
36
|
-
this.isInitialised = true;
|
|
37
|
-
this.initResponse = res;
|
|
38
|
-
});
|
|
39
|
-
this.waitForInitPromise.catch(() => {
|
|
40
|
-
});
|
|
41
|
-
this.addEventListener("connection-terminated", (ev) => logger.info({ err: ev.data }, "connection terminated"));
|
|
42
|
-
}
|
|
43
|
-
async rpc(type, request, timeoutMs = DEFAULT_RPC_TIMEOUT_MS) {
|
|
44
|
-
const msgId = generateRpcMessageId();
|
|
45
|
-
this.logger.debug({ type, id: msgId }, "sending rpc request");
|
|
46
|
-
const now = Date.now();
|
|
47
|
-
try {
|
|
48
|
-
const rslt = this.waitForResponse(msgId, timeoutMs);
|
|
49
|
-
await this.sendMessage({ id: msgId, [getRpcRequestType(type)]: request });
|
|
50
|
-
return await rslt;
|
|
51
|
-
} finally {
|
|
52
|
-
const timeTakenMs = Date.now() - now;
|
|
53
|
-
this.logger.debug({ type, timeTakenMs }, "received rpc response");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
waitForResponse(id, timeoutMs = DEFAULT_RPC_TIMEOUT_MS) {
|
|
57
|
-
if (this.isClosed) {
|
|
58
|
-
throw new AttestorError(
|
|
59
|
-
"ERROR_NETWORK_ERROR",
|
|
60
|
-
"Client connection already closed"
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
return new Promise((resolve, reject) => {
|
|
64
|
-
const handler = (event) => {
|
|
65
|
-
if (event.data.id !== id) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
removeHandlers();
|
|
69
|
-
if ("error" in event.data) {
|
|
70
|
-
reject(event.data.error);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
resolve(event.data.data);
|
|
74
|
-
};
|
|
75
|
-
const terminateHandler = (event) => {
|
|
76
|
-
removeHandlers();
|
|
77
|
-
if (event.data.code === "ERROR_NO_ERROR") {
|
|
78
|
-
reject(
|
|
79
|
-
new AttestorError(
|
|
80
|
-
"ERROR_NETWORK_ERROR",
|
|
81
|
-
event.data.message,
|
|
82
|
-
event.data.data
|
|
83
|
-
)
|
|
84
|
-
);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
reject(event.data);
|
|
88
|
-
};
|
|
89
|
-
const timeout = setTimeout(() => {
|
|
90
|
-
removeHandlers();
|
|
91
|
-
reject(
|
|
92
|
-
new AttestorError(
|
|
93
|
-
"ERROR_TIMEOUT",
|
|
94
|
-
`RPC request timed out after ${timeoutMs}ms`,
|
|
95
|
-
{ id }
|
|
96
|
-
)
|
|
97
|
-
);
|
|
98
|
-
}, timeoutMs);
|
|
99
|
-
const removeHandlers = () => {
|
|
100
|
-
clearTimeout(timeout);
|
|
101
|
-
this.removeEventListener("rpc-response", handler);
|
|
102
|
-
this.removeEventListener("connection-terminated", terminateHandler);
|
|
103
|
-
};
|
|
104
|
-
this.addEventListener("rpc-response", handler);
|
|
105
|
-
this.addEventListener("connection-terminated", terminateHandler);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
waitForInit = () => {
|
|
109
|
-
if (this.isClosed) {
|
|
110
|
-
throw new AttestorError(
|
|
111
|
-
"ERROR_NETWORK_ERROR",
|
|
112
|
-
"Client connection already closed"
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
return this.waitForInitPromise;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
export {
|
|
119
|
-
AttestorClient
|
|
120
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { RPCMessage } from '#src/proto/api.ts';
|
|
2
|
-
import type { IAttestorSocket } from '#src/types/index.ts';
|
|
3
|
-
export declare function wsMessageHandler(this: IAttestorSocket, data: unknown): Promise<void>;
|
|
4
|
-
export declare function handleMessage(this: IAttestorSocket, msg: RPCMessage): Promise<void> | undefined;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { RPCMessages } from "../../proto/api.js";
|
|
2
|
-
import { AttestorError, extractArrayBufferFromWsData, getRpcRequest, getRpcRequestType, getRpcResponseType } from "../../utils/index.js";
|
|
3
|
-
async function wsMessageHandler(data) {
|
|
4
|
-
const buff = await extractArrayBufferFromWsData(data);
|
|
5
|
-
const { messages } = RPCMessages.decode(buff);
|
|
6
|
-
for (const msg of messages) {
|
|
7
|
-
await handleMessage.call(this, msg);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function handleMessage(msg) {
|
|
11
|
-
this.logger?.trace({ msg }, "received message");
|
|
12
|
-
if (msg.connectionTerminationAlert) {
|
|
13
|
-
const err = AttestorError.fromProto(
|
|
14
|
-
msg.connectionTerminationAlert
|
|
15
|
-
);
|
|
16
|
-
this.logger?.warn(
|
|
17
|
-
{
|
|
18
|
-
err: err.code !== "ERROR_NO_ERROR" ? err : void 0
|
|
19
|
-
},
|
|
20
|
-
"received connection termination alert"
|
|
21
|
-
);
|
|
22
|
-
this.dispatchRPCEvent("connection-terminated", err);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const rpcRequest = getRpcRequest(msg);
|
|
26
|
-
if (rpcRequest) {
|
|
27
|
-
if (rpcRequest.direction === "response" && rpcRequest.type === "error") {
|
|
28
|
-
this.dispatchRPCEvent("rpc-response", {
|
|
29
|
-
id: msg.id,
|
|
30
|
-
error: AttestorError.fromProto(msg.requestError)
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const resType = getRpcResponseType(rpcRequest.type);
|
|
35
|
-
if (rpcRequest.direction === "response") {
|
|
36
|
-
this.dispatchRPCEvent("rpc-response", {
|
|
37
|
-
id: msg.id,
|
|
38
|
-
type: rpcRequest.type,
|
|
39
|
-
data: msg[resType]
|
|
40
|
-
});
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (!this.isInitialised && rpcRequest.type !== "init") {
|
|
44
|
-
this.logger.warn(
|
|
45
|
-
{ type: rpcRequest.type },
|
|
46
|
-
"RPC request received before initialisation"
|
|
47
|
-
);
|
|
48
|
-
void this.sendMessage({
|
|
49
|
-
id: msg.id,
|
|
50
|
-
requestError: AttestorError.badRequest("Initialise connection first").toProto()
|
|
51
|
-
});
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
this.dispatchRPCEvent("rpc-request", {
|
|
56
|
-
requestId: msg.id,
|
|
57
|
-
type: rpcRequest.type,
|
|
58
|
-
data: msg[getRpcRequestType(rpcRequest.type)],
|
|
59
|
-
respond: (res) => {
|
|
60
|
-
if (!this.isOpen) {
|
|
61
|
-
this.logger?.debug(
|
|
62
|
-
{ type: rpcRequest.type, res },
|
|
63
|
-
"connection closed before responding"
|
|
64
|
-
);
|
|
65
|
-
reject(new Error("connection closed"));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if ("code" in res) {
|
|
69
|
-
reject(res);
|
|
70
|
-
return this.sendMessage({
|
|
71
|
-
id: msg.id,
|
|
72
|
-
requestError: res.toProto()
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
resolve();
|
|
76
|
-
return this.sendMessage({ id: msg.id, [resType]: res });
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (msg.tunnelMessage) {
|
|
82
|
-
this.dispatchRPCEvent("tunnel-message", msg.tunnelMessage);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (msg.tunnelDisconnectEvent) {
|
|
86
|
-
this.dispatchRPCEvent(
|
|
87
|
-
"tunnel-disconnect-event",
|
|
88
|
-
msg.tunnelDisconnectEvent
|
|
89
|
-
);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
this.logger.warn({ msg }, "unhandled message");
|
|
93
|
-
}
|
|
94
|
-
export {
|
|
95
|
-
handleMessage,
|
|
96
|
-
wsMessageHandler
|
|
97
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { InitRequest } from '#src/proto/api.ts';
|
|
2
|
-
export declare const DEFAULT_ZK_CONCURRENCY = 10;
|
|
3
|
-
export declare const RECLAIM_USER_AGENT = "reclaim/0.0.1";
|
|
4
|
-
export declare const DEFAULT_HTTPS_PORT = 443;
|
|
5
|
-
export declare const WS_PATHNAME = "/ws";
|
|
6
|
-
export declare const BROWSER_RPC_PATHNAME = "/browser-rpc";
|
|
7
|
-
export declare const ATTESTOR_ADDRESS_PATHNAME = "/address";
|
|
8
|
-
export declare const DEFAULT_REMOTE_FILE_FETCH_BASE_URL = "/browser-rpc/resources";
|
|
9
|
-
export declare const API_SERVER_PORT = 8001;
|
|
10
|
-
export declare const CONNECTION_TIMEOUT_MS = 10000;
|
|
11
|
-
export declare const DNS_SERVERS: string[];
|
|
12
|
-
export declare const MAX_CLAIM_TIMESTAMP_DIFF_S: number;
|
|
13
|
-
export declare const CURRENT_ATTESTOR_VERSION: 5;
|
|
14
|
-
export declare const DEFAULT_METADATA: InitRequest;
|
|
15
|
-
export declare const PROVIDER_CTX: {
|
|
16
|
-
version: 5;
|
|
17
|
-
};
|
|
18
|
-
export declare const PING_INTERVAL_MS = 10000;
|
|
19
|
-
/**
|
|
20
|
-
* Maximum interval in seconds to wait for before assuming
|
|
21
|
-
* the connection is dead
|
|
22
|
-
* @default 30s
|
|
23
|
-
*/
|
|
24
|
-
export declare const MAX_NO_DATA_INTERVAL_MS = 30000;
|
|
25
|
-
export declare const MAX_PAYLOAD_SIZE: number;
|
|
26
|
-
export declare const DEFAULT_AUTH_EXPIRY_S: number;
|
|
27
|
-
export declare const DEFAULT_RPC_TIMEOUT_MS = 90000;
|
|
28
|
-
export declare const TOPRF_DOMAIN_SEPARATOR = "reclaim-toprf";
|
|
29
|
-
export declare const MAX_CERT_SIZE_BYTES: number;
|
|
30
|
-
export declare const CERT_ALLOWED_MIMETYPES: string[];
|
|
31
|
-
export declare const BGP_WS_URL = "wss://ris-live.ripe.net/v1/ws/?client=reclaim-hijack-detector";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { AttestorVersion, ServiceSignatureType } from "../proto/api.js";
|
|
2
|
-
const DEFAULT_ZK_CONCURRENCY = 10;
|
|
3
|
-
const RECLAIM_USER_AGENT = "reclaim/0.0.1";
|
|
4
|
-
const DEFAULT_HTTPS_PORT = 443;
|
|
5
|
-
const WS_PATHNAME = "/ws";
|
|
6
|
-
const BROWSER_RPC_PATHNAME = "/browser-rpc";
|
|
7
|
-
const ATTESTOR_ADDRESS_PATHNAME = "/address";
|
|
8
|
-
const DEFAULT_REMOTE_FILE_FETCH_BASE_URL = `${BROWSER_RPC_PATHNAME}/resources`;
|
|
9
|
-
const API_SERVER_PORT = 8001;
|
|
10
|
-
const CONNECTION_TIMEOUT_MS = 1e4;
|
|
11
|
-
const DNS_SERVERS = [
|
|
12
|
-
"8.8.8.8",
|
|
13
|
-
"8.8.4.4"
|
|
14
|
-
];
|
|
15
|
-
const MAX_CLAIM_TIMESTAMP_DIFF_S = 10 * 60;
|
|
16
|
-
const CURRENT_ATTESTOR_VERSION = AttestorVersion.ATTESTOR_VERSION_3_0_0;
|
|
17
|
-
const DEFAULT_METADATA = {
|
|
18
|
-
signatureType: ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH,
|
|
19
|
-
clientVersion: CURRENT_ATTESTOR_VERSION,
|
|
20
|
-
auth: void 0
|
|
21
|
-
};
|
|
22
|
-
const PROVIDER_CTX = { version: CURRENT_ATTESTOR_VERSION };
|
|
23
|
-
const PING_INTERVAL_MS = 1e4;
|
|
24
|
-
const MAX_NO_DATA_INTERVAL_MS = 3e4;
|
|
25
|
-
const MAX_PAYLOAD_SIZE = 512 * 1024 * 1024;
|
|
26
|
-
const DEFAULT_AUTH_EXPIRY_S = 15 * 60;
|
|
27
|
-
const DEFAULT_RPC_TIMEOUT_MS = 9e4;
|
|
28
|
-
const TOPRF_DOMAIN_SEPARATOR = "reclaim-toprf";
|
|
29
|
-
const MAX_CERT_SIZE_BYTES = 10 * 1024 * 1024 * 1024;
|
|
30
|
-
const CERT_ALLOWED_MIMETYPES = [
|
|
31
|
-
"application/x-x509-ca-cert",
|
|
32
|
-
"application/x-x509-user-cert",
|
|
33
|
-
"application/pkix-cert",
|
|
34
|
-
"application/pkcs7-mime",
|
|
35
|
-
"application/octet-stream"
|
|
36
|
-
];
|
|
37
|
-
const BGP_WS_URL = "wss://ris-live.ripe.net/v1/ws/?client=reclaim-hijack-detector";
|
|
38
|
-
export {
|
|
39
|
-
API_SERVER_PORT,
|
|
40
|
-
ATTESTOR_ADDRESS_PATHNAME,
|
|
41
|
-
BGP_WS_URL,
|
|
42
|
-
BROWSER_RPC_PATHNAME,
|
|
43
|
-
CERT_ALLOWED_MIMETYPES,
|
|
44
|
-
CONNECTION_TIMEOUT_MS,
|
|
45
|
-
CURRENT_ATTESTOR_VERSION,
|
|
46
|
-
DEFAULT_AUTH_EXPIRY_S,
|
|
47
|
-
DEFAULT_HTTPS_PORT,
|
|
48
|
-
DEFAULT_METADATA,
|
|
49
|
-
DEFAULT_REMOTE_FILE_FETCH_BASE_URL,
|
|
50
|
-
DEFAULT_RPC_TIMEOUT_MS,
|
|
51
|
-
DEFAULT_ZK_CONCURRENCY,
|
|
52
|
-
DNS_SERVERS,
|
|
53
|
-
MAX_CERT_SIZE_BYTES,
|
|
54
|
-
MAX_CLAIM_TIMESTAMP_DIFF_S,
|
|
55
|
-
MAX_NO_DATA_INTERVAL_MS,
|
|
56
|
-
MAX_PAYLOAD_SIZE,
|
|
57
|
-
PING_INTERVAL_MS,
|
|
58
|
-
PROVIDER_CTX,
|
|
59
|
-
RECLAIM_USER_AGENT,
|
|
60
|
-
TOPRF_DOMAIN_SEPARATOR,
|
|
61
|
-
WS_PATHNAME
|
|
62
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function benchmark(): Promise<string>;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
crypto,
|
|
3
|
-
encryptWrappedRecord,
|
|
4
|
-
SUPPORTED_CIPHER_SUITE_MAP
|
|
5
|
-
} from "../utils/tls-imports.js";
|
|
6
|
-
import { strToUint8Array } from "../utils/generics.js";
|
|
7
|
-
import { logger } from "../utils/logger.js";
|
|
8
|
-
import { makeZkProofGenerator } from "../utils/zk.js";
|
|
9
|
-
const ZK_CIPHER_SUITES = [
|
|
10
|
-
"TLS_CHACHA20_POLY1305_SHA256",
|
|
11
|
-
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
12
|
-
"TLS_AES_128_GCM_SHA256"
|
|
13
|
-
];
|
|
14
|
-
async function benchmark() {
|
|
15
|
-
let benchmarkRes = "";
|
|
16
|
-
for (const cipherSuite of ZK_CIPHER_SUITES) {
|
|
17
|
-
const now = Date.now();
|
|
18
|
-
const alg = cipherSuite.includes("CHACHA20") ? "CHACHA20-POLY1305" : cipherSuite.includes("AES_256_GCM") ? "AES-256-GCM" : "AES-128-GCM";
|
|
19
|
-
const keylength = alg === "AES-128-GCM" ? 16 : 32;
|
|
20
|
-
const key = Buffer.alloc(keylength, 0);
|
|
21
|
-
const {
|
|
22
|
-
ivLength: fixedIvLength
|
|
23
|
-
} = SUPPORTED_CIPHER_SUITE_MAP[cipherSuite];
|
|
24
|
-
const fixedIv = Buffer.alloc(fixedIvLength, 0);
|
|
25
|
-
const encKey = await crypto.importKey(alg, key);
|
|
26
|
-
const vectors = [
|
|
27
|
-
{
|
|
28
|
-
plaintext: `My cool API secret is "my name jeff". Please don't reveal it`
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
const proofGenerator = await makeZkProofGenerator({
|
|
32
|
-
logger,
|
|
33
|
-
cipherSuite
|
|
34
|
-
});
|
|
35
|
-
for (const { plaintext } of vectors) {
|
|
36
|
-
const plaintextArr = strToUint8Array(plaintext);
|
|
37
|
-
const { ciphertext, iv } = await encryptWrappedRecord(
|
|
38
|
-
plaintextArr,
|
|
39
|
-
{
|
|
40
|
-
key: encKey,
|
|
41
|
-
iv: fixedIv,
|
|
42
|
-
recordNumber: 0,
|
|
43
|
-
recordHeaderOpts: {
|
|
44
|
-
type: "WRAPPED_RECORD"
|
|
45
|
-
},
|
|
46
|
-
cipherSuite,
|
|
47
|
-
version: cipherSuite.includes("ECDHE_") ? "TLS1_2" : "TLS1_3"
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
const packet = {
|
|
51
|
-
type: "ciphertext",
|
|
52
|
-
encKey,
|
|
53
|
-
iv,
|
|
54
|
-
recordNumber: 0,
|
|
55
|
-
plaintext: plaintextArr,
|
|
56
|
-
ciphertext,
|
|
57
|
-
fixedIv: new Uint8Array(0),
|
|
58
|
-
data: ciphertext
|
|
59
|
-
};
|
|
60
|
-
await proofGenerator.addPacketToProve(
|
|
61
|
-
packet,
|
|
62
|
-
{
|
|
63
|
-
type: "zk",
|
|
64
|
-
redactedPlaintext: plaintextArr
|
|
65
|
-
},
|
|
66
|
-
() => {
|
|
67
|
-
},
|
|
68
|
-
() => {
|
|
69
|
-
throw new Error("should not be called in benchmark");
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
await proofGenerator.generateProofs();
|
|
73
|
-
}
|
|
74
|
-
benchmarkRes = benchmarkRes + `Benchmark ${alg} ok. Took ${Date.now() - now} ms
|
|
75
|
-
`;
|
|
76
|
-
}
|
|
77
|
-
logger.info(benchmarkRes);
|
|
78
|
-
return benchmarkRes;
|
|
79
|
-
}
|
|
80
|
-
export {
|
|
81
|
-
benchmark
|
|
82
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
class EventBus {
|
|
2
|
-
#listeners = [];
|
|
3
|
-
addListener(fn) {
|
|
4
|
-
this.#listeners.push(fn);
|
|
5
|
-
return () => {
|
|
6
|
-
this.#listeners = this.#listeners.filter((l) => l !== fn);
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
dispatch(data) {
|
|
10
|
-
for (const listener of this.#listeners) {
|
|
11
|
-
listener(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
EventBus
|
|
17
|
-
};
|
|
File without changes
|