status-go/server/pairing
Icaro Motta 919277be38
feat(pairing)_: Fallback pairing seed (#5614) (#5627)
* feat(pairing)!: Add extra parameters and remove v2 compatibility

This commit includes the following changes:

I have added a flag to maintain 2.29 compatibility.

Breaking change in connection string

The local pairing code that was parsing the connection string had a few non-upgradable features:

It was strictly checking the number of parameters, throwing an error if the number was different. This made it impossible to add parameters to it without breaking.
It was strictly checking the version number. This made increasing the version number impossible as older client would just refuse to connect.
The code has been changed so that:

Two parameters have been added, installation-id and key-uid. Those are needed for the fallback flow.
I have also removed version from the payload, since it wasn't used.

This means that we don't support v1 anymore. V2 parsing is supported . Going forward there's a clear strategy on how to update the protocol (append parameters, don't change existing one).

https://www.youtube.com/watch?v=oyLBGkS5ICk Is a must watch video for understanding the strategy

Changed MessengerResponse to use internally a map of installations rather than an array (minor)
Just moving towards maps as arrays tend to lead to subtle bugs.

Moved pairing methods to messenger_pairing.go
Just moved some methods

Added 2 new methods for the fallback flow
FinishPairingThroughSeedPhraseProcess
https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R29

EnableAndSyncInstallation

https://github.com/status-im/status-go/pull/5567/files#diff-1ad620b07fa3bd5fbc96c9f459d88829938a162bf1aaf41c61dea6e38b488d54R18

Flow for clients
Client A1 is logged in
Client A2 is logged out

Client A1 shows a QR code
Client A2 scans a QR code
If connection fails on A2, the user will be prompted to enter a seed phrase.
If the generated account matches the key-uid from the QR code, A2 should call FinishPairingThroughSeedPhraseProcess with the installation id passed in the QR code. This will send installation information over waku. The user should be shown its own installation id and prompted to check the other device.
Client A1 will receive new installation data through waku, if they are still on the qr code page, they should show a popup to the user showing the received installation id, and a way to Enable and Sync, which should call the EnableAndSyncInstallation endpoint. This should finish the fallback syncing flow.
Current issues
Currently I haven't tested that all the data is synced after finishing the flow. I see that the two devices are paired correctly, but for example the DisplayName is not changed on the receiving device. I haven't had time to look into it further.

* test_: add more test for connection string parser

* fix_: fix panic when parse old connection string

* test_: add comments for TestMessengerPairAfterSeedPhrase

* fix_: correct error description

* feat_:rename FinishPairingThroughSeedPhraseProcess to EnableInstallationAndPair

* fix_: delete leftover

* fix_: add UniqueKey method

* fix_: unify the response for InputConnectionStringForBootstrapping

* fix_: remove fields installationID and keyUID in GethStatusBackend

* fix_: rename messenger_pairing to messenger_pairing_and_syncing

---------

Co-authored-by: frank <lovefree103@gmail.com>
Co-authored-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2024-07-30 13:03:43 -03:00
..
peers feat(pairing)_: Fallback pairing seed (#5614) (#5627) 2024-07-30 13:03:43 -03:00
preflight Fix/timesource offline (#4309) 2023-11-13 14:06:32 -05:00
statecontrol Added functionality to local pairing that makes client calls (more) idempotent 2023-08-21 15:44:32 +01:00
versioning Local Pairing: connection string version 2 with sharing multiple server addresses (#3909) 2023-08-22 19:18:14 +03:00
TODO.MD Added a (rough) roadmap to resolving a number of known issues 2023-08-14 15:10:54 +01:00
certs.go optimised finding server cert (#4148) 2023-10-18 14:17:49 +08:00
certs_test.go Reconciled duplicate cert funcs 2023-03-24 17:31:34 +00:00
challenge_management.go Addressed feedback from @ilmotta 2023-03-24 16:47:43 +00:00
client.go refactor_: set default node config values for frontend when doing local pair sync 2024-04-25 11:51:23 +08:00
common.go fix(config)_: fix TorrentConfig when loading node config from DB 2024-06-12 02:50:29 +07:00
components_test.go Local Pairing: connection string version 2 with sharing multiple server addresses (#3909) 2023-08-22 19:18:14 +03:00
config.go feat(pairing)_: Fallback pairing seed (#5614) (#5627) 2024-07-30 13:03:43 -03:00
config_test.go refactor_: set default node config values for frontend when doing local pair sync 2024-04-25 11:51:23 +08:00
connection.go feat(pairing)_: Fallback pairing seed (#5614) (#5627) 2024-07-30 13:03:43 -03:00
connection_test.go feat(pairing)_: Fallback pairing seed (#5614) (#5627) 2024-07-30 13:03:43 -03:00
events.go chore: pairings file related properties removed from the local pairing 2023-09-13 17:15:32 +02:00
handlers.go [#4200] Avoid tx watching for addresses which were not exposed 2023-12-01 12:30:42 +01:00
interfaces.go Removed HandlerServer interface 2023-04-04 15:29:13 +01:00
payload_encryptor.go Refactored BasePayloadReceiver to handle Receive() 2023-04-04 11:56:40 +01:00
payload_management.go chore: pairings file related properties removed from the local pairing 2023-09-13 17:15:32 +02:00
payload_management_test.go fix: use proper migrations for protocol's test database 2023-10-03 15:11:58 +02:00
payload_mounter.go chore: pairings file related properties removed from the local pairing 2023-09-13 17:15:32 +02:00
payload_receiver.go chore: pairings file related properties removed from the local pairing 2023-09-13 17:15:32 +02:00
peers.go optimised finding server cert (#4148) 2023-10-18 14:17:49 +08:00
raw_message_collector.go Refactored BasePayloadReceiver to handle Receive() 2023-04-04 11:56:40 +01:00
raw_message_handler.go feat: adapt create/restore/login endpoints for keycard usage (#5311) 2024-06-26 13:14:27 +02:00
server.go feat(pairing)_: Fallback pairing seed (#5614) (#5627) 2024-07-30 13:03:43 -03:00
server_pairing_test.go feat(pairing)_: Fallback pairing seed (#5614) (#5627) 2024-07-30 13:03:43 -03:00
sync_device_test.go feat(pairing)_: Fallback pairing seed (#5614) (#5627) 2024-07-30 13:03:43 -03:00
utils.go fix(pairing): Received installation event (#3422) 2023-04-26 14:48:49 +03:00