Skip to content

feat: replace is_pro boolean with entitlements array in JWT claims#2179

Merged
yujonglee merged 4 commits intomainfrom
devin/1765249917-entitlements-based-is-pro
Dec 9, 2025
Merged

feat: replace is_pro boolean with entitlements array in JWT claims#2179
yujonglee merged 4 commits intomainfrom
devin/1765249917-entitlements-based-is-pro

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 9, 2025

Summary

Replaces the is_pro boolean JWT claim with a more flexible entitlements array containing all of the user's active Stripe Entitlements. This is more future-proof: adding new Stripe Features requires no code changes.

Before: { "is_pro": true } based on any active/trialing subscription
After: { "entitlements": ["hyprnote_pro", "other_feature", ...] } based on Stripe active_entitlements

The frontend (billing.tsx) now:

  • Exposes entitlements: string[] for future feature gating
  • Derives isPro from entitlements.includes("hyprnote_pro")

Review & Testing Checklist for Human

  • CRITICAL: Create Feature in Stripe Dashboard with lookup_key = 'hyprnote_pro' and attach it to your Pro product BEFORE deploying. Without this, all Pro users will lose access.
  • Verify stripe.active_entitlements table is being populated by stripe-sync-engine webhooks in your environment
  • Confirm no other services/code consume the JWT expecting is_pro boolean (this is a breaking change to JWT structure)
  • Test with a real Pro subscriber to confirm they get entitlements: ["hyprnote_pro"] in their JWT after migration
  • Run the SQL tests locally with supabase test db to verify the test cases pass

Recommended test plan:

  1. In Stripe Dashboard (test mode), go to Product catalog → Features → Create feature with lookup_key hyprnote_pro
  2. Attach the feature to your Pro product
  3. Run supabase migration up --local to apply the migration
  4. Run supabase test db to verify tests pass
  5. Create a test subscription and verify the entitlement syncs to stripe.active_entitlements
  6. Verify the JWT contains entitlements: ["hyprnote_pro"] for the subscribed user
  7. Verify the desktop app correctly shows Pro status

Notes

  • The lookup_key = 'hyprnote_pro' is hardcoded in billing.tsx. If you want a different key, update both the Stripe Feature and the frontend code.
  • This depends on Stripe's Entitlements feature being available on your Stripe plan.
  • The entitlements array is sorted alphabetically and will contain all active entitlements for the user.

Link to Devin run: https://app.devin.ai/sessions/e407499d03e44a6881ccea898edda98d
Requested by: yujonglee (@yujonglee)

…n status

- Add new migration to update custom_access_token_hook to check active_entitlements
- Check for lookup_key='pro' instead of any active/trialing subscription
- Update tests to verify entitlements-based is_pro logic
- More robust: only grants pro status for specific feature entitlement, not any subscription

Requires creating a Feature in Stripe Dashboard with lookup_key='pro' and attaching it to the Pro product.

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@netlify
Copy link

netlify bot commented Dec 9, 2025

Deploy Preview for hyprnote-storybook ready!

Name Link
🔨 Latest commit 711c8fb
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/6937a9c4c926270008a0a94b
😎 Deploy Preview https://deploy-preview-2179--hyprnote-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 9, 2025

Deploy Preview for hyprnote ready!

Name Link
🔨 Latest commit 711c8fb
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/6937a9c4b6df350008636eb4
😎 Deploy Preview https://deploy-preview-2179--hyprnote.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 9, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

devin-ai-integration bot and others added 2 commits December 9, 2025 03:18
Per user request, merged the entitlements-based is_pro logic directly into the
original auth hook migration since production DB is still clean.

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
- Auth hook now returns entitlements: ['hyprnote_pro', ...] array with all user's active entitlements
- billing.tsx derives isPro from entitlements.includes('hyprnote_pro')
- Also exposes entitlements array for future feature gating
- Updated tests to verify entitlements array structure

This is more future-proof: adding new Stripe Features requires no code changes.

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration devin-ai-integration bot changed the title feat: switch is_pro to use Stripe Entitlements instead of subscription status feat: replace is_pro boolean with entitlements array in JWT claims Dec 9, 2025
@yujonglee yujonglee merged commit d871f18 into main Dec 9, 2025
14 of 17 checks passed
@yujonglee yujonglee deleted the devin/1765249917-entitlements-based-is-pro branch December 9, 2025 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant