mbkbucket 3.2.0 → 3.3.1

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.
Files changed (44) hide show
  1. package/index.js +7 -7
  2. package/{cli.js → lib/cli.js} +0 -1
  3. package/lib/public/mbkbucket-helper-demo.html +1177 -0
  4. package/lib/public/mbkbucket-helper.css +1235 -0
  5. package/lib/public/mbkbucket-helper.js +1550 -0
  6. package/{src → lib/src}/app.js +7 -0
  7. package/{src → lib/src}/config/index.js +1 -1
  8. package/{src → lib/src}/services/s3.service.js +3 -2
  9. package/package.json +13 -3
  10. package/.github/PACKAGE.md +0 -19
  11. package/.github/workflows/publish.yml +0 -88
  12. package/index.d.ts +0 -444
  13. package/lib/index.js +0 -17
  14. package/test/config-validation.test.js +0 -116
  15. /package/{public → lib/public}/bucketadmin.css +0 -0
  16. /package/{public → lib/public}/bucketadmin.js +0 -0
  17. /package/{src → lib/src}/cli/auth-helper.js +0 -0
  18. /package/{src → lib/src}/config/validation.js +0 -0
  19. /package/{src → lib/src}/controllers/api.controller.js +0 -0
  20. /package/{src → lib/src}/controllers/dashboard.controller.js +0 -0
  21. /package/{src → lib/src}/controllers/info.controller.js +0 -0
  22. /package/{src → lib/src}/controllers/view.controller.js +0 -0
  23. /package/{src → lib/src}/middleware/async-handler.js +0 -0
  24. /package/{src → lib/src}/middleware/bucket-resolver.js +0 -0
  25. /package/{src → lib/src}/middleware/error-handler.js +0 -0
  26. /package/{src → lib/src}/middleware/rate-limiter.js +0 -0
  27. /package/{src → lib/src}/middleware/security.js +0 -0
  28. /package/{src → lib/src}/routes/api.routes.js +0 -0
  29. /package/{src → lib/src}/routes/index.js +0 -0
  30. /package/{src → lib/src}/routes/info.routes.js +0 -0
  31. /package/{src → lib/src}/routes/view.routes.js +0 -0
  32. /package/{src → lib/src}/utils/errors.js +0 -0
  33. /package/{src → lib/src}/utils/helpers.js +0 -0
  34. /package/{src → lib/src}/utils/logger.js +0 -0
  35. /package/{views → lib/views}/bucket.handlebars +0 -0
  36. /package/{views → lib/views}/bucketadmin_alerts.handlebars +0 -0
  37. /package/{views → lib/views}/bucketadmin_delete_modal.handlebars +0 -0
  38. /package/{views → lib/views}/bucketadmin_filelist_skeleton.handlebars +0 -0
  39. /package/{views → lib/views}/bucketadmin_newfolder_modal.handlebars +0 -0
  40. /package/{views → lib/views}/bucketadmin_preview_modal.handlebars +0 -0
  41. /package/{views → lib/views}/bucketadmin_upload_modal.handlebars +0 -0
  42. /package/{views → lib/views}/bucketadmincontent.handlebars +0 -0
  43. /package/{views → lib/views}/bucketportal.handlebars +0 -0
  44. /package/{views → lib/views}/mbkbucket_info.handlebars +0 -0
