Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

threads-api

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

threads-api - npm Package Compare versions

Comparing version 1.5.4 to 1.6.1

106

build/threads-api.d.ts
/// <reference types="node" />
import { AxiosRequestConfig } from 'axios';
import { REPLY_CONTROL_OPTIONS } from './constants';
import { AndroidDevice, Extensions, Thread, ThreadsUser } from './threads-types';
import { AndroidDevice, Extensions, Story, Thread, ThreadsUser } from './threads-types';
import { StrictUnion } from './types/utils';

@@ -32,2 +32,6 @@ export type ErrorResponse = {

};
export type GetUserProfileLoggedInResponse = {
users: ThreadsUser[];
status: 'ok';
};
export type GetUserProfileFollowPaginatedResponse = {

@@ -41,2 +45,48 @@ status: 'ok';

};
export type GetThreadRepliesPaginatedResponse = {
containing_thread: Thread;
reply_threads: Thread[];
subling_threads: Thread[];
paging_tokens: {
downward: string;
};
downwards_thread_will_continue: boolean;
target_post_reply_placeholder: string;
status: 'ok';
};
export type GetNotificationsOptions = {
feed_type: string;
mark_as_seen: boolean;
timezone_offset: number;
timezone_name: string;
selected_filters?: ThreadsAPI.NotificationFilter;
max_id?: string;
pagination_first_record_timestamp?: number;
};
export interface GetNotificationsPagination {
maxID?: string;
firstRecordTimestamp?: number;
}
export type GetNotificationsPaginatedResponse = {
counts: {
[key: string]: any;
};
last_checked: number;
new_stories: Story[];
old_stories: Story[];
continuation_token: number;
subscription: any;
is_last_page: boolean;
next_max_id: string;
auto_load_more_enabled: boolean;
pagination_first_record_timestamp: number;
filters: any[];
status: 'ok';
};
export type GetRecommendedPaginatedResponse = {
users: ThreadsUser[];
paging_token: string;
has_more: boolean;
status: 'ok';
};
export type GetUserProfileThreadResponse = {

@@ -136,2 +186,7 @@ data: {

type PostReplyControl = keyof typeof REPLY_CONTROL_OPTIONS;
enum NotificationFilter {
MENTIONS = "text_post_app_mentions",
REPLIES = "text_post_app_replies",
VERIFIED = "verified"
}
type PublishOptions = {

@@ -153,5 +208,27 @@ text?: string;

}
interface UserProfileQuerier<T extends any> {
(userID: string, options?: AxiosRequestConfig): Promise<T>;
}
interface PaginationUserIDQuerier<T extends any> {
(userID: string, maxID?: string, options?: AxiosRequestConfig): Promise<T>;
}
interface PaginationRepliesQuerier<T extends any> {
(postID: string, maxID?: string, options?: AxiosRequestConfig): Promise<T>;
}
interface PaginationNotificationsQuerier<T extends any> {
(filter?: ThreadsAPI.NotificationFilter, pagination?: GetNotificationsPagination, config?: AxiosRequestConfig): Promise<T>;
}
interface PaginationRecommendedQuerier<T extends any> {
(maxID?: string, config?: AxiosRequestConfig): Promise<T>;
}
interface SearchQuerier<T extends any> {
(query: string, count?: number, options?: AxiosRequestConfig): Promise<T>;
}
export type SearchUsersResponse = {
num_results: number;
users: ThreadsUser[];
has_more: boolean;
rank_token: string;
status: 'ok';
};
export type PaginationAndSearchOptions = {

@@ -260,2 +337,3 @@ maxID?: string;

getUserProfile: UserIDQuerier<ThreadsUser>;
getUserProfileLoggedIn: UserProfileQuerier<GetUserProfileLoggedInResponse>;
getUserProfileThreads: UserIDQuerier<Thread[]>;

@@ -290,2 +368,3 @@ getUserProfileThreadsLoggedIn: PaginationUserIDQuerier<GetUserProfileThreadsPaginatedResponse>;

}>;
getThreadsLoggedIn: PaginationRepliesQuerier<GetThreadRepliesPaginatedResponse>;
getThreadLikers: (postID: string, options?: AxiosRequestConfig) => Promise<{

@@ -295,5 +374,10 @@ users: ThreadsUser[];

getTimeline: (maxID?: string, options?: AxiosRequestConfig) => Promise<GetTimelineResponse>;
_fetchAuthGetRequest: <T extends unknown>(url: string, options?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<T, any>>;
_toggleAuthPostRequest: <T extends unknown>(url: string, data?: Record<string, string>, options?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<T, any>>;
like: (postID: string, options?: AxiosRequestConfig) => Promise<boolean>;
unlike: (postID: string, options?: AxiosRequestConfig) => Promise<boolean>;
like: (postID: string, options?: AxiosRequestConfig) => Promise<{
status: 'ok' | string;
}>;
unlike: (postID: string, options?: AxiosRequestConfig) => Promise<{
status: 'ok' | string;
}>;
follow: (userID: string, options?: AxiosRequestConfig) => Promise<FriendshipStatusResponse>;

@@ -303,2 +387,16 @@ unfollow: (userID: string, options?: AxiosRequestConfig) => Promise<FriendshipStatusResponse>;

unrepost: (originalPostID: string, options?: AxiosRequestConfig) => Promise<FriendshipStatusResponse>;
mute: (muteOptions: {
postID?: string;
userID: string;
}, options?: AxiosRequestConfig) => Promise<boolean>;
unmute: (muteOptions: {
postID?: string;
userID: string;
}, options?: AxiosRequestConfig) => Promise<boolean>;
block: (userID: string, options?: AxiosRequestConfig) => Promise<boolean>;
unblock: (userID: string, options?: AxiosRequestConfig) => Promise<boolean>;
getNotifications: PaginationNotificationsQuerier<GetNotificationsPaginatedResponse>;
setNotificationsSeen: (options?: AxiosRequestConfig) => Promise<boolean>;
searchUsers: SearchQuerier<SearchUsersResponse>;
getRecommended: PaginationRecommendedQuerier<GetRecommendedPaginatedResponse>;
getToken: () => Promise<string | undefined>;

@@ -330,2 +428,2 @@ _timezoneOffset: number | undefined;

export type ThreadsAPIPublishOptions = ThreadsAPI.PublishOptions;
export {};
export default ThreadsAPI;

2

build/threads-api.js

@@ -1,1 +0,1 @@

"use strict";!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{DEFAULT_DEVICE:function(){return h},ThreadsAPI:function(){return p}});var e=require("axios"),t=require("crypto"),r=require("mrmime"),n=require("uuid"),s=require("./constants"),a=require("./dynamic-data");function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t,r,n,s,a,o){try{var i=e[a](o),u=i.value}catch(e){r(e);return}i.done?t(u):Promise.resolve(u).then(n,s)}function u(e){return function(){var t=this,r=arguments;return new Promise(function(n,s){var a=e.apply(t,r);function o(e){i(a,n,s,o,u,"next",e)}function u(e){i(a,n,s,o,u,"throw",e)}o(void 0)})}}function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){var r,n,s,a,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(s=(s=o.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}var h={manufacturer:"OnePlus",model:"ONEPLUS+A3010",os_version:25,os_release:"7.1.1"},p=function(){"use strict";function o(o){var i,p,f,g,v=this;this.verbose=!1,this.token=void 0,this.fbLSDToken=s.DEFAULT_LSD_TOKEN,this.noUpdateToken=!1,this.noUpdateLSD=!1,this.device=h,this.userID=void 0,this.locale=void 0,this.maxRetries=1;var _=this;this.syncLoginExperiments=u(function(){var t,r,a;return d(this,function(o){switch(o.label){case 0:r={id:t=(0,n.v4)(),experiments:s.LOGIN_EXPERIMENTS},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,e.default.post(""+s.BASE_API_URL+"/api/v1/qe/sync/",_.sign(r),{httpAgent:_.httpAgent,httpsAgent:_.httpsAgent,headers:l({},_._getAppHeaders(),{Authorization:void 0,"Sec-Fetch-Site":"same-origin","X-DEVICE-ID":t})})];case 2:return[2,o.sent()];case 3:throw a=o.sent(),_.verbose&&console.log("[SYNC LOGIN EXPERIMENT FAILED]",a.response.data),Error("Sync login experiment failed");case 4:return[2]}})});var b=this;this.encryptPassword=u(function(e){var r,n,s,a,o,i,u,l,c,h,p;return d(this,function(d){switch(d.label){case 0:return r=t.randomBytes(32),n=t.randomBytes(12),[4,b.syncLoginExperiments()];case 1:return s=d.sent().headers,b.verbose&&console.log("[SYNC LOGIN EXPERIMENT HEADERS]",JSON.stringify(s)),a=s["ig-set-password-encryption-key-id"],o=s["ig-set-password-encryption-pub-key"],i=t.publicEncrypt({key:Buffer.from(o||"","base64").toString(),padding:t.constants.RSA_PKCS1_PADDING},r),u=t.createCipheriv("aes-256-gcm",r,n),l=Math.floor(Date.now()/1e3).toString(),u.setAAD(Buffer.from(l)),c=Buffer.concat([u.update(e,"utf8"),u.final()]),(h=Buffer.alloc(2,0)).writeInt16LE(i.byteLength,0),p=u.getAuthTag(),[2,{time:l,password:Buffer.concat([Buffer.from([1,a||0]),n,h,i,p,c]).toString("base64")}]}})});var m=this;this.login=u(function(){var t,r,n,a;return d(this,function(o){switch(o.label){case 0:t=function(){var e;return d(this,function(t){switch(t.label){case 0:return t.trys.push([0,1,,3]),[2,{v:n()}];case 1:return t.sent(),m.verbose&&console.error("[LOGIN] Failed to login, retrying... ("+(r+1)+"/"+m.maxRetries+")"),e=1e3*Math.pow(2,r),[4,new Promise(function(t){return setTimeout(t,e)})];case 2:return t.sent(),r++,[3,3];case 3:return[2]}})},r=0,n=u(function(){var t,r,n,a,o,i,u,l;return d(this,function(c){switch(c.label){case 0:return m.verbose&&console.log("[LOGIN] Logging in..."),[4,m.encryptPassword(m.password)];case 1:return r=encodeURIComponent(JSON.stringify({client_input_params:{password:"#PWD_INSTAGRAM:4:"+(t=c.sent()).time+":"+t.password,contact_point:m.username,device_id:m.deviceID},server_params:{credential_type:"password",device_id:m.deviceID}})),n=encodeURIComponent(JSON.stringify({bloks_version:s.BLOKS_VERSION,styles_id:"instagram"})),a={httpAgent:m.httpAgent,httpsAgent:m.httpsAgent,method:"POST",headers:m._getAppHeaders(),responseType:"text",data:"params="+r+"&bk_client_context="+n+"&bloks_versioning_id="+s.BLOKS_VERSION},[4,(0,e.default)(""+s.BASE_API_URL+"/api/v1/bloks/apps/com.bloks.www.bloks.caa.login.async.send_login_request/",a)];case 2:o=JSON.stringify((o=c.sent().data).replaceAll("\\","")),m.verbose&&console.log("[LOGIN] Cleaned output",o);try{return u=o.split("Bearer IGT:2:")[1].split('"')[0].replaceAll("\\",""),l=null==(i=o.match(/pk_id(.{18})/))?void 0:i[1].replaceAll(/[\\":]/g,""),m.noUpdateToken||(m.verbose&&console.debug("[token] UPDATED",u),m.token=u),m.userID=l,m.verbose&&console.debug("[userID] UPDATED",m.userID),[2,{token:u,userID:l}]}catch(e){throw m.verbose&&console.error("[LOGIN] Failed to login",e),Error("Login Failed")}return[2]}})}),o.label=1;case 1:if(!(r<m.maxRetries))return[3,3];return[5,function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(t())];case 2:var i;if("object"==((i=a=o.sent())&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i))return[2,a.v];return[3,1];case 3:throw Error("[LOGIN] Failed to login after "+m.maxRetries+" retries")}})}),this._getUnAuthenticatedHeaders=function(){return{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.199 Safari/537.36","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}},this._getDefaultUserDataHeaders=function(e){return l({},v._getUnAuthenticatedHeaders(),{Host:"www.threads.net",Accept:"*/*","Accept-Language":v.locale,"cache-control":"no-cache",Origin:"https://www.threads.net",Pragma:"no-cache","Sec-Fetch-Site":"same-origin","X-Asbd-id":"129477","X-FB-Friendly-Name":"BarcelonaProfileRootQuery","X-FB-Lsd":v.fbLSDToken,"X-Ig-App-Id":"238260118697367"},e?{Referer:"https://www.threads.net/@"+e}:void 0)},this._getAppHeaders=function(){return l({"User-Agent":"Barcelona "+a.LATEST_ANDROID_APP_VERSION+" Android","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},v.token&&{Authorization:"Bearer IGT:2:"+v.token})},this._getInstaHeaders=function(){return l({},v._getAppHeaders(),{"X-Bloks-Is-Layout-Rtl":"false","X-Bloks-Version-Id":s.BLOKS_VERSION,"X-Ig-Android-Id":v.deviceID,"X-Ig-App-Id":s.IG_APP_ID,"Accept-Language":v.locale||"en-US"},v.userID&&{"Ig-U-Ds-User-Id":v.userID,"Ig-Intended-User-Id":v.userID},v.locale&&{"X-Ig-App-Locale":v.locale.replace("-","_"),"X-Ig-Device-Locale":v.locale.replace("-","_"),"X-Ig-Mapped-Locale":v.locale.replace("-","_")})},this._getDefaultHeaders=function(e){return l({},v._getAppHeaders(),{authority:"www.threads.net",accept:"*/*","accept-language":v.locale,"cache-control":"no-cache",origin:"https://www.threads.net",pragma:"no-cache","Sec-Fetch-Site":"same-origin","x-asbd-id":"129477","x-fb-lsd":v.fbLSDToken,"x-ig-app-id":"238260118697367"},e?{referer:"https://www.threads.net/@"+e}:void 0)};var I=this;this._getCleanedProfileHTML=u(function(t,r,n){return d(this,function(s){switch(s.label){case 0:return[4,e.default.get(""+t+r,l({},n,{httpAgent:I.httpAgent,httpsAgent:I.httpsAgent,headers:l({},I._getDefaultHeaders(r),{accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","accept-language":"ko,en;q=0.9,ko-KR;q=0.8,ja;q=0.7",Authorization:void 0,referer:"https://www.instagram.com/","sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"cross-site","sec-fetch-user":"?1","upgrade-insecure-requests":"1","x-asbd-id":void 0,"x-fb-lsd":void 0,"x-ig-app-id":void 0})}))];case 1:return[2,(0,s.sent().data).replace(/\s/g,"").replace(/\n/g,"")]}})});var D=this;this.getUserIDfromUsernameWithInstagram=u(function(e,t){var r,n,s,a,o;return d(this,function(i){switch(i.label){case 0:return[4,D._getCleanedProfileHTML("https://www.instagram.com/",e,t)];case 1:return a=null==(r=(s=i.sent()).match(/"user_id":"(\d+)",/))?void 0:r[1],o=null==(n=s.match(/"LSD",\[\],{"token":"(\w+)"},\d+\]/))?void 0:n[1],!D.noUpdateLSD&&o&&(D.fbLSDToken=o,D.verbose&&console.debug("[fbLSDToken] UPDATED",D.fbLSDToken)),[2,a]}})});var A=this;this.getUserIDfromUsername=u(function(e,t){var r,n,s,a,o;return d(this,function(i){switch(i.label){case 0:return[4,A._getCleanedProfileHTML("https://www.threads.net/@",e,t)];case 1:if(a=null==(r=(s=i.sent()).match(/"user_id":"(\d+)"/))?void 0:r[1],o=null==(n=s.match(/"LSD",\[\],{"token":"(\w+)"},\d+\]/))?void 0:n[1],!a)return[2,A.getUserIDfromUsernameWithInstagram(e,t)];return!A.noUpdateLSD&&o&&(A.fbLSDToken=o,A.verbose&&console.debug("[fbLSDToken] UPDATED",A.fbLSDToken)),[2,a]}})});var w=this;this.getCurrentUserID=u(function(e){var t;return d(this,function(r){switch(r.label){case 0:if(w.userID)return w.verbose&&console.debug("[userID] USING",w.userID),[2,w.userID];if(!w.username)throw Error("username is not defined");r.label=1;case 1:return r.trys.push([1,3,,5]),[4,w.getUserIDfromUsername(w.username,e)];case 2:return w.userID=r.sent(),w.verbose&&console.debug("[userID] UPDATED",w.userID),[2,w.userID];case 3:return t=r.sent(),w.verbose&&console.error("[userID] Failed to fetch userID, Fallbacking to login",t),[4,w.login()];case 4:return[2,r.sent().userID];case 5:return[2]}})}),this._requestQuery=function(t,r,n){return Object.keys(r).forEach(function(e){return void 0===r[e]&&delete r[e]}),e.default.post(t,new URLSearchParams(r),l({httpAgent:v.httpAgent,httpsAgent:v.httpsAgent,headers:v._getDefaultHeaders()},n))},this._requestUserDataQuery=function(t,r,n){return Object.keys(r).forEach(function(e){return void 0===r[e]&&delete r[e]}),e.default.post(t,new URLSearchParams(r),l({httpAgent:v.httpAgent,httpsAgent:v.httpsAgent,headers:v._getDefaultUserDataHeaders()},n))},this._destructureFromUserIDQuerier=function(e){var t,r;return"string"==typeof e[0]&&"string"==typeof e[1]?(t=e[1],r=e[2]):(t=e[0],r=e[1]),{userID:t,options:r}};var S=this;this.getUserProfile=u(function(){var e,t,r,n,s,a,o=arguments;return d(this,function(i){switch(i.label){case 0:for(t=Array(e=o.length),r=0;r<e;r++)t[r]=o[r];return s=(n=S._destructureFromUserIDQuerier(t)).userID,a=n.options,S.verbose&&console.debug("[fbLSDToken] USING",S.fbLSDToken),[4,S._requestUserDataQuery("https://www.threads.net/api/graphql",{lsd:S.fbLSDToken,variables:JSON.stringify({userID:s}),doc_id:"23996318473300828"},a)];case 1:return[2,i.sent().data.data.userData.user]}})});var y=this;this.getUserProfileThreads=u(function(){var e,t,r,n,s,a,o,i,u=arguments;return d(this,function(l){switch(l.label){case 0:for(t=Array(e=u.length),r=0;r<e;r++)t[r]=u[r];return o=(a=y._destructureFromUserIDQuerier(t)).userID,i=a.options,y.verbose&&console.debug("[fbLSDToken] USING",y.fbLSDToken),[4,y._requestUserDataQuery("https://www.threads.net/api/graphql",{lsd:y.fbLSDToken,variables:JSON.stringify({userID:o}),doc_id:"6232751443445612"},i)];case 1:return[2,(null==(s=l.sent().data.data)?void 0:null==(n=s.mediaData)?void 0:n.threads)||[]]}})});var L=this;this.getUserProfileThreadsLoggedIn=u(function(t,r,n){var a,o,i,u;return d(this,function(c){switch(c.label){case 0:if(void 0===r&&(r=""),void 0===n&&(n={}),L.token)return[3,2];return[4,L.getToken()];case 1:c.sent(),c.label=2;case 2:if(!L.token)throw Error("Token not found");o=void 0,c.label=3;case 3:return c.trys.push([3,5,,6]),[4,e.default.get(s.BASE_API_URL+"/api/v1/text_feed/"+t+"/profile/"+(r&&"?max_id="+r),l({},n,{headers:l({},L._getInstaHeaders(),null==(i=n)?void 0:i.headers)}))];case 4:return o=c.sent().data,[3,6];case 5:return o=null==(u=c.sent().response)?void 0:u.data,[3,6];case 6:if((null==(a=o)?void 0:a.status)!=="ok")throw L.verbose&&console.log("[USER FEED] Failed to fetch",o),Error("Failed to fetch user feed: "+JSON.stringify(o));return[2,o]}})}),this._getDefaultRepliesHeaders=function(e){return l({},v._getUnAuthenticatedHeaders(),{Host:"www.threads.net",Accept:"*/*","Accept-Language":v.locale,"cache-control":"no-cache",Origin:"https://www.threads.net",Pragma:"no-cache","Sec-Fetch-Site":"same-origin","X-Asbd-id":"129477","X-FB-Friendly-Name":"BarcelonaProfileProfileRepliesTabQuery","X-FB-Lsd":v.fbLSDToken,"X-Ig-App-Id":"238260118697367"},e?{Referer:"https://www.threads.net/@"+e+"/replies"}:void 0)},this._requestRepliesQuery=function(t,r,n){return Object.keys(r).forEach(function(e){return void 0===r[e]&&delete r[e]}),e.default.post(t,new URLSearchParams(r),l({httpAgent:v.httpAgent,httpsAgent:v.httpsAgent,headers:v._getDefaultRepliesHeaders()},n))};var U=this;this.getUserProfileReplies=u(function(){var e,t,r,n,s,a,o,i=arguments;return d(this,function(u){switch(u.label){case 0:for(t=Array(e=i.length),r=0;r<e;r++)t[r]=i[r];return a=(s=U._destructureFromUserIDQuerier(t)).userID,o=s.options,U.verbose&&console.debug("[fbLSDToken] USING",U.fbLSDToken),[4,U._requestRepliesQuery("https://www.threads.net/api/graphql",{lsd:U.fbLSDToken,variables:JSON.stringify({userID:a}),doc_id:"6684830921547925"},o)];case 1:return[2,(null==(n=u.sent().data.data.mediaData)?void 0:n.threads)||[]]}})});var k=this;this.getUserProfileRepliesLoggedIn=u(function(t,r,n){var s,a,o,i;return d(this,function(u){switch(u.label){case 0:if(void 0===r&&(r=""),void 0===n&&(n={}),k.token)return[3,2];return[4,k.getToken()];case 1:u.sent(),u.label=2;case 2:if(!k.token)throw Error("Token not found");a=void 0,u.label=3;case 3:return u.trys.push([3,5,,6]),[4,e.default.get("https://i.instagram.com/api/v1/text_feed/"+t+"/profile/replies/"+(r&&"?max_id="+r),l({},n,{headers:l({},k._getAppHeaders(),null==(o=n)?void 0:o.headers)}))];case 4:return a=u.sent().data,[3,6];case 5:return a=null==(i=u.sent().response)?void 0:i.data,[3,6];case 6:if((null==(s=a)?void 0:s.status)!=="ok")throw k.verbose&&console.log("[USER FEED] Failed to fetch",a),Error("Failed to fetch user feed: "+JSON.stringify(a));return[2,a]}})});var E=this;this.getUserFollowers=u(function(t,r,n){var a,o,i,u,c,h,p,f;return d(this,function(d){switch(d.label){case 0:if(o=(a=void 0===r?{}:r).maxID,i=a.query,E.token)return[3,2];return[4,E.getToken()];case 1:d.sent(),d.label=2;case 2:if(!E.token)throw Error("Token not found");c=void 0,h=new URLSearchParams(s.BASE_FOLLOW_PARAMS),o&&h.append("max_id",o),i&&h.append("query",i),d.label=3;case 3:return d.trys.push([3,5,,6]),[4,e.default.get("https://i.instagram.com/api/v1/friendships/"+t+"/followers/?"+h.toString(),l({},n,{headers:l({},E._getInstaHeaders(),{"X-Ig-Nav-Chain":s.FOLLOW_NAV_CHAIN},null==(p=n)?void 0:p.headers)}))];case 4:return c=d.sent().data,[3,6];case 5:return c=null==(f=d.sent().response)?void 0:f.data,[3,6];case 6:if((null==(u=c)?void 0:u.status)!=="ok")throw E.verbose&&console.log("[USER FOLLOWERS] Failed to fetch",c),Error("Failed to fetch user followers: "+JSON.stringify(c));return[2,c]}})});var T=this;this.getUserFollowings=u(function(t,r,n){var a,o,i,u,c,h,p,f;return d(this,function(d){switch(d.label){case 0:if(o=(a=void 0===r?{}:r).maxID,i=a.query,T.token)return[3,2];return[4,T.getToken()];case 1:d.sent(),d.label=2;case 2:if(!T.token)throw Error("Token not found");c=void 0,h=new URLSearchParams(s.BASE_FOLLOW_PARAMS),o&&h.append("max_id",o),i&&h.append("query",i),d.label=3;case 3:return d.trys.push([3,5,,6]),[4,e.default.get("https://i.instagram.com/api/v1/friendships/"+t+"/following/?"+h.toString(),l({},n,{headers:l({},T._getInstaHeaders(),{"X-Ig-Nav-Chain":s.FOLLOW_NAV_CHAIN},null==(p=n)?void 0:p.headers)}))];case 4:return c=d.sent().data,[3,6];case 5:return c=null==(f=d.sent().response)?void 0:f.data,[3,6];case 6:if((null==(u=c)?void 0:u.status)!=="ok")throw T.verbose&&console.log("[USER FOLLOWING] Failed to fetch",c),Error("Failed to fetch user following: "+JSON.stringify(c));return[2,c]}})}),this.getPostIDfromThreadID=function(e){e=(e=(e=e.split("?")[0]).replace(/\s/g,"")).replace(/\//g,"");for(var t,r=0n,n=c(e);!(t=n()).done;){var s=t.value;r=64n*r+BigInt("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(s))}return r.toString()},this.getPostIDfromURL=function(e){var t,r,n=null==e?void 0:e.split("?")[0];return(null==(t=n)?void 0:t.endsWith("/"))&&(n=n.slice(0,-1)),n=(null==(r=n)?void 0:r.split("/").pop())||"",v.getPostIDfromThreadID(n||"")};var O=this;this.getThreads=u(function(e,t){return d(this,function(r){switch(r.label){case 0:return O.verbose&&console.debug("[fbLSDToken] USING",O.fbLSDToken),[4,O._requestUserDataQuery("https://www.threads.net/api/graphql",{lsd:O.fbLSDToken,variables:JSON.stringify({postID:e}),doc_id:"5587632691339264"},t)];case 1:return[2,r.sent().data.data.data]}})});var P=this;this.getThreadLikers=u(function(e,t){return d(this,function(r){switch(r.label){case 0:return P.verbose&&console.debug("[fbLSDToken] USING",P.fbLSDToken),[4,P._requestUserDataQuery("https://www.threads.net/api/graphql",{lsd:P.fbLSDToken,variables:JSON.stringify({mediaID:e}),doc_id:"9360915773983802"},t)];case 1:return[2,r.sent().data.data.likers]}})});var R=this;this.getTimeline=u(function(e,t){var r;return d(this,function(n){switch(n.label){case 0:if(void 0===e&&(e=""),!R.token&&(!R.username||!R.password))throw Error("Username or password not set");return[4,R.getToken()];case 1:if(!n.sent())throw Error("Token not found");n.label=2;case 2:return n.trys.push([2,4,,5]),[4,R._requestQuery(""+s.BASE_API_URL+"/api/v1/feed/text_post_app_timeline/",{pagination_source:"text_post_feed_threads",max_id:e||void 0},l({},t,{headers:R._getAppHeaders()}))];case 3:return[2,n.sent().data];case 4:throw r=n.sent(),R.verbose&&console.log("[TIMELINE FETCH FAILED]",r.response.data),Error("Failed to fetch timeline");case 5:return[2]}})});var N=this;this._toggleAuthPostRequest=u(function(t,r,n){return d(this,function(s){switch(s.label){case 0:return[4,N.getToken()];case 1:if(!s.sent())throw Error("Token not found");return[4,e.default.post(t,r?new URLSearchParams(r):void 0,l({},n,{httpAgent:N.httpAgent,httpsAgent:N.httpsAgent,headers:N._getDefaultHeaders()}))];case 2:return[2,s.sent()]}})});var x=this;this.like=u(function(e,t){var r;return d(this,function(n){switch(n.label){case 0:return[4,x.getCurrentUserID()];case 1:return r=n.sent(),[4,x._toggleAuthPostRequest(s.BASE_API_URL+"/api/v1/media/"+e+"_"+r+"/like/",void 0,t)];case 2:return[2,"ok"===n.sent().data.status]}})});var F=this;this.unlike=u(function(e,t){var r;return d(this,function(n){switch(n.label){case 0:return[4,F.getCurrentUserID()];case 1:return r=n.sent(),[4,F._toggleAuthPostRequest(s.BASE_API_URL+"/api/v1/media/"+e+"_"+r+"/unlike/",void 0,t)];case 2:return[2,"ok"===n.sent().data.status]}})});var q=this;this.follow=u(function(e,t){var r;return d(this,function(n){switch(n.label){case 0:return[4,q._toggleAuthPostRequest(s.BASE_API_URL+"/api/v1/friendships/create/"+e+"/",void 0,t)];case 1:return r=n.sent(),q.verbose&&console.debug("[FOLLOW]",r.data),[2,r.data]}})});var H=this;this.unfollow=u(function(e,t){var r;return d(this,function(n){switch(n.label){case 0:return[4,H._toggleAuthPostRequest(s.BASE_API_URL+"/api/v1/friendships/destroy/"+e+"/",void 0,t)];case 1:return r=n.sent(),H.verbose&&console.debug("[UNFOLLOW]",r.data),[2,r.data]}})});var B=this;this.repost=u(function(e,t){var r;return d(this,function(n){switch(n.label){case 0:return[4,B._toggleAuthPostRequest(""+s.BASE_API_URL+"api/v1/repost/create_repost/",{media_id:e},t)];case 1:return r=n.sent(),B.verbose&&console.debug("[REPOST]",r.data),[2,r.data]}})});var C=this;this.unrepost=u(function(e,t){var r;return d(this,function(n){switch(n.label){case 0:return[4,C._toggleAuthPostRequest(""+s.BASE_API_URL+"/api/v1/repost/delete_text_app_repost/",{original_media_id:e},t)];case 1:return r=n.sent(),C.verbose&&console.debug("[UNREPOST]",r.data),[2,r.data]}})});var G=this;this.getToken=u(function(){return d(this,function(e){switch(e.label){case 0:if(G.token)return G.verbose&&console.debug("[token] USING",G.token),[2,G.token];if(!G.username||!G.password)throw Error("Username and password are required");return[4,G.login()];case 1:return e.sent(),[2,G.token]}})}),this._lastUploadID=0,this._nextUploadID=function(){var e=Date.now(),t=v._lastUploadID;return(v._lastUploadID=e<t?t+1:e).toString()},this._createUploadMetadata=function(e){var t;return void 0===e&&(e=v._nextUploadID()),{upload_id:e,source_type:"4",timezone_offset:(null!=(t=v._timezoneOffset)?t:v._timezoneOffset=-(60*new Date().getTimezoneOffset())).toString(),device:v.device}};var M=this;this.publish=u(function(t){var r,n,a,o,i,u,h,p,f,g,v,_;return d(this,function(d){switch(d.label){case 0:if(r="string"==typeof t?{text:t}:t,!M.token&&(!M.username||!M.password))throw Error("Username or password not set");return[4,M.getCurrentUserID()];case 1:if(!(n=d.sent()))throw Error("User ID not found");return[4,M.getToken()];case 2:if(!d.sent())throw Error("Token not found");if(o=l({},M._createUploadMetadata(),{text_post_app_info:{reply_control:s.REPLY_CONTROL_OPTIONS[null!=(a=r.replyControl)?a:"everyone"]},_uid:n,device_id:M.deviceID,caption:r.text||""}),i=s.POST_URL,!(u=r.attachment)&&("image"in r&&r.image?u={image:r.image}:"url"in r&&r.url&&(u={url:r.url})),!u)return[3,9];if(!u.url)return[3,3];return o.text_post_app_info.link_attachment_url=u.url,[3,9];case 3:if(!u.image)return[3,5];return i=s.POST_WITH_IMAGE_URL,[4,M.uploadImage(u.image,o.upload_id)];case 4:return d.sent(),o.scene_type=null,o.scene_capture_type="",[3,9];case 5:if(!u.sidecar)return[3,9];i=s.POST_WITH_SIDECAR_URL,o.client_sidecar_id=o.upload_id,o.children_metadata=[],h=c(u.sidecar),d.label=6;case 6:if((p=h()).done)return[3,9];return f=p.value,[4,M.uploadImage(f)];case 7:g=d.sent().upload_id,o.children_metadata.push(l({},M._createUploadMetadata(g),{scene_type:null,scene_capture_type:""})),d.label=8;case 8:return[3,6];case 9:return r.parentPostID&&(o.text_post_app_info.reply_id=r.parentPostID.replace(/_\d+$/,"")),r.quotedPostID&&(o.text_post_app_info.quoted_post_id=r.quotedPostID.replace(/_\d+$/,"")),i===s.POST_URL&&(o.publish_mode="text_post"),v="signed_body=SIGNATURE."+encodeURIComponent(JSON.stringify(o)),[4,e.default.post(i,v,{httpAgent:M.httpAgent,httpsAgent:M.httpsAgent,headers:M._getAppHeaders(),timeout:6e4})];case 10:if(_=d.sent(),M.verbose&&console.debug("[PUBLISH]",_.data),"ok"===_.data.status)return[2,_.data.media.id.replace(/_\d+$/,"")];return[2,void 0]}})});var X=this;this.delete=u(function(t,r){var n,a;return d(this,function(o){switch(o.label){case 0:return n=s.BASE_API_URL+"/api/v1/media/"+t+"/delete/",a="signed_body=SIGNATURE."+encodeURIComponent(JSON.stringify({media_id:t,_uid:X.userID,_uuid:X.deviceID})),[4,e.default.post(n,a,l({httpAgent:X.httpAgent,httpsAgent:X.httpsAgent,headers:X._getAppHeaders(),timeout:6e4},r))];case 1:if("ok"===o.sent().data.status)return[2,!0];return[2,!1]}})});var W=this;this.publishWithImage=u(function(e,t){return d(this,function(r){return[2,W.publish({text:e,image:t})]})});var J=this;if(this.uploadImage=u(function(t,s){var a,o,i,u,c,h,p,f,g,v,_;return d(this,function(d){switch(d.label){case 0:if(void 0===s&&(s=J._nextUploadID()),o="https://www.instagram.com/rupload_igphoto/"+(a=s+"_0_"+Math.floor(9e9*Math.random()+1e9)),!("string"==typeof t||"path"in t))return[3,6];if((c="string"==typeof t?t:t.path).startsWith("http"))return[3,3];return[4,Promise.resolve().then(function(){return require("fs")})];case 1:return[4,d.sent().promises.readFile(c)];case 2:return i=d.sent(),u=r.lookup(c)||"application/octet-stream",[3,5];case 3:return[4,e.default.get(c,{responseType:"arraybuffer"})];case 4:h=d.sent(),i=Buffer.from(h.data,"binary"),u=h.headers["content-type"],d.label=5;case 5:return[3,7];case 6:i=t.data,u=(t.type.includes("/")?t.type:r.lookup(t.type))||"application/octet-stream",d.label=7;case 7:p={upload_id:s,media_type:"1",sticker_burnin_params:JSON.stringify([]),image_compression:JSON.stringify({lib_name:"moz",lib_version:"3.1.m",quality:"80"}),xsharing_user_ids:JSON.stringify([]),retry_context:JSON.stringify({num_step_auto_retry:"0",num_reupload:"0",num_step_manual_retry:"0"}),"IG-FB-Xpost-entry-point-v2":"feed"},f=i.length,g=l({},J._getDefaultHeaders(),{"Content-Type":"application/octet-stream",X_FB_PHOTO_WATERFALL_ID:(0,n.v4)(),"X-Entity-Type":void 0!==u?"image/"+u:"image/jpeg",Offset:"0","X-Instagram-Rupload-Params":JSON.stringify(p),"X-Entity-Name":a,"X-Entity-Length":f.toString(),"Content-Length":f.toString(),"Accept-Encoding":"gzip"}),J.verbose&&console.log("[UPLOAD_IMAGE] Uploading "+f.toLocaleString()+"b as "+s+"..."),d.label=8;case 8:return d.trys.push([8,10,,11]),[4,e.default.post(o,i,{httpAgent:J.httpAgent,headers:g,timeout:6e4})];case 9:return v=d.sent().data,J.verbose&&console.log("[UPLOAD_IMAGE] SUCCESS",v),[2,v];case 10:throw _=d.sent(),J.verbose&&console.log("[UPLOAD_IMAGE] FAILED",_.response.data),Error("Upload image failed");case 11:return[2]}})}),(null==o?void 0:o.token)&&(this.token=o.token),(null==o?void 0:o.fbLSDToken)&&(this.fbLSDToken=o.fbLSDToken),this.noUpdateToken=!!(null==o?void 0:o.noUpdateToken),this.noUpdateLSD=!!(null==o?void 0:o.noUpdateLSD),this.verbose=(null==o?void 0:o.verbose)||!1,this.httpAgent=null==o?void 0:o.httpAgent,this.httpsAgent=null==o?void 0:o.httpsAgent,this.username=null!=(i=null==o?void 0:o.username)?i:process.env.THREADS_USERNAME,this.password=null!=(p=null==o?void 0:o.password)?p:process.env.THREADS_PASSWORD,this.deviceID=null!=(g=null!=(f=null==o?void 0:o.deviceID)?f:process.env.THREADS_DEVICE_ID)?g:"",this.deviceID||(this.deviceID="android-"+(1e24*Math.random()).toString(36),console.warn("โš ๏ธ WARNING: deviceID not provided, automatically generating device id '"+this.deviceID+"'","Please save this device id and use it for future uses to prevent login issues.","You can provide this device id by passing it to the constructor or setting the THREADS_DEVICE_ID environment variable (.env file)")),this.device=null==o?void 0:o.device,this.userID=null==o?void 0:o.userID,null==o?void 0:o.locale)this.locale=o.locale;else{var Q=Intl.DateTimeFormat().resolvedOptions().locale;this.locale=Q}this.maxRetries=(null==o?void 0:o.maxRetries)||this.maxRetries}return o.prototype.sign=function(e){var r="object"==typeof e?JSON.stringify(e):e;return{ig_sig_key_version:4,signed_body:t.createHmac("sha256",s.SIGNATURE_KEY).update(r).digest("hex")+"."+r}},o}();
"use strict";!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{DEFAULT_DEVICE:function(){return p},ThreadsAPI:function(){return f},default:function(){return g}});var e=require("axios"),t=require("crypto"),r=require("mrmime"),n=require("uuid"),s=require("./constants"),a=require("./dynamic-data"),o=require("./error");function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t,r,n,s,a,o){try{var i=e[a](o),u=i.value}catch(e){r(e);return}i.done?t(u):Promise.resolve(u).then(n,s)}function c(e){return function(){var t=this,r=arguments;return new Promise(function(n,s){var a=e.apply(t,r);function o(e){u(a,n,s,o,i,"next",e)}function i(e){u(a,n,s,o,i,"throw",e)}o(void 0)})}}function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){var r,n,s,a,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(s=(s=o.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}var p={manufacturer:"OnePlus",model:"ONEPLUS+A3010",os_version:25,os_release:"7.1.1"},f=function(){"use strict";function i(i){var u,f,g,_,v=this;this.verbose=!1,this.token=void 0,this.fbLSDToken=s.DEFAULT_LSD_TOKEN,this.noUpdateToken=!1,this.noUpdateLSD=!1,this.device=p,this.userID=void 0,this.locale=void 0,this.maxRetries=1;var b=this;this.syncLoginExperiments=c(function(){var t,r,a;return h(this,function(o){switch(o.label){case 0:r={id:t=(0,n.v4)(),experiments:s.LOGIN_EXPERIMENTS},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,e.default.post(""+s.BASE_API_URL+"/api/v1/qe/sync/",b.sign(r),{httpAgent:b.httpAgent,httpsAgent:b.httpsAgent,headers:l({},b._getAppHeaders(),{Authorization:void 0,"Sec-Fetch-Site":"same-origin","X-DEVICE-ID":t})})];case 2:return[2,o.sent()];case 3:throw a=o.sent(),b.verbose&&console.log("[SYNC LOGIN EXPERIMENT FAILED]",a.response.data),Error("Sync login experiment failed");case 4:return[2]}})});var m=this;this.encryptPassword=c(function(e){var r,n,s,a,o,i,u,c,l,d,p;return h(this,function(h){switch(h.label){case 0:return r=t.randomBytes(32),n=t.randomBytes(12),[4,m.syncLoginExperiments()];case 1:return s=h.sent().headers,m.verbose&&console.log("[SYNC LOGIN EXPERIMENT HEADERS]",JSON.stringify(s)),a=s["ig-set-password-encryption-key-id"],o=s["ig-set-password-encryption-pub-key"],i=t.publicEncrypt({key:Buffer.from(o||"","base64").toString(),padding:t.constants.RSA_PKCS1_PADDING},r),u=t.createCipheriv("aes-256-gcm",r,n),c=Math.floor(Date.now()/1e3).toString(),u.setAAD(Buffer.from(c)),l=Buffer.concat([u.update(e,"utf8"),u.final()]),(d=Buffer.alloc(2,0)).writeInt16LE(i.byteLength,0),p=u.getAuthTag(),[2,{time:c,password:Buffer.concat([Buffer.from([1,a||0]),n,d,i,p,l]).toString("base64")}]}})});var I=this;this.login=c(function(){var t,r,n,a;return h(this,function(o){switch(o.label){case 0:t=function(){var e;return h(this,function(t){switch(t.label){case 0:return t.trys.push([0,1,,3]),[2,{v:n()}];case 1:return t.sent(),I.verbose&&console.error("[LOGIN] Failed to login, retrying... ("+(r+1)+"/"+I.maxRetries+")"),e=1e3*Math.pow(2,r),[4,new Promise(function(t){return setTimeout(t,e)})];case 2:return t.sent(),r++,[3,3];case 3:return[2]}})},r=0,n=c(function(){var t,r,n,a,o,i,u,c;return h(this,function(l){switch(l.label){case 0:return I.verbose&&console.log("[LOGIN] Logging in..."),[4,I.encryptPassword(I.password)];case 1:return r=encodeURIComponent(JSON.stringify({client_input_params:{password:"#PWD_INSTAGRAM:4:"+(t=l.sent()).time+":"+t.password,contact_point:I.username,device_id:I.deviceID},server_params:{credential_type:"password",device_id:I.deviceID}})),n=encodeURIComponent(JSON.stringify({bloks_version:s.BLOKS_VERSION,styles_id:"instagram"})),a={httpAgent:I.httpAgent,httpsAgent:I.httpsAgent,method:"POST",headers:I._getAppHeaders(),responseType:"text",data:"params="+r+"&bk_client_context="+n+"&bloks_versioning_id="+s.BLOKS_VERSION},[4,(0,e.default)(""+s.BASE_API_URL+"/api/v1/bloks/apps/com.bloks.www.bloks.caa.login.async.send_login_request/",a)];case 2:o=JSON.stringify((o=l.sent().data).replaceAll("\\","")),I.verbose&&console.log("[LOGIN] Cleaned output",o);try{return u=o.split("Bearer IGT:2:")[1].split('"')[0].replaceAll("\\",""),c=null==(i=o.match(/pk_id(.{18})/))?void 0:i[1].replaceAll(/[\\":]/g,""),I.noUpdateToken||(I.verbose&&console.debug("[token] UPDATED",u),I.token=u),I.userID=c,I.verbose&&console.debug("[userID] UPDATED",I.userID),[2,{token:u,userID:c}]}catch(e){throw I.verbose&&console.error("[LOGIN] Failed to login",e),Error("Login Failed")}return[2]}})}),o.label=1;case 1:if(!(r<I.maxRetries))return[3,3];return[5,function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(t())];case 2:var i;if("object"==((i=a=o.sent())&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i))return[2,a.v];return[3,1];case 3:throw Error("[LOGIN] Failed to login after "+I.maxRetries+" retries")}})}),this._getUnAuthenticatedHeaders=function(){return{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.199 Safari/537.36","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}},this._getDefaultUserDataHeaders=function(e){return l({},v._getUnAuthenticatedHeaders(),{Host:"www.threads.net",Accept:"*/*","Accept-Language":v.locale,"cache-control":"no-cache",Origin:"https://www.threads.net",Pragma:"no-cache","Sec-Fetch-Site":"same-origin","X-Asbd-id":"129477","X-FB-Friendly-Name":"BarcelonaProfileRootQuery","X-FB-Lsd":v.fbLSDToken,"X-Ig-App-Id":"238260118697367"},e?{Referer:"https://www.threads.net/@"+e}:void 0)},this._getAppHeaders=function(){return l({"User-Agent":"Barcelona "+a.LATEST_ANDROID_APP_VERSION+" Android","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},v.token&&{Authorization:"Bearer IGT:2:"+v.token})},this._getInstaHeaders=function(){return l({},v._getAppHeaders(),{"X-Bloks-Is-Layout-Rtl":"false","X-Bloks-Version-Id":s.BLOKS_VERSION,"X-Ig-Android-Id":v.deviceID,"X-Ig-App-Id":s.IG_APP_ID,"Accept-Language":v.locale||"en-US"},v.userID&&{"Ig-U-Ds-User-Id":v.userID,"Ig-Intended-User-Id":v.userID},v.locale&&{"X-Ig-App-Locale":v.locale.replace("-","_"),"X-Ig-Device-Locale":v.locale.replace("-","_"),"X-Ig-Mapped-Locale":v.locale.replace("-","_")})},this._getDefaultHeaders=function(e){return l({},v._getAppHeaders(),{authority:"www.threads.net",accept:"*/*","accept-language":v.locale,"cache-control":"no-cache",origin:"https://www.threads.net",pragma:"no-cache","Sec-Fetch-Site":"same-origin","x-asbd-id":"129477","x-fb-lsd":v.fbLSDToken,"x-ig-app-id":"238260118697367"},e?{referer:"https://www.threads.net/@"+e}:void 0)};var A=this;this._getCleanedProfileHTML=c(function(t,r,n){return h(this,function(s){switch(s.label){case 0:return[4,e.default.get(""+t+r,l({},n,{httpAgent:A.httpAgent,httpsAgent:A.httpsAgent,headers:l({},A._getDefaultHeaders(r),{accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","accept-language":"ko,en;q=0.9,ko-KR;q=0.8,ja;q=0.7",Authorization:void 0,referer:"https://www.instagram.com/","sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"cross-site","sec-fetch-user":"?1","upgrade-insecure-requests":"1","x-asbd-id":void 0,"x-fb-lsd":void 0,"x-ig-app-id":void 0})}))];case 1:return[2,(0,s.sent().data).replace(/\s/g,"").replace(/\n/g,"")]}})});var S=this;this.getUserIDfromUsernameWithInstagram=c(function(e,t){var r,n,s,a,o;return h(this,function(i){switch(i.label){case 0:return[4,S._getCleanedProfileHTML("https://www.instagram.com/",e,t)];case 1:return a=null==(r=(s=i.sent()).match(/"user_id":"(\d+)",/))?void 0:r[1],o=null==(n=s.match(/"LSD",\[\],{"token":"(\w+)"},\d+\]/))?void 0:n[1],!S.noUpdateLSD&&o&&(S.fbLSDToken=o,S.verbose&&console.debug("[fbLSDToken] UPDATED",S.fbLSDToken)),[2,a]}})});var w=this;this.getUserIDfromUsername=c(function(e,t){var r,n,s,a,o;return h(this,function(i){switch(i.label){case 0:return[4,w._getCleanedProfileHTML("https://www.threads.net/@",e,t)];case 1:if(a=null==(r=(s=i.sent()).match(/"user_id":"(\d+)"/))?void 0:r[1],o=null==(n=s.match(/"LSD",\[\],{"token":"(\w+)"},\d+\]/))?void 0:n[1],!a)return[2,w.getUserIDfromUsernameWithInstagram(e,t)];return!w.noUpdateLSD&&o&&(w.fbLSDToken=o,w.verbose&&console.debug("[fbLSDToken] UPDATED",w.fbLSDToken)),[2,a]}})});var D=this;this.getCurrentUserID=c(function(e){var t;return h(this,function(r){switch(r.label){case 0:if(D.userID)return D.verbose&&console.debug("[userID] USING",D.userID),[2,D.userID];if(!D.username)throw Error("username is not defined");r.label=1;case 1:return r.trys.push([1,3,,5]),[4,D.getUserIDfromUsername(D.username,e)];case 2:return D.userID=r.sent(),D.verbose&&console.debug("[userID] UPDATED",D.userID),[2,D.userID];case 3:return t=r.sent(),D.verbose&&console.error("[userID] Failed to fetch userID, Fallbacking to login",t),[4,D.login()];case 4:return[2,r.sent().userID];case 5:return[2]}})}),this._requestQuery=function(t,r,n){return Object.keys(r).forEach(function(e){return void 0===r[e]&&delete r[e]}),e.default.post(t,new URLSearchParams(r),l({httpAgent:v.httpAgent,httpsAgent:v.httpsAgent,headers:v._getDefaultHeaders()},n))},this._requestUserDataQuery=function(t,r,n){return Object.keys(r).forEach(function(e){return void 0===r[e]&&delete r[e]}),e.default.post(t,new URLSearchParams(r),l({httpAgent:v.httpAgent,httpsAgent:v.httpsAgent,headers:v._getDefaultUserDataHeaders()},n))},this._destructureFromUserIDQuerier=function(e){var t,r;return"string"==typeof e[0]&&"string"==typeof e[1]?(t=e[1],r=e[2]):(t=e[0],r=e[1]),{userID:t,options:r}};var y=this;this.getUserProfile=c(function(){var e,t,r,n,s,a,o=arguments;return h(this,function(i){switch(i.label){case 0:for(t=Array(e=o.length),r=0;r<e;r++)t[r]=o[r];return s=(n=y._destructureFromUserIDQuerier(t)).userID,a=n.options,y.verbose&&console.debug("[fbLSDToken] USING",y.fbLSDToken),[4,y._requestUserDataQuery("https://www.threads.net/api/graphql",{lsd:y.fbLSDToken,variables:JSON.stringify({userID:s}),doc_id:"23996318473300828"},a)];case 1:return[2,i.sent().data.data.userData.user]}})});var U=this;this.getUserProfileLoggedIn=c(function(e,t){var r,n,a;return h(this,function(i){switch(i.label){case 0:void 0===t&&(t={}),n=void 0,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,U._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/users/"+e+"/info?is_prefetch=false&entry_point=profile&from_module=ProfileViewModel",t)];case 2:return n=i.sent().data,[3,4];case 3:return n=null==(a=i.sent().response)?void 0:a.data,[3,4];case 4:if((null==(r=n)?void 0:r.status)!=="ok")throw U.verbose&&console.log("[USER PROFILE] Failed to fetch",n),new o.ThreadsAPIError("Failed to fetch user profile: "+JSON.stringify(n),n);return[2,n]}})});var E=this;this.getUserProfileThreads=c(function(){var e,t,r,n,s,a,o,i,u=arguments;return h(this,function(c){switch(c.label){case 0:for(t=Array(e=u.length),r=0;r<e;r++)t[r]=u[r];return o=(a=E._destructureFromUserIDQuerier(t)).userID,i=a.options,E.verbose&&console.debug("[fbLSDToken] USING",E.fbLSDToken),[4,E._requestUserDataQuery("https://www.threads.net/api/graphql",{lsd:E.fbLSDToken,variables:JSON.stringify({userID:o}),doc_id:"6232751443445612"},i)];case 1:return[2,(null==(s=c.sent().data.data)?void 0:null==(n=s.mediaData)?void 0:n.threads)||[]]}})});var L=this;this.getUserProfileThreadsLoggedIn=c(function(e,t,r){var n,a,i;return h(this,function(u){switch(u.label){case 0:void 0===t&&(t=""),void 0===r&&(r={}),a=void 0,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,L._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/text_feed/"+e+"/profile/"+(t?"?max_id="+t:""),r)];case 2:return a=u.sent().data,[3,4];case 3:return a=null==(i=u.sent().response)?void 0:i.data,[3,4];case 4:if((null==(n=a)?void 0:n.status)!=="ok")throw L.verbose&&console.log("[USER THREADS] Failed to fetch",a),new o.ThreadsAPIError("Failed to fetch user threads: "+JSON.stringify(a),a);return[2,a]}})}),this._getDefaultRepliesHeaders=function(e){return l({},v._getUnAuthenticatedHeaders(),{Host:"www.threads.net",Accept:"*/*","Accept-Language":v.locale,"cache-control":"no-cache",Origin:"https://www.threads.net",Pragma:"no-cache","Sec-Fetch-Site":"same-origin","X-Asbd-id":"129477","X-FB-Friendly-Name":"BarcelonaProfileProfileRepliesTabQuery","X-FB-Lsd":v.fbLSDToken,"X-Ig-App-Id":"238260118697367"},e?{Referer:"https://www.threads.net/@"+e+"/replies"}:void 0)},this._requestRepliesQuery=function(t,r,n){return Object.keys(r).forEach(function(e){return void 0===r[e]&&delete r[e]}),e.default.post(t,new URLSearchParams(r),l({httpAgent:v.httpAgent,httpsAgent:v.httpsAgent,headers:v._getDefaultRepliesHeaders()},n))};var T=this;this.getUserProfileReplies=c(function(){var e,t,r,n,s,a,o,i=arguments;return h(this,function(u){switch(u.label){case 0:for(t=Array(e=i.length),r=0;r<e;r++)t[r]=i[r];return a=(s=T._destructureFromUserIDQuerier(t)).userID,o=s.options,T.verbose&&console.debug("[fbLSDToken] USING",T.fbLSDToken),[4,T._requestRepliesQuery("https://www.threads.net/api/graphql",{lsd:T.fbLSDToken,variables:JSON.stringify({userID:a}),doc_id:"6684830921547925"},o)];case 1:return[2,(null==(n=u.sent().data.data.mediaData)?void 0:n.threads)||[]]}})});var R=this;this.getUserProfileRepliesLoggedIn=c(function(e,t,r){var n,a,i;return h(this,function(u){switch(u.label){case 0:if(void 0===t&&(t=""),void 0===r&&(r={}),R.token)return[3,2];return[4,R.getToken()];case 1:u.sent(),u.label=2;case 2:if(!R.token)throw Error("Token not found");a=void 0,u.label=3;case 3:return u.trys.push([3,5,,6]),[4,R._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/text_feed/"+e+"/profile/replies/"+(t?"?max_id="+t:""),r)];case 4:return a=u.sent().data,[3,6];case 5:return a=null==(i=u.sent().response)?void 0:i.data,[3,6];case 6:if((null==(n=a)?void 0:n.status)!=="ok")throw R.verbose&&console.log("[USER REPLIES] Failed to fetch",a),new o.ThreadsAPIError("Failed to fetch user replies: "+JSON.stringify(a),a);return[2,a]}})});var P=this;this.getUserFollowers=c(function(e,t,r){var n,a,i,u,c,d,p,f;return h(this,function(h){switch(h.label){case 0:a=(n=void 0===t?{}:t).maxID,i=n.query,c=void 0,d=new URLSearchParams(s.BASE_FOLLOW_PARAMS),a&&d.append("max_id",a),i&&d.append("query",i),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,P._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/friendships/"+e+"/followers/?"+d.toString(),l({},r,{headers:l({"X-Ig-Nav-Chain":s.FOLLOW_NAV_CHAIN},null==(p=r)?void 0:p.headers)}))];case 2:return c=h.sent().data,[3,4];case 3:return c=null==(f=h.sent().response)?void 0:f.data,[3,4];case 4:if((null==(u=c)?void 0:u.status)!=="ok")throw P.verbose&&console.log("[USER FOLLOWERS] Failed to fetch",c),new o.ThreadsAPIError("Failed to fetch user followers: "+JSON.stringify(c),c);return[2,c]}})});var k=this;this.getUserFollowings=c(function(e,t,r){var n,a,i,u,c,d,p,f;return h(this,function(h){switch(h.label){case 0:a=(n=void 0===t?{}:t).maxID,i=n.query,c=void 0,d=new URLSearchParams(s.BASE_FOLLOW_PARAMS),a&&d.append("max_id",a),i&&d.append("query",i),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,k._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/friendships/"+e+"/following/?"+d.toString(),l({},r,{headers:l({"X-Ig-Nav-Chain":s.FOLLOW_NAV_CHAIN},null==(p=r)?void 0:p.headers)}))];case 2:return c=h.sent().data,[3,4];case 3:return c=null==(f=h.sent().response)?void 0:f.data,[3,4];case 4:if((null==(u=c)?void 0:u.status)!=="ok")throw k.verbose&&console.log("[USER FOLLOWINGS] Failed to fetch",c),new o.ThreadsAPIError("Failed to fetch user followings: "+JSON.stringify(c),c);return[2,c]}})}),this.getPostIDfromThreadID=function(e){e=(e=(e=e.split("?")[0]).replace(/\s/g,"")).replace(/\//g,"");for(var t,r=0n,n=d(e);!(t=n()).done;){var s=t.value;r=64n*r+BigInt("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(s))}return r.toString()},this.getPostIDfromURL=function(e){var t,r,n=null==e?void 0:e.split("?")[0];return(null==(t=n)?void 0:t.endsWith("/"))&&(n=n.slice(0,-1)),n=(null==(r=n)?void 0:r.split("/").pop())||"",v.getPostIDfromThreadID(n||"")};var O=this;this.getThreads=c(function(e,t){return h(this,function(r){switch(r.label){case 0:return O.verbose&&console.debug("[fbLSDToken] USING",O.fbLSDToken),[4,O._requestUserDataQuery("https://www.threads.net/api/graphql",{lsd:O.fbLSDToken,variables:JSON.stringify({postID:e}),doc_id:"5587632691339264"},t)];case 1:return[2,r.sent().data.data.data]}})});var N=this;this.getThreadsLoggedIn=c(function(e,t,r){var n,a,i;return h(this,function(u){switch(u.label){case 0:void 0===t&&(t=""),void 0===r&&(r={}),a=void 0,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,N._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/text_feed/"+e+"/replies/"+(t?"?paging_token="+t:""),r)];case 2:return a=u.sent().data,[3,4];case 3:return a=null==(i=u.sent().response)?void 0:i.data,[3,4];case 4:if((null==(n=a)?void 0:n.status)!=="ok")throw N.verbose&&console.log("[USER FEED] Failed to fetch",a),new o.ThreadsAPIError("Failed to fetch user feed: "+JSON.stringify(a),a);return[2,a]}})});var x=this;this.getThreadLikers=c(function(e,t){return h(this,function(r){switch(r.label){case 0:return x.verbose&&console.debug("[fbLSDToken] USING",x.fbLSDToken),[4,x._requestUserDataQuery("https://www.threads.net/api/graphql",{lsd:x.fbLSDToken,variables:JSON.stringify({mediaID:e}),doc_id:"9360915773983802"},t)];case 1:return[2,r.sent().data.data.likers]}})});var F=this;this.getTimeline=c(function(e,t){var r;return h(this,function(n){switch(n.label){case 0:if(void 0===e&&(e=""),!F.token&&(!F.username||!F.password))throw Error("Username or password not set");return[4,F.getToken()];case 1:if(!n.sent())throw Error("Token not found");n.label=2;case 2:return n.trys.push([2,4,,5]),[4,F._requestQuery(""+s.BASE_API_URL+"/api/v1/feed/text_post_app_timeline/",{pagination_source:"text_post_feed_threads",max_id:e||void 0},l({},t,{headers:F._getAppHeaders()}))];case 3:return[2,n.sent().data];case 4:throw r=n.sent(),F.verbose&&console.log("[TIMELINE FETCH FAILED]",r.response.data),Error("Failed to fetch timeline");case 5:return[2]}})});var q=this;this._fetchAuthGetRequest=c(function(t,r){var n;return h(this,function(s){switch(s.label){case 0:return[4,q.getToken()];case 1:if(!s.sent())throw Error("Token not found");return[4,e.default.get(t,l({},r,{headers:l({},q._getInstaHeaders(),null==(n=r)?void 0:n.headers)}))];case 2:return[2,s.sent()]}})});var B=this;this._toggleAuthPostRequest=c(function(t,r,n){return h(this,function(s){switch(s.label){case 0:return[4,B.getToken()];case 1:if(!s.sent())throw Error("Token not found");return[4,e.default.post(t,r?new URLSearchParams(r):void 0,l({},n,{httpAgent:B.httpAgent,httpsAgent:B.httpsAgent,headers:B._getDefaultHeaders()}))];case 2:return[2,s.sent()]}})});var G=this;this.like=c(function(e,t){var r;return h(this,function(n){switch(n.label){case 0:return[4,G.getCurrentUserID()];case 1:return r=n.sent(),[4,G._toggleAuthPostRequest(s.BASE_API_URL+"/api/v1/media/"+e+"_"+r+"/like/",void 0,t)];case 2:return[2,n.sent().data]}})});var C=this;this.unlike=c(function(e,t){var r;return h(this,function(n){switch(n.label){case 0:return[4,C.getCurrentUserID()];case 1:return r=n.sent(),[4,C._toggleAuthPostRequest(s.BASE_API_URL+"/api/v1/media/"+e+"_"+r+"/unlike/",void 0,t)];case 2:return[2,n.sent().data]}})});var H=this;this.follow=c(function(e,t){var r;return h(this,function(n){switch(n.label){case 0:return[4,H._toggleAuthPostRequest(s.BASE_API_URL+"/api/v1/friendships/create/"+e+"/",void 0,t)];case 1:return r=n.sent(),H.verbose&&console.debug("[FOLLOW]",r.data),[2,r.data]}})});var M=this;this.unfollow=c(function(e,t){var r;return h(this,function(n){switch(n.label){case 0:return[4,M._toggleAuthPostRequest(s.BASE_API_URL+"/api/v1/friendships/destroy/"+e+"/",void 0,t)];case 1:return r=n.sent(),M.verbose&&console.debug("[UNFOLLOW]",r.data),[2,r.data]}})});var J=this;this.repost=c(function(e,t){var r;return h(this,function(n){switch(n.label){case 0:return[4,J._toggleAuthPostRequest(""+s.BASE_API_URL+"/api/v1/repost/create_repost/",{media_id:e},t)];case 1:return r=n.sent(),J.verbose&&console.debug("[REPOST]",r.data),[2,r.data]}})});var X=this;this.unrepost=c(function(e,t){var r;return h(this,function(n){switch(n.label){case 0:return[4,X._toggleAuthPostRequest(""+s.BASE_API_URL+"/api/v1/repost/delete_text_app_repost/",{original_media_id:e},t)];case 1:return r=n.sent(),X.verbose&&console.debug("[UNREPOST]",r.data),[2,r.data]}})});var W=this;this.mute=c(function(e,t){var r,n,a,o;return h(this,function(i){switch(i.label){case 0:return r=""+s.BASE_API_URL+"/api/v1/friendships/mute_posts_or_story_from_follow/",n={_uid:W.userID,_uuid:W.deviceID,container_module:"ig_text_feed_timeline"},e.postID&&(n.media_id=String(e.postID)),n.target_posts_author_id=String(e.userID),a={signed_body:"SIGNATURE."+encodeURIComponent(JSON.stringify(n))},[4,W._toggleAuthPostRequest(r,a,t)];case 1:return o=i.sent(),W.verbose&&console.debug("[MUTE]",o.data),[2,o.data]}})});var j=this;this.unmute=c(function(e,t){var r,n,a,o;return h(this,function(i){switch(i.label){case 0:return r=""+s.BASE_API_URL+"/api/v1/friendships/unmute_posts_or_story_from_follow/",n={_uid:j.userID,_uuid:j.deviceID,container_module:"ig_text_feed_timeline"},e.postID&&(n.media_id=String(e.postID)),n.target_posts_author_id=String(e.userID),a={signed_body:"SIGNATURE."+encodeURIComponent(JSON.stringify(n))},[4,j._toggleAuthPostRequest(r,a,t)];case 1:return o=i.sent(),j.verbose&&console.debug("[UNMUTE]",o.data),[2,o.data]}})});var Q=this;this.block=c(function(e,t){var r,n,a;return h(this,function(o){switch(o.label){case 0:return r=s.BASE_API_URL+"/api/v1/friendships/block/"+e+"/",n={signed_body:"SIGNATURE."+encodeURIComponent(JSON.stringify({surface:"ig_text_feed_timeline",is_auto_block_enabled:!0,user_id:e,_uid:Q.userID,_uuid:Q.deviceID}))},[4,Q._toggleAuthPostRequest(r,n,t)];case 1:return a=o.sent(),Q.verbose&&console.debug("[MUTE]",a.data),[2,a.data]}})});var z=this;this.unblock=c(function(e,t){var r,n,a;return h(this,function(o){switch(o.label){case 0:return r=s.BASE_API_URL+"/api/v1/friendships/unblock/"+e+"/",n={signed_body:"SIGNATURE."+encodeURIComponent(JSON.stringify({user_id:e,_uid:z.userID,_uuid:z.deviceID,container_module:"ig_text_feed_timeline"}))},[4,z._toggleAuthPostRequest(r,n,t)];case 1:return a=o.sent(),z.verbose&&console.debug("[MUTE]",a.data),[2,a.data]}})});var V=this;this.getNotifications=c(function(e,t,r){var n,a,i,u,c;return h(this,function(l){switch(l.label){case 0:void 0===r&&(r={}),a={feed_type:"all",mark_as_seen:!1,timezone_offset:-25200,timezone_name:"America%2FLos_Angeles"},e&&(a.selected_filters=e),t&&(a.max_id=t.maxID,a.pagination_first_record_timestamp=t.firstRecordTimestamp),i=Object.entries(a).map(function(e){return e[0]+"="+e[1]}).join("&"),u=void 0,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,V._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/text_feed/text_app_notifications/?"+i,r)];case 2:return u=l.sent().data,[3,4];case 3:return u=null==(c=l.sent().response)?void 0:c.data,[3,4];case 4:if((null==(n=u)?void 0:n.status)!=="ok")throw V.verbose&&console.log("[NOTIFICATIONS] Failed to fetch",u),new o.ThreadsAPIError("Failed to fetch notifications: "+JSON.stringify(u),u);return[2,u]}})});var K=this;this.setNotificationsSeen=c(function(e){var t,r,n;return h(this,function(a){switch(a.label){case 0:return t=""+s.BASE_API_URL+"/api/v1/text_feed/text_app_inbox_seen/",r={_uuid:""+K.userID},[4,K._toggleAuthPostRequest(t,r,e)];case 1:return n=a.sent(),K.verbose&&console.debug("[SET_NOTIFICATIONS_SEEN]",n.data),[2,n.data]}})});var Y=this;this.searchUsers=c(function(e,t,r){var n,a,i,u;return h(this,function(c){switch(c.label){case 0:void 0===t&&(t=30),void 0===r&&(r={}),a=Object.entries({q:e,count:t}).map(function(e){return e[0]+"="+e[1]}).join("&"),i=void 0,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,Y._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/users/search/?"+a,r)];case 2:return i=c.sent().data,[3,4];case 3:return i=null==(u=c.sent().response)?void 0:u.data,[3,4];case 4:if((null==(n=i)?void 0:n.status)!=="ok")throw Y.verbose&&console.log("[USER SEARCH] Failed to fetch",i),new o.ThreadsAPIError("Failed to fetch user search results: "+JSON.stringify(i),i);return[2,i]}})});var $=this;this.getRecommended=c(function(e,t){var r,n,a;return h(this,function(i){switch(i.label){case 0:void 0===e&&(e=""),void 0===t&&(t={}),n=void 0,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,$._fetchAuthGetRequest(s.BASE_API_URL+"/api/v1/text_feed/recommended_users/?"+(e?"?max_id="+e:""),t)];case 2:return n=i.sent().data,[3,4];case 3:return n=null==(a=i.sent().response)?void 0:a.data,[3,4];case 4:if((null==(r=n)?void 0:r.status)!=="ok")throw $.verbose&&console.log("[RECOMMENDED] Failed to fetch",n),new o.ThreadsAPIError("Failed to fetch recommended users: "+JSON.stringify(n),n);return[2,n]}})});var Z=this;this.getToken=c(function(){return h(this,function(e){switch(e.label){case 0:if(Z.token)return Z.verbose&&console.debug("[token] USING",Z.token),[2,Z.token];if(!Z.username||!Z.password)throw Error("Username and password are required");return[4,Z.login()];case 1:return e.sent(),[2,Z.token]}})}),this._lastUploadID=0,this._nextUploadID=function(){var e=Date.now(),t=v._lastUploadID;return(v._lastUploadID=e<t?t+1:e).toString()},this._createUploadMetadata=function(e){var t;return void 0===e&&(e=v._nextUploadID()),{upload_id:e,source_type:"4",timezone_offset:(null!=(t=v._timezoneOffset)?t:v._timezoneOffset=-(60*new Date().getTimezoneOffset())).toString(),device:v.device}};var ee=this;this.publish=c(function(t){var r,n,a,o,i,u,c,p,f,g,_,v;return h(this,function(h){switch(h.label){case 0:if(r="string"==typeof t?{text:t}:t,!ee.token&&(!ee.username||!ee.password))throw Error("Username or password not set");return[4,ee.getCurrentUserID()];case 1:if(!(n=h.sent()))throw Error("User ID not found");return[4,ee.getToken()];case 2:if(!h.sent())throw Error("Token not found");if(o=l({},ee._createUploadMetadata(),{text_post_app_info:{reply_control:s.REPLY_CONTROL_OPTIONS[null!=(a=r.replyControl)?a:"everyone"]},_uid:n,device_id:ee.deviceID,caption:r.text||""}),i=s.POST_URL,!(u=r.attachment)&&("image"in r&&r.image?u={image:r.image}:"url"in r&&r.url&&(u={url:r.url})),!u)return[3,9];if(!u.url)return[3,3];return o.text_post_app_info.link_attachment_url=u.url,[3,9];case 3:if(!u.image)return[3,5];return i=s.POST_WITH_IMAGE_URL,[4,ee.uploadImage(u.image,o.upload_id)];case 4:return h.sent(),o.scene_type=null,o.scene_capture_type="",[3,9];case 5:if(!u.sidecar)return[3,9];i=s.POST_WITH_SIDECAR_URL,o.client_sidecar_id=o.upload_id,o.children_metadata=[],c=d(u.sidecar),h.label=6;case 6:if((p=c()).done)return[3,9];return f=p.value,[4,ee.uploadImage(f)];case 7:g=h.sent().upload_id,o.children_metadata.push(l({},ee._createUploadMetadata(g),{scene_type:null,scene_capture_type:""})),h.label=8;case 8:return[3,6];case 9:return r.parentPostID&&(o.text_post_app_info.reply_id=r.parentPostID.replace(/_\d+$/,"")),r.quotedPostID&&(o.text_post_app_info.quoted_post_id=r.quotedPostID.replace(/_\d+$/,"")),i===s.POST_URL&&(o.publish_mode="text_post"),_="signed_body=SIGNATURE."+encodeURIComponent(JSON.stringify(o)),[4,e.default.post(i,_,{httpAgent:ee.httpAgent,httpsAgent:ee.httpsAgent,headers:ee._getAppHeaders(),timeout:6e4})];case 10:if(v=h.sent(),ee.verbose&&console.debug("[PUBLISH]",v.data),"ok"===v.data.status)return[2,v.data];return[2,void 0]}})});var et=this;this.delete=c(function(t,r){var n,a;return h(this,function(o){switch(o.label){case 0:return n=s.BASE_API_URL+"/api/v1/media/"+t+"/delete/",a="signed_body=SIGNATURE."+encodeURIComponent(JSON.stringify({media_id:t,_uid:et.userID,_uuid:et.deviceID})),[4,e.default.post(n,a,l({httpAgent:et.httpAgent,httpsAgent:et.httpsAgent,headers:et._getAppHeaders(),timeout:6e4},r))];case 1:if("ok"===o.sent().data.status)return[2,!0];return[2,!1]}})});var er=this;this.publishWithImage=c(function(e,t){return h(this,function(r){return[2,er.publish({text:e,image:t})]})});var en=this;if(this.uploadImage=c(function(t,s){var a,o,i,u,c,d,p,f,g,_,v;return h(this,function(h){switch(h.label){case 0:if(void 0===s&&(s=en._nextUploadID()),o="https://www.instagram.com/rupload_igphoto/"+(a=s+"_0_"+Math.floor(9e9*Math.random()+1e9)),!("string"==typeof t||"path"in t))return[3,6];if((c="string"==typeof t?t:t.path).startsWith("http"))return[3,3];return[4,Promise.resolve().then(function(){return require("fs")})];case 1:return[4,h.sent().promises.readFile(c)];case 2:return i=h.sent(),u=r.lookup(c)||"application/octet-stream",[3,5];case 3:return[4,e.default.get(c,{responseType:"arraybuffer"})];case 4:d=h.sent(),i=Buffer.from(d.data,"binary"),u=d.headers["content-type"],h.label=5;case 5:return[3,7];case 6:i=t.data,u=(t.type.includes("/")?t.type:r.lookup(t.type))||"application/octet-stream",h.label=7;case 7:p={upload_id:s,media_type:"1",sticker_burnin_params:JSON.stringify([]),image_compression:JSON.stringify({lib_name:"moz",lib_version:"3.1.m",quality:"80"}),xsharing_user_ids:JSON.stringify([]),retry_context:JSON.stringify({num_step_auto_retry:"0",num_reupload:"0",num_step_manual_retry:"0"}),"IG-FB-Xpost-entry-point-v2":"feed"},f=i.length,g=l({},en._getDefaultHeaders(),{"Content-Type":"application/octet-stream",X_FB_PHOTO_WATERFALL_ID:(0,n.v4)(),"X-Entity-Type":void 0!==u?"image/"+u:"image/jpeg",Offset:"0","X-Instagram-Rupload-Params":JSON.stringify(p),"X-Entity-Name":a,"X-Entity-Length":f.toString(),"Content-Length":f.toString(),"Accept-Encoding":"gzip"}),en.verbose&&console.log("[UPLOAD_IMAGE] Uploading "+f.toLocaleString()+"b as "+s+"..."),h.label=8;case 8:return h.trys.push([8,10,,11]),[4,e.default.post(o,i,{httpAgent:en.httpAgent,headers:g,timeout:6e4})];case 9:return _=h.sent().data,en.verbose&&console.log("[UPLOAD_IMAGE] SUCCESS",_),[2,_];case 10:throw v=h.sent(),en.verbose&&console.log("[UPLOAD_IMAGE] FAILED",v.response.data),Error("Upload image failed");case 11:return[2]}})}),(null==i?void 0:i.token)&&(this.token=i.token),(null==i?void 0:i.fbLSDToken)&&(this.fbLSDToken=i.fbLSDToken),this.noUpdateToken=!!(null==i?void 0:i.noUpdateToken),this.noUpdateLSD=!!(null==i?void 0:i.noUpdateLSD),this.verbose=(null==i?void 0:i.verbose)||!1,this.httpAgent=null==i?void 0:i.httpAgent,this.httpsAgent=null==i?void 0:i.httpsAgent,this.username=null!=(u=null==i?void 0:i.username)?u:process.env.THREADS_USERNAME,this.password=null!=(f=null==i?void 0:i.password)?f:process.env.THREADS_PASSWORD,this.deviceID=null!=(_=null!=(g=null==i?void 0:i.deviceID)?g:process.env.THREADS_DEVICE_ID)?_:"",this.deviceID||(this.deviceID="android-"+(1e24*Math.random()).toString(36),console.warn("โš ๏ธ WARNING: deviceID not provided, automatically generating device id '"+this.deviceID+"'","Please save this device id and use it for future uses to prevent login issues.","You can provide this device id by passing it to the constructor or setting the THREADS_DEVICE_ID environment variable (.env file)")),this.device=null==i?void 0:i.device,this.userID=null==i?void 0:i.userID,null==i?void 0:i.locale)this.locale=i.locale;else{var es=Intl.DateTimeFormat().resolvedOptions().locale;this.locale=es}this.maxRetries=(null==i?void 0:i.maxRetries)||this.maxRetries}return i.prototype.sign=function(e){var r="object"==typeof e?JSON.stringify(e):e;return{ig_sig_key_version:4,signed_body:t.createHmac("sha256",s.SIGNATURE_KEY).update(r).digest("hex")+"."+r}},i}(),g=f;

@@ -1,20 +0,149 @@

export interface ThreadsUser {
export interface ThreadsUser extends Partial<{
biography: string;
biography_with_entities: ThreadsBiographyWithEntities;
external_url: string;
primary_profile_link_type: number;
show_fb_link_on_profile: boolean;
show_fb_page_link_on_profile: boolean;
can_hide_category: boolean;
category?: any;
is_category_tappable: boolean;
is_business: boolean;
professional_conversion_suggested_account_type: number;
account_type: number;
displayed_action_button_partner?: any;
smb_delivery_partner?: any;
smb_support_delivery_partner?: any;
displayed_action_button_type?: any;
smb_support_partner?: any;
is_call_to_action_enabled?: any;
num_of_admined_pages?: any;
page_id?: any;
page_name?: any;
ads_page_id?: any;
ads_page_name?: any;
account_badges?: any[];
fbid_v2: string;
full_name: string;
follower_count: number;
following_count: number;
following_tag_count: number;
has_anonymous_profile_picture: boolean;
has_onboarded_to_text_post_app: boolean;
is_private: boolean;
is_verified: boolean;
media_count: number;
pk: number;
pk_id: string;
profile_pic_id: string;
text_post_app_joiner_number: number;
third_party_downloads_enabled: number;
username: string;
current_catalog_id?: any;
mini_shop_seller_onboarding_status?: any;
shopping_post_onboard_nux_type?: any;
ads_incentive_expiration_date?: any;
account_category: string;
auto_expand_chaining?: any;
bio_interests: ThreadsBioInterests;
bio_links: any[];
can_add_fb_group_link_on_profile: boolean;
can_use_affiliate_partnership_messaging_as_creator: boolean;
can_use_affiliate_partnership_messaging_as_brand: boolean;
can_use_branded_content_discovery_as_brand: boolean;
can_use_branded_content_discovery_as_creator: boolean;
creator_shopping_info: ThreadsCreatorShoppingInfo;
existing_user_age_collection_enabled: boolean;
fan_club_info: ThreadsFanClubInfo;
feed_post_reshare_disabled: boolean;
follow_friction_type: number;
has_chaining: boolean;
has_collab_collections: boolean;
has_exclusive_feed_content: boolean;
has_fan_club_subscriptions: boolean;
has_guides: boolean;
has_highlight_reels: boolean;
has_music_on_profile: boolean;
has_private_collections: boolean;
has_public_tab_threads: boolean;
has_videos: boolean;
hd_profile_pic_url_info: ThreadsHdProfilePicVersion;
hd_profile_pic_versions: ThreadsHdProfilePicVersion[];
highlight_reshare_disabled: boolean;
include_direct_blacklist_status: boolean;
is_bestie: boolean;
is_favorite: boolean;
is_favorite_for_stories: boolean;
is_favorite_for_igtv: boolean;
is_favorite_for_clips: boolean;
is_favorite_for_highlights: boolean;
is_in_canada: boolean;
is_interest_account: boolean;
is_memorialized: boolean;
is_new_to_instagram: boolean;
is_potential_business: boolean;
is_profile_broadcast_sharing_enabled: boolean;
is_regulated_c18: boolean;
is_supervision_features_enabled: boolean;
is_whatsapp_linked: boolean;
live_subscription_status: string;
mutual_followers_count: number;
nametag?: any;
open_external_url_with_in_app_browser: boolean;
pinned_channels_info: ThreadsPinnedChannelsInfo;
profile_context: string;
profile_context_facepile_users: any[];
profile_context_links_with_user_ids: any[];
profile_pic_url: string;
profile_type: number;
pronouns: any[];
remove_message_entrypoint: boolean;
robi_feedback_source?: any;
show_account_transparency_details: boolean;
show_ig_app_switcher_badge: boolean;
show_post_insights_entry_point: boolean;
show_text_post_app_badge: boolean;
show_text_post_app_switcher_badge: boolean;
total_ar_effects: number;
total_igtv_videos: number;
transparency_product_enabled: boolean;
usertags_count: number;
id: any;
}> {
pk: number;
username: string;
hd_profile_pic_versions: ThreadsHdProfilePicVersion[];
full_name: string;
is_verified: boolean;
biography: string;
biography_with_entities: any;
follower_count: number;
profile_context_facepile_users: any;
bio_links: ThreadsBioLink[];
pk: string;
full_name: string;
id: any;
is_private: boolean;
profile_pic_url: string;
}
export interface ThreadsBiographyWithEntities {
raw_text: string;
entities?: null[] | null;
}
export interface ThreadsBioInterests {
interests?: null[] | null;
}
export interface ThreadsCreatorShoppingInfo {
linked_merchant_accounts?: null[] | null;
}
export interface ThreadsFanClubInfo {
fan_club_id?: any;
fan_club_name?: any;
is_fan_club_referral_eligible?: any;
fan_consideration_page_revamp_eligiblity?: any;
is_fan_club_gifting_eligible?: any;
subscriber_count?: any;
connected_member_count?: any;
autosave_to_exclusive_highlight?: any;
has_enough_subscribers_for_ssc?: any;
}
export interface ThreadsPinnedChannelsInfo {
pinned_channels_list?: null[] | null;
has_public_channels: boolean;
}
export interface ThreadsHdProfilePicVersion {
height: number;
url: string;
width: number;
height: number;
}

@@ -26,5 +155,8 @@ export interface ThreadsBioLink {

thread_items: ThreadItem[];
thread_type?: string;
header?: any;
thread_type: string;
show_create_reply_cta: boolean;
id: string;
view_state_item_type?: number;
posts: Post[];
}

@@ -35,33 +167,40 @@ export interface ThreadItem {

view_replies_cta_string?: string;
should_show_replies_cta: boolean;
reply_facepile_users: ReplyFacepileUser[];
should_show_replies_cta: boolean;
reply_to_author?: any;
can_inline_expand_below: boolean;
__typename: string;
}
export interface QuotedPost {
text_post_app_info: TextPostAppInfo;
user: ThreadsUserSummary;
pk: string;
media_overlay_info: any;
code: string;
caption: Caption;
image_versions2: ImageVersions2;
original_width: number;
original_height: number;
video_versions: any[];
carousel_media: any;
carousel_media_count: any;
has_audio: any;
like_count: number;
taken_at: number;
id: string;
}
export interface TextPostAppInfo {
link_preview_attachment: any;
share_info: ShareInfo;
reply_to_author: any;
is_post_unavailable: boolean;
is_reply: boolean;
reply_to_author: boolean;
direct_reply_count: number;
self_thread: boolean;
reply_facepile_users: ReplyFacepileUser[];
link_preview_attachment: LinkPreviewAttachment;
can_reply: boolean;
reply_control: string;
hush_info: any;
share_info: ShareInfo;
}
export interface LinkPreviewAttachment {
url: string;
display_url: string;
title: string;
image_url: string;
}
export interface Post {
user: ThreadsUserSummary;
pk: string;
id: string;
text_post_app_info: TextPostAppInfo;
caption?: Caption | null;
taken_at: number;
device_timestamp: number;
media_type: number;
code: string;
client_cache_key: string;
filter_type: number;
product_type: string;
organic_tracking_token: string;
image_versions2: ImageVersions2;

@@ -71,20 +210,29 @@ original_width: number;

video_versions: any[];
carousel_media: any;
carousel_media_count: any;
pk: string;
has_audio: any;
text_post_app_info: TextPostAppInfo;
caption?: Caption;
taken_at: number;
like_count: number;
code: string;
timezone_offset: number;
has_liked: boolean;
like_and_view_counts_disabled: boolean;
can_viewer_reshare: boolean;
integrity_review_decision: string;
top_likers: any[];
user: ThreadsUser;
carousel_media_count?: any;
carousel_media?: any;
carousel_media_ids?: string[];
has_audio?: any;
media_overlay_info: any;
id: string;
}
export interface ThreadsUserSummary {
profile_pic_url: string;
username: string;
id: any;
is_verified: boolean;
pk: string;
export interface FriendshipStatus {
following: boolean;
followed_by: boolean;
blocking: boolean;
muting: boolean;
is_private: boolean;
incoming_request: boolean;
outgoing_request: boolean;
text_post_app_pre_following: boolean;
is_bestie: boolean;
is_restricted: boolean;
is_feed_favorite: boolean;
is_eligible_to_subscribe: boolean;
}

@@ -95,35 +243,41 @@ export interface ImageVersions2 {

export interface Candidate {
width: number;
height: number;
url: string;
width: number;
scans_profile: string;
__typename: string;
}
export interface ShareInfo {
quoted_post?: QuotedPost;
reposted_post?: RepostedPost;
can_repost: boolean;
is_reposted_by_viewer: boolean;
repost_restricted_reason?: any;
can_quote_post: boolean;
quoted_post?: Post | null;
reposted_post?: Post | null;
}
export interface RepostedPost {
pk: string;
user: ThreadsUserSummary;
image_versions2: ImageVersions2;
original_width: number;
original_height: number;
video_versions: VideoVersion[];
carousel_media: any;
carousel_media_count: any;
has_audio?: boolean;
text_post_app_info: TextPostAppInfo;
caption: Caption;
like_count: number;
taken_at: number;
code: string;
id: string;
}
export interface VideoVersion {
type: number;
width: number;
height: number;
url: string;
id: string;
__typename: string;
}
export interface Caption {
pk: string;
user_id: any;
text: string;
type: number;
created_at: number;
created_at_utc: number;
content_type: string;
status: string;
bit_flags: number;
did_report_as_spam: boolean;
share_enabled: boolean;
user: ThreadsUser;
is_covered: boolean;
is_ranked_comment: boolean;
media_id: any;
private_reply_status: number;
}

@@ -138,2 +292,37 @@ export interface ReplyFacepileUser {

}
export interface Story {
story_type: number;
type: number;
args: StoryArgs;
counts: any[];
pk: string;
}
export interface StoryArgs {
extra_actions?: string[] | null;
profile_id: number;
profile_name: string;
profile_image: string;
profile_image_destination: string;
destination: string;
rich_text: string;
extra: StoryExtra;
actions?: string[] | null;
inline_controls?: StoryInlineControls[] | null;
timestamp: number;
tuuid: string;
clicked: boolean;
af_candidate_id: number;
}
export interface StoryExtra {
title: string;
is_aggregated: boolean;
icon_name: string;
icon_color: string;
icon_url: string;
context: string;
content: string;
}
export interface StoryInlineControls {
action_type: string;
}
export interface AndroidDevice {

@@ -140,0 +329,0 @@ manufacturer: string;

{
"name": "threads-api",
"version": "1.5.4",
"version": "1.6.1",
"description": "Unofficial, Reverse-Engineered Node.js/TypeScript client for Meta's [Threads](https://threads.net).",

@@ -5,0 +5,0 @@ "author": "Junho Yeo <i@junho.io>",

@@ -74,2 +74,12 @@ # [<img src="https://github.com/junhoyeo/threads-api/raw/main/.github/logo.jpg" width="36" height="36" />](https://github.com/junhoyeo) Threads API

##### ๐Ÿ’ก Get User Profile (from v1.6.0)
- `getUserProfile` but with auth
```ts
const userID = '5438123050';
const { user } = await threadsAPI.getUserProfileLoggedIn();
console.log(JSON.stringify(user));
```
##### ๐Ÿ’ก Get Timeline

@@ -106,2 +116,54 @@

##### ๐Ÿ’ก Get Details(with Following Threads) for a specific Thread (from v1.6.0)
- `getThreads` but with auth (this will return more data)
```ts
let data = await threadsAPI.getThreadsLoggedIn(postID);
console.log(JSON.stringify(data.containing_thread));
console.log(JSON.stringify(data.reply_threads));
console.log(JSON.stringify(data.subling_threads));
if (data.downwards_thread_will_continue) {
const cursor = data.paging_tokens.downward;
data = await threadsAPI.getThreadsLoggedIn(postID, cursor);
}
```
##### ๐Ÿ”” Get Notifications (from v1.6.0)
```ts
let data = await threadsAPI.getNotifications(
ThreadsAPI.NotificationFilter.MENTIONS, // {MENTIONS, REPLIES, VERIFIED}
);
if (!data.is_last_page) {
const cursor = data.next_max_id;
data = await threadsAPI.getNotifications(ThreadsAPI.NotificationFilter.MENTIONS, cursor);
}
```
##### ๐Ÿ’Ž Get Recommended (from v1.6.0)
```ts
let data = await threadsAPI.getRecommended();
console.log(JSON.stringify(data.users)); // ThreadsUser[]
if (data.has_more) {
const cursor = data.paging_token;
data = await threadsAPI.getRecommended(cursor);
}
```
##### ๐Ÿ” Search Users (from v1.6.0)
```ts
const query = 'zuck';
const count = 40; // default value is set to 30
const data = await threadsAPI.searchUsers(query, count);
console.log(JSON.stringify(data.num_results));
console.log(JSON.stringify(data.users)); // ThreadsUser[]
```
### ๐Ÿš€ Usage (Write)

@@ -267,2 +329,37 @@

##### ๐Ÿ”‡ Mute/Unmute a User/Post (from v1.6.0)
```ts
const userID = await threadsAPI.getUserIDfromUsername('zuck');
const threadURL = 'https://www.threads.net/t/CugK35fh6u2';
const postID = threadsAPI.getPostIDfromURL(threadURL); // or use `getPostIDfromThreadID`
// ๐Ÿ’ก Uses current credentials
// Mute User
await threadsAPI.mute({ userID });
await threadsAPI.unfollow({ userID });
// Mute a Post of User
await threadsAPI.mute({ userID, postID });
await threadsAPI.unfollow({ userID, postID });
```
##### ๐Ÿ”‡ Block/Unblock a User (from v1.6.0)
```ts
const userID = await threadsAPI.getUserIDfromUsername('zuck');
// ๐Ÿ’ก Uses current credentials
await threadsAPI.block({ userID });
await threadsAPI.unblock({ userID });
```
##### ๐Ÿ”” Set Notifications Seen (from v1.6.0)
```ts
// ๐Ÿ’ก Uses current credentials
await threadsAPI.setNotificationsSeen();
```
<details>

@@ -269,0 +366,0 @@ <summary>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc