fca-nx 6.6.8 → 6.7.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.
Files changed (51) hide show
  1. package/module/login.js +17 -8
  2. package/module/loginHelper.js +31 -2
  3. package/package.json +3 -2
  4. package/src/api/messaging/uploadAttachment.js +2 -2
  5. package/src/api/socket/core/getSeqID.js +53 -58
  6. package/src/api/socket/e2ee/index.js +1 -1
  7. package/src/api/socket/listenE2EE.js +14 -4
  8. package/src/api/socket/listenMqtt.js +20 -12
  9. package/src/utils/format/utils.js +18 -12
  10. package/src/utils/utils.js +15 -6
  11. package/e2ee/config.json +0 -0
  12. package/e2ee/crypto.js +0 -173
  13. package/e2ee/index.js +0 -1032
  14. package/e2ee/proto/ArmadilloApplication.proto +0 -281
  15. package/e2ee/proto/ArmadilloICDC.proto +0 -14
  16. package/e2ee/proto/ConsumerApplication.proto +0 -232
  17. package/e2ee/proto/MessageApplication.proto +0 -82
  18. package/e2ee/proto/MessageTransport.proto +0 -77
  19. package/e2ee/proto/WACommon.proto +0 -66
  20. package/e2ee/proto/WAMediaTransport.proto +0 -176
  21. package/e2ee/protocol.js +0 -196
  22. package/e2ee/ratchet.js +0 -219
  23. package/e2ee/store.js +0 -182
  24. package/e2ee/vendor/fb-e2ee.cjs +0 -9159
  25. package/e2ee/vendor/proto/ArmadilloApplication.proto +0 -281
  26. package/e2ee/vendor/proto/ArmadilloICDC.proto +0 -14
  27. package/e2ee/vendor/proto/ConsumerApplication.proto +0 -232
  28. package/e2ee/vendor/proto/MessageApplication.proto +0 -82
  29. package/e2ee/vendor/proto/MessageTransport.proto +0 -77
  30. package/e2ee/vendor/proto/WACommon.proto +0 -66
  31. package/e2ee/vendor/proto/WAMediaTransport.proto +0 -176
  32. package/src/api/socket/e2ee/e2ee/crypto.js +0 -173
  33. package/src/api/socket/e2ee/e2ee/index.js +0 -421
  34. package/src/api/socket/e2ee/e2ee/proto/ArmadilloApplication.proto +0 -281
  35. package/src/api/socket/e2ee/e2ee/proto/ArmadilloICDC.proto +0 -14
  36. package/src/api/socket/e2ee/e2ee/proto/ConsumerApplication.proto +0 -232
  37. package/src/api/socket/e2ee/e2ee/proto/MessageApplication.proto +0 -82
  38. package/src/api/socket/e2ee/e2ee/proto/MessageTransport.proto +0 -77
  39. package/src/api/socket/e2ee/e2ee/proto/WACommon.proto +0 -66
  40. package/src/api/socket/e2ee/e2ee/proto/WAMediaTransport.proto +0 -176
  41. package/src/api/socket/e2ee/e2ee/protocol.js +0 -196
  42. package/src/api/socket/e2ee/e2ee/ratchet.js +0 -219
  43. package/src/api/socket/e2ee/e2ee/store.js +0 -182
  44. package/src/api/socket/e2ee/e2ee/vendor/fb-e2ee.cjs +0 -9162
  45. package/src/api/socket/e2ee/e2ee/vendor/proto/ArmadilloApplication.proto +0 -281
  46. package/src/api/socket/e2ee/e2ee/vendor/proto/ArmadilloICDC.proto +0 -14
  47. package/src/api/socket/e2ee/e2ee/vendor/proto/ConsumerApplication.proto +0 -232
  48. package/src/api/socket/e2ee/e2ee/vendor/proto/MessageApplication.proto +0 -82
  49. package/src/api/socket/e2ee/e2ee/vendor/proto/MessageTransport.proto +0 -77
  50. package/src/api/socket/e2ee/e2ee/vendor/proto/WACommon.proto +0 -66
  51. package/src/api/socket/e2ee/e2ee/vendor/proto/WAMediaTransport.proto +0 -176
