SkateSpots/src/lib/sasquatchPro.ts
shakespeare.diy 79d1d47823 Sasquatch Pro Phase 3: npub-bound Lightning paywall + gating
Adds the Sasquatch Pro supporter pass with strong, forge-resistant
verification bound to the paying user's npub — no backend required.

Verification (useSasquatchPro):
- STRONG: NIP-57 zap receipt (kind 9735). Purchase signs a zap request
  tagged pro-tier/pro-expiry; the receipt embeds it, cryptographically
  binding payment → identity (unforgeable by the user).
- FALLBACK: self-signed kind-32671 receipt so paying users are never
  locked out if the provider emits no zap receipt.
- Platform owners always Pro. Access = max unexpired expiry.

Purchase (usePurchasePro):
- Zap to skatespots@minibits.cash (falls back to plain invoice), pay via
  NWC → WebLN → manual QR. Publishes the fallback receipt on success.

Pricing (sasquatchPro.ts): 4 tiers — 7d/2k, 1mo/5k, 3mo/12k (popular),
1yr/36k sats.

UI (SasquatchProDialog): upgrade sheet with tiers, perk list, QR
fallback, "already Pro" state, extend flow.

Gating (SasquatchGuide):
- Personal tools (get_my_*) now require login + Pro; prompt only exposes
  them to Pro users; tool switch guards with a pro_required nudge.
- ⚡ Pro badge when active, ⚡ Go Pro button otherwise; local upgrade
  nudge for "my/mine" questions from non-Pro users.

Docs: kind 32671 + verification model documented in NIP.md.

Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
2026-07-29 23:33:39 +07:00

43 lines
1.9 KiB
TypeScript

/**
* Sasquatch Pro — pricing tiers + shared constants.
* ─────────────────────────────────────────────────────────────────────────────
* Pro is a Lightning "supporter pass" that unlocks Sasquatch's personal
* assistant, action-drafting, priority model, and perks. Payment goes to the
* platform Lightning address via a NIP-57 zap, and access is verified two ways:
*
* 1. STRONG (preferred): a kind-9735 zap receipt from the platform's Lightning
* provider, bound to the paying user's npub — unforgeable by the user.
* 2. FALLBACK: a self-signed kind-32671 membership receipt (used only if the
* provider doesn't publish zap receipts), which references the payment so a
* future verifier can validate it retroactively.
*/
/** Platform Lightning address that receives Pro payments. */
export const PRO_LIGHTNING_ADDRESS = 'skatespots@minibits.cash';
export interface ProTier {
id: string;
label: string;
days: number;
sats: number;
/** Approx USD at ~$60k/BTC, for display only. */
usd: string;
/** Marketing flag. */
badge?: string;
popular?: boolean;
}
/** The four supporter tiers. Kept deliberately small to avoid choice paralysis. */
export const PRO_TIERS: ProTier[] = [
{ id: '7d', label: '7 days', days: 7, sats: 2000, usd: '~$1.20', badge: 'Try it' },
{ id: '1m', label: '1 month', days: 30, sats: 5000, usd: '~$3' },
{ id: '3m', label: '3 months', days: 90, sats: 12000, usd: '~$7', badge: '20% off', popular: true },
{ id: '1y', label: '1 year', days: 365, sats: 36000, usd: '~$21', badge: 'Best value · 40% off' },
];
export function tierById(id: string): ProTier | undefined {
return PRO_TIERS.find((t) => t.id === id);
}
/** Seconds in a day. */
export const DAY_SECONDS = 24 * 60 * 60;