@balena/pinejs 25.0.8 → 25.0.9
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/.pinejs-cache.json +1 -1
- package/.versionbot/CHANGELOG.yml +92 -1
- package/{acfe8513bda15957403d.json → 2a929f22eb27e33c3797.json} +2 -2
- package/CHANGELOG.md +8 -0
- package/VERSION +1 -1
- package/out/webresource-handler/actions/beginUpload.js +12 -21
- package/out/webresource-handler/actions/beginUpload.js.map +1 -1
- package/out/webresource-handler/actions/cancelUpload.js +8 -3
- package/out/webresource-handler/actions/cancelUpload.js.map +1 -1
- package/out/webresource-handler/actions/commitUpload.js +9 -3
- package/out/webresource-handler/actions/commitUpload.js.map +1 -1
- package/package.json +2 -2
- package/src/webresource-handler/actions/beginUpload.ts +22 -26
- package/src/webresource-handler/actions/cancelUpload.ts +11 -3
- package/src/webresource-handler/actions/commitUpload.ts +13 -3
|
@@ -1,3 +1,78 @@
|
|
|
1
|
+
- commits:
|
|
2
|
+
- subject: Validate `commitUpload` payloads with zod
|
|
3
|
+
hash: 035fe8ef6d9527a6787ccf5a795f648b4afb1ee6
|
|
4
|
+
body: |
|
|
5
|
+
The payload was only checked for `uuid` being a string, and other
|
|
6
|
+
properties were ignored or passed to the provider as they were. It is
|
|
7
|
+
now a `z.compile`d strict object whose `uuid` must be a UUID, as
|
|
8
|
+
generated by `beginUpload`, and whose optional `providerCommitData` must
|
|
9
|
+
be an object. Its contents stay unchecked here as they are provider
|
|
10
|
+
specific, and the provider validates them. Anything else gets a 400
|
|
11
|
+
"Invalid commit upload payload".
|
|
12
|
+
footer:
|
|
13
|
+
Change-type: patch
|
|
14
|
+
change-type: patch
|
|
15
|
+
author: Pagan Gazzard
|
|
16
|
+
nested: []
|
|
17
|
+
- subject: Validate `cancelUpload` payloads with zod
|
|
18
|
+
hash: 5761edd5f213984eba687679a5187a5c9b9b11ea
|
|
19
|
+
body: |
|
|
20
|
+
The payload was only checked for `uuid` being a string, and any other
|
|
21
|
+
properties were ignored. It is now a `z.compile`d strict object whose
|
|
22
|
+
`uuid` must be a UUID, as generated by `beginUpload`, so a malformed
|
|
23
|
+
uuid or an unknown property gets a 400 "Invalid cancel upload payload"
|
|
24
|
+
rather than a lookup and a 401, or being ignored.
|
|
25
|
+
footer:
|
|
26
|
+
Change-type: patch
|
|
27
|
+
change-type: patch
|
|
28
|
+
author: Pagan Gazzard
|
|
29
|
+
nested: []
|
|
30
|
+
- subject: Bound `beginUpload` payload values by their column types
|
|
31
|
+
hash: 12a25d27ae44a2d7dc1653b9fbaaa50921837a2a
|
|
32
|
+
body: |
|
|
33
|
+
`size` and `chunk_size` accepted any number, so fractional or negative
|
|
34
|
+
sizes reached the fake patch and the storage provider. Values that
|
|
35
|
+
don't fit the `multipart_upload` columns (`chunk_size` above the 32-bit
|
|
36
|
+
`Integer`, `filename` or `content_type` over the 255 characters of
|
|
37
|
+
`Short Text`) were only rejected by the insert, after the multipart
|
|
38
|
+
upload had already been started on the provider and left behind.
|
|
39
|
+
|
|
40
|
+
`size` must now be a non-negative safe integer, `chunk_size` a positive
|
|
41
|
+
32-bit integer, and `filename`/`content_type` at most 255 characters.
|
|
42
|
+
Anything else is rejected as an invalid payload. A `chunk_size` of 0 or
|
|
43
|
+
less now gets "Invalid begin upload payload" rather than "Chunk size is
|
|
44
|
+
too small".
|
|
45
|
+
footer:
|
|
46
|
+
Change-type: patch
|
|
47
|
+
change-type: patch
|
|
48
|
+
author: Pagan Gazzard
|
|
49
|
+
nested: []
|
|
50
|
+
- subject: Use zod instead of ajv to validate `beginUpload` payloads
|
|
51
|
+
hash: 1d360c6d02a73b0c0a68d23b641b813e040592e1
|
|
52
|
+
body: |
|
|
53
|
+
The payload schema is now a `z.compile`d zod schema, matching how the
|
|
54
|
+
rest of pinejs validates request bodies. It compiles fully on the zod
|
|
55
|
+
fast path (`z.compile(..., { strict: true })` doesn't throw).
|
|
56
|
+
|
|
57
|
+
zod drops a `__proto__` key when it builds a record, so the
|
|
58
|
+
single-property refine can't see it. The raw key count is checked as
|
|
59
|
+
well, so `{"__proto__": ..., "logo_image": ...}` is still rejected as
|
|
60
|
+
it was by ajv's `maxProperties`. A lone `__proto__` key is now rejected
|
|
61
|
+
by the schema rather than by the webresource field check.
|
|
62
|
+
|
|
63
|
+
Per validation call (Node 26, min of 5 runs, 10 shuffled rounds):
|
|
64
|
+
valid payloads take ~78 ns vs ~44 ns with ajv, and invalid payloads
|
|
65
|
+
~1.2 µs vs 31-131 ns, as zod falls back to its runtime parser to build
|
|
66
|
+
the issues. Both are negligible next to the transaction, S3 call and
|
|
67
|
+
insert that `beginUpload` already makes.
|
|
68
|
+
footer:
|
|
69
|
+
Change-type: patch
|
|
70
|
+
change-type: patch
|
|
71
|
+
author: Pagan Gazzard
|
|
72
|
+
nested: []
|
|
73
|
+
version: 25.0.9
|
|
74
|
+
title: ""
|
|
75
|
+
date: 2026-11-11T01:36:07.793Z
|
|
1
76
|
- commits:
|
|
2
77
|
- subject: Fix inverted `mysql` check when picking the default database URL
|
|
3
78
|
hash: 31777b8e2231692b0ef633ad7bdb390ba351e328
|
|
@@ -20,7 +95,7 @@
|
|
|
20
95
|
nested: []
|
|
21
96
|
version: 25.0.8
|
|
22
97
|
title: ""
|
|
23
|
-
date: 2026-11-11T00:
|
|
98
|
+
date: 2026-11-11T00:55:37.005Z
|
|
24
99
|
- commits:
|
|
25
100
|
- subject: Update @balena/abstract-sql-to-typescript to 6.1.36
|
|
26
101
|
hash: 5e06eb5ce68f084b7d9d1b6febabcf6742a3ba13
|
|
@@ -9280,6 +9355,7 @@
|
|
|
9280
9355
|
|
|
9281
9356
|
|
|
9282
9357
|
|
|
9358
|
+
|
|
9283
9359
|
|
|
9284
9360
|
|
|
9285
9361
|
As balena-lint
|
|
@@ -9500,6 +9576,7 @@
|
|
|
9500
9576
|
|
|
9501
9577
|
|
|
9502
9578
|
|
|
9579
|
+
|
|
9503
9580
|
|
|
9504
9581
|
|
|
9505
9582
|
As engine and npm is
|
|
@@ -9735,6 +9812,7 @@
|
|
|
9735
9812
|
|
|
9736
9813
|
|
|
9737
9814
|
|
|
9815
|
+
|
|
9738
9816
|
|
|
9739
9817
|
|
|
9740
9818
|
Ensure that the
|
|
@@ -10033,6 +10111,7 @@
|
|
|
10033
10111
|
|
|
10034
10112
|
|
|
10035
10113
|
|
|
10114
|
+
|
|
10036
10115
|
|
|
10037
10116
|
|
|
10038
10117
|
This also deprecates
|
|
@@ -10259,6 +10338,7 @@
|
|
|
10259
10338
|
|
|
10260
10339
|
|
|
10261
10340
|
|
|
10341
|
+
|
|
10262
10342
|
|
|
10263
10343
|
|
|
10264
10344
|
It can in fact be a
|
|
@@ -10486,6 +10566,7 @@
|
|
|
10486
10566
|
|
|
10487
10567
|
|
|
10488
10568
|
|
|
10569
|
+
|
|
10489
10570
|
|
|
10490
10571
|
|
|
10491
10572
|
We know what type
|
|
@@ -10718,6 +10799,7 @@
|
|
|
10718
10799
|
|
|
10719
10800
|
|
|
10720
10801
|
|
|
10802
|
+
|
|
10721
10803
|
|
|
10722
10804
|
|
|
10723
10805
|
Update
|
|
@@ -11061,6 +11143,7 @@
|
|
|
11061
11143
|
|
|
11062
11144
|
|
|
11063
11145
|
|
|
11146
|
+
|
|
11064
11147
|
|
|
11065
11148
|
|
|
11066
11149
|
This also deprecates
|
|
@@ -14377,6 +14460,7 @@
|
|
|
14377
14460
|
|
|
14378
14461
|
|
|
14379
14462
|
|
|
14463
|
+
|
|
14380
14464
|
|
|
14381
14465
|
|
|
14382
14466
|
As balena-lint
|
|
@@ -14625,6 +14709,7 @@
|
|
|
14625
14709
|
|
|
14626
14710
|
|
|
14627
14711
|
|
|
14712
|
+
|
|
14628
14713
|
|
|
14629
14714
|
|
|
14630
14715
|
As engine and npm is
|
|
@@ -14888,6 +14973,7 @@
|
|
|
14888
14973
|
|
|
14889
14974
|
|
|
14890
14975
|
|
|
14976
|
+
|
|
14891
14977
|
|
|
14892
14978
|
|
|
14893
14979
|
Ensure that the
|
|
@@ -15214,6 +15300,7 @@
|
|
|
15214
15300
|
|
|
15215
15301
|
|
|
15216
15302
|
|
|
15303
|
+
|
|
15217
15304
|
|
|
15218
15305
|
|
|
15219
15306
|
This also deprecates
|
|
@@ -15468,6 +15555,7 @@
|
|
|
15468
15555
|
|
|
15469
15556
|
|
|
15470
15557
|
|
|
15558
|
+
|
|
15471
15559
|
|
|
15472
15560
|
|
|
15473
15561
|
It can in fact be a
|
|
@@ -15723,6 +15811,7 @@
|
|
|
15723
15811
|
|
|
15724
15812
|
|
|
15725
15813
|
|
|
15814
|
+
|
|
15726
15815
|
|
|
15727
15816
|
|
|
15728
15817
|
We know what type
|
|
@@ -15983,6 +16072,7 @@
|
|
|
15983
16072
|
|
|
15984
16073
|
|
|
15985
16074
|
|
|
16075
|
+
|
|
15986
16076
|
|
|
15987
16077
|
|
|
15988
16078
|
Update
|
|
@@ -16354,6 +16444,7 @@
|
|
|
16354
16444
|
|
|
16355
16445
|
|
|
16356
16446
|
|
|
16447
|
+
|
|
16357
16448
|
|
|
16358
16449
|
|
|
16359
16450
|
This also deprecates
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/pinejs",
|
|
3
|
-
"version": "25.0.
|
|
3
|
+
"version": "25.0.9",
|
|
4
4
|
"main": "out/server-glue/module.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "git@github.com:balena-io/pinejs.git",
|
|
@@ -148,6 +148,6 @@
|
|
|
148
148
|
"recursive": true
|
|
149
149
|
},
|
|
150
150
|
"versionist": {
|
|
151
|
-
"publishedAt": "2026-11-
|
|
151
|
+
"publishedAt": "2026-11-11T01:36:08.435Z"
|
|
152
152
|
}
|
|
153
153
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file
|
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
# v25.0.9
|
|
8
|
+
## (2026-11-11)
|
|
9
|
+
|
|
10
|
+
* Validate `commitUpload` payloads with zod [Pagan Gazzard]
|
|
11
|
+
* Validate `cancelUpload` payloads with zod [Pagan Gazzard]
|
|
12
|
+
* Bound `beginUpload` payload values by their column types [Pagan Gazzard]
|
|
13
|
+
* Use zod instead of ajv to validate `beginUpload` payloads [Pagan Gazzard]
|
|
14
|
+
|
|
7
15
|
# v25.0.8
|
|
8
16
|
## (2026-11-11)
|
|
9
17
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
25.0.
|
|
1
|
+
25.0.9
|
|
@@ -4,24 +4,15 @@ import { getWebResourceFields } from '../index.js';
|
|
|
4
4
|
import { BadRequestError, NotImplementedError } from '../../sbvr-api/errors.js';
|
|
5
5
|
import { permissions, sbvrUtils } from '../../server-glue/module.js';
|
|
6
6
|
import { randomUUID } from 'crypto';
|
|
7
|
-
import
|
|
8
|
-
const beginUploadPayloadSchema =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
content_type: { type: 'string' },
|
|
17
|
-
size: { type: 'number' },
|
|
18
|
-
chunk_size: { type: 'number' },
|
|
19
|
-
},
|
|
20
|
-
required: ['filename', 'content_type', 'size'],
|
|
21
|
-
additionalProperties: false,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
const validateBeginUpload = ajv.compile(beginUploadPayloadSchema);
|
|
7
|
+
import z from 'zod';
|
|
8
|
+
const beginUploadPayloadSchema = z.compile(z
|
|
9
|
+
.record(z.string(), z.strictObject({
|
|
10
|
+
filename: z.string().max(255),
|
|
11
|
+
content_type: z.string().max(255),
|
|
12
|
+
size: z.int().nonnegative(),
|
|
13
|
+
chunk_size: z.int32().positive().optional(),
|
|
14
|
+
}))
|
|
15
|
+
.refine((payload) => Object.keys(payload).length === 1));
|
|
25
16
|
const beginUploadAction = async ({ request, tx, id, req, }) => {
|
|
26
17
|
if (typeof id !== 'number') {
|
|
27
18
|
throw new NotImplementedError('multipart upload do not yet support non-numeric ids');
|
|
@@ -64,11 +55,11 @@ const beginUploadAction = async ({ request, tx, id, req, }) => {
|
|
|
64
55
|
};
|
|
65
56
|
};
|
|
66
57
|
const parseBeginUpload = (request, webResourceHandler) => {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
if (!isValid) {
|
|
58
|
+
const result = beginUploadPayloadSchema.safeParse(request.values);
|
|
59
|
+
if (!result.success || Object.keys(request.values).length !== 1) {
|
|
70
60
|
throw new BadRequestError('Invalid begin upload payload');
|
|
71
61
|
}
|
|
62
|
+
const values = result.data;
|
|
72
63
|
const fieldName = Object.keys(values)[0];
|
|
73
64
|
const webResourceFields = getWebResourceFields(request, false);
|
|
74
65
|
if (!webResourceFields.includes(fieldName)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beginUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/beginUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAMpC,OAAO,
|
|
1
|
+
{"version":3,"file":"beginUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/beginUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO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,CAAC,CAAC,OAAO,CAAC;YACrC,MAAM,EAAE,OAAO;YACf,GAAG,EAAE,MAAM;YACX,IAAI,EAAE,WAAW;YAGjB,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,IAAI,EAAE;SAClD,CAAC,CAAC;IACJ,CAAC;YAAS,CAAC;QACV,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;YACxB,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;IACF,CAAC;AACF,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -2,6 +2,10 @@ import { BadRequestError, NotImplementedError, UnauthorizedError, } from '../../
|
|
|
2
2
|
import { api } from '../../sbvr-api/sbvr-utils.js';
|
|
3
3
|
import { permissions } from '../../server-glue/module.js';
|
|
4
4
|
import { getMultipartUploadHandler } from '../multipartUpload.js';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
const cancelUploadPayloadSchema = z.compile(z.strictObject({
|
|
7
|
+
uuid: z.uuid(),
|
|
8
|
+
}));
|
|
5
9
|
const cancelUploadAction = async ({ request, tx, id: resourceId, }) => {
|
|
6
10
|
if (typeof resourceId !== 'number') {
|
|
7
11
|
throw new NotImplementedError('multipart upload do not yet support non-numeric ids');
|
|
@@ -25,10 +29,11 @@ const cancelUploadAction = async ({ request, tx, id: resourceId, }) => {
|
|
|
25
29
|
};
|
|
26
30
|
};
|
|
27
31
|
const getOngoingUpload = async (request, affectedId, tx) => {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
throw new BadRequestError('Invalid
|
|
32
|
+
const result = cancelUploadPayloadSchema.safeParse(request.values);
|
|
33
|
+
if (!result.success) {
|
|
34
|
+
throw new BadRequestError('Invalid cancel upload payload');
|
|
31
35
|
}
|
|
36
|
+
const { uuid } = result.data;
|
|
32
37
|
const multipartUpload = await api.webresource.get({
|
|
33
38
|
resource: 'multipart_upload',
|
|
34
39
|
id: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancelUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/cancelUpload.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,GAAG,EAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"cancelUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/cancelUpload.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,GAAG,EAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,yBAAyB,GAAG,CAAC,CAAC,OAAO,CAC1C,CAAC,CAAC,YAAY,CAAC;IACd,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;CACd,CAAC,CACF,CAAC;AAEF,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACjC,OAAO,EACP,EAAE,EACF,EAAE,EAAE,UAAU,GACG,EAAqB,EAAE;IACxC,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,mBAAmB,CAC5B,qDAAqD,CACrD,CAAC;IACH,CAAC;IACD,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,CACvD,OAAO,EACP,UAAU,EACV,EAAE,CACF,CAAC;IACF,MAAM,OAAO,GAAG,yBAAyB,EA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AAe,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,IAAI,iBAAiB,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO;QACN,EAAE,EAAE,eAAe,CAAC,EAAE;QACtB,OAAO,EAAE,eAAe,CAAC,QAAQ;QACjC,QAAQ,EAAE,eAAe,CAAC,SAAS;KACnC,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -2,6 +2,11 @@ import { BadRequestError, NotImplementedError, UnauthorizedError, } from '../../
|
|
|
2
2
|
import { api } from '../../sbvr-api/sbvr-utils.js';
|
|
3
3
|
import { permissions } from '../../server-glue/module.js';
|
|
4
4
|
import { getMultipartUploadHandler } from '../multipartUpload.js';
|
|
5
|
+
import z from 'zod';
|
|
6
|
+
const commitUploadPayloadSchema = z.compile(z.strictObject({
|
|
7
|
+
uuid: z.uuid(),
|
|
8
|
+
providerCommitData: z.record(z.string(), z.unknown()).optional(),
|
|
9
|
+
}));
|
|
5
10
|
const commitUploadAction = async ({ request, tx, id, api: applicationApi, }) => {
|
|
6
11
|
if (typeof id !== 'number') {
|
|
7
12
|
throw new NotImplementedError('multipart upload do not yet support non-numeric ids');
|
|
@@ -47,10 +52,11 @@ const commitUploadAction = async ({ request, tx, id, api: applicationApi, }) =>
|
|
|
47
52
|
};
|
|
48
53
|
};
|
|
49
54
|
const getOngoingUpload = async (request, affectedId, tx) => {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
throw new BadRequestError('Invalid
|
|
55
|
+
const result = commitUploadPayloadSchema.safeParse(request.values);
|
|
56
|
+
if (!result.success) {
|
|
57
|
+
throw new BadRequestError('Invalid commit upload payload');
|
|
53
58
|
}
|
|
59
|
+
const { uuid, providerCommitData } = result.data;
|
|
54
60
|
const multipartUpload = await api.webresource.get({
|
|
55
61
|
resource: 'multipart_upload',
|
|
56
62
|
id: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/commitUpload.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"commitUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/commitUpload.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,yBAAyB,GAAG,CAAC,CAAC,OAAO,CAC1C,CAAC,CAAC,YAAY,CAAC;IACd,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;IAEd,kBAAkB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CAChE,CAAC,CACF,CAAC;AAEF,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACjC,OAAO,EACP,EAAE,EACF,EAAE,EACF,GAAG,EAAE,cAAc,GACF,EAAqB,EAAE;IACxC,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,mBAAmB,CAC5B,qDAAqD,CACrD,CAAC;IACH,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAChE,MAAM,OA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+BAA+B,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IAEjD,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC;QACjD,QAAQ,EAAE,kBAAkB;QAC5B,EAAE,EAAE;YACH,IAAI;SACJ;QACD,OAAO,EAAE;YACR,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,CAAC;YAClE,OAAO,EAAE;gBACR,MAAM,EAAE,SAAS;gBACjB,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBAClC,aAAa,EAAE,OAAO,CAAC,YAAY;gBACnC,WAAW,EAAE,UAAU;aACvB;SACD;QACD,WAAW,EAAE;YACZ,EAAE;YACF,GAAG,EAAE,WAAW,CAAC,QAAQ;SACzB;KACD,CAAC,CAAC;IAEH,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,IAAI,iBAAiB,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO;QACN,IAAI;QACJ,kBAAkB;QAClB,OAAO,EAAE,eAAe,CAAC,QAAQ;QACjC,QAAQ,EAAE,eAAe,CAAC,SAAS;QACnC,QAAQ,EAAE,eAAe,CAAC,QAAQ;QAClC,SAAS,EAAE,eAAe,CAAC,UAAU;KACrC,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/pinejs",
|
|
3
|
-
"version": "25.0.
|
|
3
|
+
"version": "25.0.9",
|
|
4
4
|
"main": "out/server-glue/module.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "git@github.com:balena-io/pinejs.git",
|
|
@@ -148,6 +148,6 @@
|
|
|
148
148
|
"recursive": true
|
|
149
149
|
},
|
|
150
150
|
"versionist": {
|
|
151
|
-
"publishedAt": "2026-11-
|
|
151
|
+
"publishedAt": "2026-11-11T01:36:08.435Z"
|
|
152
152
|
}
|
|
153
153
|
}
|
|
@@ -11,8 +11,7 @@ import type {
|
|
|
11
11
|
ODataActionArgs,
|
|
12
12
|
ODataActionRequest,
|
|
13
13
|
} from '../../sbvr-api/actions.js';
|
|
14
|
-
import
|
|
15
|
-
import type { FromSchema } from 'json-schema-to-ts';
|
|
14
|
+
import z from 'zod';
|
|
16
15
|
|
|
17
16
|
type FakeWebResourcePatch = {
|
|
18
17
|
[key: string]: Omit<WebResource, 'href'> & {
|
|
@@ -20,26 +19,21 @@ type FakeWebResourcePatch = {
|
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
const beginUploadPayloadSchema =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} as const;
|
|
39
|
-
|
|
40
|
-
const validateBeginUpload = ajv.compile<
|
|
41
|
-
FromSchema<typeof beginUploadPayloadSchema>
|
|
42
|
-
>(beginUploadPayloadSchema);
|
|
22
|
+
const beginUploadPayloadSchema = z.compile(
|
|
23
|
+
z
|
|
24
|
+
.record(
|
|
25
|
+
z.string(),
|
|
26
|
+
z.strictObject({
|
|
27
|
+
// Bounded by the `multipart_upload` columns, so that an oversized value
|
|
28
|
+
// is rejected before the multipart upload is started on the provider
|
|
29
|
+
filename: z.string().max(255), // Short Text
|
|
30
|
+
content_type: z.string().max(255), // Short Text
|
|
31
|
+
size: z.int().nonnegative(), // Big Integer
|
|
32
|
+
chunk_size: z.int32().positive().optional(), // Integer
|
|
33
|
+
}),
|
|
34
|
+
)
|
|
35
|
+
.refine((payload) => Object.keys(payload).length === 1),
|
|
36
|
+
);
|
|
43
37
|
|
|
44
38
|
export type BeginMultipartUploadResponse = {
|
|
45
39
|
[key: string]: {
|
|
@@ -106,14 +100,16 @@ const parseBeginUpload = (
|
|
|
106
100
|
request: ODataActionRequest,
|
|
107
101
|
webResourceHandler: MultipartUploadHandler,
|
|
108
102
|
) => {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
const result = beginUploadPayloadSchema.safeParse(request.values);
|
|
104
|
+
// zod drops a `__proto__` key when building a record, so the refine never
|
|
105
|
+
// sees it: count the raw keys too, to reject `{"__proto__": ..., "a": ...}`
|
|
106
|
+
if (!result.success || Object.keys(request.values).length !== 1) {
|
|
112
107
|
throw new BadRequestError('Invalid begin upload payload');
|
|
113
108
|
}
|
|
109
|
+
const values = result.data;
|
|
114
110
|
|
|
115
111
|
// This is ensured to be an object with exactly one key
|
|
116
|
-
// as the validator
|
|
112
|
+
// as the validator refines it to exactly one property
|
|
117
113
|
const fieldName = Object.keys(values)[0];
|
|
118
114
|
|
|
119
115
|
const webResourceFields = getWebResourceFields(request, false);
|
|
@@ -11,6 +11,13 @@ import {
|
|
|
11
11
|
import { api, type Response } from '../../sbvr-api/sbvr-utils.js';
|
|
12
12
|
import { permissions } from '../../server-glue/module.js';
|
|
13
13
|
import { getMultipartUploadHandler } from '../multipartUpload.js';
|
|
14
|
+
import z from 'zod';
|
|
15
|
+
|
|
16
|
+
const cancelUploadPayloadSchema = z.compile(
|
|
17
|
+
z.strictObject({
|
|
18
|
+
uuid: z.uuid(),
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
14
21
|
|
|
15
22
|
const cancelUploadAction = async ({
|
|
16
23
|
request,
|
|
@@ -56,10 +63,11 @@ const getOngoingUpload = async (
|
|
|
56
63
|
affectedId: number,
|
|
57
64
|
tx: Tx,
|
|
58
65
|
) => {
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
throw new BadRequestError('Invalid
|
|
66
|
+
const result = cancelUploadPayloadSchema.safeParse(request.values);
|
|
67
|
+
if (!result.success) {
|
|
68
|
+
throw new BadRequestError('Invalid cancel upload payload');
|
|
62
69
|
}
|
|
70
|
+
const { uuid } = result.data;
|
|
63
71
|
|
|
64
72
|
const multipartUpload = await api.webresource.get({
|
|
65
73
|
resource: 'multipart_upload',
|
|
@@ -12,6 +12,15 @@ import type { Response } from '../../sbvr-api/sbvr-utils.js';
|
|
|
12
12
|
import { api } from '../../sbvr-api/sbvr-utils.js';
|
|
13
13
|
import { permissions } from '../../server-glue/module.js';
|
|
14
14
|
import { getMultipartUploadHandler } from '../multipartUpload.js';
|
|
15
|
+
import z from 'zod';
|
|
16
|
+
|
|
17
|
+
const commitUploadPayloadSchema = z.compile(
|
|
18
|
+
z.strictObject({
|
|
19
|
+
uuid: z.uuid(),
|
|
20
|
+
// The contents are provider specific, so the provider validates them
|
|
21
|
+
providerCommitData: z.record(z.string(), z.unknown()).optional(),
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
15
24
|
|
|
16
25
|
const commitUploadAction = async ({
|
|
17
26
|
request,
|
|
@@ -76,10 +85,11 @@ const getOngoingUpload = async (
|
|
|
76
85
|
affectedId: number,
|
|
77
86
|
tx: Tx,
|
|
78
87
|
) => {
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
throw new BadRequestError('Invalid
|
|
88
|
+
const result = commitUploadPayloadSchema.safeParse(request.values);
|
|
89
|
+
if (!result.success) {
|
|
90
|
+
throw new BadRequestError('Invalid commit upload payload');
|
|
82
91
|
}
|
|
92
|
+
const { uuid, providerCommitData } = result.data;
|
|
83
93
|
|
|
84
94
|
const multipartUpload = await api.webresource.get({
|
|
85
95
|
resource: 'multipart_upload',
|