<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[jas845323]]></title><description><![CDATA[jas845323]]></description><link>https://jas845323.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 20:28:48 GMT</lastBuildDate><atom:link href="https://jas845323.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Migrating a Chrome & Firefox MV3 Extension from Lemon Squeezy to Polar.sh (Zero Backend, API Mapping & Tradeoffs)]]></title><description><![CDATA[Lemon Squeezy permanently closed new store sign-ups on November 16, 2026, launches its Stripe Managed Payments migration tooling on December 2, 2026, and…]]></description><link>https://jas845323.hashnode.dev/migrating-a-chrome-firefox-mv3-extension-from-lemon-squeezy-to-polar-sh-zero-backend-api-mapping-tradeoffs</link><guid isPermaLink="true">https://jas845323.hashnode.dev/migrating-a-chrome-firefox-mv3-extension-from-lemon-squeezy-to-polar-sh-zero-backend-api-mapping-tradeoffs</guid><category><![CDATA[chrome extension]]></category><category><![CDATA[indie hackers]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[鄧傑笙]]></dc:creator><pubDate>Fri, 27 Nov 2026 13:50:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b098835a8a55c2865aea990/cccc0b74-94c0-4e0e-bc4f-1fa40999ee74.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lemon Squeezy permanently closed new store sign-ups on <strong>November 16, 2026</strong>, launches its Stripe Managed Payments migration tooling on <strong>December 2, 2026</strong>, and will stop processing payments, renewals, checkout links, webhooks, and <strong>license key validation on March 31, 2027</strong>.</p>
<p>Because Stripe Managed Payments does not include built-in software license key generation or validation, Chrome and Firefox extension developers who relied on Lemon Squeezy's License API need a replacement that doesn't force them to run a backend server and database.</p>
<p>When Lemon Squeezy announced its sunset, I built a paid Manifest V3 browser extension directly on <strong>Polar.sh</strong> and mapped out the exact API differences, MV3 pitfalls, and client-side security tradeoffs for developers moving over.</p>
<h2>1. Endpoint &amp; Parameter Mapping: Lemon Squeezy → Polar.sh</h2>
<p>Polar.sh exposes <strong>unauthenticated Customer Portal license endpoints</strong> that only require your public <code>organization_id</code> (UUID) — so you never embed a secret API token in your extension bundle.</p>
<table>
<thead>
<tr>
<th align="left">Action</th>
<th align="left">Lemon Squeezy (<code>api.lemonsqueezy.com</code>)</th>
<th align="left">Polar.sh (<code>api.polar.sh</code>)</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Activate</td>
<td align="left"><code>POST /v1/licenses/activate</code></td>
<td align="left"><code>POST /v1/customer-portal/license-keys/activate</code></td>
</tr>
<tr>
<td align="left">Validate</td>
<td align="left"><code>POST /v1/licenses/validate</code></td>
<td align="left"><code>POST /v1/customer-portal/license-keys/validate</code></td>
</tr>
<tr>
<td align="left">Deactivate</td>
<td align="left"><code>POST /v1/licenses/deactivate</code></td>
<td align="left"><code>POST /v1/customer-portal/license-keys/deactivate</code></td>
</tr>
</tbody></table>
<p>Payload &amp; Header Mapping:</p>
<ul>
<li><code>Content-Type</code>: <code>application/x-www-form-urlencoded</code> → <code>application/json</code></li>
<li><code>license_key</code> → <code>key</code></li>
<li>Add <code>organization_id</code> (required on all 3 endpoints)</li>
<li><code>instance_name</code> → <code>label</code> (required on <code>/activate</code>)</li>
<li><code>instance_id</code> → <code>activation_id</code> (required on <code>/deactivate</code>; only needed on <code>/validate</code> when activation limits are enabled)</li>
<li>Optional <code>benefit_id</code> (UUIDv4): strongly recommended when selling multiple tiers or extensions under one Polar org so a cheaper product's key cannot unlock another tier.</li>
</ul>
<pre><code class="language-ts">// 1. Activate a device slot (required only when activation limits are enabled)
const activateRes = await fetch(
  'https://api.polar.sh/v1/customer-portal/license-keys/activate',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      key: licenseKey,
      organization_id: POLAR_PUBLIC_ORG_ID,
      benefit_id: EXPECTED_PRO_BENEFIT_ID,
      label: `Chrome Extension – ${deviceId}`,
    }),
  },
);
const activation = await activateRes.json();

