@eryxenx/insta-chat 2.0.0 → 2.0.3

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +95 -8
  2. package/index.js +105 -1
  3. package/module/login.js +51 -1
  4. package/package.json +9 -2
  5. package/src/api/action/getAppState.js +19 -1
  6. package/src/api/action/getCookies.js +7 -1
  7. package/src/api/action/getCurrentUserID.js +7 -1
  8. package/src/api/action/setOptions.js +8 -1
  9. package/src/api/messaging/editMessage.js +19 -1
  10. package/src/api/messaging/markAsRead.js +7 -1
  11. package/src/api/messaging/resolvePhotoUrl.js +8 -1
  12. package/src/api/messaging/sendMessage.js +45 -1
  13. package/src/api/messaging/sendMessageSync.js +8 -1
  14. package/src/api/messaging/sendTypingIndicator.js +7 -1
  15. package/src/api/messaging/setMessageReaction.js +19 -1
  16. package/src/api/messaging/shareContact.js +19 -1
  17. package/src/api/messaging/unsendMessage.js +16 -1
  18. package/src/api/realtime/getInbox.js +7 -1
  19. package/src/api/realtime/listen.js +7 -1
  20. package/src/api/realtime/stopListening.js +7 -1
  21. package/src/api/threads/getThreadHistory.js +16 -1
  22. package/src/api/threads/getThreadInfo.js +59 -1
  23. package/src/api/threads/getThreadList.js +22 -1
  24. package/src/api/users/getUID.js +12 -1
  25. package/src/api/users/getUserInfo.js +37 -1
  26. package/src/api.js +253 -1
  27. package/src/app/InstaClient.js +352 -1
  28. package/src/app/InstaContext.js +46 -1
  29. package/src/app/createFcaClient.js +59 -1
  30. package/src/app/loadApiMethods.js +30 -1
  31. package/src/constants.js +53 -1
  32. package/src/cookies.js +41 -1
  33. package/src/deviceIdentity.js +31 -1
  34. package/src/events/normalizeEvent.js +142 -1
  35. package/src/http.js +381 -1
  36. package/src/messageContent.js +73 -1
  37. package/src/methods/inbox.js +464 -1
  38. package/src/methods/media.js +218 -1
  39. package/src/methods/message.js +115 -1
  40. package/src/methods/reactions.js +52 -1
  41. package/src/methods/thread.js +96 -1
  42. package/src/methods/typing.js +35 -1
  43. package/src/methods/user.js +33 -1
  44. package/src/session.js +94 -1
  45. package/src/threadDetail.js +36 -1
  46. package/src/utils/antiSuspension.js +269 -0
  47. package/src/utils/dataDir.js +11 -0
  48. package/src/utils/errors.js +106 -0
  49. package/src/utils/format.js +38 -1
  50. package/src/utils/messageStyle.js +57 -1
  51. package/src/utils/sessionGuard.js +93 -0
@@ -0,0 +1,106 @@
1
+ const TRANSIENT_CODES = new Set([
2
+ "ECONNRESET",
3
+ "ETIMEDOUT",
4
+ "ECONNABORTED",
5
+ "ENOTFOUND",
6
+ "EAI_AGAIN",
7
+ "ECONNREFUSED",
8
+ "EPIPE",
9
+ "ENETUNREACH",
10
+ "EHOSTUNREACH"
11
+ ]);
12
+
13
+ const RATE_RE = /too many requests|too_many_requests|rate.?limit|please wait a few minutes/i;
14
+ const SUSPENDED_RE = /account (has been )?(suspended|disabled|banned|locked)|account_locked|has been (temporarily )?(suspended|disabled)/i;
15
+ const CHALLENGE_RE = /challenge_required|checkpoint_required|checkpoint|challenge/i;
16
+ const AUTH_RE = /login_required|require_login|not_logged_in|please log in/i;
17
+ const BLOCK_RE = /feedback_required|action_blocked|action blocked|automated behavior|automated_behavior|temporarily blocked|bot detected|bot_detected|unusual activity|suspicious activity|spam/i;
18
+ const TRANSIENT_RE = /timeout|timed out|socket hang up|network error|getaddrinfo/i;
19
+
20
+ const CODE_BY_KIND = {
21
+ auth: "IG_SESSION_INVALID",
22
+ challenge: "IG_CHALLENGE",
23
+ suspended: "IG_SUSPENDED",
24
+ blocked: "IG_BLOCKED",
25
+ rate_limited: "IG_RATE_LIMITED"
26
+ };
27
+
28
+ function statusOf(err) {
29
+ if (!err || typeof err !== "object") return null;
30
+ if (err.response && err.response.status) return err.response.status;
31
+ return err.status || null;
32
+ }
33
+
34
+ function locationOf(err) {
35
+ const headers = err && err.response && err.response.headers;
36
+ if (!headers) return "";
37
+ return String(headers.location || headers.Location || "");
38
+ }
39
+
40
+ function textOf(err) {
41
+ if (!err) return "";
42
+ if (typeof err === "string") return err;
43
+ const parts = [err.message, err.code];
44
+ const data = err.response && err.response.data;
45
+ if (data !== undefined && data !== null) {
46
+ try {
47
+ parts.push((typeof data === "string" ? data : JSON.stringify(data)).slice(0, 2000));
48
+ } catch (_) {}
49
+ }
50
+ if (err.errors) {
51
+ try {
52
+ parts.push(JSON.stringify(err.errors).slice(0, 1000));
53
+ } catch (_) {}
54
+ }
55
+ return parts.filter(Boolean).join(" ");
56
+ }
57
+
58
+ function classify(err) {
59
+ const status = statusOf(err);
60
+ const text = textOf(err);
61
+ const location = locationOf(err);
62
+
63
+ if (status === 429 || RATE_RE.test(text)) return { kind: "rate_limited", status };
64
+ if (SUSPENDED_RE.test(text)) return { kind: "suspended", status };
65
+ if (/challenge|checkpoint/i.test(location) || CHALLENGE_RE.test(text)) return { kind: "challenge", status };
66
+ if ((status >= 300 && status < 400) || /maximum number of redirects/i.test(text)) return { kind: "auth", status };
67
+ if (status === 401 || AUTH_RE.test(text)) return { kind: "auth", status };
68
+ if (BLOCK_RE.test(text)) return { kind: "blocked", status };
69
+ const code = err && typeof err === "object" ? err.code : null;
70
+ if ((status && status >= 500) || TRANSIENT_CODES.has(code) || TRANSIENT_RE.test(text)) {
71
+ return { kind: "transient", status };
72
+ }
73
+ return { kind: "unknown", status };
74
+ }
75
+
76
+ function inspectBody(data) {
77
+ if (!data || typeof data !== "object" || Array.isArray(data)) return null;
78
+ const failed =
79
+ data.status === "fail" ||
80
+ data.require_login === true ||
81
+ Boolean(data.checkpoint_url) ||
82
+ Boolean(data.challenge);
83
+ if (!failed) return null;
84
+ const message = String(data.message || data.error_type || data.error_title || "");
85
+ const info = classify({ message, response: { status: 200, data, headers: {} } });
86
+ if (info.kind === "unknown" || info.kind === "transient") return null;
87
+ return { ...info, message };
88
+ }
89
+
90
+ function toIgError(err, info) {
91
+ const error = err instanceof Error ? err : new Error(String(err));
92
+ const kind = (info && info.kind) || "unknown";
93
+ error.igKind = kind;
94
+ if (info && info.status) error.igStatus = info.status;
95
+ if (CODE_BY_KIND[kind]) error.code = CODE_BY_KIND[kind];
96
+ return error;
97
+ }
98
+
99
+ function retryAfterMs(err) {
100
+ const headers = err && err.response && err.response.headers;
101
+ const raw = headers && (headers["retry-after"] || headers["Retry-After"]);
102
+ const seconds = Number(raw);
103
+ return Number.isFinite(seconds) && seconds > 0 ? Math.min(seconds * 1000, 30 * 60 * 1000) : 0;
104
+ }
105
+
106
+ module.exports = { classify, inspectBody, toIgError, retryAfterMs };
@@ -4,4 +4,41 @@
4
4
  * Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.
