Page MenuHomePhabricator

[native] implement prekey rotation handler and call Identity
ClosedPublic

Authored by kamil on Jan 15 2024, 6:28 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 14, 5:29 PM
Unknown Object (File)
Mon, Oct 14, 5:29 PM
Unknown Object (File)
Mon, Oct 14, 5:29 PM
Unknown Object (File)
Mon, Oct 14, 5:29 PM
Unknown Object (File)
Mon, Oct 14, 5:29 PM
Unknown Object (File)
Mon, Oct 14, 5:29 PM
Unknown Object (File)
Sep 21 2024, 10:10 PM
Unknown Object (File)
Sep 5 2024, 2:21 PM
Subscribers

Details

Summary
  1. Change JSI method to accept metadata to properly auth with Identity
  2. Add component to call this after app is opened
  3. Add line to call Identity RPC using std::promise
Test Plan
  1. Test if method is called
  2. Test if uploading works (can be done by making prekey rotation is needed) and verify this by inspecting DDB content
  3. Test if old cryptoModule is restored when RPC fails

Diff Detail

Repository
rCOMM Comm
Branch
prekey-rotation-2
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil retitled this revision from [native] implement prekey rotation to [native] implement prekey rotation handler and call Identity.
kamil published this revision for review.Jan 15 2024, 6:53 AM
kamil added inline comments.
native/components/prekeys-handler.react.js
23

we could get this from IdentityServiceContextProvider - not sure what is better

native/components/prekeys-handler.react.js
11

I don't understand the purpose of this delay

18

I think you can just return undefined here

44

Why we are only rotating prekeys after a login? Shouldn't we also rotate prekeys when they expire?

Is the idea that the app will be killed / restarted frequently enough, and the rotation will typically happen then?

native/components/prekeys-handler.react.js
11

I intended to avoid blocking the initial app load when the app seems to be slowest - but if you think this doesn't improve anything I can remove it.

There is an alternative I mentioned in ENG-5889 about using native API to schedule some tasks in the background (WorkManager on Android and I think NSURLSession on iOS) but this was a lot more complicated.

18

this causes consistent-return error

44

Why we are only rotating prekeys after a login? Shouldn't we also rotate prekeys when they expire?

loggedIn is here only to avoid calling logic for logged-out users

Is the idea that the app will be killed / restarted frequently enough, and the rotation will typically happen then?

Yes, that was the intention. This causes the issue that if the user is not using the app for a very long time (longer than prekey expiring time) those will never be refreshed (see my comment above about an alternative solution that fixes this issue), but on the other hand, device will also not be able to upload one-time keys

Thanks for explaining!

native/components/prekeys-handler.react.js
18

Spoke about this with @kamil in our 1:1. Not sure why he was seeing that... we are able to do this in other parts of our codebase, such as here

native/components/prekeys-handler.react.js
23

i think we should use getCommServicesAuthMetadataEmitter like we do in IdentityServiceContextProvider, but curious for @marcin or @tomek 's thoughts

native/components/prekeys-handler.react.js
23

Emitter makes sense if we're storing the data for some time - it allows updating it. Here we're fetching it and using it immediately, and I don't see how the emitter might help.

LGTM but I think someone else should also take a look

native/components/prekeys-handler.react.js
23

makes sense

marcin added inline comments.
native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
693

Why was it removed? This TODO: is still relevant.

This revision is now accepted and ready to land.Jan 19 2024, 2:47 AM
native/components/prekeys-handler.react.js
18

updated

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
693

right, updating

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
691 ↗(On Diff #36166)

This line is relevant. Please bring it back.