From c7c8cff7bbce5d0fa24a4426e6efdf7568741b02 Mon Sep 17 00:00:00 2001 From: Alexander Elo Date: Tue, 18 Jan 2022 16:53:50 +0200 Subject: [PATCH 1/2] Allow captcha token to be passed when requesting new SMS verification --- src/AccountManager.js | 4 ++-- src/WebAPI.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AccountManager.js b/src/AccountManager.js index a7a3c6c..2297b6c 100644 --- a/src/AccountManager.js +++ b/src/AccountManager.js @@ -45,8 +45,8 @@ class AccountManager extends EventTarget { return this.server.requestVerificationVoice(this.username); } - requestSMSVerification() { - return this.server.requestVerificationSMS(this.username); + requestSMSVerification(token) { + return this.server.requestVerificationSMS(this.username, token); } async encryptDeviceName(name, providedIdentityKey) { diff --git a/src/WebAPI.js b/src/WebAPI.js index 27bd0b9..2ebc380 100644 --- a/src/WebAPI.js +++ b/src/WebAPI.js @@ -616,11 +616,11 @@ function initialize({ }); } - function requestVerificationSMS(number) { + function requestVerificationSMS(number, token) { return _ajax({ call: 'accounts', httpType: 'GET', - urlParameters: `/sms/code/${number}`, + urlParameters: `/sms/code/${number}${token ? `?captcha=${token}` : '' }`, }); } From 5c923f43d88388b7a0951d10ed4dfcee43e37092 Mon Sep 17 00:00:00 2001 From: Alexander Elo Date: Tue, 18 Jan 2022 16:54:45 +0200 Subject: [PATCH 2/2] Add Captcha token section to README file --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 7138142..1d07d03 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,21 @@ accountManager.registerSingleDevice("myCode").then(result => { }); ``` +##### CAPTCHA challenge requirement +Sometimes the Signal server requires a captcha token for registering a new account. The registration fails with a captcha required error or with `402 Payment Required` error. In this case, you need to solve a CAPTCHA challenge. + +To get the token, got to [Captcha generation](https://signalcaptchas.org/registration/generate.html). After filling the captcha, the site doesn't show the token but redirects to a signalcaptcha:// url that contains the token. To see the URL you can open the browser developer tools (F12) before completing the captcha. Check the console/network tab in the developer tools for a redirect starting with `signalcaptcha://`. Everything after `signalcaptcha://` is the captcha token. + +You can pass the captcha token to `registerSingleDevice` function like so: +``` +const captchaToken = "..."; +accountManager.requestSMSVerification(captchaToken).then(result => { + console.log("Sent verification code."); +}); +``` + +Note: Captcha token is valid for only a short period of time. + ### Sending messages To send a message, connect a `MessageSender` instance to the Signal service: