Skip to content

Conversation

kevinsung
Copy link
Contributor

@kevinsung kevinsung commented Mar 23, 2021

First time contributor checklist:

Contributor checklist:

Description

Fixes #5006.

Loads the CAPTCHA that is required for verification to register a phone number with the desktop app as a standalone device for development. I adapted this from Signal-Android. When a request for SMS or voice verification is rejected with error code 402, a new window with a CAPTCHA appears, and upon successful completion of the CAPTCHA, the window closes and the request is sent again with the newly acquired credentials.

This requires the SIGNAL_ENABLE_HTTP environment variable to be set, e.g. on Linux,

SIGNAL_ENABLE_HTTP=1 yarn start

I tested manually that this works and that it allowed me to successfully register a phone number. I tested this on Arch Linux (kernel version 5.11.8-arch1-1).

Screenshots:
screenshot1
screenshot2

@josephdangerstewart
Copy link

Running on windows 10, it looks like the captcha window opens a white screen for me.

image

Navigating to https://signalcaptchas.org/registration/generate.html shows a Recaptcha 3 box. However I don't see the Recaptcha 3 UI in the captcha window.

image

@kevinsung
Copy link
Contributor Author

@josephdangerstewart you need to set the SIGNAL_ENABLE_HTTP environment variable to a truthy value. On Linux this looks like

SIGNAL_ENABLE_HTTP=1 yarn start

@josephdangerstewart
Copy link

you need to set the SIGNAL_ENABLE_HTTP environment variable to a truthy value. On Linux this looks like

Oh whoops, looks like I missed that part in the contributing guidelines 😅 Thanks for pointing it out!

@elisedjn
Copy link

I have cherry-picked your changes onto the latest version of master. When I tried out on my Mac, I have infinite captcha check with no SMS received 😅

@kevinsung
Copy link
Contributor Author

@elisedjn Did you remember to regenerate the assets before starting the app (by running yarn grunt)? If the problem persists, can you provide a debug log?

@elisedjn
Copy link

@kevinsung Sorry for my late answer.
Thanks for your help, it's working now! :)

@dennisameling
Copy link
Contributor

Can confirm the CAPTCHA registration works, I was able to set up Signal as a standalone device on the staging servers 🎉 thanks!

image

@ghost
Copy link

ghost commented Jun 18, 2021

Hello,
I am getting the same Error 402 with the newest Development Branch, even when using
SIGNAL_ENABLE_HTTP=1 yarn start

This is the Log:
INFO 2021-06-18T05:00:21.100Z checkExpiringMessages: found no messages to expire ERROR 2021-06-18T05:00:21.308Z Top-level unhandled promise rejection: Error: Username in storage was not a string. Cannot connect to WebAPI at Object.connectToServerWithStoredCredentials ([REDACTED]/ts/util/connectToServerWithStoredCredentials.js:9:15) at Object.refreshRemoteConfig ([REDACTED]/ts/RemoteConfig.js:26:59) at invokeFunc ([REDACTED]/node_modules/lodash/lodash.js:10401:23) at leadingEdge ([REDACTED]/node_modules/lodash/lodash.js:10411:26) at Object.debounced [as maybeRefreshRemoteConfig] ([REDACTED]/node_modules/lodash/lodash.js:10478:20) at Object.initRemoteConfig ([REDACTED]/ts/RemoteConfig.js:12:19) at [REDACTED]/ts/background.js:649:36 INFO 2021-06-18T05:00:21.393Z Updating BrowserWindow config: {"maximized":false,"autoHideMenuBar":false,"fullscreen":false,"width":844,"height":653,"x":412,"y":141} INFO 2021-06-18T05:00:21.393Z config/set: Saving ephemeral config to disk INFO 2021-06-18T05:00:22.288Z provisioning socket open ERROR 2021-06-18T05:00:26.671Z Top-level unhandled error: TypeError: Cannot read property 'toUpperCase' of undefined at child.validateNumber (file://[REDACTED]/js/views/phone-input-view.js:25:9) at HTMLDivElement.dispatch (file://[REDACTED]/js/components.js:5429:27) at HTMLDivElement.elemData.handle (file://[REDACTED]/js/components.js:5233:28) INFO 2021-06-18T05:00:30.736Z GET https://textsecure-service-staging.whispersystems.org/v1/accounts/sms/code/+[REDACTED]687 ERROR 2021-06-18T05:00:31.641Z GET https://textsecure-service-staging.whispersystems.org/v1/accounts/sms/code/+[REDACTED]687 402 Error INFO 2021-06-18T05:00:40.217Z Loaded this list of log files from logPath: app.log, app.log.1, main.log, main.log.1

So i tried checking out kevinsung/captcha with which i then run yarn grunt
When I run yarn grunt I get the following Error:

Running "exec:transpile" (exec) task
$ tsc
ts/LibSignalStores.ts(42,14): error TS2515: Non-abstract class 'Sessions' does not implement inherited abstract member 'getExistingSessions' from class 'SessionStore'.
ts/logging/set_up_renderer_logging.ts(70,9): error TS2322: Type 'Readonly | { level: LogLevel.Error; msg: string; time: string; }' is not assignable to type '{ level: LogLevel; msg: string; time: string; }'.
Type 'Readonly' is missing the following properties from type '{ level: LogLevel; msg: string; time: string; }': level, msg, time
ts/logging/shared.ts(30,48): error TS2339: Property 'bind' does not exist on type 'never'.
ts/services/senderCertificate.ts(91,5): error TS2322: Type 'unknown' is not assignable to type '{ expires?: number | undefined; serialized: ArrayBuffer; } | undefined'.
Type 'unknown' is not assignable to type '{ expires?: number | undefined; serialized: ArrayBuffer; }'.
ts/services/senderCertificate.ts(91,40): error TS2349: This expression is not callable.
Type 'never' has no call signatures.
ts/services/senderCertificate.ts(92,25): error TS2571: Object is of type 'unknown'.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code: 2.
Error executing child process: Error: Process exited with code 2.
Warning: Task "exec:transpile" failed. Use --force to continue.

Aborted due to warnings.
error Command failed with exit code 3.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any Help Appreciated

@kevinsung
Copy link
Contributor Author

@RagonEbker It's likely that this branch doesn't work anymore because I've let it fall so far behind the development branch. For now, I don't intend to update this PR unless the Signal developers express interest in reviewing it. If someone else would like to fix the conflicts and open a new PR to replace mine, I will gladly close this one.

@sockbot
Copy link

sockbot commented Aug 20, 2021

I've created a draft PR at #5473 to resolve the merge conflicts in this PR.

As this is my first contribution, constructive feedback is warmly welcomed before I submit this PR for merge.

@kevinsung
Copy link
Contributor Author

Thank you @sockbot ! Closing in favor of #5473 .

@kevinsung kevinsung closed this Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't register standalone application for development (HTTP errors 401, 402)
5 participants