mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 17:08:57 +01:00
Allow hardcoding a captcha response in the config files
This commit is contained in:
+5
-1
@@ -174,7 +174,11 @@ const preventDisplaySleepService = new PreventDisplaySleepService(
|
||||
powerSaveBlocker
|
||||
);
|
||||
|
||||
const challengeHandler = new ChallengeMainHandler();
|
||||
const challengeHandler = new ChallengeMainHandler(
|
||||
config.has('hardcodedCaptchaForLocalTestingOnly')
|
||||
? config.get<string>('hardcodedCaptchaForLocalTestingOnly')
|
||||
: undefined
|
||||
);
|
||||
|
||||
const nativeThemeNotifier = new NativeThemeNotifier();
|
||||
nativeThemeNotifier.initialize();
|
||||
|
||||
@@ -10,13 +10,18 @@ import type {
|
||||
IPCResponse,
|
||||
ChallengeResponse,
|
||||
} from '../challenge.js';
|
||||
import { getEnvironment, Environment } from '../environment.js';
|
||||
|
||||
const log = createLogger('challengeMain');
|
||||
|
||||
export class ChallengeMainHandler {
|
||||
#handlers: Array<(response: ChallengeResponse) => void> = [];
|
||||
#hardcodedResult?: ChallengeResponse;
|
||||
|
||||
constructor() {
|
||||
constructor(hardcodedResult?: string) {
|
||||
if (hardcodedResult && getEnvironment() === Environment.Development) {
|
||||
this.#hardcodedResult = { captcha: hardcodedResult };
|
||||
}
|
||||
this.#initialize();
|
||||
}
|
||||
|
||||
@@ -41,9 +46,11 @@ export class ChallengeMainHandler {
|
||||
|
||||
const start = Date.now();
|
||||
|
||||
const data = await new Promise<ChallengeResponse>(resolve => {
|
||||
this.#handlers.push(resolve);
|
||||
});
|
||||
const data =
|
||||
this.#hardcodedResult ||
|
||||
(await new Promise<ChallengeResponse>(resolve => {
|
||||
this.#handlers.push(resolve);
|
||||
}));
|
||||
|
||||
const duration = Date.now() - start;
|
||||
log.info(`${logId}: got response after ${duration}ms`);
|
||||
|
||||
Reference in New Issue
Block a user