emusks 2.3.4 → 2.3.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/package.json +1 -1
- package/src/castle.js +261 -0
- package/src/flow-jetfuel.js +288 -0
- package/src/flow.js +2 -2
- package/src/helpers/index.js +2 -0
- package/src/helpers/report.js +100 -0
- package/src/helpers/tweets.js +4 -0
- package/src/helpers/users.js +4 -0
- package/src/index.js +7 -1
- package/src/scripts/castle-mint-test.js +8 -0
- package/src/scripts/login-test.js +28 -0
- package/src/scripts/verify-session.js +11 -0
- package/src/static/graphql.js +1 -1
- package/src/static/v1.1.js +1 -1
- package/src/vendor/castle-sdk.min.js +3 -0
package/src/helpers/tweets.js
CHANGED
|
@@ -353,6 +353,10 @@ export async function unmoderate(tweetId) {
|
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
+
export async function report(tweetId, reason, opts = {}) {
|
|
357
|
+
return await this.report.tweet(tweetId, reason, opts);
|
|
358
|
+
}
|
|
359
|
+
|
|
356
360
|
export async function pinReply(tweetId) {
|
|
357
361
|
return await this.graphql("PinReply", {
|
|
358
362
|
body: { variables: { tweet_id: tweetId } },
|
package/src/helpers/users.js
CHANGED
|
@@ -220,6 +220,10 @@ export async function unmute(userId) {
|
|
|
220
220
|
return json ? parseUser(json) : res;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
export async function report(userId, reason, opts = {}) {
|
|
224
|
+
return await this.report.user(userId, reason, opts);
|
|
225
|
+
}
|
|
226
|
+
|
|
223
227
|
export async function removeFollower(userId) {
|
|
224
228
|
return await this.graphql("RemoveFollower", {
|
|
225
229
|
body: { variables: { target_user_id: userId } },
|
package/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { ClientTransaction, handleXMigration } from "x-client-transaction-id";
|
|
|
2
2
|
import clients from "./clients.js";
|
|
3
3
|
import getCycleTLS from "./cycletls.js";
|
|
4
4
|
import flowLogin from "./flow.js";
|
|
5
|
+
import flowLoginJetfuel from "./flow-jetfuel.js";
|
|
5
6
|
import graphql, { GRAPHQL_ENDPOINTS } from "./graphql.js";
|
|
6
7
|
import grokApi from "./grok.js";
|
|
7
8
|
import initHelpers from "./helpers/index.js";
|
|
@@ -64,13 +65,16 @@ export default class Emusks {
|
|
|
64
65
|
if (!p.username) throw new Error("username is required for password login");
|
|
65
66
|
if (!p.password) throw new Error("password is required for password login");
|
|
66
67
|
|
|
67
|
-
const
|
|
68
|
+
const runFlow = p.flow === "classic" ? flowLogin : flowLoginJetfuel;
|
|
69
|
+
const flowResult = await runFlow({
|
|
68
70
|
username: p.username,
|
|
69
71
|
password: p.password,
|
|
70
72
|
email: p.email,
|
|
71
73
|
phone: p.phone,
|
|
72
74
|
onRequest: p.onRequest,
|
|
75
|
+
getCastleToken: p.getCastleToken,
|
|
73
76
|
proxy: p.proxy,
|
|
77
|
+
debug: p.debug,
|
|
74
78
|
});
|
|
75
79
|
|
|
76
80
|
p = {
|
|
@@ -204,3 +208,5 @@ Emusks.prototype.v2 = v2;
|
|
|
204
208
|
Emusks.prototype.jf = jetfuel;
|
|
205
209
|
Emusks.prototype.grokApi = grokApi;
|
|
206
210
|
initHelpers(Emusks.prototype);
|
|
211
|
+
|
|
212
|
+
export { REPORT_REASONS } from "./helpers/report.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mintCastleToken } from "../castle.js";
|
|
2
|
+
|
|
3
|
+
const t0 = Date.now();
|
|
4
|
+
const token = await mintCastleToken();
|
|
5
|
+
console.error(`[castle] minted in ${Date.now() - t0}ms`);
|
|
6
|
+
console.error(`[castle] len=${token.length} format=${/^[A-Za-z0-9]+\|/.test(token) ? "ok (<id>|<payload>)" : "unexpected"}`);
|
|
7
|
+
console.error(`[castle] head=${token.slice(0, 24)}`);
|
|
8
|
+
process.exit(0);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import flowLoginJetfuel from "../flow-jetfuel.js";
|
|
3
|
+
|
|
4
|
+
const CODE_FILE = "/tmp/x-code.txt";
|
|
5
|
+
const pollCode = async (type) => {
|
|
6
|
+
console.error(`[test] NEED ${type} -> write it to ${CODE_FILE}`);
|
|
7
|
+
for (let i = 0; i < 90; i++) {
|
|
8
|
+
if (existsSync(CODE_FILE)) { const c = readFileSync(CODE_FILE, "utf8").trim(); unlinkSync(CODE_FILE); if (c) { console.error(`[test] got ${type}`); return c; } }
|
|
9
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`${type} not provided within timeout`);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const r = await flowLoginJetfuel({
|
|
16
|
+
username: process.env.TEST_USER,
|
|
17
|
+
password: process.env.TEST_PW,
|
|
18
|
+
proxy: process.env.PROXY,
|
|
19
|
+
timeout: 30,
|
|
20
|
+
debug: true,
|
|
21
|
+
onRequest: pollCode,
|
|
22
|
+
});
|
|
23
|
+
console.error("[test] LOGIN OK userId=", r.userId, "auth_token?", Boolean(r.authToken), "ct0?", Boolean(r.csrfToken));
|
|
24
|
+
if (process.env.SESSION_OUT) { writeFileSync(process.env.SESSION_OUT, JSON.stringify(r, null, 2), { mode: 0o600 }); console.error("[test] session ->", process.env.SESSION_OUT); }
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error("[test] FAILED:", e.message);
|
|
27
|
+
}
|
|
28
|
+
process.exit(0);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import Emusks from "../index.js";
|
|
3
|
+
|
|
4
|
+
const s = JSON.parse(readFileSync(process.env.SESSION_IN || "/tmp/emusks-session.json", "utf8"));
|
|
5
|
+
const client = new Emusks();
|
|
6
|
+
await client.login({ auth_token: s.authToken || s.auth_token, endpoint: "web", transactionIds: true });
|
|
7
|
+
|
|
8
|
+
const res = await client.v1_1("get:account/settings", {});
|
|
9
|
+
const body = await res.json();
|
|
10
|
+
console.error("[verify] status", res.status, "| @" + body.screen_name, "| country", body.country_code);
|
|
11
|
+
process.exit(0);
|