fix(types): Add custom Express request types for station authentication

This commit is contained in:
2026-02-20 19:24:41 +01:00
parent 2da8247978
commit 778f159405
4 changed files with 111 additions and 36 deletions

View File

@@ -68,7 +68,7 @@
"rimraf": "3.0.2",
"start-server-and-test": "1.11.7",
"ts-jest": "26.5.0",
"ts-node": "9.1.1",
"ts-node": "10.9.2",
"typedoc": "0.20.19",
"typescript": "5.9.3"
},

134
pnpm-lock.yaml generated
View File

@@ -125,7 +125,7 @@ importers:
version: 2.0.0
jest:
specifier: 26.6.3
version: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
version: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
nodemon:
specifier: 2.0.7
version: 2.0.7
@@ -140,10 +140,10 @@ importers:
version: 1.11.7
ts-jest:
specifier: 26.5.0
version: 26.5.0(jest@26.6.3(ts-node@9.1.1(typescript@5.9.3)))(typescript@5.9.3)
version: 26.5.0(jest@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3)))(typescript@5.9.3)
ts-node:
specifier: 9.1.1
version: 9.1.1(typescript@5.9.3)
specifier: 10.9.2
version: 10.9.2(@types/node@25.3.0)(typescript@5.9.3)
typedoc:
specifier: 0.20.19
version: 0.20.19(typescript@5.9.3)
@@ -319,6 +319,10 @@ packages:
engines: {node: '>=0.1.95'}
hasBin: true
'@cspotcode/source-map-support@0.8.1':
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
engines: {node: '>=12'}
'@emnapi/core@1.4.0':
resolution: {integrity: sha512-H+N/FqT07NmLmt6OFFtDfwe8PNygprzBikrEMyQfgqSmT0vzE515Pz7R8izwB9q/zsH/MA64AKoul3sA6/CzVg==}
@@ -441,6 +445,9 @@ packages:
'@jridgewell/trace-mapping@0.3.25':
resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
'@jridgewell/trace-mapping@0.3.9':
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
'@napi-rs/wasm-runtime@0.2.7':
resolution: {integrity: sha512-5yximcFK5FNompXfJFoWanu5l8v1hNGqNHh9du1xETp9HWk/B/PzvchX55WYOPaIeNglG8++68AAiauBAtbnzw==}
@@ -645,6 +652,18 @@ packages:
resolution: {integrity: sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==}
engines: {node: '>= 6'}
'@tsconfig/node10@1.0.12':
resolution: {integrity: sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==}
'@tsconfig/node12@1.0.11':
resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==}
'@tsconfig/node14@1.0.3':
resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==}
'@tsconfig/node16@1.0.4':
resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==}
'@tybys/wasm-util@0.9.0':
resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==}
@@ -774,6 +793,10 @@ packages:
resolution: {integrity: sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==}
engines: {node: '>=0.4.0'}
acorn-walk@8.3.5:
resolution: {integrity: sha512-HEHNfbars9v4pgpW6SO1KSPkfoS0xVOM/9UzkJltjlsHZmJasxg8aXkuZa7SMf8vKGIBhpUsPluQSqhJFCqebw==}
engines: {node: '>=0.4.0'}
acorn@7.4.1:
resolution: {integrity: sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==}
engines: {node: '>=0.4.0'}
@@ -3934,12 +3957,19 @@ packages:
jest: '>=26 <27'
typescript: '>=3.8 <5.0'
ts-node@9.1.1:
resolution: {integrity: sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==}
engines: {node: '>=10.0.0'}
ts-node@10.9.2:
resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==}
hasBin: true
peerDependencies:
'@swc/core': '>=1.2.50'
'@swc/wasm': '>=1.2.50'
'@types/node': '*'
typescript: '>=2.7'
peerDependenciesMeta:
'@swc/core':
optional: true
'@swc/wasm':
optional: true
tslib@1.14.1:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
@@ -4118,6 +4148,9 @@ packages:
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
hasBin: true
v8-compile-cache-lib@3.0.1:
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
v8-to-istanbul@7.1.2:
resolution: {integrity: sha512-TxNb7YEUwkLXCQYeudi6lgQ/SZrzNO4kMdlqVxaZPUIUjCv6iSSypUQX70kNBSERpQ8fk48+d61FXk+tgqcWow==}
engines: {node: '>=10.10.0'}
@@ -4520,6 +4553,10 @@ snapshots:
exec-sh: 0.3.6
minimist: 1.2.8
'@cspotcode/source-map-support@0.8.1':
dependencies:
'@jridgewell/trace-mapping': 0.3.9
'@emnapi/core@1.4.0':
dependencies:
'@emnapi/wasi-threads': 1.0.1
@@ -4571,7 +4608,7 @@ snapshots:
jest-util: 26.6.2
slash: 3.0.0
'@jest/core@26.6.3(ts-node@9.1.1(typescript@5.9.3))':
'@jest/core@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))':
dependencies:
'@jest/console': 26.6.2
'@jest/reporters': 26.6.2
@@ -4584,14 +4621,14 @@ snapshots:
exit: 0.1.2
graceful-fs: 4.2.11
jest-changed-files: 26.6.2
jest-config: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-config: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-haste-map: 26.6.2
jest-message-util: 26.6.2
jest-regex-util: 26.0.0
jest-resolve: 26.6.2
jest-resolve-dependencies: 26.6.3
jest-runner: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-runtime: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-runner: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-runtime: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-snapshot: 26.6.2
jest-util: 26.6.2
jest-validate: 26.6.2
@@ -4691,13 +4728,13 @@ snapshots:
'@types/istanbul-lib-coverage': 2.0.6
collect-v8-coverage: 1.0.2
'@jest/test-sequencer@26.6.3(ts-node@9.1.1(typescript@5.9.3))':
'@jest/test-sequencer@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))':
dependencies:
'@jest/test-result': 26.6.2
graceful-fs: 4.2.11
jest-haste-map: 26.6.2
jest-runner: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-runtime: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-runner: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-runtime: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
transitivePeerDependencies:
- bufferutil
- canvas
@@ -4760,6 +4797,11 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.0
'@jridgewell/trace-mapping@0.3.9':
dependencies:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.0
'@napi-rs/wasm-runtime@0.2.7':
dependencies:
'@emnapi/core': 1.4.0
@@ -4979,6 +5021,14 @@ snapshots:
'@tootallnate/once@1.1.2': {}
'@tsconfig/node10@1.0.12': {}
'@tsconfig/node12@1.0.11': {}
'@tsconfig/node14@1.0.3': {}
'@tsconfig/node16@1.0.4': {}
'@tybys/wasm-util@0.9.0':
dependencies:
tslib: 2.8.1
@@ -5140,6 +5190,10 @@ snapshots:
acorn-walk@7.2.0: {}
acorn-walk@8.3.5:
dependencies:
acorn: 8.14.1
acorn@7.4.1: {}
acorn@8.14.1: {}
@@ -6819,9 +6873,9 @@ snapshots:
execa: 4.1.0
throat: 5.0.0
jest-cli@26.6.3(ts-node@9.1.1(typescript@5.9.3)):
jest-cli@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3)):
dependencies:
'@jest/core': 26.6.3(ts-node@9.1.1(typescript@5.9.3))
'@jest/core': 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
'@jest/test-result': 26.6.2
'@jest/types': 26.6.2
chalk: 4.1.2
@@ -6829,7 +6883,7 @@ snapshots:
graceful-fs: 4.2.11
import-local: 3.2.0
is-ci: 2.0.0
jest-config: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-config: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-util: 26.6.2
jest-validate: 26.6.2
prompts: 2.4.2
@@ -6841,10 +6895,10 @@ snapshots:
- ts-node
- utf-8-validate
jest-config@26.6.3(ts-node@9.1.1(typescript@5.9.3)):
jest-config@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3)):
dependencies:
'@babel/core': 7.26.10
'@jest/test-sequencer': 26.6.3(ts-node@9.1.1(typescript@5.9.3))
'@jest/test-sequencer': 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
'@jest/types': 26.6.2
babel-jest: 26.6.3(@babel/core@7.26.10)
chalk: 4.1.2
@@ -6854,7 +6908,7 @@ snapshots:
jest-environment-jsdom: 26.6.2
jest-environment-node: 26.6.2
jest-get-type: 26.3.0
jest-jasmine2: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-jasmine2: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-regex-util: 26.0.0
jest-resolve: 26.6.2
jest-util: 26.6.2
@@ -6862,7 +6916,7 @@ snapshots:
micromatch: 4.0.8
pretty-format: 26.6.2
optionalDependencies:
ts-node: 9.1.1(typescript@5.9.3)
ts-node: 10.9.2(@types/node@25.3.0)(typescript@5.9.3)
transitivePeerDependencies:
- bufferutil
- canvas
@@ -6941,7 +6995,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
jest-jasmine2@26.6.3(ts-node@9.1.1(typescript@5.9.3)):
jest-jasmine2@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3)):
dependencies:
'@babel/traverse': 7.27.0
'@jest/environment': 26.6.2
@@ -6956,7 +7010,7 @@ snapshots:
jest-each: 26.6.2
jest-matcher-utils: 26.6.2
jest-message-util: 26.6.2
jest-runtime: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-runtime: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-snapshot: 26.6.2
jest-util: 26.6.2
pretty-format: 26.6.2
@@ -7049,7 +7103,7 @@ snapshots:
resolve: 1.22.10
slash: 3.0.0
jest-runner@26.6.3(ts-node@9.1.1(typescript@5.9.3)):
jest-runner@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3)):
dependencies:
'@jest/console': 26.6.2
'@jest/environment': 26.6.2
@@ -7060,13 +7114,13 @@ snapshots:
emittery: 0.7.2
exit: 0.1.2
graceful-fs: 4.2.11
jest-config: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-config: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-docblock: 26.0.0
jest-haste-map: 26.6.2
jest-leak-detector: 26.6.2
jest-message-util: 26.6.2
jest-resolve: 26.6.2
jest-runtime: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-runtime: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-util: 26.6.2
jest-worker: 26.6.2
source-map-support: 0.5.21
@@ -7078,7 +7132,7 @@ snapshots:
- ts-node
- utf-8-validate
jest-runtime@26.6.3(ts-node@9.1.1(typescript@5.9.3)):
jest-runtime@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3)):
dependencies:
'@jest/console': 26.6.2
'@jest/environment': 26.6.2
@@ -7095,7 +7149,7 @@ snapshots:
exit: 0.1.2
glob: 7.2.3
graceful-fs: 4.2.11
jest-config: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-config: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-haste-map: 26.6.2
jest-message-util: 26.6.2
jest-mock: 26.6.2
@@ -7183,11 +7237,11 @@ snapshots:
merge-stream: 2.0.0
supports-color: 7.2.0
jest@26.6.3(ts-node@9.1.1(typescript@5.9.3)):
jest@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3)):
dependencies:
'@jest/core': 26.6.3(ts-node@9.1.1(typescript@5.9.3))
'@jest/core': 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
import-local: 3.2.0
jest-cli: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest-cli: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
transitivePeerDependencies:
- bufferutil
- canvas
@@ -8909,13 +8963,13 @@ snapshots:
dependencies:
punycode: 2.3.1
ts-jest@26.5.0(jest@26.6.3(ts-node@9.1.1(typescript@5.9.3)))(typescript@5.9.3):
ts-jest@26.5.0(jest@26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3)))(typescript@5.9.3):
dependencies:
'@types/jest': 26.0.20
bs-logger: 0.2.6
buffer-from: 1.1.2
fast-json-stable-stringify: 2.1.0
jest: 26.6.3(ts-node@9.1.1(typescript@5.9.3))
jest: 26.6.3(ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3))
jest-util: 26.6.2
json5: 2.2.3
lodash: 4.17.21
@@ -8925,14 +8979,22 @@ snapshots:
typescript: 5.9.3
yargs-parser: 20.2.9
ts-node@9.1.1(typescript@5.9.3):
ts-node@10.9.2(@types/node@25.3.0)(typescript@5.9.3):
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.12
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.4
'@types/node': 25.3.0
acorn: 8.14.1
acorn-walk: 8.3.5
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
source-map-support: 0.5.21
typescript: 5.9.3
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
tslib@1.14.1: {}
@@ -9136,6 +9198,8 @@ snapshots:
uuid@8.3.2: {}
v8-compile-cache-lib@3.0.1: {}
v8-to-istanbul@7.1.2:
dependencies:
'@types/istanbul-lib-coverage': 2.0.6

8
src/types/express.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
declare namespace Express {
interface Request {
/** Set by ScanAuth when the request was authenticated via a station token. Not a header — not spoofable by clients. */
isStationAuth?: boolean;
/** The authenticated station's DB id. Only present when isStationAuth === true. */
stationId?: number;
}
}

View File

@@ -13,6 +13,9 @@
"include": [
"src/**/*"
],
"files": [
"src/types/express.d.ts"
],
"exclude": [
"node_modules",
"**/*.spec.ts"