@@ -1,116 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { parseAndValidateMbkbucketVar, parseAndValidateBucketConnection, normalizeBooleanLike } from '../src/config/validation.js';
4
-
5
- test('parseAndValidateMbkbucketVar applies defaults when empty', () => {
6
- const cfg = parseAndValidateMbkbucketVar(undefined);
7
- assert.equal(cfg.p_view_inline, true);
8
- assert.equal(cfg.publiView_enabled, false);
9
- });
10
-
11
- test('parseAndValidateMbkbucketVar normalizes boolean-like strings', () => {
12
- const cfg = parseAndValidateMbkbucketVar(JSON.stringify({
13
- p_view_inline: 'false',
14
- publiView_enabled: 'true'
15
- }));
16
-
17
- assert.equal(cfg.p_view_inline, false);
18
- assert.equal(cfg.publiView_enabled, true);
19
- });
20
-
21
- test('parseAndValidateMbkbucketVar rejects invalid JSON', () => {
22
- assert.throws(() => parseAndValidateMbkbucketVar('{oops'), /Invalid JSON/);
23
- });
24
-
25
- test('parseAndValidateMbkbucketVar rejects invalid boolean values', () => {
26
- assert.throws(() => parseAndValidateMbkbucketVar(JSON.stringify({
27
- p_view_inline: 'not-bool'
28
- })), /must be a boolean/);
29
- });
30
-
31
- test('parseAndValidateMbkbucketVar accepts common boolean aliases', () => {
32
- const cfg = parseAndValidateMbkbucketVar(JSON.stringify({
33
- p_view_inline: ' ON ',
34
- publiView_enabled: '0'
35
- }));
36
-
37
- assert.equal(cfg.p_view_inline, true);
38
- assert.equal(cfg.publiView_enabled, false);
39
- });
40
-
41
- test('parseAndValidateMbkbucketVar rejects non-object values', () => {
42
- assert.throws(() => parseAndValidateMbkbucketVar('null'), /must be a valid object/);
43
- assert.throws(() => parseAndValidateMbkbucketVar('[]'), /must be a valid object/);
44
- });
45
-
46
- test('normalizeBooleanLike returns untouched for unsupported values', () => {
47
- assert.equal(normalizeBooleanLike('maybe'), 'maybe');
48
- assert.equal(normalizeBooleanLike(123), 123);
49
- });
50
-
51
- test('parseAndValidateBucketConnection accepts multi-bucket config', () => {
52
- const raw = JSON.stringify({
53
- R2_Bucket: {
54
- BUCKET_NAME: 'my-r2-bucket',
55
- ACCESS_KEY_ID: 'abc',
56
- SECRET_ACCESS_KEY: 'def',
57
- ENDPOINT: 'https://example.r2.cloudflarestorage.com'
58
- },
59
- S3_Bucket: {
60
- BUCKET_NAME: 'my-s3-bucket',
61
- ACCESS_KEY_ID: 'ghi',
62
- SECRET_ACCESS_KEY: 'jkl',
63
- ENDPOINT: 'https://s3.ap-southeast-1.amazonaws.com'
64
- }
65
- });
66
-
67
- const cfg = parseAndValidateBucketConnection(raw);
68
- assert.deepEqual(Object.keys(cfg), ['R2_Bucket', 'S3_Bucket']);
69
- });
70
-
71
- test('parseAndValidateBucketConnection returns null when unset', () => {
72
- assert.equal(parseAndValidateBucketConnection(undefined), null);
73
- assert.equal(parseAndValidateBucketConnection(''), null);
74
- });
75
-
76
- test('parseAndValidateBucketConnection rejects invalid JSON', () => {
77
- assert.throws(() => parseAndValidateBucketConnection('{oops'), /not valid JSON/);
78
- });
79
-
80
- test('parseAndValidateBucketConnection rejects empty object and array', () => {
81
- assert.throws(() => parseAndValidateBucketConnection('{}'), /non-empty object/);
82
- assert.throws(() => parseAndValidateBucketConnection('[]'), /non-empty object/);
83
- });
84
-
85
- test('parseAndValidateBucketConnection rejects missing required fields', () => {
86
- const raw = JSON.stringify({
87
- bad: {
88
- BUCKET_NAME: 'x',
89
- ACCESS_KEY_ID: 'y',
90
- ENDPOINT: 'https://example.com'
91
- }
92
- });
93
-
94
- assert.throws(() => parseAndValidateBucketConnection(raw), /missing required fields/);
95
- });
96
-
97
- test('parseAndValidateBucketConnection rejects quoted inner object shape', () => {
98
- const raw = JSON.stringify({
99
- bad: '{"BUCKET_NAME":"x"}'
100
- });
101
-
102
- assert.throws(() => parseAndValidateBucketConnection(raw), /must be an object/);
103
- });
104
-
105
- test('parseAndValidateBucketConnection rejects empty required fields', () => {
106
- const raw = JSON.stringify({
107
- bad: {
108
- BUCKET_NAME: '',
109
- ACCESS_KEY_ID: 'abc',
110
- SECRET_ACCESS_KEY: 'def',
111
- ENDPOINT: 'https://example.com'
112
- }
113
- });
114
-
115
- assert.throws(() => parseAndValidateBucketConnection(raw), /missing required fields/);
116
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes