Compare commits

...

20 Commits

Author SHA1 Message Date
zomars 64fc828744 Merge branch 'main' into feat/calcom-auth
# Conflicts:
#	.gitmodules
#	apps/console
#	apps/web/pages/settings/my-account/conferencing.tsx
#	apps/website
#	yarn.lock
2023-01-20 16:10:02 -07:00
zomars e21f86fb17 Import fixes 2023-01-18 10:26:25 -07:00
zomars 796e9edccb Merge branch 'main' into feat/calcom-auth 2023-01-18 10:20:15 -07:00
zomars ef9bbaf889 Fixes 2023-01-18 10:20:03 -07:00
zomars 3ae98e537e Update .gitmodules 2023-01-18 09:47:04 -07:00
zomars f25fae335d Fixes 2023-01-17 16:23:18 -07:00
zomars 213489c202 Revert more stuff 2023-01-17 16:18:54 -07:00
zomars 2bba63f9f0 Fixes 2023-01-17 16:08:40 -07:00
zomars 7bc14e8cf9 Revert abstraction 2023-01-17 16:05:08 -07:00
zomars c8d573983d WIP 2023-01-17 15:51:55 -07:00
zomars 798adb2627 WIP 2023-01-17 15:44:23 -07:00
zomars b8978b48bf Sync submodule 2023-01-17 15:35:03 -07:00
zomars 1c12339479 WIP 2023-01-17 15:09:36 -07:00
zomars 94e6007245 Merge branch 'main' into feat/calcom-auth 2023-01-17 13:00:16 -07:00
zomars 1046f92c76 Merge branch 'main' into feat/calcom-auth 2023-01-16 15:39:15 -07:00
zomars 50ee78a92b WIP 2023-01-13 15:08:32 -07:00
zomars 6c2919cb91 Updates packages 2023-01-13 12:38:17 -07:00
zomars 1a1e267b29 Merge branch 'main' into feat/calcom-auth
# Conflicts:
#	yarn.lock
2023-01-13 12:32:33 -07:00
Omar López f5580a44ac
Merge branch 'main' into feat/calcom-auth 2022-12-14 18:05:09 -07:00
zomars 68b41f2816 WIP 2022-12-14 18:04:10 -07:00
112 changed files with 342 additions and 363 deletions

1
apps/auth Submodule

@ -0,0 +1 @@
Subproject commit a74ac5ec4c13ebf14a827f8cfc4704e271fa0c6b

View File

