@muhgholy/next-drive 4.23.10 → 4.23.11
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.
- package/dist/{chunk-XUPDNN2U.js → chunk-26KZWPCF.js} +25 -9
- package/dist/chunk-26KZWPCF.js.map +1 -0
- package/dist/{chunk-V75PCJHT.cjs → chunk-NDHVF2IB.cjs} +25 -9
- package/dist/chunk-NDHVF2IB.cjs.map +1 -0
- package/dist/server/actions/drive.d.ts +1 -0
- package/dist/server/actions/drive.d.ts.map +1 -1
- package/dist/server/express.cjs +11 -11
- package/dist/server/express.js +2 -2
- package/dist/server/hono.cjs +11 -11
- package/dist/server/hono.js +2 -2
- package/dist/server/index.cjs +18 -18
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-V75PCJHT.cjs.map +0 -1
- package/dist/chunk-XUPDNN2U.js.map +0 -1
|
@@ -2186,7 +2186,7 @@ var withSignedUrls = (items, config) => {
|
|
|
2186
2186
|
|
|
2187
2187
|
// src/server/actions/drive.ts
|
|
2188
2188
|
var handleDriveAction = async (ctx) => {
|
|
2189
|
-
const { req, res, action, config, owner, isRootMode, information, provider, accountId } = ctx;
|
|
2189
|
+
const { req, res, action, config, owner, isRootMode, authenticated, information, provider, accountId } = ctx;
|
|
2190
2190
|
switch (action) {
|
|
2191
2191
|
case "list": {
|
|
2192
2192
|
if (req.method !== "GET") return void res.status(405).json({ status: 405, message: "Listing files requires a GET request" });
|
|
@@ -2325,6 +2325,10 @@ var handleDriveAction = async (ctx) => {
|
|
|
2325
2325
|
store.concurrent++;
|
|
2326
2326
|
}
|
|
2327
2327
|
} else {
|
|
2328
|
+
if (!authenticated) {
|
|
2329
|
+
cleanupTempFiles(files);
|
|
2330
|
+
return void res.status(401).json({ status: 401, message: "Authentication required to upload" });
|
|
2331
|
+
}
|
|
2328
2332
|
if (fileType && config.security) {
|
|
2329
2333
|
if (!validateMimeType(fileType, config.security.allowedMimeTypes)) {
|
|
2330
2334
|
cleanupTempFiles(files);
|
|
@@ -2689,12 +2693,12 @@ var driveAPIHandler = async (req, res) => {
|
|
|
2689
2693
|
if (action === "information") {
|
|
2690
2694
|
const { clientId, clientSecret, redirectUri } = config.storage?.google || {};
|
|
2691
2695
|
const googleConfigured = !!(clientId && clientSecret && redirectUri);
|
|
2692
|
-
let
|
|
2696
|
+
let authenticated2 = false;
|
|
2693
2697
|
try {
|
|
2694
2698
|
await getDriveInformation({ method: "REQUEST", req });
|
|
2695
|
-
|
|
2699
|
+
authenticated2 = true;
|
|
2696
2700
|
} catch {
|
|
2697
|
-
|
|
2701
|
+
authenticated2 = false;
|
|
2698
2702
|
}
|
|
2699
2703
|
res.status(200).json({
|
|
2700
2704
|
status: 200,
|
|
@@ -2704,15 +2708,26 @@ var driveAPIHandler = async (req, res) => {
|
|
|
2704
2708
|
google: googleConfigured
|
|
2705
2709
|
},
|
|
2706
2710
|
mode,
|
|
2707
|
-
authenticated,
|
|
2711
|
+
authenticated: authenticated2,
|
|
2708
2712
|
unauthenticatedUploads: !!config.security?.unauthenticated?.enabled
|
|
2709
2713
|
}
|
|
2710
2714
|
});
|
|
2711
2715
|
return;
|
|
2712
2716
|
}
|
|
2713
|
-
const information = await getDriveInformation({ method: "REQUEST", req });
|
|
2714
|
-
const { key: owner } = information;
|
|
2715
2717
|
const isRootMode = mode === "ROOT";
|
|
2718
|
+
let information;
|
|
2719
|
+
let authenticated = true;
|
|
2720
|
+
try {
|
|
2721
|
+
information = await getDriveInformation({ method: "REQUEST", req });
|
|
2722
|
+
} catch (err) {
|
|
2723
|
+
if ((action === "upload" || action === "cancel") && config.security?.unauthenticated?.enabled) {
|
|
2724
|
+
information = { key: null, storage: { quotaInBytes: 0 } };
|
|
2725
|
+
authenticated = false;
|
|
2726
|
+
} else {
|
|
2727
|
+
throw err;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
const { key: owner } = information;
|
|
2716
2731
|
const wasAuthHandled = await handleAuthAction(req, res, action, config, owner);
|
|
2717
2732
|
if (wasAuthHandled) return;
|
|
2718
2733
|
const { provider, accountId } = await resolveProvider(req, owner);
|
|
@@ -2723,6 +2738,7 @@ var driveAPIHandler = async (req, res) => {
|
|
|
2723
2738
|
config,
|
|
2724
2739
|
owner,
|
|
2725
2740
|
isRootMode,
|
|
2741
|
+
authenticated,
|
|
2726
2742
|
information,
|
|
2727
2743
|
provider,
|
|
2728
2744
|
accountId
|
|
@@ -2751,5 +2767,5 @@ exports.driveUpload = driveUpload;
|
|
|
2751
2767
|
exports.drive_default = drive_default;
|
|
2752
2768
|
exports.getDriveConfig = getDriveConfig;
|
|
2753
2769
|
exports.getDriveInformation = getDriveInformation;
|
|
2754
|
-
//# sourceMappingURL=chunk-
|
|
2755
|
-
//# sourceMappingURL=chunk-
|
|
2770
|
+
//# sourceMappingURL=chunk-NDHVF2IB.cjs.map
|
|
2771
|
+
//# sourceMappingURL=chunk-NDHVF2IB.cjs.map
|