rixleys 1.0.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 (128) hide show
  1. package/LICENSE +21 -0
  2. package/README.MD +2969 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +5479 -0
  5. package/WAProto/index.js +97692 -0
  6. package/WAProto/p.html +1 -0
  7. package/engine-requirements.js +10 -0
  8. package/lib/Defaults/index.js +120 -0
  9. package/lib/Defaults/rixleys-version.json +3 -0
  10. package/lib/Signal/Group/ciphertext-message.js +15 -0
  11. package/lib/Signal/Group/group-session-builder.js +64 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.js +57 -0
  14. package/lib/Signal/Group/keyhelper.js +55 -0
  15. package/lib/Signal/Group/queue-job.js +57 -0
  16. package/lib/Signal/Group/sender-chain-key.js +34 -0
  17. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  18. package/lib/Signal/Group/sender-key-message.js +69 -0
  19. package/lib/Signal/Group/sender-key-name.js +51 -0
  20. package/lib/Signal/Group/sender-key-record.js +53 -0
  21. package/lib/Signal/Group/sender-key-state.js +99 -0
  22. package/lib/Signal/Group/sender-message-key.js +29 -0
  23. package/lib/Signal/core/.eslintrc.json +31 -0
  24. package/lib/Signal/core/CODE_OF_CONDUCT.md +102 -0
  25. package/lib/Signal/core/LICENSE +621 -0
  26. package/lib/Signal/core/README.md +64 -0
  27. package/lib/Signal/core/SECURITY.md +78 -0
  28. package/lib/Signal/core/generate-proto.sh +1 -0
  29. package/lib/Signal/core/index.d.ts +55 -0
  30. package/lib/Signal/core/index.js +10 -0
  31. package/lib/Signal/core/protos/WhisperTextProtocol.proto +28 -0
  32. package/lib/Signal/core/src/.eslintrc.json +31 -0
  33. package/lib/Signal/core/src/WhisperTextProtocol.js +933 -0
  34. package/lib/Signal/core/src/base_key_type.js +7 -0
  35. package/lib/Signal/core/src/chain_type.js +6 -0
  36. package/lib/Signal/core/src/crypto.d.ts +19 -0
  37. package/lib/Signal/core/src/crypto.js +98 -0
  38. package/lib/Signal/core/src/curve.d.ts +22 -0
  39. package/lib/Signal/core/src/curve.js +142 -0
  40. package/lib/Signal/core/src/errors.js +33 -0
  41. package/lib/Signal/core/src/keyhelper.js +45 -0
  42. package/lib/Signal/core/src/numeric_fingerprint.js +72 -0
  43. package/lib/Signal/core/src/protobufs.js +10 -0
  44. package/lib/Signal/core/src/protocol_address.js +40 -0
  45. package/lib/Signal/core/src/queue_job.js +69 -0
  46. package/lib/Signal/core/src/session_builder.js +164 -0
  47. package/lib/Signal/core/src/session_cipher.js +336 -0
  48. package/lib/Signal/core/src/session_record.js +316 -0
  49. package/lib/Signal/libsignal.js +184 -0
  50. package/lib/Socket/Client/index.js +18 -0
  51. package/lib/Socket/Client/types.js +13 -0
  52. package/lib/Socket/Client/websocket.js +72 -0
  53. package/lib/Socket/business.js +260 -0
  54. package/lib/Socket/chats.js +997 -0
  55. package/lib/Socket/groups.js +418 -0
  56. package/lib/Socket/index.js +238 -0
  57. package/lib/Socket/messages-recv.js +1106 -0
  58. package/lib/Socket/messages-send.js +882 -0
  59. package/lib/Socket/newsletter.js +250 -0
  60. package/lib/Socket/socket.js +646 -0
  61. package/lib/Socket/usync.js +70 -0
  62. package/lib/Store/index.js +8 -0
  63. package/lib/Store/make-in-memory-store.js +439 -0
  64. package/lib/Store/make-ordered-dictionary.js +81 -0
  65. package/lib/Store/object-repository.js +27 -0
  66. package/lib/Types/Auth.js +2 -0
  67. package/lib/Types/Call.js +2 -0
  68. package/lib/Types/Chat.js +4 -0
  69. package/lib/Types/Contact.js +2 -0
  70. package/lib/Types/Events.js +2 -0
  71. package/lib/Types/GroupMetadata.js +2 -0
  72. package/lib/Types/Label.js +27 -0
  73. package/lib/Types/LabelAssociation.js +9 -0
  74. package/lib/Types/Message.js +7 -0
  75. package/lib/Types/Newsletter.js +18 -0
  76. package/lib/Types/Product.js +2 -0
  77. package/lib/Types/Signal.js +2 -0
  78. package/lib/Types/Socket.js +2 -0
  79. package/lib/Types/State.js +2 -0
  80. package/lib/Types/USync.js +2 -0
  81. package/lib/Types/index.js +42 -0
  82. package/lib/Utils/auth-utils.js +199 -0
  83. package/lib/Utils/browser-utils.js +35 -0
  84. package/lib/Utils/business.js +234 -0
  85. package/lib/Utils/chat-utils.js +730 -0
  86. package/lib/Utils/crypto.js +193 -0
  87. package/lib/Utils/decode-wa-message.js +217 -0
  88. package/lib/Utils/event-buffer.js +518 -0
  89. package/lib/Utils/generics.js +467 -0
  90. package/lib/Utils/history.js +94 -0
  91. package/lib/Utils/index.js +36 -0
  92. package/lib/Utils/link-preview.js +151 -0
  93. package/lib/Utils/logger.js +7 -0
  94. package/lib/Utils/lt-hash.js +51 -0
  95. package/lib/Utils/make-mutex.js +43 -0
  96. package/lib/Utils/message-retry-manager.js +185 -0
  97. package/lib/Utils/messages-media.js +879 -0
  98. package/lib/Utils/messages.js +1049 -0
  99. package/lib/Utils/noise-handler.js +150 -0
  100. package/lib/Utils/process-message.js +404 -0
  101. package/lib/Utils/rixleys-event-stream.js +63 -0
  102. package/lib/Utils/serializer.js +238 -0
  103. package/lib/Utils/signal.js +153 -0
  104. package/lib/Utils/use-multi-file-auth-state.js +124 -0
  105. package/lib/Utils/validate-connection.js +229 -0
  106. package/lib/WABinary/constants.js +1303 -0
  107. package/lib/WABinary/decode.js +265 -0
  108. package/lib/WABinary/encode.js +250 -0
  109. package/lib/WABinary/generic-utils.js +110 -0
  110. package/lib/WABinary/index.js +21 -0
  111. package/lib/WABinary/jid-utils.js +85 -0
  112. package/lib/WABinary/types.js +2 -0
  113. package/lib/WAM/BinaryInfo.js +13 -0
  114. package/lib/WAM/constants.js +15350 -0
  115. package/lib/WAM/encode.js +155 -0
  116. package/lib/WAM/index.js +19 -0
  117. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  118. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  119. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  120. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  121. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  122. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  123. package/lib/WAUSync/Protocols/index.js +20 -0
  124. package/lib/WAUSync/USyncQuery.js +89 -0
  125. package/lib/WAUSync/USyncUser.js +26 -0
  126. package/lib/WAUSync/index.js +19 -0
  127. package/lib/index.js +54 -0
  128. package/package.json +113 -0