5
5
  * Original author credit must be retained in all copies and derivatives.
6
6
  */
7
- function _0x29a8(_0x3e06ac,_0x117fd1){_0x3e06ac=_0x3e06ac-0x76;const _0x47994f=_0x4799();let _0x29a888=_0x47994f[_0x3e06ac];if(_0x29a8['KUdkpq']===undefined){var _0x319e3c=function(_0x1de68f){const _0x3834f9='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4e27eb='',_0x58ed2e='';for(let _0x512acc=0x0,_0x5958b8,_0xda170e,_0xcad8f6=0x0;_0xda170e=_0x1de68f['charAt'](_0xcad8f6++);~_0xda170e&&(_0x5958b8=_0x512acc%0x4?_0x5958b8*0x40+_0xda170e:_0xda170e,_0x512acc++%0x4)?_0x4e27eb+=String['fromCharCode'](0xff&_0x5958b8>>(-0x2*_0x512acc&0x6)):0x0){_0xda170e=_0x3834f9['indexOf'](_0xda170e);}for(let _0x272adb=0x0,_0x3dd622=_0x4e27eb['length'];_0x272adb<_0x3dd622;_0x272adb++){_0x58ed2e+='%'+('00'+_0x4e27eb['charCodeAt'](_0x272adb)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x58ed2e);};const _0x5ac0dd=function(_0x5e6ff7,_0x11d275){let _0x59be1e=[],_0x2e87c1=0x0,_0x31f30b,_0x3c00ed='';_0x5e6ff7=_0x319e3c(_0x5e6ff7);let _0x51aacc;for(_0x51aacc=0x0;_0x51aacc<0x100;_0x51aacc++){_0x59be1e[_0x51aacc]=_0x51aacc;}for(_0x51aacc=0x0;_0x51aacc<0x100;_0x51aacc++){_0x2e87c1=(_0x2e87c1+_0x59be1e[_0x51aacc]+_0x11d275['charCodeAt'](_0x51aacc%_0x11d275['length']))%0x100,_0x31f30b=_0x59be1e[_0x51aacc],_0x59be1e[_0x51aacc]=_0x59be1e[_0x2e87c1],_0x59be1e[_0x2e87c1]=_0x31f30b;}_0x51aacc=0x0,_0x2e87c1=0x0;for(let _0x5452dc=0x0;_0x5452dc<_0x5e6ff7['length'];_0x5452dc++){_0x51aacc=(_0x51aacc+0x1)%0x100,_0x2e87c1=(_0x2e87c1+_0x59be1e[_0x51aacc])%0x100,_0x31f30b=_0x59be1e[_0x51aacc],_0x59be1e[_0x51aacc]=_0x59be1e[_0x2e87c1],_0x59be1e[_0x2e87c1]=_0x31f30b,_0x3c00ed+=String['fromCharCode'](_0x5e6ff7['charCodeAt'](_0x5452dc)^_0x59be1e[(_0x59be1e[_0x51aacc]+_0x59be1e[_0x2e87c1])%0x100]);}return _0x3c00ed;};_0x29a8['JiaqYX']=_0x5ac0dd,_0x29a8['pyQOjL']={},_0x29a8['KUdkpq']=!![];}const _0x1dc2b7=_0x47994f[0x0],_0x446149=_0x3e06ac+_0x1dc2b7,_0x320efe=_0x29a8['pyQOjL'][_0x446149];return!_0x320efe?(_0x29a8['hoczSG']===undefined&&(_0x29a8['hoczSG']=!![]),_0x29a888=_0x29a8['JiaqYX'](_0x29a888,_0x117fd1),_0x29a8['pyQOjL'][_0x446149]=_0x29a888):_0x29a888=_0x320efe,_0x29a888;}const _0xbcf799=_0x29a8,_0x2ab234=_0x29a8;(function(_0x3b88ed,_0x350dbf){const _0x2fdd37=_0x29a8,_0x5b26d0=_0x29a8,_0x478a00=_0x3b88ed();while(!![]){try{const _0x4e4cd9=parseInt(_0x2fdd37(0x9c,'%(fH'))/0x1*(-parseInt(_0x2fdd37(0x7b,'4nzN'))/0x2)+parseInt(_0x2fdd37(0x80,'pZt%'))/0x3+parseInt(_0x2fdd37(0x89,'1F2X'))/0x4+-parseInt(_0x5b26d0(0xa4,'$%ju'))/0x5+parseInt(_0x2fdd37(0x98,'N&Gd'))/0x6*(parseInt(_0x2fdd37(0x76,'uPWV'))/0x7)+-parseInt(_0x2fdd37(0xa1,'!6ix'))/0x8+-parseInt(_0x5b26d0(0x8b,'FZP7'))/0x9;if(_0x4e4cd9===_0x350dbf)break;else _0x478a00['push'](_0x478a00['shift']());}catch(_0x4d5303){_0x478a00['push'](_0x478a00['shift']());}}}(_0x4799,0xa3e22));const path=require(_0xbcf799(0x90,'xEo[')),AUDIO_EXT=new Set([_0x2ab234(0xa8,'ralH'),_0x2ab234(0xa2,'eoK^'),_0x2ab234(0x77,'nzRG'),_0x2ab234(0x99,'4nzN'),_0xbcf799(0x7a,'HZ[S'),_0x2ab234(0x8c,'1Ym^')]),VIDEO_EXT=new Set([_0xbcf799(0x9a,'xEo['),_0xbcf799(0x9e,'PI6)'),_0xbcf799(0x8a,'RDic'),_0xbcf799(0x7e,'$%ju'),_0x2ab234(0xb0,'1mUD')]);function extOf(_0x454d4c){const _0xb168de=_0xbcf799,_0x398a3b=_0x2ab234,_0x13cc89={'KtXmB':function(_0x33cf1a,_0x1a0316){return _0x33cf1a(_0x1a0316);},'Orbye':function(_0x1a004b,_0x1fe1f7){return _0x1a004b||_0x1fe1f7;}};return path[_0xb168de(0x84,'PI6)')+'e'](_0x13cc89[_0x398a3b(0x7f,'*I59')](String,_0x13cc89[_0x398a3b(0x92,'!Be9')](_0x454d4c,''))[_0x398a3b(0xa9,'UPzW')]('?')[0x0])['toLowe'+_0x398a3b(0xa3,'(U6P')]();}function _0x4799(){const _0xaa6e3=['ACoSASkSzhi1mx3cQMGZqW','WRhcTSodW6yaW5W','uSkBrSkoWOFcLLtdKmkskd7dMSk/','ACkTWPmNxa','oMxdR112','kSomxhnbWQRcTNbMz1j2xG','WP3dQmoDtHe','ks/cTSkAvW','W6FcGCoxA8ojrrHHW5K/xmkjW6u','asTDmq','BCknwwbi','W5VdLHq','WQKKvmoc','nw3cL8o7nq','g8oplSoAoq','WR/cSmon','WOWEC8omWQBcTfa','k0SZW78','WQzzW5qJW7buAqC','W4BcGCoemCowDq','nSoHlCkViwC','W6JdP8oLW6S3W5ddONy','W64ydmot','W7xcSbddPHS','m8oaW47cMa','W6WGtmos','WQhcV8kNhKpdVSoijwrWnhS','W6ldImoyvdC','l8oqnmkRfW','n8kndcyv','WPNdHmk9mCk9','W7NcH8kNbwTWa8kBWQS6W5rtvq','W5PhfW','nLpcVq','o8o/m8oejfy','gre3weaM','qeKSW7Wd','C8kyrNPDdG','W484a0dcKG','W6BdUmoNtX7cRq','Amk2zSoRDtqgi3ldMCk3hCkQ','zsddGxq','WQueW5iefWRdTSo1WRvvo1yk','WQSsjum','w8oyWQW','ACoOz8kSAhyWeeNcKLeOwG','nXrQWQbxttpcNSoWxmofj8oC','jxT8W6O','uZuAWQBdHW','W7e8FCoaWPm','aerRW7dcU8kxW6T8W6nUW5ldIW','W5RcGmoirW','ns07rxu','WRVdHmkamCkGgW','W6VdRmkDWRbBWPRdK0HWW5KLWOm','z8kZySkAvqddHmo1WOmpWO3cKW','WRVdOCkHrW','E3D4WRy','EK3dI8onamkDW69lWR7dTSkbcZS','WOZdJXWFWOXCFW','mgj4W63cMSoA','uGqSqa'];_0x4799=function(){return _0xaa6e3;};return _0x4799();}const ID_KEYS=[_0x2ab234(0x86,'UPzW')+_0xbcf799(0x79,'lR]A'),_0x2ab234(0x96,'*I59')+'d',_0xbcf799(0xb3,'1F2X')+_0x2ab234(0xaa,'%(fH'),_0xbcf799(0x83,'N&Gd'),'id'];function extractMessageId(_0x207f5d){const _0x4fe387=_0xbcf799,_0x30f24e=_0x2ab234,_0x557544={'IDxsT':function(_0x9f370d,_0x441698){return _0x9f370d!==_0x441698;},'bZNbo':_0x4fe387(0xa0,'uPWV'),'bTniP':function(_0x3900e8,_0xc6ccfa){return _0x3900e8===_0xc6ccfa;},'Eeveg':_0x30f24e(0xb2,'#sAx'),'gBCnO':function(_0x2770bf,_0x4864e4){return _0x2770bf(_0x4864e4);},'EpzLC':function(_0x3f4c37,_0x10cfad){return _0x3f4c37!==_0x10cfad;},'tTjwW':_0x4fe387(0x7c,'4nzN'),'VWJrI':function(_0x1c1276,_0x127eb5){return _0x1c1276(_0x127eb5);}};if(!_0x207f5d)return null;if(typeof _0x207f5d===_0x4fe387(0x88,'4nzN'))return _0x207f5d;const _0x490631=new Set(),_0x18139f=_0x531549=>{const _0x59915f=_0x30f24e,_0xb7bcc6=_0x30f24e;if(!_0x531549||_0x557544[_0x59915f(0x95,'PI6)')](typeof _0x531549,_0x557544[_0xb7bcc6(0xac,'^ox7')])||_0x490631[_0xb7bcc6(0x81,'($fD')](_0x531549))return null;_0x490631[_0x59915f(0x82,'^ox7')](_0x531549);for(const _0x4f4f50 of ID_KEYS){if(_0x557544[_0xb7bcc6(0x78,'m9w9')](_0x557544[_0xb7bcc6(0x7d,'1F2X')],_0x557544['tTjwW'])){if(!_0x4fd38e||_0x557544[_0xb7bcc6(0xad,'N&Gd')](typeof _0x2a22a8,_0x557544[_0xb7bcc6(0xa6,'ZizB')])||_0x5a2dd9[_0xb7bcc6(0x8d,'hwOs')](_0x480a7c))return null;_0x1ad01e[_0xb7bcc6(0xae,'uPWV')](_0x488f87);for(const _0x12d9db of _0x5a8f56){const _0x1494f0=_0x2b7f91[_0x12d9db];if(_0x557544['bTniP'](typeof _0x1494f0,_0x557544[_0xb7bcc6(0x87,'1vP@')])&&_0x1494f0)return _0x1494f0;}for(const _0x351fcf of _0x398d67[_0xb7bcc6(0x94,'T#ev')](_0x37b12d)){const _0x51c28c=_0x557544[_0xb7bcc6(0x91,'Nvk7')](_0x504a6e,_0x2f9dd5[_0x351fcf]);if(_0x51c28c)return _0x51c28c;}return null;}else{const _0x2ae5ac=_0x531549[_0x4f4f50];if(_0x557544['bTniP'](typeof _0x2ae5ac,_0x557544[_0xb7bcc6(0x85,'1mUD')])&&_0x2ae5ac)return _0x2ae5ac;}}for(const _0x12cdda of Object[_0x59915f(0xab,'HZ[S')](_0x531549)){const _0x1703ad=_0x557544['VWJrI'](_0x18139f,_0x531549[_0x12cdda]);if(_0x1703ad)return _0x1703ad;}return null;};return _0x557544[_0x4fe387(0xa5,'pZt%')](_0x18139f,_0x207f5d);}module[_0xbcf799(0x9d,'xEo[')+'s']={'AUDIO_EXT':AUDIO_EXT,'VIDEO_EXT':VIDEO_EXT,'extOf':extOf,'extractMessageId':extractMessageId};
7
+
8
+ // Small shared helpers used by the FCA-shaped adapter methods.
9
+
10
+ const path = require("path");
11
+
12
+ const AUDIO_EXT = new Set([".ogg", ".opus", ".mp3", ".m4a", ".aac", ".wav"]);
13
+ const VIDEO_EXT = new Set([".mp4", ".mov", ".mkv", ".webm", ".gif"]);
14
+
15
+ function extOf(name) {
16
+ return path.extname(String(name || "").split("?")[0]).toLowerCase();
17
+ }
18
+
19
+ // Instagram's Relay mutations wrap the payload in a single dynamically-named
20
+ // key (e.g. xig_direct_text_send_with_slide_messaging_response), so walk the
21
+ // response depth-first for the first message/item id we recognise.
22
+ const ID_KEYS = ["message_id", "item_id", "messageId", "itemId", "id"];
23
+ function extractMessageId(result) {
24
+ if (!result) return null;
25
+ if (typeof result === "string") return result;
26
+
27
+ const seen = new Set();
28
+ const walk = (node) => {
29
+ if (!node || typeof node !== "object" || seen.has(node)) return null;
30
+ seen.add(node);
31
+ for (const key of ID_KEYS) {
32
+ const v = node[key];
33
+ if (typeof v === "string" && v) return v;
34
+ }
35
+ for (const key of Object.keys(node)) {
36
+ const found = walk(node[key]);
37
+ if (found) return found;
38
+ }
39
+ return null;
40
+ };
41
+ return walk(result);
42
+ }
43
+
44
+ module.exports = { AUDIO_EXT, VIDEO_EXT, extOf, extractMessageId };
@@ -1 +1,57 @@
1
- const _0x133480=_0x1847,_0x2da265=_0x1847;(function(_0x454233,_0x1bc1ce){const _0x36b328=_0x1847,_0x3e291b=_0x1847,_0x5bfca0=_0x454233();while(!![]){try{const _0x5316de=-parseInt(_0x36b328(0x12b,'f]c8'))/0x1*(-parseInt(_0x36b328(0x132,'f]c8'))/0x2)+parseInt(_0x3e291b(0x13f,'Y]6y'))/0x3+-parseInt(_0x3e291b(0x124,'Nvec'))/0x4+-parseInt(_0x3e291b(0x128,'X7CT'))/0x5*(-parseInt(_0x3e291b(0x135,'pVnq'))/0x6)+-parseInt(_0x36b328(0x12a,'^oPE'))/0x7+parseInt(_0x36b328(0x13d,'R652'))/0x8*(parseInt(_0x3e291b(0x12f,'JDyc'))/0x9)+parseInt(_0x3e291b(0x137,'^oPE'))/0xa;if(_0x5316de===_0x1bc1ce)break;else _0x5bfca0['push'](_0x5bfca0['shift']());}catch(_0x146de8){_0x5bfca0['push'](_0x5bfca0['shift']());}}}(_0x528f,0x2a4a4));const BOLD={'a':'𝗮','b':'𝗯','c':'𝗰','d':'𝗱','e':'𝗲','f':'𝗳','g':'𝗴','h':'𝗵','i':'𝗶','j':'𝗷','k':'𝗸','l':'𝗹','m':'𝗺','n':'𝗻','o':'𝗼','p':'𝗽','q':'𝗾','r':'𝗿','s':'𝘀','t':'𝘁','u':'𝘂','v':'𝘃','w':'𝘄','x':'𝘅','y':'𝘆','z':'𝘇','A':'𝗔','B':'𝗕','C':'𝗖','D':'𝗗','E':'𝗘','F':'𝗙','G':'𝗚','H':'𝗛','I':'𝗜','J':'𝗝','K':'𝗞','L':'𝗟','M':'𝗠','N':'𝗡','O':'𝗢','P':'𝗣','Q':'𝗤','R':'𝗥','S':'𝗦','T':'𝗧','U':'𝗨','V':'𝗩','W':'𝗪','X':'𝗫','Y':'𝗬','Z':'𝗭',0x0:'𝟬',0x1:'𝟭',0x2:'𝟮',0x3:'𝟯',0x4:'𝟰',0x5:'𝟱',0x6:'𝟲',0x7:'𝟳',0x8:'𝟴',0x9:'𝟵'},ITALIC={'a':'𝑎','b':'𝑏','c':'𝑐','d':'𝑑','e':'𝑒','f':'𝑓','g':'𝑔','h':'ℎ','i':'𝑖','j':'𝑗','k':'𝑘','l':'𝑙','m':'𝑚','n':'𝑛','o':'𝑜','p':'𝑝','q':'𝑞','r':'𝑟','s':'𝑠','t':'𝑡','u':'𝑢','v':'𝑣','w':'𝑤','x':'𝑥','y':'𝑦','z':'𝑧','A':'𝐴','B':'𝐵','C':'𝐶','D':'𝐷','E':'𝐸','F':'𝐹','G':'𝐺','H':'𝐻','I':'𝐼','J':'𝐽','K':'𝐾','L':'𝐿','M':'𝑀','N':'𝑁','O':'𝑂','P':'𝑃','Q':'𝑄','R':'𝑅','S':'𝑆','T':'𝑇','U':'𝑈','V':'𝑉','W':'𝑊','X':'𝑋','Y':'𝑌','Z':'𝑍'},MONO={'a':'𝚊','b':'𝚋','c':'𝚌','d':'𝚍','e':'𝚎','f':'𝚏','g':'𝚐','h':'𝚑','i':'𝚒','j':'𝚓','k':'𝚔','l':'𝚕','m':'𝚖','n':'𝚗','o':'𝚘','p':'𝚙','q':'𝚚','r':'𝚛','s':'𝚜','t':'𝚝','u':'𝚞','v':'𝚟','w':'𝚠','x':'𝚡','y':'𝚢','z':'𝚣','A':'𝙰','B':'𝙱','C':'𝙲','D':'𝙳','E':'𝙴','F':'𝙵','G':'𝙶','H':'𝙷','I':'𝙸','J':'𝙹','K':'𝙺','L':'𝙻','M':'𝙼','N':'𝙽','O':'𝙾','P':'𝙿','Q':'𝚀','R':'𝚁','S':'𝚂','T':'𝚃','U':'𝚄','V':'𝚅','W':'𝚆','X':'𝚇','Y':'𝚈','Z':'𝚉'};function mapChars(_0x108c6d,_0x1cc842){const _0x3017d2=_0x1847;return String(_0x108c6d)[_0x3017d2(0x141,'R652')+'e'](/[A-Za-z0-9]/g,_0x1a6b60=>_0x1cc842[_0x1a6b60]||_0x1a6b60);}const bold=_0x3a79d9=>mapChars(_0x3a79d9,BOLD),italic=_0x3b8b95=>mapChars(_0x3b8b95,ITALIC),monospace=_0x49c80d=>mapChars(_0x49c80d,MONO),strike=_0x115937=>String(_0x115937)[_0x133480(0x136,'8k!@')+'e'](/[A-Za-z0-9]/g,_0x254436=>_0x254436+'̶');function _0x1847(_0x2c7f1e,_0x3fd839){_0x2c7f1e=_0x2c7f1e-0x124;const _0x528f50=_0x528f();let _0x1847b9=_0x528f50[_0x2c7f1e];if(_0x1847['UByElW']===undefined){var _0x2e31d0=function(_0x3c9704){const _0x463396='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xeca35a='',_0x35226e='';for(let _0x3eb48e=0x0,_0xc77601,_0x59db71,_0x10ff85=0x0;_0x59db71=_0x3c9704['charAt'](_0x10ff85++);~_0x59db71&&(_0xc77601=_0x3eb48e%0x4?_0xc77601*0x40+_0x59db71:_0x59db71,_0x3eb48e++%0x4)?_0xeca35a+=String['fromCharCode'](0xff&_0xc77601>>(-0x2*_0x3eb48e&0x6)):0x0){_0x59db71=_0x463396['indexOf'](_0x59db71);}for(let _0x3c2501=0x0,_0x18c7fe=_0xeca35a['length'];_0x3c2501<_0x18c7fe;_0x3c2501++){_0x35226e+='%'+('00'+_0xeca35a['charCodeAt'](_0x3c2501)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x35226e);};const _0x56537a=function(_0x5556ce,_0x578ebb){let _0x10ee69=[],_0x1d1aa7=0x0,_0xb1f3c0,_0x5bfe5f='';_0x5556ce=_0x2e31d0(_0x5556ce);let _0x5a9101;for(_0x5a9101=0x0;_0x5a9101<0x100;_0x5a9101++){_0x10ee69[_0x5a9101]=_0x5a9101;}for(_0x5a9101=0x0;_0x5a9101<0x100;_0x5a9101++){_0x1d1aa7=(_0x1d1aa7+_0x10ee69[_0x5a9101]+_0x578ebb['charCodeAt'](_0x5a9101%_0x578ebb['length']))%0x100,_0xb1f3c0=_0x10ee69[_0x5a9101],_0x10ee69[_0x5a9101]=_0x10ee69[_0x1d1aa7],_0x10ee69[_0x1d1aa7]=_0xb1f3c0;}_0x5a9101=0x0,_0x1d1aa7=0x0;for(let _0x3082d5=0x0;_0x3082d5<_0x5556ce['length'];_0x3082d5++){_0x5a9101=(_0x5a9101+0x1)%0x100,_0x1d1aa7=(_0x1d1aa7+_0x10ee69[_0x5a9101])%0x100,_0xb1f3c0=_0x10ee69[_0x5a9101],_0x10ee69[_0x5a9101]=_0x10ee69[_0x1d1aa7],_0x10ee69[_0x1d1aa7]=_0xb1f3c0,_0x5bfe5f+=String['fromCharCode'](_0x5556ce['charCodeAt'](_0x3082d5)^_0x10ee69[(_0x10ee69[_0x5a9101]+_0x10ee69[_0x1d1aa7])%0x100]);}return _0x5bfe5f;};_0x1847['EQvJfv']=_0x56537a,_0x1847['IayFGI']={},_0x1847['UByElW']=!![];}const _0x1da393=_0x528f50[0x0],_0x1134fe=_0x2c7f1e+_0x1da393,_0x3db563=_0x1847['IayFGI'][_0x1134fe];return!_0x3db563?(_0x1847['tZcbIl']===undefined&&(_0x1847['tZcbIl']=!![]),_0x1847b9=_0x1847['EQvJfv'](_0x1847b9,_0x3fd839),_0x1847['IayFGI'][_0x1134fe]=_0x1847b9):_0x1847b9=_0x3db563,_0x1847b9;}function convert(_0x5ea4e9){const _0x2e280d=_0x133480,_0x5dd7ec=_0x133480,_0x2f4035={'JSBPp':function(_0x3f0873,_0x12246c){return _0x3f0873!==_0x12246c;},'QsnLf':'string'};if(_0x2f4035[_0x2e280d(0x13b,'CBy#')](typeof _0x5ea4e9,_0x2f4035['QsnLf']))return _0x5ea4e9;let _0x30521b=_0x5ea4e9;return _0x30521b=_0x30521b[_0x2e280d(0x125,'7#xS')+'e'](/\*\*\*(.+?)\*\*\*/gs,(_0x169d61,_0x344f2a)=>bold(italic(_0x344f2a))),_0x30521b=_0x30521b[_0x5dd7ec(0x130,'IGBA')+'e'](/\*\*(.+?)\*\*/gs,(_0xba1f6a,_0x30d588)=>bold(_0x30d588)),_0x30521b=_0x30521b['replac'+'e'](/__(.+?)__/gs,(_0x14b69a,_0x1b82fe)=>italic(_0x1b82fe)),_0x30521b=_0x30521b[_0x2e280d(0x12e,'f]c8')+'e'](/\*(.+?)\*/gs,(_0x1b7264,_0x5b33b5)=>bold(_0x5b33b5)),_0x30521b=_0x30521b[_0x2e280d(0x133,'LjoL')+'e'](/(^|[^A-Za-z0-9])_([^_]+)_(?![A-Za-z0-9])/gs,(_0x4601f3,_0x154aed,_0x1184a9)=>_0x154aed+italic(_0x1184a9)),_0x30521b=_0x30521b[_0x2e280d(0x12d,'BQfs')+'e'](/~~(.+?)~~/gs,(_0xb536cc,_0x3124e0)=>strike(_0x3124e0)),_0x30521b=_0x30521b[_0x2e280d(0x141,'R652')+'e'](/(^|[^~])~([^~]+)~(?![~])/gs,(_0x32913c,_0x50b338,_0xe4808f)=>_0x50b338+strike(_0xe4808f)),_0x30521b=_0x30521b[_0x2e280d(0x13c,'pVnq')+'e'](/```(.+?)```/gs,(_0x51b97e,_0x96220)=>monospace(_0x96220)),_0x30521b;}module[_0x2da265(0x129,'f]c8')+'s']={'convert':convert,'bold':bold,'italic':italic,'strike':strike,'monospace':monospace};function _0x528f(){const _0x5b2044=['WRPMW4VcNNhdJW','W6/dSMtcN8oEW4G','WQNdMu4QW7VdRSk5W7jjW4RcVmkCbW','W7hcOSkhWPNdIxe','W79DW7VdLmkkW7W8','WQ/dGhlcOSofW6/cJq','W4yrWQdcP0fN','t1RcHwBdJJHBkCoaxI8','ACobnuG2h0y','zmkcd8oPW6Wt','gb4KWRDtW7/cKtatWQJdGmoYzG','d1/dVXDTa8kFkLaNbCkTWO8','WRVcSmkXWR3dIxVcRa','zWjKW53dMh8MWRaAaIv0sW','W57dQLObka','lCoYn1qtoa','W5mGW4VcOmoCn8kA','u8oBisaPxurFyYhdQ8kD','W4eaz07cUCoinCogxMzWpa','W4iaAe7cUCofBSo4Fx13o8kB','WPKYW73cHmoCpq','F8oWyGb8huKyrmoSWQWa','fmkPW6Lsg8kd','W5ZdS38Vn13dH8oHW53cM8ohra','xSkvx8k3yM55WRZcO2rGnq','v8oEiIqOwL9aqJZdMCkW','W7JdR2tcNmonW58','gXSOWRDyW73cLWqoWQ3dNmoxBW','WQ/cPIhdGCkgW63cGCofW6DvWQy','W4jLnYBdSmk1aG'];_0x528f=function(){return _0x5b2044;};return _0x528f();}
1
+ // Instagram DMs render plain text only — no markdown, no bold. GoatBot-Pro
2
+ // commands rely on *bold* / _italic_ / ~strike~, so translate those to Unicode
3
+ // look-alikes before sending.
4
+
5
+ const BOLD = {
6
+ a: "𝗮", b: "𝗯", c: "𝗰", d: "𝗱", e: "𝗲", f: "𝗳", g: "𝗴", h: "𝗵", i: "𝗶",
7
+ j: "𝗷", k: "𝗸", l: "𝗹", m: "𝗺", n: "𝗻", o: "𝗼", p: "𝗽", q: "𝗾", r: "𝗿",
8
+ s: "𝘀", t: "𝘁", u: "𝘂", v: "𝘃", w: "𝘄", x: "𝘅", y: "𝘆", z: "𝘇",
9
+ A: "𝗔", B: "𝗕", C: "𝗖", D: "𝗗", E: "𝗘", F: "𝗙", G: "𝗚", H: "𝗛", I: "𝗜",
10
+ J: "𝗝", K: "𝗞", L: "𝗟", M: "𝗠", N: "𝗡", O: "𝗢", P: "𝗣", Q: "𝗤", R: "𝗥",
11
+ S: "𝗦", T: "𝗧", U: "𝗨", V: "𝗩", W: "𝗪", X: "𝗫", Y: "𝗬", Z: "𝗭",
12
+ 0: "𝟬", 1: "𝟭", 2: "𝟮", 3: "𝟯", 4: "𝟰", 5: "𝟱", 6: "𝟲", 7: "𝟳", 8: "𝟴", 9: "𝟵"
13
+ };
14
+
15
+ const ITALIC = {
16
+ a: "𝑎", b: "𝑏", c: "𝑐", d: "𝑑", e: "𝑒", f: "𝑓", g: "𝑔", h: "ℎ", i: "𝑖",
17
+ j: "𝑗", k: "𝑘", l: "𝑙", m: "𝑚", n: "𝑛", o: "𝑜", p: "𝑝", q: "𝑞", r: "𝑟",
18
+ s: "𝑠", t: "𝑡", u: "𝑢", v: "𝑣", w: "𝑤", x: "𝑥", y: "𝑦", z: "𝑧",
19
+ A: "𝐴", B: "𝐵", C: "𝐶", D: "𝐷", E: "𝐸", F: "𝐹", G: "𝐺", H: "𝐻", I: "𝐼",
20
+ J: "𝐽", K: "𝐾", L: "𝐿", M: "𝑀", N: "𝑁", O: "𝑂", P: "𝑃", Q: "𝑄", R: "𝑅",
21
+ S: "𝑆", T: "𝑇", U: "𝑈", V: "𝑉", W: "𝑊", X: "𝑋", Y: "𝑌", Z: "𝑍"
22
+ };
23
+
24
+ const MONO = {
25
+ a: "𝚊", b: "𝚋", c: "𝚌", d: "𝚍", e: "𝚎", f: "𝚏", g: "𝚐", h: "𝚑", i: "𝚒",
26
+ j: "𝚓", k: "𝚔", l: "𝚕", m: "𝚖", n: "𝚗", o: "𝚘", p: "𝚙", q: "𝚚", r: "𝚛",
27
+ s: "𝚜", t: "𝚝", u: "𝚞", v: "𝚟", w: "𝚠", x: "𝚡", y: "𝚢", z: "𝚣",
28
+ A: "𝙰", B: "𝙱", C: "𝙲", D: "𝙳", E: "𝙴", F: "𝙵", G: "𝙶", H: "𝙷", I: "𝙸",
29
+ J: "𝙹", K: "𝙺", L: "𝙻", M: "𝙼", N: "𝙽", O: "𝙾", P: "𝙿", Q: "𝚀", R: "𝚁",
30
+ S: "𝚂", T: "𝚃", U: "𝚄", V: "𝚅", W: "𝚆", X: "𝚇", Y: "𝚈", Z: "𝚉"
31
+ };
32
+
33
+ function mapChars(str, table) {
34
+ return String(str).replace(/[A-Za-z0-9]/g, (ch) => table[ch] || ch);
35
+ }
36
+
37
+ const bold = (s) => mapChars(s, BOLD);
38
+ const italic = (s) => mapChars(s, ITALIC);
39
+ const monospace = (s) => mapChars(s, MONO);
40
+ const strike = (s) => String(s).replace(/[A-Za-z0-9]/g, (ch) => `${ch}\u0336`);
41
+
42
+ // Applies *bold*, _italic_, ~strike~ and ```mono``` wrappers.
43
+ function convert(text) {
44
+ if (typeof text !== "string") return text;
45
+ let out = text;
46
+ out = out.replace(/\*\*\*(.+?)\*\*\*/gs, (_, m) => bold(italic(m)));
47
+ out = out.replace(/\*\*(.+?)\*\*/gs, (_, m) => bold(m));
48
+ out = out.replace(/__(.+?)__/gs, (_, m) => italic(m));
49
+ out = out.replace(/\*(.+?)\*/gs, (_, m) => bold(m));
50
+ out = out.replace(/(^|[^A-Za-z0-9])_([^_]+)_(?![A-Za-z0-9])/gs, (_, p, m) => p + italic(m));
51
+ out = out.replace(/~~(.+?)~~/gs, (_, m) => strike(m));
52
+ out = out.replace(/(^|[^~])~([^~]+)~(?![~])/gs, (_, p, m) => p + strike(m));
53
+ out = out.replace(/```(.+?)```/gs, (_, m) => monospace(m));
54
+ return out;
55
+ }
56
+
57
+ module.exports = { convert, bold, italic, strike, monospace };
@@ -0,0 +1,93 @@
1
+ /*!
2
+ * insta-chat - Unofficial Instagram Chat API
3
+ * Copyright (c) 2026 EryXenX (https://github.com/EryXenX)
4
+ * Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.
5
+ * Original author credit must be retained in all copies and derivatives.
6
+ */
7
+
8
+ "use strict";
9
+
10
+ const fs = require("fs");
11
+ const { dataPath } = require("./dataDir");
12
+
13
+ const SAVE_INTERVAL_MS = 5 * 60 * 1000;
14
+ const MIN_COOKIES = 3;
15
+ const KEEP_FROM_SEED = new Set(["sessionid", "ds_user_id"]);
16
+
17
+ function readCookieFile(filePath) {
18
+ try {
19
+ const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
20
+ return Array.isArray(parsed) ? parsed : null;
21
+ } catch (_) {
22
+ return null;
23
+ }
24
+ }
25
+
26
+ function loadSaved(filePath, seed) {
27
+ const target = filePath || dataPath("appstate.json");
28
+ const entries = readCookieFile(target) || readCookieFile(`${target}.bak`);
29
+ if (!entries || entries.length < MIN_COOKIES) return null;
30
+ const map = {};
31
+ for (const c of entries) {
32
+ const key = c && (c.key || c.name);
33
+ if (key && c.value) map[key] = c.value;
34
+ }
35
+ if (!seed || !seed.sessionid || map.sessionid !== seed.sessionid) return null;
36
+ for (const key of KEEP_FROM_SEED) delete map[key];
37
+ return map;
38
+ }
39
+
40
+ function writeAtomic(filePath, content) {
41
+ const tmp = `${filePath}.tmp`;
42
+ fs.writeFileSync(tmp, content, "utf8");
43
+ fs.renameSync(tmp, filePath);
44
+ }
45
+
46
+ function install(client, appStatePath) {
47
+ if (!client || typeof client.getAppState !== "function") return null;
48
+ const target = appStatePath || dataPath("appstate.json");
49
+
50
+ function getState() {
51
+ try {
52
+ return client.getAppState();
53
+ } catch (_) {
54
+ return null;
55
+ }
56
+ }
57
+
58
+ function save(filePath = target) {
59
+ const state = getState();
60
+ if (!Array.isArray(state) || state.length < MIN_COOKIES) return false;
61
+ try {
62
+ if (fs.existsSync(filePath)) {
63
+ try {
64
+ const existing = JSON.parse(fs.readFileSync(filePath, "utf8"));
65
+ if (Array.isArray(existing) && state.length < existing.length * 0.8) return false;
66
+ writeAtomic(`${filePath}.bak`, JSON.stringify(existing, null, 2));
67
+ } catch (_) {}
68
+ }
69
+ writeAtomic(filePath, JSON.stringify(state, null, 2));
70
+ return true;
71
+ } catch (_) {
72
+ return false;
73
+ }
74
+ }
75
+
76
+ const timer = setInterval(() => save(), SAVE_INTERVAL_MS);
77
+ if (timer.unref) timer.unref();
78
+
79
+ const onExit = () => save();
80
+ process.once("exit", onExit);
81
+
82
+ client.saveSession = (p) => save(p || target);
83
+ client.stopSessionGuard = () => {
84
+ clearInterval(timer);
85
+ process.removeListener("exit", onExit);
86
+ };
87
+
88
+ save();
89
+
90
+ return { save: client.saveSession, stop: client.stopSessionGuard, path: target };
91
+ }
92
+
93
+ module.exports = { install, loadSaved, SAVE_INTERVAL_MS, MIN_COOKIES };