felixid 1.1.1

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 (109) hide show
  1. package/WAProto/GenerateStatics.sh +4 -0
  2. package/WAProto/WAProto.proto +4775 -0
  3. package/WAProto/index.js +169661 -0
  4. package/WAProto/p.html +1 -0
  5. package/engine-requirements.js +10 -0
  6. package/lib/Defaults/index.js +120 -0
  7. package/lib/Defaults/wileys-version.json +3 -0
  8. package/lib/Signal/Group/ciphertext-message.js +15 -0
  9. package/lib/Signal/Group/group-session-builder.js +64 -0
  10. package/lib/Signal/Group/group_cipher.js +96 -0
  11. package/lib/Signal/Group/index.js +57 -0
  12. package/lib/Signal/Group/keyhelper.js +55 -0
  13. package/lib/Signal/Group/queue-job.js +57 -0
  14. package/lib/Signal/Group/sender-chain-key.js +34 -0
  15. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  16. package/lib/Signal/Group/sender-key-message.js +69 -0
  17. package/lib/Signal/Group/sender-key-name.js +51 -0
  18. package/lib/Signal/Group/sender-key-record.js +53 -0
  19. package/lib/Signal/Group/sender-key-state.js +99 -0
  20. package/lib/Signal/Group/sender-message-key.js +29 -0
  21. package/lib/Signal/libsignal.js +174 -0
  22. package/lib/Socket/Client/index.js +18 -0
  23. package/lib/Socket/Client/types.js +13 -0
  24. package/lib/Socket/Client/websocket.js +72 -0
  25. package/lib/Socket/business.js +260 -0
  26. package/lib/Socket/chats.js +997 -0
  27. package/lib/Socket/groups.js +332 -0
  28. package/lib/Socket/index.js +10 -0
  29. package/lib/Socket/messages-recv.js +1106 -0
  30. package/lib/Socket/messages-send.js +874 -0
  31. package/lib/Socket/newsletter.js +286 -0
  32. package/lib/Socket/socket.js +648 -0
  33. package/lib/Socket/usync.js +70 -0
  34. package/lib/Store/index.js +8 -0
  35. package/lib/Store/make-in-memory-store.js +439 -0
  36. package/lib/Store/make-ordered-dictionary.js +81 -0
  37. package/lib/Store/object-repository.js +27 -0
  38. package/lib/Types/Auth.js +2 -0
  39. package/lib/Types/Call.js +2 -0
  40. package/lib/Types/Chat.js +4 -0
  41. package/lib/Types/Contact.js +2 -0
  42. package/lib/Types/Events.js +2 -0
  43. package/lib/Types/GroupMetadata.js +2 -0
  44. package/lib/Types/Label.js +27 -0
  45. package/lib/Types/LabelAssociation.js +9 -0
  46. package/lib/Types/Message.js +7 -0
  47. package/lib/Types/Newsletter.js +18 -0
  48. package/lib/Types/Product.js +2 -0
  49. package/lib/Types/Signal.js +2 -0
  50. package/lib/Types/Socket.js +2 -0
  51. package/lib/Types/State.js +2 -0
  52. package/lib/Types/USync.js +2 -0
  53. package/lib/Types/index.js +42 -0
  54. package/lib/Utils/auth-utils.js +199 -0
  55. package/lib/Utils/browser-utils.js +35 -0
  56. package/lib/Utils/business.js +234 -0
  57. package/lib/Utils/chat-utils.js +730 -0
  58. package/lib/Utils/crypto.js +193 -0
  59. package/lib/Utils/decode-wa-message.js +217 -0
  60. package/lib/Utils/event-buffer.js +518 -0
  61. package/lib/Utils/generics.js +467 -0
  62. package/lib/Utils/history.js +94 -0
  63. package/lib/Utils/index.js +35 -0
  64. package/lib/Utils/link-preview.js +126 -0
  65. package/lib/Utils/logger.js +7 -0
  66. package/lib/Utils/lt-hash.js +51 -0
  67. package/lib/Utils/make-mutex.js +43 -0
  68. package/lib/Utils/message-retry-manager.js +128 -0
  69. package/lib/Utils/messages-media.js +879 -0
  70. package/lib/Utils/messages.js +1049 -0
  71. package/lib/Utils/noise-handler.js +150 -0
  72. package/lib/Utils/process-message.js +404 -0
  73. package/lib/Utils/signal.js +153 -0
  74. package/lib/Utils/use-multi-file-auth-state.js +125 -0
  75. package/lib/Utils/validate-connection.js +229 -0
  76. package/lib/Utils/wileys-event-stream.js +63 -0
  77. package/lib/Voip/audio-feeder.js +166 -0
  78. package/lib/Voip/index.js +562 -0
  79. package/lib/Voip/relay-transport.js +829 -0
  80. package/lib/Voip/signaling.js +1092 -0
  81. package/lib/Voip/types.js +23 -0
  82. package/lib/Voip/wasm-engine.js +1255 -0
  83. package/lib/Voip/worker-bootstrap.js +1078 -0
  84. package/lib/WABinary/constants.js +1303 -0
  85. package/lib/WABinary/decode.js +265 -0
  86. package/lib/WABinary/encode.js +250 -0
  87. package/lib/WABinary/generic-utils.js +110 -0
  88. package/lib/WABinary/index.js +21 -0
  89. package/lib/WABinary/jid-utils.js +85 -0
  90. package/lib/WABinary/types.js +2 -0
  91. package/lib/WAM/BinaryInfo.js +13 -0
  92. package/lib/WAM/constants.js +15350 -0
  93. package/lib/WAM/encode.js +155 -0
  94. package/lib/WAM/index.js +19 -0
  95. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  96. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  97. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  99. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  100. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  101. package/lib/WAUSync/Protocols/index.js +20 -0
  102. package/lib/WAUSync/USyncQuery.js +89 -0
  103. package/lib/WAUSync/USyncUser.js +26 -0
  104. package/lib/WAUSync/index.js +19 -0
  105. package/lib/assets/wasm/loader.js +5 -0
  106. package/lib/assets/wasm/whatsapp.wasm +0 -0
  107. package/lib/assets/wasm/worker-modules.js +273 -0
  108. package/lib/index.js +41 -0
  109. package/package.json +119 -0
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AudioFeeder = void 0;
4
+
5
+ const child_process_1 = require("node:child_process");
6
+
7
+ const LOW_WATERMARK_CHUNKS = 16;
8
+ const MAX_QUEUED_CHUNKS = 1024;
9
+ const DEFAULT_WARMUP_MS = 500;
10
+
11
+ class AudioFeeder {
12
+ constructor(sampleRate, channels, framesPerChunk, onChunk, source = "silence") {
13
+ this.sampleRate = sampleRate;
14
+ this.channels = channels;
15
+ this.framesPerChunk = framesPerChunk;
16
+ this.onChunk = onChunk;
17
+ this.source = source;
18
+
19
+ this._proc = null;
20
+ this._pending = Buffer.alloc(0);
21
+ this._queue = [];
22
+ this._emitTimer = null;
23
+ this._nextEmitAtMs = 0;
24
+ this._warmupUntilMs = 0;
25
+
26
+ this.droppedChunks = 0;
27
+ this.underflowChunks = 0;
28
+ this.bytesProduced = 0;
29
+ this.chunksEmitted = 0;
30
+
31
+ this.start = () => {
32
+ if (this._proc) {
33
+ return;
34
+ }
35
+
36
+ const chunkSamples = this.framesPerChunk * this.channels;
37
+ const chunkBytes = chunkSamples * Float32Array.BYTES_PER_ELEMENT;
38
+ const chunkIntervalMs = (this.framesPerChunk / this.sampleRate) * 1000;
39
+ const inputArgs = this._resolveInputArgs();
40
+
41
+ this._proc = (0, child_process_1.spawn)("ffmpeg", [
42
+ "-hide_banner",
43
+ "-loglevel",
44
+ "error",
45
+ "-thread_queue_size",
46
+ "512",
47
+ ...inputArgs,
48
+ "-f",
49
+ "f32le",
50
+ "-ac",
51
+ String(this.channels),
52
+ "-ar",
53
+ String(this.sampleRate),
54
+ "pipe:1"
55
+ ]);
56
+
57
+ this._proc.stdout.on("data", chunk => {
58
+ this._pending = Buffer.concat([this._pending, chunk]);
59
+
60
+ while (this._pending.length >= chunkBytes) {
61
+ if (this._queue.length >= MAX_QUEUED_CHUNKS) {
62
+ this._proc?.stdout.pause();
63
+ break;
64
+ }
65
+
66
+ const frame = this._pending.subarray(0, chunkBytes);
67
+ this._pending = this._pending.subarray(chunkBytes);
68
+
69
+ const out = new Float32Array(chunkSamples);
70
+ out.set(new Float32Array(frame.buffer, frame.byteOffset, chunkSamples));
71
+
72
+ this.bytesProduced += chunkBytes;
73
+ this._queue.push(out);
74
+ }
75
+ });
76
+
77
+ this._proc.stderr.on("data", chunk => {
78
+ process.stderr.write(`[AudioFeeder] ${chunk.toString().trim()}\n`);
79
+ });
80
+
81
+ this._proc.on("exit", code => {
82
+ if (code !== 0 && code !== null) {
83
+ process.stderr.write(`[AudioFeeder] ffmpeg exited with code=${code}\n`);
84
+ }
85
+
86
+ this._proc = null;
87
+ });
88
+
89
+ this._nextEmitAtMs = 0;
90
+ this._warmupUntilMs = Date.now() + DEFAULT_WARMUP_MS;
91
+ this._scheduleNext(chunkSamples, chunkIntervalMs);
92
+ };
93
+
94
+ this.stop = () => {
95
+ if (this._emitTimer) {
96
+ clearTimeout(this._emitTimer);
97
+ this._emitTimer = null;
98
+ }
99
+
100
+ this._proc?.kill("SIGTERM");
101
+ this._proc = null;
102
+ this._pending = Buffer.alloc(0);
103
+ this._queue = [];
104
+ this._warmupUntilMs = 0;
105
+ };
106
+
107
+ this._resolveInputArgs = () => {
108
+ if (!this.source || this.source === "silence") {
109
+ return ["-f", "lavfi", "-i", `aevalsrc=0:d=3600:s=${this.sampleRate}`];
110
+ }
111
+
112
+ if (this.source.startsWith("lavfi:")) {
113
+ return ["-f", "lavfi", "-i", this.source.slice("lavfi:".length)];
114
+ }
115
+
116
+ return ["-i", this.source];
117
+ };
118
+
119
+ this._scheduleNext = (chunkSamples, chunkIntervalMs) => {
120
+ if (!this._proc) {
121
+ return;
122
+ }
123
+
124
+ const now = Date.now();
125
+
126
+ if (this._nextEmitAtMs === 0) {
127
+ this._nextEmitAtMs = now;
128
+ }
129
+
130
+ const delayMs = Math.max(0, this._nextEmitAtMs - now);
131
+
132
+ this._emitTimer = setTimeout(() => {
133
+ this._emitTimer = null;
134
+
135
+ if (this._queue.length < LOW_WATERMARK_CHUNKS && Date.now() < this._warmupUntilMs) {
136
+ this._nextEmitAtMs = Date.now() + 10;
137
+ this._scheduleNext(chunkSamples, chunkIntervalMs);
138
+ return;
139
+ }
140
+
141
+ this._flushOne(chunkSamples);
142
+ this._nextEmitAtMs += chunkIntervalMs;
143
+ this._scheduleNext(chunkSamples, chunkIntervalMs);
144
+ }, delayMs);
145
+ };
146
+
147
+ this._flushOne = chunkSamples => {
148
+ let nextChunk = this._queue.shift();
149
+
150
+ if (!nextChunk) {
151
+ nextChunk = new Float32Array(chunkSamples);
152
+ this.underflowChunks += 1;
153
+ }
154
+
155
+ this.chunksEmitted += 1;
156
+ this.onChunk(nextChunk);
157
+
158
+ if (this._proc?.stdout.isPaused() && this._queue.length <= MAX_QUEUED_CHUNKS / 4) {
159
+ this._proc.stdout.resume();
160
+ }
161
+ };
162
+ }
163
+ }
164
+
165
+ exports.AudioFeeder = AudioFeeder;
166
+ exports.default = AudioFeeder;