mail-code-fetcher 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.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # mail-code-fetcher
2
+
3
+ Fetch email accounts from vendor API and retrieve OTP/security code via polling.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i mail-code-fetcher
9
+ # or local path during development
10
+ npm i ./packages/mail-code-fetcher
11
+ ```
12
+
13
+ ## Usage (Library)
14
+
15
+ ```js
16
+ const { fetchAccounts, fetchCode } = require('mail-code-fetcher');
17
+
18
+ (async () => {
19
+ // 1) Get accounts from vendor
20
+ const accounts = await fetchAccounts({
21
+ apikey: process.env.ACCOUNT_API_KEY,
22
+ // optional overrides
23
+ // account_api: 'https://api.dongvanfb.net/user/buy',
24
+ // account_type: 1,
25
+ // quality: 1,
26
+ // type: 'full',
27
+ });
28
+
29
+ if (!accounts.length) return console.log('No accounts');
30
+
31
+ // 2) Fetch OTP code for one account
32
+ const code = await fetchCode(accounts[0], {
33
+ timeoutMs: 120000, // optional
34
+ delayMs: 8000, // optional
35
+ // endpoint: 'https://tools.dongvanfb.net/api/get_messages_oauth2',
36
+ });
37
+
38
+ console.log({ email: accounts[0].email, code });
39
+ })();
40
+ ```
41
+
42
+ ## CLI
43
+
44
+ ```bash
45
+ # Show help
46
+ npx mail-code-fetcher help
47
+
48
+ # Fetch accounts
49
+ npx mail-code-fetcher fetch-accounts --apikey YOUR_API_KEY
50
+
51
+ # Fetch code for a single account
52
+ npx mail-code-fetcher fetch-code \
53
+ --email user@example.com \
54
+ --refresh REFRESH_TOKEN \
55
+ --client CLIENT_ID \
56
+ --timeout 120000 \
57
+ --delay 8000
58
+ ```
59
+
60
+ ## API
61
+
62
+ - `fetchAccounts({ apikey, account_api?, account_type?, quality?, type?, timeoutMs? })`
63
+ - Returns: `Array<{ email, password, refreshToken, clientId }>`
64
+ - `fetchCode({ email, refreshToken, clientId }, { timeoutMs?, delayMs?, endpoint? })`
65
+ - Returns: `string | null`
66
+
67
+ ## Notes
68
+ - This package is a light wrapper. It does not store anything, just fetches/parses data.
69
+ - Keep your API keys in environment variables.