Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3395269
D7653.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7653.id.diff
View Options
diff --git a/native/utils/crypto-utils.js b/native/utils/crypto-utils.js
new file mode 100644
--- /dev/null
+++ b/native/utils/crypto-utils.js
@@ -0,0 +1,47 @@
+// @flow
+
+import * as React from 'react';
+
+import {
+ getOlmSessionInitializationData,
+ getOlmSessionInitializationDataActionTypes,
+} from 'lib/actions/user-actions.js';
+import {
+ useServerCall,
+ useDispatchActionPromise,
+} from 'lib/utils/action-utils.js';
+
+import { commCoreModule } from '../native-modules.js';
+
+function useInitialNotificationsEncryptedMessage(): () => Promise<string> {
+ const callGetOlmSessionInitializationData = useServerCall(
+ getOlmSessionInitializationData,
+ );
+ const dispatchActionPromise = useDispatchActionPromise();
+
+ return React.useCallback(async () => {
+ const olmSessionDataPromise = callGetOlmSessionInitializationData();
+
+ dispatchActionPromise(
+ getOlmSessionInitializationDataActionTypes,
+ olmSessionDataPromise,
+ );
+
+ const { signedIdentityKeysBlob, notifInitializationInfo } =
+ await olmSessionDataPromise;
+
+ const { notificationIdentityPublicKeys } = JSON.parse(
+ signedIdentityKeysBlob.payload,
+ );
+
+ const { prekey, prekeySignature, oneTimeKey } = notifInitializationInfo;
+ return await commCoreModule.initializeNotificationsSession(
+ JSON.stringify(notificationIdentityPublicKeys),
+ prekey,
+ prekeySignature,
+ oneTimeKey,
+ );
+ }, [callGetOlmSessionInitializationData, dispatchActionPromise]);
+}
+
+export { useInitialNotificationsEncryptedMessage };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 3:15 AM (1 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2606592
Default Alt Text
D7653.id.diff (1 KB)
Attached To
Mode
D7653: Create react hook to initialize olm notiications session and get first encrypted message for the keyserver
Attached
Detach File
Event Timeline
Log In to Comment