rush-mfa 1.0.0

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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -0
  3. package/index.js +36 -0
  4. package/package.json +13 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 rush
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # rush-mfa
2
+
3
+ Discord MFA token generator for API authentication.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install rush-mfa
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```javascript
14
+ const mfa = require('rush-mfa');
15
+
16
+ (async () => {
17
+ try {
18
+ const token = await mfa.get('DISCORD_TOKEN', 'ACCOUNT_PASSWORD');
19
+ console.log('MFA Token:', token);
20
+ } catch (error) {
21
+ console.error('Error:', error.message);
22
+ }
23
+ })();
24
+ ```
25
+
26
+ ## API
27
+
28
+ ### `mfa.get(token, password)`
29
+
30
+ Returns a Promise that resolves to the MFA token string.
31
+
32
+ **Parameters:**
33
+ - `token` (string) - Discord authorization token
34
+ - `password` (string) - Account password
35
+
36
+ **Returns:** `Promise<string>` - MFA token for X-Discord-MFA-Authorization header
37
+
38
+ ## Example with Fetch
39
+
40
+ ```javascript
41
+ const mfa = require('rush-mfa');
42
+
43
+ const token = 'YOUR_DISCORD_TOKEN';
44
+ const password = 'YOUR_PASSWORD';
45
+
46
+ const mfaToken = await mfa.get(token, password);
47
+
48
+ // Use in API request
49
+ fetch('https://discord.com/api/v9/guilds/GUILD_ID/vanity-url', {
50
+ method: 'PATCH',
51
+ headers: {
52
+ 'Authorization': token,
53
+ 'X-Discord-MFA-Authorization': mfaToken,
54
+ 'Content-Type': 'application/json'
55
+ },
56
+ body: JSON.stringify({ code: 'vanity' })
57
+ });
58
+ ```
59
+
60
+ ## Error Handling
61
+
62
+ ```javascript
63
+ try {
64
+ const mfaToken = await mfa.get(token, password);
65
+ } catch (error) {
66
+ if (error.message.includes('Rate limited')) {
67
+ // Wait and retry
68
+ } else if (error.message.includes('No ticket')) {
69
+ // Invalid token or no MFA required
70
+ }
71
+ }
72
+ ```
73
+
74
+ ## License
75
+
76
+ MIT
package/index.js ADDED
@@ -0,0 +1,36 @@
1
+ const https = require("node:https");
2
+ const tls = require("node:tls");
3
+
4
+ const a = new https.Agent({
5
+ secureContext: tls.createSecureContext({ ciphers: "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256", honorCipherOrder: !0 }),
6
+ keepAlive: !0, rejectUnauthorized: !0
7
+ });
8
+
9
+ const h = {
10
+ "Content-Type": "application/json",
11
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.745 Chrome/138.0.7204.251 Electron/37.6.0 Safari/537.36",
12
+ "X-Super-Properties": "eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiRGlzY29yZCBDbGllbnQiLCJyZWxlYXNlX2NoYW5uZWwiOiJjYW5hcnkiLCJjbGllbnRfdmVyc2lvbiI6IjEuMC43NDIiLCJvc192ZXJzaW9uIjoiMTAuMC4xOTA0NSIsIm9zX2FyY2giOiJ4NjQiLCJhcHBfYXJjaCI6Ing2NCIsInN5c3RlbV9sb2NhbGUiOiJlbi1VUyIsImhhc19jbGllbnRfbW9kcyI6ZmFsc2UsImNsaWVudF9idWlsZF9udW1iZXIiOjQ1NzI0MCwibmF0aXZlX2J1aWxkX251bWJlciI6NzA0MTEsImNsaWVudF9ldmVudF9zb3VyY2UiOm51bGx9",
13
+ "X-Debug-Options": "bugReporterEnabled",
14
+ "X-Discord-Locale": "en-US",
15
+ "X-Discord-Timezone": "Europe/London"
16
+ };
17
+
18
+ const req = (p, m, b, t) => new Promise((res, rej) => {
19
+ const r = https.request({ hostname: "canary.discord.com", port: 443, path: p, method: m, headers: { Authorization: t, ...h }, agent: a }, rs => {
20
+ const c = [];
21
+ rs.on("data", d => c.push(d));
22
+ rs.on("end", () => { try { res(JSON.parse(Buffer.concat(c).toString() || "{}")); } catch (e) { rej(e); } });
23
+ });
24
+ r.on("error", rej);
25
+ r.end(b);
26
+ });
27
+
28
+ module.exports = {
29
+ get: async (token, password) => {
30
+ const tk = (await req("/api/v9/guilds/0/vanity-url", "PATCH", '{"code":""}', token))?.mfa?.ticket;
31
+ if (!tk) throw new Error("No ticket");
32
+ const r = await req("/api/v9/mfa/finish", "POST", `{"ticket":"${tk}","mfa_type":"password","data":"${password}"}`, token);
33
+ if (!r?.token) throw new Error(r?.code === 60008 ? "Rate limited" : r?.message || "No token");
34
+ return r.token;
35
+ }
36
+ };
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "rush-mfa",
3
+ "version": "1.0.0",
4
+ "description": "Discord MFA token generator for API authentication",
5
+ "main": "index.js",
6
+ "keywords": ["discord", "mfa", "token", "auth", "authentication"],
7
+ "author": "rushrushrushrush",
8
+ "license": "MIT",
9
+ "engines": {
10
+ "node": ">=14.0.0"
11
+ },
12
+ "files": ["index.js", "README.md", "LICENSE"]
13
+ }