mbkbucket 1.4.0 → 1.5.0
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/.env.example +1 -1
- package/.github/PACKAGE.md +0 -4
- package/index.d.ts +126 -37
- package/index.js +1 -1
- package/lib/index.js +2 -2
- package/lib/routes/api.js +501 -0
- package/lib/routes/index.js +17 -0
- package/lib/routes/info.js +28 -0
- package/lib/routes/view.js +458 -0
- package/package.json +2 -2
- package/public/bucketadmin.css +144 -32
- package/public/bucketadmin.js +114 -34
- package/views/bucket.handlebars +3 -3
- package/views/bucketadmin_alerts.handlebars +15 -0
- package/views/bucketadmin_delete_modal.handlebars +40 -0
- package/views/bucketadmin_filelist_skeleton.handlebars +20 -0
- package/views/bucketadmin_preview_modal.handlebars +33 -0
- package/views/bucketadmincontent.handlebars +5 -94
- package/lib/bucket.js +0 -979
package/.env.example
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
mbkautheVar={"APP_NAME":"mbkbucket","loginRedirectURL":"/dashboard","bucket":""}
|
|
2
2
|
mbkauthShared={"Main_SECRET_TOKEN": 123,"DOMAIN":"mbktech.org","IS_DEPLOYED":"false","EncPass":"false","DEVICE_TRUST_DURATION_DAYS":7,"SESSION_SECRET_KEY":"123","LOGIN_DB":"postgres://","MBKAUTH_TWO_FA_ENABLE":"true","COOKIE_EXPIRE_TIME":2,"GITHUB_LOGIN_ENABLED":"f","GITHUB_CLIENT_ID":"123","GITHUB_CLIENT_SECRET":"123","GOOGLE_LOGIN_ENABLED":"f","GOOGLE_CLIENT_ID":"123","GOOGLE_CLIENT_SECRET":"123"}
|
|
3
3
|
# See @node_modules/mbkauthe/docs/env.md for more details
|
|
4
4
|
NODE_ENV=development
|
package/.github/PACKAGE.md
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for mbkbucket 1.
|
|
1
|
+
// Type definitions for mbkbucket 1.5.0
|
|
2
2
|
// Project: https://github.com/MIbnEKhalid/mbkbucket
|
|
3
3
|
// Definitions by: Muhammad Bin Khalid <https://github.com/MIbnEKhalid">
|
|
4
4
|
|
|
@@ -26,6 +26,53 @@ export interface S3ObjectResult {
|
|
|
26
26
|
[key: string]: any;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// Options passed to uploadFile
|
|
30
|
+
export interface UploadOptions {
|
|
31
|
+
metadata?: Record<string, string>;
|
|
32
|
+
cacheControl?: string;
|
|
33
|
+
storageClass?: string;
|
|
34
|
+
serverSideEncryption?: string;
|
|
35
|
+
bucketName?: string;
|
|
36
|
+
preventOverwrite?: boolean; // added in 1.4.1
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Options for listing files
|
|
41
|
+
export interface ListFilesOptions {
|
|
42
|
+
maxKeys?: number;
|
|
43
|
+
continuationToken?: string | null;
|
|
44
|
+
delimiter?: string | null;
|
|
45
|
+
fetchOwner?: boolean;
|
|
46
|
+
startAfter?: string | null;
|
|
47
|
+
bucketName?: string;
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Result returned from listfiles calls
|
|
52
|
+
export interface ListFilesResult extends Record<string, any> {
|
|
53
|
+
requestedAt: string;
|
|
54
|
+
totalFiles: number;
|
|
55
|
+
hasMore: boolean;
|
|
56
|
+
nextToken: string | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Incomplete multipart upload descriptor returned by AWS
|
|
60
|
+
export interface IncompleteMultipartUpload {
|
|
61
|
+
Key?: string;
|
|
62
|
+
UploadId?: string;
|
|
63
|
+
Initiated?: string;
|
|
64
|
+
Initiator?: { DisplayName?: string; [key: string]: any };
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Result returned by cleanupIncompleteMultipartUploads
|
|
69
|
+
export interface CleanupResult {
|
|
70
|
+
abortedCount: number;
|
|
71
|
+
uploads: Array<{ key: string; uploadId: string; initiated?: string }>;
|
|
72
|
+
cleanedAt?: string;
|
|
73
|
+
[key: string]: any;
|
|
74
|
+
}
|
|
75
|
+
|
|
29
76
|
/**
|
|
30
77
|
* S3-related functions (available from `mbkbucket/lib/s3` and re-exported at package root)
|
|
31
78
|
*/
|
|
@@ -41,14 +88,7 @@ export function uploadFile(
|
|
|
41
88
|
key: string,
|
|
42
89
|
fileBuffer: Buffer | Uint8Array,
|
|
43
90
|
contentType: string,
|
|
44
|
-
options?:
|
|
45
|
-
metadata?: Record<string, string>;
|
|
46
|
-
cacheControl?: string;
|
|
47
|
-
storageClass?: string;
|
|
48
|
-
serverSideEncryption?: string;
|
|
49
|
-
bucketName?: string;
|
|
50
|
-
[key: string]: any;
|
|
51
|
-
}
|
|
91
|
+
options?: UploadOptions
|
|
52
92
|
): Promise<{ fileSize?: number; key: string; contentType?: string; uploadedAt?: string } & Record<string, any>>;
|
|
53
93
|
|
|
54
94
|
export function downloadFile(
|
|
@@ -83,16 +123,8 @@ export function deleteFolder(prefix: string, bucketName?: string): Promise<{
|
|
|
83
123
|
|
|
84
124
|
export function listfiles(
|
|
85
125
|
prefix?: string,
|
|
86
|
-
options?:
|
|
87
|
-
|
|
88
|
-
continuationToken?: string | null;
|
|
89
|
-
delimiter?: string | null;
|
|
90
|
-
fetchOwner?: boolean;
|
|
91
|
-
startAfter?: string | null;
|
|
92
|
-
bucketName?: string;
|
|
93
|
-
[key: string]: any;
|
|
94
|
-
}
|
|
95
|
-
): Promise<Record<string, any>>;
|
|
126
|
+
options?: ListFilesOptions
|
|
127
|
+
): Promise<ListFilesResult>;
|
|
96
128
|
|
|
97
129
|
export function getFileMetadata(key: string, bucketName?: string): Promise<{
|
|
98
130
|
key: string;
|
|
@@ -147,6 +179,17 @@ export function abortMultipartUpload(
|
|
|
147
179
|
uploadId: string
|
|
148
180
|
): Promise<{ key: string; abortedAt: string }>;
|
|
149
181
|
|
|
182
|
+
export function listIncompleteMultipartUploads(
|
|
183
|
+
prefix?: string,
|
|
184
|
+
bucketName?: string
|
|
185
|
+
): Promise<IncompleteMultipartUpload[]>;
|
|
186
|
+
|
|
187
|
+
export function cleanupIncompleteMultipartUploads(
|
|
188
|
+
olderThanDays?: number,
|
|
189
|
+
prefix?: string,
|
|
190
|
+
bucketName?: string
|
|
191
|
+
): Promise<CleanupResult>;
|
|
192
|
+
|
|
150
193
|
/**
|
|
151
194
|
* Configuration variables from mbkbucket
|
|
152
195
|
*/
|
|
@@ -193,6 +236,46 @@ declare module "mbkbucket/lib/s3" {
|
|
|
193
236
|
Key?: string;
|
|
194
237
|
[key: string]: any;
|
|
195
238
|
}
|
|
239
|
+
|
|
240
|
+
// re-use shared interfaces defined at top of index.d.ts
|
|
241
|
+
export interface UploadOptions {
|
|
242
|
+
metadata?: Record<string, string>;
|
|
243
|
+
cacheControl?: string;
|
|
244
|
+
storageClass?: string;
|
|
245
|
+
serverSideEncryption?: string;
|
|
246
|
+
bucketName?: string;
|
|
247
|
+
preventOverwrite?: boolean;
|
|
248
|
+
[key: string]: any;
|
|
249
|
+
}
|
|
250
|
+
export interface ListFilesOptions {
|
|
251
|
+
maxKeys?: number;
|
|
252
|
+
continuationToken?: string | null;
|
|
253
|
+
delimiter?: string | null;
|
|
254
|
+
fetchOwner?: boolean;
|
|
255
|
+
startAfter?: string | null;
|
|
256
|
+
bucketName?: string;
|
|
257
|
+
[key: string]: any;
|
|
258
|
+
}
|
|
259
|
+
export interface ListFilesResult extends Record<string, any> {
|
|
260
|
+
requestedAt: string;
|
|
261
|
+
totalFiles: number;
|
|
262
|
+
hasMore: boolean;
|
|
263
|
+
nextToken: string | null;
|
|
264
|
+
}
|
|
265
|
+
export interface IncompleteMultipartUpload {
|
|
266
|
+
Key?: string;
|
|
267
|
+
UploadId?: string;
|
|
268
|
+
Initiated?: string;
|
|
269
|
+
Initiator?: { DisplayName?: string; [key: string]: any };
|
|
270
|
+
[key: string]: any;
|
|
271
|
+
}
|
|
272
|
+
export interface CleanupResult {
|
|
273
|
+
abortedCount: number;
|
|
274
|
+
uploads: Array<{ key: string; uploadId: string; initiated?: string }>;
|
|
275
|
+
cleanedAt?: string;
|
|
276
|
+
[key: string]: any;
|
|
277
|
+
}
|
|
278
|
+
|
|
196
279
|
export function getBucketConfig(bucketName?: string): BucketConfig;
|
|
197
280
|
export const bucketClient: any;
|
|
198
281
|
export function getAppName(): string;
|
|
@@ -200,19 +283,14 @@ declare module "mbkbucket/lib/s3" {
|
|
|
200
283
|
export function ensurePrefix(prefix?: string): string;
|
|
201
284
|
export function getBucketClient(bucketName?: string): any;
|
|
202
285
|
export function checkHealth(): Promise<{ status: string; responseTime?: number; bucket?: string; error?: string; checkedAt: string; region?: string }>;
|
|
286
|
+
|
|
203
287
|
export function uploadFile(
|
|
204
288
|
key: string,
|
|
205
289
|
fileBuffer: Buffer | Uint8Array,
|
|
206
290
|
contentType: string,
|
|
207
|
-
options?:
|
|
208
|
-
metadata?: Record<string, string>;
|
|
209
|
-
cacheControl?: string;
|
|
210
|
-
storageClass?: string;
|
|
211
|
-
serverSideEncryption?: string;
|
|
212
|
-
bucketName?: string;
|
|
213
|
-
[key: string]: any;
|
|
214
|
-
}
|
|
291
|
+
options?: UploadOptions
|
|
215
292
|
): Promise<{ fileSize?: number; key: string; contentType?: string; uploadedAt?: string } & Record<string, any>>;
|
|
293
|
+
|
|
216
294
|
export function downloadFile(
|
|
217
295
|
key: string,
|
|
218
296
|
options?: {
|
|
@@ -225,6 +303,7 @@ declare module "mbkbucket/lib/s3" {
|
|
|
225
303
|
[key: string]: any;
|
|
226
304
|
}
|
|
227
305
|
): Promise<S3ObjectResult>;
|
|
306
|
+
|
|
228
307
|
export function deleteFile(key: string, bucketName?: string): Promise<{ key: string; deletedAt?: string } & Record<string, any>>;
|
|
229
308
|
export function deleteFiles(keys: string[], bucketName?: string): Promise<{
|
|
230
309
|
results: any[];
|
|
@@ -240,18 +319,12 @@ declare module "mbkbucket/lib/s3" {
|
|
|
240
319
|
deletedAt: string;
|
|
241
320
|
prefix?: string;
|
|
242
321
|
}>;
|
|
322
|
+
|
|
243
323
|
export function listfiles(
|
|
244
324
|
prefix?: string,
|
|
245
|
-
options?:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
delimiter?: string | null;
|
|
249
|
-
fetchOwner?: boolean;
|
|
250
|
-
startAfter?: string | null;
|
|
251
|
-
bucketName?: string;
|
|
252
|
-
[key: string]: any;
|
|
253
|
-
}
|
|
254
|
-
): Promise<Record<string, any>>;
|
|
325
|
+
options?: ListFilesOptions
|
|
326
|
+
): Promise<ListFilesResult>;
|
|
327
|
+
|
|
255
328
|
export function getFileMetadata(key: string, bucketName?: string): Promise<{
|
|
256
329
|
key: string;
|
|
257
330
|
exists: boolean;
|
|
@@ -261,6 +334,7 @@ declare module "mbkbucket/lib/s3" {
|
|
|
261
334
|
LastModified?: Date;
|
|
262
335
|
[key: string]: any;
|
|
263
336
|
}>;
|
|
337
|
+
|
|
264
338
|
export function fileExists(key: string, bucketName?: string): Promise<boolean>;
|
|
265
339
|
export function getFileSize(key: string, bucketName?: string): Promise<number | null>;
|
|
266
340
|
export function generateSignedUrl(
|
|
@@ -275,26 +349,41 @@ declare module "mbkbucket/lib/s3" {
|
|
|
275
349
|
expiresAt: string;
|
|
276
350
|
generatedAt: string;
|
|
277
351
|
}>;
|
|
352
|
+
|
|
278
353
|
export function createMultipartUpload(
|
|
279
354
|
key: string,
|
|
280
355
|
contentType?: string,
|
|
281
356
|
metadata?: Record<string, string>
|
|
282
357
|
): Promise<{ uploadId: string; key: string }>;
|
|
358
|
+
|
|
283
359
|
export function uploadPart(
|
|
284
360
|
key: string,
|
|
285
361
|
uploadId: string,
|
|
286
362
|
partNumber: number,
|
|
287
363
|
buffer: Buffer | Uint8Array
|
|
288
364
|
): Promise<{ ETag: string; partNumber: number }>;
|
|
365
|
+
|
|
289
366
|
export function completeMultipartUpload(
|
|
290
367
|
key: string,
|
|
291
368
|
uploadId: string,
|
|
292
369
|
parts: Array<{ partNumber: number; ETag: string }>
|
|
293
370
|
): Promise<{ key: string }>;
|
|
371
|
+
|
|
294
372
|
export function abortMultipartUpload(
|
|
295
373
|
key: string,
|
|
296
374
|
uploadId: string
|
|
297
375
|
): Promise<{ key: string; abortedAt: string }>;
|
|
376
|
+
|
|
377
|
+
export function listIncompleteMultipartUploads(
|
|
378
|
+
prefix?: string,
|
|
379
|
+
bucketName?: string
|
|
380
|
+
): Promise<IncompleteMultipartUpload[]>;
|
|
381
|
+
|
|
382
|
+
export function cleanupIncompleteMultipartUploads(
|
|
383
|
+
olderThanDays?: number,
|
|
384
|
+
prefix?: string,
|
|
385
|
+
bucketName?: string
|
|
386
|
+
): Promise<CleanupResult>;
|
|
298
387
|
}
|
|
299
388
|
|
|
300
389
|
declare module "mbkbucket/lib/config/index" {
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import mbkautheRoutes from "mbkauthe";
|
|
|
6
6
|
import { engine } from "express-handlebars";
|
|
7
7
|
import compression from "compression";
|
|
8
8
|
import rateLimit from 'express-rate-limit';
|
|
9
|
-
import bucketRoutes from "./lib/
|
|
9
|
+
import bucketRoutes from "./lib/routes/index.js";
|
|
10
10
|
import { checkVersion } from "./lib/config/index.js";
|
|
11
11
|
import { appVersion } from "./lib/config/index.js";
|
|
12
12
|
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Barrel file: re-export all public items from lib
|
|
2
2
|
export * from './s3.js';
|
|
3
3
|
export * from './config/index.js';
|
|
4
|
-
export { default as bucket } from './
|
|
4
|
+
export { default as bucket } from './routes/index.js';
|
|
5
5
|
|
|
6
6
|
import * as s3 from './s3.js';
|
|
7
7
|
import * as config from './config/index.js';
|
|
8
|
-
import bucket from './
|
|
8
|
+
import bucket from './routes/index.js';
|
|
9
9
|
|
|
10
10
|
// Default aggregate export for convenience
|
|
11
11
|
const defaultExport = {
|