2024-04-16 12:02:08 +08:00
|
|
|
import { ReservedPlanId, TenantTag, defaultManagementApi } from '@logto/schemas';
|
2024-01-02 11:02:16 +08:00
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
2024-07-26 11:18:21 +08:00
|
|
|
import {
|
|
|
|
type NewSubscriptionQuota,
|
|
|
|
type LogtoSkuResponse,
|
|
|
|
type TenantResponse,
|
|
|
|
type NewSubscriptionUsage,
|
|
|
|
} from '@/cloud/types/router';
|
2024-05-28 16:44:00 +08:00
|
|
|
import { RegionName } from '@/components/Region';
|
2024-07-26 11:18:21 +08:00
|
|
|
import { LogtoSkuType } from '@/types/skus';
|
2024-01-02 11:02:16 +08:00
|
|
|
import { type SubscriptionPlan } from '@/types/subscriptions';
|
|
|
|
|
2023-06-08 10:57:02 +08:00
|
|
|
import { adminEndpoint, isCloud } from './env';
|
2023-02-22 22:35:17 +08:00
|
|
|
|
2024-01-02 11:02:16 +08:00
|
|
|
const { tenantId, indicator } = defaultManagementApi.resource;
|
|
|
|
|
|
|
|
const defaultSubscriptionPlanId = ReservedPlanId.Development;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* - For cloud, the initial tenants data is empty, and it will be fetched from the cloud API.
|
|
|
|
* - OSS has a fixed tenant with ID `default` and no cloud API to dynamically fetch tenants.
|
|
|
|
*/
|
|
|
|
export const defaultTenantResponse: TenantResponse = {
|
|
|
|
id: tenantId,
|
|
|
|
name: `tenant_${tenantId}`,
|
|
|
|
tag: TenantTag.Development,
|
|
|
|
indicator,
|
|
|
|
subscription: {
|
|
|
|
status: 'active',
|
|
|
|
planId: defaultSubscriptionPlanId,
|
|
|
|
currentPeriodStart: dayjs().toDate(),
|
|
|
|
currentPeriodEnd: dayjs().add(1, 'month').toDate(),
|
|
|
|
},
|
|
|
|
usage: {
|
|
|
|
activeUsers: 0,
|
|
|
|
cost: 0,
|
|
|
|
tokenUsage: 0,
|
|
|
|
},
|
|
|
|
openInvoices: [],
|
|
|
|
isSuspended: false,
|
|
|
|
planId: defaultSubscriptionPlanId, // Reserved for compatibility with cloud
|
2024-05-28 16:44:00 +08:00
|
|
|
regionName: RegionName.EU, // Reserved for compatibility with cloud
|
|
|
|
createdAt: new Date(),
|
2024-01-02 11:02:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* - For cloud, the initial tenant's subscription plan will be fetched from the cloud API.
|
|
|
|
* - OSS has a fixed subscription plan with `development` id and no cloud API to dynamically fetch the subscription plan.
|
|
|
|
*/
|
|
|
|
export const defaultSubscriptionPlan: SubscriptionPlan = {
|
|
|
|
id: defaultSubscriptionPlanId,
|
|
|
|
name: 'Development',
|
|
|
|
createdAt: new Date(),
|
|
|
|
updatedAt: new Date(),
|
|
|
|
stripeProducts: [],
|
|
|
|
quota: {
|
|
|
|
mauLimit: null,
|
|
|
|
tokenLimit: null,
|
|
|
|
applicationsLimit: null,
|
|
|
|
machineToMachineLimit: null,
|
|
|
|
resourcesLimit: null,
|
|
|
|
scopesPerResourceLimit: null,
|
|
|
|
customDomainEnabled: true,
|
|
|
|
mfaEnabled: true,
|
|
|
|
omniSignInEnabled: true,
|
|
|
|
socialConnectorsLimit: null,
|
|
|
|
standardConnectorsLimit: null,
|
|
|
|
rolesLimit: null,
|
|
|
|
machineToMachineRolesLimit: null,
|
|
|
|
scopesPerRoleLimit: null,
|
|
|
|
auditLogsRetentionDays: null,
|
|
|
|
hooksLimit: null,
|
|
|
|
organizationsEnabled: true,
|
|
|
|
ssoEnabled: true,
|
|
|
|
ticketSupportResponseTime: 48,
|
2024-01-31 09:28:01 +08:00
|
|
|
thirdPartyApplicationsLimit: null,
|
2024-04-08 10:32:05 +08:00
|
|
|
tenantMembersLimit: null,
|
2024-04-16 12:02:08 +08:00
|
|
|
customJwtEnabled: true,
|
2024-07-22 11:09:12 +08:00
|
|
|
subjectTokenEnabled: true,
|
|
|
|
bringYourUiEnabled: true,
|
2024-01-02 11:02:16 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-07-26 11:18:21 +08:00
|
|
|
/**
|
|
|
|
* - For cloud, the initial tenant's subscription plan will be fetched from the cloud API.
|
|
|
|
* - OSS has a fixed subscription plan with `development` id and no cloud API to dynamically fetch the subscription plan.
|
|
|
|
*/
|
|
|
|
export const defaultLogtoSku: LogtoSkuResponse = {
|
|
|
|
id: ReservedPlanId.Development,
|
|
|
|
name: 'Logto Development plan',
|
|
|
|
createdAt: new Date(),
|
|
|
|
updatedAt: new Date(),
|
|
|
|
type: LogtoSkuType.Basic,
|
|
|
|
unitPrice: 0,
|
|
|
|
quota: {
|
|
|
|
// A soft limit for abuse monitoring
|
|
|
|
mauLimit: 100,
|
|
|
|
tokenLimit: null,
|
|
|
|
applicationsLimit: null,
|
|
|
|
machineToMachineLimit: null,
|
|
|
|
resourcesLimit: null,
|
|
|
|
scopesPerResourceLimit: null,
|
|
|
|
socialConnectorsLimit: null,
|
|
|
|
userRolesLimit: null,
|
|
|
|
machineToMachineRolesLimit: null,
|
|
|
|
scopesPerRoleLimit: null,
|
|
|
|
hooksLimit: null,
|
|
|
|
auditLogsRetentionDays: 14,
|
|
|
|
mfaEnabled: true,
|
|
|
|
organizationsEnabled: true,
|
|
|
|
enterpriseSsoLimit: null,
|
|
|
|
thirdPartyApplicationsLimit: null,
|
|
|
|
tenantMembersLimit: 20,
|
|
|
|
customJwtEnabled: true,
|
|
|
|
subjectTokenEnabled: true,
|
|
|
|
bringYourUiEnabled: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Quota for Free plan */
|
|
|
|
export const defaultSubscriptionQuota: NewSubscriptionQuota = {
|
|
|
|
mauLimit: 50_000,
|
|
|
|
tokenLimit: 500_000,
|
|
|
|
applicationsLimit: 3,
|
|
|
|
machineToMachineLimit: 1,
|
|
|
|
resourcesLimit: 1,
|
|
|
|
scopesPerResourceLimit: 1,
|
|
|
|
socialConnectorsLimit: 3,
|
|
|
|
userRolesLimit: 1,
|
|
|
|
machineToMachineRolesLimit: 1,
|
|
|
|
scopesPerRoleLimit: 1,
|
|
|
|
hooksLimit: 1,
|
|
|
|
auditLogsRetentionDays: 3,
|
|
|
|
mfaEnabled: false,
|
|
|
|
organizationsEnabled: false,
|
|
|
|
enterpriseSsoLimit: 0,
|
|
|
|
thirdPartyApplicationsLimit: 0,
|
|
|
|
tenantMembersLimit: 1,
|
|
|
|
customJwtEnabled: false,
|
|
|
|
subjectTokenEnabled: false,
|
|
|
|
bringYourUiEnabled: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const defaultSubscriptionUsage: NewSubscriptionUsage = {
|
|
|
|
mauLimit: 0,
|
|
|
|
tokenLimit: 0,
|
|
|
|
applicationsLimit: 0,
|
|
|
|
machineToMachineLimit: 0,
|
|
|
|
resourcesLimit: 0,
|
|
|
|
scopesPerResourceLimit: 0,
|
|
|
|
socialConnectorsLimit: 0,
|
|
|
|
userRolesLimit: 0,
|
|
|
|
machineToMachineRolesLimit: 0,
|
|
|
|
scopesPerRoleLimit: 0,
|
|
|
|
hooksLimit: 0,
|
|
|
|
mfaEnabled: false,
|
|
|
|
organizationsEnabled: false,
|
|
|
|
enterpriseSsoLimit: 0,
|
|
|
|
thirdPartyApplicationsLimit: 0,
|
|
|
|
tenantMembersLimit: 0,
|
|
|
|
customJwtEnabled: false,
|
|
|
|
subjectTokenEnabled: false,
|
|
|
|
bringYourUiEnabled: false,
|
|
|
|
};
|
|
|
|
|
2023-03-27 21:51:34 +08:00
|
|
|
const getAdminTenantEndpoint = () => {
|
|
|
|
// Allow endpoint override for dev or testing
|
2023-06-08 10:57:02 +08:00
|
|
|
if (adminEndpoint) {
|
|
|
|
return new URL(adminEndpoint);
|
2023-03-27 21:51:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return new URL(
|
|
|
|
isCloud ? window.location.origin.replace('cloud.', 'auth.') : window.location.origin
|
|
|
|
);
|
|
|
|
};
|
2023-02-18 18:37:49 +08:00
|
|
|
|
2023-03-27 21:51:34 +08:00
|
|
|
export const adminTenantEndpoint = getAdminTenantEndpoint();
|
2023-02-22 22:35:17 +08:00
|
|
|
|
2023-03-29 01:51:14 +08:00
|
|
|
export const mainTitle = isCloud ? 'Logto Cloud' : 'Logto Console';
|