Page MenuHomePhabricator

[web][native] implement creating outbound session in `OlmSessionCreatorContext`
ClosedPublic

Authored by kamil on Jan 22 2024, 2:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 22, 9:57 PM
Unknown Object (File)
Fri, Nov 8, 1:24 AM
Unknown Object (File)
Oct 25 2024, 10:48 AM
Unknown Object (File)
Oct 18 2024, 12:53 AM
Unknown Object (File)
Oct 18 2024, 12:53 AM
Unknown Object (File)
Oct 18 2024, 12:53 AM
Unknown Object (File)
Oct 18 2024, 12:53 AM
Unknown Object (File)
Sep 6 2024, 8:40 PM
Subscribers

Details

Summary

Implemented method on both platforms.

On web implementing only creating session, I am going to work on persistence (ENG-5856) and safety (ENG-6209) soon.

Depends on D10751

Test Plan

Run this code in keyserver-connection-handler (both web and native)

const devices = await identityClient?.getOutboundKeysForUser(
          '3CF3B2B6-FE28-4475-8CB3-68609A246D06', //3CF3B2B6-FE28-4475-8CB3-68609A246D06
        );

        console.log('Keys: ', devices);

        for (const deviceKeys of devices) {
          if (!deviceKeys.keys) {
            console.log(`No keys for device: ${deviceKeys.deviceID}`);
            continue;
          }
          try {
            const initMessage =
              await olmSessionCreatorContext.contentSessionCreator(
                deviceKeys.keys.identityKeysBlob.primaryIdentityPublicKeys,
                deviceKeys.keys.contentInitializationInfo,
              );
            console.log(
              `Session with device ${deviceKeys.deviceID} created: ${initMessage}`,
            );
          } catch (e) {
            console.log(
              `Session with device ${deviceKeys.deviceID} creation error: ${e.message}`,
            );
          }
        }

(if someone want to also test it please use different deviceID)

Diff Detail

Repository
rCOMM Comm
Branch
publish-web-outbound
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Jan 22 2024, 4:39 AM
This revision is now accepted and ready to land.Jan 22 2024, 8:38 AM

On web implementing only creating session, I am going to work on persistence (ENG-5856) and safety (ENG-6209) soon.

Is this the reason that we're creating a new account every time? Will that get addressed in the first or second linked tasks?

web/account/account-hooks.js
181

This function is confusingly named... it says it creates a new notif session, but it appears to actually create a brand new Olm account

We don't want to use separate Olm accounts for the notif identity depending on keyserver, right? If that's correct, shouldn't the creation of the olm.Account be separated from the creation of the olm.Session? Am I missing something?

263

Same comment here. On the native side, commCoreModule.initializeContentOutboundSession seems to handle this correctly (using an existing, persisted account instead of creating a new one every time)

On web implementing only creating session, I am going to work on persistence (ENG-5856) and safety (ENG-6209) soon.

Is this the reason that we're creating a new account every time? Will that get addressed in the first or second linked tasks?

I'm confused - we don't create a new account every time. We use the idempotent method getOrCreateCryptoStore which returned existing olm account or create new one if needed.

I know in code there is new olm.Account() but it's used only to create an object which is two lines below filled with pickled account from the crypto store.
As far as I know, creating a new account is done by account.create(); and we don't do that here. In theory, this code could result in creating a new account when there isn't any account yet, but we call this function on login so I think this code uses only previously created account.

We creating an outbound session which should result in creating a new session and I think does not change the account - inbound is different because we have to also delete used one-time keys, but this has not been implemented yet.

My apologies – I totally misread the code there 😅

Sorry for wasting your time!

This revision was landed with ongoing or failed builds.Jan 29 2024, 2:00 AM
This revision was automatically updated to reflect the committed changes.