Page MenuHomePhabricator

D10526.diff
No OneTemporary

D10526.diff

diff --git a/native/handlers/peer-to-peer-message-handler.js b/native/handlers/peer-to-peer-message-handler.js
--- a/native/handlers/peer-to-peer-message-handler.js
+++ b/native/handlers/peer-to-peer-message-handler.js
@@ -1,11 +1,12 @@
// @flow
+import { getOneTimeKeyArray } from 'lib/shared/crypto-utils.js';
import {
type PeerToPeerMessage,
peerToPeerMessageTypes,
} from 'lib/types/tunnelbroker/peer-to-peer-message-types.js';
-import { commCoreModule } from '../native-modules.js';
+import { commCoreModule, commRustModule } from '../native-modules.js';
import { nativeInboundContentSessionCreator } from '../utils/crypto-utils.js';
async function peerToPeerMessageHandler(
@@ -40,6 +41,35 @@
`${message.senderInfo.deviceID}: ${e.message}`,
);
}
+ } else if (message.type === peerToPeerMessageTypes.REFRESH_KEY_REQUEST) {
+ const [
+ { userID, deviceID, accessToken },
+ notificationsOneTimeKeys,
+ primaryOneTimeKeys,
+ ] = await Promise.all([
+ commCoreModule.getCommServicesAuthMetadata(),
+ commCoreModule.getNotificationsOneTimeKeys(message.numberOfKeys),
+ commCoreModule.getPrimaryOneTimeKeys(message.numberOfKeys),
+ ]);
+
+ if (!userID || !deviceID || !accessToken) {
+ console.log(
+ 'CommServicesAuthMetadata is missing when uploading one-time keys',
+ );
+ return;
+ }
+
+ try {
+ await commRustModule.uploadOneTimeKeys(
+ userID,
+ deviceID,
+ accessToken,
+ getOneTimeKeyArray(primaryOneTimeKeys),
+ getOneTimeKeyArray(notificationsOneTimeKeys),
+ );
+ } catch (e) {
+ console.log(`Error uploading one-time keys: ${e.message}`);
+ }
}
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 1:01 AM (17 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2573352
Default Alt Text
D10526.diff (1 KB)

Event Timeline