@poucode/baileys 1.0.1 → 1.0.2
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/lib/Utils/long-safe.js +33 -0
- package/lib/index.js +1 -0
- package/package.json +8 -5
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Safety net for: "TypeError: this.isZero is not a function"
|
|
2
|
+
//
|
|
3
|
+
// protobufjs-generated toObject() calls `util.Long.prototype.toString.call(value)`.
|
|
4
|
+
// When `value` is a string / number / bigint / plain {low, high} object (instead of a real
|
|
5
|
+
// Long instance) this throws, which breaks JSON.stringify(message) / message.toJSON() and
|
|
6
|
+
// makes the bot stop answering. This makes Long#toString tolerant of those values.
|
|
7
|
+
// It is applied automatically when the library is imported - no code needed in the bot.
|
|
8
|
+
import protobuf from 'protobufjs/minimal.js';
|
|
9
|
+
const Long = protobuf.util.Long;
|
|
10
|
+
if (Long && Long.prototype && !Long.prototype.__poucodeSafeToString) {
|
|
11
|
+
const originalToString = Long.prototype.toString;
|
|
12
|
+
const safeToString = function toString(radix) {
|
|
13
|
+
// normal case: a real Long instance
|
|
14
|
+
if (this !== null && this !== undefined && typeof this.isZero === 'function') {
|
|
15
|
+
return originalToString.call(this, radix);
|
|
16
|
+
}
|
|
17
|
+
const value = this instanceof String || this instanceof Number ? this.valueOf() : this;
|
|
18
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'bigint') {
|
|
19
|
+
return String(value);
|
|
20
|
+
}
|
|
21
|
+
if (value && typeof value.low === 'number' && typeof value.high === 'number') {
|
|
22
|
+
const combined = (BigInt(value.high >>> 0) << 32n) | BigInt(value.low >>> 0);
|
|
23
|
+
if (!value.unsigned && value.high < 0) {
|
|
24
|
+
return (combined - (1n << 64n)).toString();
|
|
25
|
+
}
|
|
26
|
+
return combined.toString();
|
|
27
|
+
}
|
|
28
|
+
return String(value);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(safeToString, '__poucodeSafeToString', { value: true });
|
|
31
|
+
Long.prototype.toString = safeToString;
|
|
32
|
+
Object.defineProperty(Long.prototype, '__poucodeSafeToString', { value: true });
|
|
33
|
+
}
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poucode/baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "A WebSockets library for interacting with WhatsApp Web — PouCode fork of Baileys",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"poucode",
|
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
"@cacheable/node-cache": "^1.4.0",
|
|
46
46
|
"@hapi/boom": "^9.1.3",
|
|
47
47
|
"async-mutex": "^0.5.0",
|
|
48
|
+
"cache-manager": "^5.7.6",
|
|
49
|
+
"chalk": "^4.1.2",
|
|
48
50
|
"libsignal": "github:tenka-san/libsignal-node",
|
|
49
51
|
"long": "^5.0.0",
|
|
50
52
|
"lru-cache": "^11.1.0",
|
|
@@ -53,9 +55,7 @@
|
|
|
53
55
|
"pino": "^9.6",
|
|
54
56
|
"protobufjs": "^7.5.6",
|
|
55
57
|
"whatsapp-rust-bridge": "0.5.4",
|
|
56
|
-
"ws": "^8.13.0"
|
|
57
|
-
"chalk": "^4.1.2",
|
|
58
|
-
"cache-manager": "^5.7.6"
|
|
58
|
+
"ws": "^8.13.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@eslint/eslintrc": "^3.3.1",
|
|
@@ -148,5 +148,8 @@
|
|
|
148
148
|
},
|
|
149
149
|
"contributors": [
|
|
150
150
|
"WhiskeySockets (original Baileys authors)"
|
|
151
|
-
]
|
|
151
|
+
],
|
|
152
|
+
"publishConfig": {
|
|
153
|
+
"registry": "https://registry.npmjs.org/"
|
|
154
|
+
}
|
|
152
155
|
}
|