@signalapp/libsignal-client 0.26.0 → 0.28.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 +40 -3
- package/dist/Address.d.ts +33 -0
- package/dist/Address.js +76 -1
- package/dist/Errors.d.ts +14 -2
- package/dist/Errors.js +3 -0
- package/dist/index.d.ts +50 -3
- package/dist/index.js +122 -8
- package/dist/usernames.d.ts +7 -0
- package/dist/usernames.js +18 -1
- package/package.json +3 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/win32-arm64/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
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>;
|
|
@@ -280,8 +306,13 @@ export function ServerSecretParams_SignDeterministic(params: Serialized<ServerSe
|
|
|
280
306
|
export function ServerSecretParams_VerifyAuthCredentialPresentation(serverSecretParams: Serialized<ServerSecretParams>, groupPublicParams: Serialized<GroupPublicParams>, presentationBytes: Buffer, currentTimeInSeconds: Timestamp): void;
|
|
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;
|
|
309
|
+
export function ServiceId_ParseFromServiceIdBinary(input: Buffer): Buffer;
|
|
310
|
+
export function ServiceId_ParseFromServiceIdString(input: string): Buffer;
|
|
311
|
+
export function ServiceId_ServiceIdBinary(value: Buffer): Buffer;
|
|
312
|
+
export function ServiceId_ServiceIdLog(value: Buffer): string;
|
|
313
|
+
export function ServiceId_ServiceIdString(value: Buffer): string;
|
|
283
314
|
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>;
|
|
315
|
+
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
316
|
export function SessionCipher_DecryptSignalMessage(message: Wrapper<SignalMessage>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, ctx: null): Promise<Buffer>;
|
|
286
317
|
export function SessionCipher_EncryptMessage(ptext: Buffer, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, ctx: null): Promise<CiphertextMessage>;
|
|
287
318
|
export function SessionRecord_ArchiveCurrentState(sessionRecord: Wrapper<SessionRecord>): void;
|
|
@@ -319,6 +350,8 @@ export function UnidentifiedSenderMessageContent_GetMsgType(m: Wrapper<Unidentif
|
|
|
319
350
|
export function UnidentifiedSenderMessageContent_GetSenderCert(m: Wrapper<UnidentifiedSenderMessageContent>): SenderCertificate;
|
|
320
351
|
export function UnidentifiedSenderMessageContent_New(message: Wrapper<CiphertextMessage>, sender: Wrapper<SenderCertificate>, contentHint: number, groupId: Buffer | null): UnidentifiedSenderMessageContent;
|
|
321
352
|
export function UnidentifiedSenderMessageContent_Serialize(obj: Wrapper<UnidentifiedSenderMessageContent>): Buffer;
|
|
353
|
+
export function UsernameLink_Create(username: string): Buffer;
|
|
354
|
+
export function UsernameLink_DecryptUsername(entropy: Buffer, encryptedUsername: Buffer): string;
|
|
322
355
|
export function Username_CandidatesFrom(nickname: string, minLen: number, maxLen: number): string;
|
|
323
356
|
export function Username_Hash(username: string): Buffer;
|
|
324
357
|
export function Username_Proof(username: string, randomness: Buffer): Buffer;
|
|
@@ -343,6 +376,10 @@ interface GroupPublicParams { readonly __type: unique symbol; }
|
|
|
343
376
|
interface GroupSecretParams { readonly __type: unique symbol; }
|
|
344
377
|
interface HsmEnclaveClient { readonly __type: unique symbol; }
|
|
345
378
|
interface IncrementalMac { readonly __type: unique symbol; }
|
|
379
|
+
interface KyberKeyPair { readonly __type: unique symbol; }
|
|
380
|
+
interface KyberPreKeyRecord { readonly __type: unique symbol; }
|
|
381
|
+
interface KyberPublicKey { readonly __type: unique symbol; }
|
|
382
|
+
interface KyberSecretKey { readonly __type: unique symbol; }
|
|
346
383
|
interface PlaintextContent { readonly __type: unique symbol; }
|
|
347
384
|
interface PreKeyBundle { readonly __type: unique symbol; }
|
|
348
385
|
interface PreKeyRecord { readonly __type: unique symbol; }
|
package/dist/Address.d.ts
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import * as Native from '../Native';
|
|
3
|
+
declare enum ServiceIdKind {
|
|
4
|
+
Aci = 0,
|
|
5
|
+
Pni = 1
|
|
6
|
+
}
|
|
7
|
+
type ThisType<T extends {
|
|
8
|
+
prototype: unknown;
|
|
9
|
+
}> = T['prototype'];
|
|
10
|
+
export declare class ServiceId extends Object {
|
|
11
|
+
private readonly serviceIdFixedWidthBinary;
|
|
12
|
+
protected constructor(serviceIdFixedWidthBinary: Buffer);
|
|
13
|
+
protected static fromUuidBytesAndKind<T extends typeof ServiceId>(this: T, uuidBytes: ArrayLike<number>, kind: ServiceIdKind): ThisType<T>;
|
|
14
|
+
getServiceIdBinary(): Buffer;
|
|
15
|
+
getServiceIdString(): string;
|
|
16
|
+
toString(): string;
|
|
17
|
+
private static parseFromServiceIdFixedWidthBinary;
|
|
18
|
+
static parseFromServiceIdBinary(serviceIdBinary: Buffer): ServiceId;
|
|
19
|
+
static parseFromServiceIdString(serviceIdString: string): ServiceId;
|
|
20
|
+
getRawUuid(): string;
|
|
21
|
+
getRawUuidBytes(): Buffer;
|
|
22
|
+
isEqual(other: ServiceId): boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare class Aci extends ServiceId {
|
|
25
|
+
private readonly __type?;
|
|
26
|
+
static fromUuid(uuidString: string): Aci;
|
|
27
|
+
static fromUuidBytes(uuidBytes: ArrayLike<number>): Aci;
|
|
28
|
+
}
|
|
29
|
+
export declare class Pni extends ServiceId {
|
|
30
|
+
private readonly __type?;
|
|
31
|
+
static fromUuid(uuidString: string): Pni;
|
|
32
|
+
static fromUuidBytes(uuidBytes: ArrayLike<number>): Pni;
|
|
33
|
+
}
|
|
2
34
|
export declare class ProtocolAddress {
|
|
3
35
|
readonly _nativeHandle: Native.ProtocolAddress;
|
|
4
36
|
private constructor();
|
|
@@ -7,3 +39,4 @@ export declare class ProtocolAddress {
|
|
|
7
39
|
name(): string;
|
|
8
40
|
deviceId(): number;
|
|
9
41
|
}
|
|
42
|
+
export {};
|
package/dist/Address.js
CHANGED
|
@@ -4,8 +4,83 @@
|
|
|
4
4
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
5
|
//
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ProtocolAddress = void 0;
|
|
7
|
+
exports.ProtocolAddress = exports.Pni = exports.Aci = exports.ServiceId = void 0;
|
|
8
8
|
const Native = require("../Native");
|
|
9
|
+
const uuid = require("uuid");
|
|
10
|
+
var ServiceIdKind;
|
|
11
|
+
(function (ServiceIdKind) {
|
|
12
|
+
ServiceIdKind[ServiceIdKind["Aci"] = 0] = "Aci";
|
|
13
|
+
ServiceIdKind[ServiceIdKind["Pni"] = 1] = "Pni";
|
|
14
|
+
})(ServiceIdKind || (ServiceIdKind = {}));
|
|
15
|
+
const SERVICE_ID_FIXED_WIDTH_BINARY_LEN = 17;
|
|
16
|
+
class ServiceId extends Object {
|
|
17
|
+
constructor(serviceIdFixedWidthBinary) {
|
|
18
|
+
super();
|
|
19
|
+
if (serviceIdFixedWidthBinary.length != SERVICE_ID_FIXED_WIDTH_BINARY_LEN) {
|
|
20
|
+
throw new TypeError('invalid Service-Id-FixedWidthBinary');
|
|
21
|
+
}
|
|
22
|
+
this.serviceIdFixedWidthBinary = serviceIdFixedWidthBinary;
|
|
23
|
+
}
|
|
24
|
+
static fromUuidBytesAndKind(uuidBytes, kind) {
|
|
25
|
+
const buffer = Buffer.alloc(SERVICE_ID_FIXED_WIDTH_BINARY_LEN);
|
|
26
|
+
buffer[0] = kind;
|
|
27
|
+
buffer.set(uuidBytes, 1);
|
|
28
|
+
return new this(buffer);
|
|
29
|
+
}
|
|
30
|
+
getServiceIdBinary() {
|
|
31
|
+
return Native.ServiceId_ServiceIdBinary(this.serviceIdFixedWidthBinary);
|
|
32
|
+
}
|
|
33
|
+
getServiceIdString() {
|
|
34
|
+
return Native.ServiceId_ServiceIdString(this.serviceIdFixedWidthBinary);
|
|
35
|
+
}
|
|
36
|
+
toString() {
|
|
37
|
+
return Native.ServiceId_ServiceIdLog(this.serviceIdFixedWidthBinary);
|
|
38
|
+
}
|
|
39
|
+
static parseFromServiceIdFixedWidthBinary(serviceIdFixedWidthBinary) {
|
|
40
|
+
switch (serviceIdFixedWidthBinary[0]) {
|
|
41
|
+
case ServiceIdKind.Aci:
|
|
42
|
+
return new Aci(serviceIdFixedWidthBinary);
|
|
43
|
+
case ServiceIdKind.Pni:
|
|
44
|
+
return new Pni(serviceIdFixedWidthBinary);
|
|
45
|
+
default:
|
|
46
|
+
throw new TypeError('unknown type in Service-Id-FixedWidthBinary');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
static parseFromServiceIdBinary(serviceIdBinary) {
|
|
50
|
+
return ServiceId.parseFromServiceIdFixedWidthBinary(Native.ServiceId_ParseFromServiceIdBinary(serviceIdBinary));
|
|
51
|
+
}
|
|
52
|
+
static parseFromServiceIdString(serviceIdString) {
|
|
53
|
+
return ServiceId.parseFromServiceIdFixedWidthBinary(Native.ServiceId_ParseFromServiceIdString(serviceIdString));
|
|
54
|
+
}
|
|
55
|
+
getRawUuid() {
|
|
56
|
+
return uuid.stringify(this.serviceIdFixedWidthBinary, 1);
|
|
57
|
+
}
|
|
58
|
+
getRawUuidBytes() {
|
|
59
|
+
return Buffer.from(this.serviceIdFixedWidthBinary.buffer, 1);
|
|
60
|
+
}
|
|
61
|
+
isEqual(other) {
|
|
62
|
+
return this.serviceIdFixedWidthBinary.equals(other.serviceIdFixedWidthBinary);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.ServiceId = ServiceId;
|
|
66
|
+
class Aci extends ServiceId {
|
|
67
|
+
static fromUuid(uuidString) {
|
|
68
|
+
return this.fromUuidBytes(uuid.parse(uuidString));
|
|
69
|
+
}
|
|
70
|
+
static fromUuidBytes(uuidBytes) {
|
|
71
|
+
return super.fromUuidBytesAndKind(uuidBytes, ServiceIdKind.Aci);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.Aci = Aci;
|
|
75
|
+
class Pni extends ServiceId {
|
|
76
|
+
static fromUuid(uuidString) {
|
|
77
|
+
return this.fromUuidBytes(uuid.parse(uuidString));
|
|
78
|
+
}
|
|
79
|
+
static fromUuidBytes(uuidBytes) {
|
|
80
|
+
return super.fromUuidBytesAndKind(uuidBytes, ServiceIdKind.Pni);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.Pni = Pni;
|
|
9
84
|
class ProtocolAddress {
|
|
10
85
|
constructor(handle) {
|
|
11
86
|
this._nativeHandle = handle;
|
package/dist/Errors.d.ts
CHANGED
|
@@ -17,7 +17,10 @@ export declare enum ErrorCode {
|
|
|
17
17
|
NicknameTooLong = 13,
|
|
18
18
|
IoError = 14,
|
|
19
19
|
InvalidMediaInput = 15,
|
|
20
|
-
UnsupportedMediaInput = 16
|
|
20
|
+
UnsupportedMediaInput = 16,
|
|
21
|
+
InputDataTooLong = 17,
|
|
22
|
+
InvalidEntropyDataLength = 18,
|
|
23
|
+
InvalidUsernameLinkEncryptedData = 19
|
|
21
24
|
}
|
|
22
25
|
export declare class LibSignalErrorBase extends Error {
|
|
23
26
|
readonly code: ErrorCode;
|
|
@@ -72,6 +75,15 @@ export type NicknameTooShortError = LibSignalErrorCommon & {
|
|
|
72
75
|
export type NicknameTooLongError = LibSignalErrorCommon & {
|
|
73
76
|
code: ErrorCode.NicknameTooLong;
|
|
74
77
|
};
|
|
78
|
+
export type InputDataTooLong = LibSignalErrorCommon & {
|
|
79
|
+
code: ErrorCode.InputDataTooLong;
|
|
80
|
+
};
|
|
81
|
+
export type InvalidEntropyDataLength = LibSignalErrorCommon & {
|
|
82
|
+
code: ErrorCode.InvalidEntropyDataLength;
|
|
83
|
+
};
|
|
84
|
+
export type InvalidUsernameLinkEncryptedData = LibSignalErrorCommon & {
|
|
85
|
+
code: ErrorCode.InvalidUsernameLinkEncryptedData;
|
|
86
|
+
};
|
|
75
87
|
export type IoError = LibSignalErrorCommon & {
|
|
76
88
|
code: ErrorCode.IoError;
|
|
77
89
|
};
|
|
@@ -81,4 +93,4 @@ export type InvalidMediaInputError = LibSignalErrorCommon & {
|
|
|
81
93
|
export type UnsupportedMediaInputError = LibSignalErrorCommon & {
|
|
82
94
|
code: ErrorCode.UnsupportedMediaInput;
|
|
83
95
|
};
|
|
84
|
-
export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | CannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | IoError | InvalidMediaInputError | UnsupportedMediaInputError;
|
|
96
|
+
export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | CannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | InputDataTooLong | InvalidEntropyDataLength | InvalidUsernameLinkEncryptedData | IoError | InvalidMediaInputError | UnsupportedMediaInputError;
|
package/dist/Errors.js
CHANGED
|
@@ -25,6 +25,9 @@ var ErrorCode;
|
|
|
25
25
|
ErrorCode[ErrorCode["IoError"] = 14] = "IoError";
|
|
26
26
|
ErrorCode[ErrorCode["InvalidMediaInput"] = 15] = "InvalidMediaInput";
|
|
27
27
|
ErrorCode[ErrorCode["UnsupportedMediaInput"] = 16] = "UnsupportedMediaInput";
|
|
28
|
+
ErrorCode[ErrorCode["InputDataTooLong"] = 17] = "InputDataTooLong";
|
|
29
|
+
ErrorCode[ErrorCode["InvalidEntropyDataLength"] = 18] = "InvalidEntropyDataLength";
|
|
30
|
+
ErrorCode[ErrorCode["InvalidUsernameLinkEncryptedData"] = 19] = "InvalidUsernameLinkEncryptedData";
|
|
28
31
|
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
|
|
29
32
|
class LibSignalErrorBase extends Error {
|
|
30
33
|
constructor(message, name, operation, extraProps) {
|
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.
|
|
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/dist/usernames.d.ts
CHANGED
|
@@ -3,4 +3,11 @@ export declare function generateCandidates(nickname: string, minNicknameLength:
|
|
|
3
3
|
export declare function hash(username: string): Buffer;
|
|
4
4
|
export declare function generateProof(username: string): Buffer;
|
|
5
5
|
export declare function generateProofWithRandom(username: string, random: Buffer): Buffer;
|
|
6
|
+
export declare class UsernameLink {
|
|
7
|
+
readonly entropy: Buffer;
|
|
8
|
+
readonly encryptedUsername: Buffer;
|
|
9
|
+
constructor(entropy: Buffer, encryptedUsername: Buffer);
|
|
10
|
+
decryptUsername(): string;
|
|
11
|
+
}
|
|
12
|
+
export declare function createUsernameLink(username: string): UsernameLink;
|
|
6
13
|
export declare function verifyProof(proof: Buffer, hash: Buffer): void;
|
package/dist/usernames.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
5
|
//
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.verifyProof = exports.generateProofWithRandom = exports.generateProof = exports.hash = exports.generateCandidates = void 0;
|
|
7
|
+
exports.verifyProof = exports.createUsernameLink = exports.UsernameLink = exports.generateProofWithRandom = exports.generateProof = exports.hash = exports.generateCandidates = void 0;
|
|
8
8
|
/* eslint @typescript-eslint/no-shadow: ["error", { "allow": ["hash"] }] */
|
|
9
9
|
const crypto_1 = require("crypto");
|
|
10
10
|
const Constants_1 = require("./zkgroup/internal/Constants");
|
|
@@ -26,6 +26,23 @@ function generateProofWithRandom(username, random) {
|
|
|
26
26
|
return Native.Username_Proof(username, random);
|
|
27
27
|
}
|
|
28
28
|
exports.generateProofWithRandom = generateProofWithRandom;
|
|
29
|
+
class UsernameLink {
|
|
30
|
+
constructor(entropy, encryptedUsername) {
|
|
31
|
+
this.entropy = entropy;
|
|
32
|
+
this.encryptedUsername = encryptedUsername;
|
|
33
|
+
}
|
|
34
|
+
decryptUsername() {
|
|
35
|
+
return Native.UsernameLink_DecryptUsername(this.entropy, this.encryptedUsername);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.UsernameLink = UsernameLink;
|
|
39
|
+
function createUsernameLink(username) {
|
|
40
|
+
const usernameLinkData = Native.UsernameLink_Create(username);
|
|
41
|
+
const entropy = usernameLinkData.slice(0, 32);
|
|
42
|
+
const encryptedUsername = usernameLinkData.slice(32);
|
|
43
|
+
return new UsernameLink(entropy, encryptedUsername);
|
|
44
|
+
}
|
|
45
|
+
exports.createUsernameLink = createUsernameLink;
|
|
29
46
|
// Only for testing. Will throw on failure.
|
|
30
47
|
function verifyProof(proof, hash) {
|
|
31
48
|
Native.Username_Verify(proof, hash);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalapp/libsignal-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|