@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.
@@ -1546,8 +1546,7 @@ var uploadChunkSchema = zod.z.object({
1546
1546
  fileName: nameSchema,
1547
1547
  fileSize: zod.z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
1548
1548
  fileType: zod.z.string().min(1).max(255),
1549
- folderId: zod.z.string().optional(),
1550
- unauthenticated: zod.z.coerce.boolean().optional()
1549
+ folderId: zod.z.string().optional()
1551
1550
  }).refine((data) => data.chunkIndex < data.totalChunks, {
1552
1551
  message: "Chunk index must be less than total chunks"
1553
1552
  });
@@ -2275,16 +2274,16 @@ var handleDriveAction = async (ctx) => {
2275
2274
  cleanupTempFiles(files);
2276
2275
  return void res.status(400).json({ status: 400, message: uploadData.error.errors[0].message });
2277
2276
  }
2278
- const { chunkIndex, totalChunks, driveId, fileName, fileSize: fileSizeInBytes, fileType, folderId, unauthenticated } = uploadData.data;
2277
+ const { chunkIndex, totalChunks, driveId, fileName, fileSize: fileSizeInBytes, fileType, folderId } = uploadData.data;
2279
2278
  let currentUploadId = driveId;
2280
2279
  const tempBaseDir = path__default.default.join(os2__default.default.tmpdir(), "next-drive-uploads");
2281
2280
  if (!currentUploadId) {
2282
2281
  if (chunkIndex !== 0) return void res.status(400).json({ message: "Could not upload: missing upload session for this chunk" });
2283
- if (unauthenticated) {
2282
+ if (!authenticated) {
2284
2283
  const unauth = config.security?.unauthenticated;
2285
2284
  if (!unauth?.enabled) {
2286
2285
  cleanupTempFiles(files);
2287
- return void res.status(403).json({ status: 403, message: "Anonymous uploads are not enabled" });
2286
+ return void res.status(401).json({ status: 401, message: "Authentication required to upload" });
2288
2287
  }
2289
2288
  if (fileSizeInBytes > unauth.maxUploadSizeInBytes) {
2290
2289
  cleanupTempFiles(files);
@@ -2325,10 +2324,6 @@ var handleDriveAction = async (ctx) => {
2325
2324
  store.concurrent++;
2326
2325
  }
2327
2326
  } else {
2328
- if (!authenticated) {
2329
- cleanupTempFiles(files);
2330
- return void res.status(401).json({ status: 401, message: "Authentication required to upload" });
2331
- }
2332
2327
  if (fileType && config.security) {
2333
2328
  if (!validateMimeType(fileType, config.security.allowedMimeTypes)) {
2334
2329
  cleanupTempFiles(files);
@@ -2347,15 +2342,15 @@ var handleDriveAction = async (ctx) => {
2347
2342
  const uploadDir2 = path__default.default.join(tempBaseDir, currentUploadId);
2348
2343
  fs__default.default.mkdirSync(uploadDir2, { recursive: true });
2349
2344
  const metadata = {
2350
- owner: unauthenticated ? null : owner,
2351
- accountId: unauthenticated ? null : accountId,
2345
+ owner: authenticated ? owner : null,
2346
+ accountId: authenticated ? accountId : null,
2352
2347
  providerName: provider.name,
2353
2348
  name: fileName,
2354
- parentId: unauthenticated || folderId === "root" || !folderId ? null : folderId,
2349
+ parentId: !authenticated || folderId === "root" || !folderId ? null : folderId,
2355
2350
  fileSize: fileSizeInBytes,
2356
2351
  mimeType: fileType,
2357
2352
  totalChunks,
2358
- unauthenticated: !!unauthenticated
2353
+ unauthenticated: !authenticated
2359
2354
  };
2360
2355
  fs__default.default.writeFileSync(path__default.default.join(uploadDir2, "metadata.json"), JSON.stringify(metadata));
2361
2356
  }
@@ -2767,5 +2762,5 @@ exports.driveUpload = driveUpload;
2767
2762
  exports.drive_default = drive_default;
2768
2763
  exports.getDriveConfig = getDriveConfig;
2769
2764
  exports.getDriveInformation = getDriveInformation;
2770
- //# sourceMappingURL=chunk-NDHVF2IB.cjs.map
2771
- //# sourceMappingURL=chunk-NDHVF2IB.cjs.map
2765
+ //# sourceMappingURL=chunk-SDOFFTZ5.cjs.map
2766
+ //# sourceMappingURL=chunk-SDOFFTZ5.cjs.map