@reclaimprotocol/attestor-core 4.0.3 → 5.0.1-beta.10
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/browser/avs/abis/avsDirectoryABI.d.ts +60 -0
- package/lib/browser/avs/abis/avsDirectoryABI.js +343 -0
- package/lib/browser/avs/abis/delegationABI.d.ts +126 -0
- package/lib/browser/avs/abis/delegationABI.js +4 -0
- package/lib/browser/avs/abis/registryABI.d.ts +136 -0
- package/lib/browser/avs/abis/registryABI.js +728 -0
- package/lib/browser/avs/client/create-claim-on-avs.d.ts +12 -0
- package/lib/browser/avs/client/create-claim-on-avs.js +168 -0
- package/lib/browser/avs/config.d.ts +7 -0
- package/lib/browser/avs/config.js +26 -0
- package/lib/browser/avs/contracts/ReclaimServiceManager.d.ts +601 -0
- package/lib/browser/avs/contracts/ReclaimServiceManager.js +0 -0
- package/lib/browser/avs/contracts/common.d.ts +50 -0
- package/lib/browser/avs/contracts/common.js +0 -0
- package/lib/browser/avs/contracts/factories/ReclaimServiceManager__factory.d.ts +890 -0
- package/lib/browser/avs/contracts/factories/ReclaimServiceManager__factory.js +1183 -0
- package/lib/browser/avs/contracts/factories/index.d.ts +1 -0
- package/lib/browser/avs/contracts/factories/index.js +4 -0
- package/lib/browser/avs/contracts/index.d.ts +3 -0
- package/lib/browser/avs/contracts/index.js +6 -0
- package/lib/browser/avs/types/index.d.ts +55 -0
- package/lib/browser/avs/types/index.js +0 -0
- package/lib/browser/avs/utils/contracts.d.ts +21 -0
- package/lib/browser/avs/utils/contracts.js +53 -0
- package/lib/browser/avs/utils/register.d.ts +27 -0
- package/lib/browser/avs/utils/register.js +74 -0
- package/lib/browser/avs/utils/tasks.d.ts +22 -0
- package/lib/browser/avs/utils/tasks.js +48 -0
- package/lib/browser/client/create-claim.d.ts +5 -0
- package/lib/browser/client/create-claim.js +461 -0
- package/lib/browser/client/index.d.ts +3 -0
- package/lib/browser/client/index.js +3 -0
- package/lib/browser/client/tunnels/make-rpc-tcp-tunnel.d.ts +16 -0
- package/lib/browser/client/tunnels/make-rpc-tcp-tunnel.js +53 -0
- package/lib/browser/client/tunnels/make-rpc-tls-tunnel.d.ts +26 -0
- package/lib/browser/client/tunnels/make-rpc-tls-tunnel.js +127 -0
- package/lib/browser/client/utils/attestor-pool.d.ts +8 -0
- package/lib/browser/client/utils/attestor-pool.js +24 -0
- package/lib/browser/client/utils/client-socket.d.ts +11 -0
- package/lib/browser/client/utils/client-socket.js +120 -0
- package/lib/browser/client/utils/message-handler.d.ts +4 -0
- package/lib/browser/client/utils/message-handler.js +97 -0
- package/lib/browser/config/index.d.ts +31 -0
- package/lib/browser/config/index.js +62 -0
- package/lib/browser/external-rpc/benchmark.d.ts +1 -0
- package/lib/browser/external-rpc/benchmark.js +82 -0
- package/lib/browser/external-rpc/event-bus.d.ts +7 -0
- package/lib/browser/external-rpc/event-bus.js +17 -0
- package/lib/browser/external-rpc/global.d.js +0 -0
- package/lib/browser/external-rpc/handle-incoming-msg.d.ts +2 -0
- package/lib/browser/external-rpc/handle-incoming-msg.js +241 -0
- package/lib/browser/external-rpc/index.d.ts +3 -0
- package/lib/browser/external-rpc/index.js +3 -0
- package/lib/browser/external-rpc/jsc-polyfills/1.d.ts +14 -0
- package/lib/browser/external-rpc/jsc-polyfills/1.js +80 -0
- package/lib/browser/external-rpc/jsc-polyfills/2.js +15 -0
- package/lib/browser/external-rpc/jsc-polyfills/event.d.ts +10 -0
- package/lib/browser/external-rpc/jsc-polyfills/event.js +19 -0
- package/lib/browser/external-rpc/jsc-polyfills/index.d.ts +2 -0
- package/lib/browser/external-rpc/jsc-polyfills/index.js +2 -0
- package/lib/browser/external-rpc/jsc-polyfills/ws.d.ts +21 -0
- package/lib/browser/external-rpc/jsc-polyfills/ws.js +83 -0
- package/lib/browser/external-rpc/setup-browser.d.ts +6 -0
- package/lib/browser/external-rpc/setup-browser.js +33 -0
- package/lib/browser/external-rpc/setup-jsc.d.ts +24 -0
- package/lib/browser/external-rpc/setup-jsc.js +22 -0
- package/lib/{window-rpc → browser/external-rpc}/types.d.ts +56 -35
- package/lib/browser/external-rpc/types.js +0 -0
- package/lib/browser/external-rpc/utils.d.ts +20 -0
- package/lib/browser/external-rpc/utils.js +100 -0
- package/lib/browser/external-rpc/zk.d.ts +14 -0
- package/lib/browser/external-rpc/zk.js +58 -0
- package/lib/browser/index.browser.js +13 -0
- package/lib/browser/index.d.ts +9 -0
- package/lib/browser/index.js +13 -0
- package/lib/browser/mechain/abis/governanceABI.d.ts +50 -0
- package/lib/browser/mechain/abis/governanceABI.js +461 -0
- package/lib/browser/mechain/abis/taskABI.d.ts +157 -0
- package/lib/browser/mechain/abis/taskABI.js +512 -0
- package/lib/browser/mechain/client/create-claim-on-mechain.d.ts +10 -0
- package/lib/browser/mechain/client/create-claim-on-mechain.js +33 -0
- package/lib/browser/mechain/client/index.d.ts +1 -0
- package/lib/browser/mechain/client/index.js +1 -0
- package/lib/browser/mechain/constants/index.d.ts +3 -0
- package/lib/browser/mechain/constants/index.js +8 -0
- package/lib/browser/mechain/index.d.ts +2 -0
- package/lib/browser/mechain/index.js +2 -0
- package/lib/browser/mechain/types/index.d.ts +23 -0
- package/lib/browser/mechain/types/index.js +0 -0
- package/lib/browser/proto/api.d.ts +651 -0
- package/lib/browser/proto/api.js +4250 -0
- package/lib/browser/proto/tee-bundle.d.ts +156 -0
- package/lib/browser/proto/tee-bundle.js +1296 -0
- package/lib/browser/providers/http/index.d.ts +18 -0
- package/lib/browser/providers/http/index.js +640 -0
- package/lib/browser/providers/http/patch-parse5-tree.d.ts +6 -0
- package/lib/browser/providers/http/patch-parse5-tree.js +34 -0
- package/lib/browser/providers/http/utils.d.ts +77 -0
- package/lib/browser/providers/http/utils.js +283 -0
- package/lib/browser/providers/index.d.ts +4 -0
- package/lib/browser/providers/index.js +7 -0
- package/lib/browser/scripts/fallbacks/crypto.js +4 -0
- package/lib/browser/scripts/fallbacks/empty.js +4 -0
- package/lib/browser/scripts/fallbacks/gnark.js +15 -0
- package/lib/browser/scripts/fallbacks/re2.js +7 -0
- package/lib/browser/scripts/fallbacks/snarkjs.js +10 -0
- package/lib/browser/scripts/fallbacks/stwo.js +159 -0
- package/lib/browser/types/bgp.d.ts +11 -0
- package/lib/browser/types/bgp.js +0 -0
- package/lib/browser/types/claims.d.ts +70 -0
- package/lib/browser/types/claims.js +0 -0
- package/lib/browser/types/client.d.ts +163 -0
- package/lib/browser/types/client.js +0 -0
- package/lib/browser/types/general.d.ts +77 -0
- package/lib/browser/types/general.js +0 -0
- package/lib/browser/types/handlers.d.ts +10 -0
- package/lib/browser/types/handlers.js +0 -0
- package/lib/browser/types/index.d.ts +10 -0
- package/lib/browser/types/index.js +10 -0
- package/lib/browser/types/providers.d.ts +161 -0
- package/lib/browser/types/providers.gen.d.ts +443 -0
- package/lib/browser/types/providers.gen.js +16 -0
- package/lib/browser/types/providers.js +0 -0
- package/lib/browser/types/rpc.d.ts +35 -0
- package/lib/browser/types/rpc.js +0 -0
- package/lib/browser/types/signatures.d.ts +28 -0
- package/lib/browser/types/signatures.js +0 -0
- package/lib/browser/types/tunnel.d.ts +18 -0
- package/lib/browser/types/tunnel.js +0 -0
- package/lib/browser/types/zk.d.ts +38 -0
- package/lib/browser/types/zk.js +0 -0
- package/lib/browser/utils/auth.d.ts +8 -0
- package/lib/browser/utils/auth.js +71 -0
- package/lib/browser/utils/b64-json.d.ts +2 -0
- package/lib/browser/utils/b64-json.js +17 -0
- package/lib/browser/utils/claims.d.ts +33 -0
- package/lib/browser/utils/claims.js +89 -0
- package/lib/browser/utils/env.d.ts +3 -0
- package/lib/browser/utils/env.js +19 -0
- package/lib/browser/utils/error.d.ts +26 -0
- package/lib/browser/utils/error.js +54 -0
- package/lib/browser/utils/generics.d.ts +119 -0
- package/lib/browser/utils/generics.js +272 -0
- package/lib/browser/utils/http-parser.d.ts +59 -0
- package/lib/browser/utils/http-parser.js +201 -0
- package/lib/browser/utils/index.browser.js +13 -0
- package/lib/browser/utils/index.d.ts +13 -0
- package/lib/browser/utils/index.js +13 -0
- package/lib/browser/utils/logger.browser.js +88 -0
- package/lib/browser/utils/logger.d.ts +14 -0
- package/lib/browser/utils/logger.js +88 -0
- package/lib/browser/utils/prepare-packets.d.ts +16 -0
- package/lib/browser/utils/prepare-packets.js +69 -0
- package/lib/browser/utils/redactions.d.ts +73 -0
- package/lib/browser/utils/redactions.js +135 -0
- package/lib/browser/utils/retries.d.ts +12 -0
- package/lib/browser/utils/retries.js +26 -0
- package/lib/browser/utils/signatures/eth.d.ts +2 -0
- package/lib/browser/utils/signatures/eth.js +31 -0
- package/lib/browser/utils/signatures/index.d.ts +5 -0
- package/lib/browser/utils/signatures/index.js +12 -0
- package/lib/browser/utils/socket-base.d.ts +23 -0
- package/lib/browser/utils/socket-base.js +96 -0
- package/lib/browser/utils/tls-imports.d.ts +21 -0
- package/lib/browser/utils/tls-imports.js +71 -0
- package/lib/browser/utils/tls.d.ts +2 -0
- package/lib/browser/utils/tls.js +58 -0
- package/lib/browser/utils/ws.d.ts +7 -0
- package/lib/browser/utils/ws.js +22 -0
- package/lib/browser/utils/zk.d.ts +71 -0
- package/lib/browser/utils/zk.js +625 -0
- 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/external-rpc/types.d.ts +213 -0
- 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.browser.d.ts +9 -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/gnark.d.ts +7 -0
- package/lib/scripts/fallbacks/gnark.js +15 -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/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 +4 -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 +30 -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 +20 -13
- package/lib/utils/generics.js +221 -297
- package/lib/utils/http-parser.d.ts +1 -1
- package/lib/utils/http-parser.js +186 -237
- package/lib/utils/index.browser.d.ts +13 -0
- package/lib/utils/index.d.ts +14 -12
- package/lib/utils/index.js +14 -29
- package/lib/utils/logger.browser.d.ts +14 -0
- 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-imports.d.ts +21 -0
- package/lib/utils/tls-imports.js +71 -0
- 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 +79 -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.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 → browser/external-rpc/jsc-polyfills/2.d.ts} +0 -0
- /package/lib/{tests/test.bgp-listener.d.ts → external-rpc/jsc-polyfills/2.d.ts} +0 -0
- /package/lib/{tests/test.claim-creation.d.ts → scripts/build-browser.d.ts} +0 -0
- /package/lib/{tests/test.http-provider-utils.d.ts → scripts/build-jsc.d.ts} +0 -0
- /package/lib/{tests/test.http-provider.d.ts → scripts/build-lib.d.ts} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RPCHandler } from '
|
|
1
|
+
import type { RPCHandler } from '#src/types/index.ts';
|
|
2
2
|
export declare const disconnectTunnel: RPCHandler<'disconnectTunnel'>;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.disconnectTunnel = void 0;
|
|
4
1
|
const disconnectTunnel = async ({ id }, { client }) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const tunnel = client.getTunnel(id);
|
|
3
|
+
await tunnel.close();
|
|
4
|
+
return {};
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
disconnectTunnel
|
|
8
8
|
};
|
|
9
|
-
exports.disconnectTunnel = disconnectTunnel;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlzY29ubmVjdFR1bm5lbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2ZXIvaGFuZGxlcnMvZGlzY29ubmVjdFR1bm5lbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFTyxNQUFNLGdCQUFnQixHQUFtQyxLQUFLLEVBQ3BFLEVBQUUsRUFBRSxFQUFFLEVBQ04sRUFBRSxNQUFNLEVBQUUsRUFDVCxFQUFFO0lBQ0gsTUFBTSxNQUFNLEdBQUcsTUFBTSxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsQ0FBQTtJQUNuQyxNQUFNLE1BQU0sQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUVwQixPQUFPLEVBQUUsQ0FBQTtBQUNWLENBQUMsQ0FBQTtBQVJZLFFBQUEsZ0JBQWdCLG9CQVE1QiJ9
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { concatenateUint8Arrays, loadX509FromPem } from "@reclaimprotocol/tls";
|
|
2
|
+
import { CERT_ALLOWED_MIMETYPES, MAX_CERT_SIZE_BYTES } from "../../config/index.js";
|
|
3
|
+
import { AttestorError } from "../../utils/error.js";
|
|
4
|
+
const fetchCertificateBytes = async ({ url }) => {
|
|
5
|
+
const res = await fetch(url, {
|
|
6
|
+
redirect: "follow",
|
|
7
|
+
signal: AbortSignal.timeout(1e4)
|
|
8
|
+
});
|
|
9
|
+
if (!res.ok) {
|
|
10
|
+
res.body?.cancel("Not ok");
|
|
11
|
+
throw new AttestorError(
|
|
12
|
+
"ERROR_CERTIFICATE_FETCH_FAILED",
|
|
13
|
+
`Failed to fetch certificate from URL: ${url}, status: ${res.status}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
const contentType = res.headers.get("content-type");
|
|
17
|
+
if (!contentType || !CERT_ALLOWED_MIMETYPES.includes(contentType)) {
|
|
18
|
+
res.body?.cancel("Mismatch");
|
|
19
|
+
throw new AttestorError(
|
|
20
|
+
"ERROR_CERTIFICATE_FETCH_FAILED",
|
|
21
|
+
`Invalid content-type when fetching certificate from URL: ${url}, content-type: ${contentType}`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (!res.body) {
|
|
25
|
+
throw new AttestorError(
|
|
26
|
+
"ERROR_CERTIFICATE_FETCH_FAILED",
|
|
27
|
+
`No body in response when fetching certificate from URL: ${url}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
let total = 0;
|
|
31
|
+
const byteArr = [];
|
|
32
|
+
for await (const chunk of res.body) {
|
|
33
|
+
total += chunk.length;
|
|
34
|
+
if (total > MAX_CERT_SIZE_BYTES) {
|
|
35
|
+
res.body.cancel("Too many bytes");
|
|
36
|
+
throw new AttestorError(
|
|
37
|
+
"ERROR_CERTIFICATE_FETCH_FAILED",
|
|
38
|
+
`Certificate size exceeds maximum limit of ${MAX_CERT_SIZE_BYTES}b`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
byteArr.push(chunk);
|
|
42
|
+
}
|
|
43
|
+
const bytes = concatenateUint8Arrays(byteArr);
|
|
44
|
+
try {
|
|
45
|
+
const cert = loadX509FromPem(bytes);
|
|
46
|
+
TLS_INTERMEDIATE_CA_CACHE[url] = cert;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
throw new AttestorError(
|
|
49
|
+
"ERROR_CERTIFICATE_FETCH_FAILED",
|
|
50
|
+
`Failed to parse certificate, error: ${err.message}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return { bytes: concatenateUint8Arrays(byteArr) };
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
fetchCertificateBytes
|
|
57
|
+
};
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { claimTeeBundle } from "../../server/handlers/claimTeeBundle.js";
|
|
2
|
+
import { claimTunnel } from "../../server/handlers/claimTunnel.js";
|
|
3
|
+
import { completeClaimOnChain } from "../../server/handlers/completeClaimOnChain.js";
|
|
4
|
+
import { createClaimOnChain } from "../../server/handlers/createClaimOnChain.js";
|
|
5
|
+
import { createTaskOnMechain } from "../../server/handlers/createTaskOnMechain.js";
|
|
6
|
+
import { createTunnel } from "../../server/handlers/createTunnel.js";
|
|
7
|
+
import { disconnectTunnel } from "../../server/handlers/disconnectTunnel.js";
|
|
8
|
+
import { fetchCertificateBytes } from "../../server/handlers/fetchCertificateBytes.js";
|
|
9
|
+
import { init } from "../../server/handlers/init.js";
|
|
10
|
+
import { toprf } from "../../server/handlers/toprf.js";
|
|
11
|
+
const HANDLERS = {
|
|
12
|
+
createTunnel,
|
|
13
|
+
disconnectTunnel,
|
|
14
|
+
claimTunnel,
|
|
15
|
+
claimTeeBundle,
|
|
16
|
+
init,
|
|
17
|
+
createClaimOnChain,
|
|
18
|
+
completeClaimOnChain,
|
|
19
|
+
toprf,
|
|
20
|
+
createTaskOnMechain,
|
|
21
|
+
fetchCertificateBytes
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
HANDLERS
|
|
21
25
|
};
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmVyL2hhbmRsZXJzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlFQUE2RDtBQUM3RCxtRkFBK0U7QUFDL0UsK0VBQTJFO0FBQzNFLGlGQUE2RTtBQUM3RSxtRUFBK0Q7QUFDL0QsMkVBQXVFO0FBQ3ZFLG1EQUErQztBQUMvQyxxREFBaUQ7QUFHcEMsUUFBQSxRQUFRLEdBQXNDO0lBQzFELFlBQVksRUFBWiwyQkFBWTtJQUNaLGdCQUFnQixFQUFoQixtQ0FBZ0I7SUFDaEIsV0FBVyxFQUFYLHlCQUFXO0lBQ1gsSUFBSSxFQUFKLFdBQUk7SUFDSixrQkFBa0IsRUFBbEIsdUNBQWtCO0lBQ2xCLG9CQUFvQixFQUFwQiwyQ0FBb0I7SUFDcEIsS0FBSyxFQUFMLGFBQUs7SUFDTCxtQkFBbUIsRUFBbkIseUNBQW1CO0NBQ25CLENBQUEifQ==
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RPCHandler } from '
|
|
1
|
+
import type { RPCHandler } from '#src/types/index.ts';
|
|
2
2
|
export declare const init: RPCHandler<'init'>;
|
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const signatures_1 = require("../../utils/signatures");
|
|
9
|
-
const TOPRF_PUBLIC_KEY = (0, env_1.getEnvVariable)('TOPRF_PUBLIC_KEY');
|
|
1
|
+
import { getBytes } from "ethers";
|
|
2
|
+
import { getAttestorAddress } from "../../server/utils/generics.js";
|
|
3
|
+
import { assertValidAuthRequest } from "../../utils/auth.js";
|
|
4
|
+
import { getEnvVariable } from "../../utils/env.js";
|
|
5
|
+
import { AttestorError } from "../../utils/index.js";
|
|
6
|
+
import { SIGNATURES } from "../../utils/signatures/index.js";
|
|
7
|
+
const TOPRF_PUBLIC_KEY = getEnvVariable("TOPRF_PUBLIC_KEY");
|
|
10
8
|
const init = async (initRequest, { client }) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
if (client.isInitialised) {
|
|
10
|
+
throw AttestorError.badRequest("Client already initialised");
|
|
11
|
+
}
|
|
12
|
+
if (!SIGNATURES[initRequest.signatureType]) {
|
|
13
|
+
throw AttestorError.badRequest("Unsupported signature type");
|
|
14
|
+
}
|
|
15
|
+
if (initRequest.clientVersion <= 0) {
|
|
16
|
+
throw AttestorError.badRequest("Unsupported client version");
|
|
17
|
+
}
|
|
18
|
+
await assertValidAuthRequest(initRequest.auth, initRequest.signatureType);
|
|
19
|
+
if (initRequest.auth?.data) {
|
|
20
|
+
client.logger = client.logger.child({
|
|
21
|
+
userId: initRequest.auth.data.id
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
client.metadata = initRequest;
|
|
25
|
+
client.isInitialised = true;
|
|
26
|
+
return {
|
|
27
|
+
toprfPublicKey: TOPRF_PUBLIC_KEY ? getBytes(TOPRF_PUBLIC_KEY) : new Uint8Array(),
|
|
28
|
+
attestorAddress: getAttestorAddress(initRequest.signatureType)
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
init
|
|
34
33
|
};
|
|
35
|
-
exports.init = init;
|
|
36
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5pdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2ZXIvaGFuZGxlcnMvaW5pdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxtQ0FBK0I7QUFFL0IscUNBQXlDO0FBQ3pDLHlDQUF1RDtBQUN2RCx1Q0FBOEM7QUFDOUMscURBQWlEO0FBRWpELE1BQU0sZ0JBQWdCLEdBQUcsSUFBQSxvQkFBYyxFQUFDLGtCQUFrQixDQUFDLENBQUE7QUFFcEQsTUFBTSxJQUFJLEdBQXVCLEtBQUssRUFDNUMsV0FBVyxFQUNYLEVBQUUsTUFBTSxFQUFFLEVBQ1QsRUFBRTs7SUFDSCxJQUFHLE1BQU0sQ0FBQyxhQUFhLEVBQUUsQ0FBQztRQUN6QixNQUFNLHFCQUFhLENBQUMsVUFBVSxDQUFDLDRCQUE0QixDQUFDLENBQUE7SUFDN0QsQ0FBQztJQUVELElBQUcsQ0FBQyx1QkFBVSxDQUFDLFdBQVcsQ0FBQyxhQUFhLENBQUMsRUFBRSxDQUFDO1FBQzNDLE1BQU0scUJBQWEsQ0FBQyxVQUFVLENBQUMsNEJBQTRCLENBQUMsQ0FBQTtJQUM3RCxDQUFDO0lBRUQsSUFBRyxXQUFXLENBQUMsYUFBYSxJQUFJLENBQUMsRUFBRSxDQUFDO1FBQ25DLE1BQU0scUJBQWEsQ0FBQyxVQUFVLENBQUMsNEJBQTRCLENBQUMsQ0FBQTtJQUM3RCxDQUFDO0lBRUQsTUFBTSxJQUFBLDZCQUFzQixFQUMzQixXQUFXLENBQUMsSUFBSSxFQUNoQixXQUFXLENBQUMsYUFBYSxDQUN6QixDQUFBO0lBRUQsSUFBRyxNQUFBLFdBQVcsQ0FBQyxJQUFJLDBDQUFFLElBQUksRUFBRSxDQUFDO1FBQzNCLE1BQU0sQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUM7WUFDbkMsTUFBTSxFQUFFLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEVBQUU7U0FDaEMsQ0FBQyxDQUFBO0lBQ0gsQ0FBQztJQUVELE1BQU0sQ0FBQyxRQUFRLEdBQUcsV0FBVyxDQUFBO0lBQzdCLE1BQU0sQ0FBQyxhQUFhLEdBQUcsSUFBSSxDQUFBO0lBRTNCLE9BQU87UUFDTixjQUFjLEVBQUUsZ0JBQWdCO1lBQy9CLENBQUMsQ0FBQyxlQUFNLENBQUMsS0FBSyxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0IsQ0FBQztZQUN6QyxDQUFDLENBQUMsSUFBSSxVQUFVLEVBQUU7S0FDbkIsQ0FBQTtBQUNGLENBQUMsQ0FBQTtBQW5DWSxRQUFBLElBQUksUUFtQ2hCIn0=
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RPCHandler } from '
|
|
1
|
+
import type { RPCHandler } from '#src/types/index.ts';
|
|
2
2
|
export declare const toprf: RPCHandler<'toprf'>;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
const env_1 = require("../../utils/env");
|
|
1
|
+
import { getBytes } from "ethers";
|
|
2
|
+
import { getEnvVariable } from "../../utils/env.js";
|
|
3
|
+
import { getEngineString, makeDefaultOPRFOperator } from "../../utils/index.js";
|
|
7
4
|
const toprf = async ({ maskedData, engine }, { logger }) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const PRIVATE_KEY_STR = getEnvVariable("TOPRF_SHARE_PRIVATE_KEY");
|
|
6
|
+
const PUBLIC_KEY_STR = getEnvVariable("TOPRF_SHARE_PUBLIC_KEY");
|
|
7
|
+
if (!PRIVATE_KEY_STR || !PUBLIC_KEY_STR) {
|
|
8
|
+
throw new Error("private/public keys not set. Cannot execute OPRF");
|
|
9
|
+
}
|
|
10
|
+
const PRIVATE_KEY = getBytes(PRIVATE_KEY_STR);
|
|
11
|
+
const PUBLIC_KEY = getBytes(PUBLIC_KEY_STR);
|
|
12
|
+
const engineStr = getEngineString(engine);
|
|
13
|
+
const operator = makeDefaultOPRFOperator("chacha20", engineStr, logger);
|
|
14
|
+
const res = await operator.evaluateOPRF(PRIVATE_KEY, maskedData);
|
|
15
|
+
return { ...res, publicKeyShare: PUBLIC_KEY };
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
toprf
|
|
19
19
|
};
|
|
20
|
-
exports.toprf = toprf;
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9wcmYuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmVyL2hhbmRsZXJzL3RvcHJmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLG1DQUErQjtBQUUvQixxQ0FBb0U7QUFDcEUsdUNBQThDO0FBRXZDLE1BQU0sS0FBSyxHQUF3QixLQUFLLEVBQzlDLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBRSxFQUN0QixFQUFFLE1BQU0sRUFBRSxFQUNULEVBQUU7SUFDSCxNQUFNLGVBQWUsR0FBRyxJQUFBLG9CQUFjLEVBQUMseUJBQXlCLENBQUMsQ0FBQTtJQUNqRSxNQUFNLGNBQWMsR0FBRyxJQUFBLG9CQUFjLEVBQUMsd0JBQXdCLENBQUMsQ0FBQTtJQUMvRCxJQUFHLENBQUMsZUFBZSxJQUFJLENBQUMsY0FBYyxFQUFFLENBQUM7UUFDeEMsTUFBTSxJQUFJLEtBQUssQ0FBQyxrREFBa0QsQ0FBQyxDQUFBO0lBQ3BFLENBQUM7SUFFRCxNQUFNLFdBQVcsR0FBRyxlQUFNLENBQUMsS0FBSyxDQUFDLFFBQVEsQ0FBQyxlQUFlLENBQUMsQ0FBQTtJQUMxRCxNQUFNLFVBQVUsR0FBRyxlQUFNLENBQUMsS0FBSyxDQUFDLFFBQVEsQ0FBQyxjQUFjLENBQUMsQ0FBQTtJQUV4RCxNQUFNLFNBQVMsR0FBRyxJQUFBLHVCQUFlLEVBQUMsTUFBTSxDQUFDLENBQUE7SUFDekMsTUFBTSxRQUFRLEdBQUcsSUFBQSwrQkFBdUIsRUFBQyxVQUFVLEVBQUUsU0FBUyxFQUFFLE1BQU0sQ0FBQyxDQUFBO0lBQ3ZFLE1BQU0sR0FBRyxHQUFHLE1BQU0sUUFBUSxDQUFDLFlBQVksQ0FBQyxXQUFXLEVBQUUsVUFBVSxDQUFDLENBQUE7SUFFaEUsT0FBTyxFQUFFLEdBQUcsR0FBRyxFQUFFLGNBQWMsRUFBRSxVQUFVLEVBQUUsQ0FBQTtBQUM5QyxDQUFDLENBQUE7QUFsQlksUUFBQSxLQUFLLFNBa0JqQiJ9
|
package/lib/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './utils/config-env';
|
|
2
|
-
export * from './create-server';
|
|
3
|
-
export * from './tunnels/make-tcp-tunnel';
|
|
4
|
-
export * from './utils/assert-valid-claim-request';
|
|
1
|
+
export * from './utils/config-env.ts';
|
|
2
|
+
export * from './create-server.ts';
|
|
3
|
+
export * from './tunnels/make-tcp-tunnel.ts';
|
|
4
|
+
export * from './utils/assert-valid-claim-request.ts';
|
package/lib/server/index.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
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("./utils/config-env"), exports);
|
|
18
|
-
__exportStar(require("./create-server"), exports);
|
|
19
|
-
__exportStar(require("./tunnels/make-tcp-tunnel"), exports);
|
|
20
|
-
__exportStar(require("./utils/assert-valid-claim-request"), exports);
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VydmVyL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxxREFBa0M7QUFDbEMsa0RBQStCO0FBQy9CLDREQUF5QztBQUN6QyxxRUFBa0QifQ==
|
|
1
|
+
export * from "./utils/config-env.js";
|
|
2
|
+
export * from "./create-server.js";
|
|
3
|
+
export * from "./tunnels/make-tcp-tunnel.js";
|
|
4
|
+
export * from "./utils/assert-valid-claim-request.js";
|
package/lib/server/socket.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { WebSocket as WS } from 'ws';
|
|
2
|
+
import type { TunnelMessage } from '#src/proto/api.ts';
|
|
3
|
+
import type { AcceptNewConnectionOpts, BGPListener, IAttestorServerSocket } from '#src/types/index.ts';
|
|
4
|
+
import { AttestorSocket } from '#src/utils/socket-base.ts';
|
|
5
5
|
export declare class AttestorServerSocket extends AttestorSocket implements IAttestorServerSocket {
|
|
6
|
-
sessionId: number;
|
|
7
|
-
bgpListener: BGPListener | undefined;
|
|
8
6
|
tunnels: IAttestorServerSocket['tunnels'];
|
|
7
|
+
readonly sessionId: number;
|
|
8
|
+
readonly bgpListener: BGPListener | undefined;
|
|
9
9
|
private constructor();
|
|
10
|
-
getTunnel(tunnelId: number): import("
|
|
10
|
+
getTunnel(tunnelId: number): import("#src/types/index.ts").Tunnel<import("#src/types/index.ts").TCPSocketProperties>;
|
|
11
11
|
removeTunnel(tunnelId: TunnelMessage['tunnelId']): void;
|
|
12
12
|
static acceptConnection(socket: WS, { req, logger, bgpListener }: AcceptNewConnectionOpts): Promise<AttestorServerSocket | undefined>;
|
|
13
13
|
}
|
package/lib/server/socket.js
CHANGED
|
@@ -1,114 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// forward packets to the appropriate tunnel
|
|
22
|
-
this.addEventListener('tunnel-message', handleTunnelMessage.bind(this));
|
|
23
|
-
// close all tunnels when the connection is terminated
|
|
24
|
-
// since this tunnel can no longer be written to
|
|
25
|
-
this.addEventListener('connection-terminated', () => {
|
|
26
|
-
for (const tunnelId in this.tunnels) {
|
|
27
|
-
const tunnel = this.tunnels[tunnelId];
|
|
28
|
-
void tunnel.close(new Error('WS session terminated'));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
getTunnel(tunnelId) {
|
|
1
|
+
import { promisify } from "util";
|
|
2
|
+
import { handleMessage } from "../client/utils/message-handler.js";
|
|
3
|
+
import { DEFAULT_RPC_TIMEOUT_MS } from "../config/index.js";
|
|
4
|
+
import { HANDLERS } from "../server/handlers/index.js";
|
|
5
|
+
import { getApm } from "../server/utils/apm.js";
|
|
6
|
+
import { getInitialMessagesFromQuery } from "../server/utils/generics.js";
|
|
7
|
+
import { AttestorError, generateSessionId } from "../utils/index.js";
|
|
8
|
+
import { AttestorSocket } from "../utils/socket-base.js";
|
|
9
|
+
class AttestorServerSocket extends AttestorSocket {
|
|
10
|
+
tunnels = {};
|
|
11
|
+
sessionId;
|
|
12
|
+
bgpListener;
|
|
13
|
+
constructor(socket, sessionId, bgpListener, logger) {
|
|
14
|
+
super(socket, {}, logger);
|
|
15
|
+
this.sessionId = sessionId;
|
|
16
|
+
this.bgpListener = bgpListener;
|
|
17
|
+
this.addEventListener("rpc-request", handleRpcRequest.bind(this));
|
|
18
|
+
this.addEventListener("tunnel-message", handleTunnelMessage.bind(this));
|
|
19
|
+
this.addEventListener("connection-terminated", () => {
|
|
20
|
+
for (const tunnelId in this.tunnels) {
|
|
33
21
|
const tunnel = this.tunnels[tunnelId];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
void tunnel.close(new Error("WS session terminated"));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
getTunnel(tunnelId) {
|
|
27
|
+
const tunnel = this.tunnels[tunnelId];
|
|
28
|
+
if (!tunnel) {
|
|
29
|
+
throw new AttestorError(
|
|
30
|
+
"ERROR_NOT_FOUND",
|
|
31
|
+
`Tunnel "${tunnelId}" not found`
|
|
32
|
+
);
|
|
41
33
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
34
|
+
return tunnel;
|
|
35
|
+
}
|
|
36
|
+
removeTunnel(tunnelId) {
|
|
37
|
+
delete this.tunnels[tunnelId];
|
|
38
|
+
}
|
|
39
|
+
static async acceptConnection(socket, { req, logger, bgpListener }) {
|
|
40
|
+
const bindSend = socket.send.bind(socket);
|
|
41
|
+
socket.send = promisify(bindSend);
|
|
42
|
+
const sessionId = generateSessionId();
|
|
43
|
+
logger = logger.child({ sessionId });
|
|
44
|
+
const client = new AttestorServerSocket(
|
|
45
|
+
socket,
|
|
46
|
+
sessionId,
|
|
47
|
+
bgpListener,
|
|
48
|
+
logger
|
|
49
|
+
);
|
|
50
|
+
try {
|
|
51
|
+
const initMsgs = getInitialMessagesFromQuery(req);
|
|
52
|
+
logger.trace(
|
|
53
|
+
{ initMsgs: initMsgs.length },
|
|
54
|
+
"new connection, validating..."
|
|
55
|
+
);
|
|
56
|
+
for (const msg of initMsgs) {
|
|
57
|
+
await handleMessage.call(client, msg);
|
|
58
|
+
}
|
|
59
|
+
logger.debug("connection accepted");
|
|
60
|
+
} catch (err) {
|
|
61
|
+
logger.error({ err }, "error in new connection");
|
|
62
|
+
if (client.isOpen) {
|
|
63
|
+
await client.terminateConnection(
|
|
64
|
+
err instanceof AttestorError ? err : AttestorError.badRequest(err.message)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
68
|
}
|
|
69
|
+
return client;
|
|
70
|
+
}
|
|
69
71
|
}
|
|
70
|
-
exports.AttestorServerSocket = AttestorServerSocket;
|
|
71
72
|
async function handleTunnelMessage({ data: { tunnelId, message } }) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error({ err, tunnelId }, 'error writing to tunnel');
|
|
79
|
-
}
|
|
73
|
+
try {
|
|
74
|
+
const tunnel = this.getTunnel(tunnelId);
|
|
75
|
+
await tunnel.write(message);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
this.logger?.error({ err, tunnelId }, "error writing to tunnel");
|
|
78
|
+
}
|
|
80
79
|
}
|
|
81
80
|
async function handleRpcRequest({ data: { data, requestId, respond, type } }) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
clearTimeout(timeout);
|
|
111
|
-
tx === null || tx === void 0 ? void 0 : tx.end();
|
|
112
|
-
}
|
|
81
|
+
const logger = this.logger.child({ rpc: type, requestId });
|
|
82
|
+
const apm = getApm();
|
|
83
|
+
const tx = apm?.startTransaction(type);
|
|
84
|
+
tx?.setLabel("requestId", requestId);
|
|
85
|
+
tx?.setLabel("sessionId", this.sessionId.toString());
|
|
86
|
+
const userId = this.metadata.auth?.data?.id;
|
|
87
|
+
if (userId) {
|
|
88
|
+
tx?.setLabel("authUserId", userId);
|
|
89
|
+
}
|
|
90
|
+
const timeout = setTimeout(() => {
|
|
91
|
+
logger.warn({ type, requestId }, "RPC took too long to respond");
|
|
92
|
+
}, DEFAULT_RPC_TIMEOUT_MS);
|
|
93
|
+
try {
|
|
94
|
+
logger.debug({ data }, "handling RPC request");
|
|
95
|
+
const handler = HANDLERS[type];
|
|
96
|
+
const res = await handler(data, { client: this, logger, tx });
|
|
97
|
+
respond(res);
|
|
98
|
+
logger.debug({ res }, "handled RPC request");
|
|
99
|
+
tx?.setOutcome("success");
|
|
100
|
+
} catch (err) {
|
|
101
|
+
logger.error({ err }, "error in RPC request");
|
|
102
|
+
respond(AttestorError.fromError(err));
|
|
103
|
+
tx?.setOutcome("failure");
|
|
104
|
+
apm?.captureError(err, { parent: tx });
|
|
105
|
+
} finally {
|
|
106
|
+
clearTimeout(timeout);
|
|
107
|
+
tx?.end();
|
|
108
|
+
}
|
|
113
109
|
}
|
|
114
|
-
|
|
110
|
+
export {
|
|
111
|
+
AttestorServerSocket
|
|
112
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CreateTunnelRequest } from '
|
|
2
|
-
import type { Logger } from '
|
|
3
|
-
import type { MakeTunnelFn, TCPSocketProperties } from '
|
|
1
|
+
import type { CreateTunnelRequest } from '#src/proto/api.ts';
|
|
2
|
+
import type { Logger } from '#src/types/index.ts';
|
|
3
|
+
import type { MakeTunnelFn, TCPSocketProperties } from '#src/types/index.ts';
|
|
4
4
|
type ExtraOpts = Omit<CreateTunnelRequest, 'id' | 'initialMessage'> & {
|
|
5
5
|
logger: Logger;
|
|
6
6
|
};
|
|
@@ -8,6 +8,8 @@ type ExtraOpts = Omit<CreateTunnelRequest, 'id' | 'initialMessage'> & {
|
|
|
8
8
|
* Builds a TCP tunnel to the given host and port.
|
|
9
9
|
* If a geolocation is provided -- an HTTPS proxy is used
|
|
10
10
|
* to connect to the host.
|
|
11
|
+
* If a proxySessionId is provided -- a static ip is used with HTTPS proxy
|
|
12
|
+
* across multiple requests with this same proxySessionId.
|
|
11
13
|
*
|
|
12
14
|
* HTTPS proxy essentially creates an opaque tunnel to the
|
|
13
15
|
* host using the CONNECT method. Any data can be sent through
|