Network sign-in: the way back after signing in on InstantAdPay (Marty 2026-11-17)
networksso.js (the shared file, same in every network site): providers now also know every site in the hub's GET /v1/sso-sites, ?return=<site>&to=/path links on IAP/LinkSpin remember the way back, a missing wallet sends the member to the provider's wallet step first and then back, and the deliberate-tap state lives 1 hour (was 20 minutes) so a sign-up has time. Join links to InstantAdPay carry ?return=<this site>&to=/my. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,7 @@ const proof = require('./proof');
|
||||
const netsites = require('./netsites');
|
||||
const lstrack = require('./lstrack');
|
||||
const chatbot = require('./chatbot');
|
||||
const adwriter = require('./adwriter');
|
||||
|
||||
const PUB = path.join(__dirname, 'public');
|
||||
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
||||
@@ -187,7 +188,10 @@ function issueTicket(req, page, shown, src, via) {
|
||||
return t;
|
||||
}
|
||||
const todayStats = () => { const t = store.today(); return { views: t.views || 0, vclicks: t.vclicks || 0, reshares: t.reshares || 0, joins: t.confirms || 0, ads: store.liveAds().length }; };
|
||||
const joinUrl = ref => ref ? C.joinUrl.split('{ref}').join(encodeURIComponent(ref)) : C.joinUrl.replace(/\/join\/\{ref\}.*$/, '/').replace(/[?&]ref=\{ref\}/, '').split('{ref}').join('');
|
||||
// a join link to InstantAdPay or LinkSpin carries the way back here (2026-11-17, Marty: "it never had a return path back"): the
|
||||
// provider remembers ?return=<this site>&to=/my and, after the sign-up or sign-in (and the wallet step), sends the member back
|
||||
const withReturn = url => { try { const x = new URL(url); if (!/^(www\.)?(instantadpay\.com|linkspin\.app)$/.test(x.hostname) && x.origin !== new URL(C.iapBase).origin) return url; x.searchParams.set('return', C.siteId); x.searchParams.set('to', '/my'); return x.toString(); } catch (e) { return url; } };
|
||||
const joinUrl = ref => withReturn(ref ? C.joinUrl.split('{ref}').join(encodeURIComponent(ref)) : C.joinUrl.replace(/\/join\/\{ref\}.*$/, '/').replace(/[?&]ref=\{ref\}/, '').split('{ref}').join(''));
|
||||
const MACRO = /\{(clickid|placement)\}|%7B(clickid|placement)%7D/gi;
|
||||
function clickLink(a, placement) {
|
||||
const l = String(a.link || ''); if (!l.match(MACRO)) return l;
|
||||
@@ -271,7 +275,8 @@ const server = http.createServer(async (req, res) => {
|
||||
return json(res, 200, { site: C.site, siteName: C.siteName, staging: C.staging, chainId: C.chainId, chainName: C.chainName, rpc: C.publicRpc, walletConnectProjectId: C.walletConnectProjectId,
|
||||
boost: C.boost, split: live ? { resharerBps: live.resharerBps, potBps: live.potBps, levelBps: live.levelBps, maxDepth: 20, live: true } : Object.assign({ proposal: true }, C.split),
|
||||
reward: { cents: C.reward.cents, dailyCap: C.reward.dailyCap, payouts: C.reward.payouts, tiers: C.reward.tiers, proposal: true }, credits: C.credits, visitSeconds: C.visitSeconds, ad: C.ad,
|
||||
sso: networksso.enabled() || networksso.hubOn(), shop: { live: shop.watching() && shop.signerOn(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer, joinUrl: joinUrl('') });
|
||||
sso: networksso.enabled() || networksso.hubOn(), shop: { live: shop.watching() && shop.signerOn(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer, joinUrl: joinUrl(''),
|
||||
aiWriter: adwriter.enabled() ? { daily: adwriter.dailyCap() } : null });
|
||||
}
|
||||
// everything a page shows, with its visit ticket. page=front|share|other, s=<share code> on share pages
|
||||
if (p === '/api/wire' && req.method === 'GET') {
|
||||
@@ -472,6 +477,17 @@ const server = http.createServer(async (req, res) => {
|
||||
catch (e) { console.error('order failed:', String(e && e.message || e).slice(0, 200)); return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
|
||||
}
|
||||
if (p === '/api/my/paid' && req.method === 'POST') { shop.nudge(); return json(res, 200, { ok: true, confirmations: C.shopConfirmations }); }
|
||||
// the AI ad writer (2026-11-17): 3 suggested ads written only from the member's own page; nothing is posted (adwriter.js)
|
||||
if (p === '/api/my/adwriter' && req.method === 'POST') {
|
||||
if (!adwriter.enabled()) return json(res, 503, { error: adwriter.MSG.off });
|
||||
if (limited(req, 'adwriter', 12, 3600000)) return json(res, 429, { error: 'Too many ad writes from this connection this hour. Try again later, or write your ad yourself.' });
|
||||
const m = store.member(me); await verifyNet(me).catch(() => {});
|
||||
if (!netVerified(m)) return json(res, 403, { error: 'The ad writer is for network members. Sign in with your network account first.' });
|
||||
const b = await readBody(req);
|
||||
const r = await adwriter.write(me, String(b.url || '').trim().slice(0, 600));
|
||||
if (r.error) return json(res, r.status || 400, { error: r.error, code: r.code, left: r.left });
|
||||
return json(res, 200, { ok: true, options: r.options, url: r.url, cached: r.cached, left: r.left });
|
||||
}
|
||||
return json(res, 404, { error: 'Not found' });
|
||||
}
|
||||
|
||||
@@ -484,7 +500,7 @@ const server = http.createServer(async (req, res) => {
|
||||
today: store.today(), totals: S.totals, members: store.members().length, ads: { live: store.liveAds().length, all: store.ads().length }, shares: S.shares.length,
|
||||
rows: { visits: store.visits().length, clicks: store.clicks().length, signups: store.signups().length, rewards: store.rewards().length },
|
||||
signup: signup.view(), shop: shop.view(), proof: proof.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), hubEvents: hubevents.view(), sso: { hub: networksso.hubOn(), pairwise: networksso.enabled() },
|
||||
linkspin: lstrack.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
|
||||
linkspin: lstrack.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length, adWriter: adwriter.view() });
|
||||
}
|
||||
if (p === '/api/admin/signups' && req.method === 'GET') {
|
||||
const st0 = String(u.searchParams.get('status') || '');
|
||||
@@ -551,6 +567,7 @@ const server = http.createServer(async (req, res) => {
|
||||
setInterval(() => { if (store.prune()) wire.rebuild(); }, 3600000).unref();
|
||||
if (C.reward.payouts) setInterval(() => signup.payDue().catch(() => {}), 60000).unref();
|
||||
chatbot.init();
|
||||
adwriter.init({ store, ad: C.ad });
|
||||
lstrack.init(C, store);
|
||||
{ let busy = false; const tick = () => { if (busy) return; busy = true; lstrack.sweep(25).catch(() => {}).finally(() => { busy = false; }); };
|
||||
setTimeout(tick, Number(process.env.LS_SWEEP_FIRST_MS || 20000)).unref(); setInterval(tick, Number(process.env.LS_SWEEP_MS || 120000)).unref(); }
|
||||
|
||||
Reference in New Issue
Block a user