echokit

What is the EchoKit Worker and Why Do You Need It?

๐ŸŽ‰ Your Worker is LIVE!

Worker URL: https://echokit-license.echokit-rk.workers.dev
Status: โœ… Deployed and healthy
Health Check: Working perfectly!
Secrets: โœ… HMAC_SECRET and ADMIN_TOKEN configured


๐Ÿค” What is it in Simple Terms?

The EchoKit Worker is a tiny app running in the cloud that checks if EchoKit Pro license keys are real and valid.

Think of it like a bouncer at a club - when someone shows a VIP pass (license key), the bouncer checks:

Where it runs: Cloudflareโ€™s global network (200+ cities worldwide)
Cost: $0/month (free tier covers everything)
Speed: <10ms anywhere in the world


๐ŸŽฏ Why You NEED It

Scenario: Youโ€™re Selling EchoKit Pro

WITHOUT a Worker โŒ:

  1. Customer buys Pro โ†’ You manually email them a โ€œlicense keyโ€ (just random text)
  2. Customer enters key โ†’ Extension just checks โ€œis it not empty?โ€
  3. Problem: Customer shares key with 10 friends โ†’ All get Pro features
  4. Result: You sell 1 license, 10 people use it = 90% revenue loss ๐Ÿ’ธ

WITH a Worker โœ…:

  1. Customer buys Pro โ†’ Worker automatically generates a cryptographically signed key
  2. Key looks like: EK-PRO-1738281600-a1b2c3d4e5f6 (has math proof built-in)
  3. Customer enters key โ†’ Extension asks Worker: โ€œIs this real?โ€
  4. Worker checks signature (like verifying a signed document)
  5. If friend tries to share: Each use is validated, you can detect patterns
  6. Result: Secure revenue, prevent piracy โœ…

๐Ÿ” How the Magic Works

License Key Anatomy

