@reclaimprotocol/attestor-core 5.0.4 → 5.0.5

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.
Files changed (122) hide show
  1. package/LICENSE +660 -660
  2. package/browser/resources/attestor-browser.min.mjs +31 -31
  3. package/lib/server/tee/acme-http-server.d.ts +13 -0
  4. package/lib/server/tee/attestation-generate.d.ts +29 -0
  5. package/lib/server/tee/bootstrap.d.ts +11 -0
  6. package/lib/server/tee/cert-manager.d.ts +24 -0
  7. package/lib/server/tee/cloud-logging.d.ts +23 -0
  8. package/lib/server/tee/secret-loader.d.ts +10 -0
  9. package/lib/server/tee/secret-manager.d.ts +3 -0
  10. package/lib/utils/gcp-attestation.d.ts +23 -0
  11. package/package.json +3 -3
  12. package/lib/avs/abis/avsDirectoryABI.js +0 -340
  13. package/lib/avs/abis/delegationABI.js +0 -1
  14. package/lib/avs/abis/registryABI.js +0 -725
  15. package/lib/avs/client/create-claim-on-avs.js +0 -138
  16. package/lib/avs/config.js +0 -20
  17. package/lib/avs/contracts/ReclaimServiceManager.js +0 -1
  18. package/lib/avs/contracts/common.js +0 -1
  19. package/lib/avs/contracts/factories/ReclaimServiceManager__factory.js +0 -1169
  20. package/lib/avs/contracts/factories/index.js +0 -4
  21. package/lib/avs/contracts/index.js +0 -2
  22. package/lib/avs/types/index.js +0 -1
  23. package/lib/avs/utils/contracts.js +0 -33
  24. package/lib/avs/utils/register.js +0 -78
  25. package/lib/avs/utils/tasks.js +0 -40
  26. package/lib/client/create-claim.js +0 -433
  27. package/lib/client/index.js +0 -3
  28. package/lib/client/tunnels/make-rpc-tcp-tunnel.js +0 -51
  29. package/lib/client/tunnels/make-rpc-tls-tunnel.js +0 -131
  30. package/lib/client/utils/attestor-pool.js +0 -25
  31. package/lib/client/utils/client-socket.js +0 -98
  32. package/lib/client/utils/message-handler.js +0 -87
  33. package/lib/config/index.js +0 -44
  34. package/lib/external-rpc/benchmark.js +0 -69
  35. package/lib/external-rpc/event-bus.js +0 -14
  36. package/lib/external-rpc/handle-incoming-msg.js +0 -233
  37. package/lib/external-rpc/jsc-polyfills/1.js +0 -82
  38. package/lib/external-rpc/jsc-polyfills/2.js +0 -20
  39. package/lib/external-rpc/jsc-polyfills/event.js +0 -14
  40. package/lib/external-rpc/jsc-polyfills/index.js +0 -2
  41. package/lib/external-rpc/jsc-polyfills/ws.js +0 -81
  42. package/lib/external-rpc/setup-browser.js +0 -33
  43. package/lib/external-rpc/setup-jsc.js +0 -22
  44. package/lib/external-rpc/types.js +0 -1
  45. package/lib/external-rpc/utils.js +0 -100
  46. package/lib/external-rpc/zk.js +0 -63
  47. package/lib/mechain/abis/governanceABI.js +0 -458
  48. package/lib/mechain/abis/taskABI.js +0 -509
  49. package/lib/mechain/client/create-claim-on-mechain.js +0 -28
  50. package/lib/mechain/client/index.js +0 -1
  51. package/lib/mechain/constants/index.js +0 -3
  52. package/lib/mechain/index.js +0 -2
  53. package/lib/mechain/types/index.js +0 -1
  54. package/lib/proto/api.js +0 -4273
  55. package/lib/proto/tee-bundle.js +0 -1316
  56. package/lib/providers/http/index.js +0 -658
  57. package/lib/providers/http/patch-parse5-tree.js +0 -33
  58. package/lib/providers/http/utils.js +0 -324
  59. package/lib/providers/index.js +0 -4
  60. package/lib/scripts/fetch-ec2-metadata.d.ts +0 -1
  61. package/lib/server/create-server.js +0 -103
  62. package/lib/server/handlers/claimTeeBundle.js +0 -252
  63. package/lib/server/handlers/claimTunnel.js +0 -73
  64. package/lib/server/handlers/completeClaimOnChain.js +0 -22
  65. package/lib/server/handlers/createClaimOnChain.js +0 -26
  66. package/lib/server/handlers/createTaskOnMechain.js +0 -47
  67. package/lib/server/handlers/createTunnel.js +0 -93
  68. package/lib/server/handlers/disconnectTunnel.js +0 -5
  69. package/lib/server/handlers/fetchCertificateBytes.js +0 -41
  70. package/lib/server/handlers/index.js +0 -22
  71. package/lib/server/handlers/init.js +0 -32
  72. package/lib/server/handlers/toprf.js +0 -16
  73. package/lib/server/index.js +0 -4
  74. package/lib/server/socket.js +0 -109
  75. package/lib/server/tunnels/make-tcp-tunnel.js +0 -177
  76. package/lib/server/utils/apm.js +0 -36
  77. package/lib/server/utils/assert-valid-claim-request.js +0 -204
  78. package/lib/server/utils/config-env.js +0 -4
  79. package/lib/server/utils/dns.js +0 -18
  80. package/lib/server/utils/gcp-attestation.js +0 -289
  81. package/lib/server/utils/generics.js +0 -51
  82. package/lib/server/utils/iso.js +0 -256
  83. package/lib/server/utils/keep-alive.js +0 -38
  84. package/lib/server/utils/nitro-attestation.js +0 -325
  85. package/lib/server/utils/process-handshake.js +0 -215
  86. package/lib/server/utils/proxy-session.js +0 -6
  87. package/lib/server/utils/tee-oprf-mpc-verification.js +0 -90
  88. package/lib/server/utils/tee-oprf-verification.js +0 -174
  89. package/lib/server/utils/tee-transcript-reconstruction.js +0 -187
  90. package/lib/server/utils/tee-verification.js +0 -421
  91. package/lib/server/utils/validation.js +0 -38
  92. package/lib/types/bgp.js +0 -1
  93. package/lib/types/claims.js +0 -1
  94. package/lib/types/client.js +0 -1
  95. package/lib/types/general.js +0 -1
  96. package/lib/types/handlers.js +0 -1
  97. package/lib/types/index.js +0 -10
  98. package/lib/types/providers.gen.js +0 -10
  99. package/lib/types/providers.js +0 -1
  100. package/lib/types/rpc.js +0 -1
  101. package/lib/types/signatures.js +0 -1
  102. package/lib/types/tunnel.js +0 -1
  103. package/lib/types/zk.js +0 -1
  104. package/lib/utils/auth.js +0 -59
  105. package/lib/utils/b64-json.js +0 -17
  106. package/lib/utils/bgp-listener.js +0 -119
  107. package/lib/utils/claims.js +0 -99
  108. package/lib/utils/env.js +0 -15
  109. package/lib/utils/error.js +0 -50
  110. package/lib/utils/generics.js +0 -317
  111. package/lib/utils/http-parser.js +0 -246
  112. package/lib/utils/index.js +0 -13
  113. package/lib/utils/logger.js +0 -91
  114. package/lib/utils/prepare-packets.js +0 -62
  115. package/lib/utils/redactions.js +0 -148
  116. package/lib/utils/retries.js +0 -24
  117. package/lib/utils/signatures/eth.js +0 -29
  118. package/lib/utils/signatures/index.js +0 -7
  119. package/lib/utils/socket-base.js +0 -90
  120. package/lib/utils/tls.js +0 -58
  121. package/lib/utils/ws.js +0 -22
  122. package/lib/utils/zk.js +0 -577
