Files
gpt/account-manager/node/inbox_runner.mjs
T
432539 fef45134d5 Initial commit: GPT 账号注册机 (open source)
只开源「GPT 账号注册机 / 管理」(account-manager):账号列表/导入导出、检测/批量检测、
拿 RT、协议/浏览器注册等注册机能力。批量直开 / 协议支付 / 提取链接 / 直卡直开 等其它功能
不含实现代码,仅通过 iframe 内嵌外链访问。真实机密均由 .gitignore 忽略,仅提供脱敏示例配置。
2026-08-05 14:54:32 +08:00

37 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 查收 wrapper —— 由 Flask /api/plus/inbox 通过 `node inbox_runner.mjs` 调用。
// 输入:stdin 一段 JSON { email, clientId, refreshToken, limit? }
// 输出:stdout 一段 JSON
// 成功 { ok:true, address, via, messages:[...] }
// 失败 { ok:false, status, error }
// 复用 auto 项目原封不动的 plus-mailbox.jsfetchPlusInbox)。
import { fetchPlusInbox } from './plus-mailbox.js';
// 复用的脚本会用 console.log 打印诊断信息(如 plus-mailbox 的“令牌换取成功”),
// 这些默认写 stdout 会污染我们的 JSON 结果。统一改写到 stderr,保证 stdout 只有结果 JSON。
const _errWrite = (...a) => { try { process.stderr.write(a.map(String).join(' ') + '\n'); } catch { /* ignore */ } };
console.log = _errWrite;
console.info = _errWrite;
console.warn = _errWrite;
function readStdin() {
return new Promise((resolve) => {
let buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', (c) => { buf += c; });
process.stdin.on('end', () => resolve(buf));
});
}
(async () => {
try {
const raw = await readStdin();
const input = JSON.parse(raw || '{}');
const { email, clientId, refreshToken } = input;
const limit = Number(input.limit) || 15;
const r = await fetchPlusInbox({ email, clientId, refreshToken }, limit);
process.stdout.write(JSON.stringify({ ok: true, address: r.address, via: r.via, messages: r.messages || [] }));
} catch (e) {
process.stdout.write(JSON.stringify({ ok: false, status: e && e.status ? e.status : 502, error: (e && e.message) || String(e) }));
}
})();