@@ -0,0 +1,78 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ **Do not file security issues as public GitHub issues, Discord posts, or PRs.** This package implements the Signal Protocol — session, prekey, and identity-key handling. A public report is an exploit broadcast, and downstream projects (notably Baileys and other WhatsApp-protocol clients) consume `libsignal-node` directly, so a vulnerable version is in the wild within minutes of disclosure.
6
+
7
+ Use either of these private channels:
8
+
9
+ 1. **Preferred:** [GitHub Security Advisories](https://github.com/WhiskeySockets/libsignal-node/security/advisories/new) on this repository. This gives us a private workspace to coordinate the fix, draft a CVE, and notify downstream projects.
10
+ 2. **Email:** **rajeh@reforward.dev** — Rajeh Taher, current maintainer. Use this if GitHub Advisories is unavailable, or if the report involves the maintainer's keys / accounts directly.
11
+
12
+ If you don't get an acknowledgement within **72 hours**, please re-send — mail filtering does occasionally swallow security reports.
13
+
14
+ ## What to include
15
+
16
+ A useful report contains:
17
+
18
+ - **Affected versions** (commit SHA or release tag)
19
+ - **Component**: session cipher, prekey/signed-prekey handling, sender keys, identity key store, curve25519 wrapper, fingerprint generation, etc.
20
+ - **Impact**: what an attacker can do (decrypt messages outside the intended audience, impersonate identities, replay, downgrade, key recovery, DoS of the protocol state) and under what preconditions
21
+ - **Reproduction**: minimal code or a deterministic test case. If the bug requires specific session state, include the construction steps — don't attach real session state from a production account.
22
+ - **Suggested fix** (optional but appreciated)
23
+
24
+ If a fix touches on-disk session state or key serialization formats, please flag that explicitly — those changes need extra coordination because they affect persisted state on every downstream user.
25
+
26
+ ## What we treat as a vulnerability
27
+
28
+ In scope:
29
+
30
+ - Identity key, signed prekey, or one-time prekey leakage or downgrade
31
+ - Session, prekey, or sender-key handling that lets a remote party impersonate, replay, or decrypt outside the intended audience
32
+ - Cryptographic flaws: incorrect ratcheting, nonce reuse, MAC bypass, signature forgery, curve25519 misuse, weak randomness in key generation
33
+ - Memory corruption / RCE via crafted protocol messages or protobuf payloads
34
+ - Logic bugs that bypass intended access controls in the session / group session machinery
35
+ - Vulnerabilities in dependencies (`curve25519-js`, `protobufjs`) that are reachable through the public API
36
+ - Information disclosure of key material or plaintext through logs, error messages, or thrown exceptions on default configurations
37
+
38
+ Out of scope (please file as regular issues or PRs):
39
+
40
+ - Bugs that only affect availability of the local process (a malformed input that throws an exception you can catch is not a CVE; a malformed input that lets a remote party crash any libsignal-node consumer is)
41
+ - Issues in third-party forks or in higher-level libraries that wrap this one (report those to that project)
42
+ - Behavior of the Signal Protocol specification itself — we implement it; we don't define it
43
+ - Reports against the upstream `libsignal` (Rust/Java/Swift) implementation — this is a Node.js port; many upstream advisories will not be reachable here, and vice versa
44
+
45
+ ## Coordinated disclosure
46
+
47
+ Our default timeline:
48
+
49
+ | Day | Step |
50
+ |---|---|
51
+ | 0 | Report received, acknowledged within 72h |
52
+ | ≤ 7 | Initial assessment shared with reporter; severity and rough timeline agreed |
53
+ | ≤ 30 | Fix prepared on a private branch; reporter invited to validate if they want |
54
+ | Coordinated date | Fix merged, release published, advisory + CVE published |
55
+
56
+ If you need to disclose sooner (e.g., active exploitation in the wild), tell us — we'll prioritize accordingly. If a fix is taking longer than 30 days, we'll keep you updated and explain why.
57
+
58
+ Because downstream consumers (Baileys, WhatsApp-protocol clients, other Signal-Protocol applications) cache session state across releases, we will coordinate the disclosure window with major downstream maintainers when the fix requires re-keying or migration.
59
+
60
+ We're happy to credit reporters in the advisory. Tell us how you'd like to be credited (name, handle, organization) or if you'd prefer to remain anonymous.
61
+
62
+ ## Supported versions
63
+
64
+ Security fixes are applied to the **latest major release line**. Older majors are unmaintained — please upgrade. The `master` branch is also patched immediately, but downstream pinning to `master` is at your own risk for stability.
65
+
66
+ | Version | Supported |
67
+ |---|---|
68
+ | `2.x` (current) | ✅ |
69
+ | `< 2.0` | ❌ |
70
+
71
+ ## Operational security for downstream users
72
+
73
+ A few notes for projects that consume `libsignal-node` — these aren't vulnerabilities in this library, but they are common ways production systems leak:
74
+
75
+ - **Identity keys are long-lived credentials.** The contents of any `SignalProtocolStore` you persist (identity keys, signed prekeys, sessions) are equivalent to an SSH private key for the account that owns them. Store them with the same care: not in container images, not in source control, encrypted at rest where you can.
76
+ - **Don't log session state or message plaintext.** It's easy to add a `console.log(decryptedMessage)` while debugging and never remove it. Filter aggressively in production.
77
+ - **Don't paste session state or store contents into AI tools, screenshots, or support tickets.** It's not redactable — anyone with the store contents can impersonate the account and decrypt messages.
78
+ - **Pin a release.** Pulling from `github:WhiskeySockets/libsignal-node` always grabs `master`. Use a tagged release in production so security advisories actually map to versions you ran.
@@ -0,0 +1 @@
1
+ yarn pbjs -t static-module -w commonjs -o ./src/WhisperTextProtocol.js ./protos/WhisperTextProtocol.proto
@@ -0,0 +1,55 @@
1
+ interface E2ESession {
2
+ registrationId: number;
3
+ identityKey: Uint8Array;
4
+ signedPreKey: {
5
+ keyId: number;
6
+ publicKey: Uint8Array;
7
+ signature: Uint8Array;
8
+ };
9
+ preKey: {
10
+ keyId: number;
11
+ publicKey: Uint8Array;
12
+ };
13
+ }
14
+
15
+ export interface SignalStorage {
16
+ loadSession(id: string): Promise<SessionRecord | null | undefined>;
17
+ storeSession(id: string, session: SessionRecord): Promise<void>;
18
+ isTrustedIdentity(
19
+ identifier: string,
20
+ identityKey: Uint8Array,
21
+ direction: number
22
+ ): boolean;
23
+ loadPreKey(
24
+ id: number | string
25
+ ): Promise<{ privKey: Buffer; pubKey: Buffer } | undefined>;
26
+ removePreKey(id: number): void;
27
+ loadSignedPreKey(): { privKey: Buffer; pubKey: Buffer };
28
+ getOurRegistrationId(): Promise<number> | number;
29
+ getOurIdentity(): { privKey: Buffer; pubKey: Buffer };
30
+ }
31
+
32
+ export class ProtocolAddress {
33
+ constructor(name: string, deviceId: number);
34
+ public id: string;
35
+ public deviceId: number;
36
+ public toString(): string;
37
+ }
38
+
39
+ export class SessionRecord {
40
+ static deserialize(serialized: Uint8Array): SessionRecord;
41
+ public serialize(): Uint8Array;
42
+ public haveOpenSession(): boolean;
43
+ }
44
+
45
+ export class SessionCipher {
46
+ constructor(storage: SignalStorage, remoteAddress: ProtocolAddress);
47
+ public decryptPreKeyWhisperMessage(ciphertext: Uint8Array): Promise<Buffer>;
48
+ public decryptWhisperMessage(ciphertext: Uint8Array): Promise<Buffer>;
49
+ public encrypt(data: Uint8Array): Promise<{ type: number; body: string }>;
50
+ }
51
+
52
+ export class SessionBuilder {
53
+ constructor(storage: SignalStorage, remoteAddress: ProtocolAddress);
54
+ public initOutgoing(session: E2ESession): Promise<void>;
55
+ }
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ exports.crypto = require('./src/crypto');
4
+ exports.curve = require('./src/curve');
5
+ exports.keyhelper = require('./src/keyhelper');
6
+ exports.ProtocolAddress = require('./src/protocol_address');
7
+ exports.SessionBuilder = require('./src/session_builder');
8
+ exports.SessionCipher = require('./src/session_cipher');
9
+ exports.SessionRecord = require('./src/session_record');
10
+ Object.assign(exports, require('./src/errors'));
@@ -0,0 +1,28 @@
1
+ package textsecure;
2
+
3
+ option java_package = "org.whispersystems.libsignal.protocol";
4
+ option java_outer_classname = "WhisperProtos";
5
+
6
+ message WhisperMessage {
7
+ optional bytes ephemeralKey = 1;
8
+ optional uint32 counter = 2;
9
+ optional uint32 previousCounter = 3;
10
+ optional bytes ciphertext = 4; // PushMessageContent
11
+ }
12
+
13
+ message PreKeyWhisperMessage {
14
+ optional uint32 registrationId = 5;
15
+ optional uint32 preKeyId = 1;
16
+ optional uint32 signedPreKeyId = 6;
17
+ optional bytes baseKey = 2;
18
+ optional bytes identityKey = 3;
19
+ optional bytes message = 4; // WhisperMessage
20
+ }
21
+
22
+ message KeyExchangeMessage {
23
+ optional uint32 id = 1;
24
+ optional bytes baseKey = 2;
25
+ optional bytes ephemeralKey = 3;
26
+ optional bytes identityKey = 4;
27
+ optional bytes baseKeySignature = 5;
28
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "parserOptions": {
3
+ "ecmaVersion": 8
4
+ },
5
+ "env": {
6
+ "es6": true,
7
+ "node": true
8
+ },
9
+ "extends": "eslint:recommended",
10
+ "rules": {
11
+ "quotes": "off",
12
+ "semi": [
13
+ "error",
14
+ "always"
15
+ ],
16
+ "no-console": "off",
17
+ "no-debugger": "off",
18
+ "no-unused-vars": [
19
+ "error",
20
+ {
21
+ "args": "none"
22
+ }
23
+ ],
24
+ "no-constant-condition": [
25
+ "error",
26
+ {
27
+ "checkLoops": false
28
+ }
29
+ ]
30
+ }
31
+ }