diff --git a/preload.js b/preload.js index 50273123f..064f224c6 100644 --- a/preload.js +++ b/preload.js @@ -56,7 +56,6 @@ window.initialisedAPI = false; window.lokiFeatureFlags = { useOnionRequests: true, - useOnionRequestsV2: true, useFileOnionRequests: true, useFileOnionRequestsV2: true, // more compact encoding of files in response onionRequestHops: 3, @@ -448,7 +447,6 @@ if (config.environment.includes('test-integration')) { window.lokiFeatureFlags = { useOnionRequests: false, useFileOnionRequests: false, - useOnionRequestsV2: false, useRequestEncryptionKeyPair: false, }; /* eslint-disable global-require, import/no-extraneous-dependencies */ diff --git a/ts/session/snode_api/onions.ts b/ts/session/snode_api/onions.ts index aa7b8f9c7..20e526d2b 100644 --- a/ts/session/snode_api/onions.ts +++ b/ts/session/snode_api/onions.ts @@ -36,32 +36,12 @@ async function encryptForPubKey(pubKeyX25519hex: string, reqObj: any): Promise, destCtx: DestinationContext, targetED25519Hex: string, - // whether to use the new "semi-binary" protocol - useV2: boolean, finalRelayOptions?: FinalRelayOptions, id = '' ) { @@ -143,7 +106,7 @@ async function buildOnionCtxs( const relayingToFinalDestination = i === firstPos; // if last position if (relayingToFinalDestination && finalRelayOptions) { - let target = useV2 ? '/loki/v2/lsrpc' : '/loki/v1/lsrpc'; + let target = '/loki/v2/lsrpc'; const isCallToPn = finalRelayOptions?.host === 'live.apns.getsession.org'; if (!isCallToPn && window.lokiFeatureFlags.useFileOnionRequestsV2) { @@ -169,7 +132,7 @@ async function buildOnionCtxs( pubkeyHex = nodePath[i + 1].pubkey_ed25519; if (!pubkeyHex) { log.error( - `loki_rpc:::makeOnionRequest ${id} - no ed25519 for`, + `loki_rpc:::buildOnionRequest ${id} - no ed25519 for`, nodePath[i + 1], 'path node', i + 1 @@ -182,12 +145,15 @@ async function buildOnionCtxs( }; } try { - const encryptFn = useV2 ? encryptForRelayV2 : encryptForRelay; // eslint-disable-next-line no-await-in-loop - const ctx = await encryptFn(nodePath[i].pubkey_x25519, dest, ctxes[ctxes.length - 1]); + const ctx = await encryptForRelayV2(nodePath[i].pubkey_x25519, dest, ctxes[ctxes.length - 1]); ctxes.push(ctx); } catch (e) { - log.error(`loki_rpc:::makeOnionRequest ${id} - encryptForRelay failure`, e.code, e.message); + log.error( + `loki_rpc:::buildOnionRequest ${id} - encryptForRelayV2 failure`, + e.code, + e.message + ); throw e; } } @@ -197,30 +163,19 @@ async function buildOnionCtxs( // we just need the targetNode.pubkey_ed25519 for the encryption // targetPubKey is ed25519 if snode is the target -async function makeOnionRequest( +async function buildOnionRequest( nodePath: Array, destCtx: DestinationContext, targetED25519Hex: string, - // whether to use the new (v2) protocol - useV2: boolean, finalRelayOptions?: FinalRelayOptions, id = '' ) { - const ctxes = await buildOnionCtxs( - nodePath, - destCtx, - targetED25519Hex, - useV2, - finalRelayOptions, - id - ); + const ctxes = await buildOnionCtxs(nodePath, destCtx, targetED25519Hex, finalRelayOptions, id); const guardCtx = ctxes[ctxes.length - 1]; // last ctx - const payload = useV2 ? makeGuardPayloadV2(guardCtx) : makeGuardPayload(guardCtx); - // all these requests should use AesGcm - return payload; + return makeGuardPayloadV2(guardCtx); } // Process a response as it arrives from `fetch`, handling @@ -427,13 +382,11 @@ const sendOnionRequest = async ( options.headers = {}; } - const useV2 = window.lokiFeatureFlags.useOnionRequestsV2; - const isLsrpc = !!finalRelayOptions; let destCtx: DestinationContext; try { - if (useV2 && !isLsrpc) { + if (!isLsrpc) { const body = options.body || ''; delete options.body; @@ -460,11 +413,10 @@ const sendOnionRequest = async ( throw e; } - const payload = await makeOnionRequest( + const payload = await buildOnionRequest( nodePath, destCtx, targetEd25519hex as string, // FIXME - useV2, finalRelayOptions, id ); @@ -477,7 +429,7 @@ const sendOnionRequest = async ( abortSignal, }; - const target = useV2 ? '/onion_req/v2' : '/onion_req'; + const target = '/onion_req/v2'; const guardUrl = `https://${nodePath[0].ip}:${nodePath[0].port}${target}`; // no logs for that one as we do need to call insecureNodeFetch to our guardNode diff --git a/ts/window.d.ts b/ts/window.d.ts index 183b5b095..b9e6ce240 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -54,7 +54,6 @@ declare global { log: any; lokiFeatureFlags: { useOnionRequests: boolean; - useOnionRequestsV2: boolean; useFileOnionRequests: boolean; useFileOnionRequestsV2: boolean; onionRequestHops: number;