<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: PermitCore</title>
    <description>The latest articles on DEV Community by PermitCore (@permitcore).</description>
    <link>https://dev.to/permitcore</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4119717%2F8a675fea-fa4b-4688-b41b-64247900bc69.png</url>
      <title>DEV Community: PermitCore</title>
      <link>https://dev.to/permitcore</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/permitcore"/>
    <language>en</language>
    <item>
      <title>Selling an Android App Outside Google Play in 2027: Verification, License Keys and Offline Checks</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Tue, 01 Dec 2026 09:45:24 +0000</pubDate>
      <link>https://dev.to/permitcore/selling-an-android-app-outside-google-play-in-2027-verification-license-keys-and-offline-checks-4n0e</link>
      <guid>https://dev.to/permitcore/selling-an-android-app-outside-google-play-in-2027-verification-license-keys-and-offline-checks-4n0e</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/sell-android-app-outside-google-play" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On 19 November 2026 Google announced that Android developer verification goes global in January 2027. Over the following months, apps from every installation source on certified Android devices, including an APK downloaded from your own website, will need to be registered by a developer whose identity Google has verified. If you sell an Android app, a Unity or Godot game build or a companion app outside Google Play, this changes how your customers install it. It does not change how you get paid or how you stop one purchase from turning into fifty installs.&lt;/p&gt;

&lt;p&gt;This guide is for indie developers and small studios who sell Android software directly: from their own site, itch.io, Galaxy Store or another store. It explains what verification requires and what it does not do, then walks through a direct-sale setup: checkout and VAT, delivering the download and the license key, activating the key on a phone without Google Play Licensing, offline use, phone swaps and refunds, and where the check goes in Kotlin, Unity and Godot. It ends with a checklist for January. The Google rules below were checked against Google's own pages on 29 November 2026; the links are listed at the end. Nothing here is legal or tax advice.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changes in 2027: Android developer verification in plain words
&lt;/h2&gt;

&lt;p&gt;Developer verification links every Android app to a real, identified person or organization. Google states that Android "requires all apps to be registered by verified developers for users to install them on certified Android devices". Certified devices are the ones that ship with Google Play services, and the FAQ says enforcement covers certified devices running Android 8 (API level 26) or higher.&lt;/p&gt;

&lt;h3&gt;
  
  
  Timeline
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;What happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;March 2026&lt;/td&gt;
&lt;td&gt;Verification opened to all developers.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;August 2026&lt;/td&gt;
&lt;td&gt;Android Developer Console APIs, limited distribution accounts and the "advanced flow" for power users launched.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30 September 2026&lt;/td&gt;
&lt;td&gt;Protections went live for apps installed from participating stores in Brazil, Indonesia, Singapore and Thailand.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;January 2027&lt;/td&gt;
&lt;td&gt;Global rollout starts with seven distributors: Google Play, Galaxy Store, Honor, Oppo, Xiaomi, Transsion and Vivo.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The following months&lt;/td&gt;
&lt;td&gt;Protections "gradually expand to all countries to cover all installation sources on certified Android devices". Google's post gives no exact day or country order.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So a direct APK download is not the first thing to be checked in January, but it is clearly included later. Register before the rollout reaches your customers, not after the first support ticket.&lt;/p&gt;

&lt;h3&gt;
  
  
  What you have to do
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create an account. If you distribute only outside Google Play, sign up for the Android Developer Console. If you already have a Play Console account, you use that, and Google says it registers most Play apps automatically (apps that use Play App Signing are claimed for you).&lt;/li&gt;
&lt;li&gt;Verify your identity as an individual or an organization. Organizations need a D-U-N-S number, which Google notes can take up to 28 days to get. The FAQ lists a $25 fee for a full distribution account.&lt;/li&gt;
&lt;li&gt;Register your package names by uploading an APK signed with your private signing key. This proves the package is yours. You can add more than one signing key to a package, and if you lose the key you cannot register the package.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Students and hobbyists can use a limited distribution account instead: no government ID and no fee, but installs are limited to a set of authorized devices. The November post raised that limit from 20 to 50 devices. That is for sharing a build with testers, not for selling copies.&lt;/p&gt;

&lt;h3&gt;
  
  
  The advanced flow and ADB
&lt;/h3&gt;

&lt;p&gt;Unregistered apps can still be installed in two ways. Developers can always install with ADB from a computer; the FAQ says nothing changes there. Users can turn on the advanced flow: enable developer options, confirm nobody is coaching them, restart and re-authenticate, wait a one-time 24 hours, then confirm with a fingerprint, face or PIN. After that they can install apps from unverified developers for 7 days or indefinitely, with an "unverified developer" warning on each install. Updates to unregistered apps also fail unless the advanced flow is on or ADB is used.&lt;/p&gt;

&lt;p&gt;For a paid app, that is not a realistic customer journey. Asking a buyer to enable developer options and wait a day before they can use what they just paid for will cost you sales and refunds. If you sell to the public, verify and register.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verification is not licensing: why a registered APK can still be copied and shared
&lt;/h2&gt;

&lt;p&gt;Verification answers one question for the phone: who made this app? It does not answer did this person pay for it? Google is explicit that verification "does not collect information about the app content or functionality". It is an identity check, not a store review and not a payment system.&lt;/p&gt;

&lt;p&gt;That means a registered APK installs on any certified device, whether the user bought it from you or got it from a friend, a forum or a file-sharing site. The protection is tied to your signing key and package name, not to a customer. Verification probably makes one kind of abuse less convenient: a modified copy has to be re-signed with someone else's key, and that key cannot claim your registered package name outright, so on a certified device it will usually need the advanced flow, ADB or a different package name. It does nothing about your genuine APK being passed around. For that you still need a license that the app checks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Google Play Licensing (LVL) and Play Integrity do not help when you sell outside Play
&lt;/h2&gt;

&lt;p&gt;Android already has two Google-run ways to ask "is this copy paid for?", and both assume Google Play sold it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Play Licensing (the License Verification Library, LVL) asks the Google Play licensing server whether the current user is licensed for the app. It needs the Play client on the device, and the server only knows about Play purchases. A customer who paid you on your website is "not licensed" as far as Google is concerned.&lt;/li&gt;
&lt;li&gt;The Play Integrity API returns an &lt;code&gt;appLicensingVerdict&lt;/code&gt;. &lt;code&gt;LICENSED&lt;/code&gt; means "the user installed or updated your app from Google Play". A direct download is, by definition, never &lt;code&gt;LICENSED&lt;/code&gt;. Play Integrity's device and app checks can still be useful, but not as proof of purchase, and they do not work on devices without Google Play services, which some direct-sale customers choose on purpose.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you sell yourself, the license has to come from your own system: a key issued when your checkout confirms payment, checked by a server you control, with a signed result the app can trust while offline.&lt;/p&gt;

&lt;h2&gt;
  
  
  The direct-sale flow: checkout, merchant of record and VAT, download link and license key in one email
&lt;/h2&gt;

&lt;p&gt;Outside a store, you do the store's job. The minimum is a checkout that charges the right tax, an email with something to download, and a license that is issued only after payment is confirmed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Checkout and tax
&lt;/h3&gt;

&lt;p&gt;Selling digital products to consumers usually means charging VAT or sales tax based on where the buyer is. In the EU that is the buyer's country, from the first sale. There are two common ways to handle it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A merchant of record, such as Paddle, sells to the customer on your behalf. It is the seller on the invoice and handles tax collection and remittance in the places it covers, and pays you out.&lt;/li&gt;
&lt;li&gt;Your own payment account, such as Stripe, where you are the seller and tax is your responsibility. Stripe Tax can calculate it, and for eligible accounts and digital products Stripe's Managed Payments can act as merchant of record.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The trade-offs are in merchant of record vs Stripe. If the same app is also on Google Play, Play's own payments policy decides whether that listing may link to your website checkout. Check it for each region instead of assuming.&lt;/p&gt;

&lt;h3&gt;
  
  
  Delivery
&lt;/h3&gt;

&lt;p&gt;The buyer needs two things: the APK and a license key. Send them together, so the first support email is not "where is my key?". In the PermitCore Store, you connect your own Stripe or Paddle account (PermitCore takes no sales commission; provider fees apply). When the signed payment webhook arrives, PermitCore issues the license with the activation limit, node locking, expiry and feature flags you set on the product, and queues one order email. That email links to the buyer's account, where the key is shown, and includes the download link you set as the product's Download URL. The step-by-step setup is in the Store guide, and the same approach for PC games is in selling a game outside Steam.&lt;/p&gt;

&lt;p&gt;Host the APK somewhere that gives a direct HTTPS download. Publish the SHA-256 checksum of each release, so careful buyers can confirm the file is yours. Once the package is registered, Google says the install experience stays the same as today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Activating a license key on an Android device: device IDs that survive updates (and why not IMEI or MAC)
&lt;/h2&gt;

&lt;p&gt;Activation binds a key to a device and counts it against the license's activation limit. In PermitCore, the app first fetches a single-use nonce from &lt;code&gt;GET /api/v1/nonce&lt;/code&gt;, then calls &lt;code&gt;POST /api/v1/activate&lt;/code&gt; with the key, the nonce and a &lt;code&gt;deviceId&lt;/code&gt;. If the limit is reached, the response is &lt;code&gt;isValid: false&lt;/code&gt; with &lt;code&gt;errorCode: "SeatsExhausted"&lt;/code&gt;. Activating again with the same device ID on a node-locked license reuses the existing seat. See POST /activate.&lt;/p&gt;

&lt;p&gt;That last point is why the device ID matters so much on a phone. It has to stay the same across app updates and reinstalls, or every reinstall burns a seat. The options on Android:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Identifier&lt;/th&gt;
&lt;th&gt;Use it?&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Settings.Secure.ANDROID_ID&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Yes, hashed&lt;/td&gt;
&lt;td&gt;On Android 8+ it is unique per app-signing key, user and device. It survives app updates and reinstalls signed with the same key, and changes after a factory reset or if your signing key changes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A random UUID saved in app storage&lt;/td&gt;
&lt;td&gt;Only as a fallback&lt;/td&gt;
&lt;td&gt;Deleted on uninstall or "clear data", so a reinstall looks like a new phone.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IMEI or serial number&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Since Android 10, normal apps cannot read them. They need a privileged permission that only system apps get.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wi-Fi MAC address&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Since Android 10, devices use a randomized MAC per network by default.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The sources are Android's ANDROID_ID reference and the Android 10 privacy changes. Hash &lt;code&gt;ANDROID_ID&lt;/code&gt; together with your package name before sending it, so the server never stores the raw value, and mention device binding in your privacy policy. The same reasoning for desktops is in device activation and hardware IDs and why MAC addresses are bad hardware IDs.&lt;/p&gt;

&lt;p&gt;One catch: because &lt;code&gt;ANDROID_ID&lt;/code&gt; depends on the signing key, a Google Play build signed by Play App Signing and your direct APK signed with your own key produce different IDs on the same phone. A customer who moves from one build to the other will use a new activation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Offline use: signed license tokens, grace periods and clock checks on a phone
&lt;/h2&gt;

&lt;p&gt;Phones lose signal on trains, planes and in basements. If your app refuses to start without a network, customers will notice before pirates do.&lt;/p&gt;

&lt;p&gt;In PermitCore you set offline grace days on the license. When the app validates online with its device ID, the response includes an &lt;code&gt;offlineCacheToken&lt;/code&gt;: a &lt;code&gt;pc_grace_v1&lt;/code&gt; token signed with your tenant's ECDSA P-256 key. It carries the product, a SHA-256 hash of the license key, the device ID and a signed &lt;code&gt;validUntil&lt;/code&gt; time. The app stores the token and, while offline, verifies the signature with your public key from &lt;code&gt;GET /api/v1/{tenantSlug}/public-key&lt;/code&gt;. Ship that public key inside the app; never read it from the cache or a network response. Never store a plain "licensed = true" flag, because anyone can edit it. For customers who are never online, an admin can also issue a manual &lt;code&gt;pc_offline_v1&lt;/code&gt; token bound to one device for 1 to 365 days. Both are described in offline licensing and offline grace mode.&lt;/p&gt;

&lt;p&gt;Plan for how offline licensing behaves on any platform, and say so in your support docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An offline device cannot learn about a revocation, a refund or a removed device until it reconnects. An already-issued token stays valid until its signed deadline. Shorter grace means faster revocation; phones are usually online, so a few days is often enough.&lt;/li&gt;
&lt;li&gt;A token's expiry is compared with the phone's clock, so add a simple local check: save the latest time you have seen (from a successful server response or the device), and treat the cached token as unusable if the clock goes clearly backwards.&lt;/li&gt;
&lt;li&gt;Online rejections win. If the server answers that the key is revoked, do not fall back to the cache. Use the cached token only when the network or server is unavailable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Phone swaps, factory resets and refunds: self-service transfers and automatic revocation
&lt;/h2&gt;

&lt;p&gt;A new phone or a factory reset produces a new device ID, so the old activation still holds a seat. Customers should be able to fix that without emailing you. Every PermitCore tenant has a customer portal at &lt;code&gt;/portal/{your-slug}&lt;/code&gt;, where a customer enters the key, sees their activated devices and removes the old one, which frees the seat. You can require an email code before a device is removed (Professional plan and above). Link the portal from your app's settings screen and from the order email. The desktop version of this flow is in transferring a license to a new computer.&lt;/p&gt;

&lt;p&gt;Refunds should change the license, not only the bank balance. A fully refunded or lost-dispute Store order revokes its license automatically, and a subscription license is deactivated when the subscription ends. The next online check fails; an offline phone stops working when its grace token runs out. If you also run your own systems, the &lt;code&gt;license.revoked&lt;/code&gt; webhook tells them.&lt;/p&gt;

&lt;p&gt;Leaked keys and shared APKs are handled the same way. Activation limits make a shared key run out of seats, the license page shows where it was activated, and you can revoke one key without touching honest customers. Minimum and maximum version rules on a license can also block very old builds after you fix something important. None of this makes copying impossible. A patched APK that removes the check will run, and the realistic response is in what to do if your software is cracked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unity, Godot and Kotlin: where to put the check
&lt;/h2&gt;

&lt;p&gt;Put the check at start-up and before paid features, not in one place that a patch can skip. Activate once after the user enters the key, then validate on later launches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kotlin or Java (plain REST)
&lt;/h3&gt;

&lt;p&gt;In a native Android app, call the REST API directly from your app or your backend: POST /activate once, then POST /validate on later launches. Run network calls off the main thread.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;android&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;annotation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SuppressLint&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;android&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;android&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Build&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;android&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Settings&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;JSONObject&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IOException&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;HttpURLConnection&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;URL&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;security&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MessageDigest&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="no"&gt;API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.permitcore.dev/api/v1"&lt;/span&gt;

&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;sha256Hex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="nc"&gt;MessageDigest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SHA-256"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toByteArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Charsets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UTF_8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;joinToString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"%02x"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Stable across updates and reinstalls signed with the same key (Android 8+).&lt;/span&gt;
&lt;span class="nd"&gt;@SuppressLint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"HardwareIds"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Secure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contentResolver&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Secure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ANDROID_ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;sha256Hex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;packageName&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"|"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;postJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;openConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;HttpURLConnection&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;requestMethod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;connectTimeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10_000&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;readTimeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10_000&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doOutput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setRequestProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;outputStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toByteArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Charsets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UTF_8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;responseCode&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inputStream&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;errorStream&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nc"&gt;IOException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"HTTP $code"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bufferedReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Call once, after the user enters the key. Never on the main thread.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;activate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;nonce&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"$API/nonce"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"nonce"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;postJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"$API/activate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"licenseKey"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"nonce"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"deviceId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"deviceName"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MODEL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;BuildConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;VERSION_NAME&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"expectedProductId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Check result.optBoolean("isValid") and result.optString("errorCode"),&lt;/span&gt;
    &lt;span class="c1"&gt;// e.g. "SeatsExhausted": point the user to the customer portal.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// On later launches: validate (no seat used) and keep the signed grace token.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="nf"&gt;postJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"$API/validate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"licenseKey"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"deviceId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;BuildConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;VERSION_NAME&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"expectedProductId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Store result.optString("offlineCacheToken") when it is present.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use the grace token offline, verify it before trusting it. PermitCore signs the base64url payload string with ECDSA P-256 and SHA-256 and sends a raw 64-byte signature. Android's &lt;code&gt;SHA256withECDSA&lt;/code&gt; verifier expects DER, so convert it first. This example needs &lt;code&gt;minSdk 26&lt;/code&gt; (or library desugaring) for &lt;code&gt;java.time&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;android&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;util&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Base64&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;JSONObject&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BigInteger&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;security&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;KeyFactory&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;security&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Signature&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;security&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;X509EncodedKeySpec&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OffsetDateTime&lt;/span&gt;

