emusks 2.0.4 → 2.0.5
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 -13
- package/package.json +1 -1
- package/src/graphql.js +34 -12
- package/src/helpers/account.js +267 -269
- package/src/helpers/bookmarks.js +101 -103
- package/src/helpers/communities.js +236 -238
- package/src/helpers/dms.js +129 -131
- package/src/helpers/index.js +50 -31
- package/src/helpers/lists.js +222 -224
- package/src/helpers/media.js +137 -139
- package/src/helpers/notifications.js +42 -44
- package/src/helpers/search.js +117 -119
- package/src/helpers/spaces.js +47 -49
- package/src/helpers/syndication.js +23 -25
- package/src/helpers/timelines.js +76 -78
- package/src/helpers/topics.js +87 -89
- package/src/helpers/trends.js +74 -76
- package/src/helpers/tweets.js +302 -304
- package/src/helpers/users.js +287 -289
- package/src/index.js +23 -19
- package/src/static/graphql.js +1 -1
package/src/index.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { ClientTransaction, handleXMigration } from "x-client-transaction-id";
|
|
2
|
-
import parseUser from "./parsers/user.js";
|
|
3
|
-
import getCycleTLS from "./cycletls.js";
|
|
4
2
|
import clients from "./clients.js";
|
|
3
|
+
import getCycleTLS from "./cycletls.js";
|
|
4
|
+
import flowLogin from "./flow.js";
|
|
5
5
|
import graphql from "./graphql.js";
|
|
6
|
+
import initHelpers from "./helpers/index.js";
|
|
7
|
+
import parseUser from "./parsers/user.js";
|
|
6
8
|
import v1_1 from "./v1.1.js";
|
|
7
9
|
import v2 from "./v2.js";
|
|
8
|
-
import flowLogin from "./flow.js";
|
|
9
|
-
import initHelpers from "./helpers/index.js";
|
|
10
10
|
|
|
11
11
|
export default class Emusks {
|
|
12
12
|
auth = null;
|
|
13
13
|
elevatedCookies = null;
|
|
14
|
-
graphql = graphql;
|
|
15
|
-
v1_1 = v1_1;
|
|
16
|
-
v2 = v2;
|
|
17
14
|
|
|
18
15
|
async elevate(password) {
|
|
19
16
|
if (!this.auth) throw new Error("must be logged in before calling elevate");
|
|
@@ -54,8 +51,10 @@ export default class Emusks {
|
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
if (p.type === "password") {
|
|
57
|
-
if (!p.username)
|
|
58
|
-
|
|
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");
|
|
59
58
|
|
|
60
59
|
const flowResult = await flowLogin({
|
|
61
60
|
username: p.username,
|
|
@@ -128,8 +127,16 @@ export default class Emusks {
|
|
|
128
127
|
}
|
|
129
128
|
this.auth.client.headers.cookie = cookieParts.join("; ");
|
|
130
129
|
|
|
130
|
+
const document = await handleXMigration();
|
|
131
|
+
const transaction = new ClientTransaction(document);
|
|
132
|
+
await transaction.initialize();
|
|
133
|
+
this.auth.generateTransactionId =
|
|
134
|
+
transaction.generateTransactionId.bind(transaction);
|
|
135
|
+
|
|
131
136
|
const responseText = await res.text();
|
|
132
|
-
const initialStateMatch = responseText.match(
|
|
137
|
+
const initialStateMatch = responseText.match(
|
|
138
|
+
/window\.__INITIAL_STATE__\s*=\s*({.*?});/s,
|
|
139
|
+
);
|
|
133
140
|
|
|
134
141
|
if (!initialStateMatch) {
|
|
135
142
|
console.warn("[emusks] failed to extract initial state from response");
|
|
@@ -148,14 +155,11 @@ export default class Emusks {
|
|
|
148
155
|
this.user = parseUser(initialStateUser);
|
|
149
156
|
this.settings = initialState?.settings?.remote?.settings;
|
|
150
157
|
|
|
151
|
-
const document = await handleXMigration();
|
|
152
|
-
const transaction = new ClientTransaction(document);
|
|
153
|
-
await transaction.initialize();
|
|
154
|
-
this.auth.generateTransactionId = transaction.generateTransactionId.bind(transaction);
|
|
155
|
-
|
|
156
|
-
const helpers = initHelpers(this);
|
|
157
|
-
Object.assign(this, helpers);
|
|
158
|
-
|
|
159
158
|
return this.user;
|
|
160
159
|
}
|
|
161
|
-
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
Emusks.prototype.graphql = graphql;
|
|
163
|
+
Emusks.prototype.v1_1 = v1_1;
|
|
164
|
+
Emusks.prototype.v2 = v2;
|
|
165
|
+
initHelpers(Emusks.prototype);
|