@lenne.tech/nest-server 11.46.4 → 11.46.6
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/.claude/rules/package-management.md +4 -3
- package/.claude/rules/testing.md +4 -4
- package/FRAMEWORK-API.md +1 -1
- package/dist/core/common/helpers/byte-range.helper.d.ts +8 -0
- package/dist/core/common/helpers/byte-range.helper.js +76 -0
- package/dist/core/common/helpers/byte-range.helper.js.map +1 -0
- package/dist/core/common/helpers/graphql-upload.helper.d.ts +10 -0
- package/dist/core/common/helpers/graphql-upload.helper.js +240 -0
- package/dist/core/common/helpers/graphql-upload.helper.js.map +1 -0
- package/dist/core/common/helpers/gridfs.helper.d.ts +7 -2
- package/dist/core/common/helpers/gridfs.helper.js +7 -4
- package/dist/core/common/helpers/gridfs.helper.js.map +1 -1
- package/dist/core/common/plugins/complexity.plugin.js +71 -7
- package/dist/core/common/plugins/complexity.plugin.js.map +1 -1
- package/dist/core/common/services/core-s3.service.d.ts +3 -0
- package/dist/core/common/services/core-s3.service.js +8 -1
- package/dist/core/common/services/core-s3.service.js.map +1 -1
- package/dist/core/modules/error-code/error-codes.d.ts +9 -0
- package/dist/core/modules/error-code/error-codes.js +8 -0
- package/dist/core/modules/error-code/error-codes.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.d.ts +5 -0
- package/dist/core/modules/file/core-file.controller.js +67 -3
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/file/core-file.service.d.ts +2 -0
- package/dist/core/modules/file/core-file.service.js +17 -6
- package/dist/core/modules/file/core-file.service.js.map +1 -1
- package/dist/core/modules/file/filesystem-file.helper.d.ts +2 -1
- package/dist/core/modules/file/filesystem-file.helper.js +2 -2
- package/dist/core/modules/file/filesystem-file.helper.js.map +1 -1
- package/dist/core/modules/file/interfaces/file-service-options.interface.d.ts +2 -0
- package/dist/core/modules/file/s3-file.helper.d.ts +2 -0
- package/dist/core/modules/file/s3-file.helper.js.map +1 -1
- package/dist/core/modules/hub/helpers/hub-mask.helper.js +5 -1
- package/dist/core/modules/hub/helpers/hub-mask.helper.js.map +1 -1
- package/dist/core.module.js +2 -1
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/server/modules/error-code/error-codes.d.ts +1 -0
- package/dist/test/test.helper.d.ts +1 -0
- package/dist/test/test.helper.js +6 -0
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/graphql-upload.d.ts +35 -1
- package/docs/REQUEST-LIFECYCLE.md +27 -4
- package/docs/error-codes.md +14 -0
- package/docs/security-overrides.md +21 -6
- package/migration-guides/11.46.4-to-11.46.5.md +183 -0
- package/migration-guides/11.46.5-to-11.46.6.md +203 -0
- package/package.json +14 -7
- package/src/core/common/helpers/byte-range.helper.ts +144 -0
- package/src/core/common/helpers/graphql-upload.helper.ts +522 -0
- package/src/core/common/helpers/gridfs.helper.ts +20 -6
- package/src/core/common/plugins/complexity.plugin.ts +150 -9
- package/src/core/common/services/core-s3.service.ts +16 -2
- package/src/core/modules/error-code/error-codes.ts +13 -0
- package/src/core/modules/file/INTEGRATION-CHECKLIST.md +1 -0
- package/src/core/modules/file/README.md +74 -1
- package/src/core/modules/file/core-file.controller.ts +139 -3
- package/src/core/modules/file/core-file.service.ts +33 -13
- package/src/core/modules/file/filesystem-file.helper.ts +8 -3
- package/src/core/modules/file/interfaces/file-service-options.interface.ts +13 -0
- package/src/core/modules/file/s3-file.helper.ts +3 -2
- package/src/core/modules/hub/helpers/hub-mask.helper.ts +16 -3
- package/src/core/modules/system-setup/INTEGRATION-CHECKLIST.md +8 -8
- package/src/core/modules/system-setup/README.md +6 -6
- package/src/core.module.ts +5 -1
- package/src/index.ts +2 -0
- package/src/test/README.md +8 -4
- package/src/test/test.helper.ts +12 -0
- package/src/types/graphql-upload.d.ts +35 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "11.46.
|
|
3
|
+
"version": "11.46.6",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -94,13 +94,13 @@
|
|
|
94
94
|
"@getbrevo/brevo": "6.2.0",
|
|
95
95
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
96
96
|
"@nestjs/apollo": "13.4.5",
|
|
97
|
-
"@nestjs/common": "11.2.
|
|
98
|
-
"@nestjs/core": "11.2.
|
|
97
|
+
"@nestjs/common": "11.2.10",
|
|
98
|
+
"@nestjs/core": "11.2.10",
|
|
99
99
|
"@nestjs/graphql": "13.4.5",
|
|
100
100
|
"@nestjs/jwt": "11.0.2",
|
|
101
101
|
"@nestjs/mongoose": "11.0.4",
|
|
102
102
|
"@nestjs/passport": "11.0.5",
|
|
103
|
-
"@nestjs/platform-express": "11.2.
|
|
103
|
+
"@nestjs/platform-express": "11.2.10",
|
|
104
104
|
"@nestjs/schedule": "6.1.3",
|
|
105
105
|
"@nestjs/swagger": "11.4.7",
|
|
106
106
|
"@nestjs/terminus": "11.1.1",
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"@tus/server": "2.4.6",
|
|
109
109
|
"@types/supertest": "7.2.1",
|
|
110
110
|
"bcrypt": "6.0.0",
|
|
111
|
+
"busboy": "1.6.0",
|
|
111
112
|
"class-transformer": "0.5.1",
|
|
112
113
|
"class-validator": "0.15.1",
|
|
113
114
|
"compression": "1.8.2",
|
|
@@ -116,11 +117,13 @@
|
|
|
116
117
|
"dotenv": "17.4.2",
|
|
117
118
|
"ejs": "6.0.1",
|
|
118
119
|
"express": "5.2.1",
|
|
120
|
+
"fs-capacitor": "6.2.0",
|
|
119
121
|
"graphql": "16.14.2",
|
|
120
122
|
"graphql-query-complexity": "2.0.0",
|
|
121
123
|
"graphql-subscriptions": "3.0.0",
|
|
122
124
|
"graphql-upload": "15.0.2",
|
|
123
125
|
"graphql-ws": "6.2.1",
|
|
126
|
+
"http-errors": "2.0.1",
|
|
124
127
|
"jose": "6.2.12",
|
|
125
128
|
"js-sha256": "1.0.0",
|
|
126
129
|
"json-to-graphql-query": "2.3.0",
|
|
@@ -130,6 +133,7 @@
|
|
|
130
133
|
"multer": "2.5.0",
|
|
131
134
|
"node-mailjet": "6.0.11",
|
|
132
135
|
"nodemailer": "10.4.1",
|
|
136
|
+
"object-path": "0.11.8",
|
|
133
137
|
"passport": "0.7.0",
|
|
134
138
|
"passport-jwt": "4.0.1",
|
|
135
139
|
"reflect-metadata": "0.2.2",
|
|
@@ -138,7 +142,7 @@
|
|
|
138
142
|
"supertest": "7.3.1",
|
|
139
143
|
"ts-morph": "28.0.0",
|
|
140
144
|
"undici": "7.30.2",
|
|
141
|
-
"ws": "8.
|
|
145
|
+
"ws": "8.23.0",
|
|
142
146
|
"yuml-diagram": "1.2.0"
|
|
143
147
|
},
|
|
144
148
|
"peerDependencies": {
|
|
@@ -190,17 +194,20 @@
|
|
|
190
194
|
"@compodoc/compodoc": "2.0.0",
|
|
191
195
|
"@nestjs/cli": "11.0.24",
|
|
192
196
|
"@nestjs/schematics": "11.1.0",
|
|
193
|
-
"@nestjs/testing": "11.2.
|
|
197
|
+
"@nestjs/testing": "11.2.10",
|
|
194
198
|
"@swc/cli": "0.8.1",
|
|
195
199
|
"@swc/core": "1.16.18",
|
|
196
200
|
"@tus/s3-store": "2.0.8",
|
|
201
|
+
"@types/busboy": "1.5.4",
|
|
197
202
|
"@types/compression": "1.8.1",
|
|
198
203
|
"@types/cookie-parser": "1.4.10",
|
|
199
204
|
"@types/ejs": "3.1.5",
|
|
200
205
|
"@types/express": "5.0.6",
|
|
206
|
+
"@types/http-errors": "2.0.5",
|
|
201
207
|
"@types/lodash": "4.17.26",
|
|
202
208
|
"@types/multer": "2.3.0",
|
|
203
209
|
"@types/node": "26.6.5",
|
|
210
|
+
"@types/object-path": "0.11.4",
|
|
204
211
|
"@types/passport": "1.0.17",
|
|
205
212
|
"@vitest/coverage-v8": "4.1.12",
|
|
206
213
|
"better-auth": "1.7.16",
|
|
@@ -220,7 +227,7 @@
|
|
|
220
227
|
"tus-js-client": "4.3.1",
|
|
221
228
|
"typescript": "5.9.3",
|
|
222
229
|
"unplugin-swc": "2.0.0",
|
|
223
|
-
"vite": "8.3.
|
|
230
|
+
"vite": "8.3.8",
|
|
224
231
|
"vite-plugin-node": "8.0.0",
|
|
225
232
|
"vitest": "4.1.12"
|
|
226
233
|
},
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A byte range of a file: the bytes `start` through `end`, both INCLUSIVE — the way HTTP counts them
|
|
3
|
+
* (`Range: bytes=0-1` is two bytes) and `fs.createReadStream()` takes them.
|
|
4
|
+
*
|
|
5
|
+
* Read with `CoreFileService.getFileStream(id, { range })` / `getFileStreamByName()` or
|
|
6
|
+
* `CoreS3Service.getObject(key, { range })`. The range must lie inside the file (`end` below its
|
|
7
|
+
* length); {@link parseRangeHeader} / `resolveDownloadRange()` produce such a range from a request.
|
|
8
|
+
*/
|
|
9
|
+
export interface ByteRange {
|
|
10
|
+
/** Last byte, inclusive */
|
|
11
|
+
end: number;
|
|
12
|
+
/** First byte, counted from 0 */
|
|
13
|
+
start: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* What {@link parseRangeHeader} decided about a `Range` header:
|
|
18
|
+
* - a {@link ByteRange} — deliver these bytes (`206 Partial Content`);
|
|
19
|
+
* - `'unsatisfiable'` — the range starts at or past the end of the file (`416 Range Not Satisfiable`);
|
|
20
|
+
* - `undefined` — deliver the whole file (`200`), the header asks for nothing this server serves.
|
|
21
|
+
*/
|
|
22
|
+
export type RangeHeaderDecision = 'unsatisfiable' | ByteRange | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Longest `Range` header that is parsed at all. A single byte range of a file the size of any store's limit is
|
|
26
|
+
* well below 100 characters; a longer header is a list of ranges or garbage, and both are answered with the whole
|
|
27
|
+
* file anyway.
|
|
28
|
+
*/
|
|
29
|
+
const MAX_RANGE_HEADER_LENGTH = 200;
|
|
30
|
+
|
|
31
|
+
/** One range of the set, `first-last`, `first-` or `-suffix`. Anchored and without nested quantifiers. */
|
|
32
|
+
const RANGE_SPEC = /^(\d*)[ \t]*-[ \t]*(\d*)$/;
|
|
33
|
+
|
|
34
|
+
/** The unit and the range set: `bytes=<set>`, the unit case-insensitive (RFC 9110 §14.1) */
|
|
35
|
+
const RANGE_UNIT = /^[ \t]*bytes[ \t]*=(.*)$/i;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Decide what a `Range` request header asks for, against a file of `length` bytes (RFC 9110 §14.1.2, §14.2).
|
|
39
|
+
*
|
|
40
|
+
* Only ONE range is served. The whole file (`undefined`) is the answer to:
|
|
41
|
+
* - no header, an empty one, or a unit other than `bytes`;
|
|
42
|
+
* - an invalid header (`bytes=5-2`, `bytes=abc`, `bytes=-`) — RFC 9110 lets a server ignore it, and the whole file
|
|
43
|
+
* is what a client that sent garbage can still use;
|
|
44
|
+
* - SEVERAL ranges (`bytes=0-1,5-9`): a `multipart/byteranges` answer is not served, the way Express's `send` does
|
|
45
|
+
* it. Media players and download managers ask for one range at a time;
|
|
46
|
+
* - a file whose length is unknown (`undefined`, negative, not an integer): a `206` must name the total length.
|
|
47
|
+
*
|
|
48
|
+
* `'unsatisfiable'` is the answer to a single range that starts at or past the end of the file, or a suffix range
|
|
49
|
+
* of length 0 — and to every range of an EMPTY file, which has no byte to start at.
|
|
50
|
+
*
|
|
51
|
+
* A range that ends past the file is cut at its last byte, and a suffix longer than the file is the whole file —
|
|
52
|
+
* both are satisfiable by definition, so a client may ask for `bytes=0-` or `bytes=0-999999999` without knowing
|
|
53
|
+
* the size.
|
|
54
|
+
*
|
|
55
|
+
* Pure function, no I/O — the HTTP glue (`resolveDownloadRange()`, `setDownloadRangeHeaders()`) lives next to
|
|
56
|
+
* `pipeFileToResponse()` in the file module.
|
|
57
|
+
*/
|
|
58
|
+
export function parseRangeHeader(
|
|
59
|
+
header: string | string[] | undefined,
|
|
60
|
+
length: number | undefined,
|
|
61
|
+
): RangeHeaderDecision {
|
|
62
|
+
if (typeof length !== 'number' || !Number.isSafeInteger(length) || length < 0) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
// Node joins repeated headers with ', ' — a repeated Range header is a list of ranges, answered with the whole file
|
|
66
|
+
const value = Array.isArray(header) ? header.join(',') : header;
|
|
67
|
+
if (typeof value !== 'string' || !value || value.length > MAX_RANGE_HEADER_LENGTH) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const unit = RANGE_UNIT.exec(value);
|
|
71
|
+
if (!unit) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
// Empty list elements are allowed and ignored (RFC 9110 §5.6.1)
|
|
75
|
+
const specs = unit[1]
|
|
76
|
+
.split(',')
|
|
77
|
+
.map((spec) => spec.trim())
|
|
78
|
+
.filter(Boolean);
|
|
79
|
+
if (specs.length !== 1) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const match = RANGE_SPEC.exec(specs[0]);
|
|
83
|
+
if (!match) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const [, first, last] = match;
|
|
87
|
+
if (!first && !last) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
if (!first) {
|
|
91
|
+
// Suffix range: the last N bytes
|
|
92
|
+
const suffix = toSafeInteger(last);
|
|
93
|
+
if (suffix === undefined) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
if (suffix === 0 || length === 0) {
|
|
97
|
+
return 'unsatisfiable';
|
|
98
|
+
}
|
|
99
|
+
return { end: length - 1, start: Math.max(0, length - suffix) };
|
|
100
|
+
}
|
|
101
|
+
const start = toSafeInteger(first);
|
|
102
|
+
const end = last ? toSafeInteger(last) : length - 1;
|
|
103
|
+
if (start === undefined || end === undefined) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
if (last && end < start) {
|
|
107
|
+
// `bytes=5-2` is invalid, not unsatisfiable — ignored
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
if (start >= length) {
|
|
111
|
+
return 'unsatisfiable';
|
|
112
|
+
}
|
|
113
|
+
return { end: Math.min(end, length - 1), start };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Check a range handed to a store read: two safe integers, `0 <= start <= end`. Returns it unchanged, `undefined`
|
|
118
|
+
* for no range, and throws a `RangeError` for anything else — the same answer from every store, before any of them
|
|
119
|
+
* is asked (each would otherwise fail in its own way: S3 with `InvalidRange`, GridFS with a driver error on the
|
|
120
|
+
* stream, the filesystem with a silently empty stream).
|
|
121
|
+
*/
|
|
122
|
+
export function assertByteRange(range: unknown): ByteRange | undefined {
|
|
123
|
+
if (range === undefined || range === null) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
const { end, start } = range as { end: number; start: number };
|
|
127
|
+
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 0 || end < start) {
|
|
128
|
+
throw new RangeError(
|
|
129
|
+
`Invalid byte range { start: ${String(start)}, end: ${String(end)} }: start and end must be integers with 0 <= start <= end (end inclusive)`,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return { end, start };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The `Content-Range` value of a range of a file with `length` bytes: `bytes 0-1/1234` */
|
|
136
|
+
export function contentRangeValue(range: ByteRange, length: number): string {
|
|
137
|
+
return `bytes ${range.start}-${range.end}/${length}`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Digits as a safe integer, `undefined` when they exceed what a Number holds exactly */
|
|
141
|
+
function toSafeInteger(digits: string): number | undefined {
|
|
142
|
+
const value = Number(digits);
|
|
143
|
+
return Number.isSafeInteger(value) ? value : undefined;
|
|
144
|
+
}
|