Receive support for Sender Key
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
e5f9c0db28
commit
e6bab06510
28 changed files with 743 additions and 164 deletions
|
@ -8,17 +8,20 @@ import { isNumber } from 'lodash';
|
|||
|
||||
import {
|
||||
Direction,
|
||||
ProtocolAddress,
|
||||
SessionStore,
|
||||
SessionRecord,
|
||||
IdentityKeyStore,
|
||||
PreKeyRecord,
|
||||
PreKeyStore,
|
||||
PrivateKey,
|
||||
ProtocolAddress,
|
||||
PublicKey,
|
||||
SignedPreKeyStore,
|
||||
SenderKeyRecord,
|
||||
SenderKeyStore,
|
||||
SessionRecord,
|
||||
SessionStore,
|
||||
SignedPreKeyRecord,
|
||||
} from 'libsignal-client';
|
||||
SignedPreKeyStore,
|
||||
Uuid,
|
||||
} from '@signalapp/signal-client';
|
||||
import { freezePreKey, freezeSignedPreKey } from './SignalProtocolStore';
|
||||
|
||||
import { typedArrayToArrayBuffer } from './Crypto';
|
||||
|
@ -131,6 +134,36 @@ export class PreKeys extends PreKeyStore {
|
|||
}
|
||||
}
|
||||
|
||||
export class SenderKeys extends SenderKeyStore {
|
||||
async saveSenderKey(
|
||||
sender: ProtocolAddress,
|
||||
distributionId: Uuid,
|
||||
record: SenderKeyRecord
|
||||
): Promise<void> {
|
||||
const encodedAddress = encodedNameFromAddress(sender);
|
||||
|
||||
await window.textsecure.storage.protocol.saveSenderKey(
|
||||
encodedAddress,
|
||||
distributionId,
|
||||
record
|
||||
);
|
||||
}
|
||||
|
||||
async getSenderKey(
|
||||
sender: ProtocolAddress,
|
||||
distributionId: Uuid
|
||||
): Promise<SenderKeyRecord | null> {
|
||||
const encodedAddress = encodedNameFromAddress(sender);
|
||||
|
||||
const senderKey = await window.textsecure.storage.protocol.getSenderKey(
|
||||
encodedAddress,
|
||||
distributionId
|
||||
);
|
||||
|
||||
return senderKey || null;
|
||||
}
|
||||
}
|
||||
|
||||
export class SignedPreKeys extends SignedPreKeyStore {
|
||||
async saveSignedPreKey(
|
||||
id: number,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue