@muhgholy/next-drive 4.23.11 → 4.23.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1533,8 +1533,7 @@ var uploadChunkSchema = z.object({
1533
1533
  fileName: nameSchema,
1534
1534
  fileSize: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
1535
1535
  fileType: z.string().min(1).max(255),
1536
- folderId: z.string().optional(),
1537
- unauthenticated: z.coerce.boolean().optional()
1536
+ folderId: z.string().optional()
1538
1537
  }).refine((data) => data.chunkIndex < data.totalChunks, {
1539
1538
  message: "Chunk index must be less than total chunks"
1540
1539
  });
@@ -2262,16 +2261,16 @@ var handleDriveAction = async (ctx) => {
2262
2261
  cleanupTempFiles(files);
2263
2262
  return void res.status(400).json({ status: 400, message: uploadData.error.errors[0].message });
2264
2263
  }
2265
- const { chunkIndex, totalChunks, driveId, fileName, fileSize: fileSizeInBytes, fileType, folderId, unauthenticated } = uploadData.data;
2264
+ const { chunkIndex, totalChunks, driveId, fileName, fileSize: fileSizeInBytes, fileType, folderId } = uploadData.data;
2266
2265
  let currentUploadId = driveId;
2267
2266
  const tempBaseDir = path.join(os2.tmpdir(), "next-drive-uploads");
2268
2267
  if (!currentUploadId) {
2269
2268
  if (chunkIndex !== 0) return void res.status(400).json({ message: "Could not upload: missing upload session for this chunk" });
2270
- if (unauthenticated) {
2269
+ if (!authenticated) {
2271
2270
  const unauth = config.security?.unauthenticated;
2272
2271
  if (!unauth?.enabled) {
2273
2272
  cleanupTempFiles(files);
2274
- return void res.status(403).json({ status: 403, message: "Anonymous uploads are not enabled" });
2273
+ return void res.status(401).json({ status: 401, message: "Authentication required to upload" });
2275
2274
  }
2276
2275
  if (fileSizeInBytes > unauth.maxUploadSizeInBytes) {
2277
2276
  cleanupTempFiles(files);
@@ -2312,10 +2311,6 @@ var handleDriveAction = async (ctx) => {
2312
2311
  store.concurrent++;
2313
2312
  }
2314
2313
  } else {
2315
- if (!authenticated) {
2316
- cleanupTempFiles(files);
2317
- return void res.status(401).json({ status: 401, message: "Authentication required to upload" });
2318
- }
2319
2314
  if (fileType && config.security) {
2320
2315
  if (!validateMimeType(fileType, config.security.allowedMimeTypes)) {
2321
2316
  cleanupTempFiles(files);
@@ -2334,15 +2329,15 @@ var handleDriveAction = async (ctx) => {
2334
2329
  const uploadDir2 = path.join(tempBaseDir, currentUploadId);
2335
2330
  fs.mkdirSync(uploadDir2, { recursive: true });
2336
2331
  const metadata = {
2337
- owner: unauthenticated ? null : owner,
2338
- accountId: unauthenticated ? null : accountId,
2332
+ owner: authenticated ? owner : null,
2333
+ accountId: authenticated ? accountId : null,
2339
2334
  providerName: provider.name,
2340
2335
  name: fileName,
2341
- parentId: unauthenticated || folderId === "root" || !folderId ? null : folderId,
2336
+ parentId: !authenticated || folderId === "root" || !folderId ? null : folderId,
2342
2337
  fileSize: fileSizeInBytes,
2343
2338
  mimeType: fileType,
2344
2339
  totalChunks,
2345
- unauthenticated: !!unauthenticated
2340
+ unauthenticated: !authenticated
2346
2341
  };
2347
2342
  fs.writeFileSync(path.join(uploadDir2, "metadata.json"), JSON.stringify(metadata));
2348
2343
  }
@@ -2738,5 +2733,5 @@ var driveAPIHandler = async (req, res) => {
2738
2733
  };
2739
2734
 
2740
2735
  export { driveAPIHandler, driveCleanup, driveConfiguration, driveConfirm, driveDelete, driveFilePath, driveFileSchemaZod, driveGetUrl, driveInfo, driveList, driveListFiles, drivePurgeExpired, driveReadFile, driveUpload, drive_default, getDriveConfig, getDriveInformation };
2741
- //# sourceMappingURL=chunk-26KZWPCF.js.map
2742
- //# sourceMappingURL=chunk-26KZWPCF.js.map
2736
+ //# sourceMappingURL=chunk-P5U4E6MG.js.map
2737
+ //# sourceMappingURL=chunk-P5U4E6MG.js.map