Page MenuHomePhabricator

Update native backup code to handle siwe backup message
AcceptedPublic

Authored by marcin on Mon, Apr 22, 11:25 AM.
Tags
None
Referenced Files
F1693892: D11715.id39388.diff
Thu, May 2, 7:40 PM
Unknown Object (File)
Thu, May 2, 7:22 AM
Unknown Object (File)
Wed, May 1, 11:56 PM
Unknown Object (File)
Tue, Apr 30, 8:03 PM
Unknown Object (File)
Sun, Apr 28, 4:18 PM
Unknown Object (File)
Sun, Apr 28, 4:17 PM
Unknown Object (File)
Fri, Apr 26, 1:48 PM
Unknown Object (File)
Fri, Apr 26, 12:25 PM
Subscribers

Details

Reviewers
kamil
bartek
Summary

This diff modifies native rust code to attach backup message to upload request provided the file exists.

Test Plan

For now test that backup upload works for password users. Very next diff will enable testing for SIWE users with just one button click

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Mon, Apr 22, 11:46 AM
Harbormaster failed remote builds in B28364: Diff 39354!

I think you should rename the generic backup_message to siwe_backup_message

LGTM but maybe @bartek could double check Rust code

native/native_rust_library/src/backup.rs
55–66 ↗(On Diff #39388)

I think this could be simplified a bit

shared/backup_client/src/lib.rs
74–77 ↗(On Diff #39388)

but you'll have to make form mutable

This revision is now accepted and ready to land.Fri, Apr 26, 12:36 AM
native/backup/use-client-backup.js
54 ↗(On Diff #39388)

is there a way to make it nullable to avoid mocking with an empty string?

native/backup/use-client-backup.js
54 ↗(On Diff #39388)

Actually this is a bit problematic. We can change the types so that user passes undefined or null instead of empty string. However the user MUST explicitly pass undefined or null - otherwise JSI will crash. Unfortunately if we change the type in CommCoreModuleJSISchema.js to sth like this:

+createNewBackup: (
    backupSecret: string,
    siweBackupMsg: ?string,
  ) => Promise<void>;

Flow won't complain if the user doesn't undefined explicitly so it won't prevent potential crash. Therefore it is best to create new JSI specifically for siwe backup creation.

P.S. JSI crashes since it accesses arguments by accessing array. So if the user doesn't provide anything for backup message JSI will try to access out of array bounds.

  1. Rename msg_backup to siwe_backup_msg
  2. Introcuce separate backup creation JSI calls for SIWE and password users to avoid macking empty string or potential crashes if dev forgets to specify null