@eryxenx/insta-chat 2.0.7 → 2.0.8

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
@@ -4,6 +4,17 @@ All notable changes to `@eryxenx/insta-chat` are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/) and uses
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [2.0.8] - 2026-10-11
8
+
9
+ ### Fixed
10
+
11
+ - **`unsendMessage` never deleted the message.** The REST delete request was
12
+ sent with an empty body, which Instagram rejects with `status: "fail"` (or a
13
+ 404/redirect). The web client sends `_csrftoken` and `_uuid`, so `/unsend`
14
+ now includes both. Previously the call resolved to `false`, which the bot
15
+ surfaced as "Could not unsend this message (Instagram refused it, or the
16
+ message is too old)."
17
+
7
18
  ## [2.0.7] - 2026-10-11
8
19
 
9
20
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eryxenx/insta-chat",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": " Unofficial Instagram Chat API for Node.js | Build Instagram DM bots on personal accounts \u2014 send messages, media, voice notes, reactions, edit & unsend, listen for incoming chats. No browser at runtime",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/src/api.js CHANGED
@@ -43,7 +43,7 @@ class InstaAPI {
43
43
  const sessionParams = options.sessionParams || this._loadSessionParams(options.sessionParamsFile);
44
44
  if (sessionParams) this.http.setSessionParams(sessionParams);
45
45
 
46
- this.message = new MessageMethods(this.http);
46
+ this.message = new MessageMethods(this.http, this.identity);
47
47
  this.reaction = new ReactionMethods(this.http);
48
48
  this.typing = new TypingMethods(this.http);
49
49
  this.thread = new ThreadMethods(this.http);
@@ -12,8 +12,9 @@ const { classify } = require("../utils/errors");
12
12
  const NO_FALLBACK_KINDS = new Set(["rate_limited", "challenge", "blocked", "suspended", "auth"]);
13
13
 
14
14
  class MessageMethods {
15
- constructor(http) {
15
+ constructor(http, identity) {
16
16
  this.http = http;
17
+ this.identity = identity;
17
18
  }
18
19
 
19
20
  // Confirmed send path from a live web session: the IGDirectTextSendMutation
@@ -98,8 +99,14 @@ class MessageMethods {
98
99
  });
99
100
  }
100
101
 
102
+ // Instagram's REST delete requires the request to look like the web client's:
103
+ // a `_csrftoken` (the csrftoken cookie) and a `_uuid` (the browser/device id).
104
+ // An empty body is rejected — Instagram answers with `status: "fail"` (or a
105
+ // 404/redirect), which made `unsend` a silent no-op.
101
106
  async unsend(threadID, itemID) {
102
- const res = await this.http.postForm(EP.ITEM_DELETE(threadID, itemID), {});
107
+ const csrf = this.http.getCookie("csrftoken");
108
+ const body = { _csrftoken: csrf, _uuid: this.identity?.uuid || this.http.uuid() };
109
+ const res = await this.http.postForm(EP.ITEM_DELETE(threadID, itemID), body);
103
110
  return res?.status === "ok";
104
111
  }
105
112