mail-code-fetcher
v1.0.0
Published
Fetch email accounts from vendor API and retrieve OTP/security code via polling.
Maintainers
Readme
mail-code-fetcher
Fetch email accounts from vendor API and retrieve OTP/security code via polling.
Install
npm i mail-code-fetcher
# or local path during development
npm i ./packages/mail-code-fetcherUsage (Library)
const { fetchAccounts, fetchCode } = require('mail-code-fetcher');
(async () => {
// 1) Get accounts from vendor
const accounts = await fetchAccounts({
apikey: process.env.ACCOUNT_API_KEY,
// optional overrides
// account_api: 'https://api.dongvanfb.net/user/buy',
// account_type: 1,
// quality: 1,
// type: 'full',
});
if (!accounts.length) return console.log('No accounts');
// 2) Fetch OTP code for one account
const code = await fetchCode(accounts[0], {
timeoutMs: 120000, // optional
delayMs: 8000, // optional
// endpoint: 'https://tools.dongvanfb.net/api/get_messages_oauth2',
});
console.log({ email: accounts[0].email, code });
})();CLI
# Show help
npx mail-code-fetcher help
# Fetch accounts
npx mail-code-fetcher fetch-accounts --apikey YOUR_API_KEY
# Fetch code for a single account
npx mail-code-fetcher fetch-code \
--email [email protected] \
--refresh REFRESH_TOKEN \
--client CLIENT_ID \
--timeout 120000 \
--delay 8000API
fetchAccounts({ apikey, account_api?, account_type?, quality?, type?, timeoutMs? })- Returns:
Array<{ email, password, refreshToken, clientId }>
- Returns:
fetchCode({ email, refreshToken, clientId }, { timeoutMs?, delayMs?, endpoint? })- Returns:
string | null
- Returns:
Notes
- This package is a light wrapper. It does not store anything, just fetches/parses data.
- Keep your API keys in environment variables.
