License server (#2379)

* WIP License server

* WIP

* Moves locations to App Store and Core

* LocationType fixes

* Runs db migrations post-deploy

* WIP

* WIP

* Cleanup

* WIP

* WIP

* Decouples translations from NavTabs

* Adds admin submodule

* Adds admin submodule

* Sync dependencies

* WIP

* WIP

* Updates submodules

* Renames package

* Updates submodules

* Adds scripts for console

* Updates license checker URL

* Updates admin

* Adds staging/prod admin console links

* Update yarn.lock

* Update NavTabs.tsx

* WIP

* Update admin

* WIP

* Adds hint to InputField

* Update admin

* Adds turbo admin dependecies

* Update admin

* Prevents redirection on form submit

* Form warning fixes

* Update admin

* Form fixes

* Update yarn.lock

* Update admin

* Update admin

* Update admin

* Adds withLicenseRequired HOC

* Adds LicenseRequired to EE components

* Admin deploy fix?

* Updates submodules

* Use relative inside lib

* type fixes

* Fixes turbo race condition

* Relocates admin to console

* Relocates admin to console

* Update console

* Update api

* Update turbo.json

* Update ErrorBoundary.tsx

* Update defaultEvents.ts

* Update checkLicense.ts

* Update yarn.lock

* Skip on E2E

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Omar Lópezandkodiakhq[bot] authored and GitHub committed 2022-05-26 11:07:14 -06:00
1 parent 6940c8d6cc
commit 9df4867fca
37 files changed
+502 -285

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import cache from "memory-cache";
import { CONSOLE_URL } from "@calcom/lib/constants";
const CACHING_TIME = 86400000; // 24 hours in milliseconds
async function checkLicense(license: string): Promise<boolean> {
if (!!process.env.NEXT_PUBLIC_IS_E2E) return true;
const url = `${CONSOLE_URL}/api/license?key=${license}`;
const cachedResponse = cache.get(url);
if (cachedResponse) {
return cachedResponse;
} else {
try {
const response = await fetch(url);
const data = await response.json();
cache.put(url, data.valid, CACHING_TIME);
return data.valid;
} catch (error) {
return false;
}
}
}
export default checkLicense;
+2 -1
View File
@@ -4,9 +4,10 @@ import customParseFormat from "dayjs/plugin/customParseFormat";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
import { nameOfDay } from "@calcom/lib/weekday";
import type { Schedule, TimeRange, WorkingHours } from "@calcom/types/schedule";
import { nameOfDay } from "./weekday";
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(customParseFormat);
+2 -1
View File
@@ -1,4 +1,5 @@
import { PeriodType, SchedulingType, UserPlan, EventTypeCustomInput } from "@prisma/client";
import type { EventTypeCustomInput } from "@prisma/client";
import { PeriodType, SchedulingType, UserPlan } from "@prisma/client";
const availability = [
{
+1 -1
View File
@@ -1,4 +1,4 @@
import { Prisma } from "@prisma/client";
import type { Prisma } from "@prisma/client";
function isPrismaObj(obj: unknown): obj is Prisma.JsonObject {
return typeof obj === "object" && !Array.isArray(obj);
+2
View File
@@ -5,6 +5,7 @@
"types": "./index.ts",
"license": "MIT",
"dependencies": {
"@prisma/client": "^3.14.0",
"bcryptjs": "^2.4.3",
"dayjs": "^1.11.2",
"ical.js": "^1.4.0",
@@ -17,6 +18,7 @@
},
"devDependencies": {
"@calcom/tsconfig": "*",
"@calcom/types": "*",
"typescript": "^4.6.4"
}
}
+2
View File
@@ -10,6 +10,8 @@ declare namespace NodeJS {
* - Acquire a commercial license to remove these terms by visiting: cal.com/sales
**/
readonly NEXT_PUBLIC_LICENSE_CONSENT: "agree" | undefined;
/** Needed to enable enterprise-only features */
readonly CALCOM_LICENSE_KEY: string | undefined;
readonly CALENDSO_ENCRYPTION_KEY: string | undefined;
readonly DATABASE_URL: string | undefined;
readonly GOOGLE_API_CREDENTIALS: string | undefined;
+1
View File
@@ -13,6 +13,7 @@ declare module "next-auth" {
* Returned by `useSession`, `getSession` and received as a prop on the `Provider` React Context
*/
interface Session {
hasValidLicense: boolean;
user: CalendsoSessionUser;
}
}