node-server-engine 1.1.4 → 1.1.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/.env.example +193 -193
- package/.mocharc.js +13 -13
- package/.nycrc +18 -18
- package/.prettierrc +7 -7
- package/Dockerfile +30 -30
- package/README.md +991 -991
- package/babel.config.json +34 -35
- package/dist/const/DebeziumEvent.js.map +1 -1
- package/dist/const/LogSeverity.js.map +1 -1
- package/dist/const/index.js.map +1 -1
- package/dist/const/metrics.js.map +1 -1
- package/dist/const/mime.js.map +1 -1
- package/dist/const/tokenIssuer.js.map +1 -1
- package/dist/db/migrations/20241030121500-create-sequelize-meta-table.js.map +1 -1
- package/dist/db/models/SequelizeMeta.js +1 -0
- package/dist/db/models/SequelizeMeta.js.map +1 -1
- package/dist/db/models/index.js.map +1 -1
- package/dist/entities/ElasticSearch/ElasticSearch.js +7 -7
- package/dist/entities/ElasticSearch/ElasticSearch.js.map +1 -1
- package/dist/entities/ElasticSearch/ElasticSearch.types.js.map +1 -1
- package/dist/entities/ElasticSearch/index.js.map +1 -1
- package/dist/entities/Endpoint/Endpoint.js +18 -17
- package/dist/entities/Endpoint/Endpoint.js.map +1 -1
- package/dist/entities/Endpoint/Endpoint.types.js.map +1 -1
- package/dist/entities/Endpoint/index.js.map +1 -1
- package/dist/entities/EngineError/EngineError.js +7 -6
- package/dist/entities/EngineError/EngineError.js.map +1 -1
- package/dist/entities/EngineError/EngineError.types.js.map +1 -1
- package/dist/entities/EngineError/index.js.map +1 -1
- package/dist/entities/KeySet/KeySet.js +10 -9
- package/dist/entities/KeySet/KeySet.js.map +1 -1
- package/dist/entities/KeySet/KeySet.types.js.map +1 -1
- package/dist/entities/KeySet/index.js.map +1 -1
- package/dist/entities/LifecycleController/LifecycleController.js.map +1 -1
- package/dist/entities/LifecycleController/LifecycleController.types.js.map +1 -1
- package/dist/entities/LifecycleController/index.js.map +1 -1
- package/dist/entities/Localizator/Localizator.js +7 -7
- package/dist/entities/Localizator/Localizator.js.map +1 -1
- package/dist/entities/Localizator/Localizator.types.js.map +1 -1
- package/dist/entities/Localizator/guessNamingConvention/guessNamingConvention.js.map +1 -1
- package/dist/entities/Localizator/guessNamingConvention/index.js.map +1 -1
- package/dist/entities/Localizator/index.js.map +1 -1
- package/dist/entities/MessageHandler/MessageHandler.js +7 -6
- package/dist/entities/MessageHandler/MessageHandler.js.map +1 -1
- package/dist/entities/MessageHandler/MessageHandler.types.js.map +1 -1
- package/dist/entities/MessageHandler/index.js.map +1 -1
- package/dist/entities/PubSub/PubSub.js +25 -25
- package/dist/entities/PubSub/PubSub.js.map +1 -1
- package/dist/entities/PubSub/PubSub.types.js.map +1 -1
- package/dist/entities/PubSub/handleMessage/handleMessage.js +6 -6
- package/dist/entities/PubSub/handleMessage/handleMessage.js.map +1 -1
- package/dist/entities/PubSub/handleMessage/index.js.map +1 -1
- package/dist/entities/PubSub/index.js.map +1 -1
- package/dist/entities/PushNotification/PushNotification.js +4 -4
- package/dist/entities/PushNotification/PushNotification.js.map +1 -1
- package/dist/entities/PushNotification/PushNotification.types.js.map +1 -1
- package/dist/entities/PushNotification/index.js.map +1 -1
- package/dist/entities/Redis/Redis.js +8 -8
- package/dist/entities/Redis/Redis.js.map +1 -1
- package/dist/entities/Redis/Redis.types.js.map +1 -1
- package/dist/entities/Redis/Redis.validate.js +2 -2
- package/dist/entities/Redis/Redis.validate.js.map +1 -1
- package/dist/entities/Redis/index.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.config.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.js +2 -2
- package/dist/entities/Sequelize/Sequelize.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.types.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.validate.js +2 -2
- package/dist/entities/Sequelize/Sequelize.validate.js.map +1 -1
- package/dist/entities/Sequelize/index.js.map +1 -1
- package/dist/entities/Server/Server.const.js.map +1 -1
- package/dist/entities/Server/Server.js +18 -17
- package/dist/entities/Server/Server.js.map +1 -1
- package/dist/entities/Server/Server.types.js.map +1 -1
- package/dist/entities/Server/index.js.map +1 -1
- package/dist/entities/SocketClient/SocketClient.js +33 -32
- package/dist/entities/SocketClient/SocketClient.js.map +1 -1
- package/dist/entities/SocketClient/SocketClient.types.js.map +1 -1
- package/dist/entities/SocketClient/index.js.map +1 -1
- package/dist/entities/SocketClient/parseMessage/index.js.map +1 -1
- package/dist/entities/SocketClient/parseMessage/parseMessage.js +2 -2
- package/dist/entities/SocketClient/parseMessage/parseMessage.js.map +1 -1
- package/dist/entities/Storage/Storage.js +20 -20
- package/dist/entities/Storage/Storage.js.map +1 -1
- package/dist/entities/Storage/Storage.types.js.map +1 -1
- package/dist/entities/Storage/index.js.map +1 -1
- package/dist/entities/ValidationError/ValidationError.js.map +1 -1
- package/dist/entities/ValidationError/index.js.map +1 -1
- package/dist/entities/WebError/WebError.js +7 -6
- package/dist/entities/WebError/WebError.js.map +1 -1
- package/dist/entities/WebError/WebError.types.js.map +1 -1
- package/dist/entities/WebError/index.js.map +1 -1
- package/dist/entities/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics/debug.js.map +1 -1
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics/request.js.map +1 -1
- package/dist/middleware/authAdmin/authAdmin.js.map +1 -1
- package/dist/middleware/authAdmin/authAdmin.types.js.map +1 -1
- package/dist/middleware/authAdmin/index.js.map +1 -1
- package/dist/middleware/authHmac/authHmac.js.map +1 -1
- package/dist/middleware/authHmac/authHmac.types.js.map +1 -1
- package/dist/middleware/authHmac/index.js.map +1 -1
- package/dist/middleware/authJwt/authJwt.js.map +1 -1
- package/dist/middleware/authJwt/authJwt.types.js.map +1 -1
- package/dist/middleware/authJwt/index.js.map +1 -1
- package/dist/middleware/authStatic/authStatic.js +3 -3
- package/dist/middleware/authStatic/authStatic.js.map +1 -1
- package/dist/middleware/authStatic/index.js.map +1 -1
- package/dist/middleware/authTls/authTls.js +8 -8
- package/dist/middleware/authTls/authTls.js.map +1 -1
- package/dist/middleware/authTls/authTls.types.js.map +1 -1
- package/dist/middleware/authTls/index.js.map +1 -1
- package/dist/middleware/checkPermission/checkPermission.js.map +1 -1
- package/dist/middleware/error/error.js.map +1 -1
- package/dist/middleware/error/index.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.js +2 -2
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.types.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/index.js.map +1 -1
- package/dist/middleware/fileUploader/fileUploader.js +12 -12
- package/dist/middleware/fileUploader/fileUploader.js.map +1 -1
- package/dist/middleware/fileUploader/fileUploader.types.js.map +1 -1
- package/dist/middleware/fileUploader/index.js.map +1 -1
- package/dist/middleware/fileUploader/isMultiPart/index.js.map +1 -1
- package/dist/middleware/fileUploader/isMultiPart/isMultipart.js.map +1 -1
- package/dist/middleware/fileUploader/validate/index.js.map +1 -1
- package/dist/middleware/fileUploader/validate/validate.js.map +1 -1
- package/dist/middleware/fourOhFour/fourOhFour.js.map +1 -1
- package/dist/middleware/fourOhFour/index.js.map +1 -1
- package/dist/middleware/geminiFileUploader/geminiFileUploader.js.map +1 -1
- package/dist/middleware/geminiFileUploader/index.js.map +1 -1
- package/dist/middleware/healthCheck/healthCheck.js +2 -2
- package/dist/middleware/healthCheck/healthCheck.js.map +1 -1
- package/dist/middleware/healthCheck/index.js.map +1 -1
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/metrics/index.js.map +1 -1
- package/dist/middleware/metrics/metrics.js.map +1 -1
- package/dist/middleware/requestMetrics/index.js.map +1 -1
- package/dist/middleware/requestMetrics/requestMetrics.js.map +1 -1
- package/dist/middleware/swaggerDocs/index.js.map +1 -1
- package/dist/middleware/swaggerDocs/swaggerDocs.js +7 -7
- package/dist/middleware/swaggerDocs/swaggerDocs.js.map +1 -1
- package/dist/middleware/swaggerDocs/swaggerDocs.types.js.map +1 -1
- package/dist/middleware/userResolver/index.js.map +1 -1
- package/dist/middleware/userResolver/userResolver.js.map +1 -1
- package/dist/middleware/validate/index.js.map +1 -1
- package/dist/middleware/validate/validate.js.map +1 -1
- package/dist/middleware/version/index.js.map +1 -1
- package/dist/middleware/version/version.js +3 -3
- package/dist/middleware/version/version.js.map +1 -1
- package/dist/utils/checkEnvironment/index.js +13 -13
- package/dist/utils/checkEnvironment/index.js.map +1 -1
- package/dist/utils/createHttpServer/createHttpServer.js.map +1 -1
- package/dist/utils/createHttpServer/createHttpServer.validate.js +2 -2
- package/dist/utils/createHttpServer/createHttpServer.validate.js.map +1 -1
- package/dist/utils/createHttpServer/index.js.map +1 -1
- package/dist/utils/createSortedObject/createSortedObject.js.map +1 -1
- package/dist/utils/createSortedObject/index.js.map +1 -1
- package/dist/utils/dbMigration/dbMigration.js +8 -8
- package/dist/utils/dbMigration/dbMigration.js.map +1 -1
- package/dist/utils/dbMigration/dbMigration.types.js.map +1 -1
- package/dist/utils/dbMigration/index.js.map +1 -1
- package/dist/utils/dbMigration/migrateMetadataTable/index.js.map +1 -1
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js +4 -4
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js.map +1 -1
- package/dist/utils/envAssert/envAssert.js +6 -6
- package/dist/utils/envAssert/envAssert.js.map +1 -1
- package/dist/utils/envAssert/index.js.map +1 -1
- package/dist/utils/envAssert/validators/hostList.js +2 -2
- package/dist/utils/envAssert/validators/hostList.js.map +1 -1
- package/dist/utils/envAssert/validators/index.js.map +1 -1
- package/dist/utils/envAssert/validators/ipList.js +2 -2
- package/dist/utils/envAssert/validators/ipList.js.map +1 -1
- package/dist/utils/envAssert/validators/path.js +2 -2
- package/dist/utils/envAssert/validators/path.js.map +1 -1
- package/dist/utils/envAssert/validators/string.js +2 -2
- package/dist/utils/envAssert/validators/string.js.map +1 -1
- package/dist/utils/envAssert/validators/stringList.js +3 -3
- package/dist/utils/envAssert/validators/stringList.js.map +1 -1
- package/dist/utils/filter/filter.js +4 -4
- package/dist/utils/filter/filter.js.map +1 -1
- package/dist/utils/filter/index.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.types.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.validate.js.map +1 -1
- package/dist/utils/getDynamicLink/index.js.map +1 -1
- package/dist/utils/hmac/checkEnv/checkEnv.js +2 -2
- package/dist/utils/hmac/checkEnv/checkEnv.js.map +1 -1
- package/dist/utils/hmac/checkEnv/index.js.map +1 -1
- package/dist/utils/hmac/createHmac/createHmac.js.map +1 -1
- package/dist/utils/hmac/createHmac/index.js.map +1 -1
- package/dist/utils/hmac/index.js.map +1 -1
- package/dist/utils/hmac/index.types.js.map +1 -1
- package/dist/utils/hmac/signPayload/index.js.map +1 -1
- package/dist/utils/hmac/signPayload/signPayload.js.map +1 -1
- package/dist/utils/hmac/verifySignature/index.js.map +1 -1
- package/dist/utils/hmac/verifySignature/verifySignature.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/jwt/index.js.map +1 -1
- package/dist/utils/jwt/jwt.js.map +1 -1
- package/dist/utils/jwt/jwt.types.js.map +1 -1
- package/dist/utils/report/index.js.map +1 -1
- package/dist/utils/report/output.js.map +1 -1
- package/dist/utils/report/output.types.js.map +1 -1
- package/dist/utils/report/report.js.map +1 -1
- package/dist/utils/report/report.types.js.map +1 -1
- package/dist/utils/request/index.js.map +1 -1
- package/dist/utils/request/request.js.map +1 -1
- package/dist/utils/semverCompare/index.js.map +1 -1
- package/dist/utils/semverCompare/semverCompare.js +5 -5
- package/dist/utils/semverCompare/semverCompare.js.map +1 -1
- package/dist/utils/sendEmail/index.js.map +1 -1
- package/dist/utils/sendEmail/sendEmail.js +8 -8
- package/dist/utils/sendEmail/sendEmail.js.map +1 -1
- package/dist/utils/sendEmail/sendEmail.types.js.map +1 -1
- package/dist/utils/sendPush/index.js.map +1 -1
- package/dist/utils/sendPush/sendPush.js +5 -5
- package/dist/utils/sendPush/sendPush.js.map +1 -1
- package/dist/utils/sendPush/sendPush.types.js.map +1 -1
- package/dist/utils/tlsConfig/index.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.js +2 -2
- package/dist/utils/tlsConfig/tlsConfig.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.types.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.validate.js +2 -2
- package/dist/utils/tlsConfig/tlsConfig.validate.js.map +1 -1
- package/dist/utils/tlsRequest/index.js.map +1 -1
- package/dist/utils/tlsRequest/tlsRequest.js.map +1 -1
- package/dist/utils/trimPathSlash/index.js.map +1 -1
- package/dist/utils/trimPathSlash/trimPathSlash.js +4 -4
- package/dist/utils/trimPathSlash/trimPathSlash.js.map +1 -1
- package/eslint.config.mjs +11 -11
- package/package.json +159 -164
- package/src/const/DebeziumEvent.ts +6 -6
- package/src/const/LogSeverity.ts +7 -7
- package/src/const/index.ts +5 -5
- package/src/const/metrics.ts +6 -6
- package/src/const/mime.ts +37 -37
- package/src/const/tokenIssuer.ts +9 -9
- package/src/db/migrations/20241030121500-create-sequelize-meta-table.ts +29 -29
- package/src/db/models/SequelizeMeta.ts +16 -16
- package/src/db/models/index.ts +2 -2
- package/src/entities/ElasticSearch/ElasticSearch.ts +103 -103
- package/src/entities/ElasticSearch/ElasticSearch.types.ts +7 -7
- package/src/entities/ElasticSearch/index.ts +2 -2
- package/src/entities/Endpoint/Endpoint.test.ts +337 -337
- package/src/entities/Endpoint/Endpoint.ts +202 -202
- package/src/entities/Endpoint/Endpoint.types.ts +205 -205
- package/src/entities/Endpoint/index.ts +2 -2
- package/src/entities/EngineError/EngineError.ts +28 -28
- package/src/entities/EngineError/EngineError.types.ts +15 -15
- package/src/entities/EngineError/index.ts +2 -2
- package/src/entities/KeySet/KeySet.test.ts +126 -126
- package/src/entities/KeySet/KeySet.ts +172 -172
- package/src/entities/KeySet/KeySet.types.ts +28 -28
- package/src/entities/KeySet/index.ts +2 -2
- package/src/entities/LifecycleController/LifecycleController.test.ts +48 -48
- package/src/entities/LifecycleController/LifecycleController.ts +24 -24
- package/src/entities/LifecycleController/LifecycleController.types.ts +5 -5
- package/src/entities/LifecycleController/index.ts +2 -2
- package/src/entities/Localizator/Localizator.ts +139 -139
- package/src/entities/Localizator/Localizator.types.ts +52 -52
- package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.test.ts +165 -165
- package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.ts +58 -58
- package/src/entities/Localizator/guessNamingConvention/index.ts +1 -1
- package/src/entities/Localizator/index.ts +2 -2
- package/src/entities/MessageHandler/MessageHandler.test.ts +130 -130
- package/src/entities/MessageHandler/MessageHandler.ts +72 -72
- package/src/entities/MessageHandler/MessageHandler.types.ts +15 -15
- package/src/entities/MessageHandler/index.ts +2 -2
- package/src/entities/PubSub/PubSub.test.ts +297 -297
- package/src/entities/PubSub/PubSub.ts +202 -202
- package/src/entities/PubSub/PubSub.types.ts +76 -76
- package/src/entities/PubSub/handleMessage/handleMessage.test.ts +102 -102
- package/src/entities/PubSub/handleMessage/handleMessage.ts +65 -65
- package/src/entities/PubSub/handleMessage/index.ts +1 -1
- package/src/entities/PubSub/index.ts +2 -2
- package/src/entities/PushNotification/PushNotification.test.ts +35 -35
- package/src/entities/PushNotification/PushNotification.ts +44 -44
- package/src/entities/PushNotification/PushNotification.types.ts +25 -25
- package/src/entities/PushNotification/index.ts +2 -2
- package/src/entities/Redis/Redis.ts +71 -71
- package/src/entities/Redis/Redis.types.ts +19 -19
- package/src/entities/Redis/Redis.validate.ts +17 -17
- package/src/entities/Redis/index.ts +2 -2
- package/src/entities/Sequelize/Sequelize.config.ts +59 -59
- package/src/entities/Sequelize/Sequelize.test.ts +21 -21
- package/src/entities/Sequelize/Sequelize.ts +75 -75
- package/src/entities/Sequelize/Sequelize.types.ts +10 -10
- package/src/entities/Sequelize/Sequelize.validate.ts +15 -15
- package/src/entities/Sequelize/index.ts +2 -2
- package/src/entities/Server/Server.const.ts +56 -56
- package/src/entities/Server/Server.test.ts +272 -272
- package/src/entities/Server/Server.ts +445 -445
- package/src/entities/Server/Server.types.ts +88 -88
- package/src/entities/Server/index.ts +2 -2
- package/src/entities/SocketClient/SocketClient.test.ts +392 -392
- package/src/entities/SocketClient/SocketClient.ts +401 -401
- package/src/entities/SocketClient/SocketClient.types.ts +62 -62
- package/src/entities/SocketClient/index.ts +2 -2
- package/src/entities/SocketClient/parseMessage/index.ts +1 -1
- package/src/entities/SocketClient/parseMessage/parseMessage.test.ts +20 -20
- package/src/entities/SocketClient/parseMessage/parseMessage.ts +26 -26
- package/src/entities/Storage/Storage.test.ts +58 -58
- package/src/entities/Storage/Storage.ts +219 -219
- package/src/entities/Storage/Storage.types.ts +57 -57
- package/src/entities/Storage/index.ts +2 -2
- package/src/entities/ValidationError/ValidationError.ts +34 -34
- package/src/entities/ValidationError/index.ts +1 -1
- package/src/entities/WebError/WebError.test.ts +18 -18
- package/src/entities/WebError/WebError.ts +23 -23
- package/src/entities/WebError/WebError.types.ts +9 -9
- package/src/entities/WebError/index.ts +2 -2
- package/src/entities/index.ts +16 -16
- package/src/index.ts +4 -4
- package/src/metrics/debug.ts +10 -10
- package/src/metrics/index.ts +2 -2
- package/src/metrics/request.ts +17 -17
- package/src/middleware/authAdmin/authAdmin.test.ts +199 -199
- package/src/middleware/authAdmin/authAdmin.ts +114 -114
- package/src/middleware/authAdmin/authAdmin.types.ts +19 -19
- package/src/middleware/authAdmin/index.ts +2 -2
- package/src/middleware/authHmac/authHmac.test.ts +86 -86
- package/src/middleware/authHmac/authHmac.ts +56 -56
- package/src/middleware/authHmac/authHmac.types.ts +7 -7
- package/src/middleware/authHmac/index.ts +2 -2
- package/src/middleware/authJwt/authJwt.test.ts +54 -54
- package/src/middleware/authJwt/authJwt.ts +55 -55
- package/src/middleware/authJwt/authJwt.types.ts +14 -14
- package/src/middleware/authJwt/index.ts +2 -2
- package/src/middleware/authStatic/authStatic.test.ts +36 -36
- package/src/middleware/authStatic/authStatic.ts +45 -45
- package/src/middleware/authStatic/index.ts +1 -1
- package/src/middleware/authTls/authTls.test.ts +138 -138
- package/src/middleware/authTls/authTls.ts +106 -106
- package/src/middleware/authTls/authTls.types.ts +13 -13
- package/src/middleware/authTls/index.ts +2 -2
- package/src/middleware/checkPermission/checkPermission.ts +32 -32
- package/src/middleware/error/error.test.ts +60 -60
- package/src/middleware/error/error.ts +25 -25
- package/src/middleware/error/index.ts +1 -1
- package/src/middleware/fileUploader/compressAvatar/compressAvatar.ts +25 -25
- package/src/middleware/fileUploader/compressAvatar/compressAvatar.types.ts +12 -12
- package/src/middleware/fileUploader/compressAvatar/index.ts +2 -2
- package/src/middleware/fileUploader/fileUploader.test.ts +310 -310
- package/src/middleware/fileUploader/fileUploader.ts +303 -303
- package/src/middleware/fileUploader/fileUploader.types.ts +52 -52
- package/src/middleware/fileUploader/index.ts +2 -2
- package/src/middleware/fileUploader/isMultiPart/index.ts +1 -1
- package/src/middleware/fileUploader/isMultiPart/isMultipart.ts +9 -9
- package/src/middleware/fileUploader/validate/index.ts +1 -1
- package/src/middleware/fileUploader/validate/validate.ts +27 -27
- package/src/middleware/fourOhFour/fourOhFour.test.ts +14 -14
- package/src/middleware/fourOhFour/fourOhFour.ts +13 -13
- package/src/middleware/fourOhFour/index.ts +1 -1
- package/src/middleware/geminiFileUploader/geminiFileUploader.ts +117 -117
- package/src/middleware/geminiFileUploader/index.ts +1 -1
- package/src/middleware/healthCheck/healthCheck.test.ts +12 -12
- package/src/middleware/healthCheck/healthCheck.ts +14 -14
- package/src/middleware/healthCheck/index.ts +1 -1
- package/src/middleware/index.ts +17 -17
- package/src/middleware/metrics/index.ts +1 -1
- package/src/middleware/metrics/metrics.test.ts +46 -46
- package/src/middleware/metrics/metrics.ts +24 -24
- package/src/middleware/requestMetrics/index.ts +1 -1
- package/src/middleware/requestMetrics/requestMetrics.test.ts +77 -77
- package/src/middleware/requestMetrics/requestMetrics.ts +20 -20
- package/src/middleware/swaggerDocs/index.ts +2 -2
- package/src/middleware/swaggerDocs/swaggerDocs.ts +114 -114
- package/src/middleware/swaggerDocs/swaggerDocs.types.ts +41 -41
- package/src/middleware/userResolver/index.ts +1 -1
- package/src/middleware/userResolver/userResolver.test.ts +35 -35
- package/src/middleware/userResolver/userResolver.ts +35 -35
- package/src/middleware/validate/index.ts +1 -1
- package/src/middleware/validate/validate.test.ts +43 -43
- package/src/middleware/validate/validate.ts +25 -25
- package/src/middleware/version/index.ts +1 -1
- package/src/middleware/version/version.test.ts +23 -23
- package/src/middleware/version/version.ts +12 -12
- package/src/utils/checkEnvironment/index.ts +49 -49
- package/src/utils/createHttpServer/createHttpServer.test.ts +24 -24
- package/src/utils/createHttpServer/createHttpServer.ts +34 -34
- package/src/utils/createHttpServer/createHttpServer.validate.ts +17 -17
- package/src/utils/createHttpServer/index.ts +1 -1
- package/src/utils/createSortedObject/createSortedObject.ts +20 -20
- package/src/utils/createSortedObject/createSortedObjet.test.ts +47 -47
- package/src/utils/createSortedObject/index.ts +1 -1
- package/src/utils/dbMigration/dbMigration.test.ts +209 -209
- package/src/utils/dbMigration/dbMigration.ts +199 -199
- package/src/utils/dbMigration/dbMigration.types.ts +11 -11
- package/src/utils/dbMigration/index.ts +2 -2
- package/src/utils/dbMigration/migrateMetadataTable/index.ts +1 -1
- package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.test.ts +59 -59
- package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.ts +102 -102
- package/src/utils/envAssert/envAssert.ts +31 -31
- package/src/utils/envAssert/index.ts +1 -1
- package/src/utils/envAssert/validators/hostList.ts +17 -17
- package/src/utils/envAssert/validators/index.ts +5 -5
- package/src/utils/envAssert/validators/ipList.ts +13 -13
- package/src/utils/envAssert/validators/path.ts +13 -13
- package/src/utils/envAssert/validators/string.ts +9 -9
- package/src/utils/envAssert/validators/stringList.ts +13 -13
- package/src/utils/filter/filter.ts +17 -17
- package/src/utils/filter/index.ts +1 -1
- package/src/utils/getDynamicLink/getDynamicLink.test.ts +51 -51
- package/src/utils/getDynamicLink/getDynamicLink.ts +28 -28
- package/src/utils/getDynamicLink/getDynamicLink.types.ts +11 -11
- package/src/utils/getDynamicLink/getDynamicLink.validate.ts +6 -6
- package/src/utils/getDynamicLink/index.ts +2 -2
- package/src/utils/hmac/checkEnv/checkEnv.test.ts +18 -18
- package/src/utils/hmac/checkEnv/checkEnv.ts +9 -9
- package/src/utils/hmac/checkEnv/index.ts +1 -1
- package/src/utils/hmac/createHmac/createHmac.ts +33 -33
- package/src/utils/hmac/createHmac/index.ts +1 -1
- package/src/utils/hmac/index.ts +4 -4
- package/src/utils/hmac/index.types.ts +13 -13
- package/src/utils/hmac/signPayload/index.ts +1 -1
- package/src/utils/hmac/signPayload/signPayload.ts +16 -16
- package/src/utils/hmac/verifySignature/index.ts +1 -1
- package/src/utils/hmac/verifySignature/verifySignature.ts +24 -24
- package/src/utils/index.ts +26 -26
- package/src/utils/jwt/index.ts +2 -2
- package/src/utils/jwt/jwt.test.ts +41 -41
- package/src/utils/jwt/jwt.ts +204 -204
- package/src/utils/jwt/jwt.types.ts +21 -21
- package/src/utils/report/index.ts +3 -3
- package/src/utils/report/output.ts +45 -45
- package/src/utils/report/output.types.ts +70 -70
- package/src/utils/report/report.test.ts +133 -133
- package/src/utils/report/report.ts +134 -134
- package/src/utils/report/report.types.ts +13 -13
- package/src/utils/request/index.ts +1 -1
- package/src/utils/request/request.test.ts +26 -26
- package/src/utils/request/request.ts +48 -48
- package/src/utils/semverCompare/index.ts +1 -1
- package/src/utils/semverCompare/semverCompare.test.ts +49 -49
- package/src/utils/semverCompare/semverCompare.ts +60 -60
- package/src/utils/sendEmail/index.ts +1 -1
- package/src/utils/sendEmail/sendEmail.ts +27 -27
- package/src/utils/sendEmail/sendEmail.types.ts +7 -7
- package/src/utils/sendPush/index.ts +2 -2
- package/src/utils/sendPush/sendPush.ts +20 -20
- package/src/utils/sendPush/sendPush.types.ts +25 -25
- package/src/utils/tlsConfig/index.ts +2 -2
- package/src/utils/tlsConfig/tlsConfig.test.ts +32 -32
- package/src/utils/tlsConfig/tlsConfig.ts +47 -47
- package/src/utils/tlsConfig/tlsConfig.types.ts +11 -11
- package/src/utils/tlsConfig/tlsConfig.validate.ts +25 -25
- package/src/utils/tlsRequest/index.ts +1 -1
- package/src/utils/tlsRequest/tlsRequest.test.ts +63 -63
- package/src/utils/tlsRequest/tlsRequest.ts +12 -12
- package/src/utils/trimPathSlash/index.ts +1 -1
- package/src/utils/trimPathSlash/trimPathSlash.test.ts +26 -26
- package/src/utils/trimPathSlash/trimPathSlash.ts +8 -8
- package/test/env.ts +56 -56
- package/test/factory/index.ts +8 -8
- package/test/factory/sequelizeMeta.ts +12 -12
- package/test/hooks.ts +37 -37
- package/test/index.ts +3 -3
- package/test/stub/index.ts +3 -3
- package/test/stub/stubLocales.ts +68 -68
- package/test/stub/stubPubSub.ts +7 -7
- package/test/stub/stubStorage.ts +77 -77
- package/test/stub/stubStorage.types.ts +11 -11
- package/test/utils/app.ts +31 -31
- package/test/utils/index.ts +1 -1
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +32 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebError.js","names":["_const","require","_EngineError2","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","WebError","exports","_EngineError","config","_this","_classCallCheck2","severity","LogSeverity","WARNING","
|
|
1
|
+
{"version":3,"file":"WebError.js","names":["_const","require","_EngineError2","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","WebError","exports","_EngineError","config","_this","_classCallCheck2","severity","LogSeverity","WARNING","_defineProperty2","statusCode","errorCode","_inherits2","_createClass2","EngineError"],"sources":["../../../src/entities/WebError/WebError.ts"],"sourcesContent":["import { WebErrorOptions } from './WebError.types';\nimport { LogSeverity } from 'const';\nimport { EngineError } from 'entities/EngineError';\n\n/**\n * Error class used when errors should be reported to the client\n */\nexport class WebError extends EngineError {\n /** Machine readable error code that will be sent to the client */\n public errorCode: string;\n /** HTTP status code associated with this error */\n public statusCode: number;\n\n /**\n * Create a WebError, these errors are best suited for runtime errors\n */\n public constructor(config: WebErrorOptions) {\n super({ ...config, severity: config.severity ?? LogSeverity.WARNING });\n\n this.statusCode = config.statusCode ?? 400;\n this.errorCode = config.errorCode;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAAmD,SAAAE,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,CAAAC,OAAA,EAAAH,CAAA,OAAAI,2BAAA,CAAAD,OAAA,EAAAJ,CAAA,EAAAM,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAP,CAAA,EAAAC,CAAA,YAAAC,gBAAA,CAAAC,OAAA,EAAAJ,CAAA,EAAAS,WAAA,IAAAR,CAAA,CAAAS,KAAA,CAAAV,CAAA,EAAAE,CAAA;AAAA,SAAAI,0BAAA,cAAAN,CAAA,IAAAW,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAX,CAAA,aAAAM,yBAAA,YAAAA,CAAA,aAAAN,CAAA;AAEnD;AACA;AACA;AAFA,IAGae,QAAQ,GAAAC,OAAA,CAAAD,QAAA,0BAAAE,YAAA;EAMnB;AACF;AACA;EACE,SAAAF,SAAmBG,MAAuB,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAhB,OAAA,QAAAW,QAAA;IAC1CI,KAAA,GAAApB,UAAA,OAAAgB,QAAA,GAAM;MAAE,GAAGG,MAAM;MAAEG,QAAQ,EAAEH,MAAM,CAACG,QAAQ,IAAIC,kBAAW,CAACC;IAAQ,CAAC;IATvE;IAAA,IAAAC,gBAAA,CAAApB,OAAA,EAAAe,KAAA;IAEA;IAAA,IAAAK,gBAAA,CAAApB,OAAA,EAAAe,KAAA;IASEA,KAAA,CAAKM,UAAU,GAAGP,MAAM,CAACO,UAAU,IAAI,GAAG;IAC1CN,KAAA,CAAKO,SAAS,GAAGR,MAAM,CAACQ,SAAS;IAAC,OAAAP,KAAA;EACpC;EAAC,IAAAQ,UAAA,CAAAvB,OAAA,EAAAW,QAAA,EAAAE,YAAA;EAAA,WAAAW,aAAA,CAAAxB,OAAA,EAAAW,QAAA;AAAA,EAd2Bc,yBAAW","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebError.types.js","names":[],"sources":["../../../src/entities/WebError/WebError.types.ts"],"sourcesContent":["import { EngineErrorOptions } from 'entities/EngineError';\
|
|
1
|
+
{"version":3,"file":"WebError.types.js","names":[],"sources":["../../../src/entities/WebError/WebError.types.ts"],"sourcesContent":["import { EngineErrorOptions } from 'entities/EngineError';\n\n/** Options to create a Web Error */\nexport interface WebErrorOptions extends EngineErrorOptions {\n /** Machine readable error code that will be sent to the client */\n errorCode: string;\n /** HTTP status code associated with this error (default: 400) */\n statusCode?: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_WebError","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_WebError2"],"sources":["../../../src/entities/WebError/index.ts"],"sourcesContent":["export * from './WebError';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_WebError","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_WebError2"],"sources":["../../../src/entities/WebError/index.ts"],"sourcesContent":["export * from './WebError';\nexport * from './WebError.types';\n"],"mappings":";;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_EngineError","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_WebError","_ValidationError","_KeySet","_Endpoint","_MessageHandler","_SocketClient","_Server","_Redis","_Localizator","_Storage","_Sequelize","_ElasticSearch","_LifecycleController","_PubSub","_PushNotification"],"sources":["../../src/entities/index.ts"],"sourcesContent":["export * from './EngineError';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_EngineError","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_WebError","_ValidationError","_KeySet","_Endpoint","_MessageHandler","_SocketClient","_Server","_Redis","_Localizator","_Storage","_Sequelize","_ElasticSearch","_LifecycleController","_PubSub","_PushNotification"],"sources":["../../src/entities/index.ts"],"sourcesContent":["export * from './EngineError';\nexport * from './WebError';\nexport * from './ValidationError';\nexport * from './KeySet';\nexport * from './Endpoint';\nexport * from './MessageHandler';\nexport * from './SocketClient';\nexport * from './Server';\nexport * from './Redis';\nexport * from './Localizator';\nexport * from './Storage';\nexport * from './Sequelize';\nexport * from './ElasticSearch';\nexport * from './LifecycleController';\nexport * from './PubSub';\nexport * from './PushNotification';\n"],"mappings":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,SAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,SAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,SAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,SAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,gBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,gBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,gBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,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AAA;AAAAC,MAAA,CAAAC,IAAA,CAAAmB,oBAAA,EAAAlB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAiB,oBAAA,CAAAjB,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAa,oBAAA,CAAAjB,GAAA;IAAA;EAAA;AAAA;AACA,IAAAkB,OAAA,GAAAtB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAoB,OAAA,EAAAnB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAkB,OAAA,CAAAlB,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAc,OAAA,CAAAlB,GAAA;IAAA;EAAA;AAAA;AACA,IAAAmB,iBAAA,GAAAvB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAqB,iBAAA,EAAApB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAmB,iBAAA,CAAAnB,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAe,iBAAA,CAAAnB,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_const","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_entities","_utils","_middleware","_interopRequireWildcard","middleware","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set"],"sources":["../src/index.ts"],"sourcesContent":["export * from './const';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_const","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_entities","_utils","_middleware","_interopRequireWildcard","middleware","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set"],"sources":["../src/index.ts"],"sourcesContent":["export * from './const';\nexport * from './entities';\nexport * from './utils';\nexport * as middleware from './middleware';\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,SAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,SAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,SAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,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AA4B,wBAAA,WAAAC,CAAA,IAAAX,CAAA,oBAAAW,CAAA,OAAAxB,cAAA,CAAAC,IAAA,CAAAY,CAAA,EAAAW,CAAA,SAAAC,CAAA,GAAAH,CAAA,GAAA3B,MAAA,CAAA4B,wBAAA,CAAAV,CAAA,EAAAW,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAAnB,GAAA,IAAAmB,CAAA,CAAAC,GAAA,IAAA/B,MAAA,CAAAS,cAAA,CAAAgB,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","names":["_promClient","require","_const","debugActivated","exports","Gauge","name","help","registers","instanceRegistry","set","process","env","DEBUG","length"],"sources":["../../src/metrics/debug.ts"],"sourcesContent":["import { Gauge } from 'prom-client';\
|
|
1
|
+
{"version":3,"file":"debug.js","names":["_promClient","require","_const","debugActivated","exports","Gauge","name","help","registers","instanceRegistry","set","process","env","DEBUG","length"],"sources":["../../src/metrics/debug.ts"],"sourcesContent":["import { Gauge } from 'prom-client';\nimport { instanceRegistry } from 'const';\n\nexport const debugActivated = new Gauge({\n name: 'debug_activated',\n help: 'Debug is activated',\n registers: [instanceRegistry]\n});\n\ndebugActivated.set(process.env.DEBUG?.length ? 1 : 0);\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,IAAIE,iBAAK,CAAC;EACtCC,IAAI,EAAE,iBAAiB;EACvBC,IAAI,EAAE,oBAAoB;EAC1BC,SAAS,EAAE,CAACC,uBAAgB;AAC9B,CAAC,CAAC;AAEFN,cAAc,CAACO,GAAG,CAACC,OAAO,CAACC,GAAG,CAACC,KAAK,EAAEC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_request","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_debug"],"sources":["../../src/metrics/index.ts"],"sourcesContent":["export * from './request';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_request","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_debug"],"sources":["../../src/metrics/index.ts"],"sourcesContent":["export * from './request';\nexport * from './debug';\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","names":["_promClient","require","_const","httpRequestCount","exports","Counter","name","help","registers","instanceRegistry","labelNames","httpRequestDuration","Histogram","buckets"],"sources":["../../src/metrics/request.ts"],"sourcesContent":["import { Counter, Histogram } from 'prom-client';\
|
|
1
|
+
{"version":3,"file":"request.js","names":["_promClient","require","_const","httpRequestCount","exports","Counter","name","help","registers","instanceRegistry","labelNames","httpRequestDuration","Histogram","buckets"],"sources":["../../src/metrics/request.ts"],"sourcesContent":["import { Counter, Histogram } from 'prom-client';\nimport { instanceRegistry } from 'const';\n\nexport const httpRequestCount = new Counter({\n name: 'http_requests_total',\n help: 'Total count of request received',\n registers: [instanceRegistry],\n labelNames: ['service', 'path', 'method', 'status']\n});\n\nexport const httpRequestDuration = new Histogram({\n name: 'http_requests_duration',\n help: 'Duration of the request received',\n registers: [instanceRegistry],\n labelNames: ['service', 'path', 'method', 'status'],\n buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.5, 1, 2.5, 5, 10]\n});\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAIE,mBAAO,CAAC;EAC1CC,IAAI,EAAE,qBAAqB;EAC3BC,IAAI,EAAE,iCAAiC;EACvCC,SAAS,EAAE,CAACC,uBAAgB,CAAC;EAC7BC,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;AACpD,CAAC,CAAC;AAEK,MAAMC,mBAAmB,GAAAP,OAAA,CAAAO,mBAAA,GAAG,IAAIC,qBAAS,CAAC;EAC/CN,IAAI,EAAE,wBAAwB;EAC9BC,IAAI,EAAE,kCAAkC;EACxCC,SAAS,EAAE,CAACC,uBAAgB,CAAC;EAC7BC,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC;EACnDG,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;AACxE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authAdmin.js","names":["_const","require","_EngineError","_WebError","_utils","namespace","authAdmin","options","permission","EngineError","message","request","response","next","scheme","credentials","headers","authorization","split","toLowerCase","WebError","errorCode","statusCode","data","reportDebug","payload","jwtVerify","TokenIssuer","ADMIN_API","per","permissions","userPermissions","Array","endpointPermission","adminPermissions","checkUserPermissions","admin","email","sub","endpointPermissionParts","userPermissionLoop","permissionParts","length","i"],"sources":["../../../src/middleware/authAdmin/authAdmin.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\
|
|
1
|
+
{"version":3,"file":"authAdmin.js","names":["_const","require","_EngineError","_WebError","_utils","namespace","authAdmin","options","permission","EngineError","message","request","response","next","scheme","credentials","headers","authorization","split","toLowerCase","WebError","errorCode","statusCode","data","reportDebug","payload","jwtVerify","TokenIssuer","ADMIN_API","per","permissions","userPermissions","Array","endpointPermission","adminPermissions","checkUserPermissions","admin","email","sub","endpointPermissionParts","userPermissionLoop","permissionParts","length","i"],"sources":["../../../src/middleware/authAdmin/authAdmin.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\nimport { TokenIssuer } from 'const';\nimport { EndpointAuthParams, EndpointAuthType } from 'entities/Endpoint';\nimport { EngineError } from 'entities/EngineError';\nimport { WebError } from 'entities/WebError';\nimport { reportDebug, jwtVerify } from 'utils';\nimport {} from './authAdmin.types';\n\nconst namespace = 'engine:middleware:authAdmin';\n\n/** Generate a middleware to authenticate the client connection with a Admin api */\nexport function authAdmin(\n options: EndpointAuthParams<EndpointAuthType.ADMIN>\n): (request: Request, response: Response, next: NextFunction) => Promise<void> {\n if (!options.permission)\n throw new EngineError({\n message: 'Endpoint using admin auth type must specify permission'\n });\n return async (\n request: Request,\n response: Response,\n next: NextFunction\n ): Promise<void> => {\n const [scheme, credentials] =\n request.headers?.authorization?.split(' ') ?? [];\n // No bearer token has been sent\n if (!credentials || scheme.toLowerCase() !== 'bearer') {\n throw new WebError({\n errorCode: 'unauthorized',\n statusCode: 401,\n message: 'No bearer token found',\n data: { authorization: request.headers?.authorization }\n });\n }\n reportDebug({\n namespace,\n message: 'Performing JWT authentication',\n data: { scheme, credentials }\n });\n // Verify token and extract its payload\n const payload = await jwtVerify(credentials, TokenIssuer.ADMIN_API);\n reportDebug({\n namespace,\n message: 'Extracted user data from JWT',\n data: { payload, credentials }\n });\n\n if (!payload.per)\n throw new WebError({\n errorCode: 'unauthorized',\n statusCode: 401,\n message: `User token does not contain any permission claim`\n });\n\n // User Permission\n const permissions = payload.per;\n const userPermissions =\n permissions instanceof Array ? permissions : [permissions];\n\n reportDebug({\n namespace,\n message: 'Performing Admin Permission check',\n data: {\n permissions,\n endpointPermission: options.permission,\n adminPermissions: userPermissions\n }\n });\n\n if (!checkUserPermissions(userPermissions, options.permission)) {\n throw new WebError({\n errorCode: 'unauthorized',\n statusCode: 401,\n message: `User does not have required permission \"${options.permission}\"`,\n data: { userPermissions }\n });\n }\n\n // The user object on the request is hydrated with data from the token\n request.admin = {\n ...request.admin,\n email: payload.sub,\n permissions: userPermissions\n };\n\n next();\n };\n}\n\n/** */\nfunction checkUserPermissions(\n userPermissions: Array<string>,\n endpointPermission: string\n): boolean {\n const endpointPermissionParts = endpointPermission.split(':');\n userPermissionLoop: for (const permission of userPermissions) {\n const permissionParts = permission.split(':');\n\n // Ignore if both are not same length\n if (permissionParts.length !== endpointPermissionParts.length)\n continue userPermissionLoop;\n\n for (let i = 0; i < permissionParts.length; i++) {\n // Wildcards get automatic validation, otherwise it must match with the same part of the endpoint permission\n if (\n permissionParts[i] !== '*' &&\n permissionParts[i] !== endpointPermissionParts[i]\n )\n continue userPermissionLoop;\n }\n return true;\n }\n return false;\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GA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AC,EAAEA,CAAC,GAAGF,eAAe,CAACC,MAAM,EAAEC,CAAC,EAAE,EAAE;MAC/C;MACA,IACEF,eAAe,CAACE,CAAC,CAAC,KAAK,GAAG,IAC1BF,eAAe,CAACE,CAAC,CAAC,KAAKJ,uBAAuB,CAACI,CAAC,CAAC,EAEjD,SAASH,kBAAkB;IAC/B;IACA,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authAdmin.types.js","names":[],"sources":["../../../src/middleware/authAdmin/authAdmin.types.ts"],"sourcesContent":["// Override the Express request object to add the files\
|
|
1
|
+
{"version":3,"file":"authAdmin.types.js","names":[],"sources":["../../../src/middleware/authAdmin/authAdmin.types.ts"],"sourcesContent":["// Override the Express request object to add the files\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Express {\n /** Express request object */\n interface Request {\n /** User that identified using a JWT */\n admin?: RequestAdminProps;\n }\n }\n}\n\n/** Admin auth properties of the request */\nexport interface RequestAdminProps {\n /** Email address of the user */\n email: string;\n /** List of permissions that the user has */\n permissions: Array<string>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_authAdmin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_authAdmin2"],"sources":["../../../src/middleware/authAdmin/index.ts"],"sourcesContent":["export * from './authAdmin';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_authAdmin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_authAdmin2"],"sources":["../../../src/middleware/authAdmin/index.ts"],"sourcesContent":["export * from './authAdmin';\nexport * from './authAdmin.types';\n"],"mappings":";;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,UAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,UAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,UAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authHmac.js","names":["_WebError","require","_hmac","_report","namespace","authHmac","options","req","res","next","payload","method","query","body","signature","signatureSettings","isGithub","headers","substr","algorithm","sort","encode","settings","secret","WebError","message","errorCode","statusCode","reportDebug","data","verifySignature"],"sources":["../../../src/middleware/authHmac/authHmac.ts"],"sourcesContent":["import { BinaryToTextEncoding } from 'crypto';\
|
|
1
|
+
{"version":3,"file":"authHmac.js","names":["_WebError","require","_hmac","_report","namespace","authHmac","options","req","res","next","payload","method","query","body","signature","signatureSettings","isGithub","headers","substr","algorithm","sort","encode","settings","secret","WebError","message","errorCode","statusCode","reportDebug","data","verifySignature"],"sources":["../../../src/middleware/authHmac/authHmac.ts"],"sourcesContent":["import { BinaryToTextEncoding } from 'crypto';\nimport { Request, Response, NextFunction } from 'express';\nimport { HmacPayload } from './authHmac.types';\nimport { EndpointAuthParams, EndpointAuthType } from 'entities/Endpoint';\nimport { WebError } from 'entities/WebError';\nimport { verifySignature } from 'utils/hmac';\nimport { reportDebug } from 'utils/report';\n\nconst namespace = 'engine:middleware:authHmac';\n\n/** Generate an HMAC authentication middleware */\nexport function authHmac(\n options: EndpointAuthParams<EndpointAuthType.HMAC> = {}\n): (req: Request, res: Response, next: NextFunction) => void {\n return (req: Request, res: Response, next: NextFunction): void => {\n const payload = (\n req.method === 'GET' ? req.query : req.body\n ) as HmacPayload;\n let signature: string | undefined;\n let signatureSettings;\n if (options.isGithub) {\n // For GitHub, the signature is in the header and is has specific settings\n signature =\n req.headers['x-hub-signature'] &&\n (req.headers['x-hub-signature'] as string).substr(5);\n signatureSettings = {\n algorithm: 'sha1',\n sort: false,\n encode: 'hex' as BinaryToTextEncoding\n };\n } else {\n // In our standard authentication, the signature is included in the payload\n signature = payload.signature;\n delete payload.signature;\n }\n const settings = { secret: options.secret, ...signatureSettings };\n if (!signature)\n throw new WebError({\n message: 'No signature was provided',\n errorCode: 'unauthorized',\n statusCode: 401\n });\n reportDebug({\n namespace,\n message: 'Performing HMAC authentication',\n data: { payload, signature, settings }\n });\n if (!verifySignature(payload, signature, settings))\n throw new WebError({\n message: 'Signature does not match hmac of payload',\n errorCode: 'unauthorized',\n statusCode: 401\n });\n next();\n };\n}\n"],"mappings":";;;;;;AAIA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,MAAMG,SAAS,GAAG,4BAA4B;;AAE9C;AACO,SAASC,QAAQA,CACtBC,OAAkD,GAAG,CAAC,CAAC,EACI;EAC3D,OAAO,CAACC,GAAY,EAAEC,GAAa,EAAEC,IAAkB,KAAW;IAChE,MAAMC,OAAO,GACXH,GAAG,CAACI,MAAM,KAAK,KAAK,GAAGJ,GAAG,CAACK,KAAK,GAAGL,GAAG,CAACM,IACzB;IAChB,IAAIC,SAA6B;IACjC,IAAIC,iBAAiB;IACrB,IAAIT,OAAO,CAACU,QAAQ,EAAE;MACpB;MACAF,SAAS,GACPP,GAAG,CAACU,OAAO,CAAC,iBAAiB,CAAC,IAC7BV,GAAG,CAACU,OAAO,CAAC,iBAAiB,CAAC,CAAYC,MAAM,CAAC,CAAC,CAAC;MACtDH,iBAAiB,GAAG;QAClBI,SAAS,EAAE,MAAM;QACjBC,IAAI,EAAE,KAAK;QACXC,MAAM,EAAE;MACV,CAAC;IACH,CAAC,MAAM;MACL;MACAP,SAAS,GAAGJ,OAAO,CAACI,SAAS;MAC7B,OAAOJ,OAAO,CAACI,SAAS;IAC1B;IACA,MAAMQ,QAAQ,GAAG;MAAEC,MAAM,EAAEjB,OAAO,CAACiB,MAAM;MAAE,GAAGR;IAAkB,CAAC;IACjE,IAAI,CAACD,SAAS,EACZ,MAAM,IAAIU,kBAAQ,CAAC;MACjBC,OAAO,EAAE,2BAA2B;MACpCC,SAAS,EAAE,cAAc;MACzBC,UAAU,EAAE;IACd,CAAC,CAAC;IACJ,IAAAC,mBAAW,EAAC;MACVxB,SAAS;MACTqB,OAAO,EAAE,gCAAgC;MACzCI,IAAI,EAAE;QAAEnB,OAAO;QAAEI,SAAS;QAAEQ;MAAS;IACvC,CAAC,CAAC;IACF,IAAI,CAAC,IAAAQ,qBAAe,EAACpB,OAAO,EAAEI,SAAS,EAAEQ,QAAQ,CAAC,EAChD,MAAM,IAAIE,kBAAQ,CAAC;MACjBC,OAAO,EAAE,0CAA0C;MACnDC,SAAS,EAAE,cAAc;MACzBC,UAAU,EAAE;IACd,CAAC,CAAC;IACJlB,IAAI,CAAC,CAAC;EACR,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authHmac.types.js","names":[],"sources":["../../../src/middleware/authHmac/authHmac.types.ts"],"sourcesContent":["/** Options for HMAC auth */\
|
|
1
|
+
{"version":3,"file":"authHmac.types.js","names":[],"sources":["../../../src/middleware/authHmac/authHmac.types.ts"],"sourcesContent":["/** Options for HMAC auth */\nexport interface HmacPayload {\n /** Generic object payload */\n [key: string]: unknown;\n /** HMAC signature of the whole payload */\n signature?: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_authHmac","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_authHmac2"],"sources":["../../../src/middleware/authHmac/index.ts"],"sourcesContent":["export * from './authHmac';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_authHmac","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_authHmac2"],"sources":["../../../src/middleware/authHmac/index.ts"],"sourcesContent":["export * from './authHmac';\nexport * from './authHmac.types';\n"],"mappings":";;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authJwt.js","names":["_const","require","_EngineError","_WebError","_jwt","_report","namespace","authJwt","process","env","ACCESS_TOKEN_AUDIENCE","EngineError","message","request","response","next","scheme","credentials","headers","authorization","split","toLowerCase","WebError","errorCode","statusCode","data","reportDebug","payload","jwtVerify","TokenIssuer","AUTH_SERVICE","user"],"sources":["../../../src/middleware/authJwt/authJwt.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\
|
|
1
|
+
{"version":3,"file":"authJwt.js","names":["_const","require","_EngineError","_WebError","_jwt","_report","namespace","authJwt","process","env","ACCESS_TOKEN_AUDIENCE","EngineError","message","request","response","next","scheme","credentials","headers","authorization","split","toLowerCase","WebError","errorCode","statusCode","data","reportDebug","payload","jwtVerify","TokenIssuer","AUTH_SERVICE","user"],"sources":["../../../src/middleware/authJwt/authJwt.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\nimport { TokenIssuer } from 'const';\nimport { EngineError } from 'entities/EngineError';\nimport { WebError } from 'entities/WebError';\nimport { jwtVerify } from 'utils/jwt';\nimport { reportDebug } from 'utils/report';\nimport {} from './authJwt.types';\n\nconst namespace = 'engine:middleware:authJwt';\n\n/** Generate a middleware to authenticate the client connection with a JWT */\nexport function authJwt(): (\n request: Request,\n response: Response,\n next: NextFunction\n) => Promise<void> {\n if (!process.env.ACCESS_TOKEN_AUDIENCE)\n throw new EngineError({\n message: 'Env variable ACCESS_TOKEN_AUDIENCE is not defined'\n });\n\n return async (\n request: Request,\n response: Response,\n next: NextFunction\n ): Promise<void> => {\n const [scheme, credentials] =\n request.headers?.authorization?.split(' ') ?? [];\n // No bearer token has been sent\n if (!credentials || scheme.toLowerCase() !== 'bearer') {\n throw new WebError({\n message: 'No bearer token found',\n errorCode: 'unauthorized',\n statusCode: 401,\n data: { authorization: request.headers?.authorization }\n });\n }\n reportDebug({\n namespace,\n message: 'Performing JWT authentication',\n data: { scheme, credentials }\n });\n // Verify token and extract its payload\n const payload = await jwtVerify(credentials, TokenIssuer.AUTH_SERVICE);\n reportDebug({\n namespace,\n message: 'Extracted user data from JWT',\n data: { payload, credentials }\n });\n // The user object on the request is hydrated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CAAC,CAAC;IACF;IACAJ,OAAO,CAACkB,IAAI,GAAGJ,OAAO,CAACI,IAAI;IAE3BhB,IAAI,CAAC,CAAC;EACR,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authJwt.types.js","names":[],"sources":["../../../src/middleware/authJwt/authJwt.types.ts"],"sourcesContent":["export {};\
|
|
1
|
+
{"version":3,"file":"authJwt.types.js","names":[],"sources":["../../../src/middleware/authJwt/authJwt.types.ts"],"sourcesContent":["export {};\n\n// Override the Express request object to add the files\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Express {\n /** Express request object */\n interface Request {\n /** User that identified using a JWT */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n user?: Record<string, any>;\n }\n }\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_authJwt","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_authJwt2"],"sources":["../../../src/middleware/authJwt/index.ts"],"sourcesContent":["export * from './authJwt';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_authJwt","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_authJwt2"],"sources":["../../../src/middleware/authJwt/index.ts"],"sourcesContent":["export * from './authJwt';\nexport * from './authJwt.types';\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,SAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,SAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,SAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,SAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -8,9 +8,9 @@ var _WebError = require("../../entities/WebError");
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
const namespace = 'engine:middleware:authStatic';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* Generate a middleware to authenticate the client connection with a static token
|
|
13
|
-
* @return {Function}
|
|
11
|
+
/**
|
|
12
|
+
* Generate a middleware to authenticate the client connection with a static token
|
|
13
|
+
* @return {Function}
|
|
14
14
|
*/
|
|
15
15
|
function authStatic() {
|
|
16
16
|
(0, _utils.assertEnvironment)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authStatic.js","names":["_WebError","require","_utils","namespace","authStatic","assertEnvironment","STATIC_TOKEN","envAssert","isString","req","res","next","scheme","credentials","headers","authorization","split","toLowerCase","WebError","statusCode","errorCode","message","data","reportDebug","process","env"],"sources":["../../../src/middleware/authStatic/authStatic.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\
|
|
1
|
+
{"version":3,"file":"authStatic.js","names":["_WebError","require","_utils","namespace","authStatic","assertEnvironment","STATIC_TOKEN","envAssert","isString","req","res","next","scheme","credentials","headers","authorization","split","toLowerCase","WebError","statusCode","errorCode","message","data","reportDebug","process","env"],"sources":["../../../src/middleware/authStatic/authStatic.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\nimport { WebError } from 'entities/WebError';\nimport { assertEnvironment, envAssert, reportDebug } from 'utils';\n\nconst namespace = 'engine:middleware:authStatic';\n\n/**\n * Generate a middleware to authenticate the client connection with a static token\n * @return {Function}\n */\nexport function authStatic(): (\n req: Request,\n res: Response,\n next: NextFunction\n) => void {\n assertEnvironment({ STATIC_TOKEN: envAssert.isString() });\n\n return (req: Request, res: Response, next: NextFunction): void => {\n const [scheme, credentials] = req.headers?.authorization?.split(' ') ?? [];\n // No bearer token has been sent\n if (!credentials || scheme.toLowerCase() !== 'bearer') {\n throw new WebError({\n statusCode: 401,\n errorCode: 'unauthorized',\n message: 'No bearer token found',\n data: { authorization: req.headers?.authorization }\n });\n }\n reportDebug({\n namespace,\n message: 'Performing Static authentication',\n data: { scheme, credentials }\n });\n // Verify token\n if (credentials !== process.env.STATIC_TOKEN) {\n throw new WebError({\n statusCode: 401,\n errorCode: 'unauthorized',\n message: 'Invalid token supplied',\n data: { credentials }\n });\n }\n next();\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,SAAS,GAAG,8BAA8B;;AAEhD;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAAA,EAIhB;EACR,IAAAC,wBAAiB,EAAC;IAAEC,YAAY,EAAEC,gBAAS,CAACC,QAAQ,CAAC;EAAE,CAAC,CAAC;EAEzD,OAAO,CAACC,GAAY,EAAEC,GAAa,EAAEC,IAAkB,KAAW;IAChE,MAAM,CAACC,MAAM,EAAEC,WAAW,CAAC,GAAGJ,GAAG,CAACK,OAAO,EAAEC,aAAa,EAAEC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE;IAC1E;IACA,IAAI,CAACH,WAAW,IAAID,MAAM,CAACK,WAAW,CAAC,CAAC,KAAK,QAAQ,EAAE;MACrD,MAAM,IAAIC,kBAAQ,CAAC;QACjBC,UAAU,EAAE,GAAG;QACfC,SAAS,EAAE,cAAc;QACzBC,OAAO,EAAE,uBAAuB;QAChCC,IAAI,EAAE;UAAEP,aAAa,EAAEN,GAAG,CAACK,OAAO,EAAEC;QAAc;MACpD,CAAC,CAAC;IACJ;IACA,IAAAQ,kBAAW,EAAC;MACVpB,SAAS;MACTkB,OAAO,EAAE,kCAAkC;MAC3CC,IAAI,EAAE;QAAEV,MAAM;QAAEC;MAAY;IAC9B,CAAC,CAAC;IACF;IACA,IAAIA,WAAW,KAAKW,OAAO,CAACC,GAAG,CAACnB,YAAY,EAAE;MAC5C,MAAM,IAAIY,kBAAQ,CAAC;QACjBC,UAAU,EAAE,GAAG;QACfC,SAAS,EAAE,cAAc;QACzBC,OAAO,EAAE,wBAAwB;QACjCC,IAAI,EAAE;UAAET;QAAY;MACtB,CAAC,CAAC;IACJ;IACAF,IAAI,CAAC,CAAC;EACR,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_authStatic","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/middleware/authStatic/index.ts"],"sourcesContent":["export * from './authStatic';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_authStatic","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/middleware/authStatic/index.ts"],"sourcesContent":["export * from './authStatic';\n"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -13,14 +13,14 @@ var _report = require("../../utils/report");
|
|
|
13
13
|
require("./authTls.types");
|
|
14
14
|
const namespace = 'engine:middleware:authTls';
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Returns a middleware for TLS authentication
|
|
18
|
-
* Both client and server must have a certificate signed by the same CA
|
|
19
|
-
* Host name of the client is added to the express request object under 'request.user.host'
|
|
20
|
-
* A limited number of hosts can be specified with the environment variable ALLOWED_CLIENT_HOSTS
|
|
21
|
-
* @param {Object} options
|
|
22
|
-
* @param {Array<String>} options.whitelist - List of certificate Common Name or Alt Name that are permitted to make requests to this endpoint
|
|
23
|
-
* @return {Function}
|
|
16
|
+
/**
|
|
17
|
+
* Returns a middleware for TLS authentication
|
|
18
|
+
* Both client and server must have a certificate signed by the same CA
|
|
19
|
+
* Host name of the client is added to the express request object under 'request.user.host'
|
|
20
|
+
* A limited number of hosts can be specified with the environment variable ALLOWED_CLIENT_HOSTS
|
|
21
|
+
* @param {Object} options
|
|
22
|
+
* @param {Array<String>} options.whitelist - List of certificate Common Name or Alt Name that are permitted to make requests to this endpoint
|
|
23
|
+
* @return {Function}
|
|
24
24
|
*/
|
|
25
25
|
function authTls(options = {}) {
|
|
26
26
|
(0, _checkEnvironment.assertEnvironment)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authTls.js","names":["_WebError","require","_checkEnvironment","_envAssert","_report","namespace","authTls","options","assertEnvironment","TLS_SERVER_KEY","envAssert","isPath","TLS_SERVER_CERT","request","response","next","authTlsMiddleware","allowedClientHosts","loadEnv","process","env","ALLOWED_CLIENT_HOSTS","isHostList","split","map","value","trim","socket","authorized","WebError","errorCode","statusCode","message","clientCertificate","getPeerCertificate","subjects","subject","CN","push","subjectaltname","length","altNames","whitelist","reportDebug","data","certificate","allowed","includes","hosts"],"sources":["../../../src/middleware/authTls/authTls.ts"],"sourcesContent":["import { TLSSocket } from 'tls';\
|
|
1
|
+
{"version":3,"file":"authTls.js","names":["_WebError","require","_checkEnvironment","_envAssert","_report","namespace","authTls","options","assertEnvironment","TLS_SERVER_KEY","envAssert","isPath","TLS_SERVER_CERT","request","response","next","authTlsMiddleware","allowedClientHosts","loadEnv","process","env","ALLOWED_CLIENT_HOSTS","isHostList","split","map","value","trim","socket","authorized","WebError","errorCode","statusCode","message","clientCertificate","getPeerCertificate","subjects","subject","CN","push","subjectaltname","length","altNames","whitelist","reportDebug","data","certificate","allowed","includes","hosts"],"sources":["../../../src/middleware/authTls/authTls.ts"],"sourcesContent":["import { TLSSocket } from 'tls';\nimport { Request, Response, NextFunction } from 'express';\nimport { EndpointAuthParams, EndpointAuthType } from 'entities/Endpoint';\nimport { WebError } from 'entities/WebError';\nimport { assertEnvironment } from 'utils/checkEnvironment';\nimport { envAssert } from 'utils/envAssert';\nimport { reportDebug } from 'utils/report';\nimport {} from './authTls.types';\n\nconst namespace = 'engine:middleware:authTls';\n\n/**\n * Returns a middleware for TLS authentication\n * Both client and server must have a certificate signed by the same CA\n * Host name of the client is added to the express request object under 'request.user.host'\n * A limited number of hosts can be specified with the environment variable ALLOWED_CLIENT_HOSTS\n * @param {Object} options\n * @param {Array<String>} options.whitelist - List of certificate Common Name or Alt Name that are permitted to make requests to this endpoint\n * @return {Function}\n */\nexport function authTls(\n options: EndpointAuthParams<EndpointAuthType.TLS> = {}\n): (request: Request, response: Response, next: NextFunction) => void {\n assertEnvironment({\n TLS_SERVER_KEY: envAssert.isPath(),\n TLS_SERVER_CERT: envAssert.isPath()\n });\n\n return (request: Request, response: Response, next: NextFunction): void => {\n authTlsMiddleware(request, response, next, options);\n };\n}\n\nlet allowedClientHosts: Array<string> = [];\n\n/** Load TLS auth related environment variables */\nexport function loadEnv(): void {\n if (process.env.ALLOWED_CLIENT_HOSTS) {\n assertEnvironment({ ALLOWED_CLIENT_HOSTS: envAssert.isHostList() });\n allowedClientHosts = process.env.ALLOWED_CLIENT_HOSTS.split(',').map(\n (value) => value.trim()\n );\n } else {\n allowedClientHosts = [];\n }\n}\n\nloadEnv();\n\n/** Middleware that handles mTLS based authentication */\nexport function authTlsMiddleware(\n request: Request,\n response: Response,\n next: NextFunction,\n options: EndpointAuthParams<EndpointAuthType.TLS> = {}\n): void {\n const socket = request.socket as TLSSocket;\n // Check if the client's tls certificate is valid\n if (!socket?.authorized) {\n throw new WebError({\n errorCode: 'unauthorized',\n statusCode: 401,\n message: 'TLS certificate could not be validated'\n });\n }\n\n // Extract the subjects for the client certificate\n const clientCertificate = socket.getPeerCertificate();\n const subjects = [];\n if (clientCertificate.subject.CN) subjects.push(clientCertificate.subject.CN);\n if (clientCertificate.subjectaltname?.length) {\n const altNames = clientCertificate.subjectaltname\n .split(',')\n .map((subject) => subject.trim())\n .map((value) => value.split(':')[1]);\n subjects.push(...altNames);\n }\n\n const whitelist = options.whitelist ?? allowedClientHosts;\n reportDebug({\n namespace,\n message: 'Performing TLS authentication',\n data: { certificate: clientCertificate, whitelist, subjects }\n });\n // Check that the subject is authorized\n if (whitelist?.length) {\n let allowed = false;\n for (const subject of subjects) {\n if (whitelist.includes(subject)) {\n allowed = true;\n break;\n }\n }\n // Throw error if there is no subject in the whitelist\n if (!allowed)\n throw new WebError({\n errorCode: 'unauthorized',\n statusCode: 401,\n message: 'Client host is not in the whitelist',\n data: { subjects }\n });\n }\n // Pas subjects down\n request.hosts = subjects;\n next();\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACAA,OAAA;AAEA,MAAMI,SAAS,GAAG,2BAA2B;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CACrBC,OAAiD,GAAG,CAAC,CAAC,EACc;EACpE,IAAAC,mCAAiB,EAAC;IAChBC,cAAc,EAAEC,oBAAS,CAACC,MAAM,CAAC,CAAC;IAClCC,eAAe,EAAEF,oBAAS,CAACC,MAAM,CAAC;EACpC,CAAC,CAAC;EAEF,OAAO,CAACE,OAAgB,E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ChB,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEY,OAAO,IAAKA,OAAO,CAACV,IAAI,CAAC,CAAC,CAAC,CAChCF,GAAG,CAAEC,KAAK,IAAKA,KAAK,CAACF,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtCY,QAAQ,CAACG,IAAI,CAAC,GAAGG,QAAQ,CAAC;EAC5B;EAEA,MAAMC,SAAS,GAAGnC,OAAO,CAACmC,SAAS,IAAIzB,kBAAkB;EACzD,IAAA0B,mBAAW,EAAC;IACVtC,SAAS;IACT2B,OAAO,EAAE,+BAA+B;IACxCY,IAAI,EAAE;MAAEC,WAAW,EAAEZ,iBAAiB;MAAES,SAAS;MAAEP;IAAS;EAC9D,CAAC,CAAC;EACF;EACA,IAAIO,SAAS,EAAEF,MAAM,EAAE;IACrB,IAAIM,OAAO,GAAG,KAAK;IACnB,KAAK,MAAMV,OAAO,IAAID,QAAQ,EAAE;MAC9B,IAAIO,SAAS,CAACK,QAAQ,CAACX,OAAO,CAAC,EAAE;QAC/BU,OAAO,GAAG,IAAI;QACd;MACF;IACF;IACA;IACA,IAAI,CAACA,OAAO,EACV,MAAM,IAAIjB,kBAAQ,CAAC;MACjBC,SAAS,EAAE,cAAc;MACzBC,UAAU,EAAE,GAAG;MACfC,OAAO,EAAE,qCAAqC;MAC9CY,IAAI,EAAE;QAAET;MAAS;IACnB,CAAC,CAAC;EACN;EACA;EACAtB,OAAO,CAACmC,KAAK,GAAGb,QAAQ;EACxBpB,IAAI,CAAC,CAAC;AACR","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authTls.types.js","names":[],"sources":["../../../src/middleware/authTls/authTls.types.ts"],"sourcesContent":["// Override the Express request object to add the files\
|
|
1
|
+
{"version":3,"file":"authTls.types.js","names":[],"sources":["../../../src/middleware/authTls/authTls.types.ts"],"sourcesContent":["// Override the Express request object to add the files\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Express {\n /** Express HTTP request */\n interface Request {\n /** Host names provided by the mTLS authenticated client */\n hosts?: Array<string>;\n }\n }\n}\n\nexport {};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_authTls","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/middleware/authTls/index.ts"],"sourcesContent":["export * from './authTls';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_authTls","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/middleware/authTls/index.ts"],"sourcesContent":["export * from './authTls';\nexport {} from './authTls.types';\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACAJ,OAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkPermission.js","names":["checkPermission","requiredActions","req","res","next","user","permissions","status","json","message","requiredActionsArray","Array","isArray","requiredActionsLower","map","action","toLowerCase","hasPermission","some","permission","includes"],"sources":["../../../src/middleware/checkPermission/checkPermission.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\
|
|
1
|
+
{"version":3,"file":"checkPermission.js","names":["checkPermission","requiredActions","req","res","next","user","permissions","status","json","message","requiredActionsArray","Array","isArray","requiredActionsLower","map","action","toLowerCase","hasPermission","some","permission","includes"],"sources":["../../../src/middleware/checkPermission/checkPermission.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\n\n/** Middleware to check if the user has at least one of the required permissions (case-insensitive). */\nfunction checkPermission(requiredActions: string | string[]) {\n return function (req: Request, res: Response, next: NextFunction) {\n const user = req.user;\n\n if (!user || !user.permissions) {\n return res.status(403).json({ message: 'User does not have permissions' });\n }\n\n // Normalize input to an array of strings\n const requiredActionsArray = Array.isArray(requiredActions)\n ? requiredActions\n : [requiredActions];\n\n // Normalize required actions to lowercase\n const requiredActionsLower = requiredActionsArray.map(action => action.toLowerCase());\n\n // Check if the user has any of the required permissions (case-insensitive)\n const hasPermission = user.permissions.some((permission: string) =>\n requiredActionsLower.includes(permission.toLowerCase())\n );\n\n if (!hasPermission) {\n return res.status(403).json({ message: 'Permission denied' });\n }\n\n next();\n };\n}\n\nexport { checkPermission };"],"mappings":";;;;;;AAEA;AACA,SAASA,eAAeA,CAACC,eAAkC,EAAE;EAC3D,OAAO,UAAUC,GAAY,EAAEC,GAAa,EAAEC,IAAkB,EAAE;IAChE,MAAMC,IAAI,GAAGH,GAAG,CAACG,IAAI;IAErB,IAAI,CAACA,IAAI,IAAI,CAACA,IAAI,CAACC,WAAW,EAAE;MAC9B,OAAOH,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC;QAAEC,OAAO,EAAE;MAAiC,CAAC,CAAC;IAC5E;;IAEA;IACA,MAAMC,oBAAoB,GAAGC,KAAK,CAACC,OAAO,CAACX,eAAe,CAAC,GACvDA,eAAe,GACf,CAACA,eAAe,CAAC;;IAErB;IACA,MAAMY,oBAAoB,GAAGH,oBAAoB,CAACI,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,WAAW,CAAC,CAAC,CAAC;;IAErF;IACA,MAAMC,aAAa,GAAGZ,IAAI,CAACC,WAAW,CAACY,IAAI,CAAEC,UAAkB,IAC7DN,oBAAoB,CAACO,QAAQ,CAACD,UAAU,CAACH,WAAW,CAAC,CAAC,CACxD,CAAC;IAED,IAAI,CAACC,aAAa,EAAE;MAClB,OAAOd,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC;QAAEC,OAAO,EAAE;MAAoB,CAAC,CAAC;IAC/D;IAEAL,IAAI,CAAC,CAAC;EACR,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":["_WebError","require","_report","namespace","error","request","response","next","reportDebug","message","data","reportError","WebError","status","statusCode","json","errorCode","hint"],"sources":["../../../src/middleware/error/error.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\
|
|
1
|
+
{"version":3,"file":"error.js","names":["_WebError","require","_report","namespace","error","request","response","next","reportDebug","message","data","reportError","WebError","status","statusCode","json","errorCode","hint"],"sources":["../../../src/middleware/error/error.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\nimport { WebError } from 'entities/WebError';\nimport { reportError, reportDebug } from 'utils/report';\n\nconst namespace = 'engine:middleware:error';\n\n/** Handle errors globally */\nexport function error(\n error: Error,\n request: Request,\n response: Response,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n next: NextFunction\n): void {\n reportDebug({ namespace, message: 'Received error', data: { error } });\n reportError(error, request);\n if (error instanceof WebError) {\n response.status(error.statusCode).json({\n errorCode: error.errorCode,\n hint: error.hint\n });\n return;\n }\n response.status(500).json({ errorCode: 'server-error' });\n}\n"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,SAAS,GAAG,yBAAyB;;AAE3C;AACO,SAASC,KAAKA,CACnBA,KAAY,EACZC,OAAgB,EAChBC,QAAkB;AAClB;AACAC,IAAkB,EACZ;EACN,IAAAC,mBAAW,EAAC;IAAEL,SAAS;IAAEM,OAAO,EAAE,gBAAgB;IAAEC,IAAI,EAAE;MAAEN;IAAM;EAAE,CAAC,CAAC;EACtE,IAAAO,mBAAW,EAACP,KAAK,EAAEC,OAAO,CAAC;EAC3B,IAAID,KAAK,YAAYQ,kBAAQ,EAAE;IAC7BN,QAAQ,CAACO,MAAM,CAACT,KAAK,CAACU,UAAU,CAAC,CAACC,IAAI,CAAC;MACrCC,SAAS,EAAEZ,KAAK,CAACY,SAAS;MAC1BC,IAAI,EAAEb,KAAK,CAACa;IACd,CAAC,CAAC;IACF;EACF;EACAX,QAAQ,CAACO,MAAM,CAAC,GAAG,CAAC,CAACE,IAAI,CAAC;IAAEC,SAAS,EAAE;EAAe,CAAC,CAAC;AAC1D","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_error","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/middleware/error/index.ts"],"sourcesContent":["export * from './error';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_error","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/middleware/error/index.ts"],"sourcesContent":["export * from './error';\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.compressAvatar = compressAvatar;
|
|
8
8
|
var _sharp = _interopRequireDefault(require("sharp"));
|
|
9
|
-
/**
|
|
10
|
-
* Compress the user's avatar before uploading
|
|
9
|
+
/**
|
|
10
|
+
* Compress the user's avatar before uploading
|
|
11
11
|
*/
|
|
12
12
|
function compressAvatar(fileStream, options) {
|
|
13
13
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressAvatar.js","names":["_sharp","_interopRequireDefault","require","compressAvatar","fileStream","options","resize","height","width","quality","transform","sharp","fit","toFormat","pipe"],"sources":["../../../../src/middleware/fileUploader/compressAvatar/compressAvatar.ts"],"sourcesContent":["import { Readable } from 'stream';\
|
|
1
|
+
{"version":3,"file":"compressAvatar.js","names":["_sharp","_interopRequireDefault","require","compressAvatar","fileStream","options","resize","height","width","quality","transform","sharp","fit","toFormat","pipe"],"sources":["../../../../src/middleware/fileUploader/compressAvatar/compressAvatar.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport sharp from 'sharp';\nimport { CompressionOptions } from './compressAvatar.types';\n\n/**\n * Compress the user's avatar before uploading\n */\nexport function compressAvatar(\n fileStream: Readable,\n options: CompressionOptions\n): Readable {\n const {\n resize: { height, width },\n quality\n } = options;\n const transform = sharp()\n .resize(width, height, {\n fit: 'cover'\n })\n .toFormat('jpeg', {\n quality: quality\n });\n fileStream.pipe(transform);\n return fileStream;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA;AACA;AACA;AACO,SAASC,cAAcA,CAC5BC,UAAoB,EACpBC,OAA2B,EACjB;EACV,MAAM;IACJC,MAAM,EAAE;MAAEC,MAAM;MAAEC;IAAM,CAAC;IACzBC;EACF,CAAC,GAAGJ,OAAO;EACX,MAAMK,SAAS,GAAG,IAAAC,cAAK,EAAC,CAAC,CACtBL,MAAM,CAACE,KAAK,EAAED,MAAM,EAAE;IACrBK,GAAG,EAAE;EACP,CAAC,CAAC,CACDC,QAAQ,CAAC,MAAM,EAAE;IAChBJ,OAAO,EAAEA;EACX,CAAC,CAAC;EACJL,UAAU,CAACU,IAAI,CAACJ,SAAS,CAAC;EAC1B,OAAON,UAAU;AACnB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressAvatar.types.js","names":[],"sources":["../../../../src/middleware/fileUploader/compressAvatar/compressAvatar.types.ts"],"sourcesContent":["/** Options to compress image */\
|
|
1
|
+
{"version":3,"file":"compressAvatar.types.js","names":[],"sources":["../../../../src/middleware/fileUploader/compressAvatar/compressAvatar.types.ts"],"sourcesContent":["/** Options to compress image */\nexport interface CompressionOptions {\n /** Set dimensions in which the image will be resized */\n resize: {\n /** Height of the resized image */\n height: number;\n /** Width of the resized image */\n width: number;\n };\n /** JPG quality factor to apply when compressing */\n quality: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_compressAvatar","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_compressAvatar2"],"sources":["../../../../src/middleware/fileUploader/compressAvatar/index.ts"],"sourcesContent":["export * from './compressAvatar';\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_compressAvatar","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_compressAvatar2"],"sources":["../../../../src/middleware/fileUploader/compressAvatar/index.ts"],"sourcesContent":["export * from './compressAvatar';\nexport * from './compressAvatar.types';\n"],"mappings":";;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,eAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,gBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,gBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,gBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,gBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -15,8 +15,8 @@ var _WebError = require("../../entities/WebError");
|
|
|
15
15
|
var _report = require("../../utils/report");
|
|
16
16
|
const namespace = 'engine:middleware:fileUploader';
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Generate a custom fileUploader middleware
|
|
18
|
+
/**
|
|
19
|
+
* Generate a custom fileUploader middleware
|
|
20
20
|
*/
|
|
21
21
|
function fileUploader(options, validator) {
|
|
22
22
|
return (request, response, next) => fileUploaderMiddleware(request, response, next, options, validator);
|
|
@@ -53,9 +53,9 @@ function fileUploaderMiddleware(request, response, next, filesOptions, validator
|
|
|
53
53
|
});
|
|
54
54
|
let hasError = false;
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* Function called when an error happened in the process
|
|
58
|
-
* It immediately stops and drains all connection and deletes all files that have already been uploaded
|
|
56
|
+
/**
|
|
57
|
+
* Function called when an error happened in the process
|
|
58
|
+
* It immediately stops and drains all connection and deletes all files that have already been uploaded
|
|
59
59
|
*/
|
|
60
60
|
function triggerError(error) {
|
|
61
61
|
pendingWrites--;
|
|
@@ -100,15 +100,15 @@ function fileUploaderMiddleware(request, response, next, filesOptions, validator
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
/*
|
|
104
|
-
* On cancel request, while processing
|
|
103
|
+
/*
|
|
104
|
+
* On cancel request, while processing
|
|
105
105
|
*/
|
|
106
106
|
request.connection.on('close', function () {
|
|
107
107
|
if (!response.writableEnded) triggerError(new Error('Request cancelled'));
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
/**
|
|
111
|
-
* Once all the fields have been read they are checked against the validation schema
|
|
110
|
+
/**
|
|
111
|
+
* Once all the fields have been read they are checked against the validation schema
|
|
112
112
|
*/
|
|
113
113
|
async function validateFields() {
|
|
114
114
|
try {
|
|
@@ -257,9 +257,9 @@ function fileUploaderMiddleware(request, response, next, filesOptions, validator
|
|
|
257
257
|
});
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
/**
|
|
261
|
-
* Handle non file fields
|
|
262
|
-
* These fields will be pushed to the body as array of strings
|
|
260
|
+
/**
|
|
261
|
+
* Handle non file fields
|
|
262
|
+
* These fields will be pushed to the body as array of strings
|
|
263
263
|
*/
|
|
264
264
|
busboy.on('field', (fieldName, value) => {
|
|
265
265
|
if (!request.body) request.body = {};
|