@eryxenx/insta-chat 2.0.1 → 2.0.4

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 +112 -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 +224 -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 +284 -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
- const _0x598f71=_0x56c2,_0x401023=_0x56c2;(function(_0x54b563,_0x1e0b6e){const _0x2bf4ec=_0x56c2,_0x12e7c9=_0x56c2,_0x49c1ab=_0x54b563();while(!![]){try{const _0x460ba3=-parseInt(_0x2bf4ec(0x1bd,'ng*E'))/0x1+parseInt(_0x2bf4ec(0x1a4,'OY#Y'))/0x2*(parseInt(_0x2bf4ec(0x181,'I[HH'))/0x3)+-parseInt(_0x2bf4ec(0x1b9,'Su[['))/0x4+-parseInt(_0x12e7c9(0x19b,'gP!7'))/0x5+parseInt(_0x2bf4ec(0x1bc,'%N)d'))/0x6*(parseInt(_0x2bf4ec(0x180,'OMc0'))/0x7)+parseInt(_0x12e7c9(0x189,'WRvs'))/0x8*(parseInt(_0x2bf4ec(0x1a6,'YrAV'))/0x9)+-parseInt(_0x2bf4ec(0x1b4,'JQmB'))/0xa*(-parseInt(_0x12e7c9(0x1b6,'Lo&5'))/0xb);if(_0x460ba3===_0x1e0b6e)break;else _0x49c1ab['push'](_0x49c1ab['shift']());}catch(_0x208cc9){_0x49c1ab['push'](_0x49c1ab['shift']());}}}(_0x1f02,0xd4870));const path=require('path'),AUDIO_EXT=new Set([_0x598f71(0x1af,'%N)d'),_0x401023(0x1ad,'D$cZ'),'.mp3','.m4a',_0x401023(0x19d,'zbxQ'),_0x401023(0x186,'Su[[')]),VIDEO_EXT=new Set([_0x598f71(0x195,'WX@j'),_0x598f71(0x182,'BNrc'),'.mkv',_0x401023(0x18d,'NA#i'),_0x401023(0x1c3,'WX@j')]);function extOf(_0x94648d){const _0x4de6b1=_0x598f71,_0x5287dc=_0x598f71,_0xcc799f={'kQYrN':function(_0x4c8736,_0x4612d6){return _0x4c8736||_0x4612d6;}};return path[_0x4de6b1(0x191,'CX%L')+'e'](String(_0xcc799f[_0x5287dc(0x18a,'YrAV')](_0x94648d,''))[_0x4de6b1(0x1bb,'ZY3A')]('?')[0x0])[_0x5287dc(0x1a5,'n51]')+_0x4de6b1(0x1b5,'%ymz')]();}function _0x1f02(){const _0x1dcbdc=['nCkeWRxcObtdQq','iSoPc8oZWQmwzu3cS8onWOlcKCkf','nmkrWQm','WO7dGCocDwa','WQJcGWGiWQhdSgWK','gSohW5NdJmklWPyPW6yNWQlcMHq','W4zkrCk0WQvJ','r1KlWP5o','W40lhXC','W6jYWObfWQy','WO7dRColt1/dHq','W78QDCo6','W5TvWPxdUaC','z8ookmo9W7pcVIhdVCoBqcNcNa','fSkLrCo8hmk4W6/cL8kzyuaEWQe','w15rW5G','W6mQFCoBWOxdTgO','mCoPW44SdtO','mCkSzmkPWOy','oSkMw8k9','shVcO8kmkW','W5BdJWvGDCkS','CmovW7fooeC+WOC','W55VBSkVWOu','y8oGbCkAxG','tCkzBSkCbSkG','mWXqCSoC','WPu6oMRcHq','uSk/iW4','WOuDzCkfl3W','W5hdRWJcN8oaW4O','W7JdLrO','WOxcO0VdGCkrWPtcQ8oLd8ofW53cR8o5','ASoWj8kUAq','W78GBmkO','xv7cLG','a8oUWPu','BNK3','e1DTW5HF','qSoog8kO','vv7cPmkybmoaW6hcVGyGk8omqa','W7SqgSkCWPe','W5/dQ8o3iW','WQBcQc9NiCkZWPpcJq','qSkoEmoJWQe','W4iop2S+','tCkOsf/dJ8kdocjQWQiUfCkx','sCkKcXdcKmoozGy','wZdcJZldSG','ovCYWPTBv1O','WPFdP8o0u0NdHW','WOyhbmoQW70YfJRdLSkNDGOU','EmkHsCkdW78','ae7dMhvh','W7HFySk/WO4','W5ZdHbWvWPG','W6hcRSonWObf','W4mweGRdMmou','WR4jWONdJSoc','BCohW6FdUMtcTmk1W5HsjmkOWQdcR8oz','WRFdNHKb','gSoaW5xdHSkdWP4LW5GzWPpcJJO','WQa6hdNcLa','W5LormkvWQC','WO4pWRNdOJVcMSoLWRu','WR3dV8kAemk4vCkdhG','CCk7CmowWQi','omo1dCo3r8kKWPhcQmkdWRLtW6S1jW','WOi/pWxcTW'];_0x1f02=function(){return _0x1dcbdc;};return _0x1f02();}const ID_KEYS=[_0x598f71(0x1c2,'n51]')+_0x401023(0x19a,'I[HH'),_0x401023(0x18c,'fd3)')+'d',_0x401023(0x190,'TOUG')+_0x598f71(0x198,'OY#Y'),_0x401023(0x1b8,'Jisl'),'id'];function extractMessageId(_0x71ecdb){const _0x593ce0=_0x598f71,_0x31d814=_0x598f71,_0x36a50e={'QuOUW':function(_0x148ab2,_0x527f16){return _0x148ab2(_0x527f16);},'fdSvY':function(_0x1487f1,_0x170d43){return _0x1487f1!==_0x170d43;},'tAQco':_0x593ce0(0x184,'!agj'),'lpsHl':_0x593ce0(0x1be,'YrAV'),'AviFf':_0x31d814(0x1ab,'4PLm'),'nPygL':function(_0x3a72ba,_0x3a751a){return _0x3a72ba!==_0x3a751a;},'ZcBHR':function(_0x307821,_0x31dfd8){return _0x307821!==_0x31dfd8;},'Eubsa':_0x593ce0(0x18b,'I[HH'),'MaUbE':function(_0x465279,_0x20e75b){return _0x465279===_0x20e75b;},'djYSZ':'DiIqf'};if(!_0x71ecdb)return null;if(_0x36a50e[_0x31d814(0x194,'I[HH')](typeof _0x71ecdb,_0x36a50e[_0x31d814(0x1a7,'Su[[')]))return _0x71ecdb;const _0x2118ed=new Set(),_0x448ce7=_0x32f3f4=>{const _0x2c8947=_0x593ce0,_0x14ab5b=_0x593ce0;if(_0x36a50e[_0x2c8947(0x19f,'%ymz')]!==_0x36a50e[_0x14ab5b(0x1a3,'O[ua')])return _0x457a06[_0x14ab5b(0x1ac,'B(1D')+'e'](_0x36a50e[_0x2c8947(0x1b1,'#h2P')](_0x2a4e02,_0x2da7f5||'')[_0x14ab5b(0x1b7,'#h2P')]('?')[0x0])['toLowe'+'rCase']();else{if(!_0x32f3f4||_0x36a50e[_0x14ab5b(0x185,'OMc0')](typeof _0x32f3f4,_0x36a50e['tAQco'])||_0x2118ed[_0x14ab5b(0x1ba,'Jisl')](_0x32f3f4))return null;_0x2118ed[_0x14ab5b(0x192,'%N)d')](_0x32f3f4);for(const _0x3b3c46 of ID_KEYS){if(_0x36a50e[_0x14ab5b(0x1a0,'RCcf')](_0x36a50e[_0x2c8947(0x1aa,'%N)d')],_0x36a50e[_0x14ab5b(0x19c,'[^vr')])){const _0x331857=_0x36a50e[_0x14ab5b(0x1a8,'kejf')](_0x580b0a,_0x1f1034[_0xf3b80a]);if(_0x331857)return _0x331857;}else{const _0x132137=_0x32f3f4[_0x3b3c46];if(_0x36a50e[_0x2c8947(0x1a9,'YrAV')](typeof _0x132137,_0x36a50e[_0x2c8947(0x1b2,'YrAV')])&&_0x132137)return _0x132137;}}for(const _0x9cf91d of Object[_0x2c8947(0x18f,'07wV')](_0x32f3f4)){if(_0x2c8947(0x1bf,'OY#Y')!==_0x36a50e[_0x14ab5b(0x1c4,'Iv*A')]){const _0x44c1a6=_0x448ce7(_0x32f3f4[_0x9cf91d]);if(_0x44c1a6)return _0x44c1a6;}else{if(!_0x24a1a7||_0x36a50e[_0x14ab5b(0x199,'BNrc')](typeof _0x40ac97,_0x36a50e[_0x14ab5b(0x187,'2f)8')])||_0x172571[_0x2c8947(0x197,'q6IH')](_0x101324))return null;_0x1d0bc5[_0x14ab5b(0x196,'2f)8')](_0x53bae6);for(const _0x774360 of _0x3b2c6b){const _0x341287=_0x4a5927[_0x774360];if(typeof _0x341287===_0x36a50e[_0x2c8947(0x18e,'WWIU')]&&_0x341287)return _0x341287;}for(const _0x40d187 of _0x38b93c[_0x14ab5b(0x1c0,'B(1D')](_0x3733a7)){const _0x1f10ee=_0x23d041(_0x1a546e[_0x40d187]);if(_0x1f10ee)return _0x1f10ee;}return null;}}return null;}};return _0x36a50e[_0x593ce0(0x1c1,'VuQT')](_0x448ce7,_0x71ecdb);}function _0x56c2(_0x10a8fa,_0x5bcb9e){_0x10a8fa=_0x10a8fa-0x180;const _0x1f02d1=_0x1f02();let _0x56c2bb=_0x1f02d1[_0x10a8fa];if(_0x56c2['nwTkge']===undefined){var _0x415f23=function(_0x39042f){const _0x2768cc='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x126e91='',_0x84832d='';for(let _0x457a06=0x0,_0x2a4e02,_0x2da7f5,_0x26f961=0x0;_0x2da7f5=_0x39042f['charAt'](_0x26f961++);~_0x2da7f5&&(_0x2a4e02=_0x457a06%0x4?_0x2a4e02*0x40+_0x2da7f5:_0x2da7f5,_0x457a06++%0x4)?_0x126e91+=String['fromCharCode'](0xff&_0x2a4e02>>(-0x2*_0x457a06&0x6)):0x0){_0x2da7f5=_0x2768cc['indexOf'](_0x2da7f5);}for(let _0x22a022=0x0,_0x46771d=_0x126e91['length'];_0x22a022<_0x46771d;_0x22a022++){_0x84832d+='%'+('00'+_0x126e91['charCodeAt'](_0x22a022)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x84832d);};const _0x39c712=function(_0x10499b,_0x2bf8a4){let _0x48dd85=[],_0x171bed=0x0,_0x1df0ef,_0x25603b='';_0x10499b=_0x415f23(_0x10499b);let _0x1b6dec;for(_0x1b6dec=0x0;_0x1b6dec<0x100;_0x1b6dec++){_0x48dd85[_0x1b6dec]=_0x1b6dec;}for(_0x1b6dec=0x0;_0x1b6dec<0x100;_0x1b6dec++){_0x171bed=(_0x171bed+_0x48dd85[_0x1b6dec]+_0x2bf8a4['charCodeAt'](_0x1b6dec%_0x2bf8a4['length']))%0x100,_0x1df0ef=_0x48dd85[_0x1b6dec],_0x48dd85[_0x1b6dec]=_0x48dd85[_0x171bed],_0x48dd85[_0x171bed]=_0x1df0ef;}_0x1b6dec=0x0,_0x171bed=0x0;for(let _0x5023d0=0x0;_0x5023d0<_0x10499b['length'];_0x5023d0++){_0x1b6dec=(_0x1b6dec+0x1)%0x100,_0x171bed=(_0x171bed+_0x48dd85[_0x1b6dec])%0x100,_0x1df0ef=_0x48dd85[_0x1b6dec],_0x48dd85[_0x1b6dec]=_0x48dd85[_0x171bed],_0x48dd85[_0x171bed]=_0x1df0ef,_0x25603b+=String['fromCharCode'](_0x10499b['charCodeAt'](_0x5023d0)^_0x48dd85[(_0x48dd85[_0x1b6dec]+_0x48dd85[_0x171bed])%0x100]);}return _0x25603b;};_0x56c2['nEbJgg']=_0x39c712,_0x56c2['UbeWfx']={},_0x56c2['nwTkge']=!![];}const _0x22db23=_0x1f02d1[0x0],_0x17fdb3=_0x10a8fa+_0x22db23,_0x1e2115=_0x56c2['UbeWfx'][_0x17fdb3];return!_0x1e2115?(_0x56c2['VwhGkp']===undefined&&(_0x56c2['VwhGkp']=!![]),_0x56c2bb=_0x56c2['nEbJgg'](_0x56c2bb,_0x5bcb9e),_0x56c2['UbeWfx'][_0x17fdb3]=_0x56c2bb):_0x56c2bb=_0x1e2115,_0x56c2bb;}module[_0x598f71(0x188,'Sy]D')+'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 _0x5a483b=_0x20a1;function _0x46f5(){const _0x39c5c1=['d8kUmSkeWP/dMmkhW5rPEIa','zmkpCSkQFCowuG','WOC+ouXJfJxcS8knW7RdIw0','kmkPCr7dQ8kPiW','bCk/WQ/dM8kJqq','WR18jxLDxa','cZf7cXZcRW','mSkSWQfYWPPAW4mtWO7cPSoKW7VcGa','nSkYp8koWPjE','WO8oeCopA2pcO8oAWR8','DCoNF8oxW4SnBfPoEry+','eCoJh8oPW6ynshBdPmkGWP3cLmoe','uJVcQmkbzSk8WR14WQtcNmkQaW','w8o0xY9Tka','WOGju8ogxL7cGSoF','WPmbeWVcLSoUFMZdM3FdQGu','W7jYW7e4f8kAWPOeetBcGd4o','W4mAW5zgb8kL','W7FdI33dSgObW5pcVq','WOGlfSkDiWFcKmo+WQRcMmkyW6a','CSoHDSoxW4Cjs1vwrdKn','Bmk9rNnfahhcGCoTWO4OWR8','sSopW5jxW77cGmo7yXeoemoA','ymoreSowb8o8Eh0pqIq','W6SLW7/cSNWFESoSW5ZdLmoKW4xdUq','B8kLvZNdHmkp','WRD2fc/cGmoMlbJdVq','fG1onX4','gYPRkdJdRq','WQq0WOb2ua'];_0x46f5=function(){return _0x39c5c1;};return _0x46f5();}function _0x20a1(_0x56d663,_0x1da8c2){_0x56d663=_0x56d663-0x19a;const _0x46f5a2=_0x46f5();let _0x20a145=_0x46f5a2[_0x56d663];if(_0x20a1['DlEdVv']===undefined){var _0x55417a=function(_0x2006cb){const _0x4f2f90='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5a091a='',_0xb3c545='';for(let _0x155f7a=0x0,_0xc0842d,_0x30a686,_0x1f1fe7=0x0;_0x30a686=_0x2006cb['charAt'](_0x1f1fe7++);~_0x30a686&&(_0xc0842d=_0x155f7a%0x4?_0xc0842d*0x40+_0x30a686:_0x30a686,_0x155f7a++%0x4)?_0x5a091a+=String['fromCharCode'](0xff&_0xc0842d>>(-0x2*_0x155f7a&0x6)):0x0){_0x30a686=_0x4f2f90['indexOf'](_0x30a686);}for(let _0x5da843=0x0,_0x90e18b=_0x5a091a['length'];_0x5da843<_0x90e18b;_0x5da843++){_0xb3c545+='%'+('00'+_0x5a091a['charCodeAt'](_0x5da843)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xb3c545);};const _0x10671e=function(_0x9cc5c7,_0xbb0afe){let _0x4e96dd=[],_0x529885=0x0,_0x4ece2d,_0x745fd6='';_0x9cc5c7=_0x55417a(_0x9cc5c7);let _0xdca617;for(_0xdca617=0x0;_0xdca617<0x100;_0xdca617++){_0x4e96dd[_0xdca617]=_0xdca617;}for(_0xdca617=0x0;_0xdca617<0x100;_0xdca617++){_0x529885=(_0x529885+_0x4e96dd[_0xdca617]+_0xbb0afe['charCodeAt'](_0xdca617%_0xbb0afe['length']))%0x100,_0x4ece2d=_0x4e96dd[_0xdca617],_0x4e96dd[_0xdca617]=_0x4e96dd[_0x529885],_0x4e96dd[_0x529885]=_0x4ece2d;}_0xdca617=0x0,_0x529885=0x0;for(let _0x142257=0x0;_0x142257<_0x9cc5c7['length'];_0x142257++){_0xdca617=(_0xdca617+0x1)%0x100,_0x529885=(_0x529885+_0x4e96dd[_0xdca617])%0x100,_0x4ece2d=_0x4e96dd[_0xdca617],_0x4e96dd[_0xdca617]=_0x4e96dd[_0x529885],_0x4e96dd[_0x529885]=_0x4ece2d,_0x745fd6+=String['fromCharCode'](_0x9cc5c7['charCodeAt'](_0x142257)^_0x4e96dd[(_0x4e96dd[_0xdca617]+_0x4e96dd[_0x529885])%0x100]);}return _0x745fd6;};_0x20a1['PkJKRR']=_0x10671e,_0x20a1['zANyFr']={},_0x20a1['DlEdVv']=!![];}const _0x3a6782=_0x46f5a2[0x0],_0x1acefd=_0x56d663+_0x3a6782,_0x3c15ac=_0x20a1['zANyFr'][_0x1acefd];return!_0x3c15ac?(_0x20a1['zLqYLH']===undefined&&(_0x20a1['zLqYLH']=!![]),_0x20a145=_0x20a1['PkJKRR'](_0x20a145,_0x1da8c2),_0x20a1['zANyFr'][_0x1acefd]=_0x20a145):_0x20a145=_0x3c15ac,_0x20a145;}(function(_0x113231,_0x1c0efa){const _0x2ba6ba=_0x20a1,_0x5b3fa3=_0x20a1,_0x48fc89=_0x113231();while(!![]){try{const _0x3c8c98=-parseInt(_0x2ba6ba(0x1a5,'Nn1^'))/0x1+-parseInt(_0x5b3fa3(0x1ae,'S$(m'))/0x2*(parseInt(_0x2ba6ba(0x1a2,'%]vs'))/0x3)+parseInt(_0x2ba6ba(0x1b0,'pwrb'))/0x4*(-parseInt(_0x2ba6ba(0x1b1,'3gI('))/0x5)+parseInt(_0x2ba6ba(0x19b,'Ss[P'))/0x6+-parseInt(_0x5b3fa3(0x1b5,'9rxd'))/0x7+parseInt(_0x2ba6ba(0x1a6,'&]wu'))/0x8+-parseInt(_0x5b3fa3(0x1b7,'ZQgE'))/0x9*(-parseInt(_0x2ba6ba(0x1a3,'ZQgE'))/0xa);if(_0x3c8c98===_0x1c0efa)break;else _0x48fc89['push'](_0x48fc89['shift']());}catch(_0x53ec1c){_0x48fc89['push'](_0x48fc89['shift']());}}}(_0x46f5,0x3ccb7));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(_0x449641,_0x41d051){const _0x528a83=_0x20a1;return String(_0x449641)[_0x528a83(0x1b2,'Wym&')+'e'](/[A-Za-z0-9]/g,_0x52c6a6=>_0x41d051[_0x52c6a6]||_0x52c6a6);}const bold=_0x5389d9=>mapChars(_0x5389d9,BOLD),italic=_0x45353c=>mapChars(_0x45353c,ITALIC),monospace=_0x49b3fb=>mapChars(_0x49b3fb,MONO),strike=_0x419879=>String(_0x419879)[_0x5a483b(0x19d,'kFel')+'e'](/[A-Za-z0-9]/g,_0x215056=>_0x215056+'̶');function convert(_0x3e4319){const _0x4522f0=_0x5a483b,_0x18b857=_0x5a483b,_0x2312b5={'oYEPc':function(_0x57b959,_0x35fa06){return _0x57b959!==_0x35fa06;},'dtCwq':_0x4522f0(0x1ac,'5Tm&')};if(_0x2312b5[_0x4522f0(0x1ab,'Mx[A')](typeof _0x3e4319,_0x2312b5[_0x4522f0(0x1ad,'Ff5J')]))return _0x3e4319;let _0x1c1c13=_0x3e4319;return _0x1c1c13=_0x1c1c13[_0x4522f0(0x1a9,'3gI(')+'e'](/\*\*\*(.+?)\*\*\*/gs,(_0x218822,_0x12db1f)=>bold(italic(_0x12db1f))),_0x1c1c13=_0x1c1c13[_0x4522f0(0x1b6,'[urY')+'e'](/\*\*(.+?)\*\*/gs,(_0x54ddd5,_0x56cbd4)=>bold(_0x56cbd4)),_0x1c1c13=_0x1c1c13['replac'+'e'](/__(.+?)__/gs,(_0x2070dc,_0x4f08c3)=>italic(_0x4f08c3)),_0x1c1c13=_0x1c1c13[_0x18b857(0x1b6,'[urY')+'e'](/\*(.+?)\*/gs,(_0x57c076,_0x255fbe)=>bold(_0x255fbe)),_0x1c1c13=_0x1c1c13[_0x4522f0(0x1a1,'yTDk')+'e'](/(^|[^A-Za-z0-9])_([^_]+)_(?![A-Za-z0-9])/gs,(_0x3eba64,_0x2e10c4,_0x468b3e)=>_0x2e10c4+italic(_0x468b3e)),_0x1c1c13=_0x1c1c13[_0x4522f0(0x1b3,'xW^o')+'e'](/~~(.+?)~~/gs,(_0x2382eb,_0x1523dd)=>strike(_0x1523dd)),_0x1c1c13=_0x1c1c13['replac'+'e'](/(^|[^~])~([^~]+)~(?![~])/gs,(_0x378676,_0x56f054,_0x385c23)=>_0x56f054+strike(_0x385c23)),_0x1c1c13=_0x1c1c13[_0x4522f0(0x1b4,'Mx[A')+'e'](/```(.+?)```/gs,(_0x377f65,_0x599519)=>monospace(_0x599519)),_0x1c1c13;}module['export'+'s']={'convert':convert,'bold':bold,'italic':italic,'strike':strike,'monospace':monospace};
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 };