@hiroosy/baileys-lite 0.0.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.
- package/README.md +25 -0
- package/WAProto/index.d.ts +15932 -0
- package/WAProto/index.js +115856 -0
- package/engine-requirements.js +11 -0
- package/package.json +27 -0
- package/src/binary/wa-binary-constants.js +1300 -0
- package/src/binary/wa-binary.js +649 -0
- package/src/constants.js +143 -0
- package/src/defaults.js +102 -0
- package/src/foundation/audio-duration.js +530 -0
- package/src/foundation/audio-samples.js +268 -0
- package/src/foundation/boom.js +46 -0
- package/src/foundation/cache.js +142 -0
- package/src/foundation/concurrency.js +87 -0
- package/src/foundation/curve25519.js +221 -0
- package/src/foundation/link-preview.js +320 -0
- package/src/foundation/logger.js +69 -0
- package/src/foundation/long.js +140 -0
- package/src/foundation/protobuf-minimal.js +619 -0
- package/src/foundation/wa-crypto.js +76 -0
- package/src/foundation/zip.js +124 -0
- package/src/index.js +48 -0
- package/src/signal/libsignal.js +1051 -0
- package/src/signal/signal-group.js +487 -0
- package/src/signal/signal-repository.js +646 -0
- package/src/socket/business-communities.js +830 -0
- package/src/socket/chats.js +674 -0
- package/src/socket/groups-newsletter.js +342 -0
- package/src/socket/messages-recv.js +1835 -0
- package/src/socket/messages-send.js +1202 -0
- package/src/socket/socket-core.js +833 -0
- package/src/socket/usync.js +291 -0
- package/src/socket-client/websocket-client.js +124 -0
- package/src/utils/auth-state-core.js +764 -0
- package/src/utils/auth-state-storage.js +316 -0
- package/src/utils/chat-sync.js +1045 -0
- package/src/utils/media.js +841 -0
- package/src/utils/message-compose.js +1609 -0
- package/src/utils/message-processing.js +958 -0
- package/src/utils/wa-protocol-core.js +1283 -0
- package/src/vendor/jpeg-js/LICENSE +25 -0
- package/src/vendor/jpeg-js/decoder.js +1152 -0
- package/src/vendor/jpeg-js/encoder.js +824 -0
- package/src/vendor/pngjs/LICENSE +20 -0
- package/src/vendor/pngjs/bitmapper.js +273 -0
- package/src/vendor/pngjs/bitpacker.js +167 -0
- package/src/vendor/pngjs/constants.js +38 -0
- package/src/vendor/pngjs/crc.js +47 -0
- package/src/vendor/pngjs/filter-pack.js +179 -0
- package/src/vendor/pngjs/filter-parse-sync.js +27 -0
- package/src/vendor/pngjs/filter-parse.js +185 -0
- package/src/vendor/pngjs/format-normaliser.js +101 -0
- package/src/vendor/pngjs/interlace.js +101 -0
- package/src/vendor/pngjs/packer-sync.js +65 -0
- package/src/vendor/pngjs/packer.js +138 -0
- package/src/vendor/pngjs/paeth-predictor.js +22 -0
- package/src/vendor/pngjs/parser-sync.js +121 -0
- package/src/vendor/pngjs/parser.js +299 -0
- package/src/vendor/pngjs/png-sync.js +19 -0
- package/src/vendor/pngjs/sync-inflate.js +174 -0
- package/src/vendor/pngjs/sync-reader.js +54 -0
- package/src/wam/wam-constants.js +22853 -0
- package/src/wam/wam.js +151 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-version-independent synchronous zlib inflate (wraps zlib.Inflate's internal handle directly).
|
|
3
|
+
* Vendored from `pngjs` 7.0.0 (MIT). Only require()/module.exports converted to import/export
|
|
4
|
+
* (zlib/util/assert/buffer -> node: specifiers). See ./LICENSE.
|
|
5
|
+
* Algorithm body unchanged vs. upstream md5 91108ad5150178c7643155151266d812.
|
|
6
|
+
* https://github.com/pngjs/pngjs
|
|
7
|
+
*/
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
import assertModule from 'node:assert'
|
|
11
|
+
const assert = assertModule.ok
|
|
12
|
+
import zlib from 'node:zlib'
|
|
13
|
+
import util from 'node:util'
|
|
14
|
+
|
|
15
|
+
import { kMaxLength } from 'node:buffer'
|
|
16
|
+
|
|
17
|
+
function Inflate(opts) {
|
|
18
|
+
if (!(this instanceof Inflate)) {
|
|
19
|
+
return new Inflate(opts);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (opts && opts.chunkSize < zlib.Z_MIN_CHUNK) {
|
|
23
|
+
opts.chunkSize = zlib.Z_MIN_CHUNK;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
zlib.Inflate.call(this, opts);
|
|
27
|
+
|
|
28
|
+
// Node 8 --> 9 compatibility check
|
|
29
|
+
this._offset = this._offset === undefined ? this._outOffset : this._offset;
|
|
30
|
+
this._buffer = this._buffer || this._outBuffer;
|
|
31
|
+
|
|
32
|
+
if (opts && opts.maxLength != null) {
|
|
33
|
+
this._maxLength = opts.maxLength;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function createInflate(opts) {
|
|
38
|
+
return new Inflate(opts);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _close(engine, callback) {
|
|
42
|
+
if (callback) {
|
|
43
|
+
process.nextTick(callback);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Caller may invoke .close after a zlib error (which will null _handle).
|
|
47
|
+
if (!engine._handle) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
engine._handle.close();
|
|
52
|
+
engine._handle = null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Inflate.prototype._processChunk = function (chunk, flushFlag, asyncCb) {
|
|
56
|
+
if (typeof asyncCb === "function") {
|
|
57
|
+
return zlib.Inflate._processChunk.call(this, chunk, flushFlag, asyncCb);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let self = this;
|
|
61
|
+
|
|
62
|
+
let availInBefore = chunk && chunk.length;
|
|
63
|
+
let availOutBefore = this._chunkSize - this._offset;
|
|
64
|
+
let leftToInflate = this._maxLength;
|
|
65
|
+
let inOff = 0;
|
|
66
|
+
|
|
67
|
+
let buffers = [];
|
|
68
|
+
let nread = 0;
|
|
69
|
+
|
|
70
|
+
let error;
|
|
71
|
+
this.on("error", function (err) {
|
|
72
|
+
error = err;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
function handleChunk(availInAfter, availOutAfter) {
|
|
76
|
+
if (self._hadError) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let have = availOutBefore - availOutAfter;
|
|
81
|
+
assert(have >= 0, "have should not go down");
|
|
82
|
+
|
|
83
|
+
if (have > 0) {
|
|
84
|
+
let out = self._buffer.slice(self._offset, self._offset + have);
|
|
85
|
+
self._offset += have;
|
|
86
|
+
|
|
87
|
+
if (out.length > leftToInflate) {
|
|
88
|
+
out = out.slice(0, leftToInflate);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
buffers.push(out);
|
|
92
|
+
nread += out.length;
|
|
93
|
+
leftToInflate -= out.length;
|
|
94
|
+
|
|
95
|
+
if (leftToInflate === 0) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (availOutAfter === 0 || self._offset >= self._chunkSize) {
|
|
101
|
+
availOutBefore = self._chunkSize;
|
|
102
|
+
self._offset = 0;
|
|
103
|
+
self._buffer = Buffer.allocUnsafe(self._chunkSize);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (availOutAfter === 0) {
|
|
107
|
+
inOff += availInBefore - availInAfter;
|
|
108
|
+
availInBefore = availInAfter;
|
|
109
|
+
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
assert(this._handle, "zlib binding closed");
|
|
117
|
+
let res;
|
|
118
|
+
do {
|
|
119
|
+
res = this._handle.writeSync(
|
|
120
|
+
flushFlag,
|
|
121
|
+
chunk, // in
|
|
122
|
+
inOff, // in_off
|
|
123
|
+
availInBefore, // in_len
|
|
124
|
+
this._buffer, // out
|
|
125
|
+
this._offset, //out_off
|
|
126
|
+
availOutBefore
|
|
127
|
+
); // out_len
|
|
128
|
+
// Node 8 --> 9 compatibility check
|
|
129
|
+
res = res || this._writeState;
|
|
130
|
+
} while (!this._hadError && handleChunk(res[0], res[1]));
|
|
131
|
+
|
|
132
|
+
if (this._hadError) {
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (nread >= kMaxLength) {
|
|
137
|
+
_close(this);
|
|
138
|
+
throw new RangeError(
|
|
139
|
+
"Cannot create final Buffer. It would be larger than 0x" +
|
|
140
|
+
kMaxLength.toString(16) +
|
|
141
|
+
" bytes"
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let buf = Buffer.concat(buffers, nread);
|
|
146
|
+
_close(this);
|
|
147
|
+
|
|
148
|
+
return buf;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
util.inherits(Inflate, zlib.Inflate);
|
|
152
|
+
|
|
153
|
+
function zlibBufferSync(engine, buffer) {
|
|
154
|
+
if (typeof buffer === "string") {
|
|
155
|
+
buffer = Buffer.from(buffer);
|
|
156
|
+
}
|
|
157
|
+
if (!(buffer instanceof Buffer)) {
|
|
158
|
+
throw new TypeError("Not a string or buffer");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
let flushFlag = engine._finishFlushFlag;
|
|
162
|
+
if (flushFlag == null) {
|
|
163
|
+
flushFlag = zlib.Z_FINISH;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return engine._processChunk(buffer, flushFlag);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function inflateSync(buffer, opts) {
|
|
170
|
+
return zlibBufferSync(new Inflate(opts), buffer);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { Inflate, createInflate, inflateSync };
|
|
174
|
+
export default inflateSync;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queues fixed-length read requests and satisfies them from an in-memory buffer (no real streaming).
|
|
3
|
+
* Vendored from `pngjs` 7.0.0 (MIT). Only require()/module.exports converted to import/export
|
|
4
|
+
* (zlib/util/assert/buffer -> node: specifiers). See ./LICENSE.
|
|
5
|
+
* Algorithm body unchanged vs. upstream md5 2f8cd5d2a5f159a57f163a5fad634463.
|
|
6
|
+
* https://github.com/pngjs/pngjs
|
|
7
|
+
*/
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
let SyncReader = function (buffer) {
|
|
11
|
+
this._buffer = buffer;
|
|
12
|
+
this._reads = [];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
SyncReader.prototype.read = function (length, callback) {
|
|
16
|
+
this._reads.push({
|
|
17
|
+
length: Math.abs(length), // if length < 0 then at most this length
|
|
18
|
+
allowLess: length < 0,
|
|
19
|
+
func: callback,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
SyncReader.prototype.process = function () {
|
|
24
|
+
// as long as there is any data and read requests
|
|
25
|
+
while (this._reads.length > 0 && this._buffer.length) {
|
|
26
|
+
let read = this._reads[0];
|
|
27
|
+
|
|
28
|
+
if (
|
|
29
|
+
this._buffer.length &&
|
|
30
|
+
(this._buffer.length >= read.length || read.allowLess)
|
|
31
|
+
) {
|
|
32
|
+
// ok there is any data so that we can satisfy this request
|
|
33
|
+
this._reads.shift(); // == read
|
|
34
|
+
|
|
35
|
+
let buf = this._buffer;
|
|
36
|
+
|
|
37
|
+
this._buffer = buf.slice(read.length);
|
|
38
|
+
|
|
39
|
+
read.func.call(this, buf.slice(0, read.length));
|
|
40
|
+
} else {
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (this._reads.length > 0) {
|
|
46
|
+
throw new Error("There are some read requests waitng on finished stream");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (this._buffer.length > 0) {
|
|
50
|
+
throw new Error("unrecognised content at end of stream");
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default SyncReader;
|