status-go/api
frank f123e98179
feat: fallback pairing seed (#5614)
* 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: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2024-07-30 17:14:05 +08:00
..
multiformat Add spiff workflow cmd 2023-03-16 14:31:34 +00:00
.gitignore Fix some tests & upgrade contracts 2021-07-20 10:57:38 +02:00
app_state.go Clean api package (#1055) 2018-06-27 10:11:45 +02:00
app_state_test.go Clean api package (#1055) 2018-06-27 10:11:45 +02:00
backend.go feat: adapt create/restore/login endpoints for keycard usage (#5311) 2024-06-26 13:14:27 +02:00
backend_test.go feat: fallback pairing seed (#5614) 2024-07-30 17:14:05 +08:00
create_account_and_login_test.go fix: proper usage of CreateAccount RootDataDir (#5284) 2024-06-05 14:03:34 +01:00
default_networks.go fix(wallet)_: fix provider down event happening too often (#5595) 2024-07-29 18:07:43 +01:00
default_networks_test.go fix(wallet)_: add POKT(Grove) sepolia url 2024-05-08 12:35:12 +02:00
default_test.go fix(integration-tests)_: add missing HTTPVirtualHosts 2024-07-04 16:14:02 +02:00
defaults.go chore_: rename shards.test to status.prod (#5571) 2024-07-29 17:19:48 -04:00
geth_backend.go feat: fallback pairing seed (#5614) 2024-07-30 17:14:05 +08:00
messenger_raw_message_resend_test.go fix(communities)_: validate if RawMessage from DB is valid before sending it 2024-07-23 19:54:39 +02:00
old_mobile_user_upgrading_from_v1_to_v2_test.go test_: correct comment 2024-06-05 19:36:05 +08:00
test_helpers.go fix(integration-tests)_: add missing HTTPVirtualHosts 2024-07-04 16:14:02 +02:00
utils.go synchronize display name (#2989) 2022-12-29 14:16:19 +08:00
utils_test.go fix(tests): moved test db setup to a common place 't/helpers', created 2023-08-18 09:00:56 +02:00