11import { env } from "@/env.mjs"
2- import { Entitlement , entitlementsByPlan , Plan , isValidEntitlement } from "./constants"
2+ import { Entitlement , entitlementsByPlan , Plan } from "./constants"
33import { base64Decode } from "@/lib/utils" ;
44import { z } from "zod" ;
55import { SOURCEBOT_SUPPORT_EMAIL } from "@/lib/constants" ;
@@ -12,7 +12,6 @@ const eeLicenseKeyPayloadSchema = z.object({
1212 seats : z . number ( ) ,
1313 // ISO 8601 date string
1414 expiryDate : z . string ( ) . datetime ( ) ,
15- customEntitlements : z . array ( z . string ( ) ) . optional ( )
1615} ) ;
1716
1817type LicenseKeyPayload = z . infer < typeof eeLicenseKeyPayloadSchema > ;
@@ -39,6 +38,10 @@ export const getLicenseKey = (): LicenseKeyPayload | null => {
3938
4039export const getPlan = ( ) : Plan => {
4140 if ( env . NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT ) {
41+ if ( env . NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === "demo" ) {
42+ return "cloud:demo" ;
43+ }
44+
4245 return "cloud:team" ;
4346 }
4447
@@ -50,9 +53,6 @@ export const getPlan = (): Plan => {
5053 process . exit ( 1 ) ;
5154 }
5255
53- if ( licenseKey . customEntitlements ) {
54- return "self-hosted:enterprise-custom" ;
55- }
5656 return licenseKey . seats === SOURCEBOT_UNLIMITED_SEATS ? "self-hosted:enterprise-unlimited" : "self-hosted:enterprise" ;
5757 } else {
5858 console . info ( `No valid license key found. Falling back to oss plan.` ) ;
@@ -71,30 +71,6 @@ export const hasEntitlement = (entitlement: Entitlement) => {
7171}
7272
7373export const getEntitlements = ( ) : Entitlement [ ] => {
74- const licenseKey = getLicenseKey ( ) ;
75- if ( ! licenseKey ) {
76- return entitlementsByPlan [ "oss" ] ;
77- }
78-
7974 const plan = getPlan ( ) ;
80- if ( plan === "self-hosted:enterprise-custom" ) {
81- const customEntitlements = licenseKey . customEntitlements ;
82- if ( ! customEntitlements ) {
83- console . error ( `The provided license key is under the self-hosted:enterprise-custom plan but has no custom entitlements. Returning oss entitlements.` ) ;
84- return entitlementsByPlan [ "oss" ] ;
85- }
86-
87- const validCustomEntitlements : Entitlement [ ] = [ ] ;
88- for ( const entitlement of customEntitlements ) {
89- if ( ! isValidEntitlement ( entitlement ) ) {
90- console . error ( `Invalid custom entitlement "${ entitlement } " provided in license key. Skipping.` ) ;
91- continue ;
92- }
93- validCustomEntitlements . push ( entitlement as Entitlement ) ;
94- }
95-
96- return validCustomEntitlements ;
97- }
98-
9975 return entitlementsByPlan [ plan ] ;
10076}
0 commit comments