@reclaimprotocol/attestor-core 4.0.3 → 5.0.1-beta.2
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/LICENSE +660 -660
- package/README.md +1 -2
- package/lib/avs/abis/avsDirectoryABI.js +341 -342
- package/lib/avs/abis/delegationABI.js +4 -5
- package/lib/avs/abis/registryABI.js +722 -723
- package/lib/avs/client/create-claim-on-avs.d.ts +5 -5
- package/lib/avs/client/create-claim-on-avs.js +160 -139
- package/lib/avs/config.d.ts +1 -1
- package/lib/avs/config.js +25 -23
- package/lib/avs/contracts/ReclaimServiceManager.d.ts +436 -532
- package/lib/avs/contracts/ReclaimServiceManager.js +0 -3
- package/lib/avs/contracts/common.d.ts +40 -11
- package/lib/avs/contracts/common.js +0 -3
- package/lib/avs/contracts/factories/ReclaimServiceManager__factory.d.ts +13 -11
- package/lib/avs/contracts/factories/ReclaimServiceManager__factory.js +1157 -1148
- package/lib/avs/contracts/factories/index.d.ts +1 -1
- package/lib/avs/contracts/factories/index.js +4 -9
- package/lib/avs/contracts/index.d.ts +3 -3
- package/lib/avs/contracts/index.js +6 -40
- package/lib/avs/types/index.d.ts +6 -6
- package/lib/avs/types/index.js +0 -3
- package/lib/avs/utils/contracts.d.ts +14 -14
- package/lib/avs/utils/contracts.js +50 -35
- package/lib/avs/utils/register.d.ts +3 -3
- package/lib/avs/utils/register.js +71 -79
- package/lib/avs/utils/tasks.d.ts +4 -4
- package/lib/avs/utils/tasks.js +44 -41
- package/lib/client/create-claim.d.ts +2 -2
- package/lib/client/create-claim.js +437 -400
- package/lib/client/index.d.ts +3 -3
- package/lib/client/index.js +3 -20
- package/lib/client/tunnels/make-rpc-tcp-tunnel.d.ts +2 -2
- package/lib/client/tunnels/make-rpc-tcp-tunnel.js +49 -56
- package/lib/client/tunnels/make-rpc-tls-tunnel.d.ts +4 -3
- package/lib/client/tunnels/make-rpc-tls-tunnel.js +123 -131
- package/lib/client/utils/attestor-pool.d.ts +3 -1
- package/lib/client/utils/attestor-pool.js +21 -25
- package/lib/client/utils/client-socket.d.ts +4 -4
- package/lib/client/utils/client-socket.js +114 -94
- package/lib/client/utils/message-handler.d.ts +2 -2
- package/lib/client/utils/message-handler.js +89 -86
- package/lib/config/index.d.ts +6 -3
- package/lib/config/index.js +60 -37
- package/lib/external-rpc/benchmark.d.ts +1 -0
- package/lib/external-rpc/benchmark.js +82 -0
- package/lib/external-rpc/event-bus.d.ts +7 -0
- package/lib/external-rpc/event-bus.js +17 -0
- package/lib/external-rpc/global.d.js +0 -0
- package/lib/external-rpc/handle-incoming-msg.d.ts +2 -0
- package/lib/external-rpc/handle-incoming-msg.js +241 -0
- package/lib/external-rpc/index.d.ts +3 -0
- package/lib/external-rpc/index.js +3 -0
- package/lib/external-rpc/jsc-polyfills/1.d.ts +14 -0
- package/lib/external-rpc/jsc-polyfills/1.js +80 -0
- package/lib/external-rpc/jsc-polyfills/2.js +15 -0
- package/lib/external-rpc/jsc-polyfills/event.d.ts +10 -0
- package/lib/external-rpc/jsc-polyfills/event.js +19 -0
- package/lib/external-rpc/jsc-polyfills/index.d.ts +2 -0
- package/lib/external-rpc/jsc-polyfills/index.js +2 -0
- package/lib/external-rpc/jsc-polyfills/ws.d.ts +21 -0
- package/lib/external-rpc/jsc-polyfills/ws.js +83 -0
- package/lib/external-rpc/setup-browser.d.ts +6 -0
- package/lib/external-rpc/setup-browser.js +33 -0
- package/lib/external-rpc/setup-jsc.d.ts +24 -0
- package/lib/external-rpc/setup-jsc.js +22 -0
- package/lib/{window-rpc → external-rpc}/types.d.ts +56 -35
- package/lib/external-rpc/types.js +0 -0
- package/lib/external-rpc/utils.d.ts +20 -0
- package/lib/external-rpc/utils.js +100 -0
- package/lib/external-rpc/zk.d.ts +14 -0
- package/lib/external-rpc/zk.js +58 -0
- package/lib/index.d.ts +8 -9
- package/lib/index.js +12 -49
- package/lib/mechain/abis/governanceABI.js +460 -461
- package/lib/mechain/abis/taskABI.js +505 -506
- package/lib/mechain/client/create-claim-on-mechain.d.ts +3 -3
- package/lib/mechain/client/create-claim-on-mechain.js +31 -30
- package/lib/mechain/client/index.d.ts +1 -1
- package/lib/mechain/client/index.js +1 -18
- package/lib/mechain/constants/index.js +8 -7
- package/lib/mechain/index.d.ts +2 -2
- package/lib/mechain/index.js +2 -19
- package/lib/mechain/types/index.d.ts +2 -2
- package/lib/mechain/types/index.js +0 -3
- package/lib/proto/api.d.ts +182 -39
- package/lib/proto/api.js +4105 -3555
- package/lib/proto/tee-bundle.d.ts +156 -0
- package/lib/proto/tee-bundle.js +1296 -0
- package/lib/providers/http/index.d.ts +16 -1
- package/lib/providers/http/index.js +603 -576
- package/lib/providers/http/patch-parse5-tree.d.ts +6 -0
- package/lib/providers/http/patch-parse5-tree.js +34 -0
- package/lib/providers/http/utils.d.ts +7 -4
- package/lib/providers/http/utils.js +240 -317
- package/lib/providers/index.d.ts +1 -1
- package/lib/providers/index.js +5 -9
- package/lib/scripts/check-avs-registration.d.ts +1 -1
- package/lib/scripts/check-avs-registration.js +24 -25
- package/lib/scripts/fallbacks/crypto.d.ts +1 -0
- package/lib/scripts/fallbacks/crypto.js +4 -0
- package/lib/scripts/fallbacks/empty.d.ts +3 -0
- package/lib/scripts/fallbacks/empty.js +4 -0
- package/lib/scripts/fallbacks/re2.d.ts +1 -0
- package/lib/scripts/fallbacks/re2.js +7 -0
- package/lib/scripts/fallbacks/snarkjs.d.ts +1 -0
- package/lib/scripts/fallbacks/snarkjs.js +10 -0
- package/lib/scripts/fallbacks/stwo.d.ts +6 -0
- package/lib/scripts/fallbacks/stwo.js +159 -0
- package/lib/scripts/generate-provider-types.js +92 -73
- package/lib/scripts/generate-receipt.d.ts +2 -2
- package/lib/scripts/generate-receipt.js +94 -83
- package/lib/scripts/generate-toprf-keys.js +17 -16
- package/lib/scripts/jsc-cli-rpc.d.ts +1 -0
- package/lib/scripts/jsc-cli-rpc.js +35 -0
- package/lib/scripts/register-avs-operator.d.ts +1 -1
- package/lib/scripts/register-avs-operator.js +3 -7
- package/lib/scripts/start-server.d.ts +1 -1
- package/lib/scripts/start-server.js +9 -11
- package/lib/scripts/update-avs-metadata.d.ts +1 -1
- package/lib/scripts/update-avs-metadata.js +17 -19
- package/lib/scripts/utils.js +8 -9
- package/lib/scripts/whitelist-operator.d.ts +1 -1
- package/lib/scripts/whitelist-operator.js +13 -15
- package/lib/server/create-server.d.ts +3 -2
- package/lib/server/create-server.js +98 -85
- package/lib/server/handlers/claimTeeBundle.d.ts +6 -0
- package/lib/server/handlers/claimTeeBundle.js +232 -0
- package/lib/server/handlers/claimTunnel.d.ts +1 -1
- package/lib/server/handlers/claimTunnel.js +75 -73
- package/lib/server/handlers/completeClaimOnChain.d.ts +1 -1
- package/lib/server/handlers/completeClaimOnChain.js +27 -26
- package/lib/server/handlers/createClaimOnChain.d.ts +1 -1
- package/lib/server/handlers/createClaimOnChain.js +30 -29
- package/lib/server/handlers/createTaskOnMechain.d.ts +1 -1
- package/lib/server/handlers/createTaskOnMechain.js +54 -49
- package/lib/server/handlers/createTunnel.d.ts +1 -1
- package/lib/server/handlers/createTunnel.js +91 -94
- package/lib/server/handlers/disconnectTunnel.d.ts +1 -1
- package/lib/server/handlers/disconnectTunnel.js +6 -8
- package/lib/server/handlers/fetchCertificateBytes.d.ts +2 -0
- package/lib/server/handlers/fetchCertificateBytes.js +57 -0
- package/lib/server/handlers/index.d.ts +1 -1
- package/lib/server/handlers/index.js +24 -21
- package/lib/server/handlers/init.d.ts +1 -1
- package/lib/server/handlers/init.js +31 -34
- package/lib/server/handlers/toprf.d.ts +1 -1
- package/lib/server/handlers/toprf.js +17 -19
- package/lib/server/index.d.ts +4 -4
- package/lib/server/index.js +4 -21
- package/lib/server/socket.d.ts +7 -7
- package/lib/server/socket.js +104 -106
- package/lib/server/tunnels/make-tcp-tunnel.d.ts +5 -3
- package/lib/server/tunnels/make-tcp-tunnel.js +189 -162
- package/lib/server/utils/apm.d.ts +1 -1
- package/lib/server/utils/apm.js +26 -40
- package/lib/server/utils/assert-valid-claim-request.d.ts +6 -5
- package/lib/server/utils/assert-valid-claim-request.js +339 -185
- package/lib/server/utils/config-env.js +4 -7
- package/lib/server/utils/dns.js +18 -16
- package/lib/server/utils/gcp-attestation.d.ts +17 -0
- package/lib/server/utils/gcp-attestation.js +237 -0
- package/lib/server/utils/generics.d.ts +3 -3
- package/lib/server/utils/generics.js +37 -51
- package/lib/server/utils/iso.js +255 -256
- package/lib/server/utils/keep-alive.d.ts +2 -2
- package/lib/server/utils/keep-alive.js +36 -40
- package/lib/server/utils/nitro-attestation.d.ts +33 -0
- package/lib/server/utils/nitro-attestation.js +249 -0
- package/lib/server/utils/oprf-raw.d.ts +21 -0
- package/lib/server/utils/oprf-raw.js +61 -0
- package/lib/server/utils/process-handshake.d.ts +3 -3
- package/lib/server/utils/process-handshake.js +217 -175
- package/lib/server/utils/proxy-session.d.ts +1 -0
- package/lib/server/utils/proxy-session.js +6 -0
- package/lib/server/utils/tee-oprf-mpc-verification.d.ts +16 -0
- package/lib/server/utils/tee-oprf-mpc-verification.js +86 -0
- package/lib/server/utils/tee-oprf-verification.d.ts +24 -0
- package/lib/server/utils/tee-oprf-verification.js +151 -0
- package/lib/server/utils/tee-transcript-reconstruction.d.ts +24 -0
- package/lib/server/utils/tee-transcript-reconstruction.js +140 -0
- package/lib/server/utils/tee-verification.d.ts +28 -0
- package/lib/server/utils/tee-verification.js +358 -0
- package/lib/{utils → server/utils}/validation.d.ts +1 -1
- package/lib/server/utils/validation.js +45 -0
- package/lib/types/bgp.js +0 -3
- package/lib/types/claims.d.ts +7 -10
- package/lib/types/claims.js +0 -3
- package/lib/types/client.d.ts +5 -5
- package/lib/types/client.js +0 -3
- package/lib/types/general.d.ts +29 -4
- package/lib/types/general.js +0 -3
- package/lib/types/handlers.d.ts +3 -3
- package/lib/types/handlers.js +0 -3
- package/lib/types/index.d.ts +10 -10
- package/lib/types/index.js +10 -27
- package/lib/types/providers.d.ts +15 -4
- package/lib/types/providers.gen.d.ts +15 -1
- package/lib/types/providers.gen.js +15 -13
- package/lib/types/providers.js +0 -3
- package/lib/types/rpc.d.ts +2 -2
- package/lib/types/rpc.js +0 -3
- package/lib/types/signatures.js +0 -3
- package/lib/types/tunnel.d.ts +2 -2
- package/lib/types/tunnel.js +0 -3
- package/lib/types/zk.d.ts +17 -2
- package/lib/types/zk.js +0 -3
- package/lib/utils/auth.d.ts +2 -1
- package/lib/utils/auth.js +66 -59
- package/lib/utils/b64-json.js +13 -19
- package/lib/utils/bgp-listener.d.ts +1 -1
- package/lib/utils/bgp-listener.js +111 -114
- package/lib/utils/claims.d.ts +3 -3
- package/lib/utils/claims.js +78 -101
- package/lib/utils/env.js +15 -16
- package/lib/utils/error.d.ts +6 -7
- package/lib/utils/error.js +50 -39
- package/lib/utils/generics.d.ts +15 -13
- package/lib/utils/generics.js +217 -297
- package/lib/utils/http-parser.d.ts +1 -1
- package/lib/utils/http-parser.js +186 -237
- package/lib/utils/index.d.ts +13 -12
- package/lib/utils/index.js +13 -29
- package/lib/utils/logger.d.ts +1 -1
- package/lib/utils/logger.js +69 -87
- package/lib/utils/prepare-packets.d.ts +3 -3
- package/lib/utils/prepare-packets.js +66 -58
- package/lib/utils/redactions.d.ts +20 -1
- package/lib/utils/redactions.js +116 -129
- package/lib/utils/retries.d.ts +1 -1
- package/lib/utils/retries.js +24 -26
- package/lib/utils/signatures/eth.d.ts +1 -1
- package/lib/utils/signatures/eth.js +28 -30
- package/lib/utils/signatures/index.d.ts +3 -3
- package/lib/utils/signatures/index.js +11 -10
- package/lib/utils/socket-base.d.ts +6 -5
- package/lib/utils/socket-base.js +89 -88
- package/lib/utils/tls.d.ts +1 -1
- package/lib/utils/tls.js +54 -28
- package/lib/utils/ws.d.ts +1 -6
- package/lib/utils/ws.js +17 -33
- package/lib/utils/zk.d.ts +28 -12
- package/lib/utils/zk.js +587 -406
- package/package.json +72 -60
- package/lib/avs/tests/test.operator.d.ts +0 -11
- package/lib/avs/tests/test.operator.js +0 -313
- package/lib/avs/tests/utils.d.ts +0 -2
- package/lib/avs/tests/utils.js +0 -50
- package/lib/scripts/verify-root-ca.d.ts +0 -1
- package/lib/scripts/verify-root-ca.js +0 -51
- package/lib/tests/describe-with-server.d.ts +0 -20
- package/lib/tests/describe-with-server.js +0 -64
- package/lib/tests/mock-provider-server.d.ts +0 -13
- package/lib/tests/mock-provider-server.js +0 -65
- package/lib/tests/mocks.d.ts +0 -4
- package/lib/tests/mocks.js +0 -23
- package/lib/tests/test.auth.js +0 -75
- package/lib/tests/test.bgp-listener.js +0 -169
- package/lib/tests/test.claim-creation.js +0 -280
- package/lib/tests/test.http-parser.d.ts +0 -1
- package/lib/tests/test.http-parser.js +0 -120
- package/lib/tests/test.http-provider-utils.js +0 -2416
- package/lib/tests/test.http-provider.d.ts +0 -1
- package/lib/tests/test.http-provider.js +0 -114
- package/lib/tests/test.rpc-communication.d.ts +0 -1
- package/lib/tests/test.rpc-communication.js +0 -64
- package/lib/tests/test.rpc-tunnel.d.ts +0 -1
- package/lib/tests/test.rpc-tunnel.js +0 -172
- package/lib/tests/test.signatures.d.ts +0 -1
- package/lib/tests/test.signatures.js +0 -24
- package/lib/tests/test.tcp-tunnel.d.ts +0 -1
- package/lib/tests/test.tcp-tunnel.js +0 -64
- package/lib/tests/test.zk.d.ts +0 -1
- package/lib/tests/test.zk.js +0 -337
- package/lib/tests/utils.d.ts +0 -18
- package/lib/tests/utils.js +0 -64
- package/lib/utils/atomic-operations.d.ts +0 -24
- package/lib/utils/atomic-operations.js +0 -65
- package/lib/utils/benchmark.d.ts +0 -1
- package/lib/utils/benchmark.js +0 -70
- package/lib/utils/connection-state-machine.d.ts +0 -43
- package/lib/utils/connection-state-machine.js +0 -129
- package/lib/utils/resource-monitor.d.ts +0 -61
- package/lib/utils/resource-monitor.js +0 -107
- package/lib/utils/validation.js +0 -46
- package/lib/window-rpc/index.d.ts +0 -3
- package/lib/window-rpc/index.js +0 -20
- package/lib/window-rpc/setup-window-rpc.d.ts +0 -5
- package/lib/window-rpc/setup-window-rpc.js +0 -291
- package/lib/window-rpc/types.js +0 -3
- package/lib/window-rpc/utils.d.ts +0 -14
- package/lib/window-rpc/utils.js +0 -102
- package/lib/window-rpc/window-rpc-zk.d.ts +0 -15
- package/lib/window-rpc/window-rpc-zk.js +0 -85
- /package/lib/{tests/test.auth.d.ts → external-rpc/jsc-polyfills/2.d.ts} +0 -0
- /package/lib/{tests/test.bgp-listener.d.ts → scripts/build-browser.d.ts} +0 -0
- /package/lib/{tests/test.claim-creation.d.ts → scripts/build-jsc.d.ts} +0 -0
- /package/lib/{tests/test.http-provider-utils.d.ts → scripts/build-lib.d.ts} +0 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { ServiceSignatureType } from "../../proto/api.js";
|
|
2
|
+
import { BodyType, KOutputPayload, TOutputPayload, VerificationBundle } from "../../proto/tee-bundle.js";
|
|
3
|
+
import { validateGcpAttestationAndExtractKey } from "../../server/utils/gcp-attestation.js";
|
|
4
|
+
import { validateNitroAttestationAndExtractKey } from "../../server/utils/nitro-attestation.js";
|
|
5
|
+
import { AttestorError } from "../../utils/error.js";
|
|
6
|
+
import { SIGNATURES } from "../../utils/signatures/index.js";
|
|
7
|
+
async function verifyTeeBundle(bundleBytes, logger) {
|
|
8
|
+
const bundle = parseVerificationBundle(bundleBytes);
|
|
9
|
+
validateBundleCompleteness(bundle);
|
|
10
|
+
const { teekKeyResult, teetKeyResult } = await extractPublicKeys(bundle, logger);
|
|
11
|
+
await verifyTeeSignatures(bundle, teekKeyResult, teetKeyResult, logger);
|
|
12
|
+
if (!bundle.teekSigned || !bundle.teetSigned) {
|
|
13
|
+
throw new AttestorError("ERROR_INVALID_CLAIM", "Missing TEE signed messages");
|
|
14
|
+
}
|
|
15
|
+
const kOutputPayload = parseKOutputPayload(bundle.teekSigned);
|
|
16
|
+
const tOutputPayload = parseTOutputPayload(bundle.teetSigned);
|
|
17
|
+
validateTimestamps(kOutputPayload, tOutputPayload, logger);
|
|
18
|
+
const teeSessionId = validateSessionIds(kOutputPayload, tOutputPayload, logger);
|
|
19
|
+
logger.info("TEE bundle verification successful");
|
|
20
|
+
return {
|
|
21
|
+
teekSigned: bundle.teekSigned,
|
|
22
|
+
teetSigned: bundle.teetSigned,
|
|
23
|
+
kOutputPayload,
|
|
24
|
+
tOutputPayload,
|
|
25
|
+
teekPcr0: teekKeyResult.pcr0,
|
|
26
|
+
teetPcr0: teetKeyResult.pcr0,
|
|
27
|
+
teeSessionId
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function parseVerificationBundle(bundleBytes) {
|
|
31
|
+
try {
|
|
32
|
+
return VerificationBundle.decode(bundleBytes);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
throw new Error(`Failed to parse verification bundle: ${error.message}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function validateBundleCompleteness(bundle) {
|
|
38
|
+
if (!bundle.teekSigned) {
|
|
39
|
+
throw new Error("SECURITY ERROR: missing TEE_K signed message - verification bundle incomplete");
|
|
40
|
+
}
|
|
41
|
+
if (!bundle.teetSigned) {
|
|
42
|
+
throw new Error("SECURITY ERROR: missing TEE_T signed message - verification bundle incomplete");
|
|
43
|
+
}
|
|
44
|
+
const hasAttestations = bundle.teekSigned.attestationReport?.report && bundle.teekSigned.attestationReport.report.length > 0 || bundle.teetSigned.attestationReport?.report && bundle.teetSigned.attestationReport.report.length > 0;
|
|
45
|
+
const hasPublicKeys = bundle.teekSigned.ethAddress && bundle.teekSigned.ethAddress.length > 0 || bundle.teetSigned.ethAddress && bundle.teetSigned.ethAddress.length > 0;
|
|
46
|
+
if (!hasAttestations && !hasPublicKeys) {
|
|
47
|
+
throw new Error("SECURITY ERROR: bundle must have either Nitro attestations (production) or embedded public keys (development)");
|
|
48
|
+
}
|
|
49
|
+
if (bundle.teekSigned.bodyType !== BodyType.BODY_TYPE_K_OUTPUT) {
|
|
50
|
+
throw new Error("Invalid TEE_K signed message: wrong body type");
|
|
51
|
+
}
|
|
52
|
+
if (bundle.teetSigned.bodyType !== BodyType.BODY_TYPE_T_OUTPUT) {
|
|
53
|
+
throw new Error("Invalid TEE_T signed message: wrong body type");
|
|
54
|
+
}
|
|
55
|
+
if (!bundle.teekSigned.body || bundle.teekSigned.body.length === 0) {
|
|
56
|
+
throw new Error("Invalid TEE_K signed message: empty body");
|
|
57
|
+
}
|
|
58
|
+
if (!bundle.teetSigned.body || bundle.teetSigned.body.length === 0) {
|
|
59
|
+
throw new Error("Invalid TEE_T signed message: empty body");
|
|
60
|
+
}
|
|
61
|
+
if (!bundle.teekSigned.signature || bundle.teekSigned.signature.length === 0) {
|
|
62
|
+
throw new Error("Invalid TEE_K signed message: missing signature");
|
|
63
|
+
}
|
|
64
|
+
if (!bundle.teetSigned.signature || bundle.teetSigned.signature.length === 0) {
|
|
65
|
+
throw new Error("Invalid TEE_T signed message: missing signature");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function extractPublicKeys(bundle, logger) {
|
|
69
|
+
const hasEmbeddedAttestations = bundle.teekSigned.attestationReport?.report && bundle.teekSigned.attestationReport.report.length > 0 && (bundle.teetSigned.attestationReport?.report && bundle.teetSigned.attestationReport.report.length > 0);
|
|
70
|
+
let teekKeyResult;
|
|
71
|
+
let teetKeyResult;
|
|
72
|
+
if (hasEmbeddedAttestations) {
|
|
73
|
+
logger.info("Using production mode: extracting keys from attestations");
|
|
74
|
+
if (!bundle.teekSigned?.attestationReport?.report) {
|
|
75
|
+
throw new Error("TEE_K embedded attestation report missing");
|
|
76
|
+
}
|
|
77
|
+
if (!bundle.teetSigned?.attestationReport?.report) {
|
|
78
|
+
throw new Error("TEE_T embedded attestation report missing");
|
|
79
|
+
}
|
|
80
|
+
const teekAttestationType = bundle.teekSigned.attestationReport.type || "nitro";
|
|
81
|
+
const teetAttestationType = bundle.teetSigned.attestationReport.type || "nitro";
|
|
82
|
+
logger.info(`TEE_K attestation type: ${teekAttestationType}`);
|
|
83
|
+
logger.info(`TEE_T attestation type: ${teetAttestationType}`);
|
|
84
|
+
const teekAttestationBytes = bundle.teekSigned.attestationReport.report;
|
|
85
|
+
const teetAttestationBytes = bundle.teetSigned.attestationReport.report;
|
|
86
|
+
if (teekAttestationType === "gcp") {
|
|
87
|
+
const gcpResult = await validateGcpAttestationAndExtractKey(teekAttestationBytes, logger);
|
|
88
|
+
if (!gcpResult.isValid) {
|
|
89
|
+
throw new Error(`TEE_K GCP attestation validation failed: ${gcpResult.errors.join(", ")}`);
|
|
90
|
+
}
|
|
91
|
+
if (!gcpResult.ethAddress) {
|
|
92
|
+
throw new Error("TEE_K GCP attestation validation failed: no address");
|
|
93
|
+
}
|
|
94
|
+
if (gcpResult.userDataType !== "tee_k") {
|
|
95
|
+
throw new Error(`TEE_K GCP attestation validation failed: wrong TEE type, expected tee_k, got ${gcpResult.userDataType}`);
|
|
96
|
+
}
|
|
97
|
+
teekKeyResult = {
|
|
98
|
+
teeType: gcpResult.userDataType,
|
|
99
|
+
ethAddress: "0x" + Buffer.from(gcpResult.ethAddress).toString("hex"),
|
|
100
|
+
pcr0: gcpResult.pcr0 || "gcp-no-digest"
|
|
101
|
+
};
|
|
102
|
+
} else {
|
|
103
|
+
const nitroResult = await validateNitroAttestationAndExtractKey(teekAttestationBytes);
|
|
104
|
+
if (!nitroResult.isValid) {
|
|
105
|
+
throw new Error(`TEE_K Nitro attestation validation failed: ${nitroResult.errors.join(", ")}`);
|
|
106
|
+
}
|
|
107
|
+
if (!nitroResult.ethAddress) {
|
|
108
|
+
throw new Error("TEE_K Nitro attestation validation failed: no address");
|
|
109
|
+
}
|
|
110
|
+
if (nitroResult.userDataType !== "tee_k") {
|
|
111
|
+
throw new Error(`TEE_K Nitro attestation validation failed: wrong TEE type, expected tee_k, got ${nitroResult.userDataType}`);
|
|
112
|
+
}
|
|
113
|
+
teekKeyResult = {
|
|
114
|
+
teeType: nitroResult.userDataType,
|
|
115
|
+
ethAddress: nitroResult.ethAddress,
|
|
116
|
+
pcr0: nitroResult.pcr0
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (teetAttestationType === "gcp") {
|
|
120
|
+
const gcpResult = await validateGcpAttestationAndExtractKey(teetAttestationBytes, logger);
|
|
121
|
+
if (!gcpResult.isValid) {
|
|
122
|
+
throw new Error(`TEE_T GCP attestation validation failed: ${gcpResult.errors.join(", ")}`);
|
|
123
|
+
}
|
|
124
|
+
if (!gcpResult.ethAddress) {
|
|
125
|
+
throw new Error("TEE_T GCP attestation validation failed: no address");
|
|
126
|
+
}
|
|
127
|
+
if (gcpResult.userDataType !== "tee_t") {
|
|
128
|
+
throw new Error(`TEE_T GCP attestation validation failed: wrong TEE type, expected tee_t, got ${gcpResult.userDataType}`);
|
|
129
|
+
}
|
|
130
|
+
teetKeyResult = {
|
|
131
|
+
teeType: gcpResult.userDataType,
|
|
132
|
+
ethAddress: "0x" + Buffer.from(gcpResult.ethAddress).toString("hex"),
|
|
133
|
+
pcr0: gcpResult.pcr0 || "gcp-no-digest"
|
|
134
|
+
};
|
|
135
|
+
if (!gcpResult.envVars?.EXPECTED_TEEK_PCR0) {
|
|
136
|
+
throw new Error("TEE_T GCP attestation missing required EXPECTED_TEEK_PCR0 environment variable");
|
|
137
|
+
}
|
|
138
|
+
const expectedPcr0 = gcpResult.envVars.EXPECTED_TEEK_PCR0;
|
|
139
|
+
const actualPcr0 = teekKeyResult.pcr0;
|
|
140
|
+
logger.info(`Cross-validating TEE_K PCR0: expected=${expectedPcr0}, actual=${actualPcr0}`);
|
|
141
|
+
if (expectedPcr0 !== actualPcr0) {
|
|
142
|
+
throw new Error(`TEE cross-validation failed: TEE_T expects TEE_K PCR0 "${expectedPcr0}" but got "${actualPcr0}"`);
|
|
143
|
+
}
|
|
144
|
+
logger.info("TEE cross-validation successful: TEE_K PCR0 matches TEE_T expectation");
|
|
145
|
+
} else {
|
|
146
|
+
const nitroResult = await validateNitroAttestationAndExtractKey(teetAttestationBytes);
|
|
147
|
+
if (!nitroResult.isValid) {
|
|
148
|
+
throw new Error(`TEE_T Nitro attestation validation failed: ${nitroResult.errors.join(", ")}`);
|
|
149
|
+
}
|
|
150
|
+
if (!nitroResult.ethAddress) {
|
|
151
|
+
throw new Error("TEE_T Nitro attestation validation failed: no address");
|
|
152
|
+
}
|
|
153
|
+
if (nitroResult.userDataType !== "tee_t") {
|
|
154
|
+
throw new Error(`TEE_T Nitro attestation validation failed: wrong TEE type, expected tee_t, got ${nitroResult.userDataType}`);
|
|
155
|
+
}
|
|
156
|
+
teetKeyResult = {
|
|
157
|
+
teeType: nitroResult.userDataType,
|
|
158
|
+
ethAddress: nitroResult.ethAddress,
|
|
159
|
+
pcr0: nitroResult.pcr0
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
logger.info("Attestations validated successfully");
|
|
163
|
+
} else {
|
|
164
|
+
const standaloneEnabled = process.env.TEE_STANDALONE === "true" || process.env.TEE_STANDALONE === "1";
|
|
165
|
+
if (!standaloneEnabled) {
|
|
166
|
+
throw new Error("Missing attestation reports and standalone mode is not enabled (set TEE_STANDALONE=true to enable)");
|
|
167
|
+
}
|
|
168
|
+
const hasEmbeddedKeys = bundle.teekSigned.ethAddress && bundle.teekSigned.ethAddress.length > 0 && (bundle.teetSigned.ethAddress && bundle.teetSigned.ethAddress.length > 0);
|
|
169
|
+
if (!hasEmbeddedKeys) {
|
|
170
|
+
throw new Error("Missing attestation and no embedded ETH addresses for standalone mode");
|
|
171
|
+
}
|
|
172
|
+
logger.warn("STANDALONE MODE ENABLED: Using embedded ETH addresses without attestation verification");
|
|
173
|
+
const teekAddress = Buffer.from(bundle.teekSigned.ethAddress).toString("utf8");
|
|
174
|
+
teekKeyResult = {
|
|
175
|
+
teeType: "tee_k",
|
|
176
|
+
ethAddress: teekAddress,
|
|
177
|
+
pcr0: "standalone-mode"
|
|
178
|
+
// No PCR0 in standalone mode
|
|
179
|
+
};
|
|
180
|
+
logger.info(`TEE_K standalone address: ${teekAddress}`);
|
|
181
|
+
const teetAddress = Buffer.from(bundle.teetSigned.ethAddress).toString("utf8");
|
|
182
|
+
teetKeyResult = {
|
|
183
|
+
teeType: "tee_t",
|
|
184
|
+
ethAddress: teetAddress,
|
|
185
|
+
pcr0: "standalone-mode"
|
|
186
|
+
// No PCR0 in standalone mode
|
|
187
|
+
};
|
|
188
|
+
logger.info(`TEE_T standalone address: ${teetAddress}`);
|
|
189
|
+
logger.info("Standalone mode key extraction successful");
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
teekKeyResult,
|
|
193
|
+
teetKeyResult
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async function verifyTeeSignatures(bundle, teekKeyResult, teetKeyResult, logger) {
|
|
197
|
+
if (!bundle.teekSigned) {
|
|
198
|
+
throw new Error("TEE_K signed message is missing");
|
|
199
|
+
}
|
|
200
|
+
const teekResult = await verifyTeeSignature(
|
|
201
|
+
bundle.teekSigned,
|
|
202
|
+
teekKeyResult,
|
|
203
|
+
"TEE_K",
|
|
204
|
+
logger
|
|
205
|
+
);
|
|
206
|
+
if (!teekResult.isValid) {
|
|
207
|
+
throw new Error(`TEE_K signature verification failed: ${teekResult.errors.join(", ")}`);
|
|
208
|
+
}
|
|
209
|
+
if (!bundle.teetSigned) {
|
|
210
|
+
throw new Error("TEE_T signed message is missing");
|
|
211
|
+
}
|
|
212
|
+
const teetResult = await verifyTeeSignature(
|
|
213
|
+
bundle.teetSigned,
|
|
214
|
+
teetKeyResult,
|
|
215
|
+
"TEE_T",
|
|
216
|
+
logger
|
|
217
|
+
);
|
|
218
|
+
if (!teetResult.isValid) {
|
|
219
|
+
throw new Error(`TEE_T signature verification failed: ${teetResult.errors.join(", ")}`);
|
|
220
|
+
}
|
|
221
|
+
logger.info("TEE signatures verified successfully");
|
|
222
|
+
}
|
|
223
|
+
async function verifyTeeSignature(signedMessage, extractedKey, teeType, logger) {
|
|
224
|
+
const errors = [];
|
|
225
|
+
if (!signedMessage) {
|
|
226
|
+
return {
|
|
227
|
+
isValid: false,
|
|
228
|
+
errors: ["Signed message is null or undefined"]
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
let ethAddress;
|
|
233
|
+
if (extractedKey.ethAddress) {
|
|
234
|
+
ethAddress = extractedKey.ethAddress;
|
|
235
|
+
logger.debug(`${teeType} using ETH address from attestation: ${ethAddress}`);
|
|
236
|
+
} else {
|
|
237
|
+
return {
|
|
238
|
+
isValid: false,
|
|
239
|
+
errors: ["eth address is null"]
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const { verify: verifySig } = SIGNATURES[ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH];
|
|
243
|
+
const isValid = await verifySig(
|
|
244
|
+
signedMessage.body,
|
|
245
|
+
signedMessage.signature,
|
|
246
|
+
ethAddress
|
|
247
|
+
);
|
|
248
|
+
if (!isValid) {
|
|
249
|
+
errors.push(`${teeType} signature verification failed for address ${ethAddress}`);
|
|
250
|
+
}
|
|
251
|
+
logger.debug(`${teeType} signature verification result: ${isValid} for address ${ethAddress}`);
|
|
252
|
+
return {
|
|
253
|
+
isValid: errors.length === 0,
|
|
254
|
+
errors,
|
|
255
|
+
address: extractedKey.ethAddress
|
|
256
|
+
};
|
|
257
|
+
} catch (error) {
|
|
258
|
+
errors.push(`${teeType} signature verification error: ${error.message}`);
|
|
259
|
+
return {
|
|
260
|
+
isValid: false,
|
|
261
|
+
errors
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function parseKOutputPayload(signedMessage) {
|
|
266
|
+
const payload = KOutputPayload.decode(signedMessage.body);
|
|
267
|
+
if (!payload.redactedRequest) {
|
|
268
|
+
throw new Error("Missing redacted request in TEE_K payload");
|
|
269
|
+
}
|
|
270
|
+
if (!payload.consolidatedResponseKeystream || payload.consolidatedResponseKeystream.length === 0) {
|
|
271
|
+
throw new Error("Missing consolidated response keystream in TEE_K payload");
|
|
272
|
+
}
|
|
273
|
+
if (!payload.certificateInfo) {
|
|
274
|
+
throw new Error("Missing certificate info in TEE_K payload");
|
|
275
|
+
}
|
|
276
|
+
return payload;
|
|
277
|
+
}
|
|
278
|
+
function parseTOutputPayload(signedMessage) {
|
|
279
|
+
const payload = TOutputPayload.decode(signedMessage.body);
|
|
280
|
+
if (!payload.consolidatedResponseCiphertext || payload.consolidatedResponseCiphertext.length === 0) {
|
|
281
|
+
throw new Error("Missing consolidated response ciphertext in TEE_T payload");
|
|
282
|
+
}
|
|
283
|
+
return payload;
|
|
284
|
+
}
|
|
285
|
+
function validateTimestamps(kPayload, tPayload, logger) {
|
|
286
|
+
const now = Date.now();
|
|
287
|
+
const kTimestamp = kPayload.timestampMs;
|
|
288
|
+
const tTimestamp = tPayload.timestampMs;
|
|
289
|
+
const kTimestampS = Math.floor(kTimestamp / 1e3);
|
|
290
|
+
const tTimestampS = Math.floor(tTimestamp / 1e3);
|
|
291
|
+
const nowS = Math.floor(now / 1e3);
|
|
292
|
+
logger.info("Validating TEE timestamps", {
|
|
293
|
+
kTimestampMs: kTimestamp,
|
|
294
|
+
tTimestampMs: tTimestamp,
|
|
295
|
+
kTimestampS,
|
|
296
|
+
tTimestampS,
|
|
297
|
+
nowS
|
|
298
|
+
});
|
|
299
|
+
const maxAgeMs = 10 * 60 * 1e3;
|
|
300
|
+
const oldestAllowed = now - maxAgeMs;
|
|
301
|
+
if (kTimestamp < oldestAllowed) {
|
|
302
|
+
throw new Error(`TEE_K timestamp ${kTimestamp} is too old. Must be within 10 minutes of current time ${now}`);
|
|
303
|
+
}
|
|
304
|
+
if (tTimestamp < oldestAllowed) {
|
|
305
|
+
throw new Error(`TEE_T timestamp ${tTimestamp} is too old. Must be within 10 minutes of current time ${now}`);
|
|
306
|
+
}
|
|
307
|
+
const maxFutureMs = 60 * 1e3;
|
|
308
|
+
const maxAllowed = now + maxFutureMs;
|
|
309
|
+
if (kTimestamp > maxAllowed) {
|
|
310
|
+
throw new Error(`TEE_K timestamp ${kTimestamp} is in the future. Current time is ${now}`);
|
|
311
|
+
}
|
|
312
|
+
if (tTimestamp > maxAllowed) {
|
|
313
|
+
throw new Error(`TEE_T timestamp ${tTimestamp} is in the future. Current time is ${now}`);
|
|
314
|
+
}
|
|
315
|
+
const timestampDiffMs = Math.abs(kTimestamp - tTimestamp);
|
|
316
|
+
const maxDiffMs = 60 * 1e3;
|
|
317
|
+
if (timestampDiffMs > maxDiffMs) {
|
|
318
|
+
throw new Error(`TEE timestamps differ by ${timestampDiffMs}ms, which exceeds maximum allowed difference of ${maxDiffMs}ms (1 minute)`);
|
|
319
|
+
}
|
|
320
|
+
logger.info("TEE timestamp validation successful", {
|
|
321
|
+
timestampDiffMs,
|
|
322
|
+
ageKMs: now - kTimestamp,
|
|
323
|
+
ageTMs: now - tTimestamp
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function validateSessionIds(kPayload, tPayload, logger) {
|
|
327
|
+
const kSessionId = kPayload.sessionId;
|
|
328
|
+
const tSessionId = tPayload.sessionId;
|
|
329
|
+
logger.info("Validating TEE session IDs", {
|
|
330
|
+
kSessionId,
|
|
331
|
+
tSessionId
|
|
332
|
+
});
|
|
333
|
+
if (!kSessionId || kSessionId.length === 0) {
|
|
334
|
+
throw new AttestorError(
|
|
335
|
+
"ERROR_INVALID_CLAIM",
|
|
336
|
+
"Missing session_id in TEE_K payload - required for cross-TEE binding"
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
if (!tSessionId || tSessionId.length === 0) {
|
|
340
|
+
throw new AttestorError(
|
|
341
|
+
"ERROR_INVALID_CLAIM",
|
|
342
|
+
"Missing session_id in TEE_T payload - required for cross-TEE binding"
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
if (kSessionId !== tSessionId) {
|
|
346
|
+
throw new AttestorError(
|
|
347
|
+
"ERROR_INVALID_CLAIM",
|
|
348
|
+
`Session ID mismatch: TEE_K session_id "${kSessionId}" does not match TEE_T session_id "${tSessionId}".`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
logger.info("TEE session ID validation successful", {
|
|
352
|
+
sessionId: kSessionId
|
|
353
|
+
});
|
|
354
|
+
return kSessionId;
|
|
355
|
+
}
|
|
356
|
+
export {
|
|
357
|
+
verifyTeeBundle
|
|
358
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ProviderName, ProviderParams } from '
|
|
1
|
+
import type { ProviderName, ProviderParams } from '#src/types/index.ts';
|
|
2
2
|
export declare function assertValidateProviderParams<T extends ProviderName>(name: T, params: unknown): asserts params is ProviderParams<T>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Ajv } from "ajv";
|
|
2
|
+
import { PROVIDER_SCHEMAS } from "../../types/providers.gen.js";
|
|
3
|
+
import { AttestorError } from "../../utils/error.js";
|
|
4
|
+
const PROVIDER_VALIDATOR_MAP = {};
|
|
5
|
+
const AJV = new Ajv({
|
|
6
|
+
allErrors: true,
|
|
7
|
+
strict: true,
|
|
8
|
+
strictRequired: false,
|
|
9
|
+
formats: {
|
|
10
|
+
binary(data) {
|
|
11
|
+
return data instanceof Uint8Array || typeof Buffer !== "undefined" && Buffer.isBuffer(data);
|
|
12
|
+
},
|
|
13
|
+
url(data) {
|
|
14
|
+
try {
|
|
15
|
+
new URL(data);
|
|
16
|
+
return true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function assertValidateProviderParams(name, params) {
|
|
24
|
+
let validate = PROVIDER_VALIDATOR_MAP[name];
|
|
25
|
+
if (!validate) {
|
|
26
|
+
const schema = PROVIDER_SCHEMAS[name]?.parameters;
|
|
27
|
+
if (!schema) {
|
|
28
|
+
throw new AttestorError(
|
|
29
|
+
"ERROR_BAD_REQUEST",
|
|
30
|
+
`Invalid provider name "${String(name)}"`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
validate = AJV.compile(schema);
|
|
34
|
+
}
|
|
35
|
+
if (!validate?.(params)) {
|
|
36
|
+
throw new AttestorError(
|
|
37
|
+
"ERROR_BAD_REQUEST",
|
|
38
|
+
"Params validation failed",
|
|
39
|
+
{ errors: JSON.stringify(validate.errors) }
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
assertValidateProviderParams
|
|
45
|
+
};
|
package/lib/types/bgp.js
CHANGED
package/lib/types/claims.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ProviderClaimData } from '
|
|
2
|
-
import type { IAttestorClient, IAttestorClientInitParams } from '
|
|
3
|
-
import type { CompleteTLSPacket, Logger } from '
|
|
4
|
-
import type { ProofGenerationStep, ProviderName, ProviderParams, ProviderSecretParams } from '
|
|
5
|
-
import type { Transcript } from '
|
|
6
|
-
import type { PrepareZKProofsBaseOpts } from '
|
|
1
|
+
import type { ProviderClaimData } from '#src/proto/api.ts';
|
|
2
|
+
import type { IAttestorClient, IAttestorClientInitParams } from '#src/types/client.ts';
|
|
3
|
+
import type { CompleteTLSPacket, Logger } from '#src/types/general.ts';
|
|
4
|
+
import type { ProofGenerationStep, ProviderName, ProviderParams, ProviderSecretParams } from '#src/types/providers.ts';
|
|
5
|
+
import type { Transcript } from '#src/types/tunnel.ts';
|
|
6
|
+
import type { PrepareZKProofsBaseOpts } from '#src/types/zk.ts';
|
|
7
7
|
/**
|
|
8
8
|
* Uniquely identifies a claim.
|
|
9
9
|
* Hash of claim info.
|
|
@@ -11,10 +11,7 @@ import type { PrepareZKProofsBaseOpts } from '../types/zk';
|
|
|
11
11
|
*/
|
|
12
12
|
export type ClaimID = ProviderClaimData['identifier'];
|
|
13
13
|
export type ClaimInfo = Pick<ProviderClaimData, 'context' | 'provider' | 'parameters'>;
|
|
14
|
-
export type
|
|
15
|
-
identifier: ClaimID;
|
|
16
|
-
};
|
|
17
|
-
export type CompleteClaimData = Pick<ProviderClaimData, 'owner' | 'timestampS' | 'epoch'> & AnyClaimInfo;
|
|
14
|
+
export type CompleteClaimData = Pick<ProviderClaimData, 'owner' | 'timestampS' | 'epoch'> & ClaimInfo;
|
|
18
15
|
export type CreateClaimOnAttestorOpts<N extends ProviderName> = {
|
|
19
16
|
/** name of the provider to generate signed receipt for */
|
|
20
17
|
name: N;
|
package/lib/types/claims.js
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhaW1zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL2NsYWltcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
package/lib/types/client.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'http';
|
|
2
|
-
import type { AuthenticationRequest, InitRequest, InitResponse, RPCMessage, RPCMessages, ServiceSignatureType, TunnelMessage } from '../proto/api';
|
|
3
|
-
import type { BGPListener } from '../types/bgp';
|
|
4
|
-
import type { Logger } from '../types/general';
|
|
5
|
-
import type { RPCEvent, RPCEventMap, RPCEventType, RPCRequestData, RPCResponseData, RPCType } from '../types/rpc';
|
|
6
|
-
import type { TCPSocketProperties, Tunnel } from '../types/tunnel';
|
|
7
2
|
import type { WebSocket as WSWebSocket } from 'ws';
|
|
3
|
+
import type { AuthenticationRequest, InitRequest, InitResponse, RPCMessage, RPCMessages, ServiceSignatureType, TunnelMessage } from '#src/proto/api.ts';
|
|
4
|
+
import type { BGPListener } from '#src/types/bgp.ts';
|
|
5
|
+
import type { Logger } from '#src/types/general.ts';
|
|
6
|
+
import type { RPCEvent, RPCEventMap, RPCEventType, RPCRequestData, RPCResponseData, RPCType } from '#src/types/rpc.ts';
|
|
7
|
+
import type { TCPSocketProperties, Tunnel } from '#src/types/tunnel.ts';
|
|
8
8
|
/**
|
|
9
9
|
* Any WebSocket implementation -- either the native
|
|
10
10
|
* WebSocket or the WebSocket from the `ws` package.
|
package/lib/types/client.js
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL2NsaWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
package/lib/types/general.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger as TLSLogger, TLSPacketContext, TLSProtocolVersion } from '@reclaimprotocol/tls';
|
|
2
|
-
import type { TOPRFProofParams } from '
|
|
2
|
+
import type { OPRFRawMarker, TOPRFProofParams } from '#src/types/zk.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Represents a slice of any array or string
|
|
5
5
|
*/
|
|
@@ -11,11 +11,14 @@ export type RedactedOrHashedArraySlice = {
|
|
|
11
11
|
fromIndex: number;
|
|
12
12
|
toIndex: number;
|
|
13
13
|
/**
|
|
14
|
-
* By default, the
|
|
15
|
-
* a deterministic hash, set this to
|
|
14
|
+
* By default, the data is redacted. Instead if you'd like
|
|
15
|
+
* a deterministic hash, set this to:
|
|
16
|
+
* - 'oprf' for client-side TOPRF with ZK proof
|
|
17
|
+
* - 'oprf-mpc' for TEE-to-TEE MPC OPRF
|
|
18
|
+
* - 'oprf-raw' for server-side OPRF (data revealed to attestor)
|
|
16
19
|
* @default undefined
|
|
17
20
|
*/
|
|
18
|
-
hash?: 'oprf';
|
|
21
|
+
hash?: 'oprf' | 'oprf-mpc' | 'oprf-raw';
|
|
19
22
|
};
|
|
20
23
|
export type Logger = TLSLogger & {
|
|
21
24
|
child: (opts: {
|
|
@@ -27,6 +30,17 @@ export type ZKRevealInfo = {
|
|
|
27
30
|
type: 'zk';
|
|
28
31
|
redactedPlaintext: Uint8Array;
|
|
29
32
|
toprfs?: TOPRFProofParams[];
|
|
33
|
+
oprfRawMarkers?: OPRFRawMarker[];
|
|
34
|
+
overshotToprfFromPrevBlock?: {
|
|
35
|
+
length: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* If an oprf-raw marker from the previous block overshot into this block.
|
|
39
|
+
* The server will collect plaintext from this block to complete the OPRF.
|
|
40
|
+
*/
|
|
41
|
+
overshotOprfRawFromPrevBlock?: {
|
|
42
|
+
length: number;
|
|
43
|
+
};
|
|
30
44
|
};
|
|
31
45
|
export type MessageRevealInfo = {
|
|
32
46
|
type: 'complete';
|
|
@@ -48,4 +62,15 @@ export type IDecryptedTranscript = {
|
|
|
48
62
|
transcript: IDecryptedTranscriptMessage[];
|
|
49
63
|
tlsVersion: TLSProtocolVersion;
|
|
50
64
|
hostname: string;
|
|
65
|
+
/**
|
|
66
|
+
* oprf-raw replacements: original plaintext -> nullifier mappings
|
|
67
|
+
* for server-side parameter replacement
|
|
68
|
+
*/
|
|
69
|
+
oprfRawReplacements?: OPRFRawReplacement[];
|
|
70
|
+
};
|
|
71
|
+
export type OPRFRawReplacement = {
|
|
72
|
+
/** Original plaintext that was OPRF'd */
|
|
73
|
+
originalText: string;
|
|
74
|
+
/** OPRF nullifier string to replace with */
|
|
75
|
+
nullifierText: string;
|
|
51
76
|
};
|
package/lib/types/general.js
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9nZW5lcmFsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
package/lib/types/handlers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Transaction } from 'elastic-apm-node';
|
|
2
|
-
import type { IAttestorServerSocket } from '
|
|
3
|
-
import type { Logger } from '
|
|
4
|
-
import type { RPCRequestData, RPCResponseData, RPCType } from '
|
|
2
|
+
import type { IAttestorServerSocket } from '#src/types/client.ts';
|
|
3
|
+
import type { Logger } from '#src/types/general.ts';
|
|
4
|
+
import type { RPCRequestData, RPCResponseData, RPCType } from '#src/types/rpc.ts';
|
|
5
5
|
export type RPCHandlerMetadata = {
|
|
6
6
|
logger: Logger;
|
|
7
7
|
tx?: Transaction;
|
package/lib/types/handlers.js
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvaGFuZGxlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './providers';
|
|
2
|
-
export * from './general';
|
|
3
|
-
export * from './signatures';
|
|
4
|
-
export * from './claims';
|
|
5
|
-
export * from './zk';
|
|
6
|
-
export * from './client';
|
|
7
|
-
export * from './rpc';
|
|
8
|
-
export * from './tunnel';
|
|
9
|
-
export * from './handlers';
|
|
10
|
-
export * from './bgp';
|
|
1
|
+
export * from './providers.ts';
|
|
2
|
+
export * from './general.ts';
|
|
3
|
+
export * from './signatures.ts';
|
|
4
|
+
export * from './claims.ts';
|
|
5
|
+
export * from './zk.ts';
|
|
6
|
+
export * from './client.ts';
|
|
7
|
+
export * from './rpc.ts';
|
|
8
|
+
export * from './tunnel.ts';
|
|
9
|
+
export * from './handlers.ts';
|
|
10
|
+
export * from './bgp.ts';
|
package/lib/types/index.js
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./providers"), exports);
|
|
18
|
-
__exportStar(require("./general"), exports);
|
|
19
|
-
__exportStar(require("./signatures"), exports);
|
|
20
|
-
__exportStar(require("./claims"), exports);
|
|
21
|
-
__exportStar(require("./zk"), exports);
|
|
22
|
-
__exportStar(require("./client"), exports);
|
|
23
|
-
__exportStar(require("./rpc"), exports);
|
|
24
|
-
__exportStar(require("./tunnel"), exports);
|
|
25
|
-
__exportStar(require("./handlers"), exports);
|
|
26
|
-
__exportStar(require("./bgp"), exports);
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDhDQUEyQjtBQUMzQiw0Q0FBeUI7QUFDekIsK0NBQTRCO0FBQzVCLDJDQUF3QjtBQUN4Qix1Q0FBb0I7QUFDcEIsMkNBQXdCO0FBQ3hCLHdDQUFxQjtBQUNyQiwyQ0FBd0I7QUFDeEIsNkNBQTBCO0FBQzFCLHdDQUFxQiJ9
|
|
1
|
+
export * from "./providers.js";
|
|
2
|
+
export * from "./general.js";
|
|
3
|
+
export * from "./signatures.js";
|
|
4
|
+
export * from "./claims.js";
|
|
5
|
+
export * from "./zk.js";
|
|
6
|
+
export * from "./client.js";
|
|
7
|
+
export * from "./rpc.js";
|
|
8
|
+
export * from "./tunnel.js";
|
|
9
|
+
export * from "./handlers.js";
|
|
10
|
+
export * from "./bgp.js";
|
package/lib/types/providers.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TLSConnectionOptions } from '@reclaimprotocol/tls';
|
|
2
|
-
import type { AttestorVersion, ProviderClaimData } from '
|
|
3
|
-
import type { ArraySlice, Logger, RedactedOrHashedArraySlice } from '
|
|
4
|
-
import type { ProvidersConfig } from '
|
|
5
|
-
import type { Transcript } from '
|
|
2
|
+
import type { AttestorVersion, ProviderClaimData } from '#src/proto/api.ts';
|
|
3
|
+
import type { ArraySlice, Logger, RedactedOrHashedArraySlice } from '#src/types/general.ts';
|
|
4
|
+
import type { ProvidersConfig } from '#src/types/providers.gen.ts';
|
|
5
|
+
import type { Transcript } from '#src/types/tunnel.ts';
|
|
6
6
|
export type AttestorData = {
|
|
7
7
|
id: string;
|
|
8
8
|
url: string;
|
|
@@ -66,6 +66,17 @@ export interface Provider<N extends ProviderName, Params = ProviderParams<N>, Se
|
|
|
66
66
|
* @example "US", "IN"
|
|
67
67
|
*/
|
|
68
68
|
geoLocation?: ProviderField<Params, SecretParams, string | undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* Session identifier for proxy IP persistence.
|
|
71
|
+
*
|
|
72
|
+
* When provided, ensures all requests within the same session
|
|
73
|
+
* are routed through the same proxy IP address. Useful for
|
|
74
|
+
* maintaining IP consistency across multiple requests.
|
|
75
|
+
*
|
|
76
|
+
* Can be a smallcase alphanumeric string of length 8-14 characters.
|
|
77
|
+
* @example "mystring12345", "something1234"
|
|
78
|
+
*/
|
|
79
|
+
proxySessionId?: ProviderField<Params, SecretParams, string | undefined>;
|
|
69
80
|
/** extra options to pass to the client like root CA certificates */
|
|
70
81
|
additionalClientOptions?: ProviderField<Params, SecretParams, TLSConnectionOptions | undefined>;
|
|
71
82
|
/**
|