&lt;span class="c1"&gt;// Raw r||s (64 bytes) to an ASN.1 DER ECDSA signature.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;rawToDer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ByteArray&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ByteArray&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;BigInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copyOfRange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toByteArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;BigInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copyOfRange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toByteArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;byteArrayOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toByte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toByte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
        &lt;span class="nf"&gt;byteArrayOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toByte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Returns the verified claims, or null. TRUSTED_PUBLIC_KEY is the SPKI base64&lt;/span&gt;
&lt;span class="c1"&gt;// public key from /api/v1/{tenantSlug}/public-key, compiled into the app.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;verifyGraceToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"pc_grace_v1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;URL_SAFE&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;NO_WRAP&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;KeyFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"EC"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generatePublic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;X509EncodedKeySpec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;TRUSTED_PUBLIC_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;NO_WRAP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;verifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Signature&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SHA256withECDSA"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;initVerify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toByteArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Charsets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UTF_8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;// the base64url payload string itself&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;verifier&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;rawToDer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;claims&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;JSONObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Charsets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UTF_8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;bound&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"deviceId"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"deviceId"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;nodeLocked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"nodeLocked"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBoolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"nodeLocked"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;optBoolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"isValid"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OffsetDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"validUntil"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isAfter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OffsetDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;optString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"licenseKeySha256"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nf"&gt;sha256Hex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;optString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"productId"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignoreCase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bound&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;bound&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignoreCase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;nodeLocked&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bound&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isNotEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;optBoolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"deviceActivated"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;claims&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;null&lt;/span&gt;   &lt;span class="c1"&gt;// malformed, tampered, expired or for another key/device: not licensed&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Unity
&lt;/h3&gt;

