Move challenge urls into config
This commit is contained in:
parent
7f772e49b6
commit
3e586be46a
8 changed files with 25 additions and 10 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue