emusks 2.0.4 → 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/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");
@@ -78,6 +75,20 @@ export default class Emusks {
78
75
  if (typeof p.client === "string") p.client = clients[p.client];
79
76
  if (!p.client) throw new Error("invalid client!");
80
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
+ }
81
92
 
82
93
  p.client.headers = {
83
94
  "accept-language": "en-US,en;q=0.9",
@@ -128,6 +139,11 @@ export default class Emusks {
128
139
  }
129
140
  this.auth.client.headers.cookie = cookieParts.join("; ");
130
141
 
142
+ const document = await handleXMigration();
143
+ const transaction = new ClientTransaction(document);
144
+ await transaction.initialize();
145
+ this.auth.generateTransactionId = transaction.generateTransactionId.bind(transaction);
146
+
131
147
  const responseText = await res.text();
132
148
  const initialStateMatch = responseText.match(/window\.__INITIAL_STATE__\s*=\s*({.*?});/s);
133
149
 
@@ -148,14 +164,11 @@ export default class Emusks {
148
164
  this.user = parseUser(initialStateUser);
149
165
  this.settings = initialState?.settings?.remote?.settings;
150
166
 
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
167
  return this.user;
160
168
  }
161
- }
169
+ }
170
+
171
+ Emusks.prototype.graphql = graphql;
172
+ Emusks.prototype.v1_1 = v1_1;
173
+ Emusks.prototype.v2 = v2;
174
+ initHelpers(Emusks.prototype);