&lt;p&gt;The Unity SDK supports mobile builds and uses &lt;code&gt;UnityWebRequest&lt;/code&gt;. On Android, pass two things explicitly: &lt;code&gt;UnityHardwareId.Get()&lt;/code&gt; as the device ID (Unity's &lt;code&gt;SystemInfo.deviceUniqueIdentifier&lt;/code&gt;, which on Android is the MD5 of &lt;code&gt;ANDROID_ID&lt;/code&gt;), and &lt;code&gt;Application.persistentDataPath&lt;/code&gt; as the cache folder. More in integrating PermitCore with Unity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nc"&gt;PermitCore&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nc"&gt;UnityEngine&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ANDROID_ID-based on Android; survives updates signed with the same key.&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://api.permitcore.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;cacheDirectory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;persistentDataPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;trustedPublicKeys&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;TrustedTenantPublicKey&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;UnityHardwareId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Once, after the player enters the key:&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ActivateAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;deviceName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;SystemInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deviceModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;expectedProductId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ProductId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Every later launch (falls back to the verified grace token when offline):&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ValidateAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expectedProductId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ProductId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsValid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;ShowActivationScreen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Godot
&lt;/h3&gt;

&lt;p&gt;The Godot SDK is a GDScript add-on with the same activate, validate and signed offline cache. As with any engine build, test your Android export on real phones before you sell it, and pass a stable &lt;code&gt;device_id&lt;/code&gt; so a reinstall keeps the same device identity. See Godot license keys in GDScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Signing keys and package names: keep your APK signing key and your license signing key separate and backed up
&lt;/h2&gt;

&lt;p&gt;After January you will have two different keys that matter, and mixing them up is expensive.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;APK signing key&lt;/th&gt;
&lt;th&gt;License signing key&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What it signs&lt;/td&gt;
&lt;td&gt;Your APK (and proves package ownership for verification)&lt;/td&gt;
&lt;td&gt;License responses and offline tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Where it lives&lt;/td&gt;
&lt;td&gt;Your keystore, or Google's servers with Play App Signing&lt;/td&gt;
&lt;td&gt;Your PermitCore tenant (ECDSA P-256)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What ships in the app&lt;/td&gt;
&lt;td&gt;The signature, not the key&lt;/td&gt;
&lt;td&gt;Only the public key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;If you lose it&lt;/td&gt;
&lt;td&gt;You cannot register the package, users cannot update to a build signed with a new key, and every &lt;code&gt;ANDROID_ID&lt;/code&gt;-based device ID changes&lt;/td&gt;
&lt;td&gt;Rotate: issue a new key and keep the previous public key in the app's trusted list until old tokens expire&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Back up the keystore and its passwords in two places that are not your laptop, and write down which key signs which channel (Play, Galaxy Store, your website). If you rotate the APK key later, register the new key for the package before you ship with it. Never put the license private key in the app. The rotation steps are in license signing key rotation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your address on the listing: business address options for EEA/UK "trader" developers
&lt;/h2&gt;

&lt;p&gt;A related change landed in the same weeks. Google Play's trader status declaration requires every active Play developer account to declare by 1 February 2027 whether it is a trader under EEA and UK law, ahead of Play's move to an online marketplace model in those regions on 1 March 2027. Selling paid apps, in-app purchases or ad-supported apps on a regular basis usually makes you a trader. For a personal account that declares as a trader, Google says a contact phone number is shown on Play and the address is also public. Reports from Android Authority and others say the details are shown worldwide and that PO boxes are not accepted.&lt;/p&gt;

&lt;p&gt;This only affects your Play listing, but direct sellers have a similar duty: EU consumer law generally expects an online seller to show who they are and a geographic address. If you do not want your home address public:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sell through a legal entity, such as a company, with its own business address. Google's organization accounts need a D-U-N-S number, so start early.&lt;/li&gt;
&lt;li&gt;Use a staffed office, coworking or registered office service address where it is legally allowed to be your business address. Check what Google and your local rules accept before relying on it.&lt;/li&gt;
&lt;li&gt;If you use a merchant of record, it is the seller on the invoice, but your own website and any store listing still need correct contact details.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not declare yourself a non-trader just to hide an address if you sell commercially. Google warns that a false declaration can lead to removal, and if you are unsure, ask a lawyer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist before January 2027
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create your Android Developer Console account, or check your Play Console account, and finish identity verification. Request a D-U-N-S number now if you register as an organization.&lt;/li&gt;
&lt;li&gt;Register every package name you distribute outside Play, with every signing key you use. Check the status in the console or in Android Studio when you build a signed APK.&lt;/li&gt;
&lt;li&gt;Back up each APK signing key in two safe places and record which key signs which channel.&lt;/li&gt;
&lt;li&gt;Remove any dependency on Google Play Licensing or Play Integrity licensing verdicts from your direct-sale build.&lt;/li&gt;
&lt;li&gt;Choose your checkout: a merchant of record or your own Stripe account with tax handled.&lt;/li&gt;
&lt;li&gt;Send the APK link and the license key together in the order email, and publish a checksum for each release.&lt;/li&gt;
&lt;li&gt;Use a hashed &lt;code&gt;ANDROID_ID&lt;/code&gt; as the device ID. Never use IMEI, serial number or MAC.&lt;/li&gt;
&lt;li&gt;Set offline grace days, verify signed tokens in the app, ship the public key in the app and add a simple clock-rollback check.&lt;/li&gt;
&lt;li&gt;Link the customer portal from your settings screen, and test a phone swap and a factory reset end to end.&lt;/li&gt;
&lt;li&gt;Run a test purchase and a full refund in test mode, and confirm the key is revoked.&lt;/li&gt;
&lt;li&gt;If you are also on Google Play, make your trader declaration before 1 February 2027 with an address you are willing to publish.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Developer verification makes Android installs more accountable, and a registered direct-sale app will install as smoothly as one from a store. Getting paid, delivering the key and keeping one purchase on a reasonable number of phones is still your job. If you want those parts ready-made, start with the &lt;a href="https://permitcore.dev/docs/store" rel="noopener noreferrer"&gt;Store guide&lt;/a&gt; or compare plans on the &lt;a href="https://permitcore.dev/pricing" rel="noopener noreferrer"&gt;pricing page&lt;/a&gt;. For the iPhone side, see &lt;a href="https://permitcore.dev/blog/ios-app-web-checkout" rel="noopener noreferrer"&gt;selling iOS app unlocks through your own web checkout&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;p&gt;Checked on 29 November 2026:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Android Developers Blog, Expanding Android developer verification in 2027 (19 November 2026)&lt;/li&gt;
&lt;li&gt;Android Developers, Android developer verification, guide and FAQ&lt;/li&gt;
&lt;li&gt;Android Developers, Settings.Secure.ANDROID_ID and Android 10 privacy changes&lt;/li&gt;
&lt;li&gt;Android Developers, Google Play Licensing overview and Play Integrity verdicts&lt;/li&gt;
&lt;li&gt;Play Console Help, Trader status declaration&lt;/li&gt;
&lt;li&gt;Unity Scripting Reference, SystemInfo.deviceUniqueIdentifier&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>gamedev</category>
      <category>indiedev</category>
    </item>
    <item>
      <title>Lemon Squeezy Is Shutting Down: How to Move Your License Keys Without Breaking Activations</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Wed, 25 Nov 2026 09:49:11 +0000</pubDate>
      <link>https://dev.to/permitcore/lemon-squeezy-is-shutting-down-how-to-move-your-license-keys-without-breaking-activations-3df0</link>
      <guid>https://dev.to/permitcore/lemon-squeezy-is-shutting-down-how-to-move-your-license-keys-without-breaking-activations-3df0</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/lemon-squeezy-shutting-down" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you sell software through Lemon Squeezy, you now have a hard deadline: the platform is winding down. On November 16, 2026 it closed new store sign-ups, and it will stop processing payments, including subscription renewals, on &lt;strong&gt;March 31, 2027&lt;/strong&gt;. Lemon Squeezy says that deadline will not be extended (&lt;a href="https://www.lemonsqueezy.com/blog/saying-goodbye-to-lemon-squeezy" rel="noopener noreferrer"&gt;official announcement&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Most coverage focuses on the payment move. For software sellers, the harder part is the license keys. Customers have already typed those keys into installed copies of your app, and those copies call Lemon Squeezy's License API. This guide covers that half of the migration: what to export, how to keep existing keys working, how to ship the app update, and how to connect the new payment provider so renewals and refunds keep updating licenses.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Dates and quotes in this article come from Lemon Squeezy's own pages as of November 23, 2026. Re-check the &lt;a href="https://docs.lemonsqueezy.com/migration" rel="noopener noreferrer"&gt;migration guide&lt;/a&gt; before you act, because the details may change.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Lemon Squeezy shutdown timeline
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;What happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;November 16, 2026&lt;/td&gt;
&lt;td&gt;Lemon Squeezy stops accepting new users and new store sign-ups.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;December 2, 2026&lt;/td&gt;
&lt;td&gt;Migration tooling for Stripe Managed Payments launches for eligible stores at &lt;code&gt;app.lemonsqueezy.com/migration&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mid-January 2027&lt;/td&gt;
&lt;td&gt;Lemon Squeezy's recommended latest date to &lt;em&gt;start&lt;/em&gt; a migration. It estimates the full process can take up to 8 weeks.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;March 31, 2027&lt;/td&gt;
&lt;td&gt;Lemon Squeezy stops processing transactions, including subscription renewals.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Source: &lt;a href="https://docs.lemonsqueezy.com/migration" rel="noopener noreferrer"&gt;Lemon Squeezy is winding down&lt;/a&gt;. Your store keeps working as usual until March 31, 2027, so you can keep selling while you prepare.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Stripe Managed Payments migrates, and what it leaves behind
&lt;/h2&gt;

&lt;p&gt;Lemon Squeezy recommends moving to Managed Payments, Stripe's merchant-of-record product. The migration tooling creates your products in Stripe, migrates customers with a report mapping Lemon Squeezy customer IDs to Stripe customer IDs, and moves eligible subscriptions after giving customers at least 14 days' notice. Most card subscriptions move without customers re-entering payment details. PayPal subscriptions cannot migrate.&lt;/p&gt;

&lt;p&gt;License keys are a different story. Lemon Squeezy's &lt;a href="https://docs.lemonsqueezy.com/migration/digital-fulfillment" rel="noopener noreferrer"&gt;digital fulfillment page&lt;/a&gt; is explicit:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Managed Payments doesn’t deliver files, download links, or license keys.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It also warns that if you don't migrate historical orders and subscriptions to a new fulfillment solution by the deadline, “customers may lose access to their license keys, files, and links after March 31, 2027.” Your options are to host fulfillment yourself or use a third-party provider that can migrate your historical orders, subscriptions, license keys and customer entitlements.&lt;/p&gt;

&lt;p&gt;So whichever payment provider you choose, license keys need their own plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your three options
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Managed Payments plus a licensing service.&lt;/strong&gt; Stripe handles checkout, tax and disputes; a licensing service holds keys, activations and validation. Managed Payments is only available in supported locations and for eligible digital products, so check eligibility first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Paddle.&lt;/strong&gt; Paddle is also a merchant of record. Use it if Managed Payments isn't available where your business is based, or if you rely on something it doesn't support. Lemon Squeezy's guide lists PayPal, storefronts, digital fulfillment and affiliates as not included in Managed Payments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your own Stripe account.&lt;/strong&gt; This gives you the most control. As Lemon Squeezy notes, if your new provider isn't the merchant of record, “your business becomes responsible for tax compliance in every applicable jurisdiction.” Read &lt;a href="https://permitcore.dev/blog/merchant-of-record-vs-stripe" rel="noopener noreferrer"&gt;merchant of record vs. Stripe&lt;/a&gt; before you choose this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Going forward, we recommend &lt;strong&gt;Paddle or Stripe&lt;/strong&gt; for new PermitCore Store setups. PermitCore Store connects your own Stripe or Paddle account. With Stripe, a Store can use standard Stripe Checkout, Stripe Tax, or Managed Payments for eligible accounts and products. See the &lt;a href="https://permitcore.dev/docs/store" rel="noopener noreferrer"&gt;Store setup guide&lt;/a&gt;, &lt;a href="https://permitcore.dev/blog/paddle-license-keys" rel="noopener noreferrer"&gt;Paddle license keys&lt;/a&gt; and &lt;a href="https://permitcore.dev/blog/software-licensing-with-stripe" rel="noopener noreferrer"&gt;software licensing with Stripe&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Export everything before you need it
&lt;/h2&gt;

&lt;p&gt;Export now, even if you plan to migrate in January. Lemon Squeezy's dashboard can email you an orders CSV, but that file does not include license keys or activations. The API gives you both through &lt;a href="https://docs.lemonsqueezy.com/api/license-keys/list-all-license-keys" rel="noopener noreferrer"&gt;&lt;code&gt;GET /v1/license-keys&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://docs.lemonsqueezy.com/api/license-key-instances/list-all-license-key-instances" rel="noopener noreferrer"&gt;&lt;code&gt;GET /v1/license-key-instances&lt;/code&gt;&lt;/a&gt;. Each license key object includes the full &lt;code&gt;key&lt;/code&gt;, &lt;code&gt;product_id&lt;/code&gt;, &lt;code&gt;activation_limit&lt;/code&gt;, &lt;code&gt;instances_count&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt;, &lt;code&gt;expires_at&lt;/code&gt; and &lt;code&gt;user_email&lt;/code&gt;. Each instance includes its &lt;code&gt;identifier&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create an API key in your Lemon Squeezy account settings, keep it in an environment variable, and run this with Node.js 18 or newer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// export-ls-licenses.mjs&lt;/span&gt;
&lt;span class="c1"&gt;// Run: LS_API_KEY=... LS_STORE_ID=... node export-ls-licenses.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;writeFile&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:fs/promises"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.lemonsqueezy.com/v1"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;Accept&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/vnd.api+json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/vnd.api+json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`Bearer ${process.env.LS_API_KEY}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;listAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"?"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"&amp;amp;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"?"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sb"&gt;`${BASE}/${path}${sep}page[size]=100`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;            &lt;span class="c1"&gt;// rate limited: wait, then retry&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${path}: HTTP ${res.status}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;// absent on the last page&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;LS_STORE_ID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;listAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`license-keys?filter[store_id]=${store}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;instances&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;listAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"license-key-instances"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;opts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mo"&gt;0o600&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;            &lt;span class="c1"&gt;// readable by you only&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;writeFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ls-license-keys.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;writeFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ls-license-key-instances.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instances&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${keys.length} keys, ${instances.length} instances exported`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List endpoints return at most 100 results per page, and the script follows &lt;code&gt;links.next&lt;/code&gt; until it runs out, as described in Lemon Squeezy's &lt;a href="https://docs.lemonsqueezy.com/api/getting-started/requests" rel="noopener noreferrer"&gt;pagination reference&lt;/a&gt;. Also export customers, orders and subscriptions, which the &lt;a href="https://docs.lemonsqueezy.com/migration" rel="noopener noreferrer"&gt;migration guide&lt;/a&gt; asks you to back up. You will want them for support and refunds long after the store is closed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Treat the export as a secret.&lt;/strong&gt; These files contain every customer's plaintext license key. Keep them off shared drives and out of git, and delete working copies when the migration is done.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Check the counts before relying on the files: the key total should match your dashboard, and you should spot-check a few customers end to end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Import existing keys so customers never re-enter them
&lt;/h2&gt;

&lt;p&gt;The goal is that a customer's existing Lemon Squeezy key keeps working, unchanged, against the new system. In PermitCore, that's possible because validation never checks the key's format. The server hashes whatever string the app sends and looks that hash up. A Lemon Squeezy key like &lt;code&gt;80e15db5-c796-436b-850c-8f9c98a48abe&lt;/code&gt; works exactly as it is.&lt;/p&gt;

&lt;p&gt;Create the matching products in PermitCore first. Then convert the export into a CSV for &lt;strong&gt;Licenses → Import&lt;/strong&gt;. The column names below match the wizard's &lt;strong&gt;Generic CSV&lt;/strong&gt; preset, so the mapping step fills itself in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// to-permitcore-csv.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;readFile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;writeFile&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:fs/promises"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Lemon Squeezy product_id -&amp;gt; exact PermitCore product name&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;PRODUCT_MAP&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"123456"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Acme Editor Pro"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"123457"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Acme Editor Team"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;UNLIMITED_CAP&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// explicit cap for keys with no Lemon Squeezy limit&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;readFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ls-license-keys.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"utf8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="sb"&gt;`"${String(v ?? "").replaceAll('"', '""')}"`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"product"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"max_activations"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="s2"&gt;"current_activations"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"expires_at"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;review&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;PRODUCT_MAP&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;disabled&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"disabled"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;review&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${a.key_short} (${a.status}, product ${a.product_id})`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;activation_limit&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="no"&gt;UNLIMITED_CAP&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;instances_count&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expires_at&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user_email&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;writeFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"permitcore-import.csv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mo"&gt;0o600&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${rows.length - 1} rows ready; review manually:`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;review&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upload &lt;code&gt;permitcore-import.csv&lt;/code&gt; under &lt;strong&gt;Licenses → Import&lt;/strong&gt; with the Generic CSV preset, review the column mapping, and check the preview. The wizard hashes each key in your browser before sending it. Rows with a missing key, an unknown product or an invalid value are flagged and skipped without blocking the rest of the file. Each result row says &lt;code&gt;Created&lt;/code&gt;, &lt;code&gt;Duplicate&lt;/code&gt; or &lt;code&gt;Failed&lt;/code&gt;, and you can download a CSV of anything that didn't import cleanly.&lt;/p&gt;

&lt;p&gt;A few decisions to make before you import:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Re-imports are safe.&lt;/strong&gt; A key that already exists comes back as &lt;code&gt;Duplicate&lt;/code&gt;, which is not an error. You can export and import again later to pick up keys sold in the meantime.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Passphrase.&lt;/strong&gt; It's optional for imports. Skipping it doesn't affect validation or activation; it only means you can't reveal the plaintext key again from the admin panel. If you skip it, keep your original export somewhere secure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unlimited keys.&lt;/strong&gt; PermitCore needs an explicit activation cap, so choose a number you're comfortable with for keys that had no limit in Lemon Squeezy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disabled keys.&lt;/strong&gt; The script leaves disabled keys and unmapped products out and lists them for manual review instead of silently reactivating them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you'd rather script the import, the wizard uses &lt;code&gt;POST /api/licenses/import&lt;/code&gt;, which accepts up to 500 rows per request with SHA-256 key hashes rather than plaintext keys. The full field list is in &lt;a href="https://permitcore.dev/docs/migrating-from-other-systems" rel="noopener noreferrer"&gt;Migrating from Other Systems&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to existing activations
&lt;/h3&gt;

&lt;p&gt;Mapping &lt;code&gt;instances_count&lt;/code&gt; to &lt;code&gt;current_activations&lt;/code&gt; carries over the &lt;em&gt;count&lt;/em&gt; of used seats. For example, a key with 3 of 5 seats used keeps 2 free seats. It does not recreate the device records themselves: Lemon Squeezy instance identifiers belong to Lemon Squeezy's License API and mean nothing to another validation service. Decide your re-enrollment policy in advance. A device that activates again after the switch can take another seat, so you might import the count and raise the cap slightly during the transition, or import zero used seats and let devices re-enroll. Test both with a real key before choosing. The &lt;a href="https://permitcore.dev/blog/switch-software-licensing-provider" rel="noopener noreferrer"&gt;licensing migration guide&lt;/a&gt; covers this in more detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Ship an app update with a short dual-check window
&lt;/h2&gt;

&lt;p&gt;Importing keys doesn't change installed software. Every copy of your app already out there calls &lt;code&gt;api.lemonsqueezy.com/v1/licenses/validate&lt;/code&gt;, and only a new release can change that. The new release should validate against &lt;a href="https://permitcore.dev/docs/api/validate" rel="noopener noreferrer"&gt;&lt;code&gt;POST /api/v1/validate&lt;/code&gt;&lt;/a&gt; and read the key from wherever the old version stored it, so customers aren't asked for it again.&lt;/p&gt;

&lt;p&gt;Between your first import and the day you stop selling on Lemon Squeezy, new keys may appear in Lemon Squeezy before your next import. A short fallback window covers that gap. Only use it when PermitCore says the key is unknown, check that the key belongs to &lt;em&gt;your&lt;/em&gt; store, and end it on a fixed date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;PERMITCORE_VALIDATE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.permitcore.dev/api/v1/validate"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;PRODUCT_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"7f3e9a2b-1c4d-4e8f-9a6b-3d2c1e0f5a8b"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// your PermitCore product&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;LS_STORE_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12345&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                &lt;span class="c1"&gt;// your Lemon Squeezy store&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;LS_PRODUCT_IDS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;123456&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// products this app accepts&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;LS_FALLBACK_UNTIL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"2027-01-31T00:00:00Z"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// your final import&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;checkLicense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;PERMITCORE_VALIDATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;licenseKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expectedProductId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;PRODUCT_ID&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;pc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isValid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"permitcore"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;license&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;pc&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Fall back only for keys PermitCore has never seen, and only until the cutoff.&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;errorCode&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;"NotFound"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="no"&gt;LS_FALLBACK_UNTIL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;pc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://api.lemonsqueezy.com/v1/licenses/validate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Accept&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;license_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;store_id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="no"&gt;LS_STORE_ID&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
               &lt;span class="no"&gt;LS_PRODUCT_IDS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;valid&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;ours&lt;/span&gt;
    &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"lemonsqueezy-transition"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// picked up by your next import&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;"License key not recognised"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;store_id&lt;/code&gt; and &lt;code&gt;product_id&lt;/code&gt; checks matter. Lemon Squeezy's validate endpoint needs no API key, so without them a key from any other Lemon Squeezy store would pass. Set &lt;code&gt;LS_FALLBACK_UNTIL&lt;/code&gt; to the date of your final import after checkout has moved, and never later than March 31, 2027. After that, remove the fallback in the next release. If you use an official SDK, the same &lt;code&gt;validate&lt;/code&gt; call is available there; see &lt;a href="https://permitcore.dev/docs/sdks" rel="noopener noreferrer"&gt;SDKs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Reconnect renewals, refunds and failed payments
&lt;/h2&gt;

&lt;p&gt;A key is only as current as the payment events behind it. When you move checkout, every renewal, cancellation, refund and failed payment has to update the license, or customers keep access they didn't pay for, or lose access they did pay for.&lt;/p&gt;

&lt;p&gt;If you sell through PermitCore Store, choose Paddle or Stripe under &lt;strong&gt;License Store → Settings&lt;/strong&gt;, connect and verify the account, map products and prices, and run a sandbox purchase before going live. PermitCore checks each signed provider notification against the provider's data before issuing or updating a license. A success-page redirect alone never issues a key. The &lt;a href="https://permitcore.dev/docs/store" rel="noopener noreferrer"&gt;Store guide&lt;/a&gt; walks through both providers.&lt;/p&gt;

&lt;p&gt;Keep two things in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Changing the Store's provider affects new checkouts only.&lt;/strong&gt; Existing subscriptions stay with the provider they started on. Subscriptions started on Lemon Squeezy keep renewing there until Lemon Squeezy stops processing on March 31, 2027, so they need their own move: Lemon Squeezy's migration tooling for Managed Payments, or its migration intake form for another provider. Lemon Squeezy notes that only card-paid subscriptions can move to another provider.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep your own systems in sync.&lt;/strong&gt; If your backend tracks license state, subscribe to PermitCore &lt;a href="https://permitcore.dev/docs/webhooks" rel="noopener noreferrer"&gt;webhooks&lt;/a&gt; such as &lt;code&gt;license.created&lt;/code&gt;, &lt;code&gt;license.updated&lt;/code&gt; and &lt;code&gt;license.revoked&lt;/code&gt;, verify the signature over the raw body, and process each event ID once. See &lt;a href="https://permitcore.dev/blog/revoke-license-after-failed-payment" rel="noopener noreferrer"&gt;revoking a license after a failed payment&lt;/a&gt; for the access policy side.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  If you sell through PermitCore Store with Lemon Squeezy today
&lt;/h2&gt;

&lt;p&gt;Because Lemon Squeezy is shutting down, PermitCore is removing it as an option for new Store setups. Stores that haven't connected Lemon Squeezy won't be able to choose it.&lt;/p&gt;

&lt;p&gt;If your Store already uses Lemon Squeezy, it keeps working until Lemon Squeezy stops processing payments on March 31, 2027. Keys issued by PermitCore Store are already held in PermitCore, not in Lemon Squeezy, so changing the payment provider doesn't change your customers' keys. We'll help you move to Paddle or Stripe with existing license keys and activations intact, and you'll get advance notice before the Lemon Squeezy integration is switched off. Questions: &lt;a href="mailto:info@permitcore.dev"&gt;info@permitcore.dev&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens to customers who never update the app
&lt;/h2&gt;

&lt;p&gt;Older versions keep calling Lemon Squeezy's License API. Lemon Squeezy hasn't said exactly how that API will behave after March 31, 2027, beyond the warning that customers may lose access to their keys. Plan as if old versions will stop validating.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ship the update well before March, and make it the default download everywhere you link.&lt;/li&gt;
&lt;li&gt;Email customers with a direct download link, and tell them their existing key keeps working.&lt;/li&gt;
&lt;li&gt;Give support a short reply for “my license stopped working”: update to the current version, and use the same key.&lt;/li&gt;
&lt;li&gt;If your old version caches a successful check for offline use, factor in how long that cache lasts before it re-checks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See &lt;a href="https://permitcore.dev/blog/what-happens-if-a-license-server-goes-down" rel="noopener noreferrer"&gt;what happens if a license server goes down&lt;/a&gt; for designing the next release so a provider outage never locks out paying customers. Our &lt;a href="https://permitcore.dev/exit-plan" rel="noopener noreferrer"&gt;exit plan&lt;/a&gt; explains what happens to your keys if you ever leave PermitCore.&lt;/p&gt;

&lt;h2&gt;
  
  
  Countdown checklist to March 31, 2027
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Now
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Export license keys, instances, customers, orders and subscriptions through the API. Check the counts.&lt;/li&gt;
&lt;li&gt;Decide on a provider: Managed Payments (check eligibility), Paddle, or your own Stripe account.&lt;/li&gt;
&lt;li&gt;Consider removing PayPal from Lemon Squeezy checkout, since PayPal subscriptions can't migrate.&lt;/li&gt;
&lt;li&gt;Create products in PermitCore and import a small test batch. Validate a real migrated key.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  From December 2, 2026
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you're eligible, open the Migration Hub and run the sandbox migration Lemon Squeezy provides.&lt;/li&gt;
&lt;li&gt;Connect Paddle or Stripe in PermitCore Store and complete a sandbox purchase, refund and failed renewal.&lt;/li&gt;
&lt;li&gt;Release the app update with the dual-check window.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  By mid-January 2027
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Start the payment migration, as Lemon Squeezy recommends.&lt;/li&gt;
&lt;li&gt;Move new checkouts to the new provider and update every buy link. Lemon Squeezy notes that none of them redirect automatically.&lt;/li&gt;
&lt;li&gt;Run the final export and import. &lt;code&gt;Duplicate&lt;/code&gt; results for keys you already imported are expected.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Before March 31, 2027
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Confirm every remaining subscription has moved or has a plan.&lt;/li&gt;
&lt;li&gt;Ship the release that removes the Lemon Squeezy fallback.&lt;/li&gt;
&lt;li&gt;Keep a secure archive of the export for support, refunds and tax questions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can I keep my Lemon Squeezy license key format?
&lt;/h3&gt;

&lt;p&gt;Yes. PermitCore validates by hashing the exact key string, so imported Lemon Squeezy keys keep working unchanged. Preserve the original value exactly, including case and separators. New keys issued later can use PermitCore's own format, and both kinds work side by side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do old activation counts carry over?
&lt;/h3&gt;

&lt;p&gt;The count does, through the activations-used column. Individual device records don't, because Lemon Squeezy instance IDs only mean something to Lemon Squeezy. Plan how re-activating devices should count against the limit.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if Managed Payments doesn't support my country?
&lt;/h3&gt;

&lt;p&gt;Lemon Squeezy says you'll need to move to another provider, and offers a data export guide and a migration intake form for moving card subscriptions. Paddle is a merchant-of-record option to evaluate. Your own Stripe account is another, if you're prepared to handle tax compliance yourself. Check each provider's supported countries and payment methods before committing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I have to switch payment providers and licensing at the same time?
&lt;/h3&gt;

&lt;p&gt;No, and it's usually safer not to. Import keys and ship the app update first, while Lemon Squeezy still takes payments. Then move checkout. Each step is easier to test and roll back on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Over to you
&lt;/h2&gt;

&lt;p&gt;If you're moving a store off Lemon Squeezy right now, which part worries you more: the payment and subscription move, or the license keys already sitting in installed copies of your app? I'd like to hear how you're planning the switch, and if you get stuck, the &lt;a href="https://permitcore.dev/docs/migrating-from-other-systems" rel="noopener noreferrer"&gt;import guide&lt;/a&gt; is the place to start.&lt;/p&gt;

</description>
      <category>saas</category>
      <category>licensing</category>
      <category>indiedev</category>
      <category>stripe</category>
    </item>
    <item>
      <title>Found a Cracked Copy of Your App? A Practical Response Plan for Indie Devs</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Sun, 22 Nov 2026 09:34:06 +0000</pubDate>
      <link>https://dev.to/permitcore/found-a-cracked-copy-of-your-app-a-practical-response-plan-for-indie-devs-a2p</link>
      <guid>https://dev.to/permitcore/found-a-cracked-copy-of-your-app-a-practical-response-plan-for-indie-devs-a2p</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/what-to-do-if-your-software-is-cracked" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You found your paid desktop app on a warez site. Someone posted a keygen. A GitHub repository contains a modified build with your payment screen removed. Or a Unity asset you sell has been repackaged and uploaded under someone else's name. Whichever it is, the next half hour decides whether you end up with one piracy incident or a piracy incident plus a support incident.&lt;/p&gt;

&lt;p&gt;The first reaction is usually a mix of anger and urgency: take it down, rotate everything, add more obfuscation, lock every legitimate customer out until the leak is contained. That reaction is understandable. It is also how developers turn one piracy incident into a support incident.&lt;/p&gt;

&lt;p&gt;If you are searching for &lt;strong&gt;what to do if your software is cracked&lt;/strong&gt;, the realistic answer has two tracks. Preserve evidence and pursue the copies you can remove. At the same time, make the unauthorized copy less useful without making the legitimate product worse.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Scope note:&lt;/strong&gt; this is a practical engineering and incident-response guide, not legal advice. Copyright, trademark, contract, and platform rules vary by country and by the facts of the copy. Preserve evidence before contacting a host, and talk to a qualified lawyer when the identity of your business, meaningful revenue, or customer safety is at risk.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Crack, keygen, or re-upload: identify what happened
&lt;/h2&gt;

&lt;p&gt;Do not use â€œpiratedâ€ as the only diagnosis. Different incidents need different responses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cracked binary:&lt;/strong&gt; your executable was patched so a local license check always succeeds, an expiry branch never runs, or a feature flag is forced on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keygen or leaked key:&lt;/strong&gt; attackers generate keys your app accepts, or one genuine key is being redistributed and activated across many devices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Re-upload:&lt;/strong&gt; someone republishes your binary, source, web bundle, Unity package, documentation, branding, or screenshotsâ€”possibly with ads, telemetry, or payment code removed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clone:&lt;/strong&gt; another product imitates the behavior or appearance without necessarily copying protected code or assets. This is harder to evaluate from a screenshot alone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impersonation:&lt;/strong&gt; the copy uses your product name, logo, domain-like name, or publisher identity in a way that can confuse customers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Save the exact URLs, repository owner, commit hashes, release files, package identifiers, screenshots, timestamps, download hashes, and the original files that show your earlier authorship. Record what is copied rather than only stating that the project is â€œa crack.â€ If the download might be malicious, do not run it on your development machine or upload customer data to it.&lt;/p&gt;

&lt;p&gt;The distinction matters. A copied codebase can support a copyright complaint. A fake publisher using your name may create a trademark or impersonation issue. A single leaked license is primarily an access-control incident. A clean-room competitor implementing the same idea may be frustrating without being a copy of your protected expression.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why nothing shipped to a customer's machine is unbreakable
&lt;/h2&gt;

&lt;p&gt;A desktop, Unity, or Electron application eventually runs instructions on hardware the customer controls. A sufficiently motivated analyst can inspect the binary, modify branches, intercept calls, replace bundled JavaScript, or patch the code that handles a server response. Obfuscation raises the time and skill required; it does not change that boundary.&lt;/p&gt;

&lt;p&gt;That does not make licensing pointless. A lock does not need to defeat every specialist forever. It needs to stop casual copying, keep one legitimate key from becoming a public key, give paying customers a smoother path than piracy, and let you react when abuse becomes visible. The useful question is not â€œcan this ever be cracked?â€ It is â€œwhat value does the cracked build lose, how quickly can we respond, and what does enforcement cost honest users?â€&lt;/p&gt;

&lt;p&gt;Avoid the common overreaction of stacking invasive anti-tamper checks until antivirus tools flag the app or legitimate users lose access offline. For most indie products, server-authoritative entitlements, sensible &lt;a href="https://permitcore.dev/blog/device-activation-hwid" rel="noopener noreferrer"&gt;device activation&lt;/a&gt;, signed offline state, and predictable recovery provide a better trade than an escalating war against debuggers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takedowns in practice: use the right claim
&lt;/h2&gt;

&lt;p&gt;A recent &lt;a href="https://news.ycombinator.com/item?id=49982498" rel="noopener noreferrer"&gt;Hacker News discussion about copied Photopea builds&lt;/a&gt; is a useful caution. The developer said GitHub replied after a month that it could not confirm a violation of 17 U.S.C. Â§1201. That section concerns circumvention of technological protection measures. It is not interchangeable with the ordinary notice-and-takedown process for material that copies a copyrighted work.&lt;/p&gt;

&lt;p&gt;For an unauthorized copy of your code, binary, art, documentation, or package, the relevant route may instead be a copyright notice under Â§512. The &lt;a href="https://www.copyright.gov/512/" rel="noopener noreferrer"&gt;U.S. Copyright Office's Â§512 guidance&lt;/a&gt; says a notice generally identifies the protected work and the material to remove, provides contact information, includes good-faith and accuracy statements, and carries the owner or agent's signature. Registration is not required merely to send a notice, although U.S. works generally must be registered before filing an infringement lawsuit.&lt;/p&gt;

&lt;p&gt;GitHub publishes a separate &lt;a href="https://docs.github.com/en/site-policy/content-removal-policies/guide-to-submitting-a-dmca-takedown-notice" rel="noopener noreferrer"&gt;guide for submitting a DMCA takedown notice&lt;/a&gt; and explains its process publicly. Follow the platform's current form, identify specific files or releases, and explain where the original work appears. Do not casually make a sworn claim about material you have not compared.&lt;/p&gt;

&lt;p&gt;Use this escalation order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Preserve evidence before the repository, listing, or account changes.&lt;/li&gt;
&lt;li&gt;Use the host or marketplace's copyright, impersonation, malware, or trademark channel that matches the facts.&lt;/li&gt;
&lt;li&gt;If the copy is hosted elsewhere, identify the hosting provider and its designated copyright contact rather than arguing with the uploader indefinitely.&lt;/li&gt;
&lt;li&gt;Report search results separately when a search engine exposes a persistent infringing URL.&lt;/li&gt;
&lt;li&gt;Escalate to counsel when a counter-notice arrives, the platform rejects a complete notice, the copy impersonates your business, or the commercial damage justifies it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Trademark can help when someone is presenting the copy as your product or confusing buyers about its source. It does not give ownership of a generic feature or software idea. Keep release records, dated screenshots, package-signing history, and consistent use of your product name; if the brand is valuable, discuss registration and enforcement strategy with a trademark professional.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to make a crack worth less
&lt;/h2&gt;

&lt;p&gt;The strongest practical defense is to keep changing value outside the copied binary. A pirated build may launch today, but it should not automatically receive every benefit of an active customer relationship.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Updates:&lt;/strong&gt; deliver signed releases through an authenticated update channel. A copied old build can keep running without silently becoming the latest paid version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud or team features:&lt;/strong&gt; keep collaboration, sync, managed assets, usage quotas, or hosted processing behind an account and current entitlement when those features genuinely need a server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Support and recovery:&lt;/strong&gt; give customers device resets, account recovery, invoices, and responsive help that an anonymous download cannot provide.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Entitlements:&lt;/strong&gt; return a product, edition, expiry, activation limit, and explicit feature setâ€”not one permanent boolean. &lt;a href="https://permitcore.dev/blog/feature-based-licensing" rel="noopener noreferrer"&gt;Feature-based licensing&lt;/a&gt; lets the product evolve without shipping a different security model for every tier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authenticity:&lt;/strong&gt; code-sign installers and updates so customers can distinguish your release from a modified upload.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not move arbitrary functionality to a server only to punish pirates. A calculator that becomes unusable on a flight has lost product quality, not gained security. Keep the online boundary where it creates real value or where current state matters, and use explicit offline policy for the rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Signed responses beat a local true/false check
&lt;/h2&gt;

&lt;p&gt;The easiest licensing check to patch looks like this: read a local file, compare a string, return &lt;code&gt;true&lt;/code&gt;. The attacker only needs to change one branch or replace the file.&lt;/p&gt;

&lt;p&gt;A better online design sends the key's lookup value, product identity, app version, and device identity to the licensing service over TLS. The service decides the current state and returns structured data: valid or invalid, reason, expiry, edition, features, activation allowance, and trial state. Your app should fail safely when the response is malformed and should not accept a response for a different product.&lt;/p&gt;

&lt;p&gt;For offline use, cache a short-lived payload signed by a private key held only by the service. Ship only the public verification key in the application. The app verifies the signature, product, device, expiry, and allowed offline window before trusting it. The &lt;a href="https://permitcore.dev/blog/offline-license-validation-csharp" rel="noopener noreferrer"&gt;C# signed-token walkthrough&lt;/a&gt; and &lt;a href="https://permitcore.dev/tutorials/offline-license-validation-cpp" rel="noopener noreferrer"&gt;C++ offline validation tutorial&lt;/a&gt; show the model in concrete code.&lt;/p&gt;

&lt;p&gt;A signature prevents an attacker from inventing or editing an authentic entitlement payload without detection. It does &lt;strong&gt;not&lt;/strong&gt; prevent someone from patching your application so it skips verification entirely. That is why signed state is one layer, not a claim of uncrackable software. Keep the decision distributed across meaningful product boundaries, and avoid a single obvious function whose only job is to unlock everything.&lt;/p&gt;

&lt;p&gt;For the current server-side contract, see the &lt;a href="https://permitcore.dev/docs/api/validate" rel="noopener noreferrer"&gt;validation API&lt;/a&gt; and the security boundaries in &lt;a href="https://permitcore.dev/docs/security" rel="noopener noreferrer"&gt;PermitCore's security documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Detecting and revoking leaked license keys
&lt;/h2&gt;

&lt;p&gt;If a genuine key leaks, do not rotate every customer's key. Identify the affected license first. Look for a sudden increase in unique devices, impossible geography, repeated activation-limit failures, unusual app versions, or validation volume that does not match the customer's plan.&lt;/p&gt;

&lt;p&gt;Then choose a proportionate response:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Verify the signal.&lt;/strong&gt; A new laptop, VPN, classroom, render farm, or shared team license can look unusual without being abuse.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stop new activations.&lt;/strong&gt; Freeze or reduce the affected key's activation allowance while preserving the evidence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contact the customer.&lt;/strong&gt; A buyer may be the victim of malware, a public support paste, or an ex-employee rather than the source of deliberate redistribution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Revoke and replace.&lt;/strong&gt; Revoke the leaked credential, issue a replacement to the verified owner, and invalidate active sessions or devices that should no longer work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shorten stale access.&lt;/strong&gt; Previously signed offline tokens remain usable until their expiry. Use an offline window that matches the product's real needs, not an effectively permanent cache.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Activation limits are not just a purchase-time restriction; they create the operational signal that one key is spreading. The &lt;a href="https://permitcore.dev/docs/activation-pool" rel="noopener noreferrer"&gt;activation-pool documentation&lt;/a&gt;, &lt;a href="https://permitcore.dev/docs/license-controls" rel="noopener noreferrer"&gt;license controls&lt;/a&gt;, and guide to &lt;a href="https://permitcore.dev/blog/prevent-license-key-sharing" rel="noopener noreferrer"&gt;preventing license-key sharing&lt;/a&gt; cover the mechanics and the false-positive tradeoffs.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to turn some pirates into customers
&lt;/h2&gt;

&lt;p&gt;Not every unauthorized user was a lost full-price sale. Some could not evaluate the product, could not pay in their region, feared a subscription, needed it once, or did not trust a small vendor enough to buy before trying. Others simply will not pay. Treating all of them as the same customer leads to bad pricing and worse product decisions.&lt;/p&gt;

&lt;p&gt;Make the legitimate route obviously better:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Offer a useful trial that starts server-side and survives reinstall attempts without collecting invasive hardware data. See the &lt;a href="https://permitcore.dev/blog/software-free-trial-license" rel="noopener noreferrer"&gt;software trial implementation guide&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Price for the audience you actually have: indie, commercial, team, education, and regional cases may need different paths.&lt;/li&gt;
&lt;li&gt;Let a buyer deactivate an old machine and recover access without waiting days for support.&lt;/li&gt;
&lt;li&gt;Explain perpetual versus subscription rights, offline behavior, update eligibility, and refund terms before checkout.&lt;/li&gt;
&lt;li&gt;For Unity tools, make the official package easier to update and verify than a forum re-upload. The &lt;a href="https://permitcore.dev/tutorials/sell-unity-game-asset-licenses" rel="noopener noreferrer"&gt;Unity asset licensing tutorial&lt;/a&gt; shows a product-scoped flow.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A respectful â€œthis copy cannot receive updates; start a trial or enter a valid licenseâ€ screen usually converts better than deleting user files, shaming the user, or pretending a network error is corruption. Never make anti-piracy code destructive. The person seeing the message may have bought the product and hit a recoverable licensing problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist for the first 30 minutes
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Minute 0â€“5: preserve.&lt;/strong&gt; Save URLs, screenshots, timestamps, account names, hashes, repository commit IDs, and a copy of the relevant public material. Do not interact with suspicious binaries on your normal machine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minute 5â€“10: classify.&lt;/strong&gt; Decide whether this is a cracked binary, leaked key, keygen, copied source/assets, re-upload, impersonation, or a combination.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minute 10â€“15: contain.&lt;/strong&gt; If a specific credential is confirmed leaked, block new activations or suspend that license. Do not revoke unrelated customers or ship an emergency build without testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minute 15â€“20: notify.&lt;/strong&gt; Use the platform channel that matches the evidenceâ€”copyright, trademark, impersonation, malware, or licensing-key abuse. Be specific and truthful.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minute 20â€“25: protect customers.&lt;/strong&gt; Publish a short notice only if users could confuse the copy with your release or run malware. Point to your canonical download and code-signing identity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minute 25â€“30: plan the next build.&lt;/strong&gt; Add one measured improvement: shorter signed offline state, product-scoped validation, clearer feature entitlements, activation telemetry, authenticated updates, or better trial conversion.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After the immediate response, write a short incident record: what leaked, when it was discovered, which users or keys were affected, what you changed, and what you deliberately did not change. That keeps the next incident from becoming another improvised emergency.&lt;/p&gt;

&lt;p&gt;You cannot make client-side software impossible to copy. You can make unauthorized copies stale, disconnected, harder to trust, and less convenient than buying. More importantly, you can build an incident process that protects revenue without treating every legitimate customer as an attacker.&lt;/p&gt;




&lt;p&gt;Have you ever found a cracked or re-uploaded copy of your own software, and what did you do first? ðŸ™‚&lt;/p&gt;

</description>
      <category>security</category>
      <category>licensing</category>
      <category>indiedev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Licensing a WordPress Plugin: Sites, Staging Copies and Gated Updates</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Sun, 15 Nov 2026 09:38:53 +0000</pubDate>
      <link>https://dev.to/permitcore/licensing-a-wordpress-plugin-sites-staging-copies-and-gated-updates-56lc</link>
      <guid>https://dev.to/permitcore/licensing-a-wordpress-plugin-sites-staging-copies-and-gated-updates-56lc</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/wordpress-plugin-license-key" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A WordPress plugin license key needs a policy for sites, staging copies and updates. A customer can clone a database, move from HTTP to HTTPS or restore a backup without buying a new product. Decide which changes represent a new licensed installation before writing the activation call. Keep published pages available while the licensing check runs.&lt;/p&gt;

&lt;p&gt;This guide uses PermitCore PHP SDK 2.1.1 and a single-site plugin example. It also explains the decisions a theme developer needs to make. The code is an integration example you package and test yourself; it is not an official WordPress plugin or updater library. Start with &lt;a href="https://permitcore.dev/blog/getting-started-first-license" rel="noopener noreferrer"&gt;issuing your first license&lt;/a&gt; if you do not yet have a product and a test key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the site becomes the device identifier
&lt;/h2&gt;

&lt;p&gt;PermitCore's existing activation endpoint accepts a &lt;code&gt;deviceId&lt;/code&gt;. Here, the plugin chooses that value from the site's normalized hostname. This does not introduce a domain activation type, prove domain ownership or discover which WordPress installation is genuine. A site administrator controls the PHP code and the WordPress configuration.&lt;/p&gt;

&lt;p&gt;For this production example, configure a node-locked test license with one activation slot. A known device can reactivate without consuming another seat; a different device cannot take an occupied single seat. These are tested activation behaviors. The &lt;a href="https://permitcore.dev/blog/prevent-license-key-sharing" rel="noopener noreferrer"&gt;license sharing guide&lt;/a&gt; discusses what client checks can enforce and where your own server needs to make the final decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Normalize the hostname from home_url()
&lt;/h2&gt;

&lt;p&gt;Use the site's configured &lt;code&gt;home_url()&lt;/code&gt;, which describes its public address. The request's Host header is an unsuitable licensing identity. Parse the hostname, lowercase it, remove a terminal dot and deliberately collapse a leading &lt;code&gt;www.&lt;/code&gt;. Ignore scheme, port, path and trailing slash. Under this policy, &lt;code&gt;http://www.example.com/&lt;/code&gt; and &lt;code&gt;https://example.com:8443/shop/&lt;/code&gt; share one identifier.&lt;/p&gt;

&lt;p&gt;That equivalence is a product decision. Different applications under the same hostname also share a seat here. If your offer licenses subdirectories separately, design and test a different identifier before launch. Use ASCII hostnames, including an explicitly configured punycode hostname where needed; this example does not implement internationalized-domain conversion. WordPress documents the underlying &lt;a href="https://developer.wordpress.org/reference/functions/home_url/" rel="noopener noreferrer"&gt;home_url function&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;site-policy.php&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;
&lt;span class="k"&gt;declare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strict_types&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;acme_site_host&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;strtolower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;rtrim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;wp_parse_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;home_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;PHP_URL_HOST&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;str_starts_with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'www.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;substr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;acme_nonproduction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;wp_get_environment_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'production'&lt;/span&gt;
        &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;in_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'localhost'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'127.0.0.1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'[::1]'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;str_ends_with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'.localhost'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;str_ends_with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'.local'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;str_ends_with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'.test'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;str_starts_with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'staging.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;acme_license_scope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sha256'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"\0"&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"\0"&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="no"&gt;ACME_PRODUCT_ID&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"\0"&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nf"&gt;wp_get_environment_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;acme_entitled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;get_option&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_key'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;acme_site_host&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$good&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_option&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_good'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;is_multisite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
        &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nf"&gt;is_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$good&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$good&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'scope'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nf"&gt;acme_license_scope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$good&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'until'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use the real PHP activation and validation calls
&lt;/h2&gt;

&lt;p&gt;Install &lt;code&gt;permitcore/sdk&lt;/code&gt; with Composer in your build workspace, then package its &lt;code&gt;vendor&lt;/code&gt; directory with the example files. Require PHP 8.0 or later and the SDK's cURL, JSON and OpenSSL extensions. Replace the sample product GUID with the public product ID from your account. The API base URL and product ID are configuration, while management credentials belong on your controlled backend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require permitcore/sdk:2.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The refresh function below sends &lt;code&gt;wp-host:&lt;/code&gt; plus the normalized hostname to &lt;code&gt;activate()&lt;/code&gt; on production. Repeating that call on a node-locked license uses the same device identity. On a recognized development or staging installation, it calls &lt;code&gt;validate()&lt;/code&gt;, which checks the key and expected product without allocating an activation. The SDK handles the activation nonce.&lt;/p&gt;

&lt;p&gt;Always pass &lt;code&gt;expectedProductId&lt;/code&gt;. A key for another product must not unlock this plugin. Read &lt;code&gt;isValid&lt;/code&gt; and the machine-readable &lt;code&gt;errorCode&lt;/code&gt;, including &lt;code&gt;WrongProduct&lt;/code&gt;; an HTTP 200 response can still contain a rejected license. The &lt;a href="https://permitcore.dev/docs/sdks/php" rel="noopener noreferrer"&gt;PHP SDK reference&lt;/a&gt; and &lt;a href="https://permitcore.dev/docs/api/errors" rel="noopener noreferrer"&gt;API error reference&lt;/a&gt; describe those contracts.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;refresh.php&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;
&lt;span class="k"&gt;declare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strict_types&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;PermitCore&lt;/span&gt;\&lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;acme_refresh_license&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt; &lt;span class="nv"&gt;$client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;get_option&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_key'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;acme_site_host&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;is_multisite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;delete_option&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_good'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nv"&gt;$client&lt;/span&gt; &lt;span class="o"&gt;??=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s1"&gt;'https://api.permitcore.dev'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;enableOfflineCache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'wp-host:'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maxRetries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;acme_nonproduction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nv"&gt;$client&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expectedProductId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;ACME_PRODUCT_ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$client&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;activate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'wp-host:'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deviceName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;expectedProductId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;ACME_PRODUCT_ID&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;isValid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$until&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;DAY_IN_SECONDS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;expiresAt&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$until&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$until&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;strtotime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;expiresAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nf"&gt;update_option&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_good'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'scope'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;acme_license_scope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'until'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$until&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nf"&gt;set_transient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_notice'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'License checked.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;HOUR_IN_SECONDS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;elseif&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;errorCode&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'RequestFailed'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Retain the previous deadline. An outage never extends it.&lt;/span&gt;
        &lt;span class="nf"&gt;set_transient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_notice'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Check delayed; retry later.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;HOUR_IN_SECONDS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;delete_option&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_good'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nf"&gt;set_transient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_notice'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'License needs attention.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;HOUR_IN_SECONDS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Staging, localhost and multisite need explicit rules
&lt;/h2&gt;

&lt;p&gt;The hostname helper recognizes localhost, loopback addresses, &lt;code&gt;*.localhost&lt;/code&gt;, &lt;code&gt;*.local&lt;/code&gt;, &lt;code&gt;*.test&lt;/code&gt; and a &lt;code&gt;staging.&lt;/code&gt; prefix. It also respects any &lt;code&gt;wp_get_environment_type()&lt;/code&gt; value other than production. A name such as &lt;code&gt;staging-shop.example.com&lt;/code&gt; does not match the prefix rule. Set the environment explicitly when a hosting provider uses another convention.&lt;/p&gt;

&lt;p&gt;Development detection changes this example's choice of SDK call. It does not create a PermitCore-enforced staging allowance or grant access without a valid key. An operator can change the environment flag, so it cannot independently protect a download service against abuse. WordPress describes the supported values and production default in its &lt;a href="https://developer.wordpress.org/reference/functions/wp_get_environment_type/" rel="noopener noreferrer"&gt;environment type reference&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Multisite needs another commercial decision. Subdirectory sites can share a hostname; mapped domains can differ. A network-wide purchase and a purchase for each blog need different identifiers, storage and administration permissions. This example checks &lt;code&gt;is_multisite()&lt;/code&gt; and declines to authorize premium operations there. It leaves the front end running and displays an admin notice. Implement and test the network policy separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Schedule checks and keep settings behind administrator permissions
&lt;/h2&gt;

&lt;p&gt;Place all three PHP files in your plugin directory. The bootstrap below schedules one hourly event when the plugin activates and removes it on deactivation. Saving a key schedules a check rather than waiting for an API call inside the settings form. The frontend does not make a blocking license request on every page load.&lt;/p&gt;

&lt;p&gt;WP-Cron runs due work when WordPress gets traffic; hourly scheduling is not a promise that a request executes at an exact minute. Use a properly configured system cron trigger if your deployment needs predictable checking. An expired local deadline stays expired even when the scheduled event is late. See WordPress's &lt;a href="https://developer.wordpress.org/reference/functions/wp_schedule_event/" rel="noopener noreferrer"&gt;recurring event reference&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The settings page and save handler both require &lt;code&gt;manage_options&lt;/code&gt;. The handler verifies a nonce before changing the stored key. Output is escaped, the existing key is never printed back into the form, and changing the key clears the previous entitlement. Store the customer key with autoload disabled, restrict access to database backups and avoid logging request bodies. This example does not encrypt WordPress options.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;plugin.php&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;
&lt;span class="cm"&gt;/**
 * Plugin Name: Acme licensing example
 * Requires PHP: 8.0
 */&lt;/span&gt;
&lt;span class="k"&gt;declare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strict_types&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;require_once&lt;/span&gt; &lt;span class="n"&gt;__DIR__&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/vendor/autoload.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;require_once&lt;/span&gt; &lt;span class="n"&gt;__DIR__&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/site-policy.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;require_once&lt;/span&gt; &lt;span class="n"&gt;__DIR__&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/refresh.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Replace with your product's public GUID before packaging.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;ACME_PRODUCT_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'11111111-2222-3333-4444-555555555555'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;register_activation_hook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__FILE__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;is_multisite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;wp_next_scheduled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_check'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;wp_schedule_event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'hourly'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'acme_license_check'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;register_deactivation_hook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__FILE__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;wp_clear_scheduled_hook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_check'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;add_action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_check'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'acme_refresh_license'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;add_action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'admin_menu'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;add_options_page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Acme license'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Acme license'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'manage_options'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'acme-license'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'acme_license_page'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;acme_license_page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;current_user_can&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'manage_options'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;wp_die&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;esc_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Permission denied.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'response'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;form method="post" action="'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nf"&gt;esc_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;admin_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'admin-post.php'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'"&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;wp_nonce_field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_save_license'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;input type="hidden" name="action" value="acme_save_license"&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;label&amp;gt;License key &amp;lt;input name="license_key" type="password" value="" required autocomplete="off"&amp;gt;&amp;lt;/label&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;button type="submit"&amp;gt;Save and schedule check&amp;lt;/button&amp;gt;&amp;lt;/form&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'
'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nf"&gt;esc_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;get_transient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_notice'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'
'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;is_multisite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'
'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nf"&gt;esc_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'This example requires a separate multisite policy.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'
'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;add_action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'admin_post_acme_save_license'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;current_user_can&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'manage_options'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;wp_die&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;esc_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Permission denied.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'response'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;check_admin_referer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_save_license'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;wp_unslash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_POST&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'license_key'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;wp_die&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;esc_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Enter a license key.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;update_option&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_key'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;delete_option&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'acme_license_good'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;is_multisite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;wp_schedule_single_event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'acme_license_check'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;wp_safe_redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;admin_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'options-general.php?page=acme-license'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;add_filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'pre_set_site_transient_update_plugins'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$updates&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;is_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$updates&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;acme_entitled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;unset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$updates&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;plugin_basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__FILE__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$updates&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Call acme_entitled() before a paid admin operation.&lt;/span&gt;
&lt;span class="c1"&gt;// Keep ordinary frontend rendering independent of this decision.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Handle an unreachable API without taking the site down
&lt;/h2&gt;

&lt;p&gt;The example disables the SDK's offline cache and implements a local, bounded convenience policy for the plugin's paid admin operations. A successful check records the current key/site/product/environment scope and a deadline of at most 24 hours, capped by the returned license expiry. A timeout reported as &lt;code&gt;RequestFailed&lt;/code&gt; preserves that deadline. It never creates a first success or moves the deadline forward.&lt;/p&gt;

&lt;p&gt;This WordPress option is editable by the site operator. It is not signed PermitCore offline proof and does not authorize server-hosted downloads. PermitCore's PHP signed cache has separate trusted-public-key and context requirements, described in the &lt;a href="https://permitcore.dev/blog/offline-grace-mode" rel="noopener noreferrer"&gt;offline grace guide&lt;/a&gt;. Choose and test one policy deliberately instead of treating an arbitrary saved “valid” flag as cryptographic verification.&lt;/p&gt;

&lt;p&gt;Every other negative result clears this sample's entitlement. That includes wrong-product, expired or missing-key decisions, HTTP rejections and malformed responses. Show a quiet “check delayed” message for a connection failure and an actionable licensing message for a rejection. Neither condition calls a frontend shutdown function. Keep existing content rendering independent of &lt;code&gt;acme_entitled()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Put the entitlement check at the boundary of each new paid operation, such as an administrator starting a premium export. Keep previously saved posts, configuration and ordinary rendering accessible when the deadline passes. An update notice is feedback; your download endpoint is a separate authorization boundary. If a premium component contributes frontend output, define how existing content keeps rendering before adding the licensing condition. Test that behavior with the API disconnected as well as with a deliberately rejected key, using a disposable copy of a representative customer site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate update offers and authorize the ZIP separately
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;pre_set_site_transient_update_plugins&lt;/code&gt; filter removes only this plugin's update entry when its cached entitlement is unavailable. It does not generate release metadata or a package URL. Your distribution service must already provide those. A theme needs its corresponding update hook and a separately tested implementation.&lt;/p&gt;

&lt;p&gt;Protect the ZIP download on your server. Recheck the product and entitlement there before issuing short-lived download authorization. A public ZIP URL remains public even when WordPress hides its update notice. Keep management API keys out of the installed plugin, and test that a direct unauthenticated download is denied. The guide to &lt;a href="https://permitcore.dev/blog/how-to-build-a-license-key-system" rel="noopener noreferrer"&gt;building a licensing system&lt;/a&gt; explains the client/server boundary.&lt;/p&gt;

&lt;p&gt;When a revocation or refunded purchase leads to a negative license decision, the refresh clears the local entitlement. That becomes visible at the next successful check, subject to this example's bounded outage window. Your commerce integration owns the refund-to-license decision; the updater filter does not process payments. See &lt;a href="https://permitcore.dev/blog/revoke-license-after-failed-payment" rel="noopener noreferrer"&gt;license handling after a failed payment&lt;/a&gt; and &lt;a href="https://permitcore.dev/blog/license-error-messages" rel="noopener noreferrer"&gt;license error messages&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Move a license without inventing an activation ID
&lt;/h2&gt;

&lt;p&gt;The PHP SDK's &lt;code&gt;activate()&lt;/code&gt; result does not expose an &lt;code&gt;activationId&lt;/code&gt;. Do not fabricate one from the hostname or key. This example directs customers to their existing account's device list, where they select and confirm removal of the old activation, then save the key on the new production site. Account ownership and any configured removal policy still apply.&lt;/p&gt;

&lt;p&gt;The SDK has &lt;code&gt;deactivate(tenantSlug, licenseKey, activationId)&lt;/code&gt;, but calling it requires the actual selected activation ID and a permitted removal flow. It does not supply a complete WordPress transfer UI. The &lt;a href="https://permitcore.dev/blog/how-to-transfer-a-software-license-to-a-new-computer" rel="noopener noreferrer"&gt;license transfer guide&lt;/a&gt; covers the existing lifecycle. A restored backup with a different hostname cannot reuse this example's old local success record.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before selling a premium plugin or theme
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write down the licensed unit, www equivalence, staging policy and multisite decision.&lt;/li&gt;
&lt;li&gt;Exercise production activation, repeated activation and a second hostname against a single-seat test license.&lt;/li&gt;
&lt;li&gt;Test wrong-product keys, revocation, timeouts, expired local state and copied WordPress databases.&lt;/li&gt;
&lt;li&gt;Verify settings permissions, nonce rejection, escaped notices and the absence of plaintext keys in logs.&lt;/li&gt;
&lt;li&gt;Authorize downloads on your server and keep ordinary site rendering available through all failure paths.&lt;/li&gt;
&lt;li&gt;Run the supplied hostname and policy tests, then test your packaged plugin on the WordPress/PHP versions you support.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The accompanying tests exercise the exact example files with WordPress function stubs and the real PHP SDK's method signatures. They do not establish a hosted WordPress integration. Treat this as a starting implementation whose packaging, update service and supported environments you still verify.&lt;/p&gt;




&lt;p&gt;We are a young startup and keep publishing guides like this one. If you sell a premium WordPress plugin or theme: how do you treat staging copies and cloned databases today, and which part of the update/download flow took the most work? 🙂&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>php</category>
      <category>webdev</category>
      <category>security</category>
    </item>
    <item>
      <title>Electron License Checks: Keep the Decision Out of app.asar's Reach</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Fri, 13 Nov 2026 09:34:28 +0000</pubDate>
      <link>https://dev.to/permitcore/electron-license-checks-keep-the-decision-out-of-appasars-reach-2hde</link>
      <guid>https://dev.to/permitcore/electron-license-checks-keep-the-decision-out-of-appasars-reach-2hde</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/electron-app-license-check" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every Electron app ships its JavaScript inside &lt;code&gt;app.asar&lt;/code&gt;, and anyone can extract that archive. If your paid features are guarded by a single &lt;code&gt;if (isLicensed)&lt;/code&gt; in the renderer, cracking the app is a matter of editing one line and repacking. The fix is structural rather than clever obfuscation: the main process owns the license decision, the renderer only ever sees a status string, fuses and ASAR integrity make tampered packages refuse to start, and offline proof is a server-signed token your app verifies with a public key.&lt;/p&gt;

&lt;p&gt;This walkthrough covers each of those layers with working code. If you have not issued and validated a first key yet, start with &lt;a href="https://permitcore.dev/tutorials/license-sell-electron-app" rel="noopener noreferrer"&gt;how to add licensing to an Electron app&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Electron apps are easy to crack: app.asar is your source code
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;app.asar&lt;/code&gt; packages your application's files. It provides convenient distribution and can hide source from casual browsing, but its JavaScript is still readable after extraction. A renderer-only flag is especially easy to override. Someone who can modify the renderer can skip the conditional that hides a paid menu and call whatever is behind it.&lt;/p&gt;

&lt;p&gt;Minifying JavaScript can make inspection less convenient. It cannot give bundled code the same protection as a server-held signing key. Keep private signing keys and vendor API credentials outside the package, including source maps and release configuration. &lt;a href="https://www.electronjs.org/docs/latest/tutorial/asar-archives" rel="noopener noreferrer"&gt;Electron's ASAR archive documentation&lt;/a&gt; explains how packaged files are accessed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule #1: the license check lives in the main process, not the renderer
&lt;/h2&gt;

&lt;p&gt;Read the user-entered key from protected local storage in the main process. Validate with the app version and expected product ID there, and store the decision there. If a paid export runs through IPC, its main-process handler must check the current entitlement immediately before doing the work. Disabling an Export button is useful feedback. The handler is where access is enforced.&lt;/p&gt;

&lt;p&gt;Start the window with a checking state and let the main process validate asynchronously. Gate paid operations while that decision is pending. Keep any free or read-only flows available according to your product policy. The &lt;a href="https://permitcore.dev/blog/license-check-at-app-startup" rel="noopener noreferrer"&gt;startup licensing guide&lt;/a&gt; shows how to keep this path responsive during timeouts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exposing only license status to the UI with contextBridge and IPC
&lt;/h2&gt;

&lt;p&gt;Keep &lt;code&gt;contextIsolation&lt;/code&gt; and renderer sandboxing enabled, with &lt;code&gt;nodeIntegration&lt;/code&gt; off. Load a bundled renderer, restrict navigation and new windows, and validate the IPC sender. The following main-process module takes an existing &lt;code&gt;BrowserWindow&lt;/code&gt;, the exact URL you load into it and your main-process key reader. Register the handler once for that window, then call &lt;code&gt;refreshLicense&lt;/code&gt; from the main process. The getter cannot start a request or return the key, token or raw provider response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// main-license.cjs&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ipcMain&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'electron'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'@permitcore/permitcore'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'node:path'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;installLicenseStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rendererUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;readKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'https://api.permitcore.dev'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;trustedPublicKeys&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;publicKeys&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;cacheDirectory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'userData'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'license-cache'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'checking'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;ipcMain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'license:status'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;senderFrame&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;webContents&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
        &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;webContents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mainFrame&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
        &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;rendererUrl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Invalid license sender'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;refreshLicense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'checking'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;readKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getVersion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;productId&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isValid&lt;/span&gt;
        &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isOffline&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'offline'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'active'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'restricted'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'restricted'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;installLicenseStatus&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// preload.cjs&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;contextBridge&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ipcRenderer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'electron'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;contextBridge&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exposeInMainWorld&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'license'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;getStatus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ipcRenderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'license:status'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The renderer calls &lt;code&gt;window.license.getStatus()&lt;/code&gt; and displays &lt;code&gt;checking&lt;/code&gt;, &lt;code&gt;active&lt;/code&gt;, &lt;code&gt;offline&lt;/code&gt; or &lt;code&gt;restricted&lt;/code&gt;. Give each privileged IPC operation its own narrow interface and authorization check. &lt;a href="https://www.electronjs.org/docs/latest/tutorial/context-isolation" rel="noopener noreferrer"&gt;Electron's context isolation guide&lt;/a&gt; and &lt;a href="https://www.electronjs.org/docs/latest/tutorial/security#17-validate-the-sender-of-all-ipc-messages" rel="noopener noreferrer"&gt;IPC sender guidance&lt;/a&gt; explain these boundaries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Electron fuses that close the obvious bypasses
&lt;/h2&gt;

&lt;p&gt;Fuses change features in the packaged Electron binary. For the macOS or Windows release in this example, disable &lt;code&gt;RunAsNode&lt;/code&gt;, &lt;code&gt;EnableNodeOptionsEnvironmentVariable&lt;/code&gt; and &lt;code&gt;EnableNodeCliInspectArguments&lt;/code&gt; to remove unused ways to run Node or attach its inspector. Turning off RunAsNode can break &lt;code&gt;child_process.fork&lt;/code&gt; in Electron. Check that your app and its dependencies do not require these features.&lt;/p&gt;

&lt;p&gt;Enable &lt;code&gt;OnlyLoadAppFromAsar&lt;/code&gt; to prevent falling back to an unpacked app directory. Pair it with &lt;code&gt;EnableEmbeddedAsarIntegrityValidation&lt;/code&gt; on supported targets. Run this example with the packaged app or executable path before signing, and integrate the equivalent settings into your package hooks in production. &lt;a href="https://www.electronjs.org/docs/latest/tutorial/fuses" rel="noopener noreferrer"&gt;Electron documents each fuse and its defaults&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// set-fuses.mjs — run on the packaged macOS or Windows artifact&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;flipFuses&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FuseVersion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FuseV1Options&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@electron/fuses'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;packagedApp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;packagedApp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Provide the packaged app path'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;flipFuses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;packagedApp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FuseVersion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;V1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;FuseV1Options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RunAsNode&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;FuseV1Options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;EnableNodeOptionsEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;FuseV1Options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;EnableNodeCliInspectArguments&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;FuseV1Options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OnlyLoadAppFromAsar&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;FuseV1Options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;EnableEmbeddedAsarIntegrityValidation&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ASAR integrity and code signing: making "unpack, edit, repack" fail
&lt;/h2&gt;

&lt;p&gt;Electron documents ASAR integrity for macOS from Electron 16 and Windows from Electron 30. The binary needs the expected hash of the ASAR header, and the archive needs its integrity metadata. With ASAR enabled, Electron Packager 18.3.1 or later and Electron Forge 7.4.0 or later supply the package metadata. Flipping a fuse without that hash can make a legitimate package fail at launch.&lt;/p&gt;

&lt;p&gt;Package and set fuses before signing. Sign the resulting artifacts and notarize macOS releases for direct distribution. The integrity check can detect an archive change on its own. Signing and the platform's signature enforcement make it meaningful against replacement of both the archive and its expected hash or binary. Test on a clean machine with the same enforcement your customers use. Verify an unchanged release starts, then test archive tampering on a disposable copy. &lt;a href="https://www.electronjs.org/docs/latest/tutorial/asar-integrity" rel="noopener noreferrer"&gt;ASAR integrity&lt;/a&gt; and &lt;a href="https://www.electronjs.org/docs/latest/tutorial/code-signing" rel="noopener noreferrer"&gt;Electron code signing&lt;/a&gt; describe the packaging steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  No secrets in the bundle: server-signed tokens verified with a public key
&lt;/h2&gt;

&lt;p&gt;Keep the private signing key server-side. Ship trusted public keys with the app or through a trusted configuration channel. The public key verifies a signature without granting the ability to mint proof. Obtain trusted pins independently of an incoming token or cache file. Plan how to distribute replacement pins before retiring a key. See the &lt;a href="https://permitcore.dev/blog/license-signing-key-rotation" rel="noopener noreferrer"&gt;signing key rotation guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;PermitCore Node SDK 2.1.1 verifies signed &lt;code&gt;pc_grace_v1&lt;/code&gt; cache proof for network interruptions. It also supports a separate &lt;code&gt;pc_offline_v1&lt;/code&gt; token provisioned for offline activation. On installations designed to stay offline, call &lt;code&gt;activateOffline(token, deviceId, productId)&lt;/code&gt; for the provisioned token and &lt;code&gt;validateOffline(deviceId, productId)&lt;/code&gt; for subsequent checks against that saved proof. See &lt;a href="https://permitcore.dev/docs/offline-licensing" rel="noopener noreferrer"&gt;offline licensing&lt;/a&gt; for the trust and device requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Offline launches: cached signed validation and a grace period
&lt;/h2&gt;

&lt;p&gt;For normally connected apps, set a bounded offline grace period and configure &lt;code&gt;trustedPublicKeys&lt;/code&gt; before the first online validation. Use a private cache directory and a stable device ID. When a valid response includes signed grace proof, the SDK verifies it before caching. On a network failure, &lt;code&gt;validate&lt;/code&gt; can return &lt;code&gt;isValid: true&lt;/code&gt; and &lt;code&gt;isOffline: true&lt;/code&gt; from verified cache. The proof is bound to the key and product and, when applicable, the activated device. Its signed &lt;code&gt;validUntil&lt;/code&gt; limits offline use.&lt;/p&gt;

&lt;p&gt;Give customers a readable offline state and a way to reconnect. An explicit server rejection does not fall back to old proof on that request. A device that stays offline cannot learn about server-side revocation until it reconnects, and expired or invalid cached proof cannot authorize a new offline session. See &lt;a href="https://permitcore.dev/blog/offline-grace-mode" rel="noopener noreferrer"&gt;offline grace mode&lt;/a&gt; for policy choices.&lt;/p&gt;

&lt;h2&gt;
  
  
  What hardening can't stop (and why revocation and updates matter more)
&lt;/h2&gt;

&lt;p&gt;Someone who controls a machine can instrument it or replace the client. Fuses, IPC boundaries, signatures and short-lived proof raise the work required for common bypasses. Use verified server-side authorization for paid operations that already run on your infrastructure. Keep update artifacts signed and Electron current so you can ship fixes. Revalidate when connected according to your policy, and revoke compromised keys without punishing every customer.&lt;/p&gt;

&lt;p&gt;For abuse that involves a shared key instead of a modified app, review &lt;a href="https://permitcore.dev/blog/prevent-license-key-sharing" rel="noopener noreferrer"&gt;device and sharing limits&lt;/a&gt;. If you find a redistributed build, follow the response checklist in &lt;a href="https://permitcore.dev/blog/what-to-do-if-your-software-is-cracked" rel="noopener noreferrer"&gt;what to do when your software is cracked&lt;/a&gt;. Make recovery and legitimate offline use part of the same release test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it together with the PermitCore Node SDK (checklist)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;a href="https://permitcore.dev/docs/sdks/node" rel="noopener noreferrer"&gt;PermitCore Node SDK 2.1.1&lt;/a&gt; and construct the client only in the main process.&lt;/li&gt;
&lt;li&gt;Keep the key reader private. Call &lt;code&gt;validate(key, app.getVersion(), productId)&lt;/code&gt; and use the result at the paid operation boundary.&lt;/li&gt;
&lt;li&gt;Configure trusted public keys and cache storage. Test a valid key, an explicit rejection, a wrong product, a network outage, and expired or tampered offline proof.&lt;/li&gt;
&lt;li&gt;Verify the preload exposes only the status getter and a different frame cannot invoke it. Check that paid IPC handlers enforce the entitlement independently.&lt;/li&gt;
&lt;li&gt;Set fuses, generate ASAR integrity metadata, sign the final package and test update and tamper handling on each supported platform.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;We are a young startup and keep publishing guides like this one. If you ship an Electron app: which of these layers do you already have in your release pipeline, and which one would you add first? 🙂&lt;/p&gt;

</description>
      <category>electron</category>
      <category>javascript</category>
      <category>security</category>
      <category>licensing</category>
    </item>
    <item>
      <title>Open Core in a Public Repo: Gate Paid Features With License Keys, Not Secrecy</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Wed, 11 Nov 2026 09:34:42 +0000</pubDate>
      <link>https://dev.to/permitcore/open-core-in-a-public-repo-gate-paid-features-with-license-keys-not-secrecy-14g3</link>
      <guid>https://dev.to/permitcore/open-core-in-a-public-repo-gate-paid-features-with-license-keys-not-secrecy-14g3</guid>
      <description>&lt;p&gt;Your repository is public. Anyone can read the paid modules, fork them, and build them. So what actually separates the Community edition from the paid one?&lt;/p&gt;

&lt;p&gt;In open core and Fair Source projects the answer is not code secrecy. It is the &lt;strong&gt;license key&lt;/strong&gt;: a signed entitlement that tells one self-hosted installation which paid features it is allowed to use. This post walks through how to design that boundary so it stays fair to operators and practical for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open core vs Fair Source in one paragraph
&lt;/h2&gt;

&lt;p&gt;Classic open core keeps the core under an open source license and puts commercial modules in a separate directory (often &lt;code&gt;ee/&lt;/code&gt;) with their own terms. Fair Source goes a step further: the commercial code is readable, but the license limits certain uses of current versions and converts to a permissive license later. Keygen &lt;a href="https://keygen.sh/blog/keygen-is-now-fair-source/" rel="noopener noreferrer"&gt;moved to FCL&lt;/a&gt;, and Directus &lt;a href="https://directus.com/resources/directus-v12-license-change" rel="noopener noreferrer"&gt;announced an FCL-derived license for v12&lt;/a&gt; together with registration keys for paid users.&lt;/p&gt;

&lt;p&gt;Quick comparison (high level, &lt;strong&gt;not legal advice&lt;/strong&gt;, always read the exact terms you ship):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Separate &lt;code&gt;ee/&lt;/code&gt; terms&lt;/td&gt;
&lt;td&gt;Core and commercial modules carry different licenses; the repo makes the boundary obvious&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://fsl.software/" rel="noopener noreferrer"&gt;FSL&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Limits competing use; becomes Apache 2.0 or MIT after two years&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://fcl.dev/" rel="noopener noreferrer"&gt;FCL&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Limits competing use, protects license-key functionality, future license per chosen variant&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.elastic.co/licensing/elastic-license" rel="noopener noreferrer"&gt;ELv2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Restricts offering as a managed service, bypassing key functionality, removing notices&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The key is the line, and that is fine
&lt;/h2&gt;

&lt;p&gt;A self-hosted operator controls the binary. They can patch it. Accept that, and design for the honest majority:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sign the proof.&lt;/strong&gt; A modified config file should never be able to grant access in the unmodified product.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check where the paid operation runs&lt;/strong&gt;, on the server side, not only in the UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No mandatory telemetry, no remote kill switch.&lt;/strong&gt; Operators of self-hosted software care a lot about this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explain state clearly.&lt;/strong&gt; If a feature is unavailable, say why and how to restore it. Never lock people out of their own data.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Model features as entitlements, not editions
&lt;/h2&gt;

&lt;p&gt;Use stable entitlement identifiers instead of hard-coding "is this Pro?":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Community&lt;/strong&gt;: read and edit data (no key needed)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pro&lt;/strong&gt;: adds &lt;code&gt;exports&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enterprise&lt;/strong&gt;: adds &lt;code&gt;sso&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each paid operation checks its own entitlement. If the proof is invalid or scoped to another product, the paid operation is denied and Community keeps working.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nc"&gt;PermitCore&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nc"&gt;Exports&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nc"&gt;Sso&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;CheckFeatures&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Guid&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"PERMITCORE_LICENSE_KEY"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsNullOrWhiteSpace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ValidateAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expectedProductId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsValid&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;HasFeature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"exports"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsValid&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;HasFeature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"sso"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Air-gapped and flaky-network installs
&lt;/h2&gt;

&lt;p&gt;Self-hosted often means "no internet". Two patterns cover most cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Air-gapped&lt;/strong&gt;: ship a signed token file, ship trusted public keys through your release channel, and validate offline (signature, deadline, device, expected product).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Normally connected&lt;/strong&gt;: configure an offline grace period so signed cached proof keeps working through a network outage.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nc"&gt;AcceptOffline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Guid&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"PERMITCORE_OFFLINE_FILE"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsNullOrWhiteSpace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ActivateOffline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ReadAllText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsValid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Let customers keep what they paid for
&lt;/h2&gt;

&lt;p&gt;If your terms promise a perpetual fallback, keep that decision separate from license validation: compare the chosen build's release date with a trusted maintenance end date.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nc"&gt;CanUseRelease&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;LicenseResult&lt;/span&gt; &lt;span class="n"&gt;entitlement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;DateTime&lt;/span&gt; &lt;span class="n"&gt;releasedAtUtc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;entitlement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsValid&lt;/span&gt;
       &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entitlement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MaintenanceExpiresAt&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nc"&gt;DateTime&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;releasedAtUtc&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Docker, Kubernetes and CI
&lt;/h2&gt;

&lt;p&gt;Never bake the key into an image layer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker: &lt;code&gt;docker run --env PERMITCORE_LICENSE_KEY ...&lt;/code&gt; (inherits from the exported variable)&lt;/li&gt;
&lt;li&gt;Kubernetes: &lt;code&gt;env.valueFrom.secretKeyRef&lt;/code&gt; on the workload&lt;/li&gt;
&lt;li&gt;CI: map the protected secret to the same variable for integration tests&lt;/li&gt;
&lt;li&gt;Offline installs: mount the token file read-only and point &lt;code&gt;PERMITCORE_OFFLINE_FILE&lt;/code&gt; at it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep keys and token files out of build logs and public CI output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The examples use the PermitCore .NET SDK, which handles key issuing, entitlements and online/offline validation. The full guide, with links to the offline, grace-period and key-rotation deep dives, is on our blog: &lt;a href="https://permitcore.dev/blog/open-core-license-key" rel="noopener noreferrer"&gt;Open Core and Fair Source: gating paid features with license keys&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you ship open core or Fair Source: where do you draw the line between Community and paid, and do you check entitlements in the UI, the server, or both? 🙂&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>selfhosted</category>
      <category>licensing</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Selling Your Game Outside Steam: Keys, Downloads and a Direct Sale That Delivers Itself</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Mon, 09 Nov 2026 09:36:38 +0000</pubDate>
      <link>https://dev.to/permitcore/selling-your-game-outside-steam-keys-downloads-and-a-direct-sale-that-delivers-itself-3mip</link>
      <guid>https://dev.to/permitcore/selling-your-game-outside-steam-keys-downloads-and-a-direct-sale-that-delivers-itself-3mip</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/sell-game-outside-steam" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Selling your game directly, next to or instead of a big store, starts with one question: what exactly does the buyer get after paying? A Steam activation code, an itch.io download link, a DRM-free build and a build that checks its own license are four different things. They come from different systems and need different delivery and support. Naming the right one on your sales page is the first step to a smooth direct sale.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Pick the kind of access you sell
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Steam keys.&lt;/strong&gt; A Steam key activates the game inside Steam. You request keys through Steamworks, and selling them on your own site still gives the buyer a Steam entitlement. Read the current &lt;a href="https://partner.steamgames.com/doc/features/keys" rel="noopener noreferrer"&gt;Steam Key rules and guidelines&lt;/a&gt; before you plan bundles, backer rewards or discounts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;itch.io download keys.&lt;/strong&gt; An itch.io &lt;a href="https://itch.io/docs/creators/download-keys" rel="noopener noreferrer"&gt;download key&lt;/a&gt; is a private URL to your project's files on itch.io. It is a great fit when itch.io hosts your builds and you want to hand out access to backers or press.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A DRM-free build.&lt;/strong&gt; You sell a download and trust the buyer. Here the important parts are clear usage terms, a reliable download page and an easy way to get updates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your own licensed build.&lt;/strong&gt; Your game checks an entitlement you issued: the right product, a valid key, and the device policy you chose. This is the option that gives you full control over editions, trials, device limits and offline play, and it is the one the rest of this post focuses on.&lt;/p&gt;

&lt;p&gt;Selling more than one kind? That works well as long as each listing says clearly which one it delivers.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Write the promise next to the price
&lt;/h2&gt;

&lt;p&gt;Before the buyer pays, tell them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;supported operating systems and the edition they are buying&lt;/li&gt;
&lt;li&gt;where the download comes from, and whether an account or launcher is needed&lt;/li&gt;
&lt;li&gt;how many devices they can activate&lt;/li&gt;
&lt;li&gt;how the game behaves offline&lt;/li&gt;
&lt;li&gt;which updates are included&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep the same wording on the checkout page, in the game UI, on the support page and in your refund policy. If the build depends on platform features (cloud saves, achievements, workshop content, multiplayer identity), test the direct build on its own before launch so the listing matches what players get.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Use editions for demos, backers and the full game
&lt;/h2&gt;

&lt;p&gt;With your own license you can model editions as features on one product: for example &lt;code&gt;full_campaign&lt;/code&gt; or &lt;code&gt;level_editor&lt;/code&gt;. The game checks the feature before unlocking that content.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Demo:&lt;/strong&gt; playable without a key; the full game unlocks after a valid license check.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trial:&lt;/strong&gt; a time-limited license with a clear end date and an obvious upgrade button.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backers / early access:&lt;/strong&gt; say which builds and which updates are included instead of promising a vague "lifetime key".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More on this: &lt;a href="https://permitcore.dev/blog/feature-based-licensing" rel="noopener noreferrer"&gt;feature-based licensing&lt;/a&gt; and &lt;a href="https://permitcore.dev/blog/software-free-trial-license" rel="noopener noreferrer"&gt;free-trial licenses&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Design offline play deliberately
&lt;/h2&gt;

&lt;p&gt;Players expect a single-player game to run on a train. A good pattern:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Activate once online and bind the license to a stable device identity.&lt;/li&gt;
&lt;li&gt;Store a signed offline token and verify it locally against a public key that ships with your game.&lt;/li&gt;
&lt;li&gt;Check the product, the device and the token's expiry, not only the signature.&lt;/li&gt;
&lt;li&gt;Refresh the token in the background whenever the player is online.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then test the real situations on every platform you ship: clean install, restart, suspend and resume, lost connection, and an expired token. The &lt;a href="https://permitcore.dev/docs/offline-licensing" rel="noopener noreferrer"&gt;offline licensing docs&lt;/a&gt; walk through the setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Connect payment and delivery into one flow
&lt;/h2&gt;

&lt;p&gt;The smoothest direct sale is one where the payment itself triggers delivery:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The buyer pays through your payment provider (for example your own Stripe, Paddle or Lemon Squeezy account).&lt;/li&gt;
&lt;li&gt;A verified payment webhook, not the success page, confirms the purchase.&lt;/li&gt;
&lt;li&gt;The license is issued for the right product and features.&lt;/li&gt;
&lt;li&gt;The buyer receives an email with the key and the download link, and can find both again in a customer account.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Renewals, cancellations and refunds should run through the same flow, so the license always matches the payment state. If you are deciding between a merchant of record and your own Stripe account, this &lt;a href="https://permitcore.dev/blog/merchant-of-record-vs-stripe" rel="noopener noreferrer"&gt;comparison&lt;/a&gt; covers VAT and fees.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Example: a Unity game sold from your own store
&lt;/h2&gt;

&lt;p&gt;Here is how this looks with PermitCore, which connects licensing to a branded Store on your own payment account with 0% sales commission:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the product and choose the edition, validity and device policy.&lt;/li&gt;
&lt;li&gt;Add the &lt;a href="https://permitcore.dev/tutorials/sell-unity-game-asset-licenses" rel="noopener noreferrer"&gt;Unity SDK&lt;/a&gt; and validate the expected product before the protected content runs; activate the device where registration is needed.&lt;/li&gt;
&lt;li&gt;Create the Store listing, describe the build clearly and add the download URL of your release host.&lt;/li&gt;
&lt;li&gt;Connect your payment account, matching prices and signed webhooks.&lt;/li&gt;
&lt;li&gt;Run a sandbox purchase and check the whole chain: payment, correct product and features, delivery email and the download.&lt;/li&gt;
&lt;li&gt;In the game, test the valid, expired, revoked and wrong-product outcomes, plus your device and offline rules.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;a href="https://permitcore.dev/docs/store" rel="noopener noreferrer"&gt;Store docs&lt;/a&gt; and the &lt;a href="https://permitcore.dev/docs/customer-portal" rel="noopener noreferrer"&gt;customer portal docs&lt;/a&gt; cover setup and self-service.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Make support boring
&lt;/h2&gt;

&lt;p&gt;Tell buyers where to find their purchase, key and download, how to move to a new PC and whom to contact if an email does not arrive. Self-service device deactivation and re-download from a customer account remove most support email. Pair a fair device limit with that self-service and honest buyers stay happy while casual key sharing gets awkward; &lt;a href="https://permitcore.dev/blog/prevent-license-key-sharing" rel="noopener noreferrer"&gt;this guide&lt;/a&gt; goes deeper.&lt;/p&gt;

&lt;p&gt;Before launch, check this list:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The checkout says which build or platform key is sold.&lt;/li&gt;
&lt;li&gt;Download and update hosting work on their own.&lt;/li&gt;
&lt;li&gt;Payment, license issuance and the delivery email have each been tested.&lt;/li&gt;
&lt;li&gt;The game handles wrong product, device limit, expiry and no network without unlocking paid content.&lt;/li&gt;
&lt;li&gt;Device transfer, offline time, refunds and support match what the page promises.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you sell (or plan to sell) a game outside the big stores: which part took the most work for you, payments, delivery or keeping keys from being shared?&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>indiedev</category>
      <category>unity3d</category>
      <category>licensing</category>
    </item>
    <item>
      <title>Sell software through your own Paddle or Lemon Squeezy account—with licensing connected</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Sat, 07 Nov 2026 19:31:56 +0000</pubDate>
      <link>https://dev.to/permitcore/sell-software-through-your-own-paddle-or-lemon-squeezy-account-with-licensing-connected-1jbn</link>
      <guid>https://dev.to/permitcore/sell-software-through-your-own-paddle-or-lemon-squeezy-account-with-licensing-connected-1jbn</guid>
      <description>&lt;p&gt;You want to sell your app, not spend every release maintaining a second product made of checkout pages, tax settings, invoice links and license-delivery scripts.&lt;/p&gt;

&lt;p&gt;A merchant of record can take on the payment, tax and receipt side of eligible software sales under your agreement with it. But a successful checkout still needs to become something your customer can actually use: the right license, for the right product, in an account they can return to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PermitCore Store now connects those steps with Stripe, Paddle and Lemon Squeezy.&lt;/strong&gt; Choose one payment provider for your branded Store, connect your own account, and link verified payments to automatic software license delivery.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose your payment relationship. Keep your own brand.
&lt;/h2&gt;

&lt;p&gt;Your payment account should fit how you sell.&lt;/p&gt;

&lt;p&gt;If you want to use Paddle or Lemon Squeezy as merchant of record, you can connect your own provider account to PermitCore Store. The selected provider handles checkout, tax and its receipts under your merchant-of-record agreement. PermitCore handles the licensing and fulfillment side.&lt;/p&gt;

&lt;p&gt;Stripe remains supported for your Store. If you sell directly through your own Stripe account, you remain responsible for your applicable tax obligations; the Store setup guide explains the available tax configuration.&lt;/p&gt;

&lt;p&gt;The important distinction is ownership of the relationship: this is &lt;strong&gt;your provider account for your customers' purchases&lt;/strong&gt;, not the account used to pay for your own PermitCore subscription.&lt;/p&gt;

&lt;p&gt;PermitCore takes &lt;strong&gt;0% sales commission&lt;/strong&gt;. Your selected provider's fees, payout terms and account requirements still apply.&lt;/p&gt;

&lt;h2&gt;
  
  
  A storefront that looks like your software belongs there
&lt;/h2&gt;

&lt;p&gt;The Store is more than a payment link.&lt;/p&gt;

&lt;p&gt;Use your logo, colors and product imagery. Organize products into collections, add a featured spotlight, and build product pages with descriptions, feature lists and price choices. Offer one-time purchases or recurring products according to your sales model.&lt;/p&gt;

&lt;p&gt;The same product and license settings connect the storefront to what your app enforces: features, device limits and access rules.&lt;/p&gt;

&lt;p&gt;That gives the sale a continuous path:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create&lt;/strong&gt; the product and the license settings your customer should receive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implement&lt;/strong&gt; licensing in your app through the REST API or an official SDK.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sell&lt;/strong&gt; through your branded Store and selected payment account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deliver&lt;/strong&gt; access after payment is verified, with purchase history available in the customer's account.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Connect payment to access—not just a success page
&lt;/h2&gt;

&lt;p&gt;A browser landing on a thank-you page is useful feedback. It is not the authority for issuing a paid license.&lt;/p&gt;

&lt;p&gt;PermitCore verifies provider payment notifications and payment evidence before fulfillment. A completed purchase creates the appropriate order and license; the customer receives an email linking to their account rather than a license key exposed in the message.&lt;/p&gt;

&lt;p&gt;For recurring products, paid renewals extend the existing key. Failed payments follow the Store's configured payment-grace policy. Cancellation and refunds follow their respective access rules, while customers retain their purchase history and provider documents.&lt;/p&gt;

&lt;p&gt;That connection matters after the first sale as much as during checkout. You should not need a separate manual process to reconcile a renewed subscription with a customer's software access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Paddle and Lemon Squeezy: same goal, different setup
&lt;/h2&gt;

&lt;p&gt;With &lt;strong&gt;Paddle&lt;/strong&gt;, the Store can create or update the connected provider catalog from your Store products and prices. Review the resulting mappings and provider tax categories as part of setup.&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;Lemon Squeezy&lt;/strong&gt;, create products and variants in its dashboard, then connect the matching variants in PermitCore. A multi-product cart uses an aggregate provider line while PermitCore preserves the individual purchase shares. Different recurring intervals use separate checkouts.&lt;/p&gt;

&lt;p&gt;Both routes connect your provider account to the same branded storefront and licensing workflow. The &lt;a href="https://permitcore.dev/docs/store" rel="noopener noreferrer"&gt;Store setup guide&lt;/a&gt; walks through account configuration, product mappings, payment notifications and going live.&lt;/p&gt;

&lt;h2&gt;
  
  
  Less glue between selling and shipping
&lt;/h2&gt;

&lt;p&gt;For an indie developer, reducing tax and invoicing administration is only part of the benefit. The other part is keeping the sale connected to the software you ship.&lt;/p&gt;

&lt;p&gt;Your Store presents the product. Your selected provider handles the payment relationship. PermitCore delivers and manages the license.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://permitcore.dev/solutions/sell-license-keys" rel="noopener noreferrer"&gt;Explore PermitCore Store&lt;/a&gt;, or follow the setup guide to connect your account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which part of selling software takes more of your time today: tax and invoices, storefront setup, or keeping paid access synchronized?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>indiehackers</category>
      <category>saas</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>License Checks at App Startup: Open the Window First, Verify in the Background</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Sat, 07 Nov 2026 09:41:08 +0000</pubDate>
      <link>https://dev.to/permitcore/license-checks-at-app-startup-open-the-window-first-verify-in-the-background-39kl</link>
      <guid>https://dev.to/permitcore/license-checks-at-app-startup-open-the-window-first-verify-in-the-background-39kl</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/license-check-at-app-startup" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A license check at startup has two jobs: get the app on screen quickly, and decide which features the customer can use. Those jobs do not have to happen in the same moment. Render the first window from local proof, then confirm the entitlement with the server in the background and update the UI when the answer arrives.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Open the window and verify local proof
&lt;/h2&gt;

&lt;p&gt;Show the main shell right away and keep license settings and the user's own files reachable. If your licensing policy allows offline use, verify the cached signed token against your trusted public key, and check that it belongs to the expected device and product. Check its expiry every time it is used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No token, or a token that fails verification: keep paid features restricted until the server confirms access.&lt;/li&gt;
&lt;li&gt;A revocation the app has already seen: persist it, so restarting with an old token on disk cannot bring access back.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In PermitCore, the offline flow accepts a server-issued signed token through &lt;code&gt;ActivateOffline&lt;/code&gt; / &lt;code&gt;activate_offline&lt;/code&gt; and checks it locally with &lt;code&gt;ValidateOffline&lt;/code&gt; / &lt;code&gt;validate_offline&lt;/code&gt;. Use the same trusted public key, device and product context at both steps. The &lt;a href="https://permitcore.dev/docs/offline-licensing" rel="noopener noreferrer"&gt;offline licensing setup&lt;/a&gt; walks through the configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Run the online check after the window renders
&lt;/h2&gt;

&lt;p&gt;Run one validation per license at a time, with a short timeout. Retry transient failures with a small random delay, and respect the server's retry window when you are rate limited. Validation goes through the &lt;a href="https://permitcore.dev/docs/api/validate" rel="noopener noreferrer"&gt;validate endpoint&lt;/a&gt;; device activation is its own step.&lt;/p&gt;

&lt;p&gt;C#:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;LicenseResult&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;CheckAfterLaunchAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;PermitCoreClient&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Guid&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;CancellationToken&lt;/span&gt; &lt;span class="n"&gt;windowClosing&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CancellationTokenSource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateLinkedTokenSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;windowClosing&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CancelAfter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TimeSpan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ValidateAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expectedProductId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;ct&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_after_launch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expected_product_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Construct the Python client with &lt;code&gt;timeout=2&lt;/code&gt;. If your desktop toolkit has its own worker mechanism instead of asyncio, run the call there and hand the result back to the UI thread. Either way, ignore results that arrive for a window that has closed or a key that has been replaced.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Treat valid, denied and unknown as three different outcomes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Verified online:&lt;/strong&gt; apply the entitlement for that product. When the cached signed token gets close to expiry, fetch a freshly issued one from your trusted issuer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explicit denial&lt;/strong&gt; (revoked, expired, wrong product): persist the decision for that key, device and product, invalidate the offline authorization, and keep the recovery screen available.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unknown&lt;/strong&gt; (timeout, network failure, HTTP 503): the entitlement is unresolved. Keep exactly the access backed by current, verified local proof and its existing expiry. Authentication or response-format errors are something to diagnose; they should never create or extend offline access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href="https://permitcore.dev/docs/api/errors" rel="noopener noreferrer"&gt;API error reference&lt;/a&gt; lists which responses are authoritative denials. Show a quiet status line during outages and a specific recovery action for denials. If paid access expires while offline, keep the user's documents safe and let them reconnect or enter another key.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Test the transitions and measure first paint
&lt;/h2&gt;

&lt;p&gt;In an integration fixture:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Delay the validation response past the timeout.&lt;/li&gt;
&lt;li&gt;Return HTTP 503.&lt;/li&gt;
&lt;li&gt;Return an authoritative revocation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first two must keep an unexpired offline grant working and keep an expired or missing grant restricted. The revocation must stop paid access and still apply after a restart with the old token on disk. Repeat with a wrong product, a changed device, a corrupted token and a rolled-back clock; treat unexpected clock changes as a reason to verify online.&lt;/p&gt;

&lt;p&gt;Measure two numbers separately: time to the first interactive window, and time to the online entitlement. Compare p95 cold starts under normal latency, offline, and with a slow backend. Network time should never show up in the first number.&lt;/p&gt;

&lt;p&gt;For longer interruptions, see &lt;a href="https://permitcore.dev/blog/what-happens-if-a-license-server-goes-down" rel="noopener noreferrer"&gt;what happens if a license server goes down&lt;/a&gt;, and for wording recovery screens, the &lt;a href="https://permitcore.dev/blog/license-error-messages" rel="noopener noreferrer"&gt;license error messages guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;How does your app handle startup today: does it wait for the license server, or open first and check in the background?&lt;/p&gt;

</description>
      <category>licensing</category>
      <category>desktop</category>
      <category>csharp</category>
      <category>python</category>
    </item>
    <item>
      <title>Moving to a New Licensing Provider Without Replacing Customer Keys</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Thu, 05 Nov 2026 09:32:28 +0000</pubDate>
      <link>https://dev.to/permitcore/moving-to-a-new-licensing-provider-without-replacing-customer-keys-3fba</link>
      <guid>https://dev.to/permitcore/moving-to-a-new-licensing-provider-without-replacing-customer-keys-3fba</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/switch-software-licensing-provider" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Moving to a new licensing provider does not have to mean sending every customer a new key. The key string can stay the same. What changes is the plan around it: how the application talks to the new system, how entitlement data is mapped, and how verification is trusted from the first release that points at the new endpoint.&lt;/p&gt;

&lt;p&gt;Start with a sample you own and a rollback plan. Treat key lookup, device registrations, offline proofs, payments and customer identity as separate pieces, and move each one on purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the key when the lookup can be reproduced
&lt;/h2&gt;

&lt;p&gt;The PermitCore CSV import wizard works from your existing key strings. It hashes each key in the browser, and the server then applies its own HMAC lookup protection, so the plaintext never needs to be stored for lookup to work. If you prefer to script it, the API importer accepts the documented SHA-256 input.&lt;/p&gt;

&lt;p&gt;Keep the exact original value and its encoding. Case, whitespace and separators matter, because the server hashes the plaintext bytes you supply instead of inventing a new key format. Before you roll out a client update, check a few real old keys against a migrated record that you own.&lt;/p&gt;

&lt;p&gt;If your source system stored keys in a form you cannot read back, such as a vendor-specific salted hash or an encrypted blob, work out which verifiable lookup material you actually hold. Server-side migration is the right place for that step. Keep any privileged import credential on the server and out of customer software.&lt;/p&gt;

&lt;h2&gt;
  
  
  Map products and policy before importing
&lt;/h2&gt;

&lt;p&gt;Use &lt;strong&gt;Licenses → Import&lt;/strong&gt;, choose the source preset that matches your export, and map the columns explicitly. Match each row to the correct PermitCore product, then check expiry, trial state, features, device cap, node-locking and customer association one by one rather than assuming every source field means the same thing.&lt;/p&gt;

&lt;p&gt;The API takes up to 500 rows per batch and reports a per-row outcome: Created, Duplicate or ValidationFailed. Rows commit independently, so a large import can be done in stages, and you can keep the results to reconcile any duplicate or failed rows before you retry them.&lt;/p&gt;

&lt;p&gt;Version limits use dotted-numeric versions, and dates deserve a deliberate conversion, including what timezone they mean. The &lt;a href="https://permitcore.dev/docs/migrating-from-other-systems" rel="noopener noreferrer"&gt;import reference&lt;/a&gt; lists the current column mapping and API fields. Anything outside that mapping can be applied afterwards through the normal administration workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plan device activations on purpose
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;InitialActivations&lt;/code&gt; seeds the used count for a key, anywhere from zero up to its activation limit. Pick that number together with your re-enrollment policy: an installation that registers against the new system enrolls as a fresh device, so test three cases before the real cutover: a partly occupied key, an existing installation, and a genuinely new device.&lt;/p&gt;

&lt;p&gt;Floating licenses start fresh in the new system, with a new checkout and a returned deadline for each seat. The &lt;a href="https://permitcore.dev/blog/team-license-for-software" rel="noopener noreferrer"&gt;capacity guide&lt;/a&gt; and the &lt;a href="https://permitcore.dev/docs/floating-licenses" rel="noopener noreferrer"&gt;floating lifecycle docs&lt;/a&gt; walk through that flow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose how keys are recovered later
&lt;/h2&gt;

&lt;p&gt;The import wizard offers optional passphrase encryption. If you turn it on, you keep ciphertext that an authorised person can reveal later with that passphrase. Lookup and validation work either way. Keep your authorised source export somewhere safe if you want a recovery path for the original keys.&lt;/p&gt;

&lt;p&gt;Licenses issued by the PermitCore Store have their own server-managed delivery and recovery path. The &lt;a href="https://permitcore.dev/exit-plan" rel="noopener noreferrer"&gt;exit and recovery plan&lt;/a&gt; shows which artifacts matter for which situation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ship the client update deliberately
&lt;/h2&gt;

&lt;p&gt;Importing data prepares the new system; your next application release is what points users at it. Ship a version that calls the new endpoint and checks the new product scope. If your app already keeps the customer's key in its settings, reuse that stored value so people are not asked to retype it. Implement and test that storage step, since it lives in your app.&lt;/p&gt;

&lt;p&gt;For offline use, plan new signed proofs from the new system. The official SDKs verify them against trusted public keys that you configure yourself, so include that configuration in the same release, and keep private signing and Admin keys out of the client. &lt;a href="https://permitcore.dev/blog/license-signing-key-rotation" rel="noopener noreferrer"&gt;Signing and trust rollout&lt;/a&gt; covers how to stage a change of trusted keys.&lt;/p&gt;

&lt;p&gt;Run an owned pilot where you can watch old and new decisions side by side. Write down the cutover and rollback conditions, avoid running both systems for the same customer by accident, and check what an older client does once the original endpoint is retired.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep payments on their own track
&lt;/h2&gt;

&lt;p&gt;License import is about entitlements. Card tokens, mandates, provider subscriptions and store order history are a payment-provider topic, so handle them as a separate, approved process with that provider and coordinate access dates so nobody is charged twice. If you use the PermitCore Store, changing the vendor's selected provider applies to new checkouts, and existing purchases keep the provider they were bought with. The &lt;a href="https://permitcore.dev/blog/paddle-license-keys" rel="noopener noreferrer"&gt;payment lifecycle guide&lt;/a&gt; explains how fulfillment follows each purchase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-cutover checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Reconcile row counts, duplicates, failures and product mapping between the source and the import.&lt;/li&gt;
&lt;li&gt;Test existing key strings, wrong-product rejection, expiry and your device re-enrollment policy.&lt;/li&gt;
&lt;li&gt;Test the app update, the retained key setting, the new trust configuration and offline recovery.&lt;/li&gt;
&lt;li&gt;Keep billing changes, customer communication and rollback under separate control.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Have you moved a licensing system before? Which step took the most care: the key lookup, the client rollout, or payments?&lt;/p&gt;

</description>
      <category>licensing</category>
      <category>saas</category>
      <category>migration</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Charging for an MCP Server: Check the License Before the Paid Tool Runs</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Tue, 03 Nov 2026 09:36:08 +0000</pubDate>
      <link>https://dev.to/permitcore/charging-for-an-mcp-server-check-the-license-before-the-paid-tool-runs-59c4</link>
      <guid>https://dev.to/permitcore/charging-for-an-mcp-server-check-the-license-before-the-paid-tool-runs-59c4</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/monetize-mcp-server" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you ship an MCP server people actually use, sooner or later someone asks "is there a paid version?". The pattern is simple: decide which operations are paid, tie the customer to an entitlement, and check that entitlement &lt;strong&gt;before&lt;/strong&gt; the protected work runs. A local license key suits a distributed tool; a hosted service also needs its own user authentication.&lt;/p&gt;

&lt;p&gt;This guide covers local Node.js and Python servers, plus the boundaries of a hosted design. PermitCore supplies the license check and the entitlement data; you bring your MCP server library and transport. The code below is a licensing-policy helper that you call from your own tool handler, not a complete MCP server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose where the paid value runs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local server with online checks.&lt;/strong&gt; Ship the program and check a customer key when a paid operation begins. Keep the free tools usable even if the license service is unreachable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local server with signed offline proof.&lt;/strong&gt; Verify a previously issued proof against trusted keys and its actual constraints. Revocation visibility while offline is bounded by reconnect time and token expiry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosted server.&lt;/strong&gt; Authenticate the caller, map their account to its entitlement and authorise each protected operation. You also keep control of remote computation, storage and API costs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A customer controls a local installation and can modify its code, so a local gate supports your commercial policy rather than guaranteeing anything. Put especially valuable shared data or costly computation behind an authenticated service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the key out of the conversation
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;MCP_LICENSE_KEY&lt;/code&gt; here is just a convention of this guide, not an MCP-standard field. Supply it to your own local process through private configuration or a trusted launcher. Don't ask the model to paste it into a prompt or pass it as a tool argument: those paths can end up in conversation history and traces. Your PermitCore administrative API key never belongs in the customer program.&lt;/p&gt;

&lt;p&gt;Cursor supports environment interpolation in &lt;code&gt;mcp.json&lt;/code&gt;, so the secret can stay in your environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"my-local-server"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"stdio"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/absolute/path/to/your/server.mjs"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"MCP_LICENSE_KEY"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"${env:MCP_LICENSE_KEY}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"MCP_PRODUCT_ID"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"YOUR_PRODUCT_GUID"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the product GUID and point &lt;code&gt;args&lt;/code&gt; at your real server entry point. Keep real keys out of a committed project config. For Claude Desktop, use Settings → Developer → Edit Config and the official local-server guide; don't assume Cursor's interpolation syntax works in another client.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the paid operation before any side effect
&lt;/h2&gt;

&lt;p&gt;Keep installation, discovery and genuinely free tools available without a key. A tool description saying "Pro" is only a UI hint: enforce the entitlement inside the execution handler, before exporting files, calling a billable service or changing data. Hiding a tool in the client is not access control.&lt;/p&gt;

&lt;p&gt;For the examples, create a product in PermitCore, use its GUID as &lt;code&gt;MCP_PRODUCT_ID&lt;/code&gt;, and add a &lt;code&gt;pro_export&lt;/code&gt; feature to the licenses that should unlock your export tool. A valid key for a &lt;em&gt;different&lt;/em&gt; product must not grant access, so the helpers compare the product id as well as the feature.&lt;/p&gt;

&lt;h3&gt;
  
  
  Node.js
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;PermitCoreClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@permitcore/permitcore&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;checkProLicense&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MCP_LICENSE_KEY&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;productId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MCP_PRODUCT_ID&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Configure MCP_LICENSE_KEY and MCP_PRODUCT_ID privately.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MCP_API_URL&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.permitcore.dev&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;enableOfflineCache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;timeoutMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;maxRetries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isValid&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;productId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Pro access could not be confirmed. Check the key, product and service.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;PermitCoreClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hasFeature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pro_export&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;This license does not include Pro export.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Pro access could not be confirmed. Check the configuration and service.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;permitcore&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PermitCoreClient&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_pro_license&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;MCP_LICENSE_KEY&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;product_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;MCP_PRODUCT_ID&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;allowed&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Configure MCP_LICENSE_KEY and MCP_PRODUCT_ID privately.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PermitCoreClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;MCP_API_URL&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://api.permitcore.dev&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;enable_offline_cache&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_retries&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1.0.0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expected_product_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_valid&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;allowed&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Pro access could not be confirmed. Check the key, product and service.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has_feature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pro_export&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;allowed&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;This license does not include Pro export.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;allowed&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;allowed&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Pro access could not be confirmed. Check the configuration and service.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Call the helper from the protected handler and stop before doing the work when &lt;code&gt;allowed&lt;/code&gt; is false. Free handlers never call it. These online-only helpers disable offline caching and retries and use a five-second timeout per attempt. The Python SDK call is synchronous, so an async server should run it on a worker thread. &lt;code&gt;MCP_API_URL&lt;/code&gt; is trusted process configuration (self-hosting or a local test fixture); never derive it from a tool argument or model output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Return a useful refusal
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://modelcontextprotocol.io/specification/2026-07-28/server/tools" rel="noopener noreferrer"&gt;MCP tools specification&lt;/a&gt; separates tool execution failures from malformed protocol requests. For a denied business operation, return a tool error (&lt;code&gt;isError: true&lt;/code&gt;) with a short, safe explanation, using the result type your MCP library expects.&lt;/p&gt;

&lt;p&gt;Say what to do next: configure the key outside the conversation, check that it belongs to this product, or get a license that includes the feature. A temporary verification failure shouldn't tell a paying customer their key is definitely invalid, and the message must never contain the key or account details.&lt;/p&gt;

&lt;p&gt;One stdio detail: stdout carries protocol messages, so a licensing banner printed there can break the connection. Keep diagnostics on stderr and redact secrets there too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design offline use as its own policy
&lt;/h2&gt;

&lt;p&gt;A local server may need to work on a train or an isolated workstation. Use the signed offline path from the &lt;a href="https://permitcore.dev/docs/offline-licensing" rel="noopener noreferrer"&gt;offline licensing docs&lt;/a&gt;: a successful online check can provide a signed grace-cache token when configured. Verifying a saved unsigned JSON response, or caching a &lt;code&gt;true&lt;/code&gt; forever, is not safe. Test expiry, tampering and key rotation separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seats and usage
&lt;/h2&gt;

&lt;p&gt;One key copied into several client configs doesn't define a team-seat policy. Pick &lt;a href="https://permitcore.dev/blog/node-locked-vs-floating-licenses" rel="noopener noreferrer"&gt;node-locked or floating controls&lt;/a&gt; for what you sell, and don't activate on every tool call: activation is separate from validation. If you charge by usage, define the billable unit (messages, tokens, successful exports are all different) and use &lt;a href="https://permitcore.dev/blog/metered-software-licensing-explained" rel="noopener noreferrer"&gt;metering&lt;/a&gt; explicitly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hosted access needs authentication too
&lt;/h2&gt;

&lt;p&gt;For an HTTP-based server, follow the &lt;a href="https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization" rel="noopener noreferrer"&gt;MCP authorization specification&lt;/a&gt;. Authentication says who is calling; your commercial policy says what their account may use, so map the authenticated account to its entitlement instead of sharing one global key. Don't treat a model-supplied email or license string as proof of identity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sell it and test the whole path
&lt;/h2&gt;

&lt;p&gt;A PermitCore Store can use your own Stripe or Paddle account and deliver a key after verified payment, with 0% PermitCore sales commission (provider fees apply). Configure the product, features and seat policy, then test a purchase together with the protected tool.&lt;/p&gt;

&lt;p&gt;Before release, run through the real client and transport: free tools with no key; Pro with the right feature; a key for another product; an expired or revoked key; a service failure; and confirm no side effect happens after a denial and that license material never reaches protocol output, logs or the model.&lt;/p&gt;

&lt;p&gt;Full original with all the links: &lt;a href="https://permitcore.dev/blog/monetize-mcp-server" rel="noopener noreferrer"&gt;permitcore.dev/blog/monetize-mcp-server&lt;/a&gt;. Docs: &lt;a href="https://permitcore.dev/docs/getting-started" rel="noopener noreferrer"&gt;permitcore.dev/docs/getting-started&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;If you're building MCP servers, how are you planning to charge for them: a license key in the client config, a hosted account, or something else? I'd love to hear what's working. 🙂&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>node</category>
      <category>licensing</category>
    </item>
    <item>
      <title>Perpetual License vs Subscription License: Which Should You Sell?</title>
      <dc:creator>PermitCore</dc:creator>
      <pubDate>Sun, 01 Nov 2026 09:27:06 +0000</pubDate>
      <link>https://dev.to/permitcore/perpetual-license-vs-subscription-license-which-should-you-sell-16gl</link>
      <guid>https://dev.to/permitcore/perpetual-license-vs-subscription-license-which-should-you-sell-16gl</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://permitcore.dev/blog/perpetual-vs-subscription-license" rel="noopener noreferrer"&gt;PermitCore blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Perpetual and subscription aren't really about the license technology at all. A license key doesn't care whether it's "supposed to" last forever. The real difference is a business model decision: does the customer own access forever after one payment, or do they keep paying to keep access? Most licensing platforms, including ours, can issue either from the exact same product.&lt;/p&gt;

&lt;h2&gt;
  
  
  How purchase type determines access
&lt;/h2&gt;

&lt;p&gt;For a one-time purchase in PermitCore Store, &lt;code&gt;LicenseExpiryDays&lt;/code&gt; sets the number of days of access; leaving it blank creates a perpetual key. Monthly and annual purchases follow Stripe's paid billing period instead: each paid invoice extends the same key. Failed renewals use the configured payment grace window, 14 days by default, and access expires when it ends.&lt;/p&gt;

&lt;p&gt;A product can offer one-time, monthly, and annual options side by side; the selected purchase type determines which expiry rule applies. Activations, node locking, and feature flags remain independent controls.&lt;/p&gt;

&lt;h2&gt;
  
  
  Perpetual: what you're actually trading
&lt;/h2&gt;

&lt;p&gt;A perpetual license (one payment, access forever) is simple to explain to a customer and creates no ongoing billing relationship to maintain: no dunning emails, no cancellation flow, no "why was I charged again" support tickets.&lt;/p&gt;

&lt;p&gt;The tradeoff is revenue shape. Each sale is a one-time event, so growth depends entirely on new customers or paid upgrades, not a compounding base of renewals.&lt;/p&gt;

&lt;p&gt;It also creates a real, ongoing support obligation most vendors underestimate. A customer who paid once five years ago may still expect their software to run, even as the OS and platform change underneath them. Perpetual access does not itself promise endless feature upgrades or commercial support. Applicable security-support duties need separate assessment; they are not erased by an expired upgrade contract. Our &lt;a href="https://permitcore.dev/blog/cyber-resilience-act-software-developers" rel="noopener noreferrer"&gt;CRA support and licensing guide&lt;/a&gt; goes deeper. In short: state the purchased execution rights, the upgrade policy and the security-support period separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Subscription: what you're actually trading
&lt;/h2&gt;

&lt;p&gt;A subscription (recurring charge, access requires staying current) creates a predictable, compounding revenue base and a natural way to fund ongoing development. The customer relationship doesn't end at the sale.&lt;/p&gt;

&lt;p&gt;The tradeoff is operational surface:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Failed payments need handling (grace window, then expiry).&lt;/li&gt;
&lt;li&gt;Cancellations need a clean flow.&lt;/li&gt;
&lt;li&gt;Every renewal is a moment a customer can decide to leave, so churn becomes a metric you actively manage.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Selling both isn't unusual
&lt;/h2&gt;

&lt;p&gt;A common pattern: subscription as the default (lower upfront price, steady revenue) with a perpetual option at a higher price point for customers who specifically want to avoid recurring billing. Enterprise procurement teams in particular often prefer a one-time purchase over an operating subscription for budgeting reasons that have nothing to do with your product.&lt;/p&gt;

&lt;p&gt;Since both are just a price plus an expiry setting on the same product, offering both isn't extra engineering work, just a second price point.&lt;/p&gt;

&lt;h2&gt;
  
  
  What doesn't change either way
&lt;/h2&gt;

&lt;p&gt;Node-locking, floating seats, feature gating, and offline support are all independent of whether the license is perpetual or subscription. The perpetual-vs-subscription decision is purely about the business model; how the license actually behaves on a customer's machine is a separate, orthogonal choice.&lt;/p&gt;




&lt;p&gt;Which model are you selling right now, and what made you pick it? I'd love to hear how other indie devs decided. 🙂&lt;/p&gt;

</description>
      <category>saas</category>
      <category>licensing</category>
      <category>indiehackers</category>
      <category>gamedev</category>
    </item>
  </channel>
</rss>
