From 6096bf38c6271917ee96ccc60d21661925fa4454 Mon Sep 17 00:00:00 2001 From: martbost Date: Wed, 28 Oct 2026 08:07:26 -0500 Subject: [PATCH] POL Miner integration, gated (2026-10-28): POLMINER_SSO_SECRET / POLMINER_URL / POLMINER_ALT_URLS with pmMint/pmOpen/pmIsGameUrl/pmCallback; GAME_AUTH polminer (in-game sign-in kit); /api/my/polminer hand-off + iap.return + my.js redirect (my.js?v=20261028pm); refuel game 'polminer' (label "supply crate", receipt kind pm-crate, note "POL Miner supply crate"); GAMES() card (art polminer.com/og-polminer.jpg) and STRIP line, both hidden until 'polminer' is in site config gamesLive; walletnudge entry (idle until the secret is set); gamestats name; chatbot CANNED + systemPrompt fact follow gamesLive (coming-soon answer and fact until launch, its KB answer kept out of the prompt), KNOWLEDGE_DATE 2026-10-28. qa member: 0 bugs (2 old admin warnings), qa public: 0 bugs. Co-Authored-By: Claude Opus 5.5 --- chatbot.js | 19 +++++++++++---- gamestats.js | 2 +- public/assets/my.js | 1 + public/my.html | 2 +- server.js | 57 ++++++++++++++++++++++++++++++++++++++++----- walletnudge.js | 1 + 6 files changed, 70 insertions(+), 12 deletions(-) diff --git a/chatbot.js b/chatbot.js index 0c9fd79..b6dd40d 100644 --- a/chatbot.js +++ b/chatbot.js @@ -23,6 +23,7 @@ let PASS_TIERS = null; // () => the live pass tiers (server.js, from gamepass.cf const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro'; function init(opts) { + if (opts && typeof opts.gameLive === 'function') GAME_LIVE = opts.gameLive; if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; PASS_TIERS = typeof opts.passTiers === 'function' ? opts.passTiers : null; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); } function key() { if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim(); @@ -31,7 +32,7 @@ function key() { function enabled() { return !!key(); } // ---- canned answers: instant, free, always in voice ---- -const KNOWLEDGE_DATE = '2026-10-27'; // bump whenever the canned answers / prompt are brought up to date +const KNOWLEDGE_DATE = '2026-10-28'; // bump whenever the canned answers / prompt are brought up to date const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|team at instantadpay|someone|a (human|person|real person))|support (email|address|ticket|team|desk)|help ?desk|(open|send|file|submit|raise) (a )?(support )?ticket|\b(human|real person|live (agent|person|chat|support))\b|customer (service|support)|support@|how (do|can) i get (help|support)/i; const CANNED = [ { id: 'support', title: 'Contact support or open a ticket', q: ['How do I contact support?', 'How do I talk to a real person?', 'How do I open a support ticket?'], tags: ['support', 'help', 'ticket', 'contact', 'help desk'], @@ -59,6 +60,9 @@ const CANNED = [ { id: 'spellwheel', title: 'SpellWheel word game', q: ['What is SpellWheel?', 'Is there a daily word puzzle?'], tags: ['games', 'spellwheel', 'word game', 'daily puzzle'], re: /(spell ?wheel|letter wheel|word (game|puzzle)|crossword|daily puzzle)/i, a: 'SpellWheel (https://spellwheel.com, also in Members > Games) is a free word game: swipe the letters on the wheel to fill the crossword grid, travel through six cozy places, and solve a new daily puzzle that everyone gets at the same time. Sign in with your InstantAdPay account right in the game to save progress: clearing levels, finishing a place and solving the daily puzzle each pay POL, collected in your SpellWheel balance and sent to the wallet on your InstantAdPay account automatically. Nothing here is a promise of income.' }, + { id: 'polminer', title: 'POL Miner mining game', q: ['What is POL Miner?', 'How do Polygon crystals work in POL Miner?', 'What is a supply crate?'], tags: ['games', 'polminer', 'mining', 'polygon crystal', 'supply crate'], + re: /(pol ?miner|mining game|digging game|polygon crystals?|pink crystals?|drill boss(es)?|supply crates?)/i, + a: 'POL Miner (https://polminer.com, also in Members > Games) is a free dig-down mining game. Dig through the layers of dirt and rock, haul ore up to sell for coins, upgrade your pick, lamp, cart and thruster, and beat a drill boss every 30 m to open the way deeper. The rare glowing pink Polygon crystals pay a random amount of POL the first time you dig each one out, each drill boss pays POL the first time you beat it, and so do your first trips to 50, 100, 150 and 200 m. Coins are for upgrades only and never turn into POL. You can play as a guest right away; sign in with your InstantAdPay account in the game and what you earned as a guest is collected. POL collects in your POL Miner balance and is sent automatically to the wallet linked to your InstantAdPay account (one free signature on the Wallet tab) once it reaches the payout amount. Low on lamp power or coins? Park on the SUPPLY pad: a short sponsor visit opens a supply crate with a full lamp and coins.' }, { id: 'polybreak', title: 'PolyBreak brick breaker', q: ['What is PolyBreak?', 'How do I get another paddle?'], tags: ['games', 'polybreak', 'brick breaker', 'gem'], re: /(poly ?break|brick ?breaker|breakout|arkanoid|purple gem|polygon gem|one more paddle|\bcapsules?\b)/i, a: 'PolyBreak (https://polybreak.app, also in Members > Games) is a free brick breaker in the Amiga arcade style: break a wall of glass jewel bricks with the ball and paddle, catch falling capsules (wider paddle, split ball, lasers, slow ball, catch, a break gate that skips the round, an extra paddle), and catch the purple Polygon gem when it drifts down. Sign in with your InstantAdPay account in one tap. Your first clear of each round pays POL into your PolyBreak game balance, and each gem catch pays a small random amount of POL; the balance is sent to the wallet on your InstantAdPay account automatically at the payout line shown in the game. Out of paddles? A short visit to a member\u2019s page gives you one more paddle on the same round. Share your PolyBreak link from the game: when people you invite play, you earn a share too. Nothing here is a promise of income.' }, @@ -235,6 +239,11 @@ const netRateAnswer = n => n === 1 ? 'Your banner and text ads also run on Netwo function synFact() { const n = SYN_N(); return '- NETWORK RATE (live, Marty 2026-10-27): delivery ON instantadpay.com is charged at the normal rate. Network Ad Space impressions of banner/text ads cost 1/' + n + ' of the on-site rate (' + n + ' network views = the price of 1 view here; credit log line "Network views (1/' + n + ' rate)"), and PassiveDrip partner visits use up 1 visit of a pack per ' + n + ' partner visits. The budget is the limit, burns follow what was charged, nothing charged before 2026-10-27 changed. AdRevLinks popups and DripOffers clicks are not charged. Game refuels and Spooky Doors are charged as normal visits.' + String.fromCharCode(10); } // the refuel fact follows the refuelStreak switch: while it is off the assistant says it is not live yet (2026-10-24) let REFUEL_ON = () => false; +// POL Miner (2026-10-28) follows site config gamesLive: until 'polminer' is in it the assistant only says it is coming soon +let GAME_LIVE = () => false; +const POLMINER_SOON_ANSWER = 'POL Miner, a dig-down mining game where rare Polygon crystals pay POL, is coming soon to the InstantAdPay games. It is not open yet; it will show up on your Games tab (Members > Games) and in the release notes when it launches.'; +const pmLive = () => { try { return !!GAME_LIVE('polminer'); } catch (e) { return false; } }; +function polminerFact() { return pmLive() ? '- POL MINER (https://polminer.com, Members > Games): a free dig-down mining game. Dig, sell ore for coins, upgrade pick/lamp/cart/thruster, beat a drill boss every 30 m. Pink Polygon crystals pay a random POL amount the first time each one is dug out; each boss pays POL on its first win per account; first trips to 50/100/150/200 m pay POL. Coins never turn into POL. Guests can play and collect at sign-in. POL is paid automatically to the wallet linked on InstantAdPay. The SUPPLY pad opens a sponsored supply crate (full lamp + coins, never POL) after a short sponsor visit.\n' : '- POL MINER: COMING SOON, not open yet. Never send members to polminer.com; say it is coming soon to the Games tab.\n'; } function refuelFact() { return REFUEL_ON() ? "- MONTHLY REFUEL STREAK (built 2026-10-24, switch refuelStreak): ONE streak per member across InstantAdPay and LinkSpin. Counted refuel = a NEW package of $20+ on InstantAdPay or $25+ on LinkSpin by one of the member's own positions. First one sets the member's own refuel day; next due 30 days after the last counted refuel; window opens 5 days before the due day; 5-day grace after it; Central time. Missing the grace resets the streak, except one free miss per 365 days. Bonus (purchased-grade ad credits on the site where bought, credit log 'Refuel streak'): one engine m1 +10%, m2 +15%, m3 +20%, m4+ +25%; both sites in the same cycle m1 +15%, m2 +20%, m3 +30%, m4+ +40% each (first site topped up to the both rate, difference only) plus a 100-credit Featured bonus on InstantAdPay at m4+ (purchased-grade credits, any format). Stacks on Five Dollar Friday / Wired Wednesday. Pit Stop: another $20+/$25+ package on a site already refueled this cycle, before the next window opens (the other site's first package in the cycle is the second engine instead) = half the current streak rate, once per site per cycle, not a counted refuel. Badges: Engine Started (first refuel), Refueled 3 / 6 / 12 months. ENGINE ROOM: unlocked by the first counted refuel (greyed 'Refuel to start your engine' before), IAP tab Engine Room + LinkSpin Ads screen panel, same data both sites: dials Fuel left (credits free + in campaigns on both sites vs this cycle's refuel credits incl. bonus, days left at the recent burn), Clicks this week (vs last week, clicks per 1,000 credits), Goals this month (conversion pixel conversions since the 1st Central vs the member's own goal); streak panel; warning lights (ads at 80%, ads out, refuel day coming, login slot open); six part lights (fuel, banner spin, spin link, page, testing, conversion tracking: green working, amber needs attention, grey not started with a Set it up link); one Next move button from simple rules. REFUEL KIT: each counted refuel unlocks the Central-month's members-only banner set for this site's own program (5 sizes, personalized server-side with @username + QR to the member's link; IAP: Promo tools card with Use in an IAP banner campaign; LinkSpin: Ads screen card with Load into my Banner Spin); kits stay usable after the month; streak month 3+ adds an animated GIF, month 6+ a BannerKitAI custom-banners credit (coming, entitlement saved). Reminders 5 days before, on the day, last call at the end of grace (email + on-site notice). The member's Refuel card (InstantAdPay Overview, LinkSpin Credits/Ads) shows refuel day, streak, next bonus, Pit Stop status. Either site alone keeps the streak (one-engine rates); both sites in one cycle = the bigger bonus; never say both are required. MEMBER GUIDE PAGE (public, 2026-10-24): /refuel on both sites (https://instantadpay.com/refuel and https://linkspin.app/refuel): the flow, the numbers, the member steps, leader coaching and FAQ; point members there for the full picture. Ad credits only, never cash; never promise income. No auto-billing: the member chooses every package. ROUTES (2026-10-25): LinkSpin menu item Refuel = https://linkspin.app/credits#refuel (the Refuel panel, scrolled to and highlighted); packages of $25+ there are marked counts for Refuel; https://linkspin.app/credits#buy = the package picker; https://linkspin.app/ads#engine = LinkSpin Engine Room. InstantAdPay Engine Room = https://instantadpay.com/my#engine; its Set up conversion tracking opens https://instantadpay.com/my#conversions (Campaigns > Conversion tracking card, same goals LinkSpin counts). Engine Room links that cross to LinkSpin (Banner Spin, spin link, page, testing, refuel LinkSpin) open LinkSpin with a note at the top naming the job, Step 1, a guide link and Back to InstantAdPay; same email signs in on both.\n" : '- MONTHLY REFUEL STREAK: built but NOT switched on yet. If asked, say it is coming and nothing counts toward it today; do not quote bonus rates or dates.\n'; } const REFUEL_OFF_ANSWER = 'The Monthly Refuel streak (bonus ad credits for refueling every month, more when you refuel both InstantAdPay and LinkSpin) is built but not switched on yet, so nothing counts toward it today. The bonuses running now are Five Dollar Friday and Wired Wednesday on InstantAdPay. When the streak goes live, your Refuel card will show your refuel day.'; function systemPrompt(kbBlock) { @@ -242,7 +251,7 @@ function systemPrompt(kbBlock) { FACTS: - LEVEL 4 OVERRIDE (LIVE 2026-10-26, first payout Monday 2026-11-02): company-paid, off-chain decision, on-chain payment. 3% of every package purchase (the POL actually paid) goes to the buyer's 4th upline on the contract sponsor chain if that member's contract buyerCount is 5 or more (qualifying buyer = direct referral with a $20+ purchase, same bar as level 3); otherwise it hunts up to the next qualified upline, max 25 hops; the company account (#1) or no qualified upline = company keeps it; exactly one recipient per purchase. Paid weekly in POL every Monday after 9 AM Central for the previous Monday to Sunday Central week, from a company payer wallet via the contract's award(memberId), shown in Earnings as 'Level 4 override' with a Polygon link and announced by email and an on-site notice. Under 0.01 POL carries to the next week. Purchases from the start date only, no back pay. Funded from the platform's 20%; the contract split 50/20/10 is unchanged. Never promise amounts. -${passTiersFact()}${refuelFact()}${synFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref= link. +${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref= link. - HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time. - PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide. - WIRED WEDNESDAY: every Wednesday, Central time (midnight to midnight), any ad package of $20 or more (Activation and up; no $10 pack exists) earns +25% bonus credits wired into the buyer's balance the moment the purchase settles, purchased-grade (usable on every format incl. login ads), credit log label "Wired Wednesday". First one: Wednesday 2026-09-30. Page: instantadpay.com/wednesday. Credits buy ad delivery, never money. @@ -388,15 +397,17 @@ async function answerRaw(message, historyText) { let hit = null, kbOk = true; try { hit = await kb.fastPath(msg); } catch (e) { kbOk = false; console.error('kb fast path', e.message); } if (hit && hit.id === 'refuel' && !REFUEL_ON()) return { reply: REFUEL_OFF_ANSWER, canned: true, kb: hit.id }; + if (hit && (hit.id === 'polminer' || hit.id === 'c-polminer') && !pmLive()) return { reply: POLMINER_SOON_ANSWER, canned: true, kb: hit.id }; if (hit && (hit.id === 'network-rate' || hit.id === 'c-network-rate') && SYN_N() !== 4) return { reply: netRateAnswer(SYN_N()), canned: true, kb: hit.id }; if (hit) return Object.assign({ reply: hit.answer, canned: true, kb: hit.id }, hit.handoff ? { handoff: true } : {}); - if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {}); + if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'polminer' && !pmLive() ? { reply: POLMINER_SOON_ANSWER, canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {}); // retrieval: the closest entries ride along in the system prompt (a short follow-up borrows words from the chat so far) let kbBlock = '', kbIds = []; try { const query = msg.split(/\s+/).length < 4 && historyText ? msg + ' ' + String(historyText).slice(-200) : msg; const hits = await kb.context(query, 5); - kbBlock = kb.promptBlock(hits); kbIds = hits.map(h => h.entry.id); + const hitsOk = pmLive() ? hits : hits.filter(h => !/^(c-)?polminer$/.test(String(h.entry && h.entry.id))); // not live yet: keep its answer out of the prompt + kbBlock = kb.promptBlock(hitsOk); kbIds = hitsOk.map(h => h.entry.id); } catch (e) { console.error('kb search', e.message); } if (!enabled()) return { reply: 'Good question. The quick answers I have cover packages, payouts, qualification, and joining; for anything deeper, the plain-language contract review at https://instantadpay.com/contract covers most of it, or tap "Send this to support" and Marty will answer.', handoff: true }; // One retry: the usual failure is a single provider dropping the request, and asking diff --git a/gamestats.js b/gamestats.js index bb1d317..33e7cc1 100644 --- a/gamestats.js +++ b/gamestats.js @@ -10,7 +10,7 @@ const fs = require('fs'); const path = require('path'); let R = null; -const NAMES = { spookydoors: 'Spooky Doors', gemkingdom: 'Gem Kingdom', clutterhunt: 'ClutterHunt', driprunner: 'Drip Runner', polywarriors: 'PolyWarriors', spellwheel: 'SpellWheel', roadagent: 'Road Agent', polhunter: 'PolHunter', passivedrip: 'PassiveDrip', polybreak: 'PolyBreak', shardsofvalor: 'Shards of Valor' }; +const NAMES = { spookydoors: 'Spooky Doors', gemkingdom: 'Gem Kingdom', clutterhunt: 'ClutterHunt', driprunner: 'Drip Runner', polywarriors: 'PolyWarriors', spellwheel: 'SpellWheel', roadagent: 'Road Agent', polhunter: 'PolHunter', passivedrip: 'PassiveDrip', polybreak: 'PolyBreak', polminer: 'POL Miner', shardsofvalor: 'Shards of Valor' }; const wallets = () => Object.fromEntries(String(process.env.GAME_WALLETS || '').split(',').map(x => x.trim()).filter(Boolean).map(x => { const [k, a] = x.split(':'); return [String(k).toLowerCase(), String(a || '').toLowerCase()]; }).filter(([k, a]) => k && /^0x[0-9a-f]{40}$/.test(a))); const KEY = () => String(process.env.ETHERSCAN_KEY || '').trim(); // money never flows to these from a game wallet as a payout: Marty's fee wallets, the other game wallets diff --git a/public/assets/my.js b/public/assets/my.js index 0d488c3..74d4057 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -932,6 +932,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str if (me.returnTo === 'gkshop' && !render.toGame) { render.toGame = true; location.href = '/gk/shop/resume'; return; } if (me.returnTo === 'spookydoors' && !render.toGame) { render.toGame = true; location.href = '/api/my/spookydoors'; return; } // Spooky Doors sent them here to sign in (2026-10-02) if (me.returnTo === 'polybreak' && !render.toGame) { render.toGame = true; location.href = '/api/my/polybreak'; return; } // PolyBreak sent them here to sign in (2026-10-13) + if (me.returnTo === 'polminer' && !render.toGame) { render.toGame = true; location.href = '/api/my/polminer'; return; } // POL Miner sent them here to sign in (2026-10-28) if (me.returnTo === 'shardsofvalor' && !render.toGame) { render.toGame = true; location.href = '/api/my/shardsofvalor'; return; } // Shards of Valor sent them here to sign in (2026-10-18) if (me.returnTo === 'pwmint' && !render.toGame) { render.toGame = true; location.href = '/pw/mint/resume'; return; } // PolyWarriors paid mint (2026-10-05) if (me.pwMint && !me.gkShop && !me.sdShop && !document.getElementById('pwBack')) { const d = document.createElement('a'); d.id = 'pwBack'; document.body.classList.add('hasback'); d.href = '/pw/mint/resume'; d.textContent = 'PolyWarriors mint: buy a package and you go straight back to the game when it settles. Or go back now →'; d.setAttribute('style', 'position:fixed;left:12px;right:12px;bottom:14px;z-index:9999;display:block;padding:14px 44px 14px 16px;border-radius:14px;background:linear-gradient(180deg,#22E5FF,#7A2CFF);color:#fff;font-weight:800;text-align:center;text-decoration:none;box-shadow:0 10px 30px rgba(0,0,0,.45)'); document.body.appendChild(d); diff --git a/public/my.html b/public/my.html index e129c8d..ae5238c 100644 --- a/public/my.html +++ b/public/my.html @@ -1223,7 +1223,7 @@ - + diff --git a/server.js b/server.js index b2cc149..0ccd546 100644 --- a/server.js +++ b/server.js @@ -551,7 +551,7 @@ async function boot() { messages.init({ dataDir: DATA_DIR }); reports.init({ dataDir: DATA_DIR }); drip.init({ dataDir: DATA_DIR, mailer, accounts, chain, site: 'https://instantadpay.com' }); - chatbot.init({ dataDir: DATA_DIR, chain, refuelOn: () => refuel.cfg().on, passTiers: () => { const c = gamepass.cfg(); return { on: c.enabled && c.tierSales, rows: gamepass.TIER_DEFS.filter(d => d.key !== 'weekly').map(d => ({ name: d.name, perks: d.perks, price: c.tiers[d.key].price, usd: c.tiers[d.key].price / 100, days: c.tiers[d.key].days, sale: c.tiers[d.key].sale })) }; } }); // pass tiers fact follows sovTiers (2026-10-22) + chatbot.init({ dataDir: DATA_DIR, chain, gameLive: slug => String(siteConfig().gamesLive == null ? 'polhunter' : siteConfig().gamesLive).split(',').map(x => x.trim().toLowerCase()).includes(slug), refuelOn: () => refuel.cfg().on, passTiers: () => { const c = gamepass.cfg(); return { on: c.enabled && c.tierSales, rows: gamepass.TIER_DEFS.filter(d => d.key !== 'weekly').map(d => ({ name: d.name, perks: d.perks, price: c.tiers[d.key].price, usd: c.tiers[d.key].price / 100, days: c.tiers[d.key].days, sale: c.tiers[d.key].sale })) }; } }); // pass tiers fact follows sovTiers (2026-10-22) setTimeout(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 1000); setInterval(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 60 * 1000); setInterval(() => ads.scheduleSweep().catch(e => console.error('schedule sweep', e.message)), 5 * 60 * 1000); // scheduled starts/ends @@ -745,7 +745,7 @@ async function boot() { // Game Pass partner helpers (2026-10-16): which secret signs for which game, signature compare, member resolution, dev clock const GP_SECRETS = () => ({ polhunter: String(process.env.HUNT_SSO_SECRET || '').trim(), gemkingdom: GK_SECRET(), spellwheel: SW_SECRET(), spookydoors: SD_SECRET(), polywarriors: PW_SECRET(), - clutterhunt: SEEK_SECRET(), polybreak: PB_SECRET(), driprunner: DR_SECRET(), roadagent: RA_SECRET(), shardsofvalor: SOV_SECRET() }); + clutterhunt: SEEK_SECRET(), polybreak: PB_SECRET(), polminer: PM_SECRET(), driprunner: DR_SECRET(), roadagent: RA_SECRET(), shardsofvalor: SOV_SECRET() }); function gpPartnerCheck(game) { if (!gamepass.GAMES.includes(game)) return { error: 'unknown game', code: 400 }; const secret = GP_SECRETS()[game] || ''; if (secret.length < 32) return { error: game + ' is not connected', code: 503 }; return { secret }; } const gpSigOk = (want, got) => typeof got === 'string' && want.length === got.length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(got)); async function gpResolve(memberId, email) { // the account behind a game's player: main member id, a linked position's id, or (no wallet yet) the email @@ -1724,6 +1724,28 @@ async function pbCallback(cbUrl, receipt) { if (!pbIsGameUrl(cbUrl)) return false; try { const r = await fetch(cbUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ t: receipt }), signal: AbortSignal.timeout(8000) }); return r.ok; } catch (e) { console.warn('polybreak callback', e.message); return false; } } +// -- POL Miner (2026-10-28): the dig-down mining game; its own secret POLMINER_SSO_SECRET (also on the game), same shape as PolyBreak. +// Members see nothing until 'polminer' is in site config gamesLive (Games card, strip); the hand-off, in-game sign-in and supply +// crates work as soon as the secret is set, so testers can play behind the game's own staging gate. +const PM_SECRET = () => String(process.env.POLMINER_SSO_SECRET || '').trim(); +const PM_URL = () => String(process.env.POLMINER_URL || 'https://polminer.com').replace(/\/+$/, ''); +const PM_ALT = () => String(process.env.POLMINER_ALT_URLS || 'https://www.polminer.com,https://polminer.saasy.top').split(',').map(x => x.trim().replace(/\/+$/, '')).filter(Boolean); +const pmSign = p => drB64u(crypto.createHmac('sha256', PM_SECRET()).update(p).digest()); +function pmMint(claims, ttlMs) { const payload = JSON.stringify(Object.assign({ iat: Date.now(), exp: Date.now() + (ttlMs || 300000), nonce: crypto.randomBytes(12).toString('hex') }, claims, gpClaim(claims))); return drB64u(payload) + '.' + pmSign(payload); } +function pmOpen(token) { + if (PM_SECRET().length < 32) return { error: 'POL Miner is not connected yet.' }; + const [p, sig] = String(token || '').split('.'); if (!p || !sig) return { error: 'That link is not valid.' }; + let payload; try { payload = Buffer.from(String(p).replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf8'); } catch (e) { return { error: 'That link is not valid.' }; } + const want = pmSign(payload); if (want.length !== sig.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig))) return { error: 'That link is not valid.' }; + let c; try { c = JSON.parse(payload); } catch (e) { return { error: 'That link is not valid.' }; } + if (!c.exp || Date.now() > c.exp) return { error: 'That link has expired. Go back to POL Miner and tap the supply crate again.' }; + return { ok: true, claims: c }; +} +const pmIsGameUrl = u => [PM_URL()].concat(PM_ALT()).some(o => String(u || '').startsWith(o + '/')); +async function pmCallback(cbUrl, receipt) { + if (!pmIsGameUrl(cbUrl)) return false; + try { const r = await fetch(cbUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ t: receipt }), signal: AbortSignal.timeout(8000) }); return r.ok; } catch (e) { console.warn('polminer callback', e.message); return false; } +} // -- PolyWarriors (2026-10-05): the cyberpunk fighting game at polywarriors.com; its own secret PW_SSO_SECRET (also on the game) const PW_SECRET = () => String(process.env.PW_SSO_SECRET || '').trim(); const PW_URL = () => String(process.env.PW_URL || 'https://polywarriors.com').replace(/\/+$/, ''); @@ -1919,6 +1941,9 @@ function GAMES() { // PolyBreak (2026-10-13): the brick breaker; first round clears and the purple Polygon gem pay POL { slug: 'polybreak', name: 'PolyBreak', tag: 'Brick breaker', blurb: 'Break walls of glass jewel bricks with the classic arcade capsules, and catch the purple Polygon gem when it falls. First clears of each round pay POL.', art: 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/polybreak/og-polybreak-clean.jpg', play: '/api/my/polybreak', pays: 'POL for first round clears and gem catches' }, + // POL Miner (2026-10-28): dig down, beat the drill bosses, find the rare Polygon crystals (hidden until gamesLive has 'polminer') + { slug: 'polminer', name: 'POL Miner', tag: 'Mining adventure', blurb: 'Dig down through the layers, haul ore to sell, upgrade your pick, lamp and cart, and beat a drill boss every 30 m. Rare pink Polygon crystals pay POL.', + art: PM_URL() + '/og-polminer.jpg?v=1', play: '/api/my/polminer', pays: 'POL for Polygon crystals, first boss wins and depth records' }, ]); } // each game's member perk (the $5 welcome offer, 2026-10-05) shown on its card @@ -1932,6 +1957,7 @@ const STRIP = () => ({ polhunter: { line: 'Find hidden codes on sites across the network. Every find drips POL.', open: 'https://polhunter.com/', host: 'polhunter.com' }, clutterhunt: { line: 'Search cozy, cluttered rooms for hidden objects. New rooms every season.', open: SEEK_URL() + '/', host: SEEK_URL().replace(/^https?:\/\//, '') }, polybreak: { line: 'Break the glass jewel wall, catch the capsules and the purple Polygon gem. First clears pay POL.', open: PB_URL() + '/', host: PB_URL().replace(/^https?:\/\//, '') }, + polminer: { line: 'Dig deep, beat the drill bosses, find the rare pink Polygon crystals. Crystals pay POL.', open: PM_URL() + '/', host: PM_URL().replace(/^https?:\/\//, '') }, spellwheel: { line: 'Swipe the letter wheel, fill the grid, solve the daily puzzle. Levels and dailies pay POL.', open: SW_URL() + '/', host: SW_URL().replace(/^https?:\/\//, '') }, polywarriors: { line: 'Recruit one-of-a-kind warriors, fight the arena, challenge members. First wins pay POL.', open: PW_URL() + '/', host: PW_URL().replace(/^https?:\/\//, '') }, }); @@ -1999,6 +2025,8 @@ const GAME_AUTH = { mint: (a, memberId) => seekMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null }) }, polybreak: { name: 'PolyBreak', frames: false, origins: () => [PB_URL()].concat(PB_ALT()), host: () => PB_URL().replace(/^https?:\/\//, ''), mint: (a, memberId) => pbMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null, sponsorRef: a.sponsorRef || null }) }, + polminer: { name: 'POL Miner', frames: false, origins: () => [PM_URL()].concat(PM_ALT()), host: () => PM_URL().replace(/^https?:\/\//, ''), + mint: (a, memberId) => pmMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null, sponsorRef: a.sponsorRef || null }) }, spellwheel: { name: 'SpellWheel', origins: () => [SW_URL()].concat(SW_ALT()), host: () => SW_URL().replace(/^https?:\/\//, ''), mint: (a, memberId) => swMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null }) }, polywarriors: { name: 'PolyWarriors', origins: () => [PW_URL()].concat(PW_ALT()), host: () => PW_URL().replace(/^https?:\/\//, ''), @@ -2550,7 +2578,7 @@ const server = http.createServer(async (req, res) => { let memberId = 0; if (r.account.address) { try { memberId = await chain.memberIdByAccount(r.account.address); } catch (err) {} } const token = await auth.mintSession({ email: r.account.email, address: r.account.address, memberId }); - return json(res, 200, { ok: true, account: r.account, created: !!r.created, next: ({ clutterhunt: '/api/my/clutterhunt', spellwheel: '/api/my/spellwheel', polybreak: '/api/my/polybreak', polywarriors: '/api/my/polywarriors', driprunner: '/api/my/driprunner', passivedrip: '/api/my/passivedrip', gemkingdom: '/api/my/gemkingdom', gkshop: '/gk/shop/resume', spookydoors: '/api/my/spookydoors', sdshop: '/sd/shop/resume' })[parseCookies(req)['iap.return']] || null }, { 'Set-Cookie': auth.sessionCookie(token) }); // next: Drip Runner sent them here to sign in (2026-09-30) + return json(res, 200, { ok: true, account: r.account, created: !!r.created, next: ({ clutterhunt: '/api/my/clutterhunt', spellwheel: '/api/my/spellwheel', polybreak: '/api/my/polybreak', polminer: '/api/my/polminer', polywarriors: '/api/my/polywarriors', driprunner: '/api/my/driprunner', passivedrip: '/api/my/passivedrip', gemkingdom: '/api/my/gemkingdom', gkshop: '/gk/shop/resume', spookydoors: '/api/my/spookydoors', sdshop: '/sd/shop/resume' })[parseCookies(req)['iap.return']] || null }, { 'Set-Cookie': auth.sessionCookie(token) }); // next: Drip Runner sent them here to sign in (2026-09-30) } // -- in-game sign-in (2026-10-03): see GAME_AUTH. Mirrors /api/auth/email/start + verify, minus cookies. @@ -2749,7 +2777,7 @@ const server = http.createServer(async (req, res) => { if (tankHold) sponsorBlocked = 'tankHold'; else if (!sponsorId && memberId !== _defSpon) { sponsorId = _defSpon; sponsorFallback = true; } // orphan fallback → #1 (never self-sponsor) if (memberId && acct && acct.memberId !== memberId) accounts.setMemberId(acct.email, memberId).catch(() => {}); - const out = { signedIn: true, gkShop: !!parseCookies(req)['iap.gkshop'], sdShop: !!parseCookies(req)['iap.sdshop'], pwMint: !!parseCookies(req)['iap.pwmint'], returnTo: ['polhunter', 'driprunner', 'passivedrip', 'gemkingdom', 'gkshop', 'spookydoors', 'sdshop', 'pwmint', 'polybreak', 'shardsofvalor'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : null, sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null, + const out = { signedIn: true, gkShop: !!parseCookies(req)['iap.gkshop'], sdShop: !!parseCookies(req)['iap.sdshop'], pwMint: !!parseCookies(req)['iap.pwmint'], returnTo: ['polhunter', 'driprunner', 'passivedrip', 'gemkingdom', 'gkshop', 'spookydoors', 'sdshop', 'pwmint', 'polybreak', 'polminer', 'shardsofvalor'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : null, sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null, address: s.address || (acct && acct.address) || null, memberId, username: (acct && acct.username) || null, refCode: (acct && acct.code) || null, sponsorId, tankHold, sponsorFallback, @@ -3640,6 +3668,15 @@ const server = http.createServer(async (req, res) => { const tok = pbMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null, sponsorRef: (acct && acct.sponsorRef) || null }); res.writeHead(302, { Location: PB_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.return', '', 0) }); return res.end(); } + // -- POL Miner hand-off (2026-10-28): sign the member across; the game verifies with POLMINER_SSO_SECRET + if (p === '/api/my/polminer' && req.method === 'GET') { gamestats.handoff('polminer'); + const s = await auth.fromRequest(req); + if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'polminer', 1800), 'Cache-Control': 'no-store' }); return res.end(); } + if (PM_SECRET().length < 32) return json(res, 503, { error: 'POL Miner is not connected yet.' }); + const acct = await accounts.byEmail(s.email); + const tok = pmMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null, sponsorRef: (acct && acct.sponsorRef) || null }); + res.writeHead(302, { Location: PM_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.return', '', 0) }); return res.end(); + } if (p === '/api/my/spellwheel' && req.method === 'GET') { gamestats.handoff('spellwheel'); const s = await auth.fromRequest(req); if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'spellwheel', 1800), 'Cache-Control': 'no-store' }); return res.end(); } @@ -3911,13 +3948,15 @@ const server = http.createServer(async (req, res) => { if (r.error) { const g = seekOpen(u.searchParams.get('t')); if (!g.error && g.claims.game === 'seek') { r = g; game = 'seek'; } } if (r.error) { const g = swOpen(u.searchParams.get('t')); if (!g.error && g.claims.game === 'spellwheel') { r = g; game = 'spellwheel'; } } if (r.error) { const g = pbOpen(u.searchParams.get('t')); if (!g.error && g.claims.game === 'polybreak') { r = g; game = 'polybreak'; } } + if (r.error) { const g = pmOpen(u.searchParams.get('t')); if (!g.error && g.claims.game === 'polminer') { r = g; game = 'polminer'; } } if (r.error) return json(res, 400, { error: r.error }); const c = r.claims; if (c.kind !== 'refuel' || !c.nonce || !c.email || !c.ret) return json(res, 400, { error: 'That is not a refuel link.' }); if (game === 'gemkingdom' && !String(c.ret).startsWith(GK_URL() + '/')) return json(res, 400, { error: 'That is not a Gem Kingdom link.' }); if (game === 'seek' && !seekIsGameUrl(c.ret)) return json(res, 400, { error: 'That is not a ClutterHunt link.' }); if (game === 'spellwheel' && !swIsGameUrl(c.ret)) return json(res, 400, { error: 'That is not a SpellWheel link.' }); if (game === 'polybreak' && !pbIsGameUrl(c.ret)) return json(res, 400, { error: 'That is not a PolyBreak link.' }); - const G = game === 'polybreak' ? { game: 'PolyBreak', label: 'one more paddle' } : game === 'gemkingdom' ? { game: 'Gem Kingdom', label: 'continue' } : game === 'seek' ? { game: 'ClutterHunt', label: 'hint' } : game === 'spellwheel' ? { game: 'SpellWheel', label: 'hint' } : { game: 'Drip Runner', label: 'refuel' }; + if (game === 'polminer' && !pmIsGameUrl(c.ret)) return json(res, 400, { error: 'That is not a POL Miner link.' }); + const G = game === 'polminer' ? { game: 'POL Miner', label: 'supply crate' } : game === 'polybreak' ? { game: 'PolyBreak', label: 'one more paddle' } : game === 'gemkingdom' ? { game: 'Gem Kingdom', label: 'continue' } : game === 'seek' ? { game: 'ClutterHunt', label: 'hint' } : game === 'spellwheel' ? { game: 'SpellWheel', label: 'hint' } : { game: 'Drip Runner', label: 'refuel' }; for (const [n, v] of refuelTokens) if (v.ts + 30 * 60000 < Date.now()) refuelTokens.delete(n); let t = refuelTokens.get(c.nonce); if (t && t.done) return json(res, 200, Object.assign({ done: true, ret: t.doneRet || t.ret }, G)); @@ -3960,12 +3999,18 @@ const server = http.createServer(async (req, res) => { if (!tier) return json(res, 400, { error: 'That video just ran out of budget. Go back and try again.' }); await ads.markVideoSeen(t.email, t.id); credits = tier.cost; } else { - const r = await ads.completeVisit(t.email, t.id, { reward: false, note: t.game === 'polybreak' ? 'PolyBreak paddle' : t.game === 'gemkingdom' ? 'Gem Kingdom continue' : t.game === 'seek' ? 'ClutterHunt hint' : t.game === 'spellwheel' ? 'SpellWheel hint' : 'Drip Runner refuel' }); + const r = await ads.completeVisit(t.email, t.id, { reward: false, note: t.game === 'polminer' ? 'POL Miner supply crate' : t.game === 'polybreak' ? 'PolyBreak paddle' : t.game === 'gemkingdom' ? 'Gem Kingdom continue' : t.game === 'seek' ? 'ClutterHunt hint' : t.game === 'spellwheel' ? 'SpellWheel hint' : 'Drip Runner refuel' }); if (r.error) return json(res, 400, r); credits = ads.rates().visitCostPerVisit || 3; { const camp = await ads.campaignById(t.id).catch(() => null); if (camp && camp.house) credits = 0; } // a house ad costs nobody anything: no POL pool income (2026-10-03) } t.done = true; + if (t.game === 'polminer') { // POL Miner supply crate: signed receipt to the game's callback and on the ret page (the crate is a gameplay boost, never POL) + const receipt = pmMint({ kind: 'pm-crate', nonce, email: t.email, campaignId: t.id, credits }, 15 * 60000); + const posted = await pmCallback(t.cb, receipt); + t.doneRet = t.ret + (t.ret.includes('?') ? '&' : '?') + 'ok=1&r=' + encodeURIComponent(receipt); + return json(res, 200, { ok: true, posted, ret: t.doneRet, game: 'POL Miner', label: 'supply crate' }); + } if (t.game === 'polybreak') { // PolyBreak one more paddle: signed receipt to the game's callback and on the ret page const receipt = pbMint({ kind: 'pb-paddle', nonce, email: t.email, campaignId: t.id, credits }, 15 * 60000); const posted = await pbCallback(t.cb, receipt); diff --git a/walletnudge.js b/walletnudge.js index 8ee2d35..dd6f52e 100644 --- a/walletnudge.js +++ b/walletnudge.js @@ -34,6 +34,7 @@ function games() { { key: 'driprunner', name: 'Drip Runner', url: process.env.DR_URL, secret: process.env.DR_SSO_SECRET }, { key: 'roadagent', name: 'Road Agent', url: process.env.RA_URL, secret: process.env.RA_SSO_SECRET }, { key: 'polybreak', name: 'PolyBreak', url: process.env.PB_URL || 'https://polybreak.app', secret: process.env.PB_SSO_SECRET }, + { key: 'polminer', name: 'POL Miner', url: process.env.POLMINER_URL || 'https://polminer.com', secret: process.env.POLMINER_SSO_SECRET }, // 2026-10-28: idle until POLMINER_SSO_SECRET is set { key: 'spellwheel', name: 'SpellWheel', url: process.env.SW_URL || 'https://spellwheel.com', secret: process.env.SW_SSO_SECRET }, { key: 'polywarriors', name: 'PolyWarriors', url: process.env.PW_URL || 'https://polywarriors.com', secret: process.env.PW_SSO_SECRET } ].filter(g => g.url && g.secret && String(g.secret).trim().length >= 32);