emusks 2.0.5 → 2.0.6

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/build/graphql.js CHANGED
@@ -8,9 +8,12 @@ const transformed = Object.fromEntries(
8
8
  const features = data.features
9
9
  ? Object.fromEntries(Object.keys(data.features).map((k) => [k, true]))
10
10
  : undefined;
11
- const queryId = data.url.match(/\/graphql\/([^\/]+)\//)?.[1];
11
+ const queryId = data.url.match(/\/graphql\/([^/]+)\//)?.[1];
12
12
  return [name, [data.method, data.url, features, queryId]];
13
13
  }),
14
14
  );
15
15
 
16
- await Bun.write(`./src/static/graphql.js`, `export default ${JSON.stringify(transformed)};`);
16
+ await Bun.write(
17
+ `./src/static/graphql.js`,
18
+ `export default ${JSON.stringify(transformed)};`,
19
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emusks",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
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",
package/src/graphql.js CHANGED
@@ -83,7 +83,7 @@ export default async function graphql(queryName, { variables, fieldToggles, body
83
83
  method,
84
84
  )
85
85
  ).json();
86
-
86
+
87
87
  if (res?.errors?.[0]) {
88
88
  throw new Error(res.errors.map((err) => err.message).join(", "));
89
89
  }
package/src/index.js CHANGED
@@ -51,10 +51,8 @@ export default class Emusks {
51
51
  }
52
52
 
53
53
  if (p.type === "password") {
54
- if (!p.username)
55
- throw new Error("username is required for password login");
56
- if (!p.password)
57
- throw new Error("password is required for password login");
54
+ if (!p.username) throw new Error("username is required for password login");
55
+ if (!p.password) throw new Error("password is required for password login");
58
56
 
59
57
  const flowResult = await flowLogin({
60
58
  username: p.username,
@@ -77,6 +75,20 @@ export default class Emusks {
77
75
  if (typeof p.client === "string") p.client = clients[p.client];
78
76
  if (!p.client) throw new Error("invalid client!");
79
77
  if (p.proxy) this.proxy = p.proxy;
78
+
79
+ if (!p.client.bearer) {
80
+ throw new Error("client is missing bearer token!");
81
+ }
82
+ if (!p.client.userAgent || !p.client.fingerprints) {
83
+ p.client.userAgent =
84
+ p.client.userAgent ||
85
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36";
86
+
87
+ p.client.fingerprints = p.client.fingerprints || {
88
+ ja3: "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,35-5-27-16-0-10-13-23-45-65037-17613-18-65281-51-43-11,4588-29-23-24,0",
89
+ ja4r: "t13d1516h2_002f,0035,009c,009d,1301,1302,1303,c013,c014,c02b,c02c,c02f,c030,cca8,cca9_0005,000a,000b,000d,0012,0017,001b,0023,002b,002d,0033,44cd,fe0d,ff01_0403,0804,0401,0503,0805,0501,0806,0601",
90
+ };
91
+ }
80
92
 
81
93
  p.client.headers = {
82
94
  "accept-language": "en-US,en;q=0.9",
@@ -130,13 +142,10 @@ export default class Emusks {
130
142
  const document = await handleXMigration();
131
143
  const transaction = new ClientTransaction(document);
132
144
  await transaction.initialize();
133
- this.auth.generateTransactionId =
134
- transaction.generateTransactionId.bind(transaction);
145
+ this.auth.generateTransactionId = transaction.generateTransactionId.bind(transaction);
135
146
 
136
147
  const responseText = await res.text();
137
- const initialStateMatch = responseText.match(
138
- /window\.__INITIAL_STATE__\s*=\s*({.*?});/s,
139
- );
148
+ const initialStateMatch = responseText.match(/window\.__INITIAL_STATE__\s*=\s*({.*?});/s);
140
149
 
141
150
  if (!initialStateMatch) {
142
151
  console.warn("[emusks] failed to extract initial state from response");
@@ -162,4 +171,4 @@ export default class Emusks {
162
171
  Emusks.prototype.graphql = graphql;
163
172
  Emusks.prototype.v1_1 = v1_1;
164
173
  Emusks.prototype.v2 = v2;
165
- initHelpers(Emusks.prototype);
174
+ initHelpers(Emusks.prototype);