diff --git a/.storybook/preview-head.html b/.storybook/preview-head.html
index 6d16920b164e..159d81782828 100644
--- a/.storybook/preview-head.html
+++ b/.storybook/preview-head.html
@@ -49,6 +49,7 @@
OS: {
hasCustomTitleBar: () => false,
},
+ config: {},
};
window.ConversationController = window.ConversationController || {};
diff --git a/app/main.ts b/app/main.ts
index 301fa3e85a47..55266627d78d 100644
--- a/app/main.ts
+++ b/app/main.ts
@@ -424,6 +424,7 @@ async function prepareUrl(
version: app.getVersion(),
buildCreation: config.get('buildCreation'),
buildExpiration: config.get('buildExpiration'),
+ challengeUrl: config.get('challengeUrl'),
serverUrl: config.get('serverUrl'),
storageUrl: config.get('storageUrl'),
updatesUrl: config.get('updatesUrl'),
@@ -441,6 +442,7 @@ async function prepareUrl(
contentProxyUrl: config.get('contentProxyUrl'),
sfuUrl: config.get('sfuUrl'),
reducedMotionSetting: animationSettings.prefersReducedMotion,
+ registrationChallengeUrl: config.get('registrationChallengeUrl'),
serverPublicParams: config.get('serverPublicParams'),
serverTrustRoot: config.get('serverTrustRoot'),
theme,
diff --git a/config/default.json b/config/default.json
index 79ecc6d276d2..993164aa8bbf 100644
--- a/config/default.json
+++ b/config/default.json
@@ -13,6 +13,8 @@
"artCreatorUrl": "https://create.staging.signal.art",
"updatesPublicKey": "05fd7dd3de7149dc0a127909fee7de0f7620ddd0de061b37a2c303e37de802a401",
"sfuUrl": "https://sfu.voip.signal.org/",
+ "challengeUrl": "https://signalcaptchas.org/staging/challenge/generate.html",
+ "registrationChallengeUrl": "https://signalcaptchas.org/staging/registration/generate.html",
"updatesEnabled": false,
"enableCI": false,
"forcePreloadBundle": false,
diff --git a/config/production.json b/config/production.json
index 995b7af9f256..12895219887d 100644
--- a/config/production.json
+++ b/config/production.json
@@ -8,6 +8,8 @@
"2": "https://cdn2.signal.org"
},
"artCreatorUrl": "https://create.signal.art",
+ "challengeUrl": "https://signalcaptchas.org/challenge/generate.html",
+ "registrationChallengeUrl": "https://signalcaptchas.org/registration/generate.html",
"serverPublicParams": "AMhf5ywVwITZMsff/eCyudZx9JDmkkkbV6PInzG4p8x3VqVJSFiMvnvlEKWuRob/1eaIetR31IYeAbm0NdOuHH8Qi+Rexi1wLlpzIo1gstHWBfZzy1+qHRV5A4TqPp15YzBPm0WSggW6PbSn+F4lf57VCnHF7p8SvzAA2ZZJPYJURt8X7bbg+H3i+PEjH9DXItNEqs2sNcug37xZQDLm7X36nOoGPs54XsEGzPdEV+itQNGUFEjY6X9Uv+Acuks7NpyGvCoKxGwgKgE5XyJ+nNKlyHHOLb6N1NuHyBrZrgtY/JYJHRooo5CEqYKBqdFnmbTVGEkCvJKxLnjwKWf+fEPoWeQFj5ObDjcKMZf2Jm2Ae69x+ikU5gBXsRmoF94GXTLfN0/vLt98KDPnxwAQL9j5V1jGOY8jQl6MLxEs56cwXN0dqCnImzVH3TZT1cJ8SW1BRX6qIVxEzjsSGx3yxF3suAilPMqGRp4ffyopjMD1JXiKR2RwLKzizUe5e8XyGOy9fplzhw3jVzTRyUZTRSZKkMLWcQ/gv0E4aONNqs4P",
"serverTrustRoot": "BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF",
"updatesEnabled": true
diff --git a/ts/challenge.ts b/ts/challenge.ts
index 0086ae086332..0f4d5daea778 100644
--- a/ts/challenge.ts
+++ b/ts/challenge.ts
@@ -16,7 +16,7 @@ import { assertDev } from './util/assert';
import { isOlderThan } from './util/timestamp';
import { parseRetryAfterWithDefault } from './util/parseRetryAfter';
import { clearTimeoutIfNecessary } from './util/clearTimeoutIfNecessary';
-import { getEnvironment, Environment } from './environment';
+import { missingCaseError } from './util/missingCaseError';
import type { StorageInterface } from './types/Storage.d';
import * as Errors from './types/errors';
import { HTTPError } from './textsecure/Errors';
@@ -93,9 +93,6 @@ export type RequestCaptchaOptionsType = Readonly<{
}>;
const DEFAULT_EXPIRE_AFTER = 24 * 3600 * 1000; // one day
-const CAPTCHA_URL = 'https://signalcaptchas.org/challenge/generate.html';
-const CAPTCHA_STAGING_URL =
- 'https://signalcaptchas.org/staging/challenge/generate.html';
function shouldStartQueue(registered: RegisteredChallengeType): boolean {
// No retryAt provided; waiting for user to complete captcha
@@ -110,11 +107,14 @@ function shouldStartQueue(registered: RegisteredChallengeType): boolean {
return false;
}
-export function getChallengeURL(): string {
- if (getEnvironment() === Environment.Staging) {
- return CAPTCHA_STAGING_URL;
+export function getChallengeURL(type: 'chat' | 'registration'): string {
+ if (type === 'chat') {
+ return window.SignalContext.config.challengeUrl;
}
- return CAPTCHA_URL;
+ if (type === 'registration') {
+ return window.SignalContext.config.registrationChallengeUrl;
+ }
+ throw missingCaseError(type);
}
// Note that even though this is a class - only one instance of
diff --git a/ts/components/StandaloneRegistration.tsx b/ts/components/StandaloneRegistration.tsx
index a9adb9806853..d1ebb9c8548e 100644
--- a/ts/components/StandaloneRegistration.tsx
+++ b/ts/components/StandaloneRegistration.tsx
@@ -7,6 +7,7 @@ import type { Plugin } from 'intl-tel-input';
import intlTelInput from 'intl-tel-input';
import { strictAssert } from '../util/assert';
+import * as log from '../logging/log';
import { parseNumber } from '../util/libphonenumberUtil';
import { getChallengeURL } from '../challenge';
@@ -128,7 +129,9 @@ export function StandaloneRegistration({
return;
}
- document.location.href = getChallengeURL();
+ const url = getChallengeURL('registration');
+ log.info(`StandaloneRegistration: navigating to ${url}`);
+ document.location.href = url;
if (!window.Signal.challengeHandler) {
setError('Captcha handler is not ready!');
return;
diff --git a/ts/state/smart/CaptchaDialog.tsx b/ts/state/smart/CaptchaDialog.tsx
index 341b757a3d11..7f3682b31dd1 100644
--- a/ts/state/smart/CaptchaDialog.tsx
+++ b/ts/state/smart/CaptchaDialog.tsx
@@ -8,6 +8,7 @@ import type { StateType } from '../reducer';
import { getIntl } from '../selectors/user';
import { isChallengePending } from '../selectors/network';
import { getChallengeURL } from '../../challenge';
+import * as log from '../../logging/log';
const mapStateToProps = (state: StateType) => {
return {
@@ -16,7 +17,9 @@ const mapStateToProps = (state: StateType) => {
i18n: getIntl(state),
onContinue() {
- document.location.href = getChallengeURL();
+ const url = getChallengeURL('chat');
+ log.info(`CaptchaDialog: navigating to ${url}`);
+ document.location.href = url;
},
};
};
diff --git a/ts/types/RendererConfig.ts b/ts/types/RendererConfig.ts
index 0bdf144ba258..d2cb8801caa6 100644
--- a/ts/types/RendererConfig.ts
+++ b/ts/types/RendererConfig.ts
@@ -31,6 +31,7 @@ export const rendererConfigSchema = z.object({
buildExpiration: z.number(),
cdnUrl0: configRequiredStringSchema,
cdnUrl2: configRequiredStringSchema,
+ challengeUrl: configRequiredStringSchema,
certificateAuthority: configRequiredStringSchema,
contentProxyUrl: configRequiredStringSchema,
crashDumpsPath: configRequiredStringSchema,
@@ -44,6 +45,7 @@ export const rendererConfigSchema = z.object({
nodeVersion: configRequiredStringSchema,
proxyUrl: configOptionalStringSchema,
reducedMotionSetting: z.boolean(),
+ registrationChallengeUrl: configRequiredStringSchema,
serverPublicParams: configRequiredStringSchema,
serverTrustRoot: configRequiredStringSchema,
serverUrl: configRequiredStringSchema,