@whanext/core 0.19.12 → 0.19.14
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/CHANGELOG.md +11 -0
- package/dist/index.js +27 -117
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.14
|
|
4
|
+
|
|
5
|
+
- Removed the temporary end-to-end AntiEdit diagnostic instrumentation after confirming the group-author identity fix in production.
|
|
6
|
+
- Normal edit handling remains quiet apart from the existing standard error and recovery logs.
|
|
7
|
+
|
|
8
|
+
## 0.19.13
|
|
9
|
+
|
|
10
|
+
- Group edits now preserve the original message author's participant identities instead of replacing them with identities carried by the edit-addon envelope.
|
|
11
|
+
- Archived mutation recovery now prefers the original stored participant and `fromMe` values over fallback mutation metadata.
|
|
12
|
+
- Fixed external edits being incorrectly classified as owner edits in multi-account/group sessions.
|
|
13
|
+
|
|
3
14
|
## 0.19.12
|
|
4
15
|
|
|
5
16
|
- Added end-to-end AntiEdit diagnostics for encrypted addons, protocol events, direct edit envelopes, normalization, previous-message recovery, and final `messageEdited` emission.
|
package/dist/index.js
CHANGED
|
@@ -3112,13 +3112,6 @@ var ZapoProvider = class {
|
|
|
3112
3112
|
client.on("message", (event) => {
|
|
3113
3113
|
const protocol = this.#protocolMessage(event);
|
|
3114
3114
|
if (protocol && this.#isMessageMutationProtocol(protocol.type)) {
|
|
3115
|
-
if (protocol.type === proto.Message.ProtocolMessage.Type.MESSAGE_EDIT) {
|
|
3116
|
-
this.#logEditDiagnostic("received_message_protocol_payload", {
|
|
3117
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3118
|
-
targetMessageId: protocol.key?.id ?? void 0,
|
|
3119
|
-
offline: event.offline === true
|
|
3120
|
-
});
|
|
3121
|
-
}
|
|
3122
3115
|
this.#enqueueProtocolEvent({
|
|
3123
3116
|
...event,
|
|
3124
3117
|
protocolMessage: protocol
|
|
@@ -3127,11 +3120,6 @@ var ZapoProvider = class {
|
|
|
3127
3120
|
}
|
|
3128
3121
|
const directEdit = this.#directEditedMessage(event.message);
|
|
3129
3122
|
if (directEdit && event.key.id) {
|
|
3130
|
-
this.#logEditDiagnostic("received_direct_edited_message", {
|
|
3131
|
-
eventMessageId: event.key.id,
|
|
3132
|
-
targetMessageId: event.key.id,
|
|
3133
|
-
offline: event.offline === true
|
|
3134
|
-
});
|
|
3135
3123
|
this.#enqueueProtocolEvent({
|
|
3136
3124
|
...event,
|
|
3137
3125
|
protocolMessage: {
|
|
@@ -3142,14 +3130,6 @@ var ZapoProvider = class {
|
|
|
3142
3130
|
});
|
|
3143
3131
|
return;
|
|
3144
3132
|
}
|
|
3145
|
-
const encryptedEdit = this.#encryptedEditInfo(event.message);
|
|
3146
|
-
if (encryptedEdit) {
|
|
3147
|
-
this.#logEditDiagnostic("received_encrypted_addon", {
|
|
3148
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3149
|
-
targetMessageId: encryptedEdit.targetMessageId,
|
|
3150
|
-
offline: event.offline === true
|
|
3151
|
-
});
|
|
3152
|
-
}
|
|
3153
3133
|
this.#handleMessage(event);
|
|
3154
3134
|
});
|
|
3155
3135
|
client.on("message_send", (event) => {
|
|
@@ -3165,13 +3145,6 @@ var ZapoProvider = class {
|
|
|
3165
3145
|
});
|
|
3166
3146
|
});
|
|
3167
3147
|
client.on("message_protocol", (event) => {
|
|
3168
|
-
if (event.protocolMessage.type === proto.Message.ProtocolMessage.Type.MESSAGE_EDIT) {
|
|
3169
|
-
this.#logEditDiagnostic("received_message_protocol_event", {
|
|
3170
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3171
|
-
targetMessageId: event.protocolMessage.key?.id ?? void 0,
|
|
3172
|
-
offline: event.offline === true
|
|
3173
|
-
});
|
|
3174
|
-
}
|
|
3175
3148
|
this.#enqueueProtocolEvent(event);
|
|
3176
3149
|
});
|
|
3177
3150
|
client.on("message_addon", (event) => {
|
|
@@ -3229,29 +3202,10 @@ var ZapoProvider = class {
|
|
|
3229
3202
|
const kind = event.kind ?? this.#stringField(decrypted, "kind") ?? this.#stringField(decrypted, "type");
|
|
3230
3203
|
const isEdit = kind === "message_edit" || protocol?.type === proto.Message.ProtocolMessage.Type.MESSAGE_EDIT;
|
|
3231
3204
|
if (!isEdit) return;
|
|
3232
|
-
this.#logEditDiagnostic("received_decrypted_addon", {
|
|
3233
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3234
|
-
targetMessageId: event.targetMessageId ?? this.#stringField(decrypted, "targetMessageId") ?? this.#stringField(decrypted, "targetMessageID") ?? protocol?.key?.id ?? void 0,
|
|
3235
|
-
addonKind: kind ?? void 0,
|
|
3236
|
-
offline: event.offline === true
|
|
3237
|
-
});
|
|
3238
3205
|
const targetMessageId = event.targetMessageId ?? this.#stringField(decrypted, "targetMessageId") ?? this.#stringField(decrypted, "targetMessageID") ?? protocol?.key?.id ?? void 0;
|
|
3239
|
-
if (!targetMessageId)
|
|
3240
|
-
this.#logEditDiagnostic("dropped_addon_without_target", {
|
|
3241
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3242
|
-
addonKind: kind ?? void 0
|
|
3243
|
-
}, "warn");
|
|
3244
|
-
return;
|
|
3245
|
-
}
|
|
3206
|
+
if (!targetMessageId) return;
|
|
3246
3207
|
const editedMessage = protocol?.editedMessage ?? this.#addonEditedMessage(event.decrypted);
|
|
3247
|
-
if (!editedMessage)
|
|
3248
|
-
this.#logEditDiagnostic("dropped_addon_without_edited_content", {
|
|
3249
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3250
|
-
targetMessageId,
|
|
3251
|
-
addonKind: kind ?? void 0
|
|
3252
|
-
}, "warn");
|
|
3253
|
-
return;
|
|
3254
|
-
}
|
|
3208
|
+
if (!editedMessage) return;
|
|
3255
3209
|
const protocolKey = protocol?.key;
|
|
3256
3210
|
const target = {
|
|
3257
3211
|
...protocolKey ?? {},
|
|
@@ -3334,24 +3288,6 @@ var ZapoProvider = class {
|
|
|
3334
3288
|
const nested = message.ephemeralMessage?.message ?? message.deviceSentMessage?.message;
|
|
3335
3289
|
return nested ? this.#directEditedMessage(nested) : void 0;
|
|
3336
3290
|
}
|
|
3337
|
-
#encryptedEditInfo(message) {
|
|
3338
|
-
const content = unwrapZapoMessageContent(message);
|
|
3339
|
-
const encrypted = content?.secretEncryptedMessage;
|
|
3340
|
-
if (!encrypted) return void 0;
|
|
3341
|
-
if (encrypted.secretEncType !== proto.Message.SecretEncryptedMessage.SecretEncType.MESSAGE_EDIT) {
|
|
3342
|
-
return void 0;
|
|
3343
|
-
}
|
|
3344
|
-
return {
|
|
3345
|
-
...encrypted.targetMessageKey?.id ? { targetMessageId: encrypted.targetMessageKey.id } : {}
|
|
3346
|
-
};
|
|
3347
|
-
}
|
|
3348
|
-
#logEditDiagnostic(stage, context, level = "info") {
|
|
3349
|
-
this.#logger[level]("AntiEdit diagnostic", {
|
|
3350
|
-
diagnostic: "antiedit",
|
|
3351
|
-
stage,
|
|
3352
|
-
...context
|
|
3353
|
-
});
|
|
3354
|
-
}
|
|
3355
3291
|
#protocolMessage(event) {
|
|
3356
3292
|
if (event.protocolMessage) return event.protocolMessage;
|
|
3357
3293
|
const content = unwrapZapoMessageContent(event.message);
|
|
@@ -3389,38 +3325,25 @@ var ZapoProvider = class {
|
|
|
3389
3325
|
if (!protocol || !this.#isMessageMutationProtocol(protocol.type)) return;
|
|
3390
3326
|
const protocolKey = protocol.key;
|
|
3391
3327
|
if (!protocolKey?.id) {
|
|
3392
|
-
|
|
3328
|
+
this.#logger.debug("Ignored Zapo protocol mutation without a target message id.", {
|
|
3393
3329
|
messageId: event.key.id ?? void 0,
|
|
3394
3330
|
protocolType: protocol.type ?? void 0
|
|
3395
|
-
};
|
|
3396
|
-
if (protocol.type === proto.Message.ProtocolMessage.Type.MESSAGE_EDIT) {
|
|
3397
|
-
this.#logEditDiagnostic("dropped_protocol_without_target", context, "warn");
|
|
3398
|
-
} else {
|
|
3399
|
-
this.#logger.debug("Ignored Zapo protocol mutation without a target message id.", context);
|
|
3400
|
-
}
|
|
3331
|
+
});
|
|
3401
3332
|
return;
|
|
3402
3333
|
}
|
|
3403
3334
|
const remoteJid = protocolKey.remoteJid ?? event.key.remoteJid;
|
|
3404
3335
|
const participant = protocolKey.participant ?? event.key.participant;
|
|
3405
3336
|
const participantAlt = protocolKey.participantAlt ?? event.key.participantAlt;
|
|
3406
|
-
|
|
3337
|
+
let target = {
|
|
3407
3338
|
...protocolKey,
|
|
3408
3339
|
...remoteJid !== void 0 ? { remoteJid } : {},
|
|
3409
3340
|
...participant !== void 0 ? { participant } : {},
|
|
3410
3341
|
...participantAlt !== void 0 ? { participantAlt } : {}
|
|
3411
3342
|
};
|
|
3412
3343
|
const stored = await this.#findStoredMessage(target);
|
|
3344
|
+
if (stored) target = this.#targetKeyFromStoredMessage(target, stored.key);
|
|
3413
3345
|
if (!target.remoteJid && stored?.key.remoteJid) target.remoteJid = stored.key.remoteJid;
|
|
3414
|
-
if (!target.remoteJid)
|
|
3415
|
-
if (protocol.type === proto.Message.ProtocolMessage.Type.MESSAGE_EDIT) {
|
|
3416
|
-
this.#logEditDiagnostic("dropped_edit_without_chat", {
|
|
3417
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3418
|
-
targetMessageId: target.id ?? void 0,
|
|
3419
|
-
previousRecovered: stored !== void 0
|
|
3420
|
-
}, "warn");
|
|
3421
|
-
}
|
|
3422
|
-
return;
|
|
3423
|
-
}
|
|
3346
|
+
if (!target.remoteJid) return;
|
|
3424
3347
|
const type = protocol.type;
|
|
3425
3348
|
const mutationKey = this.#protocolDeliveryKey(event, target, type);
|
|
3426
3349
|
if (mutationKey && this.#handledProtocolStore.has(mutationKey)) {
|
|
@@ -3451,13 +3374,7 @@ var ZapoProvider = class {
|
|
|
3451
3374
|
return;
|
|
3452
3375
|
}
|
|
3453
3376
|
const editedContent = protocol.editedMessage ? this.#unwrapEditedContent(protocol.editedMessage) : void 0;
|
|
3454
|
-
if (!editedContent)
|
|
3455
|
-
this.#logEditDiagnostic("dropped_edit_without_content", {
|
|
3456
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3457
|
-
targetMessageId: target.id ?? void 0
|
|
3458
|
-
}, "warn");
|
|
3459
|
-
return;
|
|
3460
|
-
}
|
|
3377
|
+
if (!editedContent) return;
|
|
3461
3378
|
const pushName = event.pushName ?? stored?.pushName;
|
|
3462
3379
|
const edited = {
|
|
3463
3380
|
...stored ?? {},
|
|
@@ -3470,31 +3387,18 @@ var ZapoProvider = class {
|
|
|
3470
3387
|
...pushName !== void 0 ? { pushName } : {}
|
|
3471
3388
|
};
|
|
3472
3389
|
const message = normalizeZapoMessage(edited);
|
|
3473
|
-
if (!message)
|
|
3474
|
-
this.#logEditDiagnostic("dropped_edit_normalization_failed", {
|
|
3475
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3476
|
-
targetMessageId: target.id ?? void 0,
|
|
3477
|
-
previousRecovered: stored !== void 0
|
|
3478
|
-
}, "warn");
|
|
3479
|
-
return;
|
|
3480
|
-
}
|
|
3390
|
+
if (!message) return;
|
|
3481
3391
|
const previous = stored ? normalizeZapoMessage(stored) : void 0;
|
|
3482
3392
|
if (mutationKey) this.#rememberHandledProtocol(mutationKey);
|
|
3483
3393
|
this.#remember(edited);
|
|
3484
3394
|
const editedByMe = event.key.fromMe === true;
|
|
3485
3395
|
const editedById = event.key.participant ?? event.key.participantAlt ?? (editedByMe ? this.getCurrentUserIds()[0] : event.key.remoteJid ?? void 0);
|
|
3486
3396
|
if (!previous) {
|
|
3487
|
-
this.#
|
|
3397
|
+
this.#logger.debug("Zapo edit target was not present in the recent message cache.", {
|
|
3488
3398
|
targetMessageId: target.id ?? void 0,
|
|
3489
3399
|
chatId: target.remoteJid ?? void 0
|
|
3490
|
-
}
|
|
3400
|
+
});
|
|
3491
3401
|
}
|
|
3492
|
-
this.#logEditDiagnostic("emitting_message_edited", {
|
|
3493
|
-
eventMessageId: event.key.id ?? void 0,
|
|
3494
|
-
targetMessageId: target.id ?? void 0,
|
|
3495
|
-
previousRecovered: previous !== void 0,
|
|
3496
|
-
editedByMe
|
|
3497
|
-
});
|
|
3498
3402
|
void this.#events.emit("messageEdited", {
|
|
3499
3403
|
key: message.keys,
|
|
3500
3404
|
...previous ? { previous } : {},
|
|
@@ -3508,6 +3412,20 @@ var ZapoProvider = class {
|
|
|
3508
3412
|
const wrapper = message.editedMessage;
|
|
3509
3413
|
return wrapper?.message ?? message;
|
|
3510
3414
|
}
|
|
3415
|
+
#targetKeyFromStoredMessage(fallback, stored) {
|
|
3416
|
+
const id = stored.id ?? fallback.id;
|
|
3417
|
+
const remoteJid = stored.remoteJid ?? fallback.remoteJid;
|
|
3418
|
+
const fromMe = stored.fromMe ?? fallback.fromMe;
|
|
3419
|
+
return {
|
|
3420
|
+
...id !== void 0 ? { id } : {},
|
|
3421
|
+
...remoteJid !== void 0 ? { remoteJid } : {},
|
|
3422
|
+
...stored.remoteJidAlt !== void 0 ? { remoteJidAlt: stored.remoteJidAlt } : {},
|
|
3423
|
+
...fromMe !== void 0 ? { fromMe } : {},
|
|
3424
|
+
...stored.participant !== void 0 ? { participant: stored.participant } : {},
|
|
3425
|
+
...stored.participantAlt !== void 0 ? { participantAlt: stored.participantAlt } : {},
|
|
3426
|
+
...stored.senderUsername !== void 0 ? { senderUsername: stored.senderUsername } : {}
|
|
3427
|
+
};
|
|
3428
|
+
}
|
|
3511
3429
|
#handleGroupEvent(event) {
|
|
3512
3430
|
const groupId = event.groupJid;
|
|
3513
3431
|
if (!groupId) return;
|
|
@@ -4056,10 +3974,10 @@ var ZapoProvider = class {
|
|
|
4056
3974
|
const archivedChatId = stringValue(archived.chat_id);
|
|
4057
3975
|
const remoteJid = key.remoteJid ?? archivedChatId;
|
|
4058
3976
|
if (!remoteJid) return void 0;
|
|
4059
|
-
const participant =
|
|
3977
|
+
const participant = stringValue(archived.participant_id) ?? key.participant ?? key.participantAlt;
|
|
4060
3978
|
const archivedFromMe = booleanValue(archived.from_me);
|
|
4061
3979
|
const timestampSeconds = numberValue(archived.timestamp_seconds);
|
|
4062
|
-
const fromMe = key.fromMe
|
|
3980
|
+
const fromMe = archivedFromMe ?? key.fromMe;
|
|
4063
3981
|
const restored = {
|
|
4064
3982
|
key: {
|
|
4065
3983
|
...key,
|
|
@@ -4576,14 +4494,6 @@ var WhaNextZapoLogger = class _WhaNextZapoLogger {
|
|
|
4576
4494
|
this.#logger.info(message, this.#merge(context));
|
|
4577
4495
|
}
|
|
4578
4496
|
warn(message, context) {
|
|
4579
|
-
if (message.startsWith("addon parent message secret not found") && context?.kind === "message_edit") {
|
|
4580
|
-
this.#logger.warn("AntiEdit diagnostic", {
|
|
4581
|
-
diagnostic: "antiedit",
|
|
4582
|
-
stage: "decrypt_failed_missing_parent_secret",
|
|
4583
|
-
...this.#merge(context)
|
|
4584
|
-
});
|
|
4585
|
-
return;
|
|
4586
|
-
}
|
|
4587
4497
|
this.#logger.warn(message, this.#merge(context));
|
|
4588
4498
|
}
|
|
4589
4499
|
error(message, context) {
|