@decentnetwork/peer 0.1.82 → 0.1.83
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/dist/peer.js +7 -1
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -2084,6 +2084,9 @@ export class Peer {
|
|
|
2084
2084
|
else {
|
|
2085
2085
|
text = decodeUtf8Best(inner);
|
|
2086
2086
|
}
|
|
2087
|
+
// Carrier C peers terminate strings with a NUL — strip it so chat
|
|
2088
|
+
// text doesn't carry an invisible trailing byte.
|
|
2089
|
+
text = text?.replace(/\0+$/u, "");
|
|
2087
2090
|
if (!text) {
|
|
2088
2091
|
this.#debugLog(`crypto message packet decode failed from ${friendId}`);
|
|
2089
2092
|
return;
|
|
@@ -3246,7 +3249,10 @@ export class Peer {
|
|
|
3246
3249
|
* Detect it, decode, and emit an inlineFile event instead of dumping
|
|
3247
3250
|
* base64 into the chat. Returns true when handled. */
|
|
3248
3251
|
#tryEmitInlineFile(friendId, text, via) {
|
|
3249
|
-
|
|
3252
|
+
// The Carrier C SDK sends messages with a trailing C-string NUL, which
|
|
3253
|
+
// JSON.parse rejects. iOS's own decoder strips NULs before parsing
|
|
3254
|
+
// (CodableUtil.decode: replacingOccurrences(of: "\0")) — mirror that.
|
|
3255
|
+
const trimmed = text.replaceAll("\0", "").trim();
|
|
3250
3256
|
if (!trimmed.startsWith("{") || !trimmed.includes("\"fileName\"") || !trimmed.includes("\"data\"")) {
|
|
3251
3257
|
return false;
|
|
3252
3258
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.83",
|
|
4
4
|
"description": "Pure TypeScript port of Elastos Carrier (toxcore-derived) P2P messaging. DHT, onion routing, TCP relay, FlatBuffers app payloads, Express offline relay. Wire-compatible with iOS Beagle and the Carrier C SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|