@whanext/core 0.19.8 → 0.19.10

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.19.10
4
+
5
+ - Fixed restored sessions incorrectly waiting for a pairing challenge after the WhatsApp connection was already open.
6
+ - Pairing-code requests now stop immediately when an existing authenticated session reconnects.
7
+
8
+ ## 0.19.9
9
+
10
+ - Fixed live `message_addon` edits being discarded when Zapo reports the parent message timestamp instead of the mutation timestamp.
11
+ - Serialized decrypted edit addons through the same protocol-mutation queue used by `message_protocol`, preserving edit/revoke ordering.
12
+ - Offline-resume edit addons remain ignored by default unless `processOfflineMessages` is enabled.
13
+
3
14
  ## 0.19.8
4
15
 
5
16
  ### Fixed
package/dist/index.js CHANGED
@@ -2837,7 +2837,7 @@ var ZapoProvider = class {
2837
2837
  );
2838
2838
  }
2839
2839
  const client = await this.#ensureClient();
2840
- if (client.getCredentials()?.meJid) {
2840
+ if (client.getCredentials()?.meJid || this.#connected) {
2841
2841
  return "";
2842
2842
  }
2843
2843
  if (!this.#connectPromise && !this.#connected) {
@@ -2851,6 +2851,9 @@ var ZapoProvider = class {
2851
2851
  "The WhatsApp pairing challenge was not received in time."
2852
2852
  );
2853
2853
  }
2854
+ if (!this.#pairingRequired || this.#connected || client.getCredentials()?.meJid) {
2855
+ return "";
2856
+ }
2854
2857
  return await client.auth.requestPairingCode(normalized);
2855
2858
  } catch (error) {
2856
2859
  if (error instanceof WhaNextError) throw error;
@@ -3199,9 +3202,18 @@ var ZapoProvider = class {
3199
3202
  ...protocolKey?.participant !== void 0 ? { participant: protocolKey.participant } : event.key.participant !== void 0 ? { participant: event.key.participant } : {},
3200
3203
  ...protocolKey?.participantAlt !== void 0 ? { participantAlt: protocolKey.participantAlt } : event.key.participantAlt !== void 0 ? { participantAlt: event.key.participantAlt } : {}
3201
3204
  };
3202
- void this.#handleProtocolEvent({
3205
+ if (event.offline === true && this.#options.processOfflineMessages !== true) {
3206
+ this.#logger.debug("Ignored offline Zapo edit addon from before the current live connection.", {
3207
+ messageId: event.key.id ?? void 0,
3208
+ targetMessageId,
3209
+ chatId: target.remoteJid ?? event.key.remoteJid ?? void 0
3210
+ });
3211
+ return;
3212
+ }
3213
+ const mutationTimestampSeconds = toSeconds(protocol?.timestampMs) ?? (event.offline === true ? toSeconds(event.timestampSeconds) : void 0) ?? Math.floor(Date.now() / 1e3);
3214
+ this.#enqueueProtocolEvent({
3203
3215
  key: event.key,
3204
- ...event.timestampSeconds !== void 0 ? { timestampSeconds: event.timestampSeconds } : {},
3216
+ timestampSeconds: mutationTimestampSeconds,
3205
3217
  protocolMessage: {
3206
3218
  type: proto.Message.ProtocolMessage.Type.MESSAGE_EDIT,
3207
3219
  key: target,
@@ -3401,6 +3413,8 @@ var ZapoProvider = class {
3401
3413
  if (event.status === "open") {
3402
3414
  this.#connectPromise = void 0;
3403
3415
  this.#connected = true;
3416
+ this.#resolvePairingReady?.();
3417
+ this.#resolvePairingReady = void 0;
3404
3418
  this.#connectedAtSeconds = Math.floor(Date.now() / 1e3);
3405
3419
  this.#reconnectAttempt = 0;
3406
3420
  this.#closedNotified = false;