Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3380779
D11445.id38473.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D11445.id38473.diff
View Options
diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js
--- a/lib/types/crypto-types.js
+++ b/lib/types/crypto-types.js
@@ -112,6 +112,13 @@
TEXT: 1,
});
+export type OlmEncryptedMessageTypes = $Values<typeof olmEncryptedMessageTypes>;
+
+export type EncryptedData = {
+ +message: string,
+ +messageType: OlmEncryptedMessageTypes,
+};
+
export type ClientPublicKeys = {
+primaryIdentityPublicKeys: {
+ed25519: string,
@@ -128,7 +135,7 @@
export type OlmAPI = {
+initializeCryptoAccount: () => Promise<void>,
+getUserPublicKey: () => Promise<ClientPublicKeys>,
- +encrypt: (content: string, deviceID: string) => Promise<string>,
+ +encrypt: (content: string, deviceID: string) => Promise<EncryptedData>,
+decrypt: (encryptedContent: string, deviceID: string) => Promise<string>,
+contentInboundSessionCreator: (
contentIdentityKeys: OLMIdentityKeys,
diff --git a/native/crypto/olm-api.js b/native/crypto/olm-api.js
--- a/native/crypto/olm-api.js
+++ b/native/crypto/olm-api.js
@@ -2,10 +2,12 @@
import { getOneTimeKeyValues } from 'lib/shared/crypto-utils.js';
import { type AuthMetadata } from 'lib/shared/identity-client-context.js';
-import type {
- OneTimeKeysResultValues,
- OlmAPI,
- OLMIdentityKeys,
+import {
+ type OneTimeKeysResultValues,
+ type OlmAPI,
+ type OLMIdentityKeys,
+ type EncryptedData,
+ olmEncryptedMessageTypes,
} from 'lib/types/crypto-types.js';
import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
@@ -16,7 +18,13 @@
await commCoreModule.initializeCryptoAccount();
},
getUserPublicKey: commCoreModule.getUserPublicKey,
- encrypt: commCoreModule.encrypt,
+ async encrypt(content: string, deviceID: string): Promise<EncryptedData> {
+ const encryptedContent = await commCoreModule.encrypt(content, deviceID);
+ return {
+ message: encryptedContent,
+ messageType: olmEncryptedMessageTypes.TEXT,
+ };
+ },
decrypt: commCoreModule.decrypt,
async contentInboundSessionCreator(
contentIdentityKeys: OLMIdentityKeys,
diff --git a/native/profile/tunnelbroker-menu.react.js b/native/profile/tunnelbroker-menu.react.js
--- a/native/profile/tunnelbroker-menu.react.js
+++ b/native/profile/tunnelbroker-menu.react.js
@@ -29,6 +29,7 @@
+navigation: ProfileNavigationProp<'TunnelbrokerMenu'>,
+route: NavigationRoute<'TunnelbrokerMenu'>,
};
+
// eslint-disable-next-line no-unused-vars
function TunnelbrokerMenu(props: Props): React.Node {
const styles = useStyles(unboundStyles);
@@ -84,7 +85,7 @@
return;
}
await olmAPI.initializeCryptoAccount();
- const encrypted = await olmAPI.encrypt(
+ const { message: encrypted } = await olmAPI.encrypt(
`Encrypted message to ${recipient}`,
recipient,
);
diff --git a/web/settings/tunnelbroker-test.react.js b/web/settings/tunnelbroker-test.react.js
--- a/web/settings/tunnelbroker-test.react.js
+++ b/web/settings/tunnelbroker-test.react.js
@@ -61,7 +61,7 @@
setLoading(true);
try {
await olmAPI.initializeCryptoAccount();
- const encrypted = await olmAPI.encrypt(
+ const { message: encrypted } = await olmAPI.encrypt(
`Encrypted message to ${recipient}`,
recipient,
);
diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js
--- a/web/shared-worker/worker/worker-crypto.js
+++ b/web/shared-worker/worker/worker-crypto.js
@@ -19,6 +19,7 @@
type OneTimeKeysResultValues,
type ClientPublicKeys,
type NotificationsOlmDataType,
+ type EncryptedData,
} from 'lib/types/crypto-types.js';
import type {
IdentityNewDeviceKeyUpload,
@@ -368,7 +369,7 @@
signature,
};
},
- async encrypt(content: string, deviceID: string): Promise<string> {
+ async encrypt(content: string, deviceID: string): Promise<EncryptedData> {
if (!cryptoStore) {
throw new Error('Crypto account not initialized');
}
@@ -376,11 +377,14 @@
if (!session) {
throw new Error(`No session for deviceID: ${deviceID}`);
}
- const { body } = session.encrypt(content);
+ const encryptedContent = session.encrypt(content);
persistCryptoStore();
- return body;
+ return {
+ message: encryptedContent.body,
+ messageType: encryptedContent.type,
+ };
},
async decrypt(encryptedContent: string, deviceID: string): Promise<string> {
if (!cryptoStore) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 2:06 AM (21 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2595442
Default Alt Text
D11445.id38473.diff (4 KB)
Attached To
Mode
D11445: [web] update `encrypt` method to return `EncryptedData`
Attached
Detach File
Event Timeline
Log In to Comment