EK-PRO-1738281600-a1b2c3d4e5f6
โ”‚   โ”‚   โ”‚          โ”‚
โ”‚   โ”‚   โ”‚          โ””โ”€โ”€ Signature (mathematical proof it's real)
โ”‚   โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Expiry date (Unix timestamp)
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Plan type (PRO/YEAR/LTD)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ EchoKit prefix

The signature is created using HMAC-SHA256 cryptography with your secret key. Without knowing your secret, itโ€™s mathematically impossible to create a valid signature. Even a supercomputer couldnโ€™t crack it in billions of years.

Validation Flow (What Happens Behind the Scenes)

1. User pastes key in EchoKit extension
2. Extension sends to Worker: "Is EK-PRO-1738281600-a1b2c3d4e5f6 valid?"
3. Worker checks:
   โœ“ Format correct? (EK-PLAN-TIMESTAMP-SIG)
   โœ“ Signature matches? (uses your secret to verify)
   โœ“ Not expired? (compares timestamp to now)
4. Worker responds: "โœ… YES! Plan: PRO, Expires: Dec 31, 2026"
5. Extension unlocks Pro features

Security: Only YOU know the ECHOKIT_HMAC_SECRET. Nobody else can create valid keys.


๐ŸŒ What the Worker Can Do

1. Health Check (Is it alive?)

curl https://echokit-license.echokit-rk.workers.dev/__health
# Response: {"ok":true,"name":"EchoKit License API"}

2. Validate Keys (Extension uses this)

POST /v1/validate
Body: {"key": "EK-PRO-1738281600-..."}

# If valid:
{"valid": true, "plan": "PRO", "expiresAt": 1738281600}

# If fake:
{"valid": false, "error": "invalid signature"}

3. Issue New Keys (You use this to create keys)

POST /v1/issue
Headers: Authorization: Bearer <YOUR_ADMIN_TOKEN>
Body: {"plan": "PRO", "expiresAt": 0}

# Response:
{"ok": true, "key": "EK-PRO-1738281600-a1b2c3d4", "plan": "PRO"}

4. Payment Automation (Customer pays โ†’ Auto-issue key)

POST /v1/stripe-webhook        # Stripe (already coded!)
POST /v1/lemonsqueezy-webhook  # LemonSqueezy (recommended to add)

# When customer pays:
# โ†’ Webhook fires
# โ†’ Worker generates key
# โ†’ Email sent automatically

๐Ÿ’ฐ Cost Breakdown

Cloudflare Workers Free Tier:

Your actual usage with 1,000 Pro users:

If you somehow exceed 100K/day: $5/month for 10 million requests.

Verdict: Youโ€™ll never pay for this. Free forever.


๐ŸŽฎ Real-World Customer Journey

Letโ€™s say Sarah wants to buy EchoKit Lifetime:

  1. Sarah clicks โ€œBuy Lifetimeโ€ ($199) on your pricing page
  2. Payment processor (Stripe/LemonSqueezy) charges her card
  3. Webhook fires โ†’ Worker receives โ€œpayment successfulโ€ notification
  4. Worker generates key: EK-LTD-0-f3a8b2c1 (LTD = lifetime, 0 = never expires)
  5. Email sent automatically: โ€œThanks Sarah! Your license: EK-LTD-0-f3a8b2c1โ€
  6. Sarah opens EchoKit โ†’ Settings โ†’ Pastes key
  7. Extension asks Worker: โ€œIs EK-LTD-0-f3a8b2c1 valid?โ€
  8. Worker validates: โœ“ Signature matches โœ“ Plan is LTD โœ“ No expiry
  9. Worker responds: โ€œโœ… Valid! Lifetime plan.โ€
  10. Pro features unlock instantly โœจ

All of this happens in <1 second with zero manual work from you.


๐Ÿ”ง Test It Right Now

cd worker

# Set your credentials (you got these during deployment)
export ECHOKIT_WORKER_URL="https://echokit-license.echokit-rk.workers.dev"
export ECHOKIT_ADMIN_TOKEN="<paste-your-admin-token>"

# Run the interactive key issuer
./issue-license.sh

It will ask:

Select plan type:
  1) PRO   - Monthly (30 days)
  2) YEAR  - Annual (365 days)
  3) LTD   - Lifetime (never expires)

Enter choice [1-3]: 3

Choose 3 โ†’ Youโ€™ll get a real lifetime license key!
Then test it in the extension.


๐Ÿš€ Next Steps for Production

Set Up Automated Payments

Option A: LemonSqueezy ๐ŸŒ (RECOMMENDED)

Option B: Stripe (Already coded!)

Option C: Both!


โ“ Common Questions

Q: What if I donโ€™t use the worker?
A: EchoKit works fine, but only Free tier. No way to safely sell Pro without it.

Q: Can someone hack/crack the keys?
A: No. HMAC-SHA256 is military-grade crypto. Without your secret, impossible to forge.

Q: What if Cloudflare goes down?
A: Extension caches validations for 24 hours. Plus Cloudflare has 99.99% uptime (better than AWS).

Q: What if I lose ECHOKIT_HMAC_SECRET?
A: All existing keys become invalid. Youโ€™d need to issue new keys to all customers. SAVE IT IN YOUR PASSWORD MANAGER!

Q: Can I see whoโ€™s using what keys?
A: Current version doesnโ€™t log. Future version could add analytics (KV store).

Q: Can I revoke a key if someone cheats?
A: Not in current version (stateless design). V2 could add a revocation list.


๐Ÿ“Š Bottom Line

What it is: Your license server in the cloud
Why you need it: Prevent piracy, secure revenue, automate sales
Cost: $0/month
Speed: <10ms globally
Security: Impossible to crack
Your URL: https://echokit-license.echokit-rk.workers.dev

Without it: You canโ€™t safely sell Pro licenses (anyone can fake keys)
With it: Enterprise-grade license management for free


๐ŸŽฏ Your worker is deployed and ready!
Test it now: cd worker && ./issue-license.sh ๐Ÿš€