@@ -1,177 +0,0 @@
1
- import { HttpsProxyAgent } from 'https-proxy-agent';
2
- import { Socket } from 'net';
3
- import { CONNECTION_TIMEOUT_MS } from "../../config/index.js";
4
- import { resolveHostnames } from "../utils/dns.js";
5
- import { isValidCountryCode } from "../utils/iso.js";
6
- import { isValidProxySessionId } from "../utils/proxy-session.js";
7
- import { getEnvVariable } from "../../utils/env.js";
8
- import { AttestorError } from "../../utils/index.js";
9
- const HTTPS_PROXY_URL = getEnvVariable('HTTPS_PROXY_URL');
10
- /**
11
- * Builds a TCP tunnel to the given host and port.
12
- * If a geolocation is provided -- an HTTPS proxy is used
13
- * to connect to the host.
14
- * If a proxySessionId is provided -- a static ip is used with HTTPS proxy
15
- * across multiple requests with this same proxySessionId.
16
- *
17
- * HTTPS proxy essentially creates an opaque tunnel to the
18
- * host using the CONNECT method. Any data can be sent through
19
- * this tunnel to the end host.
20
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT
21
- *
22
- * The tunnel also retains a transcript of all messages sent and received.
23
- */
24
- export const makeTcpTunnel = async ({ onClose, onMessage, logger, ...opts }) => {
25
- const transcript = [];
26
- const socket = await connectTcp({ ...opts, logger });
27
- let closed = false;
28
- socket.on('data', message => {
29
- if (closed) {
30
- logger.warn('socket is closed, dropping message');
31
- return;
32
- }
33
- onMessage?.(message);
34
- transcript.push({ sender: 'server', message });
35
- });
36
- // socket.once('error', onSocketClose)
37
- socket.once('close', () => onSocketClose(undefined));
38
- return {
39
- socket,
40
- transcript,
41
- createRequest: opts,
42
- async write(data) {
43
- transcript.push({ sender: 'client', message: data });
44
- await new Promise((resolve, reject) => {
45
- socket.write(data, err => {
46
- if (err) {
47
- reject(err);
48
- }
49
- else {
50
- resolve();
51
- }
52
- });
53
- });
54
- },
55
- close(err) {
56
- if (closed) {
57
- return;
58
- }
59
- socket.destroy(err);
60
- }
61
- };
62
- function onSocketClose(err) {
63
- if (closed) {
64
- return;
65
- }
66
- logger.debug({ err }, 'closing socket');
67
- closed = true;
68
- onClose?.(err);
69
- onClose = undefined;
70
- }
71
- };
72
- async function connectTcp({ host, port, geoLocation, proxySessionId, logger }) {
73
- let connectTimeout;
74
- let socket;
75
- try {
76
- await new Promise(async (resolve, reject) => {
77
- try {
78
- // add a timeout to ensure the connection doesn't hang
79
- // and cause our gateway to send out a 504
80
- connectTimeout = setTimeout(() => reject(new AttestorError('ERROR_NETWORK_ERROR', 'Server connection timed out')), CONNECTION_TIMEOUT_MS);
81
- socket = await getSocket({
82
- host,
83
- port,
84
- geoLocation,
85
- proxySessionId,
86
- logger
87
- });
88
- socket.once('connect', resolve);
89
- socket.once('error', reject);
90
- socket.once('end', () => (reject(new AttestorError('ERROR_NETWORK_ERROR', 'connection closed'))));
91
- }
92
- catch (err) {
93
- reject(err);
94
- }
95
- });
96
- logger.debug({ addr: `${host}:${port}` }, 'connected');
97
- return socket;
98
- }
99
- catch (err) {
100
- socket?.end();
101
- throw err;
102
- }
103
- finally {
104
- clearTimeout(connectTimeout);
105
- }
106
- }
107
- async function getSocket(opts) {
108
- const { logger } = opts;
109
- try {
110
- return await _getSocket(opts);
111
- }
112
- catch (err) {
113
- // see if the proxy is blocking the connection
114
- // due to their own arbitrary rules,
115
- // if so -- we resolve hostname first &
116
- // connect directly via address to
117
- // avoid proxy knowing which host we're connecting to
118
- if (!(err instanceof AttestorError)
119
- || err.data?.code !== 403) {
120
- throw err;
121
- }
122
- const addrs = await resolveHostnames(opts.host);
123
- logger.info({ addrs, host: opts.host }, 'failed to connect due to restricted IP, trying via raw addr');
124
- for (const addr of addrs) {
125
- try {
126
- return await _getSocket({ ...opts, host: addr });
127
- }
128
- catch (err) {
129
- logger.error({ addr, err }, 'failed to connect to host');
130
- }
131
- }
132
- throw err;
133
- }
134
- }
135
- async function _getSocket({ host, port, geoLocation, proxySessionId, logger }) {
136
- const socket = new Socket();
137
- if ((proxySessionId || geoLocation) && !HTTPS_PROXY_URL) {
138
- logger.warn({ geoLocation, proxySessionId }, 'geoLocation or proxySessionId provided but no proxy URL found');
139
- geoLocation = '';
140
- proxySessionId = '';
141
- }
142
- if (!geoLocation && !proxySessionId) {
143
- socket.connect({ host, port, });
144
- return socket;
145
- }
146
- if (!isValidCountryCode(geoLocation)) {
147
- throw AttestorError.badRequest(`Geolocation "${geoLocation}" is invalid. Must be 2 letter ISO country code`, { geoLocation });
148
- }
149
- if (proxySessionId && !isValidProxySessionId(proxySessionId)) {
150
- throw AttestorError.badRequest(`proxySessionId "${proxySessionId}" is invalid. Must be a lowercase alphanumeric string of length 8-14 characters. eg. "mystring12345", "something1234".`, { proxySessionId });
151
- }
152
- const agentUrl = HTTPS_PROXY_URL.replace('{{geoLocation}}', geoLocation?.toLowerCase() || '').replace('{{proxySessionId}}', proxySessionId ? `-session-${proxySessionId}` : '');
153
- const agent = new HttpsProxyAgent(agentUrl);
154
- const waitForProxyRes = new Promise(resolve => {
155
- // @ts-ignore
156
- socket.once('proxyConnect', resolve);
157
- });
158
- const proxySocket = await agent.connect(
159
- // ignore, because https-proxy-agent
160
- // expects an http request object
161
- // @ts-ignore
162
- socket, { host, port, timeout: CONNECTION_TIMEOUT_MS });
163
- const res = await waitForProxyRes;
164
- if (res.statusCode !== 200) {
165
- logger.error({ geoLocation, proxySessionId, res }, 'Proxy geo location or session id failed');
166
- throw new AttestorError('ERROR_PROXY_ERROR', `Proxy via ${geoLocation ? `geo location "${geoLocation}"` : ''}${geoLocation && proxySessionId ? ', or ' : ''}${proxySessionId ? `session id "${proxySessionId}"` : ''} failed with status code: ${res.statusCode}, message: ${res.statusText}`, {
167
- code: res.statusCode,
168
- message: res.statusText,
169
- });
170
- }
171
- process.nextTick(() => {
172
- // ensure connect event is emitted
173
- // so it can be captured by the caller
174
- proxySocket.emit('connect');
175
- });
176
- return proxySocket;
177
- }
@@ -1,36 +0,0 @@
1
- import ElasticAPM from 'elastic-apm-node';
2
- import { getEnvVariable } from "../../utils/env.js";
3
- import { logger } from "../../utils/logger.js";
4
- let apm;
5
- /**
6
- * Initialises the APM agent if required,
7
- * and returns it.
8
- * If ELASTIC_APM_SERVER_URL & ELASTIC_APM_SECRET_TOKEN
9
- * are not set will return undefined
10
- *
11
- * Utilises the standard env variables mentioned
12
- * here: https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-stack.html#custom-stack-advanced-configuration
13
- */
14
- export function getApm() {
15
- if (!getEnvVariable('ELASTIC_APM_SERVER_URL')
16
- || !getEnvVariable('ELASTIC_APM_SECRET_TOKEN')) {
17
- logger.info('ELASTIC_APM_SERVER_URL or ELASTIC_APM_SECRET_TOKEN not found'
18
- + ' in env, APM agent not initialised');
19
- return undefined;
20
- }
21
- if (!apm) {
22
- const sampleRate = +(getEnvVariable('ELASTIC_APM_SAMPLE_RATE')
23
- || '0.1');
24
- apm = ElasticAPM.start({
25
- serviceName: 'reclaim_attestor',
26
- serviceVersion: '4.0.0',
27
- transactionSampleRate: sampleRate,
28
- instrumentIncomingHTTPRequests: true,
29
- usePathAsTransactionName: true,
30
- instrument: true,
31
- captureHeaders: true,
32
- });
33
- logger.info('initialised APM agent');
34
- }
35
- return apm;
36
- }
@@ -1,204 +0,0 @@
1
- import { areUint8ArraysEqual, concatenateUint8Arrays } from '@reclaimprotocol/tls';
2
- import { ClaimTunnelRequest, TranscriptMessageSenderType, ZKProofEngine } from "../../proto/api.js";
3
- import { providers } from "../../providers/index.js";
4
- import { niceParseJsonObject } from "./generics.js";
5
- import { processHandshake } from "./process-handshake.js";
6
- import { assertValidateProviderParams } from "./validation.js";
7
- import { AttestorError, canonicalStringify, decryptDirect, extractApplicationDataFromTranscript, hashProviderParams, SIGNATURES, verifyZkPacket } from "../../utils/index.js";
8
- /**
9
- * Asserts that the claim request is valid.
10
- *
11
- * 1. We begin by verifying the signature of the claim request.
12
- * 2. Next, we produce the transcript of the TLS exchange
13
- * from the proofs provided by the client.
14
- * 3. We then pull the provider the client is trying to claim
15
- * from
16
- * 4. We then use the provider's verification function to verify
17
- * whether the claim is valid.
18
- *
19
- * If any of these steps fail, we throw an error.
20
- */
21
- export async function assertValidClaimRequest(request, metadata, logger) {
22
- const { data, signatures: { requestSignature } = {}, zkEngine, fixedServerIV, fixedClientIV } = request;
23
- if (!data) {
24
- throw new AttestorError('ERROR_INVALID_CLAIM', 'No info provided on claim request');
25
- }
26
- if (!requestSignature?.length) {
27
- throw new AttestorError('ERROR_INVALID_CLAIM', 'No signature provided on claim request');
28
- }
29
- // verify request signature
30
- const serialisedReq = ClaimTunnelRequest
31
- .encode({ ...request, signatures: undefined })
32
- .finish();
33
- const { verify: verifySig } = SIGNATURES[metadata.signatureType];
34
- const verified = await verifySig(serialisedReq, requestSignature, data.owner);
35
- if (!verified) {
36
- throw new AttestorError('ERROR_INVALID_CLAIM', 'Invalid signature on claim request');
37
- }
38
- const receipt = await decryptTranscript(request.transcript, logger, zkEngine === ZKProofEngine.ZK_ENGINE_GNARK ? 'gnark' : 'snarkjs', fixedServerIV, fixedClientIV);
39
- const reqHost = request.request?.host;
40
- if (receipt.hostname !== reqHost) {
41
- throw new Error(`Expected server name ${reqHost}, got ${receipt.hostname}`);
42
- }
43
- // get all application data messages
44
- const applData = extractApplicationDataFromTranscript(receipt);
45
- const newData = await assertValidProviderTranscript(applData, data, logger, { version: metadata.clientVersion });
46
- if (newData !== data) {
47
- logger.info({ newData }, 'updated claim info');
48
- }
49
- return newData;
50
- }
51
- /**
52
- * Verify that the transcript contains a valid claim
53
- * for the provider.
54
- */
55
- export async function assertValidProviderTranscript(applData, info, logger, providerCtx) {
56
- const providerName = info.provider;
57
- const provider = providers[providerName];
58
- if (!provider) {
59
- throw new AttestorError('ERROR_INVALID_CLAIM', `Unsupported provider: ${providerName}`);
60
- }
61
- const params = niceParseJsonObject(info.parameters, 'params');
62
- const ctx = niceParseJsonObject(info.context, 'context');
63
- assertValidateProviderParams(providerName, params);
64
- const rslt = await provider.assertValidProviderReceipt({
65
- receipt: applData,
66
- params,
67
- logger,
68
- ctx: providerCtx
69
- });
70
- ctx.providerHash = hashProviderParams(params);
71
- const extractedParameters = rslt?.extractedParameters || {};
72
- if (Object.keys(extractedParameters).length) {
73
- ctx.extractedParameters = extractedParameters;
74
- }
75
- info.context = canonicalStringify(ctx) ?? '';
76
- return info;
77
- }
78
- /**
79
- * Verify that the transcript provided by the client
80
- * matches the transcript of the tunnel, the server
81
- * has created.
82
- */
83
- export function assertTranscriptsMatch(clientTranscript, tunnelTranscript) {
84
- const clientSends = concatenateUint8Arrays(clientTranscript
85
- .filter(m => m.sender === TranscriptMessageSenderType.TRANSCRIPT_MESSAGE_SENDER_TYPE_CLIENT)
86
- .map(m => m.message));
87
- const tunnelSends = concatenateUint8Arrays(tunnelTranscript
88
- .filter(m => m.sender === 'client')
89
- .map(m => m.message));
90
- if (!areUint8ArraysEqual(clientSends, tunnelSends)) {
91
- throw AttestorError.badRequest('Outgoing messages from client do not match the tunnel transcript');
92
- }
93
- const clientRecvs = concatenateUint8Arrays(clientTranscript
94
- .filter(m => m.sender === TranscriptMessageSenderType.TRANSCRIPT_MESSAGE_SENDER_TYPE_SERVER)
95
- .map(m => m.message));
96
- const tunnelRecvs = concatenateUint8Arrays(tunnelTranscript
97
- .filter(m => m.sender === 'server')
98
- .map(m => m.message))
99
- // We only need to compare the first N messages
100
- // that the client claims to have received
101
- // the rest are not relevant -- so even if they're
102
- // not present in the tunnel transcript, it's fine
103
- .slice(0, clientRecvs.length);
104
- if (!areUint8ArraysEqual(clientRecvs, tunnelRecvs)) {
105
- throw AttestorError.badRequest('Incoming messages from server do not match the tunnel transcript');
106
- }
107
- }
108
- export async function decryptTranscript(transcript, logger, zkEngine, serverIV, clientIV) {
109
- const { tlsVersion, cipherSuite, hostname, nextMsgIndex } = await processHandshake(transcript, logger);
110
- // TLS 1.3 has already one record encrypted at this point
111
- let clientRecordNumber = tlsVersion === 'TLS1_3' ? -1 : 0;
112
- let serverRecordNumber = clientRecordNumber;
113
- transcript = transcript.slice(nextMsgIndex);
114
- const overshotMap = {};
115
- const decryptedTranscript = [];
116
- for (const [i, { sender, message, reveal: { zkReveal, directReveal } = {} }] of transcript.entries()) {
117
- try {
118
- //start with first message after last handshake message
119
- await decryptMessage(sender, message, directReveal, zkReveal, i);
120
- }
121
- catch (error) {
122
- const err = new AttestorError('ERROR_INVALID_CLAIM', `error in handling packet at idx ${i}: ${error}`, { packetIdx: i, error });
123
- if (error.stack) {
124
- err.stack = error.stack;
125
- }
126
- throw err;
127
- }
128
- }
129
- return {
130
- transcript: decryptedTranscript,
131
- hostname: hostname,
132
- tlsVersion: tlsVersion,
133
- };
134
- async function decryptMessage(sender, message, directReveal, zkReveal, i) {
135
- const isServer = sender === TranscriptMessageSenderType
136
- .TRANSCRIPT_MESSAGE_SENDER_TYPE_SERVER;
137
- const recordHeader = message.slice(0, 5);
138
- const content = getWithoutHeader(message);
139
- if (isServer) {
140
- serverRecordNumber++;
141
- }
142
- else {
143
- clientRecordNumber++;
144
- }
145
- let redacted = true;
146
- let plaintext = undefined;
147
- let plaintextLength;
148
- if (directReveal?.key?.length) {
149
- const result = await decryptDirect(directReveal, cipherSuite, recordHeader, tlsVersion, content);
150
- plaintext = result.plaintext;
151
- redacted = false;
152
- plaintextLength = plaintext.length;
153
- }
154
- else if (zkReveal?.proofs?.length) {
155
- const iv = sender === TranscriptMessageSenderType
156
- .TRANSCRIPT_MESSAGE_SENDER_TYPE_SERVER
157
- ? serverIV
158
- : clientIV;
159
- const recordNumber = isServer
160
- ? serverRecordNumber
161
- : clientRecordNumber;
162
- const result = await verifyZkPacket({
163
- ciphertext: content,
164
- zkReveal,
165
- iv,
166
- recordNumber,
167
- toprfOvershotNullifier: overshotMap[i]?.data,
168
- getNextPacket(overshot) {
169
- const nextIdx = transcript
170
- .findIndex((t, j) => t.sender === sender && j > i);
171
- if (nextIdx < 0) {
172
- return;
173
- }
174
- overshotMap[nextIdx] = { data: overshot };
175
- return getWithoutHeader(transcript[nextIdx].message);
176
- },
177
- logger,
178
- cipherSuite,
179
- zkEngine: zkEngine,
180
- });
181
- plaintext = result.redactedPlaintext;
182
- redacted = false;
183
- plaintextLength = plaintext.length;
184
- }
185
- else {
186
- plaintext = content;
187
- plaintextLength = plaintext.length;
188
- }
189
- decryptedTranscript.push({
190
- sender: sender === TranscriptMessageSenderType
191
- .TRANSCRIPT_MESSAGE_SENDER_TYPE_CLIENT
192
- ? 'client'
193
- : 'server',
194
- redacted,
195
- message: plaintext,
196
- recordHeader,
197
- plaintextLength,
198
- });
199
- }
200
- }
201
- export function getWithoutHeader(message) {
202
- // strip the record header (xx 03 03 xx xx)
203
- return message.slice(5);
204
- }
@@ -1,4 +0,0 @@
1
- import { config } from 'dotenv';
2
- import { getEnvVariable } from "../../utils/env.js";
3
- const nodeEnv = getEnvVariable('NODE_ENV') || 'development';
4
- config({ path: `.env.${nodeEnv}` });
@@ -1,18 +0,0 @@
1
- import { resolve, setServers } from 'dns';
2
- import { DNS_SERVERS } from "../../config/index.js";
3
- setDnsServers();
4
- export async function resolveHostnames(hostname) {
5
- return new Promise((_resolve, reject) => {
6
- resolve(hostname, (err, addresses) => {
7
- if (err) {
8
- reject(new Error(`Could not resolve hostname: ${hostname}, ${err.message}`));
9
- }
10
- else {
11
- _resolve(addresses);
12
- }
13
- });
14
- });
15
- }
16
- function setDnsServers() {
17
- setServers(DNS_SERVERS);
18
- }