emusks 2.0.5 → 2.0.7
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 +5 -2
- package/package.json +1 -1
- package/src/graphql.js +3 -2
- package/src/helpers/media.js +2 -2
- package/src/helpers/tweets.js +2 -2
- package/src/index.js +19 -10
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\/([
|
|
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(
|
|
16
|
+
await Bun.write(
|
|
17
|
+
`./src/static/graphql.js`,
|
|
18
|
+
`export default ${JSON.stringify(transformed)};`,
|
|
19
|
+
);
|
package/package.json
CHANGED
package/src/graphql.js
CHANGED
|
@@ -82,8 +82,9 @@ export default async function graphql(queryName, { variables, fieldToggles, body
|
|
|
82
82
|
},
|
|
83
83
|
method,
|
|
84
84
|
)
|
|
85
|
-
).
|
|
86
|
-
|
|
85
|
+
).text();
|
|
86
|
+
console.log(res);
|
|
87
|
+
|
|
87
88
|
if (res?.errors?.[0]) {
|
|
88
89
|
throw new Error(res.errors.map((err) => err.message).join(", "));
|
|
89
90
|
}
|
package/src/helpers/media.js
CHANGED
|
@@ -96,9 +96,9 @@ async function makeUploadRequest(
|
|
|
96
96
|
"x-twitter-auth-type": "OAuth2Session",
|
|
97
97
|
"x-twitter-client-language": "en",
|
|
98
98
|
priority: "u=1, i",
|
|
99
|
-
"sec-ch-ua": '
|
|
99
|
+
"sec-ch-ua": 'Not(A:Brand;v=8, Chromium;v=144',
|
|
100
100
|
"sec-ch-ua-mobile": "?0",
|
|
101
|
-
"sec-ch-ua-platform": '
|
|
101
|
+
"sec-ch-ua-platform": 'macOS',
|
|
102
102
|
"sec-fetch-dest": "empty",
|
|
103
103
|
"sec-fetch-mode": "cors",
|
|
104
104
|
"sec-fetch-site": "same-site",
|
package/src/helpers/tweets.js
CHANGED
|
@@ -65,9 +65,9 @@ async function createPollCard(instance, poll) {
|
|
|
65
65
|
"x-twitter-auth-type": "OAuth2Session",
|
|
66
66
|
"x-twitter-client-language": "en",
|
|
67
67
|
priority: "u=1, i",
|
|
68
|
-
"sec-ch-ua": '
|
|
68
|
+
"sec-ch-ua": 'Not(A:Brand;v=8, Chromium;v=144',
|
|
69
69
|
"sec-ch-ua-mobile": "?0",
|
|
70
|
-
"sec-ch-ua-platform": '
|
|
70
|
+
"sec-ch-ua-platform": 'macOS',
|
|
71
71
|
"sec-fetch-dest": "empty",
|
|
72
72
|
"sec-fetch-mode": "cors",
|
|
73
73
|
"sec-fetch-site": "same-site",
|
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
|
-
|
|
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,
|
|
@@ -78,6 +76,20 @@ export default class Emusks {
|
|
|
78
76
|
if (!p.client) throw new Error("invalid client!");
|
|
79
77
|
if (p.proxy) this.proxy = p.proxy;
|
|
80
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
|
+
}
|
|
92
|
+
|
|
81
93
|
p.client.headers = {
|
|
82
94
|
"accept-language": "en-US,en;q=0.9",
|
|
83
95
|
priority: "u=1, i",
|
|
@@ -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);
|