emusks 2.2.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/graphql.js +1 -0
- package/src/helpers/account.js +5 -0
- package/src/helpers/delegates.js +30 -0
- package/src/helpers/drafts.js +38 -0
- package/src/helpers/immersive.js +19 -0
- package/src/helpers/index.js +8 -0
- package/src/helpers/notes.js +211 -0
- package/src/helpers/timelines.js +6 -0
- package/src/helpers/tweets.js +20 -0
- package/src/index.js +6 -0
- package/src/v1.1.js +5 -2
- package/src/v2.js +1 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<img src="https://emusks.tiago.zip/icon.svg" width="120">
|
|
2
2
|
<h1>emusks: Reverse-engineered Twitter API client</h1>
|
|
3
3
|
|
|
4
|
-
Log in and interact with the unofficial X API using any client identity - web, Android, iOS, or TweetDeck. Covers tweets, users, DMs, communities, spaces, articles, Grok (X's built-in AI), and XChat (X's end-to-end encrypted chat): send encrypted DMs in one call.
|
|
4
|
+
Log in and interact with the unofficial X API using any client identity - web, Android, iOS, or TweetDeck. Covers tweets, drafts, users, DMs, communities, spaces, articles, Community Notes, the immersive video feed, delegate/act-as, Grok (X's built-in AI), and XChat (X's end-to-end encrypted chat): send encrypted DMs in one call.
|
|
5
5
|
|
|
6
6
|
officially dmca'd by twitter™ 🏆 • includes a few leaked ads bearers
|
|
7
7
|
|
package/package.json
CHANGED
package/src/graphql.js
CHANGED
|
@@ -107,6 +107,7 @@ export default async function graphql(queryName, { variables, fieldToggles, body
|
|
|
107
107
|
"sec-gpc": "1",
|
|
108
108
|
cookie:
|
|
109
109
|
this.auth.client.headers.cookie + (this.elevatedCookies ? `; ${this.elevatedCookies}` : ""),
|
|
110
|
+
...(this.actingAs ? { "x-act-as-user-id": this.actingAs } : {}),
|
|
110
111
|
...headers,
|
|
111
112
|
};
|
|
112
113
|
|
package/src/helpers/account.js
CHANGED
|
@@ -267,3 +267,8 @@ export async function disableAccountLabel() {
|
|
|
267
267
|
body: { variables: {} },
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
|
+
|
|
271
|
+
export async function supportedLanguages() {
|
|
272
|
+
const res = await this.graphql("SupportedLanguages", { variables: {} });
|
|
273
|
+
return res?.data?.supported_languages?.supported_languages ?? res?.data ?? res;
|
|
274
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const CONTRIBUTEES = ["get", "https://api.x.com/1.1/users/contributees.json"];
|
|
2
|
+
const CONTRIBUTORS = ["get", "https://api.x.com/1.1/users/contributors.json"];
|
|
3
|
+
|
|
4
|
+
export async function contributees(opts = {}) {
|
|
5
|
+
const params = { ...opts.params };
|
|
6
|
+
if (opts.userId) params.user_id = opts.userId;
|
|
7
|
+
if (opts.screenName) params.screen_name = opts.screenName;
|
|
8
|
+
const res = await this.v1_1(CONTRIBUTEES, { params });
|
|
9
|
+
return await res.json();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function contributors(opts = {}) {
|
|
13
|
+
const params = { ...opts.params };
|
|
14
|
+
if (opts.userId) params.user_id = opts.userId;
|
|
15
|
+
if (opts.screenName) params.screen_name = opts.screenName;
|
|
16
|
+
const res = await this.v1_1(CONTRIBUTORS, { params });
|
|
17
|
+
return await res.json();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function actAs(userId) {
|
|
21
|
+
return this.setActingAs(userId);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function stop() {
|
|
25
|
+
return this.setActingAs(null);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function current() {
|
|
29
|
+
return this.actingAs;
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function buildPostTweetRequest(text, opts = {}) {
|
|
2
|
+
return {
|
|
3
|
+
status: text ?? "",
|
|
4
|
+
...(opts.mediaIds ? { media_ids: opts.mediaIds } : {}),
|
|
5
|
+
...(opts.replyTo ? { in_reply_to_status_id: opts.replyTo } : {}),
|
|
6
|
+
auto_populate_reply_metadata: true,
|
|
7
|
+
...opts.postTweetRequest,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function list(opts = {}) {
|
|
12
|
+
const res = await this.graphql("FetchDraftTweets", {
|
|
13
|
+
variables: { ascending: opts.ascending ?? false, ...opts.variables },
|
|
14
|
+
});
|
|
15
|
+
return res?.data?.viewer?.draft_list?.response_data ?? res;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function create(text, opts = {}) {
|
|
19
|
+
return await this.graphql("CreateDraftTweet", {
|
|
20
|
+
body: { variables: { post_tweet_request: buildPostTweetRequest(text, opts) } },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function edit(draftId, text, opts = {}) {
|
|
25
|
+
if (!draftId) throw new Error("edit requires a draftId");
|
|
26
|
+
return await this.graphql("EditDraftTweet", {
|
|
27
|
+
body: {
|
|
28
|
+
variables: { draft_tweet_id: draftId, post_tweet_request: buildPostTweetRequest(text, opts) },
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function remove(draftId) {
|
|
34
|
+
if (!draftId) throw new Error("remove requires a draftId");
|
|
35
|
+
return await this.graphql("DeleteDraftTweet", {
|
|
36
|
+
body: { variables: { draft_tweet_id: draftId } },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export async function media(pinnedTweetId, opts = {}) {
|
|
2
|
+
if (!pinnedTweetId) throw new Error("media requires a pinnedTweetId");
|
|
3
|
+
const res = await this.graphql("ImmersiveMedia", {
|
|
4
|
+
variables: {
|
|
5
|
+
pinned_tweet_id: pinnedTweetId,
|
|
6
|
+
page_name: opts.pageName ?? "immersive_video",
|
|
7
|
+
...opts.variables,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
return res?.data?.immersiveMedia ?? res;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function profile(pinnedTweetId, opts = {}) {
|
|
14
|
+
if (!pinnedTweetId) throw new Error("profile requires a pinnedTweetId");
|
|
15
|
+
const res = await this.graphql("ImmersiveProfile", {
|
|
16
|
+
variables: { pinned_tweet_id: pinnedTweetId, ...opts.variables },
|
|
17
|
+
});
|
|
18
|
+
return res?.data?.immersiveProfile ?? res;
|
|
19
|
+
}
|
package/src/helpers/index.js
CHANGED
|
@@ -2,11 +2,15 @@ import * as account from "./account.js";
|
|
|
2
2
|
import * as articles from "./articles.js";
|
|
3
3
|
import * as bookmarks from "./bookmarks.js";
|
|
4
4
|
import * as communities from "./communities.js";
|
|
5
|
+
import * as delegates from "./delegates.js";
|
|
5
6
|
import * as dms from "./dms.js";
|
|
7
|
+
import * as drafts from "./drafts.js";
|
|
6
8
|
import * as grok from "./grok.js";
|
|
9
|
+
import * as immersive from "./immersive.js";
|
|
7
10
|
import * as jetfuel from "./jetfuel.js";
|
|
8
11
|
import * as lists from "./lists.js";
|
|
9
12
|
import * as media from "./media.js";
|
|
13
|
+
import * as notes from "./notes.js";
|
|
10
14
|
import * as notifications from "./notifications.js";
|
|
11
15
|
import * as search from "./search.js";
|
|
12
16
|
import * as spaces from "./spaces.js";
|
|
@@ -56,4 +60,8 @@ export default function initHelpers(proto) {
|
|
|
56
60
|
namespace(proto, "jetfuel", jetfuel);
|
|
57
61
|
namespace(proto, "grok", grok);
|
|
58
62
|
namespace(proto, "articles", articles);
|
|
63
|
+
namespace(proto, "notes", notes);
|
|
64
|
+
namespace(proto, "delegates", delegates);
|
|
65
|
+
namespace(proto, "drafts", drafts);
|
|
66
|
+
namespace(proto, "immersive", immersive);
|
|
59
67
|
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
function data(res) {
|
|
2
|
+
return res?.data ?? res;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export async function forTweet(tweetId) {
|
|
6
|
+
if (!tweetId) throw new Error("forTweet requires a tweetId");
|
|
7
|
+
return data(await this.graphql("BirdwatchFetchNotes", { variables: { tweet_id: tweetId } }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function get(noteId) {
|
|
11
|
+
if (!noteId) throw new Error("get requires a noteId");
|
|
12
|
+
const res = await this.graphql("BirdwatchFetchOneNote", { variables: { note_id: noteId } });
|
|
13
|
+
return res?.data?.birdwatch_note_by_rest_id ?? res;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function translation(noteId, opts = {}) {
|
|
17
|
+
if (!noteId) throw new Error("translation requires a noteId");
|
|
18
|
+
return data(
|
|
19
|
+
await this.graphql("BirdwatchFetchNoteTranslation", {
|
|
20
|
+
variables: { note_id: noteId, ...opts.variables },
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function myProfile() {
|
|
26
|
+
const res = await this.graphql("BirdwatchFetchAuthenticatedUserProfile", { variables: {} });
|
|
27
|
+
return res?.data?.authenticated_user_birdwatch_profile ?? res;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function profile(alias) {
|
|
31
|
+
if (!alias) throw new Error("profile requires an alias");
|
|
32
|
+
const res = await this.graphql("BirdwatchFetchBirdwatchProfile", { variables: { alias } });
|
|
33
|
+
return res?.data?.birdwatch_profile_by_alias ?? res;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function contributorNotes(alias, opts = {}) {
|
|
37
|
+
if (!alias) throw new Error("contributorNotes requires an alias");
|
|
38
|
+
return data(
|
|
39
|
+
await this.graphql("BirdwatchFetchContributorNotesSlice", {
|
|
40
|
+
variables: { alias, cursor: opts.cursor, ...opts.variables },
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function globalTimeline(opts = {}) {
|
|
46
|
+
return data(
|
|
47
|
+
await this.graphql("BirdwatchFetchGlobalTimeline", {
|
|
48
|
+
variables: { cursor: opts.cursor, ...opts.variables },
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function batSignal(tweetId) {
|
|
54
|
+
if (!tweetId) throw new Error("batSignal requires a tweetId");
|
|
55
|
+
return data(await this.graphql("BirdwatchFetchBatSignal", { variables: { tweet_id: tweetId } }));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function canBeMediaNote(tweetId) {
|
|
59
|
+
if (!tweetId) throw new Error("canBeMediaNote requires a tweetId");
|
|
60
|
+
return data(
|
|
61
|
+
await this.graphql("BirdwatchFetchCanTweetBeMediaNote", { variables: { tweetId } }),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function clusterData(tweetId) {
|
|
66
|
+
if (!tweetId) throw new Error("clusterData requires a tweetId");
|
|
67
|
+
return data(await this.graphql("BirdwatchFetchClusterData", { variables: { tweetId } }));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function mediaMatches(tweetId, opts = {}) {
|
|
71
|
+
if (!tweetId) throw new Error("mediaMatches requires a tweetId");
|
|
72
|
+
return data(
|
|
73
|
+
await this.graphql("BirdwatchFetchMediaMatchSlice", {
|
|
74
|
+
variables: { tweet_id: tweetId, cursor: opts.cursor, ...opts.variables },
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function prominentMediaMatches(tweetId, opts = {}) {
|
|
80
|
+
if (!tweetId) throw new Error("prominentMediaMatches requires a tweetId");
|
|
81
|
+
return data(
|
|
82
|
+
await this.graphql("BirdwatchFetchProminentMediaMatchSlice", {
|
|
83
|
+
variables: { tweet_id: tweetId, cursor: opts.cursor, ...opts.variables },
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function sourceLinks(tweetId, opts = {}) {
|
|
89
|
+
if (!tweetId) throw new Error("sourceLinks requires a tweetId");
|
|
90
|
+
return data(
|
|
91
|
+
await this.graphql("BirdwatchFetchSourceLinkSlice", {
|
|
92
|
+
variables: { tweet_id: tweetId, cursor: opts.cursor, ...opts.variables },
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function sourceLinkTweet(tweetId) {
|
|
98
|
+
if (!tweetId) throw new Error("sourceLinkTweet requires a tweetId");
|
|
99
|
+
return data(await this.graphql("BirdwatchFetchSourceLinkTweet", { variables: { tweetId } }));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function authenticatedMatch(noteId) {
|
|
103
|
+
if (!noteId) throw new Error("authenticatedMatch requires a noteId");
|
|
104
|
+
return data(
|
|
105
|
+
await this.graphql("BirdwatchFetchAuthenticatedBirdwatchMatchSlice", {
|
|
106
|
+
variables: { note_id: noteId },
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export async function aliasOptions() {
|
|
112
|
+
return data(await this.graphql("BirdwatchFetchAliasSelfSelectOptions", { variables: {} }));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function aliasStatus() {
|
|
116
|
+
const res = await this.graphql("BirdwatchFetchAliasSelfSelectStatus", { variables: {} });
|
|
117
|
+
return res?.data?.authenticated_user_birdwatch_alias_self_select_status ?? res;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function publicData() {
|
|
121
|
+
const res = await this.graphql("BirdwatchFetchPublicData", { variables: {} });
|
|
122
|
+
return res?.data?.birdwatch_latest_public_data_file_bundle ?? res;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function signUpEligibility() {
|
|
126
|
+
const res = await this.graphql("BirdwatchFetchSignUpEligiblity", { variables: {} });
|
|
127
|
+
return res?.data?.birdwatch_sign_up_eligibility ?? res;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export async function suggestionFeedback(suggestionId) {
|
|
131
|
+
if (!suggestionId) throw new Error("suggestionFeedback requires a suggestionId");
|
|
132
|
+
return data(
|
|
133
|
+
await this.graphql("BirdwatchFetchSuggestionFeedbackOverview", {
|
|
134
|
+
variables: { suggestionId },
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export async function create(tweetId, dataV1, opts = {}) {
|
|
140
|
+
if (!tweetId) throw new Error("create requires a tweetId");
|
|
141
|
+
if (!dataV1) throw new Error("create requires a data_v1 note payload");
|
|
142
|
+
return await this.graphql("BirdwatchCreateNote", {
|
|
143
|
+
body: { variables: { tweet_id: tweetId, data_v1: dataV1, ...opts.variables } },
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export async function remove(noteId) {
|
|
148
|
+
if (!noteId) throw new Error("remove requires a noteId");
|
|
149
|
+
return await this.graphql("BirdwatchDeleteNote", { body: { variables: { note_id: noteId } } });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export async function rate(noteId, rating = {}) {
|
|
153
|
+
if (!noteId) throw new Error("rate requires a noteId");
|
|
154
|
+
return await this.graphql("BirdwatchCreateRating", {
|
|
155
|
+
body: { variables: { note_id: noteId, ...rating } },
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export async function deleteRating(noteId) {
|
|
160
|
+
if (!noteId) throw new Error("deleteRating requires a noteId");
|
|
161
|
+
return await this.graphql("BirdwatchDeleteRating", {
|
|
162
|
+
body: { variables: { note_id: noteId } },
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export async function appeal(noteId, opts = {}) {
|
|
167
|
+
if (!noteId) throw new Error("appeal requires a noteId");
|
|
168
|
+
return await this.graphql("BirdwatchCreateAppeal", {
|
|
169
|
+
body: { variables: { note_id: noteId, ...opts.variables } },
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export async function request(tweetId) {
|
|
174
|
+
if (!tweetId) throw new Error("request requires a tweetId");
|
|
175
|
+
return await this.graphql("BirdwatchCreateBatSignal", {
|
|
176
|
+
body: { variables: { tweet_id: tweetId } },
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export async function deleteRequest(tweetId) {
|
|
181
|
+
if (!tweetId) throw new Error("deleteRequest requires a tweetId");
|
|
182
|
+
return await this.graphql("BirdwatchDeleteBatSignal", {
|
|
183
|
+
body: { variables: { tweet_id: tweetId } },
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export async function selectAlias(opts = {}) {
|
|
188
|
+
return await this.graphql("BirdwatchAliasSelect", { body: { variables: { ...opts.variables } } });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export async function editNotificationSettings(params = {}) {
|
|
192
|
+
return await this.graphql("BirdwatchEditNotificationSettings", {
|
|
193
|
+
body: { variables: { ...params } },
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export async function editUserSettings(params = {}) {
|
|
198
|
+
return await this.graphql("BirdwatchEditUserSettings", { body: { variables: { ...params } } });
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export async function acknowledgeEarnOut() {
|
|
202
|
+
return await this.graphql("BirdwatchProfileAcknowledgeEarnOut", { body: { variables: {} } });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export async function admitUser(opts = {}) {
|
|
206
|
+
return await this.graphql("BirdwatchAdmitUser", { body: { variables: { ...opts.variables } } });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export async function removeUser(opts = {}) {
|
|
210
|
+
return await this.graphql("BirdwatchRemoveUser", { body: { variables: { ...opts.variables } } });
|
|
211
|
+
}
|
package/src/helpers/timelines.js
CHANGED
|
@@ -80,3 +80,9 @@ export async function creatorSubscriptions(opts = {}) {
|
|
|
80
80
|
});
|
|
81
81
|
return parseTimeline(raw);
|
|
82
82
|
}
|
|
83
|
+
|
|
84
|
+
export async function updatePinned(pinnedTimelineItems) {
|
|
85
|
+
return await this.graphql("UpdatePinnedTimelines", {
|
|
86
|
+
body: { variables: { pinnedTimelineItems } },
|
|
87
|
+
});
|
|
88
|
+
}
|
package/src/helpers/tweets.js
CHANGED
|
@@ -409,3 +409,23 @@ export async function similar(tweetId) {
|
|
|
409
409
|
variables: { tweet_id: tweetId },
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
|
+
|
|
413
|
+
export async function downvote(tweetId) {
|
|
414
|
+
return await this.graphql("DownvoteTweet", { body: { variables: { tweet_id: tweetId } } });
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export async function undoDownvote(tweetId) {
|
|
418
|
+
return await this.graphql("UndoDownvoteTweet", { body: { variables: { tweet_id: tweetId } } });
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export async function addContentDisclosure(tweetId, opts = {}) {
|
|
422
|
+
return await this.graphql("AddContentDisclosure", {
|
|
423
|
+
body: { variables: { tweet_id: tweetId, ...opts.variables } },
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export async function removeContentDisclosure(tweetId, opts = {}) {
|
|
428
|
+
return await this.graphql("DeleteContentDisclosure", {
|
|
429
|
+
body: { variables: { tweet_id: tweetId, ...opts.variables } },
|
|
430
|
+
});
|
|
431
|
+
}
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,12 @@ export default class Emusks {
|
|
|
15
15
|
elevatedCookies = null;
|
|
16
16
|
graphqlEndpoint = "web";
|
|
17
17
|
transactionIds = undefined;
|
|
18
|
+
actingAs = null;
|
|
19
|
+
|
|
20
|
+
setActingAs(userId) {
|
|
21
|
+
this.actingAs = userId || null;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
18
24
|
|
|
19
25
|
async elevate(password) {
|
|
20
26
|
if (!this.auth) throw new Error("must be logged in before calling elevate");
|
package/src/v1.1.js
CHANGED
|
@@ -2,7 +2,7 @@ import getCycleTLS from "./cycletls.js";
|
|
|
2
2
|
import v1_1Api from "./static/v1.1.js";
|
|
3
3
|
|
|
4
4
|
export default async function v1_1(queryName, { params, body, headers } = {}) {
|
|
5
|
-
|
|
5
|
+
const entry = Array.isArray(queryName) ? queryName : v1_1Api[queryName];
|
|
6
6
|
if (!entry) {
|
|
7
7
|
throw new Error(`v1.1 endpoint ${queryName} not found`);
|
|
8
8
|
}
|
|
@@ -62,6 +62,7 @@ export default async function v1_1(queryName, { params, body, headers } = {}) {
|
|
|
62
62
|
"sec-gpc": "1",
|
|
63
63
|
cookie:
|
|
64
64
|
this.auth.client.headers.cookie + (this.elevatedCookies ? `; ${this.elevatedCookies}` : ""),
|
|
65
|
+
...(this.actingAs ? { "x-act-as-user-id": this.actingAs } : {}),
|
|
65
66
|
...headers,
|
|
66
67
|
};
|
|
67
68
|
|
|
@@ -95,7 +96,9 @@ export default async function v1_1(queryName, { params, body, headers } = {}) {
|
|
|
95
96
|
const messages = bodyJson.errors
|
|
96
97
|
.map((e) => e.message || (e.code != null ? `code ${e.code}` : "unknown"))
|
|
97
98
|
.join("; ");
|
|
98
|
-
throw new Error(
|
|
99
|
+
throw new Error(
|
|
100
|
+
`twitter v1.1 ${Array.isArray(queryName) ? entry[1] : queryName} ${res.status}: ${messages}`,
|
|
101
|
+
);
|
|
99
102
|
}
|
|
100
103
|
return {
|
|
101
104
|
status: res.status,
|
package/src/v2.js
CHANGED
|
@@ -43,6 +43,7 @@ export default async function v2(queryName, { params, body, headers } = {}) {
|
|
|
43
43
|
"sec-gpc": "1",
|
|
44
44
|
cookie:
|
|
45
45
|
this.auth.client.headers.cookie + (this.elevatedCookies ? `; ${this.elevatedCookies}` : ""),
|
|
46
|
+
...(this.actingAs ? { "x-act-as-user-id": this.actingAs } : {}),
|
|
46
47
|
...headers,
|
|
47
48
|
};
|
|
48
49
|
|