@ -1,3 +1,4 @@
import { UserPermissionRole } from "@prisma/client";
import { useSession } from "next-auth/react";
import { useRouter } from "next/router";
import React, { ComponentProps, useEffect } from "react";
@ -6,8 +7,6 @@ import SettingsLayout from "@calcom/features/settings/layouts/SettingsLayout";
import Shell from "@calcom/features/shell/Shell";
import { ErrorBoundary } from "@calcom/ui";
import { UserPermissionRole } from ".prisma/client";
export default function AdminLayout({
children,
...rest

View File

@ -1,6 +1,6 @@
import { SyntheticEvent, useState } from "react";
import { ErrorCode } from "@calcom/lib/auth";
import { ErrorCode } from "@calcom/features/auth/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, showToast } from "@calcom/ui";

View File

@ -1,7 +1,7 @@
import { useState } from "react";
import { useForm } from "react-hook-form";
import { ErrorCode } from "@calcom/lib/auth";
import { ErrorCode } from "@calcom/features/auth/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, Dialog, DialogContent, Form, Label, PasswordField } from "@calcom/ui";

View File

@ -1,7 +1,7 @@
import React, { BaseSyntheticEvent, useState } from "react";
import { useForm } from "react-hook-form";
import { ErrorCode } from "@calcom/lib/auth";
import { ErrorCode } from "@calcom/features/auth/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, Dialog, DialogContent, Form } from "@calcom/ui";

View File

@ -1,7 +1,7 @@
import { useState } from "react";
import { useForm } from "react-hook-form";
import { ErrorCode } from "@calcom/lib/auth";
import { ErrorCode } from "@calcom/features/auth/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, Dialog, DialogContent, Form, Label, PasswordField } from "@calcom/ui";

View File

@ -1,7 +1,7 @@
import React, { BaseSyntheticEvent, useState } from "react";
import { useForm } from "react-hook-form";
import { ErrorCode } from "@calcom/lib/auth";
import { ErrorCode } from "@calcom/features/auth/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, Dialog, DialogContent, Form, TextField } from "@calcom/ui";

View File

@ -1,44 +0,0 @@
import { IdentityProvider } from "@prisma/client";
import { compare, hash } from "bcryptjs";
import { Session } from "next-auth";
import { getSession as getSessionInner, GetSessionParams } from "next-auth/react";
/** @deprecated use the one from `@calcom/lib/auth` */
export async function hashPassword(password: string) {
const hashedPassword = await hash(password, 12);
return hashedPassword;
}
/** @deprecated use the one from `@calcom/lib/auth` */
export async function verifyPassword(password: string, hashedPassword: string) {
const isValid = await compare(password, hashedPassword);
return isValid;
}
/** @deprecated use the one from `@calcom/lib/auth` */
export async function getSession(options: GetSessionParams): Promise<Session | null> {
const session = await getSessionInner(options);
// that these are equal are ensured in `[...nextauth]`'s callback
return session as Session | null;
}
/** @deprecated use the one from `@calcom/lib/auth` */
export enum ErrorCode {
UserNotFound = "user-not-found",
IncorrectPassword = "incorrect-password",
UserMissingPassword = "missing-password",
TwoFactorDisabled = "two-factor-disabled",
TwoFactorAlreadyEnabled = "two-factor-already-enabled",
TwoFactorSetupRequired = "two-factor-setup-required",
SecondFactorRequired = "second-factor-required",
IncorrectTwoFactorCode = "incorrect-two-factor-code",
InternalServerError = "internal-server-error",
NewPasswordMatchesOld = "new-password-matches-old",
ThirdPartyIdentityProviderEnabled = "third-party-identity-provider-enabled",
RateLimitExceeded = "rate-limit-exceeded",
InvalidPassword = "invalid-password",
}
/** @deprecated use the one from `@calcom/lib/auth` */
export const identityProviderNameMap: { [key in IdentityProvider]: string } = {
[IdentityProvider.CAL]: "Cal",
[IdentityProvider.GOOGLE]: "Google",
[IdentityProvider.SAML]: "SAML",
};

View File

@ -2,20 +2,6 @@ require("dotenv").config({ path: "../../.env" });
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { withSentryConfig } = require("@sentry/nextjs");
const os = require("os");
const withTM = require("next-transpile-modules")([
"@calcom/app-store",
"@calcom/core",
"@calcom/dayjs",
"@calcom/emails",
"@calcom/embed-core",
"@calcom/embed-react",
"@calcom/embed-snippet",
"@calcom/features",
"@calcom/lib",
"@calcom/prisma",
"@calcom/trpc",
"@calcom/ui",
]);
const { withAxiom } = require("next-axiom");
const { i18n } = require("./next-i18next.config");
@ -74,11 +60,24 @@ if (process.env.ANALYZE === "true") {
plugins.push(withBundleAnalyzer);
}
plugins.push(withTM);
plugins.push(withAxiom);
/** @type {import("next").NextConfig} */
const nextConfig = {
transpilePackages: [
"@calcom/app-store",
"@calcom/core",
"@calcom/dayjs",
"@calcom/emails",
"@calcom/embed-core",
"@calcom/embed-react",
"@calcom/embed-snippet",
"@calcom/features",
"@calcom/lib",
"@calcom/prisma",
"@calcom/trpc",
"@calcom/ui",
],
i18n,
productionBrowserSourceMaps: true,
/* We already do type check on GH actions */
@ -138,7 +137,7 @@ const nextConfig = {
return config;
},
async rewrites() {
return [
const rewrites = [
{
source: "/:user/avatar.png",
destination: "/api/user/avatar?username=:user",
@ -175,6 +174,14 @@ const nextConfig = {
destination: process.env.NEXT_PUBLIC_EMBED_LIB_URL?,
}, */
];
// So that we can opt-in to use an external auth server
if (process.env.NEXTAUTH_URL !== process.env.NEXT_PUBLIC_WEBAPP_URL) {
rewrites.push({
source: "/api/auth/:rest*",
destination: process.env.NEXTAUTH_URL + "/api/auth/:rest*",
});
}
return rewrites;
},
async redirects() {
const redirects = [

View File

@ -23,7 +23,6 @@
"yarn": ">=1.19.0 < 2.0.0"
},
"dependencies": {
"@boxyhq/saml-jackson": "1.3.6",
"@calcom/app-store": "*",
"@calcom/app-store-cli": "*",
"@calcom/core": "*",

View File

@ -4,12 +4,11 @@ import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import { COMPANY_NAME, DEVELOPER_DOCS, DOCS_URL, JOIN_SLACK, WEBSITE_URL } from "@calcom/lib/constants";
import { ssgInit } from "@calcom/trpc/server/ssg";
import { Icon, HeadSeo } from "@calcom/ui";
import { useLocale } from "@lib/hooks/useLocale";
import { ssgInit } from "@server/lib/ssg";
export default function Custom404() {
const { t } = useLocale();

View File

@ -26,6 +26,7 @@ import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calco
import prisma from "@calcom/prisma";
import { baseEventTypeSelect } from "@calcom/prisma/selects";
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Icon, HeadSeo, AvatarGroup } from "@calcom/ui";
import { inferSSRProps } from "@lib/types/inferSSRProps";
@ -33,8 +34,6 @@ import { EmbedProps } from "@lib/withEmbedSsr";
import { AvatarSSR } from "@components/ui/AvatarSSR";
import { ssrInit } from "@server/lib/ssr";
export default function User(props: inferSSRProps<typeof getServerSideProps> & EmbedProps) {
const { users, profile, eventTypes, isDynamicGroup, dynamicNames, dynamicUsernames, isSingleUser } = props;
const [user] = users; //To be used when we only have a single user, not dynamic group

View File

@ -62,7 +62,7 @@ Type.isThemeSupported = true;
async function getUserPageProps(context: GetStaticPropsContext) {
const { type: slug, user: username } = paramsSchema.parse(context.params);
const { ssgInit } = await import("@server/lib/ssg");
const { ssgInit } = await import("@calcom/trpc/server/ssg");
const ssg = await ssgInit(context);
const user = await prisma.user.findUnique({
where: {
@ -186,7 +186,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
}
async function getDynamicGroupPageProps(context: GetStaticPropsContext) {
const { ssgInit } = await import("@server/lib/ssg");
const { ssgInit } = await import("@calcom/trpc/server/ssg");
const ssg = await ssgInit(context);
const { type: typeParam, user: userParam } = paramsSchema.parse(context.params);
const usernameList = getUsernameList(userParam);

View File

@ -13,6 +13,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { bookEventTypeSelect } from "@calcom/prisma";
import prisma from "@calcom/prisma";
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { asStringOrNull, asStringOrThrow } from "@lib/asStringOrNull";
import getBooking, { GetBookingType } from "@lib/getBooking";
@ -20,8 +21,6 @@ import { inferSSRProps } from "@lib/types/inferSSRProps";
import BookingPage from "@components/booking/pages/BookingPage";
import { ssrInit } from "@server/lib/ssr";
export type BookPageProps = inferSSRProps<typeof getServerSideProps>;
export default function Book(props: BookPageProps) {

View File

@ -0,0 +1 @@
export { default } from "@calcom/features/auth/api/dynamicHandler";

View File

@ -1,7 +1,7 @@
import type { NextApiRequest } from "next";
import { getSession } from "@calcom/features/auth/lib";
import handleNewBooking from "@calcom/features/bookings/lib/handleNewBooking";
import { getSession } from "@calcom/lib/auth";
import { defaultResponder } from "@calcom/lib/server";
async function handler(req: NextApiRequest & { userId?: number }) {

View File

@ -1,7 +1,7 @@
import type { NextApiRequest } from "next";
import { getSession } from "@calcom/features/auth/lib";
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
import { getSession } from "@calcom/lib/auth";
import { defaultResponder, defaultHandler } from "@calcom/lib/server";
async function handler(req: NextApiRequest & { userId?: number }) {

View File

@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { z } from "zod";
import { fetcher } from "@calcom/app-store/dailyvideo/lib/VideoApiAdapter";
import { getSession } from "@calcom/lib/auth";
import { getSession } from "@calcom/features/auth/lib";
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
const getAccessLinkSchema = z.union([

View File

@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from "next";
import type { Session } from "next-auth";
import getInstalledAppPath from "@calcom/app-store/_utils/getInstalledAppPath";
import { getSession } from "@calcom/lib/auth";
import { getSession } from "@calcom/features/auth/lib";
import { deriveAppDictKeyFromType } from "@calcom/lib/deriveAppDictKeyFromType";
import prisma from "@calcom/prisma";
import type { AppDeclarativeHandler, AppHandler } from "@calcom/types/AppHandler";

View File

@ -4,13 +4,12 @@ import { useRouter } from "next/router";
import RoutingFormsRoutingConfig from "@calcom/app-store/ee/routing-forms/pages/app-routing.config";
import TypeformRoutingConfig from "@calcom/app-store/typeform/pages/app-routing.config";
import prisma from "@calcom/prisma";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { AppGetServerSideProps } from "@calcom/types/AppGetServerSideProps";
import { AppProps } from "@lib/app-providers";
import { getSession } from "@lib/auth";
import { ssrInit } from "@server/lib/ssr";
type AppPageType = {
getServerSideProps: AppGetServerSideProps;
// A component than can accept any properties

View File

@ -2,10 +2,11 @@ import { GetServerSidePropsContext } from "next";
import { ChangeEventHandler, useState } from "react";
import { getAppRegistry, getAppRegistryWithCredentials } from "@calcom/app-store/_appRegistry";
import { getSession } from "@calcom/features/auth/lib";
import { classNames } from "@calcom/lib";
import { getSession } from "@calcom/lib/auth";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { AppCategories } from "@calcom/prisma/client";
import { ssgInit } from "@calcom/trpc/server/ssg";
import { inferSSRProps } from "@calcom/types/inferSSRProps";
import {
AllApps,
@ -19,8 +20,6 @@ import {
import AppsLayout from "@components/apps/layouts/AppsLayout";
import { ssgInit } from "@server/lib/ssg";
const tabs: HorizontalTabItemProps[] = [
{
name: "app_store",

View File

@ -3,13 +3,11 @@ import Link from "next/link";
import { useRouter } from "next/router";
import z from "zod";
import AuthContainer from "@calcom/features/auth/components/AuthContainer";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ssgInit } from "@calcom/trpc/server/ssg";
import { Button, Icon, SkeletonText } from "@calcom/ui";
import AuthContainer from "@components/ui/AuthContainer";
import { ssgInit } from "@server/lib/ssg";
const querySchema = z.object({
error: z.string().optional(),
});

View File

@ -6,13 +6,11 @@ import Link from "next/link";
import React, { useMemo } from "react";
import dayjs from "@calcom/dayjs";
import AuthContainer from "@calcom/features/auth/components/AuthContainer";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import prisma from "@calcom/prisma";
import { Button, TextField } from "@calcom/ui";
import { useLocale } from "@lib/hooks/useLocale";
import AuthContainer from "@components/ui/AuthContainer";
type Props = {
id: string;
resetPasswordRequest: ResetPasswordRequest;

View File

@ -5,13 +5,11 @@ import Link from "next/link";
import { useRouter } from "next/router";
import React, { SyntheticEvent } from "react";
import AuthContainer from "@calcom/features/auth/components/AuthContainer";
import { getSession } from "@calcom/features/auth/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, EmailField } from "@calcom/ui";
import { getSession } from "@lib/auth";
import { useLocale } from "@lib/hooks/useLocale";
import AuthContainer from "@components/ui/AuthContainer";
export default function ForgotPassword({ csrfToken }: { csrfToken: string }) {
const { t, i18n } = useLocale();
const [loading, setLoading] = React.useState(false);

View File

@ -7,24 +7,21 @@ import { useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { FaGoogle } from "react-icons/fa";
import { SAMLLogin } from "@calcom/features/auth/SAMLLogin";
import AuthContainer from "@calcom/features/auth/components/AuthContainer";
import { SAMLLogin } from "@calcom/features/auth/components/SAMLLogin";
import TwoFactor from "@calcom/features/auth/components/TwoFactor";
import { ErrorCode, getSession } from "@calcom/features/auth/lib";
import { isSAMLLoginEnabled, samlProductID, samlTenantID } from "@calcom/features/ee/sso/lib/saml";
import { WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants";
import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
import prisma from "@calcom/prisma";
import { Alert, Button, EmailField, Icon, PasswordField } from "@calcom/ui";
import { ErrorCode, getSession } from "@lib/auth";
import { WEBAPP_URL, WEBSITE_URL } from "@lib/config/constants";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import AddToHomescreen from "@components/AddToHomescreen";
import TwoFactor from "@components/auth/TwoFactor";
import AuthContainer from "@components/ui/AuthContainer";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { inferSSRProps } from "@calcom/types/inferSSRProps";
import { AddToHomescreen, Alert, Button, EmailField, Icon, PasswordField } from "@calcom/ui";
import { IS_GOOGLE_LOGIN_ENABLED } from "@server/lib/constants";
import { ssrInit } from "@server/lib/ssr";
interface LoginValues {
email: string;

View File

@ -3,16 +3,14 @@ import { signOut, useSession } from "next-auth/react";
import { useRouter } from "next/router";
import { useEffect } from "react";
import AuthContainer from "@calcom/features/auth/components/AuthContainer";
import { WEBSITE_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Button, Icon } from "@calcom/ui";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import AuthContainer from "@components/ui/AuthContainer";
import { ssrInit } from "@server/lib/ssr";
type Props = inferSSRProps<typeof getServerSideProps>;
export default function Logout(props: Props) {

View File

@ -3,15 +3,14 @@ import { GetServerSidePropsContext } from "next";
import { useState } from "react";
import AdminAppsList from "@calcom/features/apps/AdminAppsList";
import { getSession } from "@calcom/lib/auth";
import SetupFormStep1 from "@calcom/features/auth/components/SetupFormStep1";
import StepDone from "@calcom/features/auth/components/StepDone";
import { getSession } from "@calcom/features/auth/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import prisma from "@calcom/prisma";
import { inferSSRProps } from "@calcom/types/inferSSRProps";
import { WizardForm } from "@calcom/ui";
import SetupFormStep1 from "./steps/SetupFormStep1";
import StepDone from "./steps/StepDone";
export default function Setup(props: inferSSRProps<typeof getServerSideProps>) {
const { t } = useLocale();
const [isLoadingStep1, setIsLoadingStep1] = useState(false);

View File

@ -2,8 +2,10 @@ import { GetServerSidePropsContext } from "next";
import { signIn } from "next-auth/react";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { z } from "zod";
import { getPremiumMonthlyPlanPriceId } from "@calcom/app-store/stripepayment/lib/utils";
import { getSession } from "@calcom/features/auth/lib";
import stripe from "@calcom/features/ee/payments/server/stripe";
import {
hostedCal,
@ -14,14 +16,10 @@ import {
} from "@calcom/features/ee/sso/lib/saml";
import { checkUsername } from "@calcom/lib/server/checkUsername";
import prisma from "@calcom/prisma";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { inferSSRProps } from "@calcom/types/inferSSRProps";
import { asStringOrNull } from "@lib/asStringOrNull";
import { getSession } from "@lib/auth";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import { ssrInit } from "@server/lib/ssr";
export type SSOProviderPageProps = inferSSRProps<typeof getServerSideProps>;
type SSOProviderPageProps = inferSSRProps<typeof getServerSideProps>;
export default function Provider(props: SSOProviderPageProps) {
const router = useRouter();
@ -49,12 +47,18 @@ export default function Provider(props: SSOProviderPageProps) {
return null;
}
const querySchema = z.object({
provider: z.union([z.string(), z.null()]).optional().default(null),
email: z.union([z.string(), z.null()]).optional().default(null),
username: z.union([z.string(), z.null()]).optional().default(null),
});
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
// get query params and typecast them to string
// (would be even better to assert them instead of typecasting)
const providerParam = asStringOrNull(context.query.provider);
const emailParam = asStringOrNull(context.query.email);
const usernameParam = asStringOrNull(context.query.username);
const {
provider: providerParam,
email: emailParam,
username: usernameParam,
} = querySchema.parse(context.query);
const successDestination = "/getting-started" + (usernameParam ? `?username=${usernameParam}` : "");
if (!providerParam) {
throw new Error(`File is not named sso/[provider]`);

View File

@ -1,16 +1,13 @@
import { CheckIcon, MailOpenIcon, ExclamationIcon } from "@heroicons/react/outline";
import { CheckIcon, ExclamationIcon, MailOpenIcon } from "@heroicons/react/outline";
import { signIn } from "next-auth/react";
import Head from "next/head";
import { useRouter } from "next/router";
import * as React from "react";
import { useEffect, useState, useRef } from "react";
import { useEffect, useRef, useState } from "react";
import z from "zod";
import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants";
import { trpc } from "@calcom/trpc/react";
import { Button, showToast } from "@calcom/ui";
import Loader from "@components/Loader";
import { Button, Loader, showToast } from "@calcom/ui";
async function sendVerificationLogin(email: string, username: string) {
await signIn("email", {

View File

@ -11,6 +11,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { stringOrNumber } from "@calcom/prisma/zod-utils";
import { trpc } from "@calcom/trpc/react";
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
import { ssrInit } from "@calcom/trpc/server/ssr";
import type { Schedule as ScheduleType, TimeRange, WorkingHours } from "@calcom/types/schedule";
import {
Button,
@ -31,8 +32,6 @@ import { HttpError } from "@lib/core/http/error";
import { SelectSkeletonLoader } from "@components/availability/SkeletonLoader";
import EditableHeading from "@components/ui/EditableHeading";
import { ssrInit } from "@server/lib/ssr";
const querySchema = z.object({
schedule: stringOrNumber,
});

View File

@ -5,6 +5,7 @@ import { NewScheduleButton, ScheduleListItem } from "@calcom/features/schedules"
import Shell from "@calcom/features/shell/Shell";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { RouterOutputs, trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { EmptyScreen, Icon, showToast } from "@calcom/ui";
import { withQuery } from "@lib/QueryCell";
@ -12,8 +13,6 @@ import { HttpError } from "@lib/core/http/error";
import SkeletonLoader from "@components/availability/SkeletonLoader";
import { ssrInit } from "@server/lib/ssr";
export function AvailabilityList({ schedules }: RouterOutputs["viewer"]["availability"]["list"]) {
const { t } = useLocale();
const utils = trpc.useContext();

View File

@ -35,6 +35,7 @@ import { localStorage } from "@calcom/lib/webstorage";
import prisma from "@calcom/prisma";
import { Prisma } from "@calcom/prisma/client";
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Button, EmailInput, Icon, HeadSeo } from "@calcom/ui";
import { timeZone } from "@lib/clock";
@ -43,8 +44,6 @@ import { inferSSRProps } from "@lib/types/inferSSRProps";
import CancelBooking from "@components/booking/CancelBooking";
import EventReservationSchema from "@components/schemas/EventReservationSchema";
import { ssrInit } from "@server/lib/ssr";
function redirectToExternalUrl(url: string) {
window.parent.location.href = url;
}

View File

@ -9,6 +9,7 @@ import BookingLayout from "@calcom/features/bookings/layout/BookingLayout";
import { filterQuerySchema, useFilterQuery } from "@calcom/features/bookings/lib/useFilterQuery";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { RouterOutputs, trpc } from "@calcom/trpc/react";
import { ssgInit } from "@calcom/trpc/server/ssg";
import { Alert, Button, EmptyScreen, Icon } from "@calcom/ui";
import { useInViewObserver } from "@lib/hooks/useInViewObserver";
@ -16,8 +17,6 @@ import { useInViewObserver } from "@lib/hooks/useInViewObserver";
import BookingListItem from "@components/booking/BookingListItem";
import SkeletonLoader from "@components/booking/SkeletonLoader";
import { ssgInit } from "@server/lib/ssg";
type BookingListingStatus = z.infer<typeof filterQuerySchema>["status"];
type BookingOutput = RouterOutputs["viewer"]["bookings"]["get"]["bookings"][0];

View File

@ -6,6 +6,7 @@ import { parseRecurringEvent } from "@calcom/lib";
import { availiblityPageEventTypeSelect } from "@calcom/prisma";
import prisma from "@calcom/prisma";
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { getWorkingHours } from "@lib/availability";
import { GetBookingType } from "@lib/getBooking";
@ -14,8 +15,6 @@ import { EmbedProps } from "@lib/withEmbedSsr";
import AvailabilityPage from "@components/booking/pages/AvailabilityPage";
import { ssrInit } from "@server/lib/ssr";
export type DynamicAvailabilityPageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
export default function Type(props: DynamicAvailabilityPageProps) {

View File

@ -5,14 +5,13 @@ import { parseRecurringEvent } from "@calcom/lib";
import prisma from "@calcom/prisma";
import { bookEventTypeSelect } from "@calcom/prisma/selects";
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { asStringOrNull, asStringOrThrow } from "@lib/asStringOrNull";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import BookingPage from "@components/booking/pages/BookingPage";
import { ssrInit } from "@server/lib/ssr";
export type HashLinkPageProps = inferSSRProps<typeof getServerSideProps>;
export default function Book(props: HashLinkPageProps) {

View File

@ -19,6 +19,7 @@ import { HttpError } from "@calcom/lib/http-error";
import prisma from "@calcom/prisma";
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { trpc, RouterOutputs } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import type { BookingLimit, RecurringEvent } from "@calcom/types/Calendar";
import { Form, showToast } from "@calcom/ui";
@ -38,8 +39,6 @@ import { EventTeamWebhooksTab } from "@components/eventtype/EventTeamWebhooksTab
import { EventTypeSingleLayout } from "@components/eventtype/EventTypeSingleLayout";
import EventWorkflowsTab from "@components/eventtype/EventWorkfowsTab";
import { ssrInit } from "@server/lib/ssr";
export type FormValues = {
title: string;
eventTitle: string;

View File

@ -12,6 +12,7 @@ import Shell from "@calcom/features/shell/Shell";
import { APP_NAME, CAL_URL, WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { RouterOutputs, trpc, TRPCClientError } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import {
Badge,
Button,
@ -40,8 +41,6 @@ import { HttpError } from "@lib/core/http/error";
import { EmbedButton, EmbedDialog } from "@components/Embed";
import SkeletonLoader from "@components/eventtype/SkeletonLoader";
import { ssrInit } from "@server/lib/ssr";
type EventTypeGroups = RouterOutputs["viewer"]["eventTypes"]["getByViewer"]["eventTypeGroups"];
type EventTypeGroupProfile = EventTypeGroups[number]["profile"];

View File

@ -4,7 +4,7 @@ import Head from "next/head";
import { useRouter } from "next/router";
import { z } from "zod";
import { getSession } from "@calcom/lib/auth";
import { getSession } from "@calcom/features/auth/lib";
import { APP_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { User } from "@calcom/prisma/client";

View File

@ -2,12 +2,11 @@ import { GetServerSidePropsContext } from "next";
import AdminAppsList from "@calcom/features/apps/AdminAppsList";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Meta } from "@calcom/ui";
import { getLayout } from "@components/auth/layouts/AdminLayout";
import { ssrInit } from "@server/lib/ssr";
function AdminAppsView() {
const { t } = useLocale();
return (

View File

@ -3,12 +3,11 @@ import { signIn } from "next-auth/react";
import { useRef } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Button, Meta, TextField } from "@calcom/ui";
import { getLayout } from "@components/auth/layouts/AdminLayout";
import { ssrInit } from "@server/lib/ssr";
function AdminView() {
const { t } = useLocale();
const usernameRef = useRef<HTMLInputElement>(null);

View File

@ -1,11 +1,10 @@
import { GetServerSidePropsContext } from "next";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Meta } from "@calcom/ui";
import { getLayout } from "@components/auth/layouts/AdminLayout";
import { ssrInit } from "@server/lib/ssr";
function AdminAppsView() {
return (
<>

View File

@ -1,12 +1,11 @@
import { GetServerSidePropsContext } from "next";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Meta } from "@calcom/ui";
import { getLayout } from "@components/auth/layouts/AdminLayout";
import { ssrInit } from "@server/lib/ssr";
function AdminUsersView() {
const { t } = useLocale();
return (

View File

@ -8,10 +8,9 @@ import { classNames } from "@calcom/lib";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Button, Icon, Meta } from "@calcom/ui";
import { ssrInit } from "@server/lib/ssr";
interface CtaRowProps {
title: string;
description: string;

View File

@ -9,6 +9,7 @@ import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { APP_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import {
Button,
Dialog,
@ -19,8 +20,6 @@ import {
AppSkeletonLoader as SkeletonLoader,
} from "@calcom/ui";
import { ssrInit } from "@server/lib/ssr";
const ApiKeysView = () => {
const { t } = useLocale();

View File

@ -6,6 +6,7 @@ import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { APP_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import {
Button,
ColorPicker,
@ -19,8 +20,6 @@ import {
UpgradeTeamsBadge,
} from "@calcom/ui";
import { ssrInit } from "@server/lib/ssr";
const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (
<SkeletonContainer>

View File

@ -9,6 +9,7 @@ import DestinationCalendarSelector from "@calcom/features/calendars/DestinationC
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import {
Alert,
Badge,
@ -30,8 +31,6 @@ import { QueryCell } from "@lib/QueryCell";
import { CalendarSwitch } from "@components/settings/CalendarSwitch";
import { ssrInit } from "@server/lib/ssr";
const SkeletonLoader = () => {
return (
<SkeletonContainer>

View File

@ -4,6 +4,7 @@ import { useState } from "react";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import {
Button,
Dialog,
@ -25,8 +26,6 @@ import {
import AppListCard from "@components/AppListCard";
import { ssrInit } from "@server/lib/ssr";
const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (
<SkeletonContainer>

View File

@ -6,6 +6,7 @@ import { Controller, useForm } from "react-hook-form";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { RouterOutputs, trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import {
Button,
Form,
@ -22,8 +23,6 @@ import {
import { withQuery } from "@lib/QueryCell";
import { nameOfDay } from "@lib/core/i18n/weekday";
import { ssrInit } from "@server/lib/ssr";
const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (
<SkeletonContainer>

View File

@ -5,13 +5,14 @@ import { signOut } from "next-auth/react";
import { BaseSyntheticEvent, useRef, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { ErrorCode } from "@calcom/features/auth/lib";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { ErrorCode } from "@calcom/lib/auth";
import { APP_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { TRPCClientErrorLike } from "@calcom/trpc/client";
import { trpc } from "@calcom/trpc/react";
import { AppRouter } from "@calcom/trpc/server/routers/_app";
import { ssrInit } from "@calcom/trpc/server/ssr";
import {
Alert,
Avatar,
@ -38,8 +39,6 @@ import {
import TwoFactor from "@components/auth/TwoFactor";
import { UsernameAvailabilityField } from "@components/ui/UsernameAvailability";
import { ssrInit } from "@server/lib/ssr";
const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (
<SkeletonContainer>

View File

@ -4,10 +4,9 @@ import { useForm } from "react-hook-form";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Button, Form, Label, Meta, showToast, Skeleton, Switch } from "@calcom/ui";
import { ssrInit } from "@server/lib/ssr";
const ProfileImpersonationView = () => {
const { t } = useLocale();
const utils = trpc.useContext();

View File

@ -3,14 +3,13 @@ import { GetServerSidePropsContext } from "next";
import { Trans } from "next-i18next";
import { useForm } from "react-hook-form";
import { identityProviderNameMap } from "@calcom/features/auth/lib";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { identityProviderNameMap } from "@calcom/lib/auth";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Button, Form, Meta, PasswordField, showToast } from "@calcom/ui";
import { ssrInit } from "@server/lib/ssr";
type ChangePasswordFormValues = {
oldPassword: string;
newPassword: string;

View File

@ -1,6 +1,6 @@
import { GetServerSidePropsContext } from "next";
import { ssrInit } from "@server/lib/ssr";
import { ssrInit } from "@calcom/trpc/server/ssr";
export { default } from "@calcom/features/ee/sso/page/user-sso-view";

View File

@ -4,13 +4,12 @@ import { useState } from "react";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Badge, Meta, Switch, SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui";
import DisableTwoFactorModal from "@components/settings/DisableTwoFactorModal";
import EnableTwoFactorModal from "@components/settings/EnableTwoFactorModal";
import { ssrInit } from "@server/lib/ssr";
const SkeletonLoader = () => {
return (
<SkeletonContainer>

View File

@ -1,6 +1,6 @@
import { GetServerSidePropsContext } from "next";
import { ssrInit } from "@server/lib/ssr";
import { ssrInit } from "@calcom/trpc/server/ssr";
export { default } from "@calcom/features/ee/teams/pages/team-appearance-view";

View File

@ -1,6 +1,6 @@
import { GetServerSidePropsContext } from "next";
import { ssrInit } from "@server/lib/ssr";
import { ssrInit } from "@calcom/trpc/server/ssr";
export { default } from "@calcom/features/ee/teams/pages/team-billing-view";

View File

@ -1,6 +1,6 @@
import { GetServerSidePropsContext } from "next";
import { ssrInit } from "@server/lib/ssr";
import { ssrInit } from "@calcom/trpc/server/ssr";
export { default } from "@calcom/features/ee/teams/pages/team-members-view";

View File

@ -1,6 +1,6 @@
import { GetServerSidePropsContext } from "next";
import { ssrInit } from "@server/lib/ssr";
import { ssrInit } from "@calcom/trpc/server/ssr";
export { default } from "@calcom/features/ee/teams/pages/team-profile-view";

View File

@ -1,6 +1,6 @@
import { GetServerSidePropsContext } from "next";
import { ssrInit } from "@server/lib/ssr";
import { ssrInit } from "@calcom/trpc/server/ssr";
export { default } from "@calcom/features/ee/sso/page/teams-sso-view";

View File

@ -3,11 +3,10 @@ import Head from "next/head";
import { CreateANewTeamForm } from "@calcom/features/ee/teams/components";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { getLayout } from "@components/layouts/WizardLayout";
import { ssrInit } from "@server/lib/ssr";
const CreateNewTeamPage = () => {
const { t } = useLocale();
return (

View File

@ -7,13 +7,13 @@ import LicenseRequired from "@calcom/features/ee/common/components/v2/LicenseReq
import { isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { inferSSRProps } from "@calcom/types/inferSSRProps";
import { Alert, Button, EmailField, PasswordField, TextField, HeadSeo } from "@calcom/ui";
import { asStringOrNull } from "@calcom/web/lib/asStringOrNull";
import { WEBAPP_URL } from "@calcom/web/lib/config/constants";
import prisma from "@calcom/web/lib/prisma";
import { IS_GOOGLE_LOGIN_ENABLED } from "@calcom/web/server/lib/constants";
import { ssrInit } from "@calcom/web/server/lib/ssr";
type FormValues = {
username: string;

View File

@ -4,6 +4,7 @@ import { privacyFilteredLocations, LocationObject } from "@calcom/core/location"
import { parseRecurringEvent } from "@calcom/lib";
import prisma from "@calcom/prisma";
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { ssgInit } from "@calcom/trpc/server/ssg";
import { asStringOrNull } from "@lib/asStringOrNull";
import { getWorkingHours } from "@lib/availability";
@ -13,8 +14,6 @@ import { EmbedProps } from "@lib/withEmbedSsr";
import AvailabilityPage from "@components/booking/pages/AvailabilityPage";
import { ssgInit } from "@server/lib/ssg";
export type AvailabilityTeamPageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
export default function TeamType(props: AvailabilityTeamPageProps) {

View File

@ -4,10 +4,9 @@ import { TeamsListing } from "@calcom/features/ee/teams/components";
import Shell from "@calcom/features/shell/Shell";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ssrInit } from "@calcom/trpc/server/ssr";
import { Button, Icon } from "@calcom/ui";
import { ssrInit } from "@server/lib/ssr";
function Teams() {
const { t } = useLocale();
return (

View File

@ -1,6 +1,6 @@
import { GetServerSidePropsContext } from "next";
import { ssrInit } from "@server/lib/ssr";
import { ssrInit } from "@calcom/trpc/server/ssr";
export { default } from "@calcom/features/ee/workflows/pages/index";

View File

@ -33,6 +33,7 @@
"dev:console": "turbo run dev --scope=\"@calcom/web\" --scope=\"@calcom/console\"",
"dev:swagger": "turbo run dev --scope=\"@calcom/api\" --scope=\"@calcom/swagger\"",
"dev:website": "turbo run dev --scope=\"@calcom/web\" --scope=\"@calcom/website\"",
"dev:auth": "turbo run dev --scope=\"@calcom/web\" --scope=\"@calcom/auth\"",
"dev": "turbo run dev --scope=\"@calcom/web\"",
"docs-build": "turbo run build --scope=\"@calcom/docs\" --include-dependencies",
"docs-dev": "turbo run dev --scope=\"@calcom/docs\"",

View File

@ -1,6 +1,14 @@
import z from "zod";
import { InstalledAppVariants } from "../utils";
const InstalledAppVariants = [
"conferencing",
"calendar",
"payment",
"analytics",
"automation",
"other",
"web3",
] as const;
const variantSchema = z.enum(InstalledAppVariants);

View File

@ -7,13 +7,11 @@
"logo": "icon.svg",
"url": "https://example.com/link",
"variant": "other",
"categories": [
"other"
],
"categories": ["other"],
"publisher": "Cal.com, Inc.",
"email": "support@cal.com",
"description": "It is a template for an app that can be installed and provides no other feature.",
"isTemplate": true,
"__createdUsingCli": true,
"__template": "link-as-an-app"
}
}

View File

@ -11,4 +11,4 @@
"@calcom/types": "*"
},
"description": "It is a template for an app that can be installed and provides no other feature."
}
}

View File

@ -23,6 +23,6 @@
]
}
},
"isTemplate":true,
"isTemplate": true,
"__createdUsingCli": true
}

View File

@ -11,6 +11,6 @@
"email": "support@cal.com",
"description": "A template showcasing how an app with EventType AppCard can be built e.g. Giphy, QR Code",
"extendsFeature": "EventType",
"isTemplate":true,
"isTemplate": true,
"__createdUsingCli": true
}

View File

@ -20,6 +20,6 @@
}
},
"description": "It is a template showing how to add a static URL EventType location e.g. Around, Whereby",
"isTemplate":true,
"isTemplate": true,
"__createdUsingCli": true
}

View File

@ -10,6 +10,6 @@
"publisher": "Cal.com Inc",
"email": "support@cal.com",
"description": "It is a template showing how an App can have settings in installed section that configures the app globally e.g. Weather in your Calendar",
"isTemplate":true,
"isTemplate": true,
"__createdUsingCli": true
}

View File

@ -11,6 +11,6 @@
"publisher": "Cal.com, Inc.",
"email": "support@cal.com",
"description": "It's a template showing how an app, that is just a link to some webpage, can be made e.g. Pipedream, Amie, Vimcal.",
"isTemplate":true,
"isTemplate": true,
"__createdUsingCli": true
}

View File

@ -6,6 +6,7 @@
"license": "MIT",
"files": [
"eslint-preset.js",
"next-i18next.config.js",
"prettier-preset.js"
],
"dependencies": {

View File

@ -1,12 +1,9 @@
import { IdentityProvider } from "@prisma/client";
import type { NextApiRequest, NextApiResponse } from "next";
import { getSession, ErrorCode, hashPassword, verifyPassword } from "@calcom/features/auth/lib";
import prisma from "@calcom/prisma";
import { getSession } from "@lib/auth";
import { ErrorCode, hashPassword, verifyPassword } from "../../../lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req: req });

View File

@ -4,10 +4,9 @@ import { NextApiRequest, NextApiResponse } from "next";
import dayjs from "@calcom/dayjs";
import { sendPasswordResetEmail } from "@calcom/emails";
import { PASSWORD_RESET_EXPIRY_HOURS } from "@calcom/emails/templates/forgot-password-email";
import { getTranslation } from "@calcom/lib/server/i18n";
import prisma from "@calcom/prisma";
import { getTranslation } from "@server/lib/i18n";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const t = await getTranslation(req.body.language ?? "en", "common");

View File

@ -10,23 +10,29 @@ import nodemailer, { TransportOptions } from "nodemailer";
import { authenticator } from "otplib";
import path from "path";
import { ErrorCode, isPasswordValid, verifyPassword } from "@calcom/features/auth/lib";
import CalComAdapter from "@calcom/features/auth/lib/next-auth-custom-adapter";
import checkLicense from "@calcom/features/ee/common/server/checkLicense";
import ImpersonationProvider from "@calcom/features/ee/impersonation/lib/ImpersonationProvider";
import { hostedCal, isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml";
import { ErrorCode, isPasswordValid, verifyPassword } from "@calcom/lib/auth";
import { APP_NAME, IS_TEAM_BILLING_ENABLED, WEBAPP_URL } from "@calcom/lib/constants";
import { symmetricDecrypt } from "@calcom/lib/crypto";
import { defaultCookies } from "@calcom/lib/default-cookies";
import { randomString } from "@calcom/lib/random";
import rateLimit from "@calcom/lib/rateLimit";
import { serverConfig } from "@calcom/lib/serverConfig";
import slugify from "@calcom/lib/slugify";
import prisma from "@calcom/prisma";
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
import CalComAdapter from "@lib/auth/next-auth-custom-adapter";
import { randomString } from "@lib/random";
import slugify from "@lib/slugify";
const GOOGLE_API_CREDENTIALS = process.env.GOOGLE_API_CREDENTIALS || "{}";
const { client_id: GOOGLE_CLIENT_ID, client_secret: GOOGLE_CLIENT_SECRET } =
JSON.parse(GOOGLE_API_CREDENTIALS)?.web || {};
const GOOGLE_LOGIN_ENABLED = process.env.GOOGLE_LOGIN_ENABLED === "true";
const IS_GOOGLE_LOGIN_ENABLED = !!(GOOGLE_CLIENT_ID && GOOGLE_CLIENT_SECRET && GOOGLE_LOGIN_ENABLED);
const IS_SAML_LOGIN_ENABLED = !!(process.env.SAML_DATABASE_URL && process.env.SAML_ADMINS);
import { GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, IS_GOOGLE_LOGIN_ENABLED } from "@server/lib/constants";
const NEXTAUTH_URL = process.env.NEXTAUTH_URL || WEBAPP_URL;
const transporter = nodemailer.createTransport<TransportOptions>({
...(serverConfig.transport as TransportOptions),
@ -173,7 +179,7 @@ if (isSAMLLoginEnabled) {
version: "2.0",
checks: ["pkce", "state"],
authorization: {
url: `${WEBAPP_URL}/api/auth/saml/authorize`,
url: `${NEXTAUTH_URL}/api/auth/saml/authorize`,
params: {
scope: "",
response_type: "code",
@ -181,10 +187,10 @@ if (isSAMLLoginEnabled) {
},
},
token: {
url: `${WEBAPP_URL}/api/auth/saml/token`,
url: `${NEXTAUTH_URL}/api/auth/saml/token`,
params: { grant_type: "authorization_code" },
},
userinfo: `${WEBAPP_URL}/api/auth/saml/userinfo`,
userinfo: `${NEXTAUTH_URL}/api/auth/saml/userinfo`,
profile: (profile) => {
return {
id: profile.id || "",
@ -211,7 +217,7 @@ if (true) {
// Here we setup the sendVerificationRequest that calls the email template with the identifier (email) and token to verify.
sendVerificationRequest: ({ identifier, url }) => {
const originalUrl = new URL(url);
const webappUrl = new URL(WEBAPP_URL);
const webappUrl = new URL(NEXTAUTH_URL);
if (originalUrl.origin !== webappUrl.origin) {
url = url.replace(originalUrl.origin, webappUrl.origin);
}
@ -224,7 +230,7 @@ if (true) {
to: identifier,
subject: "Your sign-in link for " + APP_NAME,
html: emailTemplate({
base_url: WEBAPP_URL,
base_url: NEXTAUTH_URL,
signin_url: url,
email: identifier,
}),
@ -241,7 +247,7 @@ export default NextAuth({
session: {
strategy: "jwt",
},
cookies: defaultCookies(WEBAPP_URL?.startsWith("https://")),
cookies: defaultCookies(NEXTAUTH_URL?.startsWith("https://")),
pages: {
signIn: "/auth/login",
signOut: "/auth/logout",
@ -499,7 +505,7 @@ export default NextAuth({
// Allows relative callback URLs
if (url.startsWith("/")) return `${baseUrl}${url}`;
// Allows callback URLs on the same domain
else if (new URL(url).hostname === new URL(WEBAPP_URL).hostname) return url;
else if (new URL(url).hostname === new URL(NEXTAUTH_URL).hostname) return url;
return baseUrl;
},
},

View File

@ -1,9 +1,8 @@
import { NextApiRequest, NextApiResponse } from "next";
import { hashPassword } from "@calcom/features/auth/lib";
import prisma from "@calcom/prisma";
import { hashPassword } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== "POST") {
return res.status(400).json({ message: "" });

View File

@ -2,8 +2,7 @@ import { OAuthReq } from "@boxyhq/saml-jackson";
import { NextApiRequest, NextApiResponse } from "next";
import jackson from "@calcom/features/ee/sso/lib/jackson";
import { HttpError } from "@lib/core/http/error";
import { HttpError } from "@calcom/lib/http-error";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { oauthController } = await jackson();

View File

@ -1,9 +1,8 @@
import { IdentityProvider } from "@prisma/client";
import { NextApiRequest, NextApiResponse } from "next";
import { NextApiRequest } from "next";
import z from "zod";
import { isPasswordValid } from "@calcom/lib/auth";
import { hashPassword } from "@calcom/lib/auth";
import { hashPassword, isPasswordValid } from "@calcom/features/auth/lib";
import { HttpError } from "@calcom/lib/http-error";
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
import slugify from "@calcom/lib/slugify";

View File

@ -1,22 +1,16 @@
import { IdentityProvider } from "@prisma/client";
import { NextApiRequest, NextApiResponse } from "next";
import { hashPassword } from "@calcom/lib/auth";
import { hashPassword } from "@calcom/features/auth/lib";
import slugify from "@calcom/lib/slugify";
import { closeComUpsertTeamUser } from "@calcom/lib/sync/SyncServiceManager";
import prisma from "@calcom/prisma";
import slugify from "@lib/slugify";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== "POST") {
return;
}
if (process.env.NEXT_PUBLIC_DISABLE_SIGNUP === "true") {
res.status(403).json({ message: "Signup is disabled" });
return;
}
const data = req.body;
const { email, password } = data;
const username = slugify(data.username);

View File

@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from "next";
import { authenticator } from "otplib";
import { ErrorCode, getSession, verifyPassword } from "@calcom/features/auth/lib";
import { symmetricDecrypt } from "@calcom/lib/crypto";
import prisma from "@calcom/prisma";
import { ErrorCode, getSession, verifyPassword } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== "POST") {
return res.status(405).json({ message: "Method not allowed" });

View File

@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from "next";
import { authenticator } from "otplib";
import { ErrorCode, getSession } from "@calcom/features/auth/lib";
import { symmetricDecrypt } from "@calcom/lib/crypto";
import prisma from "@calcom/prisma";
import { ErrorCode, getSession } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== "POST") {
return res.status(405).json({ message: "Method not allowed" });

View File

@ -3,11 +3,10 @@ import { NextApiRequest, NextApiResponse } from "next";
import { authenticator } from "otplib";
import qrcode from "qrcode";
import { ErrorCode, getSession, verifyPassword } from "@calcom/features/auth/lib";
import { symmetricEncrypt } from "@calcom/lib/crypto";
import prisma from "@calcom/prisma";
import { ErrorCode, getSession, verifyPassword } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== "POST") {
return res.status(405).json({ message: "Method not allowed" });

View File

@ -0,0 +1,39 @@
import { NextApiHandler, NextApiRequest, NextApiResponse } from "next";
import { HttpError } from "@calcom/lib/http-error";
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
// Check that user is authenticated
const { nextauth } = req.query;
if (!Array.isArray(nextauth)) {
return res.status(404).json({ message: `API route not found` });
}
try {
/* Absolute path didn't work */
const handlerMap = (await import("./index")).authApiHandlers;
const handlerKey = nextauth.join("/");
let handler: NextApiHandler;
if (handlerKey in handlerMap) {
handler = (await handlerMap[handlerKey as keyof typeof handlerMap])?.default;
} else {
handler = (await handlerMap.default).default;
}
if (typeof handler !== "function") {
return res.status(404).json({ message: `API handler not found` });
}
return await handler(req, res);
} catch (error) {
console.error(error);
if (error instanceof HttpError) {
return res.status(error.statusCode).json({ message: error.message });
}
if (error instanceof Error) {
return res.status(400).json({ message: error.message });
}
return res.status(404).json({ message: `API handler not found` });
}
};
export default handler;

View File

@ -0,0 +1,15 @@
export const authApiHandlers = {
default: import("./auth/next-auth"),
changepw: import("./auth/changepw"),
"forgot-password": import("./auth/forgot-password"),
"reset-password": import("./auth/reset-password"),
setup: import("./auth/setup"),
signup: import("./auth/signup"),
"two-factor/totp/disable": import("./auth/two-factor/totp/disable"),
"two-factor/totp/enable": import("./auth/two-factor/totp/enable"),
"two-factor/totp/setup": import("./auth/two-factor/totp/setup"),
"saml/authorize": import("./auth/saml/authorize"),
"saml/callback": import("./auth/saml/callback"),
"saml/token": import("./auth/saml/token"),
"saml/userinfo": import("./auth/saml/userinfo"),
};

View File

@ -1,9 +1,7 @@
import classNames from "classnames";
import { APP_NAME, LOGO } from "@calcom/lib/constants";
import { Credits, HeadSeo } from "@calcom/ui";
import Loader from "@components/Loader";
import { Credits, HeadSeo, Loader } from "@calcom/ui";
interface Props {
title: string;

View File

@ -1,8 +1,7 @@
import { UserPermissionRole } from "@prisma/client";
import { useSession } from "next-auth/react";
import { FC, Fragment } from "react";
import { UserPermissionRole } from ".prisma/client";
type AdminRequiredProps = {
as?: keyof JSX.IntrinsicElements;
children?: React.ReactNode;

View File

@ -5,7 +5,7 @@ import { useRouter } from "next/router";
import { Controller, FormProvider, useForm } from "react-hook-form";
import * as z from "zod";
import { isPasswordValid } from "@calcom/lib/auth";
import { isPasswordValid } from "@calcom/features/auth/lib";
import { WEBSITE_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { EmailField, Label, PasswordField, TextField } from "@calcom/ui";

View File

@ -1,7 +1,7 @@
import { Account, IdentityProvider, Prisma, PrismaClient, User, VerificationToken } from "@prisma/client";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
import { identityProviderNameMap } from "@lib/auth";
import { identityProviderNameMap } from "./index";
/** @return { import("next-auth/adapters").Adapter } */
export default function CalComAdapter(prismaClient: PrismaClient) {

View File

@ -4,10 +4,9 @@ import { z } from "zod";
import { PaymentData } from "@calcom/app-store/stripepayment/lib/server";
import prisma from "@calcom/prisma";
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { ssrInit } from "@calcom/trpc/server/ssr";
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
import { ssrInit } from "@server/lib/ssr";
export type PaymentPageProps = inferSSRProps<typeof getServerSideProps>;
const querySchema = z.object({

View File

@ -3,8 +3,8 @@ import Stripe from "stripe";
import { z } from "zod";
import { getRequestedSlugError } from "@calcom/app-store/stripepayment/lib/team-billing";
import { getSession } from "@calcom/features/auth/lib";
import stripe from "@calcom/features/ee/payments/server/stripe";
import { getSession } from "@calcom/lib/auth";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { HttpError } from "@calcom/lib/http-error";
import { defaultHandler, defaultResponder } from "@calcom/lib/server";

View File

@ -6,6 +6,7 @@
"version": "1.0.0",
"main": "index.ts",
"dependencies": {
"@boxyhq/saml-jackson": "1.3.6",
"@lexical/react": "^0.5.0",
"dompurify": "^2.4.1",
"lexical": "^0.5.0",

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import cache from "memory-cache";
import { ErrorCode } from "./auth";
import { ErrorCode } from "@calcom/features/auth/lib";
const rateLimit = (options: { intervalInMs: number }) => {
return {

Some files were not shown because too many files have changed in this diff Show More