@@ -1,66 +0,0 @@
1
- syntax = "proto2";
2
- package WACommon;
3
-
4
- enum FutureProofBehavior {
5
- PLACEHOLDER = 0;
6
- NO_PLACEHOLDER = 1;
7
- IGNORE = 2;
8
- }
9
-
10
- message MessageKey {
11
- optional string remoteJID = 1;
12
- optional bool fromMe = 2;
13
- optional string ID = 3;
14
- optional string participant = 4;
15
- }
16
-
17
- message Command {
18
- enum CommandType {
19
- EVERYONE = 1;
20
- SILENT = 2;
21
- AI = 3;
22
- AI_IMAGINE = 4;
23
- }
24
-
25
- optional CommandType commandType = 1;
26
- optional uint32 offset = 2;
27
- optional uint32 length = 3;
28
- optional string validationToken = 4;
29
- }
30
-
31
- message Mention {
32
- enum MentionType {
33
- PROFILE = 0;
34
- }
35
-
36
- optional MentionType mentionType = 1;
37
- optional string mentionedJID = 2;
38
- optional uint32 offset = 3;
39
- optional uint32 length = 4;
40
- }
41
-
42
- message MessageText {
43
- optional string text = 1;
44
- repeated string mentionedJID = 2;
45
- repeated Command commands = 3;
46
- repeated Mention mentions = 4;
47
- }
48
-
49
- message SubProtocol {
50
- optional bytes payload = 1;
51
- optional int32 version = 2;
52
- }
53
-
54
- message LimitSharing {
55
- enum Trigger {
56
- UNKNOWN = 0;
57
- CHAT_SETTING = 1;
58
- BIZ_SUPPORTS_FB_HOSTING = 2;
59
- UNKNOWN_GROUP = 3;
60
- }
61
-
62
- optional bool sharingLimited = 1;
63
- optional Trigger trigger = 2;
64
- optional int64 limitSharingSettingTimestamp = 3;
65
- optional bool initiatedByMe = 4;
66
- }
@@ -1,176 +0,0 @@
1
- syntax = "proto2";
2
- package WAMediaTransport;
3
-
4
- import "WACommon.proto";
5
-
6
- message WAMediaTransport {
7
- message Ancillary {
8
- message Thumbnail {
9
- message DownloadableThumbnail {
10
- optional bytes fileSHA256 = 1;
11
- optional bytes fileEncSHA256 = 2;
12
- optional string directPath = 3;
13
- optional bytes mediaKey = 4;
14
- optional int64 mediaKeyTimestamp = 5;
15
- optional string objectID = 6;
16
- optional bytes thumbnailScansSidecar = 7;
17
- repeated uint32 thumbnailScanLengths = 8;
18
- }
19
-
20
- optional bytes JPEGThumbnail = 1;
21
- optional DownloadableThumbnail downloadableThumbnail = 2;
22
- optional uint32 thumbnailWidth = 3;
23
- optional uint32 thumbnailHeight = 4;
24
- }
25
-
26
- optional uint64 fileLength = 1;
27
- optional string mimetype = 2;
28
- optional Thumbnail thumbnail = 3;
29
- optional string objectID = 4;
30
- }
31
-
32
- message Integral {
33
- optional bytes fileSHA256 = 1;
34
- optional bytes mediaKey = 2;
35
- optional bytes fileEncSHA256 = 3;
36
- optional string directPath = 4;
37
- optional int64 mediaKeyTimestamp = 5;
38
- }
39
-
40
- optional Integral integral = 1;
41
- optional Ancillary ancillary = 2;
42
- }
43
-
44
- message ImageTransport {
45
- message Ancillary {
46
- enum HdType {
47
- NONE = 0;
48
- LQ_4K = 1;
49
- HQ_4K = 2;
50
- }
51
-
52
- optional uint32 height = 1;
53
- optional uint32 width = 2;
54
- optional bytes scansSidecar = 3;
55
- repeated uint32 scanLengths = 4;
56
- optional bytes midQualityFileSHA256 = 5;
57
- optional HdType hdType = 6;
58
- repeated float memoriesConceptScores = 7 [packed=true];
59
- repeated uint32 memoriesConceptIDs = 8 [packed=true];
60
- }
61
-
62
- message Integral {
63
- optional WAMediaTransport transport = 1;
64
- }
65
-
66
- optional Integral integral = 1;
67
- optional Ancillary ancillary = 2;
68
- }
69
-
70
- message VideoTransport {
71
- message Ancillary {
72
- enum Attribution {
73
- NONE = 0;
74
- GIPHY = 1;
75
- TENOR = 2;
76
- }
77
-
78
- optional uint32 seconds = 1;
79
- optional WACommon.MessageText caption = 2;
80
- optional bool gifPlayback = 3;
81
- optional uint32 height = 4;
82
- optional uint32 width = 5;
83
- optional bytes sidecar = 6;
84
- optional Attribution gifAttribution = 7;
85
- optional string accessibilityLabel = 8;
86
- optional bool isHd = 9;
87
- }
88
-
89
- message Integral {
90
- optional WAMediaTransport transport = 1;
91
- }
92
-
93
- optional Integral integral = 1;
94
- optional Ancillary ancillary = 2;
95
- }
96
-
97
- message AudioTransport {
98
- message Ancillary {
99
- message AvatarAudio {
100
- enum AnimationsType {
101
- TALKING_A = 0;
102
- IDLE_A = 1;
103
- TALKING_B = 2;
104
- IDLE_B = 3;
105
- BACKGROUND = 4;
106
- }
107
-
108
- message DownloadableAvatarAnimations {
109
- optional bytes fileSHA256 = 1;
110
- optional bytes fileEncSHA256 = 2;
111
- optional string directPath = 3;
112
- optional bytes mediaKey = 4;
113
- optional int64 mediaKeyTimestamp = 5;
114
- optional string objectID = 6;
115
- optional AnimationsType animationsType = 7;
116
- }
117
-
118
- optional uint32 poseID = 1;
119
- repeated DownloadableAvatarAnimations avatarAnimations = 2;
120
- }
121
-
122
- optional uint32 seconds = 1;
123
- optional AvatarAudio avatarAudio = 2;
124
- optional string waveformData = 3;
125
- optional bytes waveform = 4;
126
- }
127
-
128
- message Integral {
129
- enum AudioFormat {
130
- UNKNOWN = 0;
131
- OPUS = 1;
132
- }
133
-
134
- optional WAMediaTransport transport = 1;
135
- optional AudioFormat audioFormat = 2;
136
- }
137
-
138
- optional Integral integral = 1;
139
- optional Ancillary ancillary = 2;
140
- }
141
-
142
- message DocumentTransport {
143
- message Ancillary {
144
- optional uint32 pageCount = 1;
145
- }
146
-
147
- message Integral {
148
- optional WAMediaTransport transport = 1;
149
- }
150
-
151
- optional Integral integral = 1;
152
- optional Ancillary ancillary = 2;
153
- }
154
-
155
- message StickerTransport {
156
- message Ancillary {
157
- optional uint32 pageCount = 1;
158
- optional uint32 height = 2;
159
- optional uint32 width = 3;
160
- optional uint32 firstFrameLength = 4;
161
- optional bytes firstFrameSidecar = 5;
162
- optional string mustacheText = 6;
163
- optional bool isThirdParty = 7;
164
- optional string receiverFetchID = 8;
165
- optional string accessibilityLabel = 9;
166
- }
167
-
168
- message Integral {
169
- optional WAMediaTransport transport = 1;
170
- optional bool isAnimated = 2;
171
- optional string receiverFetchID = 3;
172
- }
173
-
174
- optional Integral integral = 1;
175
- optional Ancillary ancillary = 2;
176
- }
@@ -1,173 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * SHADOWX E2EE Crypto — All primitives using Node.js built-in crypto only.
5
- * Implements: X25519 DH, HKDF-SHA256, AES-256-GCM, HMAC-SHA256
6
- * Node.js >= 15 required (crypto.hkdfSync, crypto.generateKeyPairSync x25519).
7
- */
8
-
9
- const crypto = require("crypto");
10
-
11
- // ─────────────────────────────────────────────────────────
12
- // X25519 Key Management
13
- // ─────────────────────────────────────────────────────────
14
-
15
- function generateKeyPair() {
16
- const { privateKey, publicKey } = crypto.generateKeyPairSync("x25519", {
17
- privateKeyEncoding: { type: "pkcs8", format: "der" },
18
- publicKeyEncoding: { type: "spki", format: "der" }
19
- });
20
- return {
21
- privateKey,
22
- publicKey,
23
- publicKeyRaw: exportRawPublicKey(publicKey)
24
- };
25
- }
26
-
27
- function exportRawPublicKey(spkiDer) {
28
- // X25519 SPKI DER: 12 bytes header + 32 bytes key
29
- return Buffer.from(spkiDer).slice(-32);
30
- }
31
-
32
- function importPublicKey(raw32bytes) {
33
- if (raw32bytes.length !== 32) throw new Error("X25519 public key must be 32 bytes");
34
- // Build minimal SPKI wrapper for X25519
35
- const header = Buffer.from("302a300506032b656e032100", "hex");
36
- return Buffer.concat([header, raw32bytes]);
37
- }
38
-
39
- function dh(privateKeyPkcs8Der, peerPublicRaw32) {
40
- const privKey = crypto.createPrivateKey({ key: Buffer.from(privateKeyPkcs8Der), format: "der", type: "pkcs8" });
41
- const pubKeyDer = importPublicKey(Buffer.from(peerPublicRaw32));
42
- const pubKey = crypto.createPublicKey({ key: pubKeyDer, format: "der", type: "spki" });
43
- return crypto.diffieHellman({ privateKey: privKey, publicKey: pubKey });
44
- }
45
-
46
- // ─────────────────────────────────────────────────────────
47
- // HKDF-SHA256
48
- // ─────────────────────────────────────────────────────────
49
-
50
- function hkdf(ikm, length, salt, info) {
51
- if (!salt) salt = Buffer.alloc(32, 0);
52
- if (!info) info = Buffer.alloc(0);
53
- if (typeof info === "string") info = Buffer.from(info, "utf8");
54
- return Buffer.from(crypto.hkdfSync("sha256", ikm, salt, info, length));
55
- }
56
-
57
- function hkdfExtract(salt, ikm) {
58
- return crypto.createHmac("sha256", salt).update(ikm).digest();
59
- }
60
-
61
- function hkdfExpand(prk, info, length) {
62
- const results = [];
63
- let t = Buffer.alloc(0);
64
- let i = 0;
65
- while (results.reduce((s, b) => s + b.length, 0) < length) {
66
- i++;
67
- const hmac = crypto.createHmac("sha256", prk);
68
- hmac.update(t);
69
- if (info) hmac.update(info);
70
- hmac.update(Buffer.from([i]));
71
- t = hmac.digest();
72
- results.push(t);
73
- }
74
- return Buffer.concat(results).slice(0, length);
75
- }
76
-
77
- // ─────────────────────────────────────────────────────────
78
- // AES-256-GCM
79
- // ─────────────────────────────────────────────────────────
80
-
81
- function encrypt(key32, plaintext, aad) {
82
- if (key32.length !== 32) throw new Error("AES-GCM key must be 32 bytes");
83
- const iv = crypto.randomBytes(12);
84
- const cipher = crypto.createCipheriv("aes-256-gcm", key32, iv);
85
- if (aad) cipher.setAAD(aad);
86
- const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
87
- const authTag = cipher.getAuthTag();
88
- return Buffer.concat([iv, authTag, encrypted]);
89
- }
90
-
91
- function decrypt(key32, ciphertext, aad) {
92
- if (key32.length !== 32) throw new Error("AES-GCM key must be 32 bytes");
93
- if (ciphertext.length < 28) throw new Error("Ciphertext too short");
94
- const iv = ciphertext.slice(0, 12);
95
- const authTag = ciphertext.slice(12, 28);
96
- const data = ciphertext.slice(28);
97
- const decipher = crypto.createDecipheriv("aes-256-gcm", key32, iv);
98
- decipher.setAuthTag(authTag);
99
- if (aad) decipher.setAAD(aad);
100
- return Buffer.concat([decipher.update(data), decipher.final()]);
101
- }
102
-
103
- // ─────────────────────────────────────────────────────────
104
- // HMAC-SHA256
105
- // ─────────────────────────────────────────────────────────
106
-
107
- function hmacSha256(key, data) {
108
- return crypto.createHmac("sha256", key).update(data).digest();
109
- }
110
-
111
- function constantTimeEqual(a, b) {
112
- if (a.length !== b.length) return false;
113
- return crypto.timingSafeEqual(a, b);
114
- }
115
-
116
- // ─────────────────────────────────────────────────────────
117
- // X3DH Key Agreement (Extended Triple Diffie-Hellman)
118
- // ─────────────────────────────────────────────────────────
119
-
120
- /**
121
- * Sender side of X3DH.
122
- * @param {object} senderIdKey - { privateKey, publicKey, publicKeyRaw } of sender identity key
123
- * @param {object} ephemeralKey - { privateKey, publicKey, publicKeyRaw } of ephemeral key
124
- * @param {Buffer} recipientIdPub - recipient's identity public key (raw 32 bytes)
125
- * @param {Buffer} recipientSpkPub - recipient's signed pre-key (raw 32 bytes)
126
- * @param {Buffer} [recipientOpkPub] - recipient's one-time pre-key (raw 32 bytes), optional
127
- * @returns {Buffer} 32-byte shared master secret
128
- */
129
- function x3dhSend(senderIdKey, ephemeralKey, recipientIdPub, recipientSpkPub, recipientOpkPub) {
130
- const dh1 = dh(senderIdKey.privateKey, recipientSpkPub);
131
- const dh2 = dh(ephemeralKey.privateKey, recipientIdPub);
132
- const dh3 = dh(ephemeralKey.privateKey, recipientSpkPub);
133
- const parts = recipientOpkPub
134
- ? [dh1, dh2, dh3, dh(ephemeralKey.privateKey, recipientOpkPub)]
135
- : [dh1, dh2, dh3];
136
- const ikm = Buffer.concat(parts);
137
- const F = Buffer.alloc(32, 0xFF);
138
- const salt = Buffer.alloc(32, 0);
139
- return hkdf(Buffer.concat([F, ikm]), 32, salt, Buffer.from("WhisperText", "utf8"));
140
- }
141
-
142
- /**
143
- * Receiver side of X3DH.
144
- */
145
- function x3dhReceive(recipientIdKey, recipientSpkKey, recipientOpkKey, senderIdPub, senderEphemeralPub) {
146
- const dh1 = dh(recipientSpkKey.privateKey, senderIdPub);
147
- const dh2 = dh(recipientIdKey.privateKey, senderEphemeralPub);
148
- const dh3 = dh(recipientSpkKey.privateKey, senderEphemeralPub);
149
- const parts = recipientOpkKey
150
- ? [dh1, dh2, dh3, dh(recipientOpkKey.privateKey, senderEphemeralPub)]
151
- : [dh1, dh2, dh3];
152
- const ikm = Buffer.concat(parts);
153
- const F = Buffer.alloc(32, 0xFF);
154
- const salt = Buffer.alloc(32, 0);
155
- return hkdf(Buffer.concat([F, ikm]), 32, salt, Buffer.from("WhisperText", "utf8"));
156
- }
157
-
158
- module.exports = {
159
- generateKeyPair,
160
- exportRawPublicKey,
161
- importPublicKey,
162
- dh,
163
- hkdf,
164
- hkdfExtract,
165
- hkdfExpand,
166
- encrypt,
167
- decrypt,
168
- hmacSha256,
169
- constantTimeEqual,
170
- x3dhSend,
171
- x3dhReceive,
172
- randomBytes: crypto.randomBytes.bind(crypto)
173
- };