emusks 2.3.8 → 2.3.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emusks",
3
- "version": "2.3.8",
3
+ "version": "2.3.9",
4
4
  "description": "Reverse-engineered Twitter API client. Log in and interact with the unofficial X API using any client identity - web, Android, iOS, or TweetDeck",
5
5
  "keywords": [
6
6
  "client",
@@ -146,10 +146,10 @@ function extractUserId(cookies) {
146
146
  return null;
147
147
  }
148
148
 
149
- async function resolve(value, onRequest, type) {
149
+ async function resolve(value, onRequest, type, context) {
150
150
  if (value != null && value !== "") return value;
151
151
  if (onRequest) {
152
- const v = await onRequest(type);
152
+ const v = await onRequest(type, context);
153
153
  if (v != null && v !== "") return v;
154
154
  }
155
155
  throw new Error(
@@ -267,7 +267,8 @@ export default async function flowLoginJetfuel(opts) {
267
267
  if (passwordSwitch) {
268
268
  const knowledgeCheck = response.forms.find((form) => form.url === "/onboarding/web/actions/finish_knowledge_check");
269
269
  if (knowledgeCheck && onRequest) {
270
- const alternate = await onRequest("alternate_identifier");
270
+ const kc = knowledgeCheck.fields;
271
+ const alternate = await onRequest("alternate_identifier", { challengeType: kc.challenge_type ?? null, accountFound: kc.account_found ?? null, accountFoundType: kc.account_found_type ?? null });
271
272
  if (alternate != null && alternate !== "") {
272
273
  response = await post("finish_knowledge_check", { ...knowledgeCheck.fields, challenge_response: alternate });
273
274
  strings = response.strings;
@@ -300,7 +301,7 @@ export default async function flowLoginJetfuel(opts) {
300
301
  if (challenge === "email") alternate = email || (identifier.includes("@") ? identifier : null);
301
302
  if (challenge === "phone") alternate = phone;
302
303
  }
303
- fields[field] = await resolve(alternate, onRequest, type);
304
+ fields[field] = await resolve(alternate, onRequest, type, { challengeType: fields.challenge_type ?? null, accountFound: fields.account_found ?? null, accountFoundType: fields.account_found_type ?? null });
304
305
  }
305
306
  response = await post(action, fields);
306
307
  strings = response.strings;
@@ -52,7 +52,8 @@ export async function viewer() {
52
52
  fieldToggles: { withAuxiliaryUserLabels: false },
53
53
  });
54
54
  const user = res?.data?.viewer?.user_results?.result;
55
- return user ? parseUser(user) : res;
55
+ if (!user) throw new Error("couldn't get viewer, response: " + JSON.stringify(res));
56
+ return parseUser(user);
56
57
  }
57
58
 
58
59
  export async function sessions() {
@@ -241,7 +241,8 @@ export async function get(tweetId) {
241
241
  },
242
242
  });
243
243
  const tweet = res?.data?.tweetResult?.result;
244
- return tweet ? parseTweet(tweet) : res;
244
+ if (!tweet) throw new Error("couldn't get tweet, response: " + JSON.stringify(res));
245
+ return parseTweet(tweet);
245
246
  }
246
247
 
247
248
  export async function getMany(tweetIds) {
@@ -7,7 +7,8 @@ export async function get(userId) {
7
7
  fieldToggles: { withAuxiliaryUserLabels: false },
8
8
  });
9
9
  const user = res?.data?.user?.result;
10
- return user ? parseUser(user) : res;
10
+ if (!user) throw new Error("couldn't get user, response: " + JSON.stringify(res));
11
+ return parseUser(user);
11
12
  }
12
13
 
13
14
  export async function getByUsername(username) {
@@ -16,7 +17,8 @@ export async function getByUsername(username) {
16
17
  fieldToggles: { withAuxiliaryUserLabels: false },
17
18
  });
18
19
  const user = res?.data?.user?.result;
19
- return user ? parseUser(user) : res;
20
+ if (!user) throw new Error("couldn't get user, response: " + JSON.stringify(res));
21
+ return parseUser(user);
20
22
  }
21
23
 
22
24
  export async function getMany(userIds) {
@@ -64,6 +64,10 @@ export default function parseTweet(tweet) {
64
64
  ? parseTweet(get(tweet, "quoted_status_result.result"))
65
65
  : null,
66
66
 
67
+ retweeting: legacy.retweeted_status_result?.result
68
+ ? parseTweet(legacy.retweeted_status_result.result)
69
+ : null,
70
+
67
71
  edit_control: data.edit_control || {},
68
72
  card: data.card || null,
69
73
  unmention_data: data.unmention_data || {},