Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Allow specifying internal S3 endpoint (#685)

Brendan Allan0ebdda68adc5
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index 35340ed9d..1b0ab3684 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -1106,6 +1106,8 @@ async fn upload_exported_video(
Ok(UploadResult::Success(uploaded_video.link))
}
Err(e) => {
+ error!("Failed to upload video: {e}");
+
NotificationType::UploadFailed.send(&app);
Err(e)
}
diff --git a/apps/desktop/src-tauri/src/upload.rs b/apps/desktop/src-tauri/src/upload.rs
index 6be5d9067..07d654abd 100644
--- a/apps/desktop/src-tauri/src/upload.rs
+++ b/apps/desktop/src-tauri/src/upload.rs
@@ -35,13 +35,6 @@ use specta::Type;
#[derive(Deserialize, Serialize, Clone, Type, Debug)]
pub struct S3UploadMeta {
id: String,
- user_id: String,
- #[serde(default)]
- aws_region: String,
- #[serde(default, deserialize_with = "deserialize_empty_object_as_string")]
- aws_bucket: String,
- #[serde(default)]
- aws_endpoint: String,
}
fn deserialize_empty_object_as_string<'de, D>(deserializer: D) -> Result<String, D::Error>
@@ -88,62 +81,16 @@ impl S3UploadMeta {
&self.id
}
- pub fn user_id(&self) -> &str {
- &self.user_id
- }
-
- pub fn aws_region(&self) -> &str {
- &self.aws_region
- }
-
- pub fn aws_bucket(&self) -> &str {
- &self.aws_bucket
- }
-
- pub fn aws_endpoint(&self) -> &str {
- &self.aws_endpoint
- }
-
- pub fn new(
- id: String,
- user_id: String,
- aws_region: String,
- aws_bucket: String,
- aws_endpoint: String,
- ) -> Self {
- Self {
- id,
- user_id,
- aws_region,
- aws_bucket,
- aws_endpoint,
- }
- }
-
- pub fn ensure_defaults(&mut self) {
- if self.aws_region.is_empty() {
- self.aws_region = std::env::var("NEXT_PUBLIC_CAP_AWS_REGION")
- .unwrap_or_else(|_| "us-east-1".to_string());
- }
- if self.aws_bucket.is_empty() {
- self.aws_bucket =
- std::env::var("NEXT_PUBLIC_CAP_AWS_BUCKET").unwrap_or_else(|_| "capso".to_string());
- }
- if self.aws_endpoint.is_empty() {
- self.aws_endpoint = std::env::var("NEXT_PUBLIC_CAP_AWS_ENDPOINT")
- .unwrap_or_else(|_| "https://s3.amazonaws.com".to_string());
- }
+ pub fn new(id: String) -> Self {
+ Self { id }
}
}
#[derive(serde::Serialize)]
#[serde(rename_all = "camelCase")]
struct S3UploadBody {
- user_id: String,
- file_key: String,
- aws_bucket: String,
- aws_region: String,
- aws_endpoint: String,
+ video_id: String,
+ subpath: String,
}
#[derive(serde::Serialize)]
@@ -201,33 +148,17 @@ pub async fn upload_video(
) -> Result<UploadedVideo, String> {
println!("Uploading video {video_id}...");
- let file_name = file_path
- .file_name()
- .and_then(|name| name.to_str())
- .ok_or("Invalid file path")?
- .to_string();
-
let client = reqwest::Client::new();
let s3_config = match existing_config {
Some(config) => config,
- None => create_or_get_video(app, false, Some(video_id), None).await?,
+ None => create_or_get_video(app, false, Some(video_id.clone()), None).await?,
};
- let file_key = format!(
- "{}/{}/{}",
- s3_config.user_id(),
- s3_config.id(),
- "result.mp4"
- );
-
let body = build_video_upload_body(
&file_path,
S3UploadBody {
- user_id: s3_config.user_id().to_string(),
- file_key: file_key.clone(),
- aws_bucket: s3_config.aws_bucket().to_string(),
- aws_region: s3_config.aws_region().to_string(),
- aws_endpoint: s3_config.aws_endpoint().to_string(),
+ video_id: video_id.clone(),
+ subpath: "result.mp4".to_string(),
},
)?;
@@ -336,17 +267,10 @@ pub async fn upload_image(app: &AppHandle, file_path: PathBuf) -> Result<Uploade
let client = reqwest::Client::new();
let s3_config = create_or_get_video(app, true, None, None).await?;
- let file_key = format!("{}/{}/{}", s3_config.user_id, s3_config.id, file_name);
-
- println!("File key: {file_key}");
-
let body = S3ImageUploadBody {
base: S3UploadBody {
- user_id: s3_config.user_id,
- file_key: file_key.clone(),
- aws_bucket: s3_config.aws_bucket,
- aws_region: s3_config.aws_region,
- aws_endpoint: s3_config.aws_endpoint,
+ video_id: s3_config.id.clone(),
+ subpath: file_name,
},
};
@@ -427,7 +351,6 @@ pub async fn create_or_get_video(
)
})?;
- config.ensure_defaults();
Ok(config)
}
@@ -532,18 +455,10 @@ pub async fn prepare_screenshot_upload(
s3_config: &S3UploadMeta,
screenshot_path: PathBuf,
) -> Result<reqwest::Response, String> {
- let file_key = format!(
- "{}/{}/screenshot/screen-capture.jpg",
- s3_config.user_id, s3_config.id
- );
-
let body = S3ImageUploadBody {
base: S3UploadBody {
- user_id: s3_config.user_id.clone(),
- file_key: file_key.clone(),
- aws_bucket: s3_config.aws_bucket.clone(),
- aws_region: s3_config.aws_region.clone(),
- aws_endpoint: s3_config.aws_endpoint.clone(),
+ video_id: s3_config.id.clone(),
+ subpath: "screenshot/screen-capture.jpg".to_string(),
},
};
@@ -632,10 +547,8 @@ impl InstantMultipartUpload {
// --------------------------------------------
// basic constants and info for chunk approach
// --------------------------------------------
- let file_name = "result.mp4";
let client = reqwest::Client::new();
let s3_config = pre_created_video.config;
- let file_key = format!("{}/{}/{}", s3_config.user_id(), s3_config.id(), file_name);
let mut uploaded_parts = Vec::new();
let mut part_number = 1;
@@ -652,7 +565,7 @@ impl InstantMultipartUpload {
c.post(url)
.header("Content-Type", "application/json")
.json(&serde_json::json!({
- "fileKey": file_key,
+ "videoId": s3_config.id(),
"contentType": "video/mp4"
}))
})
@@ -689,6 +602,7 @@ impl InstantMultipartUpload {
return Err("No uploadId returned from initiate endpoint".to_string());
}
};
+
if upload_id.is_empty() {
return Err("Empty uploadId returned from initiate endpoint".to_string());
}
@@ -747,7 +661,7 @@ impl InstantMultipartUpload {
&app,
&client,
&file_path,
- &file_key,
+ s3_config.id(),
&upload_id,
&mut part_number,
&mut last_uploaded_position,
@@ -774,7 +688,7 @@ impl InstantMultipartUpload {
&app,
&client,
&file_path,
- &file_key,
+ s3_config.id(),
&upload_id,
&mut 1,
&mut 0,
@@ -800,10 +714,9 @@ impl InstantMultipartUpload {
Self::finalize_upload(
&app,
&file_path,
- &file_key,
+ &s3_config.id(),
&upload_id,
&uploaded_parts,
- &video_id,
)
.await?;
@@ -825,7 +738,7 @@ impl InstantMultipartUpload {
app: &AppHandle,
client: &reqwest::Client,
file_path: &PathBuf,
- file_key: &str,
+ video_id: &str,
upload_id: &str,
part_number: &mut i32,
last_uploaded_position: &mut u64,
@@ -929,7 +842,7 @@ impl InstantMultipartUpload {
c.post(url)
.header("Content-Type", "application/json")
.json(&serde_json::json!({
- "fileKey": file_key,
+ "videoId": video_id,
"uploadId": upload_id,
"partNumber": *part_number,
"md5Sum": &md5_sum
@@ -1069,10 +982,9 @@ impl InstantMultipartUpload {
async fn finalize_upload(
app: &AppHandle,
file_path: &PathBuf,
- file_key: &str,
+ video_id: &str,
upload_id: &str,
uploaded_parts: &[UploadedPart],
- video_id: &str,
) -> Result<(), String> {
println!(
"Completing multipart upload with {} parts",
@@ -1106,7 +1018,7 @@ impl InstantMultipartUpload {
c.post(url)
.header("Content-Type", "application/json")
.json(&serde_json::json!({
- "fileKey": file_key,
+ "videoId": video_id,
"uploadId": upload_id,
"parts": uploaded_parts
}))
diff --git a/apps/desktop/src-tauri/src/web_api.rs b/apps/desktop/src-tauri/src/web_api.rs
index 9afb4ec38..43e1e838c 100644
--- a/apps/desktop/src-tauri/src/web_api.rs
+++ b/apps/desktop/src-tauri/src/web_api.rs
@@ -14,16 +14,18 @@ async fn do_authed_request(
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
- let mut req = build(client, url).header(
- "Authorization",
- format!(
- "Bearer {}",
- match &auth.secret {
- AuthSecret::ApiKey { api_key } => api_key,
- AuthSecret::Session { token, .. } => token,
- }
- ),
- );
+ let mut req = build(client, url)
+ .header(
+ "Authorization",
+ format!(
+ "Bearer {}",
+ match &auth.secret {
+ AuthSecret::ApiKey { api_key } => api_key,
+ AuthSecret::Session { token, .. } => token,
+ }
+ ),
+ )
+ .header("X-Desktop-Version", env!("CARGO_PKG_VERSION"));
if let Some(s) = std::option_env!("VITE_VERCEL_AUTOMATION_BYPASS_SECRET") {
req = req.header("x-vercel-protection-bypass", s);
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index bc6cff9ae..3a36338be 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -363,7 +363,7 @@ export type RequestOpenSettings = { page: string }
export type RequestRestartRecording = null
export type RequestStartRecording = null
export type RequestStopRecording = null
-export type S3UploadMeta = { id: string; user_id: string; aws_region?: string; aws_bucket?: string; aws_endpoint?: string }
+export type S3UploadMeta = { id: string }
export type ScreenCaptureTarget = { variant: "window"; id: number } | { variant: "screen"; id: number } | { variant: "area"; screen: number; bounds: Bounds }
export type SegmentRecordings = { display: Video; camera: Video | null; mic: Audio | null; system_audio: Audio | null }
export type SerializedEditorInstance = { framesSocketUrl: string; recordingDuration: number; savedProjectConfig: ProjectConfiguration; recordings: ProjectRecordings; path: string }
diff --git a/apps/web/actions/organization/create-space.ts b/apps/web/actions/organization/create-space.ts
index a772b215f..7132fe25d 100644
--- a/apps/web/actions/organization/create-space.ts
+++ b/apps/web/actions/organization/create-space.ts
@@ -6,8 +6,7 @@ import { spaces, users, spaceMembers } from "@cap/database/schema";
import { inArray, eq, and } from "drizzle-orm";
import { nanoId, nanoIdLength } from "@cap/database/helpers";
import { revalidatePath } from "next/cache";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { createPresignedPost } from "@aws-sdk/s3-presigned-post";
+import { createBucketProvider } from "@/utils/s3";
import { serverEnv } from "@cap/env";
import { v4 as uuidv4 } from "uuid";
@@ -52,6 +51,7 @@ export async function createSpace(
)
)
.limit(1);
+
if (existingSpace.length > 0) {
return {
success: false,
@@ -89,46 +89,22 @@ export async function createSpace(
user.activeOrganizationId
}/spaces/${spaceId}/icon-${Date.now()}.${fileExtension}`;
- // Get S3 client
- const [s3Client] = await createS3Client();
- const bucketName = await getS3Bucket();
-
- // Create presigned post
- const presignedPostData = await createPresignedPost(s3Client, {
- Bucket: bucketName,
- Key: fileKey,
- Fields: {
- "Content-Type": iconFile.type,
- },
- Expires: 600, // 10 minutes
- });
-
- // Upload file to S3
- const formDataForS3 = new FormData();
- Object.entries(presignedPostData.fields).forEach(([key, value]) => {
- formDataForS3.append(key, value as string);
- });
- formDataForS3.append("file", iconFile);
+ const bucket = await createBucketProvider();
- const uploadResponse = await fetch(presignedPostData.url, {
- method: "POST",
- body: formDataForS3,
+ await bucket.putObject(fileKey, await iconFile.bytes(), {
+ contentType: iconFile.type,
});
- if (!uploadResponse.ok) {
- throw new Error("Failed to upload file to S3");
- }
-
// Construct the icon URL
if (serverEnv().CAP_AWS_BUCKET_URL) {
// If a custom bucket URL is defined, use it
iconUrl = `${serverEnv().CAP_AWS_BUCKET_URL}/${fileKey}`;
} else if (serverEnv().CAP_AWS_ENDPOINT) {
// For custom endpoints like MinIO
- iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucketName}/${fileKey}`;
+ iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucket.name}/${fileKey}`;
} else {
// Default AWS S3 URL format
- iconUrl = `https://${bucketName}.s3.${
+ iconUrl = `https://${bucket.name}.s3.${
serverEnv().CAP_AWS_REGION || "us-east-1"
}.amazonaws.com/${fileKey}`;
}
diff --git a/apps/web/actions/organization/delete-space.ts b/apps/web/actions/organization/delete-space.ts
index 287fd2bc4..c651901a3 100644
--- a/apps/web/actions/organization/delete-space.ts
+++ b/apps/web/actions/organization/delete-space.ts
@@ -5,8 +5,7 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { spaces, spaceMembers, spaceVideos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { DeleteObjectsCommand, ListObjectsV2Command } from "@aws-sdk/client-s3";
+import { createBucketProvider } from "@/utils/s3";
interface DeleteSpaceResponse {
success: boolean;
@@ -59,30 +58,21 @@ export async function deleteSpace(
// 3. Delete space icons from S3
try {
- const [s3Client] = await createS3Client();
- const bucketName = await getS3Bucket();
+ const bucketProvider = await createBucketProvider();
// List all objects with the space prefix
- const prefix = `organizations/${user.activeOrganizationId}/spaces/${spaceId}/`;
- const listObjectsCommand = new ListObjectsV2Command({
- Bucket: bucketName,
- Prefix: prefix,
+ const listedObjects = await bucketProvider.listObjects({
+ prefix: `organizations/${user.activeOrganizationId}/spaces/${spaceId}/`,
});
- const listedObjects = await s3Client.send(listObjectsCommand);
-
if (listedObjects.Contents?.length) {
- const deleteObjectsCommand = new DeleteObjectsCommand({
- Bucket: bucketName,
- Delete: {
- Objects: listedObjects.Contents.map((content) => ({
- Key: content.Key,
- })),
- },
- });
-
- await s3Client.send(deleteObjectsCommand);
+ await bucketProvider.deleteObjects(
+ listedObjects.Contents.map((content) => ({
+ Key: content.Key,
+ }))
+ );
+
console.log(
`Deleted ${listedObjects.Contents.length} objects for space ${spaceId}`
);
@@ -92,10 +82,8 @@ export async function deleteSpace(
// Continue with space deletion even if S3 deletion fails
}
- // 4. Finally delete the space itself
await db().delete(spaces).where(eq(spaces.id, spaceId));
- // Revalidate the dashboard path to reflect the changes
revalidatePath("/dashboard");
return {
diff --git a/apps/web/actions/organization/update-space.ts b/apps/web/actions/organization/update-space.ts
index a184f6c6c..bd3692247 100644
--- a/apps/web/actions/organization/update-space.ts
+++ b/apps/web/actions/organization/update-space.ts
@@ -8,8 +8,7 @@ import { revalidatePath } from "next/cache";
import { uploadSpaceIcon } from "./upload-space-icon";
import { v4 as uuidv4 } from "uuid";
import { nanoIdLength } from "@cap/database/helpers";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { DeleteObjectCommand } from "@aws-sdk/client-s3";
+import { createBucketProvider } from "@/utils/s3";
export async function updateSpace(formData: FormData) {
const user = await getCurrentUser();
@@ -44,17 +43,10 @@ export async function updateSpace(formData: FormData) {
const space = spaceArr[0];
if (space && space.iconUrl) {
try {
- const [s3Client] = await createS3Client();
- const bucketName = await getS3Bucket();
+ const bucketProvider = await createBucketProvider();
const prevKeyMatch = space.iconUrl.match(/organizations\/.+/);
- if (prevKeyMatch && prevKeyMatch[0]) {
- await s3Client.send(
- new DeleteObjectCommand({
- Bucket: bucketName,
- Key: prevKeyMatch[0],
- })
- );
- }
+ if (prevKeyMatch && prevKeyMatch[0])
+ await bucketProvider.deleteObject(prevKeyMatch[0]);
} catch (e) {
console.warn("Failed to delete old space icon from S3", e);
}
diff --git a/apps/web/actions/organization/upload-organization-icon.ts b/apps/web/actions/organization/upload-organization-icon.ts
index 45f724505..8ca595b01 100644
--- a/apps/web/actions/organization/upload-organization-icon.ts
+++ b/apps/web/actions/organization/upload-organization-icon.ts
@@ -1,15 +1,15 @@
"use server";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { createPresignedPost } from "@aws-sdk/s3-presigned-post";
-import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
+import { db } from "@cap/database";
+import { createBucketProvider } from "@/utils/s3";
import { serverEnv } from "@cap/env";
-import DOMPurify from "dompurify";
import { eq } from "drizzle-orm";
+import DOMPurify from "dompurify";
import { JSDOM } from "jsdom";
import { revalidatePath } from "next/cache";
+import { sanitizeFile } from "@/lib/sanitizeFile";
export async function uploadOrganizationIcon(
formData: FormData,
@@ -55,50 +55,14 @@ export async function uploadOrganizationIcon(
const fileKey = `organizations/${organizationId}/icon-${Date.now()}.${fileExtension}`;
try {
- // Sanitize SVG if applicable
- let uploadFile = file;
- if (file.type === "image/svg+xml") {
- const arrayBuffer = await file.arrayBuffer();
- const svgString = Buffer.from(arrayBuffer).toString("utf-8");
- const dom = new JSDOM(svgString, { contentType: "image/svg+xml" });
- const purify = DOMPurify(dom.window);
- const sanitizedSvg = purify.sanitize(
- dom.window.document.documentElement.outerHTML,
- { USE_PROFILES: { svg: true, svgFilters: true } }
- );
- uploadFile = new File([sanitizedSvg], file.name, { type: file.type });
- }
+ const sanitizedFile = await sanitizeFile(file);
- // Get S3 client
- const [s3Client] = await createS3Client();
- const bucketName = await getS3Bucket();
-
- // Create presigned post
- const presignedPostData = await createPresignedPost(s3Client, {
- Bucket: bucketName,
- Key: fileKey,
- Fields: {
- "Content-Type": uploadFile.type,
- },
- Expires: 600, // 10 minutes
- });
-
- // Upload file to S3
- const formDataForS3 = new FormData();
- Object.entries(presignedPostData.fields).forEach(([key, value]) => {
- formDataForS3.append(key, value as string);
- });
- formDataForS3.append("file", file);
+ const bucket = await createBucketProvider();
- const uploadResponse = await fetch(presignedPostData.url, {
- method: "POST",
- body: formDataForS3,
+ await bucket.putObject(fileKey, await sanitizedFile.bytes(), {
+ contentType: file.type,
});
- if (!uploadResponse.ok) {
- throw new Error("Failed to upload file to S3");
- }
-
// Construct the icon URL
let iconUrl;
if (serverEnv().CAP_AWS_BUCKET_URL) {
@@ -106,10 +70,10 @@ export async function uploadOrganizationIcon(
iconUrl = `${serverEnv().CAP_AWS_BUCKET_URL}/${fileKey}`;
} else if (serverEnv().CAP_AWS_ENDPOINT) {
// For custom endpoints like MinIO
- iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucketName}/${fileKey}`;
+ iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucket.name}/${fileKey}`;
} else {
// Default AWS S3 URL format
- iconUrl = `https://${bucketName}.s3.${
+ iconUrl = `https://${bucket.name}.s3.${
serverEnv().CAP_AWS_REGION || "us-east-1"
}.amazonaws.com/${fileKey}`;
}
@@ -117,9 +81,7 @@ export async function uploadOrganizationIcon(
// Update organization with new icon URL
await db()
.update(organizations)
- .set({
- iconUrl,
- })
+ .set({ iconUrl })
.where(eq(organizations.id, organizationId));
revalidatePath("/dashboard/settings/organization");
diff --git a/apps/web/actions/organization/upload-space-icon.ts b/apps/web/actions/organization/upload-space-icon.ts
index 831040667..da26f2200 100644
--- a/apps/web/actions/organization/upload-space-icon.ts
+++ b/apps/web/actions/organization/upload-space-icon.ts
@@ -1,14 +1,13 @@
"use server";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { DeleteObjectCommand } from "@aws-sdk/client-s3";
-import { createPresignedPost } from "@aws-sdk/s3-presigned-post";
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { spaces } from "@cap/database/schema";
import { serverEnv } from "@cap/env";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
+import { createBucketProvider } from "@/utils/s3";
+import { sanitizeFile } from "@/lib/sanitizeFile";
export async function uploadSpaceIcon(formData: FormData, spaceId: string) {
const user = await getCurrentUser();
@@ -47,44 +46,22 @@ export async function uploadSpaceIcon(formData: FormData, spaceId: string) {
throw new Error("File size must be less than 2MB");
}
- // Sanitize SVG if applicable
- let uploadFile = file;
- if (file.type === "image/svg+xml") {
- const arrayBuffer = await file.arrayBuffer();
- const svgString = Buffer.from(arrayBuffer).toString("utf-8");
- const dom = new (await import("jsdom")).JSDOM(svgString, {
- contentType: "image/svg+xml",
- });
- const purify = (await import("dompurify")).default(dom.window);
- const sanitizedSvg = purify.sanitize(
- dom.window.document.documentElement.outerHTML,
- { USE_PROFILES: { svg: true, svgFilters: true } }
- );
- uploadFile = new File([sanitizedSvg], file.name, { type: file.type });
- }
-
// Prepare new file key
const fileExtension = file.name.split(".").pop();
const fileKey = `organizations/${
space.organizationId
}/spaces/${spaceId}/icon-${Date.now()}.${fileExtension}`;
- try {
- const [s3Client] = await createS3Client();
- const bucketName = await getS3Bucket();
+ const bucket = await createBucketProvider();
+ try {
// Remove previous icon if exists
if (space.iconUrl) {
// Try to extract the previous S3 key from the URL
const prevKeyMatch = space.iconUrl.match(/organizations\/.+/);
if (prevKeyMatch && prevKeyMatch[0]) {
try {
- await s3Client.send(
- new DeleteObjectCommand({
- Bucket: bucketName,
- Key: prevKeyMatch[0],
- })
- );
+ await bucket.deleteObject(prevKeyMatch[0]);
} catch (e) {
// Log and continue
console.warn("Failed to delete old space icon from S3", e);
@@ -92,39 +69,20 @@ export async function uploadSpaceIcon(formData: FormData, spaceId: string) {
}
}
- // Create presigned post
- const presignedPostData = await createPresignedPost(s3Client, {
- Bucket: bucketName,
- Key: fileKey,
- Fields: {
- "Content-Type": file.type,
- },
- Expires: 600, // 10 minutes
- });
-
- // Upload file to S3
- const formDataForS3 = new FormData();
- Object.entries(presignedPostData.fields).forEach(([key, value]) => {
- formDataForS3.append(key, value as string);
- });
- formDataForS3.append("file", file);
+ const sanitizedFile = await sanitizeFile(file);
- const uploadResponse = await fetch(presignedPostData.url, {
- method: "POST",
- body: formDataForS3,
+ await bucket.putObject(fileKey, await sanitizedFile.bytes(), {
+ contentType: file.type,
});
- if (!uploadResponse.ok) {
- throw new Error("Failed to upload file to S3");
- }
// Construct the icon URL
let iconUrl;
if (serverEnv().CAP_AWS_BUCKET_URL) {
iconUrl = `${serverEnv().CAP_AWS_BUCKET_URL}/${fileKey}`;
} else if (serverEnv().CAP_AWS_ENDPOINT) {
- iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucketName}/${fileKey}`;
+ iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucket.name}/${fileKey}`;
} else {
- iconUrl = `https://${bucketName}.s3.${
+ iconUrl = `https://${bucket.name}.s3.${
serverEnv().CAP_AWS_REGION || "us-east-1"
}.amazonaws.com/${fileKey}`;
}
diff --git a/apps/web/actions/screenshots/get-screenshot.ts b/apps/web/actions/screenshots/get-screenshot.ts
index ee8ddd976..cf5bd394d 100644
--- a/apps/web/actions/screenshots/get-screenshot.ts
+++ b/apps/web/actions/screenshots/get-screenshot.ts
@@ -1,14 +1,8 @@
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
-import {
- S3Client,
- ListObjectsV2Command,
- GetObjectCommand,
-} from "@aws-sdk/client-s3";
import { getCurrentUser } from "@cap/database/auth/session";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
+import { createBucketProvider } from "@/utils/s3";
import { S3_BUCKET_URL } from "@cap/utils";
import { buildEnv, serverEnv } from "@cap/env";
@@ -42,19 +36,14 @@ export async function getScreenshot(userId: string, screenshotId: string) {
}
}
- const Bucket = await getS3Bucket(bucket);
+ const bucketProvider = await createBucketProvider(bucket);
const screenshotPrefix = `${userId}/${screenshotId}/`;
try {
- const [s3Client] = await createS3Client(bucket);
-
- const objectsCommand = new ListObjectsV2Command({
- Bucket,
- Prefix: screenshotPrefix,
+ const objects = await bucketProvider.listObjects({
+ prefix: screenshotPrefix,
});
- const objects = await s3Client.send(objectsCommand);
-
const screenshot = objects.Contents?.find((object) =>
object.Key?.endsWith(".png")
);
@@ -66,14 +55,7 @@ export async function getScreenshot(userId: string, screenshotId: string) {
let screenshotUrl: string;
if (video.awsBucket !== serverEnv().CAP_AWS_BUCKET) {
- screenshotUrl = await getSignedUrl(
- s3Client,
- new GetObjectCommand({
- Bucket,
- Key: screenshot.Key,
- }),
- { expiresIn: 3600 }
- );
+ screenshotUrl = await bucketProvider.getSignedObjectUrl(screenshot.Key!);
} else {
screenshotUrl = `${S3_BUCKET_URL}/${screenshot.Key}`;
}
diff --git a/apps/web/actions/video/upload.ts b/apps/web/actions/video/upload.ts
index 7278e4f41..9d92c91fe 100644
--- a/apps/web/actions/video/upload.ts
+++ b/apps/web/actions/video/upload.ts
@@ -1,8 +1,7 @@
-'use server';
+"use server";
import { getCurrentUser } from "@cap/database/auth/session";
-import { createS3Client, getS3Bucket, getS3Config } from "@/utils/s3";
-import { createPresignedPost } from "@aws-sdk/s3-presigned-post";
+import { createBucketProvider, getS3Bucket, getS3Config } from "@/utils/s3";
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
@@ -13,7 +12,7 @@ import {
CreateInvalidationCommand,
} from "@aws-sdk/client-cloudfront";
-export async function getVideoUploadPresignedUrl({
+async function getVideoUploadPresignedUrl({
fileKey,
duration,
resolution,
@@ -33,28 +32,27 @@ export async function getVideoUploadPresignedUrl({
}
try {
- const [bucket] = await db()
+ const [customBucket] = await db()
.select()
.from(s3Buckets)
.where(eq(s3Buckets.ownerId, user.id));
- const s3Config = bucket
+ const s3Config = customBucket
? {
- endpoint: bucket.endpoint || undefined,
- region: bucket.region,
- accessKeyId: bucket.accessKeyId,
- secretAccessKey: bucket.secretAccessKey,
+ endpoint: customBucket.endpoint || undefined,
+ region: customBucket.region,
+ accessKeyId: customBucket.accessKeyId,
+ secretAccessKey: customBucket.secretAccessKey,
}
: null;
if (
- !bucket ||
+ !customBucket ||
!s3Config ||
- bucket.bucketName !== serverEnv().CAP_AWS_BUCKET
+ customBucket.bucketName !== serverEnv().CAP_AWS_BUCKET
) {
const distributionId = serverEnv().CAP_CLOUDFRONT_DISTRIBUTION_ID;
if (distributionId) {
-
const cloudfront = new CloudFrontClient({
region: serverEnv().CAP_AWS_REGION || "us-east-1",
credentials: {
@@ -66,7 +64,7 @@ export async function getVideoUploadPresignedUrl({
const pathToInvalidate = "/" + fileKey;
try {
- const invalidation = await cloudfront.send(
+ await cloudfront.send(
new CreateInvalidationCommand({
DistributionId: distributionId,
InvalidationBatch: {
@@ -84,7 +82,7 @@ export async function getVideoUploadPresignedUrl({
}
}
- const [s3Client] = await createS3Client(s3Config);
+ const bucket = await createBucketProvider(customBucket);
const contentType = fileKey.endsWith(".aac")
? "audio/aac"
@@ -107,11 +105,7 @@ export async function getVideoUploadPresignedUrl({
"x-amz-meta-audiocodec": audioCodec ?? "",
};
- const bucketName = await getS3Bucket(bucket);
-
- const presignedPostData = await createPresignedPost(s3Client, {
- Bucket: bucketName,
- Key: fileKey,
+ const presignedPostData = await bucket.getPresignedPostUrl(fileKey, {
Fields,
Expires: 1800,
});
@@ -119,7 +113,7 @@ export async function getVideoUploadPresignedUrl({
const customEndpoint = serverEnv().CAP_AWS_ENDPOINT;
if (customEndpoint && !customEndpoint.includes("amazonaws.com")) {
if (serverEnv().S3_PATH_STYLE) {
- presignedPostData.url = `${customEndpoint}/${bucketName}`;
+ presignedPostData.url = `${customEndpoint}/${bucket.name}`;
} else {
presignedPostData.url = customEndpoint;
}
@@ -179,14 +173,11 @@ export async function createVideoAndGetUploadUrl({
throw new Error("upgrade_required");
}
- const [bucket] = await db()
+ const [customBucket] = await db()
.select()
.from(s3Buckets)
.where(eq(s3Buckets.ownerId, user.id));
- const s3Config = await getS3Config(bucket);
- const bucketName = await getS3Bucket(bucket);
-
const date = new Date();
const formattedDate = `${date.getDate()} ${date.toLocaleString("default", {
month: "long",
@@ -199,7 +190,9 @@ export async function createVideoAndGetUploadUrl({
.where(eq(videos.id, videoId));
if (existingVideo) {
- const fileKey = `${user.id}/${videoId}/${isScreenshot ? "screenshot/screen-capture.jpg" : "result.mp4"}`;
+ const fileKey = `${user.id}/${videoId}/${
+ isScreenshot ? "screenshot/screen-capture.jpg" : "result.mp4"
+ }`;
const { presignedPostData } = await getVideoUploadPresignedUrl({
fileKey,
duration: duration?.toString(),
@@ -210,9 +203,6 @@ export async function createVideoAndGetUploadUrl({
return {
id: existingVideo.id,
- user_id: user.id,
- aws_region: existingVideo.awsRegion,
- aws_bucket: existingVideo.awsBucket,
presignedPostData,
};
}
@@ -220,20 +210,25 @@ export async function createVideoAndGetUploadUrl({
const idToUse = videoId || nanoId();
+ const bucket = await createBucketProvider(customBucket);
+
const videoData = {
id: idToUse,
- name: `Cap ${isScreenshot ? "Screenshot" : isUpload ? "Upload" : "Recording"} - ${formattedDate}`,
+ name: `Cap ${
+ isScreenshot ? "Screenshot" : isUpload ? "Upload" : "Recording"
+ } - ${formattedDate}`,
ownerId: user.id,
- awsRegion: s3Config.region,
- awsBucket: bucketName,
+ awsBucket: bucket.name,
source: { type: "desktopMP4" as const },
isScreenshot,
- bucket: bucket?.id,
+ bucket: customBucket?.id,
};
await db().insert(videos).values(videoData);
- const fileKey = `${user.id}/${idToUse}/${isScreenshot ? "screenshot/screen-capture.jpg" : "result.mp4"}`;
+ const fileKey = `${user.id}/${idToUse}/${
+ isScreenshot ? "screenshot/screen-capture.jpg" : "result.mp4"
+ }`;
const { presignedPostData } = await getVideoUploadPresignedUrl({
fileKey,
duration: duration?.toString(),
@@ -244,9 +239,6 @@ export async function createVideoAndGetUploadUrl({
return {
id: idToUse,
- user_id: user.id,
- aws_region: s3Config.region,
- aws_bucket: bucketName,
presignedPostData,
};
} catch (error) {
@@ -255,4 +247,4 @@ export async function createVideoAndGetUploadUrl({
error instanceof Error ? error.message : "Failed to create video"
);
}
-}
\ No newline at end of file
+}
diff --git a/apps/web/actions/videos/delete.ts b/apps/web/actions/videos/delete.ts
index 2ee8d27f1..66f573af2 100644
--- a/apps/web/actions/videos/delete.ts
+++ b/apps/web/actions/videos/delete.ts
@@ -4,8 +4,7 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { s3Buckets, videos } from "@cap/database/schema";
import { db } from "@cap/database";
import { and, eq } from "drizzle-orm";
-import { DeleteObjectsCommand, ListObjectsV2Command } from "@aws-sdk/client-s3";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
+import { createBucketProvider } from "@/utils/s3";
export async function deleteVideo(videoId: string) {
try {
@@ -25,15 +24,7 @@ export async function deleteVideo(videoId: string) {
.leftJoin(s3Buckets, eq(videos.bucket, s3Buckets.id))
.where(eq(videos.id, videoId));
- if (query.length === 0) {
- return {
- success: false,
- message: "Video does not exist",
- };
- }
-
- const result = query[0];
- if (!result) {
+ if (!query[0]) {
return {
success: false,
message: "Video not found",
@@ -44,28 +35,19 @@ export async function deleteVideo(videoId: string) {
.delete(videos)
.where(and(eq(videos.id, videoId), eq(videos.ownerId, userId)));
- const [s3Client] = await createS3Client(result.bucket);
- const Bucket = await getS3Bucket(result.bucket);
+ const bucket = await createBucketProvider(query[0].bucket);
const prefix = `${userId}/${videoId}/`;
- const listObjectsCommand = new ListObjectsV2Command({
- Bucket,
- Prefix: prefix,
+ const listedObjects = await bucket.listObjects({
+ prefix: prefix,
});
- const listedObjects = await s3Client.send(listObjectsCommand);
-
if (listedObjects.Contents?.length) {
- const deleteObjectsCommand = new DeleteObjectsCommand({
- Bucket,
- Delete: {
- Objects: listedObjects.Contents.map((content: any) => ({
- Key: content.Key,
- })),
- },
- });
-
- await s3Client.send(deleteObjectsCommand);
+ await bucket.deleteObjects(
+ listedObjects.Contents.map((content) => ({
+ Key: content.Key,
+ }))
+ );
}
return {
diff --git a/apps/web/actions/videos/edit-transcript.ts b/apps/web/actions/videos/edit-transcript.ts
index 707620c64..35d8b5b0c 100644
--- a/apps/web/actions/videos/edit-transcript.ts
+++ b/apps/web/actions/videos/edit-transcript.ts
@@ -6,14 +6,13 @@ import { videos, s3Buckets } from "@cap/database/schema";
import { db } from "@cap/database";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
-import { createS3Client } from "@/utils/s3";
+import { createBucketProvider } from "@/utils/s3";
export async function editTranscriptEntry(
videoId: string,
entryId: number,
newText: string
): Promise<{ success: boolean; message: string }> {
-
const user = await getCurrentUser();
if (!user || !videoId || entryId === undefined || !newText?.trim()) {
@@ -42,7 +41,7 @@ export async function editTranscriptEntry(
return { success: false, message: "Video information is missing" };
}
- const { video, bucket } = result;
+ const { video } = result;
if (video.ownerId !== userId) {
return {
@@ -51,40 +50,21 @@ export async function editTranscriptEntry(
};
}
- const awsRegion = video.awsRegion;
- const awsBucket = video.awsBucket;
-
- if (!awsRegion || !awsBucket) {
- return {
- success: false,
- message: "AWS region or bucket information is missing",
- };
- }
- const [s3Client] = await createS3Client(bucket);
+ const bucket = await createBucketProvider(result.bucket);
try {
const transcriptKey = `${video.ownerId}/${videoId}/transcription.vtt`;
- const getCommand = new GetObjectCommand({
- Bucket: awsBucket,
- Key: transcriptKey,
- });
-
- const response = await s3Client.send(getCommand);
- const vttContent = await response.Body?.transformToString();
-
- if (!vttContent) {
+ const vttContent = await bucket.getObject(transcriptKey);
+ if (!vttContent)
return { success: false, message: "Transcript file not found" };
- }
+
const updatedVttContent = updateVttEntry(vttContent, entryId, newText);
- const putCommand = new PutObjectCommand({
- Bucket: awsBucket,
- Key: transcriptKey,
- Body: updatedVttContent,
- ContentType: "text/vtt",
+
+ await bucket.putObject(transcriptKey, updatedVttContent, {
+ contentType: "text/vtt",
});
- await s3Client.send(putCommand);
revalidatePath(`/s/${videoId}`);
return {
@@ -96,7 +76,7 @@ export async function editTranscriptEntry(
error: error instanceof Error ? error.message : error,
videoId,
entryId,
- userId
+ userId,
});
return {
success: false,
@@ -105,8 +85,11 @@ export async function editTranscriptEntry(
}
}
-function updateVttEntry(vttContent: string, entryId: number, newText: string): string {
-
+function updateVttEntry(
+ vttContent: string,
+ entryId: number,
+ newText: string
+): string {
const lines = vttContent.split("\n");
const updatedLines: string[] = [];
let currentEntryId: number | null = null;
@@ -116,7 +99,7 @@ function updateVttEntry(vttContent: string, entryId: number, newText: string): s
for (let i = 0; i < lines.length; i++) {
const line = lines[i] || "";
const trimmedLine = line.trim();
-
+
if (!trimmedLine) {
updatedLines.push(line);
isNextLineText = false;
@@ -152,12 +135,15 @@ function updateVttEntry(vttContent: string, entryId: number, newText: string): s
}
}
}
-
+
if (!foundEntry) {
- console.warn("Target entry not found in VTT content", { entryId, totalEntries: lines.filter(line => /^\d+$/.test(line.trim())).length });
+ console.warn("Target entry not found in VTT content", {
+ entryId,
+ totalEntries: lines.filter((line) => /^\d+$/.test(line.trim())).length,
+ });
}
const result = updatedLines.join("\n");
-
+
return result;
-}
\ No newline at end of file
+}
diff --git a/apps/web/actions/videos/generate-ai-metadata.ts b/apps/web/actions/videos/generate-ai-metadata.ts
index 0b8275a1c..55395b20f 100644
--- a/apps/web/actions/videos/generate-ai-metadata.ts
+++ b/apps/web/actions/videos/generate-ai-metadata.ts
@@ -7,11 +7,12 @@ import { s3Buckets, videos } from "@cap/database/schema";
import { VideoMetadata } from "@cap/database/types";
import { eq } from "drizzle-orm";
import { serverEnv } from "@cap/env";
-import { createS3Client } from "@/utils/s3";
+import { createBucketProvider } from "@/utils/s3";
export async function generateAiMetadata(videoId: string, userId: string) {
-
if (!serverEnv().OPENAI_API_KEY) {
- console.error("[generateAiMetadata] Missing OpenAI API key, skipping AI metadata generation");
+ console.error(
+ "[generateAiMetadata] Missing OpenAI API key, skipping AI metadata generation"
+ );
return;
}
const videoQuery = await db()
@@ -20,65 +21,64 @@ export async function generateAiMetadata(videoId: string, userId: string) {
.where(eq(videos.id, videoId));
if (videoQuery.length === 0 || !videoQuery[0]?.video) {
- console.error(`[generateAiMetadata] Video ${videoId} not found in database`);
+ console.error(
+ `[generateAiMetadata] Video ${videoId} not found in database`
+ );
return;
}
-
+
const videoData = videoQuery[0].video;
- const metadata = videoData.metadata as VideoMetadata || {};
-
+ const metadata = (videoData.metadata as VideoMetadata) || {};
+
if (metadata.aiProcessing === true) {
-
const updatedAtTime = new Date(videoData.updatedAt).getTime();
const currentTime = new Date().getTime();
const tenMinutesInMs = 10 * 60 * 1000;
const minutesElapsed = Math.round((currentTime - updatedAtTime) / 60000);
-
+
if (currentTime - updatedAtTime > tenMinutesInMs) {
await db()
.update(videos)
- .set({
+ .set({
metadata: {
...metadata,
aiProcessing: false,
- generationError: null
- }
+ generationError: null,
+ },
})
.where(eq(videos.id, videoId));
-
+
metadata.aiProcessing = false;
metadata.generationError = null;
} else {
return;
}
}
-
+
if (metadata.summary || metadata.chapters) {
-
if (metadata.aiProcessing) {
await db()
.update(videos)
- .set({
+ .set({
metadata: {
...metadata,
- aiProcessing: false
- }
+ aiProcessing: false,
+ },
})
.where(eq(videos.id, videoId));
}
return;
}
-
+
if (videoData?.transcriptionStatus !== "COMPLETE") {
-
if (metadata.aiProcessing) {
await db()
.update(videos)
- .set({
+ .set({
metadata: {
...metadata,
- aiProcessing: false
- }
+ aiProcessing: false,
+ },
})
.where(eq(videos.id, videoId));
}
@@ -88,11 +88,11 @@ export async function generateAiMetadata(videoId: string, userId: string) {
try {
await db()
.update(videos)
- .set({
+ .set({
metadata: {
...metadata,
- aiProcessing: true
- }
+ aiProcessing: true,
+ },
})
.where(eq(videos.id, videoId));
const query = await db()
@@ -108,37 +108,31 @@ export async function generateAiMetadata(videoId: string, userId: string) {
const row = query[0];
if (!row || !row.video) {
- console.error(`[generateAiMetadata] Video record not found for ${videoId}`);
+ console.error(
+ `[generateAiMetadata] Video record not found for ${videoId}`
+ );
throw new Error(`Video record not found for ${videoId}`);
}
-
- const { video, bucket } = row;
+
+ const { video } = row;
const awsBucket = video.awsBucket;
if (!awsBucket) {
- console.error(`[generateAiMetadata] AWS bucket not found for video ${videoId}`);
+ console.error(
+ `[generateAiMetadata] AWS bucket not found for video ${videoId}`
+ );
throw new Error(`AWS bucket not found for video ${videoId}`);
}
- const [s3Client] = await createS3Client(bucket);
-
+
+ const bucket = await createBucketProvider(row.bucket);
+
const transcriptKey = `${userId}/${videoId}/transcription.vtt`;
- const transcriptUrl = await getSignedUrl(
- s3Client,
- new GetObjectCommand({
- Bucket: awsBucket,
- Key: transcriptKey,
- })
- );
- const res = await fetch(transcriptUrl);
- if (!res.ok) {
- console.error(`[generateAiMetadata] Failed to fetch transcript: ${res.status} ${res.statusText}`);
- throw new Error(`Failed to fetch transcript: ${res.status} ${res.statusText}`);
- }
-
- const vtt = await res.text();
+ const vtt = await bucket.getObject(transcriptKey);
if (!vtt || vtt.length < 10) {
- console.error(`[generateAiMetadata] Transcript is empty or too short (${vtt.length} chars)`);
+ console.error(
+ `[generateAiMetadata] Transcript is empty or too short (${vtt?.length} chars)`
+ );
throw new Error("Transcript is empty or too short");
}
@@ -152,7 +146,7 @@ export async function generateAiMetadata(videoId: string, userId: string) {
!l.includes("-->")
)
.join(" ");
-
+
const prompt = `You are Cap AI. Summarize the transcript and provide JSON in the following format:
{
"title": "string",
@@ -174,26 +168,34 @@ ${transcriptText}`;
});
if (!aiRes.ok) {
const errorText = await aiRes.text();
- console.error(`[generateAiMetadata] OpenAI API error: ${aiRes.status} ${errorText}`);
+ console.error(
+ `[generateAiMetadata] OpenAI API error: ${aiRes.status} ${errorText}`
+ );
throw new Error(`OpenAI API error: ${aiRes.status} ${errorText}`);
}
const aiJson = await aiRes.json();
const content = aiJson.choices?.[0]?.message?.content || "{}";
-
- let data: { title?: string; summary?: string; chapters?: { title: string; start: number }[] } = {};
+
+ let data: {
+ title?: string;
+ summary?: string;
+ chapters?: { title: string; start: number }[];
+ } = {};
try {
data = JSON.parse(content);
} catch (e) {
console.error(`[generateAiMetadata] Error parsing OpenAI response: ${e}`);
- data = {
- title: "Generated Title",
- summary: "The AI was unable to generate a proper summary for this content.",
- chapters: []
+ data = {
+ title: "Generated Title",
+ summary:
+ "The AI was unable to generate a proper summary for this content.",
+ chapters: [],
};
}
- const currentMetadata: VideoMetadata = (video.metadata as VideoMetadata) || {};
+ const currentMetadata: VideoMetadata =
+ (video.metadata as VideoMetadata) || {};
const updatedMetadata: VideoMetadata = {
...currentMetadata,
aiTitle: data.title || currentMetadata.aiTitle,
@@ -201,15 +203,20 @@ ${transcriptText}`;
chapters: data.chapters || currentMetadata.chapters,
aiProcessing: false,
};
-
+
await db()
.update(videos)
.set({ metadata: updatedMetadata })
.where(eq(videos.id, videoId));
-
- const hasDatePattern = /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(video.name || "");
-
- if ((video.name?.startsWith("Cap Recording -") || hasDatePattern) && data.title) {
+
+ const hasDatePattern = /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(
+ video.name || ""
+ );
+
+ if (
+ (video.name?.startsWith("Cap Recording -") || hasDatePattern) &&
+ data.title
+ ) {
await db()
.update(videos)
.set({ name: data.title })
@@ -217,24 +224,32 @@ ${transcriptText}`;
}
} catch (error) {
console.error(`[generateAiMetadata] Error for video ${videoId}:`, error);
-
+
try {
- const currentVideo = await db().select().from(videos).where(eq(videos.id, videoId));
+ const currentVideo = await db()
+ .select()
+ .from(videos)
+ .where(eq(videos.id, videoId));
if (currentVideo.length > 0 && currentVideo[0]) {
- const currentMetadata: VideoMetadata = (currentVideo[0].metadata as VideoMetadata) || {};
+ const currentMetadata: VideoMetadata =
+ (currentVideo[0].metadata as VideoMetadata) || {};
await db()
.update(videos)
- .set({
+ .set({
metadata: {
...currentMetadata,
aiProcessing: false,
- generationError: error instanceof Error ? error.message : String(error)
- }
+ generationError:
+ error instanceof Error ? error.message : String(error),
+ },
})
.where(eq(videos.id, videoId));
}
} catch (updateError) {
- console.error(`[generateAiMetadata] Failed to reset processing flag:`, updateError);
+ console.error(
+ `[generateAiMetadata] Failed to reset processing flag:`,
+ updateError
+ );
}
}
}
diff --git a/apps/web/actions/videos/get-og-image.tsx b/apps/web/actions/videos/get-og-image.tsx
index cfae27374..cda5692f5 100644
--- a/apps/web/actions/videos/get-og-image.tsx
+++ b/apps/web/actions/videos/get-og-image.tsx
@@ -1,8 +1,5 @@
import { ImageResponse } from "next/og";
-import { GetObjectCommand } from "@aws-sdk/client-s3";
-import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { serverEnv } from "@cap/env";
+import { createBucketProvider } from "@/utils/s3";
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
@@ -38,9 +35,9 @@ export async function generateVideoOgImage(videoId: string) {
);
}
- const { video, bucket } = videoData;
+ const { video } = videoData;
- if (!video || !bucket || video.public === false) {
+ if (!video || video.public === false) {
return new ImageResponse(
(
<div
@@ -64,18 +61,13 @@ export async function generateVideoOgImage(videoId: string) {
);
}
- const [s3Client] = await createS3Client(bucket);
- const Bucket = await getS3Bucket(bucket as any);
+ const bucket = await createBucketProvider(videoData.bucket);
const screenshotKey = `${video.ownerId}/${video.id}/screenshot/screen-capture.jpg`;
let screenshotUrl = null;
try {
- screenshotUrl = await getSignedUrl(
- s3Client,
- new GetObjectCommand({ Bucket, Key: screenshotKey }),
- { expiresIn: 3600 }
- );
+ screenshotUrl = await bucket.getSignedObjectUrl(screenshotKey);
} catch (error) {
console.error("Error generating URL for screenshot:", error);
}
@@ -173,15 +165,8 @@ async function getData(videoId: string) {
if (!result) return;
- const defaultBucket = {
- name: serverEnv().CAP_AWS_BUCKET,
- region: serverEnv().CAP_AWS_REGION,
- accessKeyId: serverEnv().CAP_AWS_ACCESS_KEY,
- secretAccessKey: serverEnv().CAP_AWS_SECRET_KEY,
- };
-
return {
video: result.video,
- bucket: result.bucket || defaultBucket,
+ bucket: result.bucket,
};
}
diff --git a/apps/web/actions/videos/get-transcript.ts b/apps/web/actions/videos/get-transcript.ts
index dd6a68eef..70f5e0c8d 100644
--- a/apps/web/actions/videos/get-transcript.ts
+++ b/apps/web/actions/videos/get-transcript.ts
@@ -1,16 +1,14 @@
"use server";
-import { GetObjectCommand } from "@aws-sdk/client-s3";
import { getCurrentUser } from "@cap/database/auth/session";
import { videos, s3Buckets } from "@cap/database/schema";
import { db } from "@cap/database";
import { eq } from "drizzle-orm";
-import { createS3Client } from "@/utils/s3";
+import { createBucketProvider } from "@/utils/s3";
export async function getTranscript(
videoId: string
): Promise<{ success: boolean; content?: string; message: string }> {
-
const user = await getCurrentUser();
if (!videoId) {
@@ -38,7 +36,7 @@ export async function getTranscript(
return { success: false, message: "Video information is missing" };
}
- const { video, bucket } = result;
+ const { video } = result;
if (video.transcriptionStatus !== "COMPLETE") {
return {
@@ -47,27 +45,12 @@ export async function getTranscript(
};
}
- const awsRegion = video.awsRegion;
- const awsBucket = video.awsBucket;
-
- if (!awsRegion || !awsBucket) {
- return {
- success: false,
- message: "AWS region or bucket information is missing",
- };
- }
- const [s3Client] = await createS3Client(bucket);
+ const bucket = await createBucketProvider(result.bucket);
try {
const transcriptKey = `${video.ownerId}/${videoId}/transcription.vtt`;
- const getCommand = new GetObjectCommand({
- Bucket: awsBucket,
- Key: transcriptKey,
- });
-
- const response = await s3Client.send(getCommand);
- const vttContent = await response.Body?.transformToString();
+ const vttContent = await bucket.getObject(transcriptKey);
if (!vttContent) {
return { success: false, message: "Transcript file not found" };
@@ -82,11 +65,11 @@ export async function getTranscript(
console.error("[getTranscript] Error fetching transcript:", {
error: error instanceof Error ? error.message : error,
videoId,
- userId: user?.id
+ userId: user?.id,
});
return {
success: false,
message: "Failed to fetch transcript",
};
}
-}
\ No newline at end of file
+}
diff --git a/apps/web/actions/videos/transcribe.ts b/apps/web/actions/videos/transcribe.ts
index bcbb5f8cb..850d93b8b 100644
--- a/apps/web/actions/videos/transcribe.ts
+++ b/apps/web/actions/videos/transcribe.ts
@@ -4,7 +4,7 @@ import { createClient } from "@deepgram/sdk";
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
-import { createS3Client } from "@/utils/s3";
+import { createBucketProvider } from "@/utils/s3";
import { serverEnv } from "@cap/env";
import { generateAiMetadata } from "@/actions/videos/generate-ai-metadata";
@@ -50,22 +50,12 @@ export async function transcribeVideo(
return { success: false, message: "Video information is missing" };
}
- const { video, bucket } = result;
+ const { video } = result;
if (!video) {
return { success: false, message: "Video information is missing" };
}
- const awsRegion = video.awsRegion;
- const awsBucket = video.awsBucket;
-
- if (!awsRegion || !awsBucket) {
- return {
- success: false,
- message: "AWS region or bucket information is missing",
- };
- }
-
if (
video.transcriptionStatus === "COMPLETE" ||
video.transcriptionStatus === "PROCESSING"
@@ -81,18 +71,12 @@ export async function transcribeVideo(
.set({ transcriptionStatus: "PROCESSING" })
.where(eq(videos.id, videoId));
- const [s3Client] = await createS3Client(bucket);
+ const bucket = await createBucketProvider(result.bucket);
try {
const videoKey = `${userId}/${videoId}/result.mp4`;
- const videoUrl = await getSignedUrl(
- s3Client,
- new GetObjectCommand({
- Bucket: awsBucket,
- Key: videoKey,
- })
- );
+ const videoUrl = await bucket.getSignedObjectUrl(videoKey);
const transcription = await transcribeAudio(videoUrl);
@@ -100,33 +84,42 @@ export async function transcribeVideo(
throw new Error("Failed to transcribe audio");
}
- const uploadCommand = new PutObjectCommand({
- Bucket: awsBucket,
- Key: `${userId}/${videoId}/transcription.vtt`,
- Body: transcription,
- ContentType: "text/vtt",
- });
-
- await s3Client.send(uploadCommand);
+ await bucket.putObject(
+ `${userId}/${videoId}/transcription.vtt`,
+ transcription,
+ { contentType: "text/vtt" }
+ );
await db()
.update(videos)
.set({ transcriptionStatus: "COMPLETE" })
.where(eq(videos.id, videoId));
- console.log(`[transcribeVideo] Transcription completed for video ${videoId}`);
+ console.log(
+ `[transcribeVideo] Transcription completed for video ${videoId}`
+ );
if (aiGenerationEnabled) {
- console.log(`[transcribeVideo] AI generation enabled, triggering AI metadata generation for video ${videoId}`);
+ console.log(
+ `[transcribeVideo] AI generation enabled, triggering AI metadata generation for video ${videoId}`
+ );
try {
- generateAiMetadata(videoId, userId).catch(error => {
- console.error(`[transcribeVideo] Error generating AI metadata for video ${videoId}:`, error);
+ generateAiMetadata(videoId, userId).catch((error) => {
+ console.error(
+ `[transcribeVideo] Error generating AI metadata for video ${videoId}:`,
+ error
+ );
});
} catch (error) {
- console.error(`[transcribeVideo] Error starting AI metadata generation for video ${videoId}:`, error);
+ console.error(
+ `[transcribeVideo] Error starting AI metadata generation for video ${videoId}:`,
+ error
+ );
}
} else {
- console.log(`[transcribeVideo] AI generation disabled, skipping AI metadata generation for video ${videoId}`);
+ console.log(
+ `[transcribeVideo] AI generation disabled, skipping AI metadata generation for video ${videoId}`
+ );
}
return {
@@ -213,7 +206,9 @@ async function transcribeAudio(videoUrl: string): Promise<string> {
return "";
}
- console.log("[transcribeAudio] Transcription result received, formatting to WebVTT");
+ console.log(
+ "[transcribeAudio] Transcription result received, formatting to WebVTT"
+ );
const captions = formatToWebVTT(result);
console.log("[transcribeAudio] Transcription complete, returning captions");
diff --git a/apps/web/app/api/desktop/[...route]/video.ts b/apps/web/app/api/desktop/[...route]/video.ts
index fa16688b1..2ff332a77 100644
--- a/apps/web/app/api/desktop/[...route]/video.ts
+++ b/apps/web/app/api/desktop/[...route]/video.ts
@@ -1,5 +1,5 @@
import { dub } from "@/utils/dub";
-import { getS3Bucket, getS3Config } from "@/utils/s3";
+import { createBucketProvider, getS3Bucket, getS3Config } from "@/utils/s3";
import { db } from "@cap/database";
import { sendEmail } from "@cap/database/emails/config";
import { FirstShareableLink } from "@cap/database/emails/first-shareable-link";
@@ -48,24 +48,19 @@ app.get(
if (!isUpgraded && duration && duration > 300)
return c.json({ error: "upgrade_required" }, { status: 403 });
- const [bucket] = await db()
+ const [customBucket] = await db()
.select()
.from(s3Buckets)
.where(eq(s3Buckets.ownerId, user.id));
- console.log("User bucket:", bucket ? "found" : "not found");
+ console.log("User bucket:", customBucket ? "found" : "not found");
- const s3Config = await getS3Config(bucket);
- const bucketName = await getS3Bucket(bucket);
-
- console.log("S3 Config:", { region: s3Config.region, bucketName });
+ const bucket = await createBucketProvider(customBucket);
const date = new Date();
const formattedDate = `${date.getDate()} ${date.toLocaleString(
"default",
- {
- month: "long",
- }
+ { month: "long" }
)} ${date.getFullYear()}`;
if (videoId !== undefined) {
@@ -77,9 +72,10 @@ app.get(
if (video) {
return c.json({
id: video.id,
+ // All deprecated
user_id: user.id,
- aws_region: video.awsRegion,
- aws_bucket: video.awsBucket,
+ aws_region: "n/a",
+ aws_bucket: "n/a",
});
}
}
@@ -92,8 +88,8 @@ app.get(
name ??
`Cap ${isScreenshot ? "Screenshot" : "Recording"} - ${formattedDate}`,
ownerId: user.id,
- awsRegion: s3Config.region,
- awsBucket: bucketName,
+ awsRegion: "auto",
+ awsBucket: bucket.name,
source:
recordingMode === "hls"
? { type: "local" as const }
@@ -101,7 +97,7 @@ app.get(
? { type: "desktopMP4" as const }
: undefined,
isScreenshot,
- bucket: bucket?.id,
+ bucket: customBucket?.id,
};
await db().insert(videos).values(videoData);
@@ -158,9 +154,10 @@ app.get(
return c.json({
id: idToUse,
+ // All deprecated
user_id: user.id,
- aws_region: s3Config.region,
- aws_bucket: bucketName,
+ aws_region: "n/a",
+ aws_bucket: "n/a",
});
} catch (error) {
console.error("Error in video create endpoint:", error);
diff --git a/apps/web/app/api/playlist/route.ts b/apps/web/app/api/playlist/route.ts
index 5181e51dd..3bfe6b618 100644
--- a/apps/web/app/api/playlist/route.ts
+++ b/apps/web/app/api/playlist/route.ts
@@ -1,7 +1,6 @@
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
-import { getCurrentUser } from "@cap/database/auth/session";
import {
generateM3U8Playlist,
generateMasterPlaylist,
diff --git a/apps/web/app/api/screenshot/route.ts b/apps/web/app/api/screenshot/route.ts
index f2badabea..957e5532d 100644
--- a/apps/web/app/api/screenshot/route.ts
+++ b/apps/web/app/api/screenshot/route.ts
@@ -2,15 +2,9 @@ import { type NextRequest } from "next/server";
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import { eq } from "drizzle-orm";
-import {
- S3Client,
- ListObjectsV2Command,
- GetObjectCommand,
-} from "@aws-sdk/client-s3";
import { getCurrentUser } from "@cap/database/auth/session";
import { getHeaders } from "@/utils/helpers";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
+import { createBucketProvider } from "@/utils/s3";
import { S3_BUCKET_URL } from "@cap/utils";
import { serverEnv } from "@cap/env";
@@ -75,19 +69,14 @@ export async function GET(request: NextRequest) {
}
}
- const Bucket = await getS3Bucket(bucket);
+ const bucketProvider = await createBucketProvider(bucket);
const screenshotPrefix = `${userId}/${videoId}/`;
try {
- const [s3Client] = await createS3Client(bucket);
-
- const objectsCommand = new ListObjectsV2Command({
- Bucket,
- Prefix: screenshotPrefix,
+ const objects = await bucketProvider.listObjects({
+ prefix: screenshotPrefix,
});
- const objects = await s3Client.send(objectsCommand);
-
const screenshot = objects.Contents?.find((object) =>
object.Key?.endsWith(".png")
);
@@ -102,14 +91,7 @@ export async function GET(request: NextRequest) {
let screenshotUrl: string;
if (video.awsBucket !== serverEnv().CAP_AWS_BUCKET) {
- screenshotUrl = await getSignedUrl(
- s3Client,
- new GetObjectCommand({
- Bucket,
- Key: screenshot.Key,
- }),
- { expiresIn: 3600 }
- );
+ screenshotUrl = await bucketProvider.getSignedObjectUrl(screenshot.Key!);
} else {
screenshotUrl = `${S3_BUCKET_URL}/${screenshot.Key}`;
}
diff --git a/apps/web/app/api/thumbnail/route.ts b/apps/web/app/api/thumbnail/route.ts
index fb8978691..1dbfdc45d 100644
--- a/apps/web/app/api/thumbnail/route.ts
+++ b/apps/web/app/api/thumbnail/route.ts
@@ -1,11 +1,9 @@
import type { NextRequest } from "next/server";
-import { ListObjectsV2Command, GetObjectCommand } from "@aws-sdk/client-s3";
import { getHeaders } from "@/utils/helpers";
import { db } from "@cap/database";
import { eq } from "drizzle-orm";
import { s3Buckets, videos } from "@cap/database/schema";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
+import { createBucketProvider } from "@/utils/s3";
import { S3_BUCKET_URL } from "@cap/utils";
import { serverEnv } from "@cap/env";
@@ -73,16 +71,12 @@ export async function GET(request: NextRequest) {
});
}
- const Bucket = await getS3Bucket(result.bucket);
- const [s3ClientInstance] = await createS3Client(result.bucket);
+ const bucketProvider = await createBucketProvider(result.bucket);
try {
- const listCommand = new ListObjectsV2Command({
- Bucket,
- Prefix: prefix,
+ const listResponse = await bucketProvider.listObjects({
+ prefix: prefix,
});
-
- const listResponse = await s3ClientInstance.send(listCommand);
const contents = listResponse.Contents || [];
const thumbnailKey = contents.find((item: any) =>
@@ -102,14 +96,7 @@ export async function GET(request: NextRequest) {
);
}
- thumbnailUrl = await getSignedUrl(
- s3ClientInstance,
- new GetObjectCommand({
- Bucket,
- Key: thumbnailKey,
- }),
- { expiresIn: 3600 }
- );
+ thumbnailUrl = await bucketProvider.getSignedObjectUrl(thumbnailKey);
} catch (error) {
return new Response(
JSON.stringify({
diff --git a/apps/web/app/api/upload/[...route]/multipart.ts b/apps/web/app/api/upload/[...route]/multipart.ts
index 16d9ba5e6..8478fb77f 100644
--- a/apps/web/app/api/upload/[...route]/multipart.ts
+++ b/apps/web/app/api/upload/[...route]/multipart.ts
@@ -1,21 +1,13 @@
import { Hono } from "hono";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import {
- CompleteMultipartUploadCommand,
- CopyObjectCommand,
- CreateMultipartUploadCommand,
- HeadObjectCommand,
- UploadPartCommand,
-} from "@aws-sdk/client-s3";
+import { createBucketProvider } from "@/utils/s3";
import { db } from "@cap/database";
import { s3Buckets } from "@cap/database/schema";
import { eq } from "drizzle-orm";
import { zValidator } from "@hono/zod-validator";
import { z } from "zod";
-import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { serverEnv } from "@cap/env";
-import { handle } from "hono/vercel";
-import { withAuth, corsMiddleware } from "@/app/api/utils";
+import { withAuth } from "@/app/api/utils";
+import { parseVideoIdOrFileKey } from "../utils";
export const app = new Hono().use(withAuth);
@@ -23,24 +15,33 @@ app.post(
"/initiate",
zValidator(
"json",
- z.object({ fileKey: z.string(), contentType: z.string() })
+ z.object({ contentType: z.string() }).and(
+ z.union([
+ z.object({ videoId: z.string() }),
+ // deprecated
+ z.object({ fileKey: z.string() }),
+ ])
+ )
),
async (c) => {
- const { fileKey, contentType } = c.req.valid("json");
+ const { contentType, ...body } = c.req.valid("json");
const user = c.get("user");
+ const fileKey = parseVideoIdOrFileKey(user.id, {
+ ...body,
+ subpath: "result.mp4",
+ });
+
try {
try {
- const { s3Client, bucketName } = await getUserBucketWithClient(user.id);
+ const { bucket } = await getUserBucketWithClient(user.id);
const finalContentType = contentType || "video/mp4";
console.log(
- `Creating multipart upload in bucket: ${bucketName}, content-type: ${finalContentType}, key: ${fileKey}`
+ `Creating multipart upload in bucket: ${bucket.name}, content-type: ${finalContentType}, key: ${fileKey}`
);
- const command = new CreateMultipartUploadCommand({
- Bucket: bucketName,
- Key: fileKey,
+ const { UploadId } = await bucket.multipart.create(fileKey, {
ContentType: finalContentType,
Metadata: {
userId: user.id,
@@ -49,9 +50,6 @@ app.post(
CacheControl: "max-age=31536000",
});
- const result = await s3Client.send(command);
- const { UploadId } = result;
-
if (!UploadId) {
throw new Error("No UploadId returned from S3");
}
@@ -60,7 +58,7 @@ app.post(
`Successfully initiated multipart upload with ID: ${UploadId}`
);
console.log(
- `Upload details: Bucket=${bucketName}, Key=${fileKey}, ContentType=${finalContentType}`
+ `Upload details: Bucket=${bucket.name}, Key=${fileKey}, ContentType=${finalContentType}`
);
return c.json({ uploadId: UploadId });
@@ -89,36 +87,43 @@ app.post(
"/presign-part",
zValidator(
"json",
- z.object({
- fileKey: z.string(),
- uploadId: z.string(),
- partNumber: z.number(),
- md5Sum: z.string(),
- })
+ z
+ .object({
+ uploadId: z.string(),
+ partNumber: z.number(),
+ md5Sum: z.string(),
+ })
+ .and(
+ z.union([
+ z.object({ videoId: z.string() }),
+ // deprecated
+ z.object({ fileKey: z.string() }),
+ ])
+ )
),
async (c) => {
- const { fileKey, uploadId, partNumber, md5Sum } = c.req.valid("json");
+ const { uploadId, partNumber, md5Sum, ...body } = c.req.valid("json");
const user = c.get("user");
+ const fileKey = parseVideoIdOrFileKey(user.id, {
+ ...body,
+ subpath: "result.mp4",
+ });
+
try {
try {
- const { s3Client, bucketName } = await getUserBucketWithClient(user.id);
+ const { bucket } = await getUserBucketWithClient(user.id);
console.log(
`Getting presigned URL for part ${partNumber} of upload ${uploadId}`
);
- const command = new UploadPartCommand({
- Bucket: bucketName,
- Key: fileKey,
- UploadId: uploadId,
- PartNumber: partNumber,
- ContentMD5: md5Sum,
- });
-
- const presignedUrl = await getSignedUrl(s3Client, command, {
- expiresIn: 3600,
- });
+ const presignedUrl = await bucket.multipart.getPresignedUploadPartUrl(
+ fileKey,
+ uploadId,
+ partNumber,
+ { ContentMD5: md5Sum }
+ );
return c.json({ presignedUrl });
} catch (s3Error) {
@@ -146,25 +151,39 @@ app.post(
"/complete",
zValidator(
"json",
- z.object({
- fileKey: z.string(),
- uploadId: z.string(),
- parts: z.array(
- z.object({
- partNumber: z.number(),
- etag: z.string(),
- size: z.number(),
- })
- ),
- })
+ z
+ .object({
+ uploadId: z.string(),
+ parts: z.array(
+ z.object({
+ partNumber: z.number(),
+ etag: z.string(),
+ size: z.number(),
+ })
+ ),
+ })
+ .and(
+ z.union([
+ z.object({
+ // deprecated
+ fileKey: z.string(),
+ }),
+ z.object({ videoId: z.string() }),
+ ])
+ )
),
async (c) => {
- const { fileKey, uploadId, parts } = c.req.valid("json");
+ const { uploadId, parts, ...body } = c.req.valid("json");
const user = c.get("user");
+ const fileKey = parseVideoIdOrFileKey(user.id, {
+ ...body,
+ subpath: "result.mp4",
+ });
+
try {
try {
- const { s3Client, bucketName } = await getUserBucketWithClient(user.id);
+ const { bucket } = await getUserBucketWithClient(user.id);
console.log(
`Completing multipart upload ${uploadId} with ${parts.length} parts for key: ${fileKey}`
@@ -196,7 +215,7 @@ app.post(
"Sending to S3:",
JSON.stringify(
{
- Bucket: bucketName,
+ Bucket: bucket.name,
Key: fileKey,
UploadId: uploadId,
Parts: formattedParts,
@@ -206,17 +225,13 @@ app.post(
)
);
- const command = new CompleteMultipartUploadCommand({
- Bucket: bucketName,
- Key: fileKey,
- UploadId: uploadId,
+ const result = await bucket.multipart.complete(fileKey, uploadId, {
MultipartUpload: {
Parts: formattedParts,
},
});
try {
- const result = await s3Client.send(command);
console.log(
`Multipart upload completed successfully: ${
result.Location || "no location"
@@ -228,15 +243,16 @@ app.post(
console.log(
"Performing metadata fix by copying the object to itself..."
);
- const copyCommand = new CopyObjectCommand({
- Bucket: bucketName,
- CopySource: `${bucketName}/${fileKey}`,
- Key: fileKey,
- ContentType: "video/mp4",
- MetadataDirective: "REPLACE",
- });
- const copyResult = await s3Client.send(copyCommand);
+ const copyResult = await bucket.copyObject(
+ `${bucket.name}/${fileKey}`,
+ fileKey,
+ {
+ ContentType: "video/mp4",
+ MetadataDirective: "REPLACE",
+ }
+ );
+
console.log("Copy for metadata fix successful:", copyResult);
} catch (copyError) {
console.error(
@@ -246,12 +262,7 @@ app.post(
}
try {
- const headCommand = new HeadObjectCommand({
- Bucket: bucketName,
- Key: fileKey,
- });
-
- const headResult = await s3Client.send(headCommand);
+ const headResult = await bucket.headObject(fileKey);
console.log(
`Object verification successful: ContentType=${headResult.ContentType}, ContentLength=${headResult.ContentLength}`
);
@@ -279,7 +290,6 @@ app.post(
location: result.Location,
success: true,
fileKey,
- bucketName,
});
} catch (completeError) {
console.error("Failed to complete multipart upload:", completeError);
@@ -319,35 +329,20 @@ app.post(
);
async function getUserBucketWithClient(userId: string) {
- const [bucket] = await db()
+ const [customBucket] = await db()
.select()
.from(s3Buckets)
.where(eq(s3Buckets.ownerId, userId));
console.log("S3 bucket configuration:", {
- hasEndpoint: !!bucket?.endpoint,
- endpoint: bucket?.endpoint || "N/A",
- region: bucket?.region || "N/A",
- hasAccessKey: !!bucket?.accessKeyId,
- hasSecretKey: !!bucket?.secretAccessKey,
+ hasEndpoint: !!customBucket?.endpoint,
+ endpoint: customBucket?.endpoint || "N/A",
+ region: customBucket?.region || "N/A",
+ hasAccessKey: !!customBucket?.accessKeyId,
+ hasSecretKey: !!customBucket?.secretAccessKey,
});
- const initialS3Config = bucket
- ? {
- endpoint: bucket.endpoint || undefined,
- region: bucket.region,
- accessKeyId: bucket.accessKeyId,
- secretAccessKey: bucket.secretAccessKey,
- forcePathStyle: true,
- }
- : null;
-
- if (!initialS3Config?.endpoint && !initialS3Config?.region) {
- console.log("Using default S3 configuration");
- }
-
- const [s3Client, s3Config] = await createS3Client(initialS3Config);
- const bucketName = await getS3Bucket(bucket);
+ const bucket = await createBucketProvider(customBucket);
- return { s3Client, s3Config, bucketName };
+ return { bucket };
}
diff --git a/apps/web/app/api/upload/[...route]/signed.ts b/apps/web/app/api/upload/[...route]/signed.ts
index 0846370c6..3d23c3c9d 100644
--- a/apps/web/app/api/upload/[...route]/signed.ts
+++ b/apps/web/app/api/upload/[...route]/signed.ts
@@ -1,8 +1,4 @@
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import {
- createPresignedPost,
- type PresignedPost,
-} from "@aws-sdk/s3-presigned-post";
+import { createBucketProvider } from "@/utils/s3";
import {
CloudFrontClient,
CreateInvalidationCommand,
@@ -16,8 +12,7 @@ import { zValidator } from "@hono/zod-validator";
import { z } from "zod";
import { withAuth } from "../../utils";
-import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
-import { PutObjectCommand } from "@aws-sdk/client-s3";
+import { parseVideoIdOrFileKey } from "../utils";
export const app = new Hono().use(withAuth);
@@ -25,47 +20,56 @@ app.post(
"/",
zValidator(
"json",
- z.object({
- fileKey: z.string(),
- duration: z.string().optional(),
- bandwidth: z.string().optional(),
- resolution: z.string().optional(),
- videoCodec: z.string().optional(),
- audioCodec: z.string().optional(),
- method: z.union([z.literal("post"), z.literal("put")]).default("post"),
- })
+ z
+ .object({
+ duration: z.string().optional(),
+ bandwidth: z.string().optional(),
+ resolution: z.string().optional(),
+ videoCodec: z.string().optional(),
+ audioCodec: z.string().optional(),
+ method: z.union([z.literal("post"), z.literal("put")]).default("post"),
+ })
+ .and(
+ z.union([
+ // DEPRECATED
+ z.object({ fileKey: z.string() }),
+ z.object({ videoId: z.string(), subpath: z.string() }),
+ ])
+ )
),
async (c) => {
const user = c.get("user");
const {
- fileKey,
duration,
bandwidth,
resolution,
videoCodec,
audioCodec,
method,
+ ...body
} = c.req.valid("json");
+ const fileKey = parseVideoIdOrFileKey(user.id, body);
+
try {
- const [bucket] = await db()
+ const [customBucket] = await db()
.select()
.from(s3Buckets)
.where(eq(s3Buckets.ownerId, user.id));
- const s3Config = bucket
+ const s3Config = customBucket
? {
- endpoint: bucket.endpoint || undefined,
- region: bucket.region,
- accessKeyId: bucket.accessKeyId,
- secretAccessKey: bucket.secretAccessKey,
+ endpoint: customBucket.endpoint || undefined,
+ region: customBucket.region,
+ accessKeyId: customBucket.accessKeyId,
+ secretAccessKey: customBucket.secretAccessKey,
}
: null;
if (
- !bucket ||
+ !customBucket ||
!s3Config ||
- bucket.bucketName !== serverEnv().CAP_AWS_BUCKET
+ customBucket.bucketName !== serverEnv().CAP_AWS_BUCKET
) {
const distributionId = serverEnv().CAP_CLOUDFRONT_DISTRIBUTION_ID;
if (distributionId) {
@@ -101,15 +105,6 @@ app.post(
}
}
- console.log("Creating S3 client with config:", {
- hasEndpoint: !!s3Config?.endpoint,
- hasRegion: !!s3Config?.region,
- hasAccessKey: !!s3Config?.accessKeyId,
- hasSecretKey: !!s3Config?.secretAccessKey,
- });
-
- const [s3Client] = await createS3Client(s3Config);
-
const contentType = fileKey.endsWith(".aac")
? "audio/aac"
: fileKey.endsWith(".webm")
@@ -122,7 +117,7 @@ app.post(
? "application/x-mpegURL"
: "video/mp2t";
- const bucketName = await getS3Bucket(bucket);
+ const bucket = await createBucketProvider(customBucket);
let data;
if (method === "post") {
@@ -136,18 +131,11 @@ app.post(
"x-amz-meta-audiocodec": audioCodec ?? "",
};
- data = await createPresignedPost(s3Client, {
- Bucket: bucketName,
- Key: fileKey,
- Fields,
- Expires: 1800,
- });
+ data = bucket.getPresignedPostUrl(fileKey, { Fields, Expires: 1800 });
} else if (method === "put") {
- const presignedUrl = await getSignedUrl(
- s3Client,
- new PutObjectCommand({
- Bucket: bucketName,
- Key: fileKey,
+ const presignedUrl = await bucket.getPresignedPutUrl(
+ fileKey,
+ {
ContentType: contentType,
Metadata: {
userid: user.id,
@@ -157,13 +145,12 @@ app.post(
videocodec: videoCodec ?? "",
audiocodec: audioCodec ?? "",
},
- }),
+ },
{ expiresIn: 1800 }
);
data = { url: presignedUrl, fields: {} };
}
- console.log({ data });
console.log("Presigned URL created successfully");
diff --git a/apps/web/app/api/upload/utils.ts b/apps/web/app/api/upload/utils.ts
new file mode 100644
index 000000000..52ea58562
--- /dev/null
+++ b/apps/web/app/api/upload/utils.ts
@@ -0,0 +1,24 @@
+export function parseVideoIdOrFileKey(
+ userId: string,
+ input:
+ | { videoId: string; subpath: string }
+ | {
+ // deprecated
+ fileKey: string;
+ }
+) {
+ let videoId;
+ let subpath;
+
+ if ("fileKey" in input) {
+ const [_, _videoId, ...subpathParts] = input.fileKey.split("/");
+ if (!_videoId) throw new Error("Invalid fileKey");
+ videoId = _videoId;
+ subpath = subpathParts.join("/");
+ } else {
+ videoId = input.videoId;
+ subpath = input.subpath;
+ }
+
+ return `${userId}/${videoId}/${subpath}`;
+}
diff --git a/apps/web/app/api/utils.ts b/apps/web/app/api/utils.ts
index e33069c7c..8923a911b 100644
--- a/apps/web/app/api/utils.ts
+++ b/apps/web/app/api/utils.ts
@@ -57,9 +57,7 @@ export const withAuth = createMiddleware<{
user: NonNullable<Awaited<ReturnType<typeof getCurrentUser>>>;
};
}>(async (c, next) => {
- console.log("withAuth", c.req);
const auth = await getAuth(c);
- console.log("withAuth", { auth });
if (!auth) return c.text("User not authenticated", 401);
c.set("user", auth.user);
diff --git a/apps/web/app/api/video/delete/route.ts b/apps/web/app/api/video/delete/route.ts
index 49e84ee62..108574f3d 100644
--- a/apps/web/app/api/video/delete/route.ts
+++ b/apps/web/app/api/video/delete/route.ts
@@ -3,13 +3,8 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { s3Buckets, videos } from "@cap/database/schema";
import { db } from "@cap/database";
import { and, eq } from "drizzle-orm";
-import {
- DeleteObjectsCommand,
- ListObjectsV2Command,
- S3Client,
-} from "@aws-sdk/client-s3";
import { getHeaders } from "@/utils/helpers";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
+import { createBucketProvider } from "@/utils/s3";
export async function DELETE(request: NextRequest) {
const user = await getCurrentUser();
@@ -55,28 +50,19 @@ export async function DELETE(request: NextRequest) {
.delete(videos)
.where(and(eq(videos.id, videoId), eq(videos.ownerId, userId)));
- const [s3Client] = await createS3Client(result.bucket);
- const Bucket = await getS3Bucket(result.bucket);
+ const bucketProvider = await createBucketProvider(result.bucket);
const prefix = `${userId}/${videoId}/`;
- const listObjectsCommand = new ListObjectsV2Command({
- Bucket,
- Prefix: prefix,
+ const listedObjects = await bucketProvider.listObjects({
+ prefix: prefix,
});
- const listedObjects = await s3Client.send(listObjectsCommand);
-
if (listedObjects.Contents?.length) {
- const deleteObjectsCommand = new DeleteObjectsCommand({
- Bucket,
- Delete: {
- Objects: listedObjects.Contents.map((content: any) => ({
- Key: content.Key,
- })),
- },
- });
-
- await s3Client.send(deleteObjectsCommand);
+ await bucketProvider.deleteObjects(
+ listedObjects.Contents.map((content) => ({
+ Key: content.Key,
+ }))
+ );
}
return Response.json(true, {
diff --git a/apps/web/app/s/[videoId]/_components/MP4VideoPlayer.tsx b/apps/web/app/s/[videoId]/_components/MP4VideoPlayer.tsx
index d3d8ceee1..e05e475db 100644
--- a/apps/web/app/s/[videoId]/_components/MP4VideoPlayer.tsx
+++ b/apps/web/app/s/[videoId]/_components/MP4VideoPlayer.tsx
@@ -148,12 +148,6 @@ export const MP4VideoPlayer = memo(
}
};
- const handleLoadedMetadata = () => {
- if (videoRef.current) {
- videoRef.current.dispatchEvent(new Event("loadedmetadata"));
- }
- };
-
const handleError = (e: ErrorEvent) => {
console.error("Video loading error:", e);
if (!isLoaded && !hasError) {
@@ -171,10 +165,13 @@ export const MP4VideoPlayer = memo(
};
video.addEventListener("loadeddata", handleLoadedData);
- video.addEventListener("loadedmetadata", handleLoadedMetadata);
video.addEventListener("error", handleError as EventListener);
video.addEventListener("canplay", handleCanPlay);
+ if (video.readyState === 4) {
+ handleLoadedData();
+ }
+
if (!isLoaded && !hasError && retryCount.current === 0) {
const initialTimeout = setTimeout(() => {
if (!isLoaded && !hasError) {
@@ -188,7 +185,6 @@ export const MP4VideoPlayer = memo(
return () => {
clearTimeout(initialTimeout);
video.removeEventListener("loadeddata", handleLoadedData);
- video.removeEventListener("loadedmetadata", handleLoadedMetadata);
video.removeEventListener("error", handleError as EventListener);
video.removeEventListener("canplay", handleCanPlay);
if (retryTimeout.current) {
@@ -199,7 +195,6 @@ export const MP4VideoPlayer = memo(
return () => {
video.removeEventListener("loadeddata", handleLoadedData);
- video.removeEventListener("loadedmetadata", handleLoadedMetadata);
video.removeEventListener("error", handleError as EventListener);
video.removeEventListener("canplay", handleCanPlay);
if (retryTimeout.current) {
diff --git a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
index f0f0fc2af..bf750ed04 100644
--- a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
+++ b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
@@ -1568,7 +1568,8 @@ function CommentIndicators(props: {
className?: string;
comments: MaybePromise<CommentWithAuthor[]>;
}) {
- const comments = use(props.comments);
+ const comments =
+ props.comments instanceof Promise ? use(props.comments) : props.comments;
return (
<div className={props.className}>
diff --git a/apps/web/components/forms/server.ts b/apps/web/components/forms/server.ts
index 0592e5bc4..169c7091c 100644
--- a/apps/web/components/forms/server.ts
+++ b/apps/web/components/forms/server.ts
@@ -3,12 +3,15 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
-import { organizationMembers, organizations, users } from "@cap/database/schema";
+import {
+ organizationMembers,
+ organizations,
+ users,
+} from "@cap/database/schema";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
-import { createS3Client, getS3Bucket } from "@/utils/s3";
-import { createPresignedPost } from "@aws-sdk/s3-presigned-post";
+import { createBucketProvider } from "@/utils/s3";
import { serverEnv } from "@cap/env";
export async function createOrganization(formData: FormData) {
@@ -16,23 +19,28 @@ export async function createOrganization(formData: FormData) {
if (!user) throw new Error("Unauthorized");
// Extract the name from the FormData
- const name = formData.get('name') as string;
+ const name = formData.get("name") as string;
if (!name) throw new Error("Organization name is required");
const organizationId = nanoId();
-
+
// Create the organization first
- const orgValues: { id: string; ownerId: string; name: string; iconUrl?: string } = {
+ const orgValues: {
+ id: string;
+ ownerId: string;
+ name: string;
+ iconUrl?: string;
+ } = {
id: organizationId,
ownerId: user.id,
name: name,
};
// Check if an icon file was uploaded
- const iconFile = formData.get('icon') as File;
+ const iconFile = formData.get("icon") as File;
if (iconFile) {
// Validate file type
- if (!iconFile.type.startsWith('image/')) {
+ if (!iconFile.type.startsWith("image/")) {
throw new Error("File must be an image");
}
@@ -42,40 +50,16 @@ export async function createOrganization(formData: FormData) {
}
// Create a unique file key
- const fileExtension = iconFile.name.split('.').pop();
+ const fileExtension = iconFile.name.split(".").pop();
const fileKey = `organizations/${organizationId}/icon-${Date.now()}.${fileExtension}`;
try {
- // Get S3 client
- const [s3Client] = await createS3Client();
- const bucketName = await getS3Bucket();
-
- // Create presigned post
- const presignedPostData = await createPresignedPost(s3Client, {
- Bucket: bucketName,
- Key: fileKey,
- Fields: {
- 'Content-Type': iconFile.type,
- },
- Expires: 600, // 10 minutes
- });
-
- // Upload file to S3
- const formDataForS3 = new FormData();
- Object.entries(presignedPostData.fields).forEach(([key, value]) => {
- formDataForS3.append(key, value as string);
- });
- formDataForS3.append('file', iconFile);
+ const bucket = await createBucketProvider();
- const uploadResponse = await fetch(presignedPostData.url, {
- method: 'POST',
- body: formDataForS3,
+ await bucket.putObject(fileKey, await iconFile.bytes(), {
+ contentType: iconFile.type,
});
- if (!uploadResponse.ok) {
- throw new Error("Failed to upload file to S3");
- }
-
// Construct the icon URL
let iconUrl;
if (serverEnv().CAP_AWS_BUCKET_URL) {
@@ -83,10 +67,12 @@ export async function createOrganization(formData: FormData) {
iconUrl = `${serverEnv().CAP_AWS_BUCKET_URL}/${fileKey}`;
} else if (serverEnv().CAP_AWS_ENDPOINT) {
// For custom endpoints like MinIO
- iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucketName}/${fileKey}`;
+ iconUrl = `${serverEnv().CAP_AWS_ENDPOINT}/${bucket.name}/${fileKey}`;
} else {
// Default AWS S3 URL format
- iconUrl = `https://${bucketName}.s3.${serverEnv().CAP_AWS_REGION || 'us-east-1'}.amazonaws.com/${fileKey}`;
+ iconUrl = `https://${bucket.name}.s3.${
+ serverEnv().CAP_AWS_REGION || "us-east-1"
+ }.amazonaws.com/${fileKey}`;
}
// Add the icon URL to the organization values
diff --git a/apps/web/lib/sanitizeFile.ts b/apps/web/lib/sanitizeFile.ts
new file mode 100644
index 000000000..ac0af027b
--- /dev/null
+++ b/apps/web/lib/sanitizeFile.ts
@@ -0,0 +1,17 @@
+import DOMPurify from "dompurify";
+import { JSDOM } from "jsdom";
+
+export async function sanitizeFile(file: File) {
+ if (file.type === "image/svg+xml") {
+ const dom = new JSDOM(await file.text(), { contentType: "image/svg+xml" });
+ const purify = DOMPurify(dom.window);
+ const sanitizedSvg = purify.sanitize(
+ dom.window.document.documentElement.outerHTML,
+ { USE_PROFILES: { svg: true, svgFilters: true } }
+ );
+
+ return new File([sanitizedSvg], file.name, { type: file.type });
+ }
+
+ return file;
+}
diff --git a/apps/web/package.json b/apps/web/package.json
index fd087dfad..c5d624306 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -102,6 +102,7 @@
"zod": "^3.24.4"
},
"devDependencies": {
+ "@smithy/types": "^4.3.1",
"@types/file-saver": "^2.0.7",
"@types/jsdom": "^21.1.7",
"@types/lodash": "^4.17.5",
diff --git a/apps/web/utils/s3.ts b/apps/web/utils/s3.ts
index be1541a0c..e9a66c239 100644
--- a/apps/web/utils/s3.ts
+++ b/apps/web/utils/s3.ts
@@ -1,10 +1,30 @@
import {
+ CompleteMultipartUploadCommand,
+ CompleteMultipartUploadCommandInput,
+ CompleteMultipartUploadOutput,
+ CopyObjectCommand,
+ CopyObjectCommandInput,
+ CopyObjectCommandOutput,
+ CreateMultipartUploadCommand,
+ CreateMultipartUploadCommandInput,
+ CreateMultipartUploadOutput,
+ DeleteObjectCommand,
+ DeleteObjectCommandOutput,
+ DeleteObjectsCommand,
+ DeleteObjectsCommandOutput,
GetObjectCommand,
HeadObjectCommand,
HeadObjectOutput,
ListObjectsV2Command,
ListObjectsV2Output,
+ ObjectIdentifier,
+ PutObjectCommand,
+ PutObjectCommandInput,
+ PutObjectCommandOutput,
+ PutObjectRequest,
S3Client,
+ UploadPartCommand,
+ UploadPartCommandInput,
} from "@aws-sdk/client-s3";
import type { s3Buckets } from "@cap/database/schema";
import type { InferSelectModel } from "drizzle-orm";
@@ -13,6 +33,15 @@ import { serverEnv } from "@cap/env";
import * as S3Presigner from "@aws-sdk/s3-request-presigner";
import * as CloudFrontPresigner from "@aws-sdk/cloudfront-signer";
import { S3_BUCKET_URL } from "@cap/utils";
+import {
+ RequestPresigningArguments,
+ StreamingBlobPayloadInputTypes,
+} from "@smithy/types";
+import {
+ createPresignedPost,
+ PresignedPost,
+ PresignedPostOptions,
+} from "@aws-sdk/s3-presigned-post";
type S3Config = {
endpoint?: string | null;
@@ -34,10 +63,12 @@ async function tryDecrypt(
}
}
-export async function getS3Config(config?: S3Config) {
+export async function getS3Config(config?: S3Config, internal = false) {
if (!config) {
return {
- endpoint: serverEnv().CAP_AWS_ENDPOINT,
+ endpoint: internal
+ ? serverEnv().S3_INTERNAL_ENDPOINT ?? serverEnv().CAP_AWS_ENDPOINT
+ : serverEnv().S3_PUBLIC_ENDPOINT ?? serverEnv().CAP_AWS_ENDPOINT,
region: serverEnv().CAP_AWS_REGION,
credentials: {
accessKeyId: serverEnv().CAP_AWS_ACCESS_KEY ?? "",
@@ -93,8 +124,8 @@ export async function getS3Bucket(
);
}
-export async function createS3Client(config?: S3Config) {
- const s3Config = await getS3Config(config);
+export async function createS3Client(config?: S3Config, internal = false) {
+ const s3Config = await getS3Config(config, internal);
const isLocalOrMinio =
s3Config.endpoint?.includes("localhost") ||
s3Config.endpoint?.includes("127.0.0.1");
@@ -109,6 +140,7 @@ export async function createS3Client(config?: S3Config) {
}
interface S3BucketProvider {
+ name: string;
getSignedObjectUrl(key: string): Promise<string>;
getObject(key: string): Promise<string | undefined>;
listObjects(config?: {
@@ -116,10 +148,54 @@ interface S3BucketProvider {
maxKeys?: number;
}): Promise<ListObjectsV2Output>;
headObject(key: string): Promise<HeadObjectOutput>;
+ putObject(
+ key: string,
+ body: StreamingBlobPayloadInputTypes,
+ fields?: { contentType?: string }
+ ): Promise<PutObjectCommandOutput>;
+ copyObject(
+ source: string,
+ key: string,
+ args?: Omit<CopyObjectCommandInput, "Bucket" | "CopySource" | "Key">
+ ): Promise<CopyObjectCommandOutput>;
+ deleteObject(key: string): Promise<DeleteObjectCommandOutput>;
+ deleteObjects(keys: ObjectIdentifier[]): Promise<DeleteObjectsCommandOutput>;
+ getPresignedPutUrl(
+ key: string,
+ args?: Omit<PutObjectRequest, "Key" | "Bucket">,
+ signingArgs?: RequestPresigningArguments
+ ): Promise<string>;
+ getPresignedPostUrl(
+ key: string,
+ args: Omit<PresignedPostOptions, "Bucket" | "Key">
+ ): Promise<PresignedPost>;
+ multipart: {
+ create(
+ key: string,
+ args?: Omit<CreateMultipartUploadCommandInput, "Bucket" | "Key">
+ ): Promise<CreateMultipartUploadOutput>;
+ getPresignedUploadPartUrl(
+ key: string,
+ uploadId: string,
+ partNumber: number,
+ args?: Omit<
+ UploadPartCommandInput,
+ "Key" | "Bucket" | "PartNumber" | "UploadId"
+ >
+ ): Promise<string>;
+ complete(
+ key: string,
+ uploadId: string,
+ args?: Omit<
+ CompleteMultipartUploadCommandInput,
+ "Key" | "Bucket" | "UploadId"
+ >
+ ): Promise<CompleteMultipartUploadOutput>;
+ };
}
function createCloudFrontProvider(config: {
- s3: S3Client;
+ s3: (internal: boolean) => Promise<S3Client>;
bucket: string;
keyPairId: string;
privateKey: string;
@@ -152,36 +228,141 @@ function createCloudFrontProvider(config: {
};
}
-function createS3Provider(client: S3Client, bucket: string): S3BucketProvider {
+function createS3Provider(
+ getClient: (internal: boolean) => Promise<S3Client>,
+ bucket: string
+): S3BucketProvider {
return {
- getSignedObjectUrl(key: string) {
+ name: bucket,
+ async getSignedObjectUrl(key: string) {
return S3Presigner.getSignedUrl(
- client,
+ await getClient(false),
new GetObjectCommand({ Bucket: bucket, Key: key }),
{ expiresIn: 3600 }
);
},
async getObject(key: string, format = "string") {
- const resp = await client.send(
- new GetObjectCommand({ Bucket: bucket, Key: key })
+ const resp = await getClient(true).then((c) =>
+ c.send(new GetObjectCommand({ Bucket: bucket, Key: key }))
);
if (format === "string") {
return await resp.Body?.transformToString();
}
},
async listObjects(config) {
- return await client.send(
- new ListObjectsV2Command({
- Bucket: bucket,
- Prefix: config?.prefix,
- MaxKeys: config?.maxKeys,
- })
+ return await getClient(true).then((c) =>
+ c.send(
+ new ListObjectsV2Command({
+ Bucket: bucket,
+ Prefix: config?.prefix,
+ MaxKeys: config?.maxKeys,
+ })
+ )
);
},
- async headObject(key) {
- return await client.send(
- new HeadObjectCommand({ Bucket: bucket, Key: key })
- );
+ headObject: (key) =>
+ getClient(true).then((client) =>
+ client.send(new HeadObjectCommand({ Bucket: bucket, Key: key }))
+ ),
+ putObject: (key, body, fields) =>
+ getClient(true).then((client) =>
+ client.send(
+ new PutObjectCommand({
+ Bucket: bucket,
+ Key: key,
+ Body: body,
+ ContentType: fields?.contentType,
+ })
+ )
+ ),
+ copyObject: (source, key, args) =>
+ getClient(true).then((client) =>
+ client.send(
+ new CopyObjectCommand({
+ Bucket: bucket,
+ CopySource: source,
+ Key: key,
+ ...args,
+ })
+ )
+ ),
+ deleteObject: (key) =>
+ getClient(true).then((client) =>
+ client.send(new DeleteObjectCommand({ Bucket: bucket, Key: key }))
+ ),
+ deleteObjects: (objects: ObjectIdentifier[]) =>
+ getClient(true).then((client) =>
+ client.send(
+ new DeleteObjectsCommand({
+ Bucket: bucket,
+ Delete: {
+ Objects: objects,
+ },
+ })
+ )
+ ),
+ getPresignedPutUrl: (key: string, args, signingArgs) =>
+ getClient(false).then((client) =>
+ S3Presigner.getSignedUrl(
+ client,
+ new PutObjectCommand({ Bucket: bucket, Key: key, ...args }),
+ signingArgs
+ )
+ ),
+ getPresignedPostUrl: (
+ key: string,
+ args: Omit<PresignedPostOptions, "Bucket" | "Key">
+ ) =>
+ getClient(false).then((client) =>
+ createPresignedPost(client, {
+ ...args,
+ Bucket: bucket,
+ Key: key,
+ })
+ ),
+ multipart: {
+ create: (key, args) =>
+ getClient(true).then((client) =>
+ client.send(
+ new CreateMultipartUploadCommand({
+ ...args,
+ Bucket: bucket,
+ Key: key,
+ })
+ )
+ ),
+ getPresignedUploadPartUrl: (key, uploadId, partNumber, args) => {
+ console.log({
+ ...args,
+ Bucket: bucket,
+ Key: key,
+ UploadId: uploadId,
+ PartNumber: partNumber,
+ });
+ return getClient(false).then((client) =>
+ S3Presigner.getSignedUrl(
+ client,
+ new UploadPartCommand({
+ ...args,
+ Bucket: bucket,
+ Key: key,
+ UploadId: uploadId,
+ PartNumber: partNumber,
+ })
+ )
+ );
+ },
+ complete: (key, uploadId, args) =>
+ getClient(true).then((client) =>
+ client.send(
+ new CompleteMultipartUploadCommand({
+ Bucket: bucket,
+ Key: key,
+ UploadId: uploadId,
+ ...args,
+ })
+ )
+ ),
},
};
}
@@ -190,7 +371,8 @@ export async function createBucketProvider(
customBucket?: InferSelectModel<typeof s3Buckets> | null
) {
const bucket = await getS3Bucket(customBucket);
- const [s3Client] = await createS3Client(customBucket);
+ const getClient = (internal: boolean) =>
+ createS3Client(customBucket, internal).then((v) => v[0]);
if (!customBucket && serverEnv().CAP_CLOUDFRONT_DISTRIBUTION_ID) {
const keyPairId = serverEnv().CLOUDFRONT_KEYPAIR_ID;
@@ -200,12 +382,12 @@ export async function createBucketProvider(
throw new Error("Missing CloudFront keypair ID or private key");
return createCloudFrontProvider({
- s3: s3Client,
+ s3: getClient,
bucket,
keyPairId,
privateKey,
});
}
- return createS3Provider(s3Client, bucket);
+ return createS3Provider(getClient, bucket);
}
diff --git a/packages/database/schema.ts b/packages/database/schema.ts
index 63559193a..ccee6f775 100644
--- a/packages/database/schema.ts
+++ b/packages/database/schema.ts
@@ -197,6 +197,7 @@ export const videos = mysqlTable(
id: nanoId("id").notNull().primaryKey().unique(),
ownerId: nanoId("ownerId").notNull(),
name: varchar("name", { length: 255 }).notNull().default("My Video"),
+ // DEPRECATED
awsRegion: varchar("awsRegion", { length: 255 }),
awsBucket: varchar("awsBucket", { length: 255 }),
bucket: nanoIdNullable("bucket"),
diff --git a/packages/env/server.ts b/packages/env/server.ts
index 2be2c3f8d..14fee6109 100644
--- a/packages/env/server.ts
+++ b/packages/env/server.ts
@@ -60,6 +60,8 @@ function createServerEnv() {
POSTHOG_PERSONAL_API_KEY: z.string().optional(),
CLOUDFRONT_KEYPAIR_ID: z.string().optional(),
CLOUDFRONT_KEYPAIR_PRIVATE_KEY: z.string().optional(),
+ S3_PUBLIC_ENDPOINT: z.string().optional(),
+ S3_INTERNAL_ENDPOINT: z.string().optional(),
},
experimental__runtimeEnv: {
...process.env,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2e10256d0..2f30e6855 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -667,6 +667,9 @@ importers:
specifier: ^3.24.4
version: 3.25.20
devDependencies:
+ '@smithy/types':
+ specifier: ^4.3.1
+ version: 4.3.1
'@types/file-saver':
specifier: ^2.0.7
version: 2.0.7
@@ -5059,10 +5062,6 @@ packages:
resolution: {integrity: sha512-3AnHfsMdq9Wg7+3BeR1HuLWI9+DMA/SoHVpCWq6xSsa52ikNd6nlF/wFzdpHyGtVa+Aji6lMgvwOF4sGcVA7SA==}
engines: {node: '>=18.0.0'}
- '@smithy/[email protected]':
- resolution: {integrity: sha512-7eMk09zQKCO+E/ivsjQv+fDlOupcFUCSC/L2YUPgwhvowVGWbPQHjEFcmjt7QQ4ra5lyowS92SV53Zc6XD4+fg==}
- engines: {node: '>=18.0.0'}
-
'@smithy/[email protected]':
resolution: {integrity: sha512-UqKOQBL2x6+HWl3P+3QqFD4ncKq0I8Nuz9QItGv5WuKuMHuuwlhvqcZCoXGfc+P1QmfJE7VieykoYYmrOoFJxA==}
engines: {node: '>=18.0.0'}
@@ -13484,7 +13483,7 @@ snapshots:
'@smithy/node-http-handler': 4.0.4
'@smithy/protocol-http': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/url-parser': 4.0.2
'@smithy/util-base64': 4.0.0
'@smithy/util-body-length-browser': 4.0.0
@@ -13530,7 +13529,7 @@ snapshots:
'@smithy/node-http-handler': 4.0.4
'@smithy/protocol-http': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/url-parser': 4.0.2
'@smithy/util-base64': 4.0.0
'@smithy/util-body-length-browser': 4.0.0
@@ -13591,7 +13590,7 @@ snapshots:
'@smithy/node-http-handler': 4.0.4
'@smithy/protocol-http': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/url-parser': 4.0.2
'@smithy/util-base64': 4.0.0
'@smithy/util-body-length-browser': 4.0.0
@@ -13636,7 +13635,7 @@ snapshots:
'@smithy/node-http-handler': 4.0.4
'@smithy/protocol-http': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/url-parser': 4.0.2
'@smithy/util-base64': 4.0.0
'@smithy/util-body-length-browser': 4.0.0
@@ -13665,7 +13664,7 @@ snapshots:
'@smithy/protocol-http': 5.1.0
'@smithy/signature-v4': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-middleware': 4.0.2
fast-xml-parser: 4.4.1
tslib: 2.8.1
@@ -13675,7 +13674,7 @@ snapshots:
'@aws-sdk/core': 3.804.0
'@aws-sdk/types': 3.804.0
'@smithy/property-provider': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13687,7 +13686,7 @@ snapshots:
'@smithy/property-provider': 4.0.2
'@smithy/protocol-http': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-stream': 4.2.0
tslib: 2.8.1
@@ -13704,7 +13703,7 @@ snapshots:
'@smithy/credential-provider-imds': 4.0.2
'@smithy/property-provider': 4.0.2
'@smithy/shared-ini-file-loader': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
transitivePeerDependencies:
- aws-crt
@@ -13721,7 +13720,7 @@ snapshots:
'@smithy/credential-provider-imds': 4.0.2
'@smithy/property-provider': 4.0.2
'@smithy/shared-ini-file-loader': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
transitivePeerDependencies:
- aws-crt
@@ -13732,7 +13731,7 @@ snapshots:
'@aws-sdk/types': 3.804.0
'@smithy/property-provider': 4.0.2
'@smithy/shared-ini-file-loader': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13743,7 +13742,7 @@ snapshots:
'@aws-sdk/types': 3.804.0
'@smithy/property-provider': 4.0.2
'@smithy/shared-ini-file-loader': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
transitivePeerDependencies:
- aws-crt
@@ -13754,7 +13753,7 @@ snapshots:
'@aws-sdk/nested-clients': 3.804.0
'@aws-sdk/types': 3.804.0
'@smithy/property-provider': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
transitivePeerDependencies:
- aws-crt
@@ -13765,7 +13764,7 @@ snapshots:
'@aws-sdk/util-arn-parser': 3.804.0
'@smithy/node-config-provider': 4.0.2
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-config-provider': 4.0.0
tslib: 2.8.1
@@ -13773,7 +13772,7 @@ snapshots:
dependencies:
'@aws-sdk/types': 3.804.0
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13786,7 +13785,7 @@ snapshots:
'@smithy/is-array-buffer': 4.0.0
'@smithy/node-config-provider': 4.0.2
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-middleware': 4.0.2
'@smithy/util-stream': 4.2.0
'@smithy/util-utf8': 4.0.0
@@ -13796,26 +13795,26 @@ snapshots:
dependencies:
'@aws-sdk/types': 3.804.0
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
'@aws-sdk/types': 3.804.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
'@aws-sdk/types': 3.804.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
'@aws-sdk/types': 3.804.0
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13828,7 +13827,7 @@ snapshots:
'@smithy/protocol-http': 5.1.0
'@smithy/signature-v4': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-config-provider': 4.0.0
'@smithy/util-middleware': 4.0.2
'@smithy/util-stream': 4.2.0
@@ -13838,7 +13837,7 @@ snapshots:
'@aws-sdk/[email protected]':
dependencies:
'@aws-sdk/types': 3.804.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13848,7 +13847,7 @@ snapshots:
'@aws-sdk/util-endpoints': 3.804.0
'@smithy/core': 3.3.1
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13879,7 +13878,7 @@ snapshots:
'@smithy/node-http-handler': 4.0.4
'@smithy/protocol-http': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/url-parser': 4.0.2
'@smithy/util-base64': 4.0.0
'@smithy/util-body-length-browser': 4.0.0
@@ -13898,7 +13897,7 @@ snapshots:
dependencies:
'@aws-sdk/types': 3.804.0
'@smithy/node-config-provider': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-config-provider': 4.0.0
'@smithy/util-middleware': 4.0.2
tslib: 2.8.1
@@ -13910,7 +13909,7 @@ snapshots:
'@aws-sdk/util-format-url': 3.804.0
'@smithy/middleware-endpoint': 4.1.2
'@smithy/signature-v4': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-hex-encoding': 4.0.0
'@smithy/util-utf8': 4.0.0
tslib: 2.8.1
@@ -13925,7 +13924,7 @@ snapshots:
'@smithy/middleware-endpoint': 4.1.2
'@smithy/protocol-http': 5.1.0
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13934,7 +13933,7 @@ snapshots:
'@aws-sdk/types': 3.804.0
'@smithy/protocol-http': 5.1.0
'@smithy/signature-v4': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13943,14 +13942,14 @@ snapshots:
'@aws-sdk/types': 3.804.0
'@smithy/property-provider': 4.0.2
'@smithy/shared-ini-file-loader': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
transitivePeerDependencies:
- aws-crt
'@aws-sdk/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13960,7 +13959,7 @@ snapshots:
'@aws-sdk/[email protected]':
dependencies:
'@aws-sdk/types': 3.804.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-endpoints': 3.0.2
tslib: 2.8.1
@@ -13968,7 +13967,7 @@ snapshots:
dependencies:
'@aws-sdk/types': 3.804.0
'@smithy/querystring-builder': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
@@ -13978,7 +13977,7 @@ snapshots:
'@aws-sdk/[email protected]':
dependencies:
'@aws-sdk/types': 3.804.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
bowser: 2.11.0
tslib: 2.8.1
@@ -13987,12 +13986,12 @@ snapshots:
'@aws-sdk/middleware-user-agent': 3.804.0
'@aws-sdk/types': 3.804.0
'@smithy/node-config-provider': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
@@ -17660,7 +17659,7 @@ snapshots:
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
@@ -17675,7 +17674,7 @@ snapshots:
'@smithy/[email protected]':
dependencies:
'@smithy/node-config-provider': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-config-provider': 4.0.0
'@smithy/util-middleware': 4.0.2
tslib: 2.8.1
@@ -17684,7 +17683,7 @@ snapshots:
dependencies:
'@smithy/middleware-serde': 4.0.3
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-body-length-browser': 4.0.0
'@smithy/util-middleware': 4.0.2
'@smithy/util-stream': 4.2.0
@@ -17695,45 +17694,45 @@ snapshots:
dependencies:
'@smithy/node-config-provider': 4.0.2
'@smithy/property-provider': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/url-parser': 4.0.2
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@aws-crypto/crc32': 5.2.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-hex-encoding': 4.0.0
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/eventstream-serde-universal': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/eventstream-serde-universal': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/eventstream-codec': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/protocol-http': 5.1.0
'@smithy/querystring-builder': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-base64': 4.0.0
tslib: 2.8.1
@@ -17741,25 +17740,25 @@ snapshots:
dependencies:
'@smithy/chunked-blob-reader': 5.0.0
'@smithy/chunked-blob-reader-native': 4.0.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-buffer-from': 4.0.0
'@smithy/util-utf8': 4.0.0
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-utf8': 4.0.0
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
@@ -17772,14 +17771,14 @@ snapshots:
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-utf8': 4.0.0
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
@@ -17788,7 +17787,7 @@ snapshots:
'@smithy/middleware-serde': 4.0.3
'@smithy/node-config-provider': 4.0.2
'@smithy/shared-ini-file-loader': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/url-parser': 4.0.2
'@smithy/util-middleware': 4.0.2
tslib: 2.8.1
@@ -17799,7 +17798,7 @@ snapshots:
'@smithy/protocol-http': 5.1.0
'@smithy/service-error-classification': 4.0.3
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-middleware': 4.0.2
'@smithy/util-retry': 4.0.3
tslib: 2.8.1
@@ -17807,19 +17806,19 @@ snapshots:
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/property-provider': 4.0.2
'@smithy/shared-ini-file-loader': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
@@ -17827,28 +17826,28 @@ snapshots:
'@smithy/abort-controller': 4.0.2
'@smithy/protocol-http': 5.1.0
'@smithy/querystring-builder': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-uri-escape': 4.0.0
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
@@ -17858,18 +17857,18 @@ snapshots:
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/is-array-buffer': 4.0.0
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-hex-encoding': 4.0.0
'@smithy/util-middleware': 4.0.2
'@smithy/util-uri-escape': 4.0.0
@@ -17882,14 +17881,10 @@ snapshots:
'@smithy/middleware-endpoint': 4.1.2
'@smithy/middleware-stack': 4.0.2
'@smithy/protocol-http': 5.1.0
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-stream': 4.2.0
tslib: 2.8.1
- '@smithy/[email protected]':
- dependencies:
- tslib: 2.8.1
-
'@smithy/[email protected]':
dependencies:
tslib: 2.8.1
@@ -17897,7 +17892,7 @@ snapshots:
'@smithy/[email protected]':
dependencies:
'@smithy/querystring-parser': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
@@ -17938,7 +17933,7 @@ snapshots:
dependencies:
'@smithy/property-provider': 4.0.2
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
bowser: 2.11.0
tslib: 2.8.1
@@ -17949,13 +17944,13 @@ snapshots:
'@smithy/node-config-provider': 4.0.2
'@smithy/property-provider': 4.0.2
'@smithy/smithy-client': 4.2.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/node-config-provider': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
@@ -17964,20 +17959,20 @@ snapshots:
'@smithy/[email protected]':
dependencies:
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/service-error-classification': 4.0.3
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/fetch-http-handler': 5.0.2
'@smithy/node-http-handler': 4.0.4
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
'@smithy/util-base64': 4.0.0
'@smithy/util-buffer-from': 4.0.0
'@smithy/util-hex-encoding': 4.0.0
@@ -18001,7 +17996,7 @@ snapshots:
'@smithy/[email protected]':
dependencies:
'@smithy/abort-controller': 4.0.2
- '@smithy/types': 4.2.0
+ '@smithy/types': 4.3.1
tslib: 2.8.1
'@socket.io/[email protected]': {}
@@ -21291,7 +21286,7 @@ snapshots:
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.10.1([email protected])([email protected])
- eslint-plugin-import: 2.31.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])
eslint-plugin-jsx-a11y: 6.10.2([email protected])
eslint-plugin-react: 7.37.5([email protected])
eslint-plugin-react-hooks: 4.6.2([email protected])
@@ -21310,7 +21305,7 @@ snapshots:
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.10.1([email protected]([email protected]))([email protected])
eslint-plugin-jsx-a11y: 6.10.2([email protected])
eslint-plugin-react: 7.37.5([email protected])
eslint-plugin-react-hooks: 4.6.2([email protected])
@@ -21349,7 +21344,7 @@ snapshots:
tinyglobby: 0.2.13
unrs-resolver: 1.7.2
optionalDependencies:
transitivePeerDependencies:
- supports-color
@@ -21401,7 +21396,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.8
@@ -21430,7 +21425,7 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.8