Skip to content

Commit

Permalink
[lib] add method to parse one-time keys
Browse files Browse the repository at this point in the history
Summary:
Add method which parses keys to store entire object.
Some context in [ENG-6099](https://linear.app/comm/issue/ENG-6099/parse-one-time-keys-from-identity).

Test Plan: Make sure keys output is correct, and it's possible to create session (later in the stack).

Reviewers: marcin, varun, michal

Reviewed By: marcin, varun

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D10368
  • Loading branch information
xsanm committed Jan 2, 2024
1 parent ec77949 commit 17e755d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/shared/crypto-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
CallServerEndpointOptions,
CallServerEndpoint,
} from '../utils/call-server-endpoint.js';
import { values } from '../utils/objects.js';
import { values, entries } from '../utils/objects.js';

export type InitialNotifMessageOptions = {
+callServerEndpoint?: ?CallServerEndpoint,
Expand Down Expand Up @@ -98,11 +98,20 @@ function getPrekeyValueFromBlob(prekeyBlob: string): string {
return getPrekeyValue(prekey);
}

function getOneTimeKeyArray(
oneTimeKeys: OLMOneTimeKeys,
): $ReadOnlyArray<string> {
return entries(oneTimeKeys.curve25519).map(([key, value]: [string, string]) =>
JSON.stringify({ curve25519: { [key]: value } }),
);
}

export {
getOneTimeKeyValues,
getPrekeyValue,
getOneTimeKeyValuesFromBlob,
getPrekeyValueFromBlob,
initialEncryptedMessageContent,
useInitialNotificationsEncryptedMessage,
getOneTimeKeyArray,
};

0 comments on commit 17e755d

Please sign in to comment.