Move challenge urls into config
This commit is contained in:
parent
7f772e49b6
commit
3e586be46a
8 changed files with 25 additions and 10 deletions
|
@ -49,6 +49,7 @@
|
|||
OS: {
|
||||
hasCustomTitleBar: () => false,
|
||||
},
|
||||
config: {},
|
||||
};
|
||||
|
||||
window.ConversationController = window.ConversationController || {};
|
||||
|
|
|
@ -424,6 +424,7 @@ async function prepareUrl(
|
|||
version: app.getVersion(),
|
||||
buildCreation: config.get<number>('buildCreation'),
|
||||
buildExpiration: config.get<number>('buildExpiration'),
|
||||
challengeUrl: config.get<string>('challengeUrl'),
|
||||
serverUrl: config.get<string>('serverUrl'),
|
||||
storageUrl: config.get<string>('storageUrl'),
|
||||
updatesUrl: config.get<string>('updatesUrl'),
|
||||
|
@ -441,6 +442,7 @@ async function prepareUrl(
|
|||
contentProxyUrl: config.get<string>('contentProxyUrl'),
|
||||
sfuUrl: config.get('sfuUrl'),
|
||||
reducedMotionSetting: animationSettings.prefersReducedMotion,
|
||||
registrationChallengeUrl: config.get<string>('registrationChallengeUrl'),
|
||||
serverPublicParams: config.get<string>('serverPublicParams'),
|
||||
serverTrustRoot: config.get<string>('serverTrustRoot'),
|
||||
theme,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue