From bbd43b6e38f7424ee555194a70e49e237eff4df0 Mon Sep 17 00:00:00 2001 From: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> Date: Wed, 26 Jul 2023 15:15:05 -0700 Subject: [PATCH] Implement read support for CDN3 --- app/main.ts | 1 + config/default.json | 3 ++- config/production.json | 3 ++- ts/textsecure/WebAPI.ts | 5 ++++- ts/types/RendererConfig.ts | 1 + ts/windows/main/phase2-dependencies.ts | 1 + 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/main.ts b/app/main.ts index a966f92f8..312c02a49 100644 --- a/app/main.ts +++ b/app/main.ts @@ -2276,6 +2276,7 @@ ipc.on('get-config', async event => { artCreatorUrl: config.get('artCreatorUrl'), cdnUrl0: config.get('cdn').get('0'), cdnUrl2: config.get('cdn').get('2'), + cdnUrl3: config.get('cdn').get('3'), certificateAuthority: config.get('certificateAuthority'), environment: !isTestEnvironment(getEnvironment()) && ciMode diff --git a/config/default.json b/config/default.json index 49648551b..392d868d1 100644 --- a/config/default.json +++ b/config/default.json @@ -5,7 +5,8 @@ "directoryMRENCLAVE": "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57", "cdn": { "0": "https://cdn-staging.signal.org", - "2": "https://cdn2-staging.signal.org" + "2": "https://cdn2-staging.signal.org", + "3": "https://cdn3-staging.signal.org" }, "contentProxyUrl": "http://contentproxy.signal.org:443", "updatesUrl": "https://updates2.signal.org/desktop", diff --git a/config/production.json b/config/production.json index 128952198..72919ab13 100644 --- a/config/production.json +++ b/config/production.json @@ -5,7 +5,8 @@ "directoryMRENCLAVE": "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57", "cdn": { "0": "https://cdn.signal.org", - "2": "https://cdn2.signal.org" + "2": "https://cdn2.signal.org", + "3": "https://cdn3.signal.org" }, "artCreatorUrl": "https://create.signal.art", "challengeUrl": "https://signalcaptchas.org/challenge/generate.html", diff --git a/ts/textsecure/WebAPI.ts b/ts/textsecure/WebAPI.ts index e8543bf3d..084776be7 100644 --- a/ts/textsecure/WebAPI.ts +++ b/ts/textsecure/WebAPI.ts @@ -1203,6 +1203,9 @@ export function initialize({ if (!isString(cdnUrlObject['2'])) { throw new Error('WebAPI.initialize: Missing CDN 2 configuration'); } + if (!isString(cdnUrlObject['3'])) { + throw new Error('WebAPI.initialize: Missing CDN 3 configuration'); + } if (!isString(certificateAuthority)) { throw new Error('WebAPI.initialize: Invalid certificateAuthority'); } @@ -2655,7 +2658,7 @@ export function initialize({ const abortController = new AbortController(); const cdnUrl = isNumber(cdnNumber) - ? cdnUrlObject[cdnNumber] || cdnUrlObject['0'] + ? cdnUrlObject[cdnNumber] ?? cdnUrlObject['0'] : cdnUrlObject['0']; // This is going to the CDN, not the service, so we use _outerAjax const stream = await _outerAjax(`${cdnUrl}/attachments/${cdnKey}`, { diff --git a/ts/types/RendererConfig.ts b/ts/types/RendererConfig.ts index 8c2420554..5d9579621 100644 --- a/ts/types/RendererConfig.ts +++ b/ts/types/RendererConfig.ts @@ -33,6 +33,7 @@ export const rendererConfigSchema = z.object({ buildExpiration: z.number(), cdnUrl0: configRequiredStringSchema, cdnUrl2: configRequiredStringSchema, + cdnUrl3: configRequiredStringSchema, challengeUrl: configRequiredStringSchema, certificateAuthority: configRequiredStringSchema, contentProxyUrl: configRequiredStringSchema, diff --git a/ts/windows/main/phase2-dependencies.ts b/ts/windows/main/phase2-dependencies.ts index 136cbdeaf..45403caed 100644 --- a/ts/windows/main/phase2-dependencies.ts +++ b/ts/windows/main/phase2-dependencies.ts @@ -31,6 +31,7 @@ window.WebAPI = window.textsecure.WebAPI.initialize({ cdnUrlObject: { 0: config.cdnUrl0, 2: config.cdnUrl2, + 3: config.cdnUrl3, }, certificateAuthority: config.certificateAuthority, contentProxyUrl: config.contentProxyUrl,