violetics 7.0.0-alpha → 7.0.2-alpha
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/LICENSE +3 -2
- package/README.md +1001 -232
- package/WAProto/index.js +75379 -142631
- package/engine-requirements.js +11 -8
- package/lib/Defaults/index.js +132 -144
- package/lib/Signal/Group/ciphertext-message.js +2 -6
- package/lib/Signal/Group/group-session-builder.js +7 -42
- package/lib/Signal/Group/group_cipher.js +37 -52
- package/lib/Signal/Group/index.js +11 -57
- package/lib/Signal/Group/keyhelper.js +7 -45
- package/lib/Signal/Group/sender-chain-key.js +7 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +8 -12
- package/lib/Signal/Group/sender-key-message.js +9 -13
- package/lib/Signal/Group/sender-key-name.js +2 -6
- package/lib/Signal/Group/sender-key-record.js +9 -22
- package/lib/Signal/Group/sender-key-state.js +27 -43
- package/lib/Signal/Group/sender-message-key.js +4 -8
- package/lib/Signal/libsignal.js +319 -94
- package/lib/Signal/lid-mapping.js +224 -139
- package/lib/Socket/Client/index.js +2 -19
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.js +162 -44
- package/lib/Socket/chats.js +477 -442
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/groups.js +110 -99
- package/lib/Socket/index.js +10 -10
- package/lib/Socket/messages-recv.js +878 -552
- package/lib/Socket/messages-send.js +859 -428
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.js +195 -390
- package/lib/Socket/socket.js +463 -289
- package/lib/Store/index.js +3 -10
- package/lib/Store/make-in-memory-store.js +73 -79
- package/lib/Store/make-ordered-dictionary.js +4 -7
- package/lib/Store/object-repository.js +2 -6
- package/lib/Types/Auth.js +1 -2
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.js +1 -2
- package/lib/Types/Chat.js +7 -4
- package/lib/Types/Contact.js +1 -2
- package/lib/Types/Events.js +1 -2
- package/lib/Types/GroupMetadata.js +1 -2
- package/lib/Types/Label.js +2 -5
- package/lib/Types/LabelAssociation.js +2 -5
- package/lib/Types/Message.js +17 -9
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.js +1 -2
- package/lib/Types/Signal.js +1 -2
- package/lib/Types/Socket.js +2 -2
- package/lib/Types/State.js +12 -2
- package/lib/Types/USync.js +1 -2
- package/lib/Types/index.js +14 -31
- package/lib/Utils/auth-utils.js +228 -145
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.js +66 -70
- package/lib/Utils/chat-utils.js +331 -249
- package/lib/Utils/crypto.js +57 -91
- package/lib/Utils/decode-wa-message.js +168 -84
- package/lib/Utils/event-buffer.js +138 -80
- package/lib/Utils/generics.js +180 -297
- package/lib/Utils/history.js +83 -49
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.js +19 -33
- package/lib/Utils/link-preview.js +14 -23
- package/lib/Utils/logger.js +2 -7
- package/lib/Utils/lt-hash.js +2 -46
- package/lib/Utils/make-mutex.js +24 -35
- package/lib/Utils/message-retry-manager.js +224 -0
- package/lib/Utils/messages-media.js +501 -496
- package/lib/Utils/messages.js +1428 -362
- package/lib/Utils/noise-handler.js +145 -100
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.js +356 -150
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/signal.js +78 -73
- package/lib/Utils/sync-action-utils.js +47 -0
- package/lib/Utils/tc-token-utils.js +17 -0
- package/lib/Utils/use-multi-file-auth-state.js +32 -34
- package/lib/Utils/validate-connection.js +91 -107
- package/lib/WABinary/constants.js +1300 -1304
- package/lib/WABinary/decode.js +26 -48
- package/lib/WABinary/encode.js +109 -155
- package/lib/WABinary/generic-utils.js +161 -149
- package/lib/WABinary/index.js +5 -21
- package/lib/WABinary/jid-utils.js +73 -40
- package/lib/WABinary/types.js +1 -2
- package/lib/WAM/BinaryInfo.js +2 -6
- package/lib/WAM/constants.js +19070 -11568
- package/lib/WAM/encode.js +17 -23
- package/lib/WAM/index.js +3 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -12
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -15
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -14
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -23
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -9
- package/lib/WAUSync/Protocols/index.js +4 -20
- package/lib/WAUSync/USyncQuery.js +40 -36
- package/lib/WAUSync/USyncUser.js +2 -6
- package/lib/WAUSync/index.js +3 -19
- package/lib/index.js +11 -44
- package/package.json +75 -108
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -111
- package/lib/Socket/groupStatus.js +0 -637
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/baileys-event-stream.js +0 -63
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const crypto_1 = require("libsignal/src/crypto");
|
|
5
|
-
const sender_message_key_1 = require("./sender-message-key");
|
|
6
|
-
class SenderChainKey {
|
|
1
|
+
import { calculateMAC } from 'libsignal/src/crypto.js';
|
|
2
|
+
import { SenderMessageKey } from './sender-message-key.js';
|
|
3
|
+
export class SenderChainKey {
|
|
7
4
|
constructor(iteration, chainKey) {
|
|
8
5
|
this.MESSAGE_KEY_SEED = Buffer.from([0x01]);
|
|
9
6
|
this.CHAIN_KEY_SEED = Buffer.from([0x02]);
|
|
10
7
|
this.iteration = iteration;
|
|
11
|
-
|
|
12
|
-
this.chainKey = chainKey;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
this.chainKey = Buffer.from(chainKey || []);
|
|
16
|
-
}
|
|
8
|
+
this.chainKey = Buffer.from(chainKey);
|
|
17
9
|
}
|
|
18
10
|
getIteration() {
|
|
19
11
|
return this.iteration;
|
|
20
12
|
}
|
|
21
13
|
getSenderMessageKey() {
|
|
22
|
-
return new
|
|
14
|
+
return new SenderMessageKey(this.iteration, this.getDerivative(this.MESSAGE_KEY_SEED, this.chainKey));
|
|
23
15
|
}
|
|
24
16
|
getNext() {
|
|
25
17
|
return new SenderChainKey(this.iteration + 1, this.getDerivative(this.CHAIN_KEY_SEED, this.chainKey));
|
|
@@ -28,7 +20,6 @@ class SenderChainKey {
|
|
|
28
20
|
return this.chainKey;
|
|
29
21
|
}
|
|
30
22
|
getDerivative(seed, key) {
|
|
31
|
-
return
|
|
23
|
+
return calculateMAC(key, seed);
|
|
32
24
|
}
|
|
33
|
-
}
|
|
34
|
-
exports.SenderChainKey = SenderChainKey;
|
|
25
|
+
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const WAProto_1 = require("../../../WAProto");
|
|
5
|
-
const ciphertext_message_1 = require("./ciphertext-message");
|
|
6
|
-
class SenderKeyDistributionMessage extends ciphertext_message_1.CiphertextMessage {
|
|
1
|
+
import { proto } from '../../../WAProto/index.js';
|
|
2
|
+
import { CiphertextMessage } from './ciphertext-message.js';
|
|
3
|
+
export class SenderKeyDistributionMessage extends CiphertextMessage {
|
|
7
4
|
constructor(id, iteration, chainKey, signatureKey, serialized) {
|
|
8
5
|
super();
|
|
9
6
|
if (serialized) {
|
|
10
7
|
try {
|
|
11
8
|
const message = serialized.slice(1);
|
|
12
|
-
const distributionMessage =
|
|
9
|
+
const distributionMessage = proto.SenderKeyDistributionMessage.decode(message).toJSON();
|
|
13
10
|
this.serialized = serialized;
|
|
14
11
|
this.id = distributionMessage.id;
|
|
15
12
|
this.iteration = distributionMessage.iteration;
|
|
@@ -32,7 +29,7 @@ class SenderKeyDistributionMessage extends ciphertext_message_1.CiphertextMessag
|
|
|
32
29
|
this.iteration = iteration;
|
|
33
30
|
this.chainKey = chainKey;
|
|
34
31
|
this.signatureKey = signatureKey;
|
|
35
|
-
const message =
|
|
32
|
+
const message = proto.SenderKeyDistributionMessage.encode(proto.SenderKeyDistributionMessage.create({
|
|
36
33
|
id,
|
|
37
34
|
iteration,
|
|
38
35
|
chainKey,
|
|
@@ -54,13 +51,12 @@ class SenderKeyDistributionMessage extends ciphertext_message_1.CiphertextMessag
|
|
|
54
51
|
return this.iteration;
|
|
55
52
|
}
|
|
56
53
|
getChainKey() {
|
|
57
|
-
return
|
|
54
|
+
return this.chainKey;
|
|
58
55
|
}
|
|
59
56
|
getSignatureKey() {
|
|
60
|
-
return
|
|
57
|
+
return this.signatureKey;
|
|
61
58
|
}
|
|
62
59
|
getId() {
|
|
63
60
|
return this.id;
|
|
64
61
|
}
|
|
65
|
-
}
|
|
66
|
-
exports.SenderKeyDistributionMessage = SenderKeyDistributionMessage;
|
|
62
|
+
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const WAProto_1 = require("../../../WAProto");
|
|
6
|
-
const ciphertext_message_1 = require("./ciphertext-message");
|
|
7
|
-
class SenderKeyMessage extends ciphertext_message_1.CiphertextMessage {
|
|
1
|
+
import { calculateSignature, verifySignature } from 'libsignal/src/curve.js';
|
|
2
|
+
import { proto } from '../../../WAProto/index.js';
|
|
3
|
+
import { CiphertextMessage } from './ciphertext-message.js';
|
|
4
|
+
export class SenderKeyMessage extends CiphertextMessage {
|
|
8
5
|
constructor(keyId, iteration, ciphertext, signatureKey, serialized) {
|
|
9
6
|
super();
|
|
10
7
|
this.SIGNATURE_LENGTH = 64;
|
|
@@ -12,7 +9,7 @@ class SenderKeyMessage extends ciphertext_message_1.CiphertextMessage {
|
|
|
12
9
|
const version = serialized[0];
|
|
13
10
|
const message = serialized.slice(1, serialized.length - this.SIGNATURE_LENGTH);
|
|
14
11
|
const signature = serialized.slice(-1 * this.SIGNATURE_LENGTH);
|
|
15
|
-
const senderKeyMessage =
|
|
12
|
+
const senderKeyMessage = proto.SenderKeyMessage.decode(message).toJSON();
|
|
16
13
|
this.serialized = serialized;
|
|
17
14
|
this.messageVersion = (version & 0xff) >> 4;
|
|
18
15
|
this.keyId = senderKeyMessage.id;
|
|
@@ -26,7 +23,7 @@ class SenderKeyMessage extends ciphertext_message_1.CiphertextMessage {
|
|
|
26
23
|
else {
|
|
27
24
|
const version = (((this.CURRENT_VERSION << 4) | this.CURRENT_VERSION) & 0xff) % 256;
|
|
28
25
|
const ciphertextBuffer = Buffer.from(ciphertext);
|
|
29
|
-
const message =
|
|
26
|
+
const message = proto.SenderKeyMessage.encode(proto.SenderKeyMessage.create({
|
|
30
27
|
id: keyId,
|
|
31
28
|
iteration: iteration,
|
|
32
29
|
ciphertext: ciphertextBuffer
|
|
@@ -52,12 +49,12 @@ class SenderKeyMessage extends ciphertext_message_1.CiphertextMessage {
|
|
|
52
49
|
verifySignature(signatureKey) {
|
|
53
50
|
const part1 = this.serialized.slice(0, this.serialized.length - this.SIGNATURE_LENGTH);
|
|
54
51
|
const part2 = this.serialized.slice(-1 * this.SIGNATURE_LENGTH);
|
|
55
|
-
const res =
|
|
52
|
+
const res = verifySignature(signatureKey, part1, part2);
|
|
56
53
|
if (!res)
|
|
57
54
|
throw new Error('Invalid signature!');
|
|
58
55
|
}
|
|
59
56
|
getSignature(signatureKey, serialized) {
|
|
60
|
-
return Buffer.from(
|
|
57
|
+
return Buffer.from(calculateSignature(signatureKey, serialized));
|
|
61
58
|
}
|
|
62
59
|
serialize() {
|
|
63
60
|
return this.serialized;
|
|
@@ -65,5 +62,4 @@ class SenderKeyMessage extends ciphertext_message_1.CiphertextMessage {
|
|
|
65
62
|
getType() {
|
|
66
63
|
return 4;
|
|
67
64
|
}
|
|
68
|
-
}
|
|
69
|
-
exports.SenderKeyMessage = SenderKeyMessage;
|
|
65
|
+
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SenderKeyName = void 0;
|
|
4
1
|
function isNull(str) {
|
|
5
2
|
return str === null || str === '';
|
|
6
3
|
}
|
|
@@ -22,7 +19,7 @@ function hashCode(strKey) {
|
|
|
22
19
|
}
|
|
23
20
|
return hash;
|
|
24
21
|
}
|
|
25
|
-
class SenderKeyName {
|
|
22
|
+
export class SenderKeyName {
|
|
26
23
|
constructor(groupId, sender) {
|
|
27
24
|
this.groupId = groupId;
|
|
28
25
|
this.sender = sender;
|
|
@@ -47,5 +44,4 @@ class SenderKeyName {
|
|
|
47
44
|
hashCode() {
|
|
48
45
|
return hashCode(this.groupId) ^ hashCode(this.sender.toString());
|
|
49
46
|
}
|
|
50
|
-
}
|
|
51
|
-
exports.SenderKeyName = SenderKeyName;
|
|
47
|
+
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const generics_1 = require("../../Utils/generics");
|
|
5
|
-
const sender_key_state_1 = require("./sender-key-state");
|
|
6
|
-
class SenderKeyRecord {
|
|
1
|
+
import { BufferJSON } from '../../Utils/generics.js';
|
|
2
|
+
import { SenderKeyState } from './sender-key-state.js';
|
|
3
|
+
export class SenderKeyRecord {
|
|
7
4
|
constructor(serialized) {
|
|
8
5
|
this.MAX_STATES = 5;
|
|
9
6
|
this.senderKeyStates = [];
|
|
10
7
|
if (serialized) {
|
|
11
8
|
for (const structure of serialized) {
|
|
12
|
-
this.senderKeyStates.push(new
|
|
9
|
+
this.senderKeyStates.push(new SenderKeyState(null, null, null, null, null, null, structure));
|
|
13
10
|
}
|
|
14
11
|
}
|
|
15
12
|
}
|
|
@@ -23,31 +20,21 @@ class SenderKeyRecord {
|
|
|
23
20
|
return this.senderKeyStates.find(state => state.getKeyId() === keyId);
|
|
24
21
|
}
|
|
25
22
|
addSenderKeyState(id, iteration, chainKey, signatureKey) {
|
|
26
|
-
this.senderKeyStates.push(new
|
|
23
|
+
this.senderKeyStates.push(new SenderKeyState(id, iteration, chainKey, null, signatureKey));
|
|
27
24
|
if (this.senderKeyStates.length > this.MAX_STATES) {
|
|
28
25
|
this.senderKeyStates.shift();
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
28
|
setSenderKeyState(id, iteration, chainKey, keyPair) {
|
|
32
29
|
this.senderKeyStates.length = 0;
|
|
33
|
-
this.senderKeyStates.push(new
|
|
30
|
+
this.senderKeyStates.push(new SenderKeyState(id, iteration, chainKey, keyPair));
|
|
34
31
|
}
|
|
35
32
|
serialize() {
|
|
36
33
|
return this.senderKeyStates.map(state => state.getStructure());
|
|
37
34
|
}
|
|
38
35
|
static deserialize(data) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
parsed = JSON.parse(data, generics_1.BufferJSON.reviver);
|
|
42
|
-
}
|
|
43
|
-
else if (data instanceof Uint8Array) {
|
|
44
|
-
const str = Buffer.from(data).toString('utf-8');
|
|
45
|
-
parsed = JSON.parse(str, generics_1.BufferJSON.reviver);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
parsed = data;
|
|
49
|
-
}
|
|
36
|
+
const str = Buffer.from(data).toString('utf-8');
|
|
37
|
+
const parsed = JSON.parse(str, BufferJSON.reviver);
|
|
50
38
|
return new SenderKeyRecord(parsed);
|
|
51
39
|
}
|
|
52
|
-
}
|
|
53
|
-
exports.SenderKeyRecord = SenderKeyRecord;
|
|
40
|
+
}
|
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const sender_chain_key_1 = require("./sender-chain-key");
|
|
5
|
-
const sender_message_key_1 = require("./sender-message-key");
|
|
6
|
-
class SenderKeyState {
|
|
1
|
+
import { SenderChainKey } from './sender-chain-key.js';
|
|
2
|
+
import { SenderMessageKey } from './sender-message-key.js';
|
|
3
|
+
export class SenderKeyState {
|
|
7
4
|
constructor(id, iteration, chainKey, signatureKeyPair, signatureKeyPublic, signatureKeyPrivate, senderKeyStateStructure) {
|
|
8
5
|
this.MAX_MESSAGE_KEYS = 2000;
|
|
9
6
|
if (senderKeyStateStructure) {
|
|
10
|
-
this.senderKeyStateStructure =
|
|
7
|
+
this.senderKeyStateStructure = {
|
|
8
|
+
...senderKeyStateStructure,
|
|
9
|
+
senderMessageKeys: Array.isArray(senderKeyStateStructure.senderMessageKeys)
|
|
10
|
+
? senderKeyStateStructure.senderMessageKeys
|
|
11
|
+
: []
|
|
12
|
+
};
|
|
11
13
|
}
|
|
12
14
|
else {
|
|
13
15
|
if (signatureKeyPair) {
|
|
14
16
|
signatureKeyPublic = signatureKeyPair.public;
|
|
15
17
|
signatureKeyPrivate = signatureKeyPair.private;
|
|
16
18
|
}
|
|
17
|
-
chainKey = typeof chainKey === 'string' ? Buffer.from(chainKey, 'base64') : chainKey;
|
|
18
|
-
const senderChainKeyStructure = {
|
|
19
|
-
iteration: iteration || 0,
|
|
20
|
-
seed: chainKey || Buffer.alloc(0)
|
|
21
|
-
};
|
|
22
|
-
const signingKeyStructure = {
|
|
23
|
-
public: typeof signatureKeyPublic === 'string'
|
|
24
|
-
? Buffer.from(signatureKeyPublic, 'base64')
|
|
25
|
-
: signatureKeyPublic || Buffer.alloc(0)
|
|
26
|
-
};
|
|
27
|
-
if (signatureKeyPrivate) {
|
|
28
|
-
signingKeyStructure.private =
|
|
29
|
-
typeof signatureKeyPrivate === 'string' ? Buffer.from(signatureKeyPrivate, 'base64') : signatureKeyPrivate;
|
|
30
|
-
}
|
|
31
19
|
this.senderKeyStateStructure = {
|
|
32
20
|
senderKeyId: id || 0,
|
|
33
|
-
senderChainKey:
|
|
34
|
-
|
|
21
|
+
senderChainKey: {
|
|
22
|
+
iteration: iteration || 0,
|
|
23
|
+
seed: Buffer.from(chainKey || [])
|
|
24
|
+
},
|
|
25
|
+
senderSigningKey: {
|
|
26
|
+
public: Buffer.from(signatureKeyPublic || []),
|
|
27
|
+
private: Buffer.from(signatureKeyPrivate || [])
|
|
28
|
+
},
|
|
35
29
|
senderMessageKeys: []
|
|
36
30
|
};
|
|
37
31
|
}
|
|
@@ -40,7 +34,7 @@ class SenderKeyState {
|
|
|
40
34
|
return this.senderKeyStateStructure.senderKeyId;
|
|
41
35
|
}
|
|
42
36
|
getSenderChainKey() {
|
|
43
|
-
return new
|
|
37
|
+
return new SenderChainKey(this.senderKeyStateStructure.senderChainKey.iteration, this.senderKeyStateStructure.senderChainKey.seed);
|
|
44
38
|
}
|
|
45
39
|
setSenderChainKey(chainKey) {
|
|
46
40
|
this.senderKeyStateStructure.senderChainKey = {
|
|
@@ -49,26 +43,17 @@ class SenderKeyState {
|
|
|
49
43
|
};
|
|
50
44
|
}
|
|
51
45
|
getSigningKeyPublic() {
|
|
52
|
-
const publicKey = this.senderKeyStateStructure.senderSigningKey.public;
|
|
53
|
-
if (publicKey
|
|
54
|
-
|
|
46
|
+
const publicKey = Buffer.from(this.senderKeyStateStructure.senderSigningKey.public);
|
|
47
|
+
if (publicKey.length === 32) {
|
|
48
|
+
const fixed = Buffer.alloc(33);
|
|
49
|
+
fixed[0] = 0x05;
|
|
50
|
+
publicKey.copy(fixed, 1);
|
|
51
|
+
return fixed;
|
|
55
52
|
}
|
|
56
|
-
|
|
57
|
-
return Buffer.from(publicKey, 'base64');
|
|
58
|
-
}
|
|
59
|
-
return Buffer.from(publicKey || []);
|
|
53
|
+
return publicKey;
|
|
60
54
|
}
|
|
61
55
|
getSigningKeyPrivate() {
|
|
62
56
|
const privateKey = this.senderKeyStateStructure.senderSigningKey.private;
|
|
63
|
-
if (!privateKey) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
if (privateKey instanceof Buffer) {
|
|
67
|
-
return privateKey;
|
|
68
|
-
}
|
|
69
|
-
else if (typeof privateKey === 'string') {
|
|
70
|
-
return Buffer.from(privateKey, 'base64');
|
|
71
|
-
}
|
|
72
57
|
return Buffer.from(privateKey || []);
|
|
73
58
|
}
|
|
74
59
|
hasSenderMessageKey(iteration) {
|
|
@@ -88,12 +73,11 @@ class SenderKeyState {
|
|
|
88
73
|
if (index !== -1) {
|
|
89
74
|
const messageKey = this.senderKeyStateStructure.senderMessageKeys[index];
|
|
90
75
|
this.senderKeyStateStructure.senderMessageKeys.splice(index, 1);
|
|
91
|
-
return new
|
|
76
|
+
return new SenderMessageKey(messageKey.iteration, messageKey.seed);
|
|
92
77
|
}
|
|
93
78
|
return null;
|
|
94
79
|
}
|
|
95
80
|
getStructure() {
|
|
96
81
|
return this.senderKeyStateStructure;
|
|
97
82
|
}
|
|
98
|
-
}
|
|
99
|
-
exports.SenderKeyState = SenderKeyState;
|
|
83
|
+
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SenderMessageKey = void 0;
|
|
4
|
-
const crypto_1 = require("libsignal/src/crypto");
|
|
5
|
-
class SenderMessageKey {
|
|
1
|
+
import { deriveSecrets } from 'libsignal/src/crypto.js';
|
|
2
|
+
export class SenderMessageKey {
|
|
6
3
|
constructor(iteration, seed) {
|
|
7
|
-
const derivative =
|
|
4
|
+
const derivative = deriveSecrets(seed, Buffer.alloc(32), Buffer.from('WhisperGroup'));
|
|
8
5
|
const keys = new Uint8Array(32);
|
|
9
6
|
keys.set(new Uint8Array(derivative[0].slice(16)));
|
|
10
7
|
keys.set(new Uint8Array(derivative[1].slice(0, 16)), 16);
|
|
@@ -25,5 +22,4 @@ class SenderMessageKey {
|
|
|
25
22
|
getSeed() {
|
|
26
23
|
return this.seed;
|
|
27
24
|
}
|
|
28
|
-
}
|
|
29
|
-
exports.SenderMessageKey = SenderMessageKey;
|
|
25
|
+
}
|