// 2. Validate on startup / daily chrome.alarms schedule
const validateRes = await fetch(
  'https://api.polar.sh/v1/customer-portal/license-keys/validate',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      key: licenseKey,
      organization_id: POLAR_PUBLIC_ORG_ID,
      benefit_id: EXPECTED_PRO_BENEFIT_ID,
      ...(activationId ? { activation_id: activationId } : {}),
    }),
  },
);
const data = await validateRes.json();
</code></pre>
<p>Don't forget <code>host_permissions</code> in <code>manifest.json</code>:</p>
<pre><code class="language-json">"host_permissions": [
  "https://api.polar.sh/*",
  "https://sandbox-api.polar.sh/*"
]
</code></pre>
<h2>2. Five MV3 + Polar Gotchas That Will Break Your Licensing Flow</h2>
<ol>
<li><strong>Per-minute IP rate limits (<code>429</code> with <code>retry-after: ~41s</code>)</strong>:
Don't validate on every popup open. Persist license state in <code>chrome.storage.local</code> (Service Worker globals vanish after ~30s), revalidate daily via <code>chrome.alarms</code>, and keep Pro unlocked during transient <code>TypeError</code> / <code>429</code> / <code>5xx</code> errors inside a 72-hour offline grace window.</li>
<li><strong>Monotonic backwards-clock tamper guard</strong>:
A naive <code>Date.now() - lastValidatedAt &lt; 72h</code> check stays valid forever if someone rolls their system clock backward. Reject grace access whenever <code>now + 60_000 &lt; lastValidatedAt</code>.</li>
<li><strong>Check <code>status</code> vs. <code>expires_at</code> by billing model</strong>:
For subscriptions, check <code>data.status === 'granted'</code> (Polar flips it to <code>revoked</code>/<code>disabled</code> on cancel or refund). For one-time keys with fixed validity, check both <code>status === 'granted'</code> and <code>expires_at</code>.</li>
<li><strong><code>activeTab</code> does not work reliably from Chrome Side Panel buttons</strong>:
Use <code>tabs</code> + scoped <code>host_permissions</code> instead. For Firefox MV3, strip <code>sidePanel</code>, map <code>side_panel</code> → <code>sidebar_action</code>, switch <code>background.service_worker</code> → <code>background.scripts</code>, and declare <code>browser_specific_settings.gecko</code>.</li>
<li><strong>Migrating existing Lemon Squeezy buyers with <code>$0</code> checkout (stays zero-backend)</strong>:
Export your LS customer, order, and license CSVs well before March 31, 2027. Verified live on <code>sandbox.polar.sh</code>: a 100% off discount drops checkout to <code>$0</code>, hides the credit card form completely, and immediately grants a fresh Polar key. For larger lists, run a local one-off script calling <code>POST /v1/discounts/</code> (<code>basis_points: 10000</code>, <code>max_redemptions: 1</code>, <code>ends_at</code>) with a local <code>discounts:write</code> token (never bundled in your extension) so shared codes can't leak. <em>(Note: PayPal subscriptions on LS cannot migrate automatically.)</em></li>
</ol>
<h2>3. Honest Security Tradeoff</h2>
<p>Any purely client-side check in a browser extension can be bypassed locally with DevTools. Zero-backend validation is a practical tradeoff for <code>$5–$29</code> local utility extensions with <code>$0</code> marginal server cost per user. If your extension proxies paid LLM APIs or proprietary backend databases, validate the Polar key on your backend before forwarding paid calls.</p>
<h2>Interactive Migration Console &amp; Working Reference</h2>
<ul>
<li>Interactive <strong>LS → Polar <code>#swap</code> diff console</strong> (plug in your own <code>organization_id</code>/<code>benefit_id</code>), <strong>live in-browser extension simulator</strong>, and the <strong>$19 PolarExt v1.2 starter kit</strong> (Chrome + Firefox MV3, 29 Vitest tests, Cursor/Claude Code rules): <a href="https://jas845323.github.io/polarext/?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=ls_sunset">https://jas845323.github.io/polarext/?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=ls_sunset</a></li>
<li>Standalone reference sheet: <a href="https://jas845323.github.io/polarext/lemon-squeezy-to-polar-migration.html">https://jas845323.github.io/polarext/lemon-squeezy-to-polar-migration.html</a></li>
</ul>
]]></content:encoded></item></channel></rss>