Podcast Commission Stack: kit under Promo tools > Network sites (read from its own /api/promo-kit feed, placed after Video App Income, added quietly: no notice, no release note) and the email-check code mail for its network gate. siteinvite.js: each site signs with its own secret (SITE_INVITE_SECRET_PCS for the new site, SITE_INVITE_SECRET unchanged for Video App Income), verify() names the signing site and a body that names any other site is refused; the new site has the code call only, no invite emails; the code limits stay one count for all sites (5 an hour per address, 2,000 a day). Chatbot answer + prompt, KNOWLEDGE_DATE 2026-11-25; qa/site-invite.test.mjs 52 -> 80 checks, routing rows in qa/chatbot-parse.mjs
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -138,5 +138,73 @@ const send = (items, x) => SI.handle('send', Object.assign({ rid: 'rid-' + Math.
|
||||
if (r.ok && r.sent === 1) ok(sent.length === n + 1 && sent[n][1] === 'bob sent you a video' && /shows how it works/.test(sent[n][2]), 'the send call passes the kind through to the email', sent[n] && sent[n][1]);
|
||||
else ok(false, 'promo send through the full path', r);
|
||||
}
|
||||
// ---- a second site, Podcast Commission Stack (2026-11-25): its own secret, the code mail only, Video App Income exactly as before ----
|
||||
{
|
||||
const PCS = 'podcastcommissionstack', VAI = 'videoappincome', pSecret = 'p'.repeat(40), vSecret = 's'.repeat(40);
|
||||
const base = { dataDir: dir, accounts, mailer, prohibited, siteConfig: () => conf, secret: vSecret, linkHosts: 'clickvidpro.com', clock: () => now, gapMs: 0, hooks: { excluded: em => em === 'flagged@mail.test' } };
|
||||
const signed = (body, secret) => { const raw = JSON.stringify(body), ts = String(Date.now()); return SI.verify({ 'x-invite-ts': ts, 'x-invite-sig': SI.sign(ts, raw, secret) }, raw); };
|
||||
// the whole HTTP path: verify names the signing site, and that name goes to handle (server.js: handle(op, sg.body, sg.site))
|
||||
const call = async (op, body, secret) => { const sg = signed(body, secret); return sg.body ? SI.handle(op, sg.body, sg.site) : sg; };
|
||||
const vaiText = c => 'Your code is: ' + c + '\n\nEnter it in Video App Income to confirm your email. It works for 15 minutes. If you did not ask for it, ignore this email.\n\nVideo App Income is part of the Crypto Team Build Network. This email was sent by InstantAdPay, the mail service of the network.';
|
||||
|
||||
// before its secret is set, the new site cannot call at all and Video App Income is as it was
|
||||
await SI.init(base); now += 24 * 3600000;
|
||||
ok(signed({ site: PCS, email: 'a@mail.test', code: '111111' }, pSecret).status === 401, 'with no secret set for Podcast Commission Stack, a call signed for it is refused');
|
||||
ok(signed({ site: VAI }, vSecret).site === VAI, 'and a Video App Income call is still accepted');
|
||||
await SI.init(Object.assign({}, base, { secrets: { [PCS]: vSecret } }));
|
||||
ok(signed({ site: PCS }, vSecret).site === VAI && (await call('code', { site: PCS, email: 'a@mail.test', code: '111111' }, vSecret)).code === 'site', 'the same secret given to both sites does not open the second site');
|
||||
await SI.init(Object.assign({}, base, { secrets: { [PCS]: 'short' } }));
|
||||
ok(signed({ site: PCS }, 'short').status === 401, 'a secret under 32 characters is not accepted for the second site');
|
||||
|
||||
// the env var, by its exact name
|
||||
process.env.SITE_INVITE_SECRET_PCS = pSecret; await SI.init(base);
|
||||
ok(signed({ site: PCS }, pSecret).site === PCS, 'SITE_INVITE_SECRET_PCS is the secret Podcast Commission Stack signs with');
|
||||
delete process.env.SITE_INVITE_SECRET_PCS;
|
||||
|
||||
await SI.init(Object.assign({}, base, { secrets: { [PCS]: pSecret } }));
|
||||
ok(signed({ site: PCS }, pSecret).site === PCS && signed({ site: VAI }, vSecret).site === VAI, 'each site is recognised by its own secret');
|
||||
ok(signed({ site: PCS }, 'x'.repeat(40)).status === 401, 'a secret that belongs to neither site is refused');
|
||||
|
||||
// the code mail for the new site
|
||||
let n = sent.length, r = await call('code', { site: PCS, email: 'Pod.Person@Mail.test', code: '730155' }, pSecret), m = sent[sent.length - 1];
|
||||
ok(r.ok && sent.length === n + 1 && m[0] === 'pod.person@mail.test' && m[1] === '730155 is your Podcast Commission Stack code', 'the code mail goes out for Podcast Commission Stack', [r, m && m.slice(0, 2)]);
|
||||
ok(m[2] === vaiText('730155').split('Video App Income').join('Podcast Commission Stack') && !/Video App Income|https?:/.test(m[2] + m[1]), 'its wording names Podcast Commission Stack, never Video App Income, and has no links', m[2]);
|
||||
ok(m[3] == null && m[4] && m[4].transactional === true && m[4].fromName === 'Podcast Commission Stack', 'it is sent as a requested mail with the From name Podcast Commission Stack', m[4]);
|
||||
ok((await call('code', { site: PCS, email: 'x@mailinator.com', code: '111111' }, pSecret)).code === 'email' && (await call('code', { site: PCS, email: 'flagged@mail.test', code: '111111' }, pSecret)).code === 'email' && (await call('code', { site: PCS, email: 'a@mail.test', code: '12ab' }, pSecret)).code === 'email', 'the same address and code checks apply to it');
|
||||
|
||||
// one site's secret never acts for the other
|
||||
n = sent.length;
|
||||
ok((await call('code', { site: PCS, email: 'b@mail.test', code: '111111' }, vSecret)).code === 'site', 'the Video App Income secret cannot send a Podcast Commission Stack code');
|
||||
ok((await call('code', { site: VAI, email: 'b@mail.test', code: '111111' }, pSecret)).code === 'site', 'the Podcast Commission Stack secret cannot send a Video App Income code');
|
||||
ok((await call('eligible', { site: VAI, sender: { email: 'ann@mail.test' } }, pSecret)).code === 'site' && (await call('send', { rid: 'rid-cross-000001', site: VAI, sender: { email: 'zed@mail.test' }, items: [{ username: 'z2', link: L('z2') }] }, pSecret)).code === 'site', 'nor reach the Video App Income invite calls');
|
||||
ok(sent.length === n, 'and none of those sent an email');
|
||||
|
||||
// invite emails are not open to the new site, with its own secret or from inside the app
|
||||
const before = (await SI.adminView()).recent.length;
|
||||
r = await call('eligible', { site: PCS, sender: { email: 'ann@mail.test' } }, pSecret); ok(r.code === 'op' && !r.directs, 'Podcast Commission Stack cannot ask who is eligible for invites', r);
|
||||
r = await call('send', { rid: 'rid-pcs-0000001', site: PCS, sender: { email: 'zed@mail.test' }, items: [{ username: 'z2', link: L('z2') }] }, pSecret); ok(r.code === 'op' && !r.results, 'or send invite emails', r);
|
||||
ok((await SI.handle('send', { rid: 'rid-pcs-0000002', site: PCS, sender: { email: 'zed@mail.test' }, items: [{ username: 'z2', link: L('z2') }] })).code === 'op' && (await SI.handle('eligible', { site: PCS, sender: { email: 'ann@mail.test' } })).code === 'op', 'the same refusal without a signer');
|
||||
ok((await SI.sample('owner@mail.test', PCS)).error === 'unknown site', 'and there is no sample invite for it');
|
||||
ok(sent.length === n && (await SI.adminView()).recent.length === before, 'nothing was sent or recorded');
|
||||
ok(SI.SITES[PCS].ops.join() === 'code' && !SI.SITES[VAI].ops && !SI.SITES[VAI].secretEnv, 'the site list: code only for the new site, Video App Income with no restriction and its original secret');
|
||||
|
||||
// Video App Income after the change: same words, same calls
|
||||
n = sent.length; r = await call('code', { site: VAI, email: 'vai.person@mail.test', code: '204681' }, vSecret); m = sent[sent.length - 1];
|
||||
ok(r.ok && sent.length === n + 1 && m[1] === '204681 is your Video App Income code' && m[2] === vaiText('204681') && m[4].transactional === true && m[4].fromName === 'Video App Income', 'the Video App Income code mail is word for word what it was', m && m.slice(1, 3));
|
||||
r = await call('eligible', { site: VAI, sender: { email: 'zed@mail.test' } }, vSecret); ok(r.ok && r.sender === 'zed' && r.directs.length === 3, 'Video App Income can still ask who is eligible', r);
|
||||
n = sent.length; r = await call('send', { rid: 'rid-vai-still-01', site: VAI, sender: { email: 'zed@mail.test' }, items: [{ username: 'z2', link: L('z2') }] }, vSecret);
|
||||
ok(r.ok && r.sent === 1 && sent.length === n + 1 && sent[n][1] === 'zed made you a video' && sent[n].length === 4, 'and still send an invite email, worded as before', r);
|
||||
ok((await call('code', { site: 'nosuchsite', email: 'a@mail.test', code: '111111' }, vSecret)).error === 'unknown site', 'an unknown site is refused as before');
|
||||
|
||||
// the limits are one count for both sites: nothing is doubled by adding a site
|
||||
for (let i = 0; i < 2; i++) await call('code', { site: PCS, email: 'both@mail.test', code: '111111' }, pSecret);
|
||||
for (let i = 0; i < 3; i++) await call('code', { site: VAI, email: 'both@mail.test', code: '111111' }, vSecret);
|
||||
n = sent.length;
|
||||
ok((await call('code', { site: PCS, email: 'both@mail.test', code: '111111' }, pSecret)).code === 'limit' && (await call('code', { site: VAI, email: 'both@mail.test', code: '111111' }, vSecret)).code === 'limit' && sent.length === n, 'five codes an hour to one address, counted across both sites');
|
||||
now += 24 * 3600000; n = sent.length; let okN = 0;
|
||||
for (let i = 0; i < 2000; i++) { const pcs = i % 2 === 0; if ((await call('code', { site: pcs ? PCS : VAI, email: 'day' + i + '@mail.test', code: '111111' }, pcs ? pSecret : vSecret)).ok) okN++; }
|
||||
ok(okN === 2000 && sent.length === n + 2000, '2,000 codes in a day go out between the two sites', okN);
|
||||
ok((await call('code', { site: PCS, email: 'over1@mail.test', code: '111111' }, pSecret)).code === 'limit' && (await call('code', { site: VAI, email: 'over2@mail.test', code: '111111' }, vSecret)).code === 'limit' && sent.length === n + 2000, 'and the 2,001st is refused for either site: the daily limit is still 2,000 in all');
|
||||
}
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
console.log('\n' + passes + ' passed, ' + fails + ' failed'); process.exit(fails ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user