diff --git a/chatbot.js b/chatbot.js index 5a08603..328e697 100644 --- a/chatbot.js +++ b/chatbot.js @@ -216,7 +216,7 @@ const CANNED = [ a: 'PIF is a gift you send from your own wallet, and the site never touches the money. That is different from other platforms, where the site takes money out of your account balance and buys the position for the other person: InstantAdPay has no balances, so the POL goes straight from your wallet to theirs, and they buy their package themselves, from their own wallet. It only appears on your own free referrals and on members you have adopted, and only once they have linked a wallet, so you cannot PIF somebody who is still sitting in the holding tank. The order is: adopt them from Members > My line > Holding tank, get them to link a wallet on their Wallet tab, then the PIF button shows up, you enter an amount and your own wallet app opens with their address already filled in. Now the part that matters most: do not send anything until you have actually talked to that person and they have told you they will use it. Once that POL leaves your wallet it is gone, there is no refund, no chargeback and nothing we can do to pull it back, because the money goes straight from your wallet to theirs and never touches us. The gift is theirs to keep whatever they do with it, so they can go quiet, spend it on something else, or never sign in again, and none of that is against any rule. Someone in the holding tank joined with nobody working with them and may never have engaged at all, which makes an unanswered PIF the easiest money on this site to lose. Get a reply, get a clear commitment that they are going to buy and build, see that they have linked a wallet and are actually active, and only then decide. If they do buy a $20 package the contract pays you 50 percent as their sponsor and they become one of your qualifying buyers, so a gift that works costs you about half; a gift to somebody who never answers costs you all of it. Never gift money you need, never borrow to do it, and treat every PIF as money you are content to lose.' }, { id: 'sponsor-video-invite', title: 'An email saying my sponsor made me a video', q: ['I got an email that my sponsor made me a video, is it real?', 'What is Video App Income?', 'How do I stop invite emails from my sponsor?'], tags: ['video app income', 'sponsor invite', 'invite email', 'made you a video'], re: /(made (me|you) a video|video app income|videoappincome|invite(d)? (email|from my sponsor)|email from my sponsor)/i, - a: 'That email is real if it names your sponsor. Video App Income is another site in the network that makes short promo videos from a phone. A sponsor there can send each of their own direct referrals one invite, once, and it is delivered by InstantAdPay so it comes from an address you already know. It shows a video your sponsor made and says plainly that they earn a share if you buy credits there. Your first video there is free, nothing is promised, and you do not have to join. Your email address was not given to your sponsor or to Video App Income: InstantAdPay sent the note on their behalf. Each person gets this invite one time only. To stop all InstantAdPay emails except sign-in codes and receipts, use the Stop these emails link at the bottom of the message.' }, + a: 'That email is real if it names your sponsor. Video App Income is another site in the network that makes short promo videos from a phone. A sponsor there can send each of their own direct referrals one invite, once, and it is delivered by InstantAdPay so it comes from an address you already know. It shows a video your sponsor made and says plainly that they earn a share if you buy credits there. Your first video there is free, nothing is promised, and you do not have to join. Your email address was not given to your sponsor or to Video App Income: InstantAdPay sent the note on their behalf. Each person gets this invite one time only. To stop all InstantAdPay emails except sign-in codes and receipts, use the Stop these emails link at the bottom of the message. Separately: if you asked Video App Income to confirm your email, the 6-digit code arrives in an email that says it was sent by InstantAdPay, because InstantAdPay is the mail service for the network. That is expected. Type the code into Video App Income within 15 minutes; if you did not ask for it, ignore it.' }, { id: 'who-invited', title: 'Who invited you? (naming your sponsor)', q: ['How do I add the person who invited me?', 'I joined without a link, can I name my sponsor?', 'What is the Who invited you card?'], tags: ['who invited you', 'invited', 'holding tank', 'no sponsor', 'sponsor link'], re: /(who invited|invited (me|by)|joined without a (link|sponsor)|forgot (the|my|to use).{0,12}(link|sponsor)|(add|name|set|enter|pick|choose) (my |a )?sponsor|nobody invited)/i, a: 'If you joined without a sponsor link, your Overview shows a Who invited you? card. Type the username of the person who invited you, confirm it, and they become your sponsor, here and on LinkSpin, and they get a notice. Do it before you switch on payouts or buy, because your sponsor locks on the contract at that point. It has to be a real member: not you, not someone in your own line, and not someone who has not switched on payouts with nobody above them who has (ask them to switch on first). Once you have a sponsor or a member number the card goes away. Nobody invited you? Tap Nobody invited me and stay in the holding tank; a small link on the Overview brings the card back while you are still there. Nothing on the site waits for your answer. New sign-ups cannot be adopted by hand for their first 24 hours, so you have a day to tell us before a member can pick you up.' }, diff --git a/mailer.js b/mailer.js index f0b0f09..5297a5a 100644 --- a/mailer.js +++ b/mailer.js @@ -51,7 +51,7 @@ async function send(to, subject, text, html, opts) { // html optional (2026-10-0 if (html) content.push({ type: 'text/html', value: html }); const msg = { personalizations: [{ to: [{ email: to }] }], - from: FROM, + from: opts && opts.fromName ? { email: FROM.email, name: String(opts.fromName).slice(0, 60) } : FROM, // same authenticated address; another network site's name on mail sent for it (siteinvite.js code mail, 2026-11-21) subject, content }; diff --git a/qa/site-invite.test.mjs b/qa/site-invite.test.mjs index 2d29cf4..36430e5 100644 --- a/qa/site-invite.test.mjs +++ b/qa/site-invite.test.mjs @@ -112,5 +112,19 @@ const send = (items, x) => SI.handle('send', Object.assign({ rid: 'rid-' + Math. ok(r.results[0].status === 'sent before' && sent.length === n, 'after a restart the once-ever rule still holds'); const v = await SI.adminView(); ok(v.on && v.recent.length > 20 && !/@/.test(JSON.stringify(v)), 'the admin view lists invites by username only'); } +// ---- the email-check code mail (a site's network gate) ---- +{ + const n = sent.length; let r = await SI.handle('code', { site: 'videoappincome', email: 'New.Person@Mail.test', code: '482913' }); + const m = sent[sent.length - 1]; + ok(r.ok && sent.length === n + 1 && m[0] === 'new.person@mail.test' && m[1] === '482913 is your Video App Income code' && m[2].startsWith('Your code is: 482913') && !/https?:/.test(m[2]), 'the code mail goes out with the code, the site name and no links', m && m.slice(0, 3)); + ok(m[4] && m[4].transactional === true && m[4].fromName === 'Video App Income', 'it is sent as a requested (transactional) mail under the site name'); + ok((await SI.handle('code', { site: 'videoappincome', email: 'not an email', code: '111111' })).code === 'email', 'a bad address is refused'); + ok((await SI.handle('code', { site: 'videoappincome', email: 'a@mail.test', code: '12ab' })).code === 'email', 'a code that is not six digits is refused'); + ok((await SI.handle('code', { site: 'videoappincome', email: 'x@mailinator.com', code: '111111' })).code === 'email', 'a throwaway address is refused'); + ok((await SI.handle('code', { site: 'videoappincome', email: 'flagged@mail.test', code: '111111' })).code === 'email', 'a suspended or flagged address is refused'); + ok((await SI.handle('code', { site: 'nosuchsite', email: 'a@mail.test', code: '111111' })).code === 'site', 'an unknown site is refused'); + for (let i = 0; i < 4; i++) await SI.handle('code', { site: 'videoappincome', email: 'new.person@mail.test', code: '482913' }); + r = await SI.handle('code', { site: 'videoappincome', email: 'new.person@mail.test', code: '482913' }); ok(r.code === 'limit', 'the sixth code to one address in an hour is refused', r); +} fs.rmSync(dir, { recursive: true, force: true }); console.log('\n' + passes + ' passed, ' + fails + ' failed'); process.exit(fails ? 1 : 0); diff --git a/server.js b/server.js index 8834f79..ccbff89 100644 --- a/server.js +++ b/server.js @@ -876,7 +876,7 @@ async function boot() { // sponsor invite emails for other network sites (siteinvite.js, 2026-11-21): the same never-mail list the tank batches use { let spamC = { at: 0, set: new Set() }; const spamSet = () => { if (Date.now() - spamC.at > 60000) { try { spamC = { at: Date.now(), set: new Set((((spamscan.view() || {}).last || {}).candidates || []).map(c => String(c.email || '').toLowerCase())) }; } catch (e) { spamC = { at: Date.now(), set: new Set() }; } } return spamC.set; }; await siteinvite.init({ dataDir: DATA_DIR, accounts, mailer, siteConfig, prohibited, - hooks: { excluded: em => fraud.excluded(em), + hooks: { excluded: em => fraud.excluded(em), suggestDomain: d => require('./emailcheck').suggestDomain(d), erased: em => erase.isErased(em), excludedPerson: async em => { if (spamSet().has(em)) return 'spam scan'; const d = String(em).split('@')[1] || ''; const fix = require('./emailcheck').suggestDomain(d); if (fix && fix !== d) return 'mistyped email domain'; if (erase.isErased(em)) return 'erased'; if (await drip.isUnsubscribed(em).catch(() => false)) return 'unsubscribed from email'; return null; } } }).catch(e => console.error('siteinvite init', e.message)); } setTimeout(() => tankbatch.tick().catch(e => console.error('tankbatch', e.message)), 4 * 60 * 1000); // past the deploy overlap window setInterval(() => tankbatch.tick().catch(e => console.error('tankbatch', e.message)), 60 * 60 * 1000); @@ -3936,7 +3936,7 @@ const server = http.createServer(async (req, res) => { const raw = await new Promise((ok, no) => { let d = ''; req.on('data', c => { d += c; if (d.length > 64000) { req.destroy(); no(new Error('too big')); } }); req.on('end', () => ok(d)); req.on('error', no); }); const sg = siteinvite.verify(req.headers, raw); if (!sg.body) return json(res, sg.status, { error: sg.error }); const op = p.slice('/api/partner/invite/'.length); - if (!['eligible', 'send'].includes(op)) return json(res, 404, { error: 'unknown op' }); + if (!['eligible', 'send', 'code'].includes(op)) return json(res, 404, { error: 'unknown op' }); const r = await siteinvite.handle(op, sg.body); return json(res, r.error ? 400 : 200, r); } diff --git a/siteinvite.js b/siteinvite.js index cac69a7..d164feb 100644 --- a/siteinvite.js +++ b/siteinvite.js @@ -9,6 +9,9 @@ // -> { ok, sender: username, directs: [{ username, state: 'ok' | 'sent' | 'no' }], left: { sender, network }, paused } // POST /api/partner/invite/send { rid, site, sender, items: [{ username, link }], note? } // -> { ok, results: [{ username, status: 'sent' | }], sent, left } +// POST /api/partner/invite/code { site, email, code } -> { ok } | { error, code } (2026-11-21) +// the email-check code for the site's network gate: the SITE makes and checks the 6-digit code, this app only mails it +// (a requested code is transactional, like a sign-in code). Fixed wording, no links; 5 an hour per address, 2,000 a day in all. // Signature: X-Invite-Ts (ms) + X-Invite-Sig = hex HMAC-SHA256(SITE_INVITE_SECRET, 'invite.v1.' + ts + '\n' + raw body), 5 minutes. // // The rules: @@ -184,7 +187,28 @@ async function send(b) { console.log('site invite', siteId, 'from', sender.username, 'sent', sentN, 'of', items.length); return { ok: true, results, sent: sentN, left: await left(sender) }; } -async function handle(op, b) { if (op === 'eligible') return eligible(b || {}); if (op === 'send') return send(b || {}); return { error: 'unknown op' }; } +// ---- the email-check code a site asks for when a new person gives their email at its network gate ---- +const codeLog = new Map(); let codeDay = { start: 0, n: 0 }; +async function code(b) { + const site = SITES[lc(b.site)]; if (!site) return { error: 'unknown site', code: 'site' }; + const em = lc(b.email), c = String(b.code || ''); + if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(em) || em.length > 190 || !/^\d{6}$/.test(c)) return { error: 'That does not look like an email address.', code: 'email' }; + const d = em.split('@')[1] || ''; + if (THROWAWAY.has(d)) return { error: 'Please use your regular email address, not a temporary one.', code: 'email' }; + if (R.hooks && R.hooks.suggestDomain) { const fix = R.hooks.suggestDomain(d); if (fix && fix !== d) return { error: 'Check the spelling of your email. Did you mean ' + em.split('@')[0] + '@' + fix + '?', code: 'email' }; } + if (R.hooks && R.hooks.excluded && R.hooks.excluded(em)) return { error: 'That email cannot be used here.', code: 'email' }; + if (R.hooks && R.hooks.erased && R.hooks.erased(em)) return { error: 'That email cannot be used here.', code: 'email' }; + if (!R.mailer || !R.mailer.hasKey()) return { error: 'Email is not available right now.', code: 'mail' }; + const now = clock(), day = dayStart(now); if (codeDay.start !== day) codeDay = { start: day, n: 0 }; + const mine = (codeLog.get(em) || []).filter(t => now - t < 3600000); + if (mine.length >= 5) return { error: 'Too many codes were sent to that address. Try again in an hour.', code: 'limit' }; + if (codeDay.n >= 2000) return { error: 'Please try again later.', code: 'limit' }; + mine.push(now); codeLog.set(em, mine); codeDay.n++; if (codeLog.size > 20000) codeLog.clear(); + const text = 'Your code is: ' + c + '\n\nEnter it in ' + site.name + ' to confirm your email. It works for 15 minutes. If you did not ask for it, ignore this email.\n\n' + site.name + ' is part of the Crypto Team Build Network. This email was sent by InstantAdPay, the mail service of the network.'; + try { await R.mailer.send(em, c + ' is your ' + site.name + ' code', text, null, { transactional: true, fromName: site.name }); } catch (e) { console.error('site code mail', e.message); return { error: 'The email could not be sent. Check the address and try again.', code: 'mail' }; } + return { ok: true }; +} +async function handle(op, b) { if (op === 'eligible') return eligible(b || {}); if (op === 'send') return send(b || {}); if (op === 'code') return code(b || {}); return { error: 'unknown op' }; } async function adminView() { const since = dayStart(clock()), c = cfg(); return { on: enabled(), paused: c.paused, perSender: c.perSender, perDay: c.perDay, today: await S().count(since), recent: (await S().recent(200)).map(r => ({ site: r.site, to: r.username, from: r.senderName, ts: r.ts, status: r.status, link: r.link })) }; } // one sample to one address, for the owner to read before the feature opens. Not counted, not recorded. async function sample(to, siteId) { const site = SITES[lc(siteId) || 'videoappincome']; if (!site) return { error: 'unknown site' }; const m = compose(site, 'yoursponsor', 'yourname', 'https://' + hosts()[0] + '/p/faceless', ''); await R.mailer.send(to, '[SAMPLE] ' + m.subject, m.text, m.html); return { ok: true, to, subject: m.subject, text: m.text }; }