Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import clsx from "clsx";
import { Check, Copy } from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "sonner";
import { parse } from "tldts";
import { useDashboardContext } from "@/app/(org)/dashboard/Contexts";
import type { DomainConfig, DomainVerification } from "./types";

Expand Down Expand Up @@ -54,6 +55,25 @@ const VerifyStep = ({
return [];
};

const isSubdomain = (raw: string): boolean => {
// Normalize and extract host (no scheme, path, port, or trailing dot)
const input =
raw
.trim()
.replace(/^https?:\/\//i, "")
.split("/")[0] ?? "";
if (!input) return false;
const host = (input.replace(/\.$/, "").split(":")[0] || "").toLowerCase();
try {
// Prefer PSL-backed parsing for correctness (e.g., co.uk, com.au)
const { subdomain } = parse(host);
return Boolean(subdomain);
} catch {
// Fallback: conservative heuristic
const parts = host.split(".");
return parts.length > 2;
}
};
const recommendedAValues = getRecommendedAValues();

// Check if DNS records are already correctly configured
Expand All @@ -63,8 +83,8 @@ const VerifyStep = ({
const cnameConfigured =
recommendedCnames.length > 0 &&
recommendedCnames.some((rec) => currentCnames.includes(rec.value));

const showARecord = recommendedARecord && !aRecordConfigured;
const showARecord =
recommendedAValues.length > 0 && !aRecordConfigured && !isSubdomain(domain);
const showCNAMERecord = hasRecommendedCNAME && !cnameConfigured;
const showTXTRecord = hasTXTVerification && !isVerified;

Expand Down Expand Up @@ -124,7 +144,7 @@ const VerifyStep = ({
) : (
!isVerified &&
domainConfig && (
<div className="space-y-4">
<div className="custom-scroll px-1 h-full max-h-[300px] space-y-4">
{/* TXT Record Configuration for Verification */}
{showTXTRecord && (
<div className="overflow-hidden rounded-lg border border-gray-4">
Expand Down
10 changes: 6 additions & 4 deletions apps/web/app/api/playlist/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Api extends HttpApi.make("CapWebApi").add(
.addError(HttpApiError.InternalServerError)
.addError(HttpApiError.NotFound),
),
) { }
) {}

const ApiLive = HttpApiBuilder.api(Api).pipe(
Layer.provide(
Expand Down Expand Up @@ -198,11 +198,13 @@ const getPlaylistResponse = (
const generatedPlaylist = generateMasterPlaylist(
videoMetadata?.Metadata?.resolution ?? "",
videoMetadata?.Metadata?.bandwidth ?? "",
`${serverEnv().WEB_URL}/api/playlist?userId=${video.ownerId
`${serverEnv().WEB_URL}/api/playlist?userId=${
video.ownerId
}&videoId=${video.id}&videoType=video`,
audioMetadata
? `${serverEnv().WEB_URL}/api/playlist?userId=${video.ownerId
}&videoId=${video.id}&videoType=audio`
? `${serverEnv().WEB_URL}/api/playlist?userId=${
video.ownerId
}&videoId=${video.id}&videoType=audio`
: null,
);

Expand Down
3 changes: 1 addition & 2 deletions apps/web/app/api/video/delete/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
HttpApiEndpoint,
HttpApiError,
HttpApiGroup,
HttpServerResponse,
} from "@effect/platform";
import { Effect, Layer, Schema } from "effect";
import { apiToHandler } from "@/lib/server";
Expand All @@ -19,7 +18,7 @@ class Api extends HttpApi.make("Api").add(
.addError(HttpApiError.Forbidden)
.addError(HttpApiError.NotFound),
),
) { }
) {}

const ApiLive = HttpApiBuilder.api(Api).pipe(
Layer.provide(
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"subtitles-parser-vtt": "^0.1.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"tldts": "^7.0.11",
"uuid": "^9.0.1",
"zod": "^3.25.76"
},
Expand Down
36 changes: 17 additions & 19 deletions packages/web-backend/src/S3Buckets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,26 @@ export class S3Buckets extends Effect.Service<S3Buckets>()("S3Buckets", {
const repo = yield* S3BucketsRepo;

const defaultConfigs = {
publicEndpoint:
yield* Config.string("S3_PUBLIC_ENDPOINT").pipe(
Config.orElse(() => Config.string("CAP_AWS_ENDPOINT")),
Config.option,
Effect.flatten,
Effect.catchTag("NoSuchElementException", () =>
Effect.dieMessage(
"Neither S3_PUBLIC_ENDPOINT nor CAP_AWS_ENDPOINT provided",
),
publicEndpoint: yield* Config.string("S3_PUBLIC_ENDPOINT").pipe(
Config.orElse(() => Config.string("CAP_AWS_ENDPOINT")),
Config.option,
Effect.flatten,
Effect.catchTag("NoSuchElementException", () =>
Effect.dieMessage(
"Neither S3_PUBLIC_ENDPOINT nor CAP_AWS_ENDPOINT provided",
),
),
internalEndpoint:
yield* Config.string("S3_INTERNAL_ENDPOINT").pipe(
Config.orElse(() => Config.string("CAP_AWS_ENDPOINT")),
Config.option,
Effect.flatten,
Effect.catchTag("NoSuchElementException", () =>
Effect.dieMessage(
"Neither S3_INTERNAL_ENDPOINT nor CAP_AWS_ENDPOINT provided",
),
),
internalEndpoint: yield* Config.string("S3_INTERNAL_ENDPOINT").pipe(
Config.orElse(() => Config.string("CAP_AWS_ENDPOINT")),
Config.option,
Effect.flatten,
Effect.catchTag("NoSuchElementException", () =>
Effect.dieMessage(
"Neither S3_INTERNAL_ENDPOINT nor CAP_AWS_ENDPOINT provided",
),
),
),
region: yield* Config.string("CAP_AWS_REGION"),
accessKey: yield* Config.string("CAP_AWS_ACCESS_KEY"),
secretKey: yield* Config.string("CAP_AWS_SECRET_KEY"),
Expand Down Expand Up @@ -181,4 +179,4 @@ export class S3Buckets extends Effect.Service<S3Buckets>()("S3Buckets", {
};
}),
dependencies: [S3BucketsRepo.Default],
}) { }
}) {}
12 changes: 7 additions & 5 deletions packages/web-backend/src/Videos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export class Videos extends Effect.Service<Videos>()("Videos", {
// This is only for external use since it does an access check,
// internal use should prefer the repo directly
getById: (id: Video.VideoId) =>
repo.getById(id).pipe(
Policy.withPublicPolicy(policy.canView(id)),
Effect.withSpan("Videos.getById"),
),
repo
.getById(id)
.pipe(
Policy.withPublicPolicy(policy.canView(id)),
Effect.withSpan("Videos.getById"),
),

/*
* Delete a video. Will fail if the user does not have access.
Expand Down Expand Up @@ -104,4 +106,4 @@ export class Videos extends Effect.Service<Videos>()("Videos", {
};
}),
dependencies: [VideosPolicy.Default, VideosRepo.Default, S3Buckets.Default],
}) { }
}) {}
40 changes: 28 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading