r2-explorer 1.1.1 → 1.1.3
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/README.md +111 -51
- package/dashboard/assets/{AuthLayout.297460d7.js → AuthLayout.7618f480.js} +1 -1
- package/dashboard/{spa/assets/EmailFilePage.f737d2d4.js → assets/EmailFilePage.bbf7a6c5.js} +1 -1
- package/dashboard/{spa/assets/ErrorNotFound.be9ef3ac.js → assets/ErrorNotFound.699f3886.js} +1 -1
- package/dashboard/{spa/assets/LoginPage.fbddb0c0.js → assets/LoginPage.149f1ef8.js} +1 -1
- package/dashboard/assets/auth-store.f621e290.js +1 -0
- package/dashboard/assets/auth.9b526521.js +1 -0
- package/dashboard/assets/{bus.b6904cee.js → bus.18b30314.js} +1 -1
- package/dashboard/assets/{index.b2fb13c9.js → index.69bcbd86.js} +3 -3
- package/dashboard/assets/{index.c9ff738b.css → index.7e109f1f.css} +1 -1
- package/dashboard/index.html +5 -7
- package/dashboard/spa/assets/{AuthLayout.297460d7.js → AuthLayout.7618f480.js} +1 -1
- package/dashboard/{assets/EmailFilePage.f737d2d4.js → spa/assets/EmailFilePage.bbf7a6c5.js} +1 -1
- package/dashboard/{assets/ErrorNotFound.be9ef3ac.js → spa/assets/ErrorNotFound.699f3886.js} +1 -1
- package/dashboard/{assets/LoginPage.fbddb0c0.js → spa/assets/LoginPage.149f1ef8.js} +1 -1
- package/dashboard/spa/assets/auth-store.f621e290.js +1 -0
- package/dashboard/spa/assets/auth.9b526521.js +1 -0
- package/dashboard/spa/assets/{bus.b6904cee.js → bus.18b30314.js} +1 -1
- package/dashboard/spa/assets/{index.b2fb13c9.js → index.69bcbd86.js} +3 -3
- package/dashboard/spa/assets/{index.c9ff738b.css → index.7e109f1f.css} +1 -1
- package/dashboard/spa/index.html +5 -7
- package/dist/index.d.mts +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +41 -62
- package/dist/index.mjs +33 -54
- package/package.json +5 -5
- package/dashboard/assets/auth-store.748ba7e9.js +0 -1
- package/dashboard/assets/auth.221c63c3.js +0 -1
- package/dashboard/spa/assets/auth-store.748ba7e9.js +0 -1
- package/dashboard/spa/assets/auth.221c63c3.js +0 -1
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ __export(src_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(src_exports);
|
|
35
35
|
var import_cloudflare_access = require("@hono/cloudflare-access");
|
|
36
|
-
var
|
|
36
|
+
var import_chanfana14 = require("chanfana");
|
|
37
37
|
var import_hono = require("hono");
|
|
38
38
|
var import_basic_auth = require("hono/basic-auth");
|
|
39
39
|
var import_cors = require("hono/cors");
|
|
@@ -60,7 +60,7 @@ async function readOnlyMiddleware(c, next) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// package.json
|
|
63
|
-
var version = "1.1.
|
|
63
|
+
var version = "1.1.3";
|
|
64
64
|
|
|
65
65
|
// src/foundation/settings.ts
|
|
66
66
|
var settings = {
|
|
@@ -213,31 +213,10 @@ var HeadObject = class extends import_chanfana4.OpenAPIRoute {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
// src/modules/buckets/listBuckets.ts
|
|
217
|
-
var import_chanfana5 = require("chanfana");
|
|
218
|
-
var ListBuckets = class extends import_chanfana5.OpenAPIRoute {
|
|
219
|
-
schema = {
|
|
220
|
-
operationId: "get-bucket-list",
|
|
221
|
-
tags: ["Buckets"],
|
|
222
|
-
summary: "List buckets"
|
|
223
|
-
};
|
|
224
|
-
async handle(c) {
|
|
225
|
-
const buckets = [];
|
|
226
|
-
for (const [key, value] of Object.entries(c.env)) {
|
|
227
|
-
if (value.get && value.put && value.get.toString().includes("function") && value.put.toString().includes("function")) {
|
|
228
|
-
buckets.push({ name: key });
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return {
|
|
232
|
-
buckets
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
|
|
237
216
|
// src/modules/buckets/listObjects.ts
|
|
238
|
-
var
|
|
217
|
+
var import_chanfana5 = require("chanfana");
|
|
239
218
|
var import_zod5 = require("zod");
|
|
240
|
-
var ListObjects = class extends
|
|
219
|
+
var ListObjects = class extends import_chanfana5.OpenAPIRoute {
|
|
241
220
|
schema = {
|
|
242
221
|
operationId: "get-bucket-list-objects",
|
|
243
222
|
tags: ["Buckets"],
|
|
@@ -273,9 +252,9 @@ var ListObjects = class extends import_chanfana6.OpenAPIRoute {
|
|
|
273
252
|
};
|
|
274
253
|
|
|
275
254
|
// src/modules/buckets/moveObject.ts
|
|
276
|
-
var
|
|
255
|
+
var import_chanfana6 = require("chanfana");
|
|
277
256
|
var import_zod6 = require("zod");
|
|
278
|
-
var MoveObject = class extends
|
|
257
|
+
var MoveObject = class extends import_chanfana6.OpenAPIRoute {
|
|
279
258
|
schema = {
|
|
280
259
|
operationId: "post-bucket-move-object",
|
|
281
260
|
tags: ["Buckets"],
|
|
@@ -312,9 +291,9 @@ var MoveObject = class extends import_chanfana7.OpenAPIRoute {
|
|
|
312
291
|
};
|
|
313
292
|
|
|
314
293
|
// src/modules/buckets/multipart/completeUpload.ts
|
|
315
|
-
var
|
|
294
|
+
var import_chanfana7 = require("chanfana");
|
|
316
295
|
var import_zod7 = require("zod");
|
|
317
|
-
var CompleteUpload = class extends
|
|
296
|
+
var CompleteUpload = class extends import_chanfana7.OpenAPIRoute {
|
|
318
297
|
schema = {
|
|
319
298
|
operationId: "post-multipart-complete-upload",
|
|
320
299
|
tags: ["Multipart"],
|
|
@@ -359,9 +338,9 @@ var CompleteUpload = class extends import_chanfana8.OpenAPIRoute {
|
|
|
359
338
|
};
|
|
360
339
|
|
|
361
340
|
// src/modules/buckets/multipart/createUpload.ts
|
|
362
|
-
var
|
|
341
|
+
var import_chanfana8 = require("chanfana");
|
|
363
342
|
var import_zod8 = require("zod");
|
|
364
|
-
var CreateUpload = class extends
|
|
343
|
+
var CreateUpload = class extends import_chanfana8.OpenAPIRoute {
|
|
365
344
|
schema = {
|
|
366
345
|
operationId: "post-multipart-create-upload",
|
|
367
346
|
tags: ["Multipart"],
|
|
@@ -401,9 +380,9 @@ var CreateUpload = class extends import_chanfana9.OpenAPIRoute {
|
|
|
401
380
|
};
|
|
402
381
|
|
|
403
382
|
// src/modules/buckets/multipart/partUpload.ts
|
|
404
|
-
var
|
|
383
|
+
var import_chanfana9 = require("chanfana");
|
|
405
384
|
var import_zod9 = require("zod");
|
|
406
|
-
var PartUpload = class extends
|
|
385
|
+
var PartUpload = class extends import_chanfana9.OpenAPIRoute {
|
|
407
386
|
schema = {
|
|
408
387
|
operationId: "post-multipart-part-upload",
|
|
409
388
|
tags: ["Multipart"],
|
|
@@ -449,9 +428,9 @@ var PartUpload = class extends import_chanfana10.OpenAPIRoute {
|
|
|
449
428
|
};
|
|
450
429
|
|
|
451
430
|
// src/modules/buckets/putMetadata.ts
|
|
452
|
-
var
|
|
431
|
+
var import_chanfana10 = require("chanfana");
|
|
453
432
|
var import_zod10 = require("zod");
|
|
454
|
-
var PutMetadata = class extends
|
|
433
|
+
var PutMetadata = class extends import_chanfana10.OpenAPIRoute {
|
|
455
434
|
schema = {
|
|
456
435
|
operationId: "post-bucket-put-object-metadata",
|
|
457
436
|
tags: ["Buckets"],
|
|
@@ -493,9 +472,9 @@ var PutMetadata = class extends import_chanfana11.OpenAPIRoute {
|
|
|
493
472
|
};
|
|
494
473
|
|
|
495
474
|
// src/modules/buckets/putObject.ts
|
|
496
|
-
var
|
|
475
|
+
var import_chanfana11 = require("chanfana");
|
|
497
476
|
var import_zod11 = require("zod");
|
|
498
|
-
var PutObject = class extends
|
|
477
|
+
var PutObject = class extends import_chanfana11.OpenAPIRoute {
|
|
499
478
|
schema = {
|
|
500
479
|
operationId: "post-bucket-upload-object",
|
|
501
480
|
tags: ["Buckets"],
|
|
@@ -636,9 +615,9 @@ async function receiveEmail(event, env, ctx, config) {
|
|
|
636
615
|
}
|
|
637
616
|
|
|
638
617
|
// src/modules/emails/sendEmail.ts
|
|
639
|
-
var
|
|
618
|
+
var import_chanfana12 = require("chanfana");
|
|
640
619
|
var import_zod12 = require("zod");
|
|
641
|
-
var SendEmail = class extends
|
|
620
|
+
var SendEmail = class extends import_chanfana12.OpenAPIRoute {
|
|
642
621
|
schema = {
|
|
643
622
|
operationId: "post-email-send",
|
|
644
623
|
tags: ["Emails"],
|
|
@@ -648,14 +627,14 @@ var SendEmail = class extends import_chanfana13.OpenAPIRoute {
|
|
|
648
627
|
content: {
|
|
649
628
|
"application/json": {
|
|
650
629
|
schema: import_zod12.z.object({
|
|
651
|
-
subject: (0,
|
|
630
|
+
subject: (0, import_chanfana12.Str)({ example: "Look! No servers" }),
|
|
652
631
|
from: import_zod12.z.object({
|
|
653
|
-
email: (0,
|
|
654
|
-
name: (0,
|
|
632
|
+
email: (0, import_chanfana12.Str)({ example: "sender@example.com" }),
|
|
633
|
+
name: (0, import_chanfana12.Str)({ example: "Workers - MailChannels integration" })
|
|
655
634
|
}),
|
|
656
635
|
to: import_zod12.z.object({
|
|
657
|
-
email: (0,
|
|
658
|
-
name: (0,
|
|
636
|
+
email: (0, import_chanfana12.Str)({ example: "test@example.com" }),
|
|
637
|
+
name: (0, import_chanfana12.Str)({ example: "Test Recipient" })
|
|
659
638
|
}).array(),
|
|
660
639
|
content: import_zod12.z.object({}).catchall(import_zod12.z.string())
|
|
661
640
|
})
|
|
@@ -675,8 +654,8 @@ var SendEmail = class extends import_chanfana13.OpenAPIRoute {
|
|
|
675
654
|
};
|
|
676
655
|
|
|
677
656
|
// src/modules/server/getInfo.ts
|
|
678
|
-
var
|
|
679
|
-
var GetInfo = class extends
|
|
657
|
+
var import_chanfana13 = require("chanfana");
|
|
658
|
+
var GetInfo = class extends import_chanfana13.OpenAPIRoute {
|
|
680
659
|
schema = {
|
|
681
660
|
operationId: "get-server-info",
|
|
682
661
|
tags: ["Server"],
|
|
@@ -684,20 +663,27 @@ var GetInfo = class extends import_chanfana14.OpenAPIRoute {
|
|
|
684
663
|
};
|
|
685
664
|
async handle(c) {
|
|
686
665
|
const { basicAuth: basicAuth2, ...config } = c.get("config");
|
|
666
|
+
const buckets = [];
|
|
667
|
+
for (const [key, value] of Object.entries(c.env)) {
|
|
668
|
+
if (value.get && value.put && value.get.toString().includes("function") && value.put.toString().includes("function")) {
|
|
669
|
+
buckets.push({ name: key });
|
|
670
|
+
}
|
|
671
|
+
}
|
|
687
672
|
return {
|
|
688
673
|
version: settings.version,
|
|
689
674
|
config,
|
|
690
675
|
auth: c.get("authentication_type") ? {
|
|
691
676
|
type: c.get("authentication_type"),
|
|
692
677
|
username: c.get("authentication_username")
|
|
693
|
-
} : void 0
|
|
678
|
+
} : void 0,
|
|
679
|
+
buckets
|
|
694
680
|
};
|
|
695
681
|
}
|
|
696
682
|
};
|
|
697
683
|
|
|
698
684
|
// src/index.ts
|
|
699
685
|
function R2Explorer(config) {
|
|
700
|
-
(0,
|
|
686
|
+
(0, import_chanfana14.extendZodWithOpenApi)(import_zod13.z);
|
|
701
687
|
config = config || {};
|
|
702
688
|
if (config.readonly !== false) config.readonly = true;
|
|
703
689
|
const openapiSchema = {
|
|
@@ -719,27 +705,20 @@ function R2Explorer(config) {
|
|
|
719
705
|
c.set("config", config);
|
|
720
706
|
await next();
|
|
721
707
|
});
|
|
722
|
-
const openapi = (0,
|
|
708
|
+
const openapi = (0, import_chanfana14.fromHono)(app, {
|
|
723
709
|
schema: openapiSchema,
|
|
724
710
|
raiseUnknownParameters: true,
|
|
725
711
|
generateOperationIds: false
|
|
726
712
|
});
|
|
727
713
|
if (config.cors === true) {
|
|
728
|
-
app.use(
|
|
729
|
-
"*",
|
|
730
|
-
(0, import_cors.cors)({
|
|
731
|
-
origin: "*",
|
|
732
|
-
allowMethods: ["*"],
|
|
733
|
-
credentials: true
|
|
734
|
-
})
|
|
735
|
-
);
|
|
714
|
+
app.use("/api/*", (0, import_cors.cors)());
|
|
736
715
|
}
|
|
737
716
|
if (config.readonly === true) {
|
|
738
|
-
app.use("
|
|
717
|
+
app.use("/api/*", readOnlyMiddleware);
|
|
739
718
|
}
|
|
740
719
|
if (config.cfAccessTeamName) {
|
|
741
|
-
app.use("
|
|
742
|
-
app.use("
|
|
720
|
+
app.use("/api/*", (0, import_cloudflare_access.cloudflareAccess)(config.cfAccessTeamName));
|
|
721
|
+
app.use("/api/*", async (c, next) => {
|
|
743
722
|
c.set("authentication_type", "cloudflare-access");
|
|
744
723
|
c.set("authentication_username", c.get("accessPayload").email);
|
|
745
724
|
await next();
|
|
@@ -751,8 +730,9 @@ function R2Explorer(config) {
|
|
|
751
730
|
scheme: "basic"
|
|
752
731
|
});
|
|
753
732
|
app.use(
|
|
754
|
-
"
|
|
733
|
+
"/api/*",
|
|
755
734
|
(0, import_basic_auth.basicAuth)({
|
|
735
|
+
invalidUserMessage: "Authentication error: Basic Auth required",
|
|
756
736
|
verifyUser: (username, password, c) => {
|
|
757
737
|
const users = Array.isArray(c.get("config").basicAuth) ? c.get("config").basicAuth : [c.get("config").basicAuth];
|
|
758
738
|
for (const user of users) {
|
|
@@ -768,7 +748,6 @@ function R2Explorer(config) {
|
|
|
768
748
|
);
|
|
769
749
|
}
|
|
770
750
|
openapi.get("/api/server/config", GetInfo);
|
|
771
|
-
openapi.get("/api/buckets", ListBuckets);
|
|
772
751
|
openapi.get("/api/buckets/:bucket", ListObjects);
|
|
773
752
|
openapi.post("/api/buckets/:bucket/move", MoveObject);
|
|
774
753
|
openapi.post("/api/buckets/:bucket/folder", CreateFolder);
|
package/dist/index.mjs
CHANGED
|
@@ -30,7 +30,7 @@ async function readOnlyMiddleware(c, next) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// package.json
|
|
33
|
-
var version = "1.1.
|
|
33
|
+
var version = "1.1.3";
|
|
34
34
|
|
|
35
35
|
// src/foundation/settings.ts
|
|
36
36
|
var settings = {
|
|
@@ -183,31 +183,10 @@ var HeadObject = class extends OpenAPIRoute4 {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
// src/modules/buckets/listBuckets.ts
|
|
187
|
-
import { OpenAPIRoute as OpenAPIRoute5 } from "chanfana";
|
|
188
|
-
var ListBuckets = class extends OpenAPIRoute5 {
|
|
189
|
-
schema = {
|
|
190
|
-
operationId: "get-bucket-list",
|
|
191
|
-
tags: ["Buckets"],
|
|
192
|
-
summary: "List buckets"
|
|
193
|
-
};
|
|
194
|
-
async handle(c) {
|
|
195
|
-
const buckets = [];
|
|
196
|
-
for (const [key, value] of Object.entries(c.env)) {
|
|
197
|
-
if (value.get && value.put && value.get.toString().includes("function") && value.put.toString().includes("function")) {
|
|
198
|
-
buckets.push({ name: key });
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
buckets
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
186
|
// src/modules/buckets/listObjects.ts
|
|
208
|
-
import { OpenAPIRoute as
|
|
187
|
+
import { OpenAPIRoute as OpenAPIRoute5 } from "chanfana";
|
|
209
188
|
import { z as z5 } from "zod";
|
|
210
|
-
var ListObjects = class extends
|
|
189
|
+
var ListObjects = class extends OpenAPIRoute5 {
|
|
211
190
|
schema = {
|
|
212
191
|
operationId: "get-bucket-list-objects",
|
|
213
192
|
tags: ["Buckets"],
|
|
@@ -243,9 +222,9 @@ var ListObjects = class extends OpenAPIRoute6 {
|
|
|
243
222
|
};
|
|
244
223
|
|
|
245
224
|
// src/modules/buckets/moveObject.ts
|
|
246
|
-
import { OpenAPIRoute as
|
|
225
|
+
import { OpenAPIRoute as OpenAPIRoute6 } from "chanfana";
|
|
247
226
|
import { z as z6 } from "zod";
|
|
248
|
-
var MoveObject = class extends
|
|
227
|
+
var MoveObject = class extends OpenAPIRoute6 {
|
|
249
228
|
schema = {
|
|
250
229
|
operationId: "post-bucket-move-object",
|
|
251
230
|
tags: ["Buckets"],
|
|
@@ -282,9 +261,9 @@ var MoveObject = class extends OpenAPIRoute7 {
|
|
|
282
261
|
};
|
|
283
262
|
|
|
284
263
|
// src/modules/buckets/multipart/completeUpload.ts
|
|
285
|
-
import { OpenAPIRoute as
|
|
264
|
+
import { OpenAPIRoute as OpenAPIRoute7 } from "chanfana";
|
|
286
265
|
import { z as z7 } from "zod";
|
|
287
|
-
var CompleteUpload = class extends
|
|
266
|
+
var CompleteUpload = class extends OpenAPIRoute7 {
|
|
288
267
|
schema = {
|
|
289
268
|
operationId: "post-multipart-complete-upload",
|
|
290
269
|
tags: ["Multipart"],
|
|
@@ -329,9 +308,9 @@ var CompleteUpload = class extends OpenAPIRoute8 {
|
|
|
329
308
|
};
|
|
330
309
|
|
|
331
310
|
// src/modules/buckets/multipart/createUpload.ts
|
|
332
|
-
import { OpenAPIRoute as
|
|
311
|
+
import { OpenAPIRoute as OpenAPIRoute8 } from "chanfana";
|
|
333
312
|
import { z as z8 } from "zod";
|
|
334
|
-
var CreateUpload = class extends
|
|
313
|
+
var CreateUpload = class extends OpenAPIRoute8 {
|
|
335
314
|
schema = {
|
|
336
315
|
operationId: "post-multipart-create-upload",
|
|
337
316
|
tags: ["Multipart"],
|
|
@@ -371,9 +350,9 @@ var CreateUpload = class extends OpenAPIRoute9 {
|
|
|
371
350
|
};
|
|
372
351
|
|
|
373
352
|
// src/modules/buckets/multipart/partUpload.ts
|
|
374
|
-
import { OpenAPIRoute as
|
|
353
|
+
import { OpenAPIRoute as OpenAPIRoute9 } from "chanfana";
|
|
375
354
|
import { z as z9 } from "zod";
|
|
376
|
-
var PartUpload = class extends
|
|
355
|
+
var PartUpload = class extends OpenAPIRoute9 {
|
|
377
356
|
schema = {
|
|
378
357
|
operationId: "post-multipart-part-upload",
|
|
379
358
|
tags: ["Multipart"],
|
|
@@ -419,9 +398,9 @@ var PartUpload = class extends OpenAPIRoute10 {
|
|
|
419
398
|
};
|
|
420
399
|
|
|
421
400
|
// src/modules/buckets/putMetadata.ts
|
|
422
|
-
import { OpenAPIRoute as
|
|
401
|
+
import { OpenAPIRoute as OpenAPIRoute10 } from "chanfana";
|
|
423
402
|
import { z as z10 } from "zod";
|
|
424
|
-
var PutMetadata = class extends
|
|
403
|
+
var PutMetadata = class extends OpenAPIRoute10 {
|
|
425
404
|
schema = {
|
|
426
405
|
operationId: "post-bucket-put-object-metadata",
|
|
427
406
|
tags: ["Buckets"],
|
|
@@ -463,9 +442,9 @@ var PutMetadata = class extends OpenAPIRoute11 {
|
|
|
463
442
|
};
|
|
464
443
|
|
|
465
444
|
// src/modules/buckets/putObject.ts
|
|
466
|
-
import { OpenAPIRoute as
|
|
445
|
+
import { OpenAPIRoute as OpenAPIRoute11 } from "chanfana";
|
|
467
446
|
import { z as z11 } from "zod";
|
|
468
|
-
var PutObject = class extends
|
|
447
|
+
var PutObject = class extends OpenAPIRoute11 {
|
|
469
448
|
schema = {
|
|
470
449
|
operationId: "post-bucket-upload-object",
|
|
471
450
|
tags: ["Buckets"],
|
|
@@ -606,9 +585,9 @@ async function receiveEmail(event, env, ctx, config) {
|
|
|
606
585
|
}
|
|
607
586
|
|
|
608
587
|
// src/modules/emails/sendEmail.ts
|
|
609
|
-
import { OpenAPIRoute as
|
|
588
|
+
import { OpenAPIRoute as OpenAPIRoute12, Str } from "chanfana";
|
|
610
589
|
import { z as z12 } from "zod";
|
|
611
|
-
var SendEmail = class extends
|
|
590
|
+
var SendEmail = class extends OpenAPIRoute12 {
|
|
612
591
|
schema = {
|
|
613
592
|
operationId: "post-email-send",
|
|
614
593
|
tags: ["Emails"],
|
|
@@ -645,8 +624,8 @@ var SendEmail = class extends OpenAPIRoute13 {
|
|
|
645
624
|
};
|
|
646
625
|
|
|
647
626
|
// src/modules/server/getInfo.ts
|
|
648
|
-
import { OpenAPIRoute as
|
|
649
|
-
var GetInfo = class extends
|
|
627
|
+
import { OpenAPIRoute as OpenAPIRoute13 } from "chanfana";
|
|
628
|
+
var GetInfo = class extends OpenAPIRoute13 {
|
|
650
629
|
schema = {
|
|
651
630
|
operationId: "get-server-info",
|
|
652
631
|
tags: ["Server"],
|
|
@@ -654,13 +633,20 @@ var GetInfo = class extends OpenAPIRoute14 {
|
|
|
654
633
|
};
|
|
655
634
|
async handle(c) {
|
|
656
635
|
const { basicAuth: basicAuth2, ...config } = c.get("config");
|
|
636
|
+
const buckets = [];
|
|
637
|
+
for (const [key, value] of Object.entries(c.env)) {
|
|
638
|
+
if (value.get && value.put && value.get.toString().includes("function") && value.put.toString().includes("function")) {
|
|
639
|
+
buckets.push({ name: key });
|
|
640
|
+
}
|
|
641
|
+
}
|
|
657
642
|
return {
|
|
658
643
|
version: settings.version,
|
|
659
644
|
config,
|
|
660
645
|
auth: c.get("authentication_type") ? {
|
|
661
646
|
type: c.get("authentication_type"),
|
|
662
647
|
username: c.get("authentication_username")
|
|
663
|
-
} : void 0
|
|
648
|
+
} : void 0,
|
|
649
|
+
buckets
|
|
664
650
|
};
|
|
665
651
|
}
|
|
666
652
|
};
|
|
@@ -695,21 +681,14 @@ function R2Explorer(config) {
|
|
|
695
681
|
generateOperationIds: false
|
|
696
682
|
});
|
|
697
683
|
if (config.cors === true) {
|
|
698
|
-
app.use(
|
|
699
|
-
"*",
|
|
700
|
-
cors({
|
|
701
|
-
origin: "*",
|
|
702
|
-
allowMethods: ["*"],
|
|
703
|
-
credentials: true
|
|
704
|
-
})
|
|
705
|
-
);
|
|
684
|
+
app.use("/api/*", cors());
|
|
706
685
|
}
|
|
707
686
|
if (config.readonly === true) {
|
|
708
|
-
app.use("
|
|
687
|
+
app.use("/api/*", readOnlyMiddleware);
|
|
709
688
|
}
|
|
710
689
|
if (config.cfAccessTeamName) {
|
|
711
|
-
app.use("
|
|
712
|
-
app.use("
|
|
690
|
+
app.use("/api/*", cloudflareAccess(config.cfAccessTeamName));
|
|
691
|
+
app.use("/api/*", async (c, next) => {
|
|
713
692
|
c.set("authentication_type", "cloudflare-access");
|
|
714
693
|
c.set("authentication_username", c.get("accessPayload").email);
|
|
715
694
|
await next();
|
|
@@ -721,8 +700,9 @@ function R2Explorer(config) {
|
|
|
721
700
|
scheme: "basic"
|
|
722
701
|
});
|
|
723
702
|
app.use(
|
|
724
|
-
"
|
|
703
|
+
"/api/*",
|
|
725
704
|
basicAuth({
|
|
705
|
+
invalidUserMessage: "Authentication error: Basic Auth required",
|
|
726
706
|
verifyUser: (username, password, c) => {
|
|
727
707
|
const users = Array.isArray(c.get("config").basicAuth) ? c.get("config").basicAuth : [c.get("config").basicAuth];
|
|
728
708
|
for (const user of users) {
|
|
@@ -738,7 +718,6 @@ function R2Explorer(config) {
|
|
|
738
718
|
);
|
|
739
719
|
}
|
|
740
720
|
openapi.get("/api/server/config", GetInfo);
|
|
741
|
-
openapi.get("/api/buckets", ListBuckets);
|
|
742
721
|
openapi.get("/api/buckets/:bucket", ListObjects);
|
|
743
722
|
openapi.post("/api/buckets/:bucket/move", MoveObject);
|
|
744
723
|
openapi.post("/api/buckets/:bucket/folder", CreateFolder);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "r2-explorer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "A Google Drive Interface for your Cloudflare R2 Buckets",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lint": "npx @biomejs/biome check src/ tests/ || (npx @biomejs/biome check --write src/ tests/; exit 1)",
|
|
17
17
|
"test": "vitest run --root tests",
|
|
18
18
|
"package": "npm run build && npm pack",
|
|
19
|
-
|
|
19
|
+
"publish-npm": "npm publish"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"homepage": "https://r2explorer.dev",
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
|
-
"url": "https://github.com/G4brym/R2-Explorer.git"
|
|
49
|
+
"url": "git+https://github.com/G4brym/R2-Explorer.git"
|
|
50
50
|
},
|
|
51
51
|
"bugs": {
|
|
52
52
|
"url": "https://github.com/G4brym/R2-Explorer/issues"
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"wrangler": "^3.91.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@hono/cloudflare-access": "^0.
|
|
62
|
+
"@hono/cloudflare-access": "^0.2.0",
|
|
63
63
|
"chanfana": "^2.5.1",
|
|
64
|
-
"hono": "^4.6.
|
|
64
|
+
"hono": "^4.6.15",
|
|
65
65
|
"postal-mime": "^2.3.2",
|
|
66
66
|
"zod": "^3.24.1"
|
|
67
67
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as c,u as i,a as s}from"./index.b2fb13c9.js";const o="r2_explorer_session_token",h=c("auth",{state:()=>({user:"",loginMethod:""}),getters:{isAuthenticated:e=>!!e.user,StateUser:e=>e.user},actions:{async LogIn(e,t){var n;const r=i(),a=btoa(`${t.username}:${t.password}`);s.defaults.headers.common.Authorization=`Basic ${a}`;try{await r.loadServerConfigs(e)}catch(l){throw console.log(l),delete s.defaults.headers.common.Authorization,new Error("Invalid username or password")}s.defaults.headers.common.Authorization=`Basic ${a}`,this.loginMethod="basic",this.user=t.email,t.remind===!0?localStorage.setItem(o,a):sessionStorage.setItem(o,a),e.replace(((n=e.currentRoute.value.query)==null?void 0:n.next)||"/")},async CheckLoginInStorage(e){let t=sessionStorage.getItem(o);if(t||(t=localStorage.getItem(o)),!t)return!1;const r=i();s.defaults.headers.common.Authorization=`Basic ${t}`;try{await r.loadServerConfigs(e)}catch{delete s.defaults.headers.common.Authorization,await e.replace({name:"login",query:{next:e.currentRoute.fullPath}});return}this.user=atob(t).split(":")[0],this.loginMethod="basic"},async LogOut(e){localStorage.removeItem(o),sessionStorage.removeItem(o),this.user="",this.loginMethod="",await e.replace({name:"login"})}}});export{h as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as o,u as e}from"./index.b2fb13c9.js";import{u as r}from"./auth-store.748ba7e9.js";var h=o(async({router:a,store:t})=>{await r(t).CheckLoginInStorage(a)===!1&&await e(t).loadServerConfigs(a,!0)});export{h as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as c,u as i,a as s}from"./index.b2fb13c9.js";const o="r2_explorer_session_token",h=c("auth",{state:()=>({user:"",loginMethod:""}),getters:{isAuthenticated:e=>!!e.user,StateUser:e=>e.user},actions:{async LogIn(e,t){var n;const r=i(),a=btoa(`${t.username}:${t.password}`);s.defaults.headers.common.Authorization=`Basic ${a}`;try{await r.loadServerConfigs(e)}catch(l){throw console.log(l),delete s.defaults.headers.common.Authorization,new Error("Invalid username or password")}s.defaults.headers.common.Authorization=`Basic ${a}`,this.loginMethod="basic",this.user=t.email,t.remind===!0?localStorage.setItem(o,a):sessionStorage.setItem(o,a),e.replace(((n=e.currentRoute.value.query)==null?void 0:n.next)||"/")},async CheckLoginInStorage(e){let t=sessionStorage.getItem(o);if(t||(t=localStorage.getItem(o)),!t)return!1;const r=i();s.defaults.headers.common.Authorization=`Basic ${t}`;try{await r.loadServerConfigs(e)}catch{delete s.defaults.headers.common.Authorization,await e.replace({name:"login",query:{next:e.currentRoute.fullPath}});return}this.user=atob(t).split(":")[0],this.loginMethod="basic"},async LogOut(e){localStorage.removeItem(o),sessionStorage.removeItem(o),this.user="",this.loginMethod="",await e.replace({name:"login"})}}});export{h as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as o,u as e}from"./index.b2fb13c9.js";import{u as r}from"./auth-store.748ba7e9.js";var h=o(async({router:a,store:t})=>{await r(t).CheckLoginInStorage(a)===!1&&await e(t).loadServerConfigs(a,!0)});export{h as default};
|