1
1
import { env } from "@/env.mjs"
2
- import { Entitlement , entitlementsByPlan , Plan , isValidEntitlement } from "./constants"
2
+ import { Entitlement , entitlementsByPlan , Plan } from "./constants"
3
3
import { base64Decode } from "@/lib/utils" ;
4
4
import { z } from "zod" ;
5
5
import { SOURCEBOT_SUPPORT_EMAIL } from "@/lib/constants" ;
@@ -12,7 +12,6 @@ const eeLicenseKeyPayloadSchema = z.object({
12
12
seats : z . number ( ) ,
13
13
// ISO 8601 date string
14
14
expiryDate : z . string ( ) . datetime ( ) ,
15
- customEntitlements : z . array ( z . string ( ) ) . optional ( )
16
15
} ) ;
17
16
18
17
type LicenseKeyPayload = z . infer < typeof eeLicenseKeyPayloadSchema > ;
@@ -39,6 +38,10 @@ export const getLicenseKey = (): LicenseKeyPayload | null => {
39
38
40
39
export const getPlan = ( ) : Plan => {
41
40
if ( env . NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT ) {
41
+ if ( env . NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === "demo" ) {
42
+ return "cloud:demo" ;
43
+ }
44
+
42
45
return "cloud:team" ;
43
46
}
44
47
@@ -50,9 +53,6 @@ export const getPlan = (): Plan => {
50
53
process . exit ( 1 ) ;
51
54
}
52
55
53
- if ( licenseKey . customEntitlements ) {
54
- return "self-hosted:enterprise-custom" ;
55
- }
56
56
return licenseKey . seats === SOURCEBOT_UNLIMITED_SEATS ? "self-hosted:enterprise-unlimited" : "self-hosted:enterprise" ;
57
57
} else {
58
58
console . info ( `No valid license key found. Falling back to oss plan.` ) ;
@@ -71,30 +71,6 @@ export const hasEntitlement = (entitlement: Entitlement) => {
71
71
}
72
72
73
73
export const getEntitlements = ( ) : Entitlement [ ] => {
74
- const licenseKey = getLicenseKey ( ) ;
75
- if ( ! licenseKey ) {
76
- return entitlementsByPlan [ "oss" ] ;
77
- }
78
-
79
74
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
-
99
75
return entitlementsByPlan [ plan ] ;
100
76
}
0 commit comments