@signalapp/libsignal-client 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Native.d.ts CHANGED
@@ -35,6 +35,12 @@ export abstract class SignedPreKeyStore {
35
35
  _getSignedPreKey(signedPreKeyId: number): Promise<SignedPreKeyRecord>;
36
36
  }
37
37
 
38
+ export abstract class KyberPreKeyStore {
39
+ _saveKyberPreKey(kyberPreKeyId: number, record: KyberPreKeyRecord): Promise<void>;
40
+ _getKyberPreKey(kyberPreKeyId: number): Promise<KyberPreKeyRecord>;
41
+ _markKyberPreKeyUsed(kyberPreKeyId: number): Promise<void>;
42
+ }
43
+
38
44
  export abstract class SenderKeyStore {
39
45
  _saveSenderKey(sender: ProtocolAddress, distributionId: Uuid, record: SenderKeyRecord): Promise<void>;
40
46
  _getSenderKey(sender: ProtocolAddress, distributionId: Uuid): Promise<SenderKeyRecord | null>;
@@ -141,6 +147,23 @@ export function IncrementalMac_CalculateChunkSize(dataSize: number): number;
141
147
  export function IncrementalMac_Finalize(mac: Wrapper<IncrementalMac>): Buffer;
142
148
  export function IncrementalMac_Initialize(key: Buffer, chunkSize: number): IncrementalMac;
143
149
  export function IncrementalMac_Update(mac: Wrapper<IncrementalMac>, bytes: Buffer, offset: number, length: number): Buffer;
150
+ export function KyberKeyPair_Generate(): KyberKeyPair;
151
+ export function KyberKeyPair_GetPublicKey(keyPair: Wrapper<KyberKeyPair>): KyberPublicKey;
152
+ export function KyberKeyPair_GetSecretKey(keyPair: Wrapper<KyberKeyPair>): KyberSecretKey;
153
+ export function KyberPreKeyRecord_Deserialize(data: Buffer): KyberPreKeyRecord;
154
+ export function KyberPreKeyRecord_GetId(obj: Wrapper<KyberPreKeyRecord>): number;
155
+ export function KyberPreKeyRecord_GetKeyPair(obj: Wrapper<KyberPreKeyRecord>): KyberKeyPair;
156
+ export function KyberPreKeyRecord_GetPublicKey(obj: Wrapper<KyberPreKeyRecord>): KyberPublicKey;
157
+ export function KyberPreKeyRecord_GetSecretKey(obj: Wrapper<KyberPreKeyRecord>): KyberSecretKey;
158
+ export function KyberPreKeyRecord_GetSignature(obj: Wrapper<KyberPreKeyRecord>): Buffer;
159
+ export function KyberPreKeyRecord_GetTimestamp(obj: Wrapper<KyberPreKeyRecord>): Timestamp;
160
+ export function KyberPreKeyRecord_New(id: number, timestamp: Timestamp, keyPair: Wrapper<KyberKeyPair>, signature: Buffer): KyberPreKeyRecord;
161
+ export function KyberPreKeyRecord_Serialize(obj: Wrapper<KyberPreKeyRecord>): Buffer;
162
+ export function KyberPublicKey_Deserialize(data: Buffer): KyberPublicKey;
163
+ export function KyberPublicKey_Equals(lhs: Wrapper<KyberPublicKey>, rhs: Wrapper<KyberPublicKey>): boolean;
164
+ export function KyberPublicKey_Serialize(obj: Wrapper<KyberPublicKey>): Buffer;
165
+ export function KyberSecretKey_Deserialize(data: Buffer): KyberSecretKey;
166
+ export function KyberSecretKey_Serialize(obj: Wrapper<KyberSecretKey>): Buffer;
144
167
  export function Mp4Sanitizer_Sanitize(input: InputStream, len: Buffer): Promise<SanitizedMetadata>;
145
168
  export function PlaintextContent_Deserialize(data: Buffer): PlaintextContent;
146
169
  export function PlaintextContent_FromDecryptionErrorMessage(m: Wrapper<DecryptionErrorMessage>): PlaintextContent;
@@ -148,13 +171,16 @@ export function PlaintextContent_GetBody(obj: Wrapper<PlaintextContent>): Buffer
148
171
  export function PlaintextContent_Serialize(obj: Wrapper<PlaintextContent>): Buffer;
149
172
  export function PreKeyBundle_GetDeviceId(obj: Wrapper<PreKeyBundle>): number;
150
173
  export function PreKeyBundle_GetIdentityKey(p: Wrapper<PreKeyBundle>): PublicKey;
174
+ export function PreKeyBundle_GetKyberPreKeyId(obj: Wrapper<PreKeyBundle>): number | null;
175
+ export function PreKeyBundle_GetKyberPreKeyPublic(bundle: Wrapper<PreKeyBundle>): KyberPublicKey | null;
176
+ export function PreKeyBundle_GetKyberPreKeySignature(bundle: Wrapper<PreKeyBundle>): Buffer;
151
177
  export function PreKeyBundle_GetPreKeyId(obj: Wrapper<PreKeyBundle>): number | null;
152
178
  export function PreKeyBundle_GetPreKeyPublic(obj: Wrapper<PreKeyBundle>): PublicKey | null;
153
179
  export function PreKeyBundle_GetRegistrationId(obj: Wrapper<PreKeyBundle>): number;
154
180
  export function PreKeyBundle_GetSignedPreKeyId(obj: Wrapper<PreKeyBundle>): number;
155
181
  export function PreKeyBundle_GetSignedPreKeyPublic(obj: Wrapper<PreKeyBundle>): PublicKey;
156
182
  export function PreKeyBundle_GetSignedPreKeySignature(obj: Wrapper<PreKeyBundle>): Buffer;
157
- export function PreKeyBundle_New(registrationId: number, deviceId: number, prekeyId: number | null, prekey: Wrapper<PublicKey> | null, signedPrekeyId: number, signedPrekey: Wrapper<PublicKey>, signedPrekeySignature: Buffer, identityKey: Wrapper<PublicKey>): PreKeyBundle;
183
+ export function PreKeyBundle_New(registrationId: number, deviceId: number, prekeyId: number | null, prekey: Wrapper<PublicKey> | null, signedPrekeyId: number, signedPrekey: Wrapper<PublicKey>, signedPrekeySignature: Buffer, identityKey: Wrapper<PublicKey>, kyberPrekeyId: number | null, kyberPrekey: Wrapper<KyberPublicKey> | null, kyberPrekeySignature: Buffer): PreKeyBundle;
158
184
  export function PreKeyRecord_Deserialize(data: Buffer): PreKeyRecord;
159
185
  export function PreKeyRecord_GetId(obj: Wrapper<PreKeyRecord>): number;
160
186
  export function PreKeyRecord_GetPrivateKey(obj: Wrapper<PreKeyRecord>): PrivateKey;
@@ -214,7 +240,7 @@ export function SealedSenderDecryptionResult_GetDeviceId(obj: Wrapper<SealedSend
214
240
  export function SealedSenderDecryptionResult_GetSenderE164(obj: Wrapper<SealedSenderDecryptionResult>): string | null;
215
241
  export function SealedSenderDecryptionResult_GetSenderUuid(obj: Wrapper<SealedSenderDecryptionResult>): string;
216
242
  export function SealedSenderDecryptionResult_Message(obj: Wrapper<SealedSenderDecryptionResult>): Buffer;
217
- export function SealedSender_DecryptMessage(message: Buffer, trustRoot: Wrapper<PublicKey>, timestamp: Timestamp, localE164: string | null, localUuid: string, localDeviceId: number, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore): Promise<SealedSenderDecryptionResult>;
243
+ export function SealedSender_DecryptMessage(message: Buffer, trustRoot: Wrapper<PublicKey>, timestamp: Timestamp, localE164: string | null, localUuid: string, localDeviceId: number, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore): Promise<SealedSenderDecryptionResult>;
218
244
  export function SealedSender_DecryptToUsmc(ctext: Buffer, identityStore: IdentityKeyStore, ctx: null): Promise<UnidentifiedSenderMessageContent>;
219
245
  export function SealedSender_Encrypt(destination: Wrapper<ProtocolAddress>, content: Wrapper<UnidentifiedSenderMessageContent>, identityKeyStore: IdentityKeyStore, ctx: null): Promise<Buffer>;
220
246
  export function SealedSender_MultiRecipientEncrypt(recipients: Wrapper<ProtocolAddress>[], recipientSessions: Wrapper<SessionRecord>[], content: Wrapper<UnidentifiedSenderMessageContent>, identityKeyStore: IdentityKeyStore, ctx: null): Promise<Buffer>;
@@ -281,7 +307,7 @@ export function ServerSecretParams_VerifyAuthCredentialPresentation(serverSecret
281
307
  export function ServerSecretParams_VerifyProfileKeyCredentialPresentation(serverSecretParams: Serialized<ServerSecretParams>, groupPublicParams: Serialized<GroupPublicParams>, presentationBytes: Buffer, currentTimeInSeconds: Timestamp): void;
282
308
  export function ServerSecretParams_VerifyReceiptCredentialPresentation(serverSecretParams: Serialized<ServerSecretParams>, presentation: Serialized<ReceiptCredentialPresentation>): void;
283
309
  export function SessionBuilder_ProcessPreKeyBundle(bundle: Wrapper<PreKeyBundle>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, ctx: null): Promise<void>;
284
- export function SessionCipher_DecryptPreKeySignalMessage(message: Wrapper<PreKeySignalMessage>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, ctx: null): Promise<Buffer>;
310
+ export function SessionCipher_DecryptPreKeySignalMessage(message: Wrapper<PreKeySignalMessage>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore, ctx: null): Promise<Buffer>;
285
311
  export function SessionCipher_DecryptSignalMessage(message: Wrapper<SignalMessage>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, ctx: null): Promise<Buffer>;
286
312
  export function SessionCipher_EncryptMessage(ptext: Buffer, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, ctx: null): Promise<CiphertextMessage>;
287
313
  export function SessionRecord_ArchiveCurrentState(sessionRecord: Wrapper<SessionRecord>): void;
@@ -343,6 +369,10 @@ interface GroupPublicParams { readonly __type: unique symbol; }
343
369
  interface GroupSecretParams { readonly __type: unique symbol; }
344
370
  interface HsmEnclaveClient { readonly __type: unique symbol; }
345
371
  interface IncrementalMac { readonly __type: unique symbol; }
372
+ interface KyberKeyPair { readonly __type: unique symbol; }
373
+ interface KyberPreKeyRecord { readonly __type: unique symbol; }
374
+ interface KyberPublicKey { readonly __type: unique symbol; }
375
+ interface KyberSecretKey { readonly __type: unique symbol; }
346
376
  interface PlaintextContent { readonly __type: unique symbol; }
347
377
  interface PreKeyBundle { readonly __type: unique symbol; }
348
378
  interface PreKeyRecord { readonly __type: unique symbol; }
package/dist/index.d.ts CHANGED
@@ -79,6 +79,28 @@ export declare class PrivateKey {
79
79
  agree(other_key: PublicKey): Buffer;
80
80
  getPublicKey(): PublicKey;
81
81
  }
82
+ export declare class KEMPublicKey {
83
+ readonly _nativeHandle: Native.KyberPublicKey;
84
+ private constructor();
85
+ static _fromNativeHandle(handle: Native.KyberPublicKey): KEMPublicKey;
86
+ static deserialize(buf: Buffer): KEMPublicKey;
87
+ serialize(): Buffer;
88
+ }
89
+ export declare class KEMSecretKey {
90
+ readonly _nativeHandle: Native.KyberSecretKey;
91
+ private constructor();
92
+ static _fromNativeHandle(handle: Native.KyberSecretKey): KEMSecretKey;
93
+ static deserialize(buf: Buffer): KEMSecretKey;
94
+ serialize(): Buffer;
95
+ }
96
+ export declare class KEMKeyPair {
97
+ readonly _nativeHandle: Native.KyberKeyPair;
98
+ private constructor();
99
+ static _fromNativeHandle(handle: Native.KyberKeyPair): KEMKeyPair;
100
+ static generate(): KEMKeyPair;
101
+ getPublicKey(): KEMPublicKey;
102
+ getSecretKey(): KEMSecretKey;
103
+ }
82
104
  export declare class IdentityKeyPair {
83
105
  readonly publicKey: PublicKey;
84
106
  readonly privateKey: PrivateKey;
@@ -91,7 +113,7 @@ export declare class IdentityKeyPair {
91
113
  export declare class PreKeyBundle {
92
114
  readonly _nativeHandle: Native.PreKeyBundle;
93
115
  private constructor();
94
- static new(registration_id: number, device_id: number, prekey_id: number | null, prekey: PublicKey | null, signed_prekey_id: number, signed_prekey: PublicKey, signed_prekey_signature: Buffer, identity_key: PublicKey): PreKeyBundle;
116
+ static new(registration_id: number, device_id: number, prekey_id: number | null, prekey: PublicKey | null, signed_prekey_id: number, signed_prekey: PublicKey, signed_prekey_signature: Buffer, identity_key: PublicKey, kyber_prekey_id?: number | null, kyber_prekey?: KEMPublicKey | null, kyber_prekey_signature?: Buffer | null): PreKeyBundle;
95
117
  deviceId(): number;
96
118
  identityKey(): PublicKey;
97
119
  preKeyId(): number | null;
@@ -100,6 +122,9 @@ export declare class PreKeyBundle {
100
122
  signedPreKeyId(): number;
101
123
  signedPreKeyPublic(): PublicKey;
102
124
  signedPreKeySignature(): Buffer;
125
+ kyberPreKeyId(): number | null;
126
+ kyberPreKeyPublic(): KEMPublicKey | null;
127
+ kyberPreKeySignature(): Buffer | null;
103
128
  }
104
129
  export declare class PreKeyRecord {
105
130
  readonly _nativeHandle: Native.PreKeyRecord;
@@ -125,6 +150,20 @@ export declare class SignedPreKeyRecord {
125
150
  signature(): Buffer;
126
151
  timestamp(): number;
127
152
  }
153
+ export declare class KyberPreKeyRecord {
154
+ readonly _nativeHandle: Native.KyberPreKeyRecord;
155
+ private constructor();
156
+ static _fromNativeHandle(nativeHandle: Native.KyberPreKeyRecord): KyberPreKeyRecord;
157
+ static new(id: number, timestamp: number, keyPair: KEMKeyPair, signature: Buffer): KyberPreKeyRecord;
158
+ serialize(): Buffer;
159
+ static deserialize(buffer: Buffer): KyberPreKeyRecord;
160
+ id(): number;
161
+ keyPair(): KEMKeyPair;
162
+ publicKey(): KEMPublicKey;
163
+ secretKey(): KEMSecretKey;
164
+ signature(): Buffer;
165
+ timestamp(): number;
166
+ }
128
167
  export declare class SignalMessage {
129
168
  readonly _nativeHandle: Native.SignalMessage;
130
169
  private constructor();
@@ -266,6 +305,14 @@ export declare abstract class SignedPreKeyStore implements Native.SignedPreKeySt
266
305
  abstract saveSignedPreKey(id: number, record: SignedPreKeyRecord): Promise<void>;
267
306
  abstract getSignedPreKey(id: number): Promise<SignedPreKeyRecord>;
268
307
  }
308
+ export declare abstract class KyberPreKeyStore implements Native.KyberPreKeyStore {
309
+ _saveKyberPreKey(kyberPreKeyId: number, record: Native.KyberPreKeyRecord): Promise<void>;
310
+ _getKyberPreKey(kyberPreKeyId: number): Promise<Native.KyberPreKeyRecord>;
311
+ _markKyberPreKeyUsed(kyberPreKeyId: number): Promise<void>;
312
+ abstract saveKyberPreKey(kyberPreKeyId: number, record: KyberPreKeyRecord): Promise<void>;
313
+ abstract getKyberPreKey(kyberPreKeyId: number): Promise<KyberPreKeyRecord>;
314
+ abstract markKyberPreKeyUsed(kyberPreKeyId: number): Promise<void>;
315
+ }
269
316
  export declare abstract class SenderKeyStore implements Native.SenderKeyStore {
270
317
  _saveSenderKey(sender: Native.ProtocolAddress, distributionId: Native.Uuid, record: Native.SenderKeyRecord): Promise<void>;
271
318
  _getSenderKey(sender: Native.ProtocolAddress, distributionId: Native.Uuid): Promise<Native.SenderKeyRecord | null>;
@@ -318,12 +365,12 @@ export declare class DecryptionErrorMessage {
318
365
  export declare function processPreKeyBundle(bundle: PreKeyBundle, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore): Promise<void>;
319
366
  export declare function signalEncrypt(message: Buffer, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore): Promise<CiphertextMessage>;
320
367
  export declare function signalDecrypt(message: SignalMessage, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore): Promise<Buffer>;
321
- export declare function signalDecryptPreKey(message: PreKeySignalMessage, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore): Promise<Buffer>;
368
+ export declare function signalDecryptPreKey(message: PreKeySignalMessage, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore): Promise<Buffer>;
322
369
  export declare function sealedSenderEncryptMessage(message: Buffer, address: ProtocolAddress, senderCert: SenderCertificate, sessionStore: SessionStore, identityStore: IdentityKeyStore): Promise<Buffer>;
323
370
  export declare function sealedSenderEncrypt(content: UnidentifiedSenderMessageContent, address: ProtocolAddress, identityStore: IdentityKeyStore): Promise<Buffer>;
324
371
  export declare function sealedSenderMultiRecipientEncrypt(content: UnidentifiedSenderMessageContent, recipients: ProtocolAddress[], identityStore: IdentityKeyStore, sessionStore: SessionStore): Promise<Buffer>;
325
372
  export declare function sealedSenderMultiRecipientMessageForSingleRecipient(message: Buffer): Buffer;
326
- export declare function sealedSenderDecryptMessage(message: Buffer, trustRoot: PublicKey, timestamp: number, localE164: string | null, localUuid: string, localDeviceId: number, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore): Promise<SealedSenderDecryptionResult>;
373
+ export declare function sealedSenderDecryptMessage(message: Buffer, trustRoot: PublicKey, timestamp: number, localE164: string | null, localUuid: string, localDeviceId: number, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore): Promise<SealedSenderDecryptionResult>;
327
374
  export declare function sealedSenderDecryptToUsmc(message: Buffer, identityStore: IdentityKeyStore): Promise<UnidentifiedSenderMessageContent>;
328
375
  export declare class Cds2Client {
329
376
  readonly _nativeHandle: Native.SgxClientState;
package/dist/index.js CHANGED
@@ -27,8 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
27
27
  });
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.Cds2Client = exports.sealedSenderDecryptToUsmc = exports.sealedSenderDecryptMessage = exports.sealedSenderMultiRecipientMessageForSingleRecipient = exports.sealedSenderMultiRecipientEncrypt = exports.sealedSenderEncrypt = exports.sealedSenderEncryptMessage = exports.signalDecryptPreKey = exports.signalDecrypt = exports.signalEncrypt = exports.processPreKeyBundle = exports.DecryptionErrorMessage = exports.PlaintextContent = exports.CiphertextMessage = exports.SealedSenderDecryptionResult = exports.groupDecrypt = exports.groupEncrypt = exports.SenderKeyStore = exports.SignedPreKeyStore = exports.PreKeyStore = exports.IdentityKeyStore = exports.SessionStore = exports.UnidentifiedSenderMessageContent = exports.SenderKeyMessage = exports.processSenderKeyDistributionMessage = exports.SenderKeyDistributionMessage = exports.SenderCertificate = exports.SenderKeyRecord = exports.ServerCertificate = exports.SessionRecord = exports.PreKeySignalMessage = exports.SignalMessage = exports.SignedPreKeyRecord = exports.PreKeyRecord = exports.PreKeyBundle = exports.IdentityKeyPair = exports.PrivateKey = exports.PublicKey = exports.Aes256GcmSiv = exports.Fingerprint = exports.DisplayableFingerprint = exports.ScannableFingerprint = exports.hkdf = exports.HKDF = exports.ContentHint = exports.Direction = exports.CiphertextMessageType = exports.Mp4Sanitizer = exports.io = exports.usernames = void 0;
31
- exports.initLogger = exports.LogLevel = exports.HsmEnclaveClient = void 0;
30
+ exports.sealedSenderEncrypt = exports.sealedSenderEncryptMessage = exports.signalDecryptPreKey = exports.signalDecrypt = exports.signalEncrypt = exports.processPreKeyBundle = exports.DecryptionErrorMessage = exports.PlaintextContent = exports.CiphertextMessage = exports.SealedSenderDecryptionResult = exports.groupDecrypt = exports.groupEncrypt = exports.SenderKeyStore = exports.KyberPreKeyStore = exports.SignedPreKeyStore = exports.PreKeyStore = exports.IdentityKeyStore = exports.SessionStore = exports.UnidentifiedSenderMessageContent = exports.SenderKeyMessage = exports.processSenderKeyDistributionMessage = exports.SenderKeyDistributionMessage = exports.SenderCertificate = exports.SenderKeyRecord = exports.ServerCertificate = exports.SessionRecord = exports.PreKeySignalMessage = exports.SignalMessage = exports.KyberPreKeyRecord = exports.SignedPreKeyRecord = exports.PreKeyRecord = exports.PreKeyBundle = exports.IdentityKeyPair = exports.KEMKeyPair = exports.KEMSecretKey = exports.KEMPublicKey = exports.PrivateKey = exports.PublicKey = exports.Aes256GcmSiv = exports.Fingerprint = exports.DisplayableFingerprint = exports.ScannableFingerprint = exports.hkdf = exports.HKDF = exports.ContentHint = exports.Direction = exports.CiphertextMessageType = exports.Mp4Sanitizer = exports.io = exports.usernames = void 0;
31
+ exports.initLogger = exports.LogLevel = exports.HsmEnclaveClient = exports.Cds2Client = exports.sealedSenderDecryptToUsmc = exports.sealedSenderDecryptMessage = exports.sealedSenderMultiRecipientMessageForSingleRecipient = exports.sealedSenderMultiRecipientEncrypt = void 0;
32
32
  const uuid = require("uuid");
33
33
  const Errors = require("./Errors");
34
34
  __exportStar(require("./Errors"), exports);
@@ -190,6 +190,54 @@ class PrivateKey {
190
190
  }
191
191
  }
192
192
  exports.PrivateKey = PrivateKey;
193
+ class KEMPublicKey {
194
+ constructor(handle) {
195
+ this._nativeHandle = handle;
196
+ }
197
+ static _fromNativeHandle(handle) {
198
+ return new KEMPublicKey(handle);
199
+ }
200
+ static deserialize(buf) {
201
+ return new KEMPublicKey(Native.KyberPublicKey_Deserialize(buf));
202
+ }
203
+ serialize() {
204
+ return Native.KyberPublicKey_Serialize(this);
205
+ }
206
+ }
207
+ exports.KEMPublicKey = KEMPublicKey;
208
+ class KEMSecretKey {
209
+ constructor(handle) {
210
+ this._nativeHandle = handle;
211
+ }
212
+ static _fromNativeHandle(handle) {
213
+ return new KEMSecretKey(handle);
214
+ }
215
+ static deserialize(buf) {
216
+ return new KEMSecretKey(Native.KyberSecretKey_Deserialize(buf));
217
+ }
218
+ serialize() {
219
+ return Native.KyberSecretKey_Serialize(this);
220
+ }
221
+ }
222
+ exports.KEMSecretKey = KEMSecretKey;
223
+ class KEMKeyPair {
224
+ constructor(handle) {
225
+ this._nativeHandle = handle;
226
+ }
227
+ static _fromNativeHandle(handle) {
228
+ return new KEMKeyPair(handle);
229
+ }
230
+ static generate() {
231
+ return new KEMKeyPair(Native.KyberKeyPair_Generate());
232
+ }
233
+ getPublicKey() {
234
+ return KEMPublicKey._fromNativeHandle(Native.KyberKeyPair_GetPublicKey(this));
235
+ }
236
+ getSecretKey() {
237
+ return KEMSecretKey._fromNativeHandle(Native.KyberKeyPair_GetSecretKey(this));
238
+ }
239
+ }
240
+ exports.KEMKeyPair = KEMKeyPair;
193
241
  class IdentityKeyPair {
194
242
  constructor(publicKey, privateKey) {
195
243
  this.publicKey = publicKey;
@@ -215,10 +263,10 @@ class PreKeyBundle {
215
263
  constructor(handle) {
216
264
  this._nativeHandle = handle;
217
265
  }
218
- static new(registration_id, device_id, prekey_id, prekey, signed_prekey_id, signed_prekey, signed_prekey_signature, identity_key) {
266
+ static new(registration_id, device_id, prekey_id, prekey, signed_prekey_id, signed_prekey, signed_prekey_signature, identity_key, kyber_prekey_id, kyber_prekey, kyber_prekey_signature) {
219
267
  return new PreKeyBundle(Native.PreKeyBundle_New(registration_id, device_id, prekey_id, prekey != null ? prekey : null,
220
268
  //prekey?,
221
- signed_prekey_id, signed_prekey, signed_prekey_signature, identity_key));
269
+ signed_prekey_id, signed_prekey, signed_prekey_signature, identity_key, kyber_prekey_id !== null && kyber_prekey_id !== void 0 ? kyber_prekey_id : null, kyber_prekey !== null && kyber_prekey !== void 0 ? kyber_prekey : null, kyber_prekey_signature !== null && kyber_prekey_signature !== void 0 ? kyber_prekey_signature : Buffer.alloc(0)));
222
270
  }
223
271
  deviceId() {
224
272
  return Native.PreKeyBundle_GetDeviceId(this);
@@ -250,6 +298,17 @@ class PreKeyBundle {
250
298
  signedPreKeySignature() {
251
299
  return Native.PreKeyBundle_GetSignedPreKeySignature(this);
252
300
  }
301
+ kyberPreKeyId() {
302
+ return Native.PreKeyBundle_GetKyberPreKeyId(this);
303
+ }
304
+ kyberPreKeyPublic() {
305
+ const handle = Native.PreKeyBundle_GetKyberPreKeyPublic(this);
306
+ return handle == null ? null : KEMPublicKey._fromNativeHandle(handle);
307
+ }
308
+ kyberPreKeySignature() {
309
+ const buf = Native.PreKeyBundle_GetKyberPreKeySignature(this);
310
+ return buf.length == 0 ? null : buf;
311
+ }
253
312
  }
254
313
  exports.PreKeyBundle = PreKeyBundle;
255
314
  class PreKeyRecord {
@@ -312,6 +371,42 @@ class SignedPreKeyRecord {
312
371
  }
313
372
  }
314
373
  exports.SignedPreKeyRecord = SignedPreKeyRecord;
374
+ class KyberPreKeyRecord {
375
+ constructor(handle) {
376
+ this._nativeHandle = handle;
377
+ }
378
+ static _fromNativeHandle(nativeHandle) {
379
+ return new KyberPreKeyRecord(nativeHandle);
380
+ }
381
+ static new(id, timestamp, keyPair, signature) {
382
+ return new KyberPreKeyRecord(Native.KyberPreKeyRecord_New(id, timestamp, keyPair, signature));
383
+ }
384
+ serialize() {
385
+ return Native.KyberPreKeyRecord_Serialize(this);
386
+ }
387
+ static deserialize(buffer) {
388
+ return new KyberPreKeyRecord(Native.KyberPreKeyRecord_Deserialize(buffer));
389
+ }
390
+ id() {
391
+ return Native.KyberPreKeyRecord_GetId(this);
392
+ }
393
+ keyPair() {
394
+ return KEMKeyPair._fromNativeHandle(Native.KyberPreKeyRecord_GetKeyPair(this));
395
+ }
396
+ publicKey() {
397
+ return KEMPublicKey._fromNativeHandle(Native.KyberPreKeyRecord_GetPublicKey(this));
398
+ }
399
+ secretKey() {
400
+ return KEMSecretKey._fromNativeHandle(Native.KyberPreKeyRecord_GetSecretKey(this));
401
+ }
402
+ signature() {
403
+ return Native.KyberPreKeyRecord_GetSignature(this);
404
+ }
405
+ timestamp() {
406
+ return Native.KyberPreKeyRecord_GetTimestamp(this);
407
+ }
408
+ }
409
+ exports.KyberPreKeyRecord = KyberPreKeyRecord;
315
410
  class SignalMessage {
316
411
  constructor(handle) {
317
412
  this._nativeHandle = handle;
@@ -676,6 +771,25 @@ class SignedPreKeyStore {
676
771
  }
677
772
  }
678
773
  exports.SignedPreKeyStore = SignedPreKeyStore;
774
+ class KyberPreKeyStore {
775
+ _saveKyberPreKey(kyberPreKeyId, record) {
776
+ return __awaiter(this, void 0, void 0, function* () {
777
+ return this.saveKyberPreKey(kyberPreKeyId, KyberPreKeyRecord._fromNativeHandle(record));
778
+ });
779
+ }
780
+ _getKyberPreKey(kyberPreKeyId) {
781
+ return __awaiter(this, void 0, void 0, function* () {
782
+ const prekey = yield this.getKyberPreKey(kyberPreKeyId);
783
+ return prekey._nativeHandle;
784
+ });
785
+ }
786
+ _markKyberPreKeyUsed(kyberPreKeyId) {
787
+ return __awaiter(this, void 0, void 0, function* () {
788
+ return this.markKyberPreKeyUsed(kyberPreKeyId);
789
+ });
790
+ }
791
+ }
792
+ exports.KyberPreKeyStore = KyberPreKeyStore;
679
793
  class SenderKeyStore {
680
794
  _saveSenderKey(sender, distributionId, record) {
681
795
  return __awaiter(this, void 0, void 0, function* () {
@@ -817,8 +931,8 @@ function signalDecrypt(message, address, sessionStore, identityStore) {
817
931
  return Native.SessionCipher_DecryptSignalMessage(message, address, sessionStore, identityStore, null);
818
932
  }
819
933
  exports.signalDecrypt = signalDecrypt;
820
- function signalDecryptPreKey(message, address, sessionStore, identityStore, prekeyStore, signedPrekeyStore) {
821
- return Native.SessionCipher_DecryptPreKeySignalMessage(message, address, sessionStore, identityStore, prekeyStore, signedPrekeyStore, null);
934
+ function signalDecryptPreKey(message, address, sessionStore, identityStore, prekeyStore, signedPrekeyStore, kyberPrekeyStore) {
935
+ return Native.SessionCipher_DecryptPreKeySignalMessage(message, address, sessionStore, identityStore, prekeyStore, signedPrekeyStore, kyberPrekeyStore, null);
822
936
  }
823
937
  exports.signalDecryptPreKey = signalDecryptPreKey;
824
938
  function sealedSenderEncryptMessage(message, address, senderCert, sessionStore, identityStore) {
@@ -845,9 +959,9 @@ function sealedSenderMultiRecipientMessageForSingleRecipient(message) {
845
959
  return Native.SealedSender_MultiRecipientMessageForSingleRecipient(message);
846
960
  }
847
961
  exports.sealedSenderMultiRecipientMessageForSingleRecipient = sealedSenderMultiRecipientMessageForSingleRecipient;
848
- function sealedSenderDecryptMessage(message, trustRoot, timestamp, localE164, localUuid, localDeviceId, sessionStore, identityStore, prekeyStore, signedPrekeyStore) {
962
+ function sealedSenderDecryptMessage(message, trustRoot, timestamp, localE164, localUuid, localDeviceId, sessionStore, identityStore, prekeyStore, signedPrekeyStore, kyberPrekeyStore) {
849
963
  return __awaiter(this, void 0, void 0, function* () {
850
- const ssdr = yield Native.SealedSender_DecryptMessage(message, trustRoot, timestamp, localE164, localUuid, localDeviceId, sessionStore, identityStore, prekeyStore, signedPrekeyStore);
964
+ const ssdr = yield Native.SealedSender_DecryptMessage(message, trustRoot, timestamp, localE164, localUuid, localDeviceId, sessionStore, identityStore, prekeyStore, signedPrekeyStore, kyberPrekeyStore);
851
965
  return SealedSenderDecryptionResult._fromNativeHandle(ssdr);
852
966
  });
853
967
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,6 +32,7 @@
32
32
  "@types/bindings": "^1.3.0",
33
33
  "@types/chai": "^4.3.1",
34
34
  "@types/chai-as-promised": "^7.1.3",
35
+ "@types/chance": "^1.1.3",
35
36
  "@types/mocha": "^5.2.7",
36
37
  "@types/node": "16.18.3",
37
38
  "@types/uuid": "^8.3.0",
@@ -39,6 +40,7 @@
39
40
  "@typescript-eslint/parser": "^5.47.0",
40
41
  "chai": "^4.2.0",
41
42
  "chai-as-promised": "^7.1.1",
43
+ "chance": "^1.1.11",
42
44
  "eslint": "^8.30.0",
43
45
  "eslint-config-prettier": "^8.5.0",
44
46
  "eslint-plugin-header": "^3.1.0",
Binary file
Binary file
Binary file