node-server-engine 1.10.14 → 1.11.0
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/README.md +200 -1
- package/dist/entities/PubSub/handleMessage/handleMessage.js +1 -1
- package/dist/entities/PubSub/handleMessage/handleMessage.js.map +1 -1
- package/dist/entities/Redis/Redis.d.ts +66 -24
- package/dist/entities/Redis/Redis.js +272 -144
- package/dist/entities/Redis/Redis.js.map +1 -1
- package/dist/entities/Redis/index.d.ts +1 -1
- package/dist/entities/Redis/index.js +10 -38
- package/dist/entities/Redis/index.js.map +1 -1
- package/dist/entities/SecretManager/SecretManager.d.ts +87 -0
- package/dist/entities/SecretManager/SecretManager.js +385 -0
- package/dist/entities/SecretManager/SecretManager.js.map +1 -0
- package/dist/entities/SecretManager/SecretManager.types.d.ts +71 -0
- package/dist/entities/SecretManager/SecretManager.types.js +2 -0
- package/dist/entities/SecretManager/SecretManager.types.js.map +1 -0
- package/dist/entities/SecretManager/index.d.ts +2 -0
- package/dist/entities/SecretManager/index.js +28 -0
- package/dist/entities/SecretManager/index.js.map +1 -0
- package/dist/entities/Sequelize/Sequelize.js +5 -3
- package/dist/entities/Sequelize/Sequelize.js.map +1 -1
- package/dist/entities/Server/Server.d.ts +2 -0
- package/dist/entities/Server/Server.js +9 -0
- package/dist/entities/Server/Server.js.map +1 -1
- package/dist/entities/Server/Server.types.d.ts +3 -0
- package/dist/entities/Server/Server.types.js.map +1 -1
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.js +11 -0
- package/dist/entities/index.js.map +1 -1
- package/dist/middleware/requestMetrics/requestMetrics.js +15 -5
- package/dist/middleware/requestMetrics/requestMetrics.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -11
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/jwt/jwt.js +25 -2
- package/dist/utils/jwt/jwt.js.map +1 -1
- package/dist/utils/sendEmail/sendEmail.js +4 -2
- package/dist/utils/sendEmail/sendEmail.js.map +1 -1
- package/package.json +1 -1
- package/dist/utils/secretManager/index.d.ts +0 -2
- package/dist/utils/secretManager/index.js +0 -28
- package/dist/utils/secretManager/index.js.map +0 -1
- package/dist/utils/secretManager/secretLoader.d.ts +0 -8
- package/dist/utils/secretManager/secretLoader.js +0 -68
- package/dist/utils/secretManager/secretLoader.js.map +0 -1
- package/dist/utils/secretManager/secretResolver.d.ts +0 -5
- package/dist/utils/secretManager/secretResolver.js +0 -41
- package/dist/utils/secretManager/secretResolver.js.map +0 -1
|
@@ -20,6 +20,7 @@ var _Endpoint = require("../Endpoint");
|
|
|
20
20
|
var _EngineError = require("../EngineError");
|
|
21
21
|
var _LifecycleController = require("../LifecycleController");
|
|
22
22
|
var _PubSub = require("../PubSub");
|
|
23
|
+
var _SecretManager = require("../SecretManager");
|
|
23
24
|
var _utils = require("../../utils");
|
|
24
25
|
var _jwt = require("../../utils/jwt");
|
|
25
26
|
var _report = require("../../utils/report");
|
|
@@ -58,6 +59,8 @@ let Server = exports.Server = /*#__PURE__*/function () {
|
|
|
58
59
|
(0, _defineProperty2.default)(this, "cron", void 0);
|
|
59
60
|
/** Global auth related configuration */
|
|
60
61
|
(0, _defineProperty2.default)(this, "auth", void 0);
|
|
62
|
+
/** Secret Manager configuration */
|
|
63
|
+
(0, _defineProperty2.default)(this, "secretManagerConfig", void 0);
|
|
61
64
|
/** WebSocket server instance, if configured */
|
|
62
65
|
(0, _defineProperty2.default)(this, "wss", void 0);
|
|
63
66
|
/** Abort controller that handles signals for the server */
|
|
@@ -80,6 +83,7 @@ let Server = exports.Server = /*#__PURE__*/function () {
|
|
|
80
83
|
noFetch: false,
|
|
81
84
|
...config.auth
|
|
82
85
|
};
|
|
86
|
+
this.secretManagerConfig = config.secretManager;
|
|
83
87
|
|
|
84
88
|
// The minimal environment check is different between the migration modes of execution and the regular server execution mode
|
|
85
89
|
// When running in migration mode, we only check that we have SQL related environment variables
|
|
@@ -159,6 +163,11 @@ let Server = exports.Server = /*#__PURE__*/function () {
|
|
|
159
163
|
message: `Starting Server`
|
|
160
164
|
});
|
|
161
165
|
|
|
166
|
+
// Load secrets from Secret Manager FIRST (before anything else that might need them)
|
|
167
|
+
if (this.secretManagerConfig) {
|
|
168
|
+
await _SecretManager.SecretManager.init(this.secretManagerConfig);
|
|
169
|
+
}
|
|
170
|
+
|
|
162
171
|
// Fetch the keys for JWT authentication
|
|
163
172
|
// Ignore in test environment as we do symmetrical token signing
|
|
164
173
|
if (process.env.NODE_ENV !== 'test' && !this.auth.noFetch) await (0, _jwt.initKeySets)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.js","names":["_fs","_interopRequireDefault","require","_path","_promises","_express","_cors","_ws","_SocketClient","_Server2","_Endpoint","_EngineError","_LifecycleController","_PubSub","_utils","_jwt","_report","_tlsConfig","namespace","Server","exports","config","_classCallCheck2","default","_defineProperty2","AbortController","validate","reportDebug","message","endpoints","globalMiddleware","errorMiddleware","initCallbacks","shutdownCallbacks","syncCallbacks","cron","auth","noFetch","checkEnvironment","process","env","RUN_MIGRATION","UNDO_MIGRATION","SQL_HOST","envAssert","isHost","SQL_USER","isString","SQL_PASSWORD","SQL_DB","NODE_ENV","PORT","isPort","SECONDARY_PORT","app","express","use","cors","origin","CORS_ORIGIN","methods","allowedHeaders","registerMiddleware","httpServer","createHttpServer","secondaryApp","secondaryMiddleware","defaultErrorMiddleware","forEach","middleware","secondaryHttpServer","disable","server","headersTimeout","keepAliveTimeout","webSocket","attachWebSocket","_createClass2","key","value","setupGlobalErrorLogging","on","err","reportError","reportInfo","setTimeout","exit","reason","Error","String","init","initKeySets","callback","runCallback","Promise","all","map","PubSub","job","runCronJob","resolve","listen","data","port","secondaryPort","nodeEnv","handleSignal","watchTlsCaFileChange","shutdown","reject","listening","address","close","error","wss","clients","socket","socketKillTimeout","WEBSOCKET_CLOSE_TIMEOUT","parseInt","setTimeoutPromise","readyState","CLOSING","OPEN","terminate","LifecycleController","shutdownRunningInstances","abortController","abort","fileWatchers","watcher","shutdownKeySets","shutdownSignals","signal","removeAllListeners","getApp","getSecondaryApp","defaultMiddleware","path","endpoint","register","options","WebSocketServer","request","SocketClient","client","isShuttingDown","then","catch","file","fs","watch","event","loadTlsConfig","setSecureContext","tlsConfig","push","handler","name","interval","undefined","function","apply","parameters","some","Endpoint","EngineError","Object","values","validator","Array"],"sources":["../../../src/entities/Server/Server.ts"],"sourcesContent":["import fs from 'fs';\nimport http from 'http';\nimport https from 'https';\nimport { AddressInfo } from 'net';\nimport path from 'path';\nimport { setTimeout as setTimeoutPromise } from 'timers/promises';\nimport { ValidatorSpec } from 'envalid';\nimport express, { Application } from 'express';\nimport cors from 'cors';\nimport { Server as WebSocketServer } from 'ws';\nimport { SocketClient } from '../SocketClient';\nimport {\n defaultMiddleware,\n defaultErrorMiddleware,\n secondaryMiddleware,\n shutdownSignals\n} from './Server.const';\nimport {\n ServerOptions,\n ServerCronJon,\n ServerAuthConfig,\n ServerWebSocketConfig,\n ServerGlobalMiddleware,\n ServerErrorMiddleWare,\n ServerCallback\n} from './Server.types';\nimport { Endpoint } from 'entities/Endpoint';\nimport { EngineError } from 'entities/EngineError';\nimport { LifecycleController } from 'entities/LifecycleController';\nimport { PubSub } from 'entities/PubSub';\nimport { checkEnvironment, envAssert, createHttpServer } from 'utils';\nimport { initKeySets, shutdownKeySets } from 'utils/jwt';\nimport { reportInfo, reportError, reportDebug } from 'utils/report';\nimport { tlsConfig, loadTlsConfig, TlsConfig } from 'utils/tlsConfig';\n\nconst namespace = 'engine:Server';\n\n/** Main server class */\nexport class Server {\n /** The express application powering the main endpoints */\n private app: Application;\n /** The node HTTP(S) server, serving the main express application */\n private httpServer: http.Server | https.Server;\n /** The express application powering the support endpoints */\n private secondaryApp: Application;\n /** The node HTTP(S) server, serving the secondary express application */\n private secondaryHttpServer: http.Server | https.Server;\n /** List of endpoint instances that the server should handle */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private endpoints: Array<Endpoint<any>>;\n /** Mapping of env variable name with functions that should run to check their validity */\n private checkEnvironment: Record<string, ValidatorSpec<unknown>>;\n /** Middleware that should run on every request before the endpoint specific logic */\n private globalMiddleware: Array<ServerGlobalMiddleware>;\n /** Error middleware that should run on every request after the endpoint specific logic, but before the generic global middleware */\n private errorMiddleware: Array<\n ServerGlobalMiddleware | ServerErrorMiddleWare\n >;\n /** Functions that should be called on server startup */\n private initCallbacks: Array<ServerCallback>;\n /** Functions that should be called on server shutdown */\n private shutdownCallbacks: Array<ServerCallback>;\n /** When set to true, this indicates that init callbacks should run synchronously in the order they are declared. By default they all run in parallel */\n private syncCallbacks: boolean;\n /** Config to set regularly running jobs on the server */\n private cron?: Array<ServerCronJon>;\n /** Global auth related configuration */\n private auth: ServerAuthConfig;\n /** WebSocket server instance, if configured */\n private wss?: WebSocketServer;\n /** Abort controller that handles signals for the server */\n private abortController = new AbortController();\n /** File system watchers for TLS certificate changes */\n private fileWatchers: Array<fs.FSWatcher> = [];\n\n /** Create a server */\n public constructor(config: ServerOptions) {\n this.validate(config);\n\n reportDebug({\n namespace,\n message: `Creating server`\n });\n\n this.endpoints = config.endpoints;\n this.globalMiddleware = config.globalMiddleware ?? [];\n this.errorMiddleware = config.errorMiddleware ?? [];\n this.initCallbacks = config.initCallbacks ?? [];\n this.shutdownCallbacks = config.shutdownCallbacks ?? [];\n this.syncCallbacks = config.syncCallbacks ?? false;\n this.cron = config.cron;\n this.auth = { noFetch: false, ...config.auth };\n\n // The minimal environment check is different between the migration modes of execution and the regular server execution mode\n // When running in migration mode, we only check that we have SQL related environment variables\n this.checkEnvironment =\n process.env.RUN_MIGRATION === 'true' ||\n process.env.UNDO_MIGRATION === 'true'\n ? {\n SQL_HOST: envAssert.isHost(),\n SQL_USER: envAssert.isString(),\n SQL_PASSWORD: envAssert.isString(),\n SQL_DB: envAssert.isString()\n }\n : {\n NODE_ENV: envAssert.isString(),\n PORT: envAssert.isPort(),\n SECONDARY_PORT: envAssert.isPort(),\n ...config.checkEnvironment\n };\n\n checkEnvironment(this.checkEnvironment);\n\n // Create the primary express core that serves the business logic\n this.app = express();\n this.app.use(\n cors({\n origin: process.env.CORS_ORIGIN ?? '*',\n methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],\n allowedHeaders: ['Content-Type', 'Authorization']\n })\n );\n this.registerMiddleware(this.app);\n this.httpServer = createHttpServer(this.app);\n\n // Create a secondary express core that servers metrics and analytics\n // This will be served on a different port, allowing to specify different firewall rules for these routes\n this.secondaryApp = express();\n [...secondaryMiddleware, ...defaultErrorMiddleware].forEach(\n (middleware) => {\n if (middleware) this.secondaryApp.use(middleware);\n }\n );\n this.secondaryHttpServer = createHttpServer(this.secondaryApp);\n\n // Remove the express headers\n this.app.disable('x-powered-by');\n this.secondaryApp.disable('x-powered-by');\n\n // We remove all node timeout on connections and requests\n // This responsibility is delegated to the front-facing load balancer\n [this.httpServer, this.secondaryHttpServer].forEach((server) => {\n server.headersTimeout = 0;\n server.keepAliveTimeout = 0;\n });\n\n if (config.webSocket) {\n this.attachWebSocket(config.webSocket);\n }\n }\n\n /**\n * Setup global error handlers for uncaught exceptions and unhandled rejections\n */\n private setupGlobalErrorLogging(): void {\n process.on('uncaughtException', (err) => {\n reportError(err);\n reportInfo('💥 Uncaught exception - process will exit');\n // Give time for logs to flush before exiting\n setTimeout(() => process.exit(1), 1000);\n });\n \n process.on('unhandledRejection', (reason: unknown) => {\n reportError(reason instanceof Error ? reason : new Error(String(reason)));\n reportInfo('💥 Unhandled rejection - process will exit');\n // Give time for logs to flush before exiting\n setTimeout(() => process.exit(1), 1000);\n });\n }\n\n /** Start the server */\n public async init(): Promise<void> {\n this.setupGlobalErrorLogging();\n reportDebug({ namespace, message: `Starting Server` });\n \n // Fetch the keys for JWT authentication\n // Ignore in test environment as we do symmetrical token signing\n if (process.env.NODE_ENV !== 'test' && !this.auth.noFetch)\n await initKeySets();\n // Run all the init callbacks\n // We can either run them all 1/1 synchronously or run them all in parallel (default)\n // Callback can either be direct function or an object with function and parameters attributes\n\n if (this.syncCallbacks) {\n for (const callback of this.initCallbacks) {\n await this.runCallback(callback);\n }\n } else {\n await Promise.all(\n this.initCallbacks.map((callback) => this.runCallback(callback))\n );\n }\n\n // Initialize the Pub/Sub module\n await PubSub.init();\n // Run all the cronjob\n if (this.cron) {\n this.cron.forEach((job) => {\n this.runCronJob(job);\n });\n }\n\n // Start listening to requests\n await Promise.all([\n new Promise<void>((resolve) =>\n this.httpServer.listen(process.env.PORT, () => {\n resolve();\n })\n ),\n new Promise<void>((resolve) =>\n this.secondaryHttpServer.listen(process.env.SECONDARY_PORT, () => {\n resolve();\n })\n )\n ]);\n reportInfo({\n message: 'SERVER_RUNNING',\n data: {\n port: process.env.PORT,\n secondaryPort: process.env.SECONDARY_PORT,\n nodeEnv: process.env.NODE_ENV\n }\n });\n\n this.handleSignal();\n\n // Watch TSL config files changing\n this.watchTlsCaFileChange();\n }\n\n /** Graceful shutdown */\n public async shutdown(): Promise<void> {\n reportDebug({ namespace, message: `Shutting down Server` });\n\n // Stop listening to HTTP requests\n await Promise.all(\n [this.httpServer, this.secondaryHttpServer].map(\n (server) =>\n new Promise<void>((resolve, reject) => {\n // Ignore if the server was already stopped\n // We have observed cases where SIGTERM was thrown multiple times\n if (!server.listening) {\n resolve();\n return;\n }\n \n const { port } = server.address() as AddressInfo;\n \n server.close((error) => {\n if (error) {\n reportError(error);\n reject(error);\n } else {\n reportInfo({\n message: `Stopped listening to requests on port ${port}`\n });\n resolve();\n }\n });\n })\n )\n );\n\n // Close all socket connections\n if (this.wss) {\n // First ask them to close gracefully\n this.wss.clients.forEach((socket) => {\n socket.close();\n });\n \n // Hard terminate all connections still open after a defined time\n const socketKillTimeout = process.env.WEBSOCKET_CLOSE_TIMEOUT\n ? parseInt(process.env.WEBSOCKET_CLOSE_TIMEOUT, 10)\n : 5000;\n \n await setTimeoutPromise(socketKillTimeout);\n \n this.wss.clients.forEach((socket) => {\n if (\n socket.readyState === socket.CLOSING ||\n socket.readyState === socket.OPEN\n ) {\n socket.terminate();\n }\n });\n \n // Close the WebSocket server itself\n await new Promise<void>((resolve, reject) => {\n this.wss?.close((error) => {\n if (error) {\n reportError(error);\n reject(error);\n } else {\n reportInfo({ message: 'WebSocket server closed' });\n resolve();\n }\n });\n });\n }\n\n // Run all the shutdown callback\n if (this.syncCallbacks) {\n for (const callback of this.shutdownCallbacks) {\n await this.runCallback(callback);\n }\n } else {\n await Promise.all(\n this.shutdownCallbacks.map((callback) => this.runCallback(callback))\n );\n }\n\n // Shutdown all the running entities\n await LifecycleController.shutdownRunningInstances();\n\n // Abort all the cronjob\n if (this.abortController) this.abortController.abort();\n\n // Close all file watchers\n this.fileWatchers.forEach((watcher) => watcher.close());\n\n // Stop the keyset timers\n shutdownKeySets();\n\n shutdownSignals.forEach((signal) => process.removeAllListeners(signal));\n }\n\n /** Get the express app instance of the server */\n public getApp(): Application {\n return this.app;\n }\n\n /** Get the express app instance of the server */\n public getSecondaryApp(): Application {\n return this.secondaryApp;\n }\n\n /** Registers all the middleware with the express app */\n private registerMiddleware(app: Application): void {\n // Global middleware can specify a path to which they apply\n [...defaultMiddleware, ...this.globalMiddleware].forEach((middleware) => {\n if (typeof middleware === 'function') {\n app.use(middleware);\n } else {\n app.use(middleware.path, middleware.middleware);\n }\n });\n // Call the register method of each endpoint\n this.endpoints.forEach((endpoint) => {\n endpoint.register(app);\n });\n // Add error middleware\n [...this.errorMiddleware, ...defaultErrorMiddleware].forEach(\n (middleware) => {\n if (typeof middleware === 'function') {\n app.use(middleware);\n } else {\n app.use(middleware.path, middleware.middleware);\n }\n }\n );\n }\n\n /** Add a handler for WebSocket connections */\n private attachWebSocket(options: ServerWebSocketConfig): void {\n this.wss = new WebSocketServer({\n ...options.server,\n server: this.httpServer\n })\n .on('connection', (webSocket, request) => {\n new SocketClient(webSocket, request, options.client);\n })\n .on('error', (error) => {\n reportError(error);\n });\n }\n\n /** Call shutdown if signal gets sent to the process */\n private handleSignal(): void {\n let isShuttingDown = false;\n \n shutdownSignals.forEach((signal) =>\n process.on(signal, () => {\n // Prevent multiple shutdown attempts\n if (isShuttingDown) {\n reportInfo(`Already shutting down, ignoring ${signal}`);\n return;\n }\n \n isShuttingDown = true;\n reportInfo(`Received shutdown signal [${signal}]`);\n \n this.shutdown()\n .then(() => {\n reportInfo('Graceful shutdown completed successfully');\n process.exit(0);\n })\n .catch((error) => {\n reportError(error);\n process.exit(1);\n });\n })\n );\n }\n\n /** Watch the TLS certificate change event */\n private watchTlsCaFileChange(): void {\n [\n 'TLS_REQUEST_KEY',\n 'TLS_REQUEST_CERT',\n 'TLS_REQUEST_CA',\n 'TLS_SERVER_KEY',\n 'TLS_SERVER_CERT',\n 'TLS_CA'\n ].forEach((key) => {\n const file = process.env[key];\n if (file) {\n const watcher = fs.watch(path.resolve(file), (event) => {\n if (event !== 'change') return;\n reportInfo(`Reloading TLS config [${file} changed]`);\n loadTlsConfig();\n (this.httpServer as https.Server).setSecureContext(\n tlsConfig as TlsConfig\n );\n });\n this.fileWatchers.push(watcher);\n }\n });\n }\n\n /** Executes a recurring job */\n private runCronJob(job: ServerCronJon): void {\n (async (): Promise<void> => {\n reportInfo({ message: `Starting scheduled job \"${job.handler.name}\"` });\n try {\n await job.handler();\n reportInfo({\n message: `Job \"${job.handler.name}\" finished, starting again in ${job.interval} seconds`\n });\n await setTimeoutPromise(job.interval * 1000, undefined, {\n signal: this.abortController.signal\n });\n this.runCronJob(job);\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n reportDebug({\n namespace,\n message: `Scheduled job \"${job.handler?.name}\" has been aborted`\n });\n } else {\n throw error;\n }\n }\n })().catch((error) => {\n reportError(error);\n });\n }\n\n /** Run a shutdown/init callback */\n private runCallback(callback: ServerCallback): unknown {\n return typeof callback === 'function'\n ? callback()\n : callback.function.apply(null, callback.parameters ?? []);\n }\n\n /**\n * Validate the Server constructor configuration\n */\n private validate(config: ServerOptions): void {\n if (\n !config.endpoints ||\n config.endpoints.some((endpoint) => !(endpoint instanceof Endpoint))\n )\n throw new EngineError(\n 'Server endpoints should be declared and all be Endpoint instances'\n );\n\n if (\n config.checkEnvironment &&\n Object.values(config.checkEnvironment).some(\n (validator) => typeof validator !== 'function'\n )\n )\n throw new EngineError(\n 'Some of the environment checks are not valid functions'\n );\n\n if (\n config.initCallbacks &&\n (!(config.initCallbacks instanceof Array) ||\n config.initCallbacks.some(\n (callback) =>\n !(\n typeof callback === 'function' ||\n typeof callback?.function === 'function'\n )\n ))\n )\n throw new EngineError('Init callbacks is not a list of functions');\n\n if (\n config.shutdownCallbacks &&\n (!(config.shutdownCallbacks instanceof Array) ||\n config.shutdownCallbacks.some(\n (callback) =>\n !(\n typeof callback === 'function' ||\n typeof callback?.function === 'function'\n )\n ))\n )\n throw new EngineError('Shutdown callbacks is not a list of functions');\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,GAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAeA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,oBAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,IAAA,GAAAb,OAAA;AACA,IAAAc,OAAA,GAAAd,OAAA;AACA,IAAAe,UAAA,GAAAf,OAAA;AAEA,MAAMgB,SAAS,GAAG,eAAe;;AAEjC;AAAA,IACaC,MAAM,GAAAC,OAAA,CAAAD,MAAA;EAqCjB;EACA,SAAAA,OAAmBE,MAA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AAE,CAAC;IAC9D;;IAEA;AACF;AACA;EAFE;IAAArF,GAAA;IAAAC,KAAA,EAGA,SAAQrD,QAAQA,CAACL,MAAqB,EAAQ;MAC5C,IACE,CAACA,MAAM,CAACQ,SAAS,IACjBR,MAAM,CAACQ,SAAS,CAACuI,IAAI,CAAEzB,QAAQ,IAAK,EAAEA,QAAQ,YAAY0B,kBAAQ,CAAC,CAAC,EAEpE,MAAM,IAAIC,wBAAW,CACnB,mEACF,CAAC;MAEH,IACEjJ,MAAM,CAACiB,gBAAgB,IACvBiI,MAAM,CAACC,MAAM,CAACnJ,MAAM,CAACiB,gBAAgB,CAAC,CAAC8H,IAAI,CACxCK,SAAS,IAAK,OAAOA,SAAS,KAAK,UACtC,CAAC,EAED,MAAM,IAAIH,wBAAW,CACnB,wDACF,CAAC;MAEH,IACEjJ,MAAM,CAACW,aAAa,KACnB,EAAEX,MAAM,CAACW,aAAa,YAAY0I,KAAK,CAAC,IACvCrJ,MAAM,CAACW,aAAa,CAACoI,IAAI,CACtBxE,QAAQ,IACP,EACE,OAAOA,QAAQ,KAAK,UAAU,IAC9B,OAAOA,QAAQ,EAAEqE,QAAQ,KAAK,UAAU,CAE9C,CAAC,CAAC,EAEJ,MAAM,IAAIK,wBAAW,CAAC,2CAA2C,CAAC;MAEpE,IACEjJ,MAAM,CAACY,iBAAiB,KACvB,EAAEZ,MAAM,CAACY,iBAAiB,YAAYyI,KAAK,CAAC,IAC3CrJ,MAAM,CAACY,iBAAiB,CAACmI,IAAI,CAC1BxE,QAAQ,IACP,EACE,OAAOA,QAAQ,KAAK,UAAU,IAC9B,OAAOA,QAAQ,EAAEqE,QAAQ,KAAK,UAAU,CAE9C,CAAC,CAAC,EAEJ,MAAM,IAAIK,wBAAW,CAAC,+CAA+C,CAAC;IAC1E;EAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Server.js","names":["_fs","_interopRequireDefault","require","_path","_promises","_express","_cors","_ws","_SocketClient","_Server2","_Endpoint","_EngineError","_LifecycleController","_PubSub","_SecretManager","_utils","_jwt","_report","_tlsConfig","namespace","Server","exports","config","_classCallCheck2","default","_defineProperty2","AbortController","validate","reportDebug","message","endpoints","globalMiddleware","errorMiddleware","initCallbacks","shutdownCallbacks","syncCallbacks","cron","auth","noFetch","secretManagerConfig","secretManager","checkEnvironment","process","env","RUN_MIGRATION","UNDO_MIGRATION","SQL_HOST","envAssert","isHost","SQL_USER","isString","SQL_PASSWORD","SQL_DB","NODE_ENV","PORT","isPort","SECONDARY_PORT","app","express","use","cors","origin","CORS_ORIGIN","methods","allowedHeaders","registerMiddleware","httpServer","createHttpServer","secondaryApp","secondaryMiddleware","defaultErrorMiddleware","forEach","middleware","secondaryHttpServer","disable","server","headersTimeout","keepAliveTimeout","webSocket","attachWebSocket","_createClass2","key","value","setupGlobalErrorLogging","on","err","reportError","reportInfo","setTimeout","exit","reason","Error","String","init","SecretManager","initKeySets","callback","runCallback","Promise","all","map","PubSub","job","runCronJob","resolve","listen","data","port","secondaryPort","nodeEnv","handleSignal","watchTlsCaFileChange","shutdown","reject","listening","address","close","error","wss","clients","socket","socketKillTimeout","WEBSOCKET_CLOSE_TIMEOUT","parseInt","setTimeoutPromise","readyState","CLOSING","OPEN","terminate","LifecycleController","shutdownRunningInstances","abortController","abort","fileWatchers","watcher","shutdownKeySets","shutdownSignals","signal","removeAllListeners","getApp","getSecondaryApp","defaultMiddleware","path","endpoint","register","options","WebSocketServer","request","SocketClient","client","isShuttingDown","then","catch","file","fs","watch","event","loadTlsConfig","setSecureContext","tlsConfig","push","handler","name","interval","undefined","function","apply","parameters","some","Endpoint","EngineError","Object","values","validator","Array"],"sources":["../../../src/entities/Server/Server.ts"],"sourcesContent":["import fs from 'fs';\nimport http from 'http';\nimport https from 'https';\nimport { AddressInfo } from 'net';\nimport path from 'path';\nimport { setTimeout as setTimeoutPromise } from 'timers/promises';\nimport { ValidatorSpec } from 'envalid';\nimport express, { Application } from 'express';\nimport cors from 'cors';\nimport { Server as WebSocketServer } from 'ws';\nimport { SocketClient } from '../SocketClient';\nimport {\n defaultMiddleware,\n defaultErrorMiddleware,\n secondaryMiddleware,\n shutdownSignals\n} from './Server.const';\nimport {\n ServerOptions,\n ServerCronJon,\n ServerAuthConfig,\n ServerWebSocketConfig,\n ServerGlobalMiddleware,\n ServerErrorMiddleWare,\n ServerCallback\n} from './Server.types';\nimport { Endpoint } from 'entities/Endpoint';\nimport { EngineError } from 'entities/EngineError';\nimport { LifecycleController } from 'entities/LifecycleController';\nimport { PubSub } from 'entities/PubSub';\nimport { SecretManager } from 'entities/SecretManager';\nimport { checkEnvironment, envAssert, createHttpServer } from 'utils';\nimport { initKeySets, shutdownKeySets } from 'utils/jwt';\nimport { reportInfo, reportError, reportDebug } from 'utils/report';\nimport { tlsConfig, loadTlsConfig, TlsConfig } from 'utils/tlsConfig';\n\nconst namespace = 'engine:Server';\n\n/** Main server class */\nexport class Server {\n /** The express application powering the main endpoints */\n private app: Application;\n /** The node HTTP(S) server, serving the main express application */\n private httpServer: http.Server | https.Server;\n /** The express application powering the support endpoints */\n private secondaryApp: Application;\n /** The node HTTP(S) server, serving the secondary express application */\n private secondaryHttpServer: http.Server | https.Server;\n /** List of endpoint instances that the server should handle */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private endpoints: Array<Endpoint<any>>;\n /** Mapping of env variable name with functions that should run to check their validity */\n private checkEnvironment: Record<string, ValidatorSpec<unknown>>;\n /** Middleware that should run on every request before the endpoint specific logic */\n private globalMiddleware: Array<ServerGlobalMiddleware>;\n /** Error middleware that should run on every request after the endpoint specific logic, but before the generic global middleware */\n private errorMiddleware: Array<\n ServerGlobalMiddleware | ServerErrorMiddleWare\n >;\n /** Functions that should be called on server startup */\n private initCallbacks: Array<ServerCallback>;\n /** Functions that should be called on server shutdown */\n private shutdownCallbacks: Array<ServerCallback>;\n /** When set to true, this indicates that init callbacks should run synchronously in the order they are declared. By default they all run in parallel */\n private syncCallbacks: boolean;\n /** Config to set regularly running jobs on the server */\n private cron?: Array<ServerCronJon>;\n /** Global auth related configuration */\n private auth: ServerAuthConfig;\n /** Secret Manager configuration */\n private secretManagerConfig?: ServerOptions['secretManager'];\n /** WebSocket server instance, if configured */\n private wss?: WebSocketServer;\n /** Abort controller that handles signals for the server */\n private abortController = new AbortController();\n /** File system watchers for TLS certificate changes */\n private fileWatchers: Array<fs.FSWatcher> = [];\n\n /** Create a server */\n public constructor(config: ServerOptions) {\n this.validate(config);\n\n reportDebug({\n namespace,\n message: `Creating server`\n });\n\n this.endpoints = config.endpoints;\n this.globalMiddleware = config.globalMiddleware ?? [];\n this.errorMiddleware = config.errorMiddleware ?? [];\n this.initCallbacks = config.initCallbacks ?? [];\n this.shutdownCallbacks = config.shutdownCallbacks ?? [];\n this.syncCallbacks = config.syncCallbacks ?? false;\n this.cron = config.cron;\n this.auth = { noFetch: false, ...config.auth };\n this.secretManagerConfig = config.secretManager;\n\n // The minimal environment check is different between the migration modes of execution and the regular server execution mode\n // When running in migration mode, we only check that we have SQL related environment variables\n this.checkEnvironment =\n process.env.RUN_MIGRATION === 'true' ||\n process.env.UNDO_MIGRATION === 'true'\n ? {\n SQL_HOST: envAssert.isHost(),\n SQL_USER: envAssert.isString(),\n SQL_PASSWORD: envAssert.isString(),\n SQL_DB: envAssert.isString()\n }\n : {\n NODE_ENV: envAssert.isString(),\n PORT: envAssert.isPort(),\n SECONDARY_PORT: envAssert.isPort(),\n ...config.checkEnvironment\n };\n\n checkEnvironment(this.checkEnvironment);\n\n // Create the primary express core that serves the business logic\n this.app = express();\n this.app.use(\n cors({\n origin: process.env.CORS_ORIGIN ?? '*',\n methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],\n allowedHeaders: ['Content-Type', 'Authorization']\n })\n );\n this.registerMiddleware(this.app);\n this.httpServer = createHttpServer(this.app);\n\n // Create a secondary express core that servers metrics and analytics\n // This will be served on a different port, allowing to specify different firewall rules for these routes\n this.secondaryApp = express();\n [...secondaryMiddleware, ...defaultErrorMiddleware].forEach(\n (middleware) => {\n if (middleware) this.secondaryApp.use(middleware);\n }\n );\n this.secondaryHttpServer = createHttpServer(this.secondaryApp);\n\n // Remove the express headers\n this.app.disable('x-powered-by');\n this.secondaryApp.disable('x-powered-by');\n\n // We remove all node timeout on connections and requests\n // This responsibility is delegated to the front-facing load balancer\n [this.httpServer, this.secondaryHttpServer].forEach((server) => {\n server.headersTimeout = 0;\n server.keepAliveTimeout = 0;\n });\n\n if (config.webSocket) {\n this.attachWebSocket(config.webSocket);\n }\n }\n\n /**\n * Setup global error handlers for uncaught exceptions and unhandled rejections\n */\n private setupGlobalErrorLogging(): void {\n process.on('uncaughtException', (err) => {\n reportError(err);\n reportInfo('💥 Uncaught exception - process will exit');\n // Give time for logs to flush before exiting\n setTimeout(() => process.exit(1), 1000);\n });\n \n process.on('unhandledRejection', (reason: unknown) => {\n reportError(reason instanceof Error ? reason : new Error(String(reason)));\n reportInfo('💥 Unhandled rejection - process will exit');\n // Give time for logs to flush before exiting\n setTimeout(() => process.exit(1), 1000);\n });\n }\n\n /** Start the server */\n public async init(): Promise<void> {\n this.setupGlobalErrorLogging();\n reportDebug({ namespace, message: `Starting Server` });\n \n // Load secrets from Secret Manager FIRST (before anything else that might need them)\n if (this.secretManagerConfig) {\n await SecretManager.init(this.secretManagerConfig);\n }\n \n // Fetch the keys for JWT authentication\n // Ignore in test environment as we do symmetrical token signing\n if (process.env.NODE_ENV !== 'test' && !this.auth.noFetch)\n await initKeySets();\n // Run all the init callbacks\n // We can either run them all 1/1 synchronously or run them all in parallel (default)\n // Callback can either be direct function or an object with function and parameters attributes\n\n if (this.syncCallbacks) {\n for (const callback of this.initCallbacks) {\n await this.runCallback(callback);\n }\n } else {\n await Promise.all(\n this.initCallbacks.map((callback) => this.runCallback(callback))\n );\n }\n\n // Initialize the Pub/Sub module\n await PubSub.init();\n // Run all the cronjob\n if (this.cron) {\n this.cron.forEach((job) => {\n this.runCronJob(job);\n });\n }\n\n // Start listening to requests\n await Promise.all([\n new Promise<void>((resolve) =>\n this.httpServer.listen(process.env.PORT, () => {\n resolve();\n })\n ),\n new Promise<void>((resolve) =>\n this.secondaryHttpServer.listen(process.env.SECONDARY_PORT, () => {\n resolve();\n })\n )\n ]);\n reportInfo({\n message: 'SERVER_RUNNING',\n data: {\n port: process.env.PORT,\n secondaryPort: process.env.SECONDARY_PORT,\n nodeEnv: process.env.NODE_ENV\n }\n });\n\n this.handleSignal();\n\n // Watch TSL config files changing\n this.watchTlsCaFileChange();\n }\n\n /** Graceful shutdown */\n public async shutdown(): Promise<void> {\n reportDebug({ namespace, message: `Shutting down Server` });\n\n // Stop listening to HTTP requests\n await Promise.all(\n [this.httpServer, this.secondaryHttpServer].map(\n (server) =>\n new Promise<void>((resolve, reject) => {\n // Ignore if the server was already stopped\n // We have observed cases where SIGTERM was thrown multiple times\n if (!server.listening) {\n resolve();\n return;\n }\n \n const { port } = server.address() as AddressInfo;\n \n server.close((error) => {\n if (error) {\n reportError(error);\n reject(error);\n } else {\n reportInfo({\n message: `Stopped listening to requests on port ${port}`\n });\n resolve();\n }\n });\n })\n )\n );\n\n // Close all socket connections\n if (this.wss) {\n // First ask them to close gracefully\n this.wss.clients.forEach((socket) => {\n socket.close();\n });\n \n // Hard terminate all connections still open after a defined time\n const socketKillTimeout = process.env.WEBSOCKET_CLOSE_TIMEOUT\n ? parseInt(process.env.WEBSOCKET_CLOSE_TIMEOUT, 10)\n : 5000;\n \n await setTimeoutPromise(socketKillTimeout);\n \n this.wss.clients.forEach((socket) => {\n if (\n socket.readyState === socket.CLOSING ||\n socket.readyState === socket.OPEN\n ) {\n socket.terminate();\n }\n });\n \n // Close the WebSocket server itself\n await new Promise<void>((resolve, reject) => {\n this.wss?.close((error) => {\n if (error) {\n reportError(error);\n reject(error);\n } else {\n reportInfo({ message: 'WebSocket server closed' });\n resolve();\n }\n });\n });\n }\n\n // Run all the shutdown callback\n if (this.syncCallbacks) {\n for (const callback of this.shutdownCallbacks) {\n await this.runCallback(callback);\n }\n } else {\n await Promise.all(\n this.shutdownCallbacks.map((callback) => this.runCallback(callback))\n );\n }\n\n // Shutdown all the running entities\n await LifecycleController.shutdownRunningInstances();\n\n // Abort all the cronjob\n if (this.abortController) this.abortController.abort();\n\n // Close all file watchers\n this.fileWatchers.forEach((watcher) => watcher.close());\n\n // Stop the keyset timers\n shutdownKeySets();\n\n shutdownSignals.forEach((signal) => process.removeAllListeners(signal));\n }\n\n /** Get the express app instance of the server */\n public getApp(): Application {\n return this.app;\n }\n\n /** Get the express app instance of the server */\n public getSecondaryApp(): Application {\n return this.secondaryApp;\n }\n\n /** Registers all the middleware with the express app */\n private registerMiddleware(app: Application): void {\n // Global middleware can specify a path to which they apply\n [...defaultMiddleware, ...this.globalMiddleware].forEach((middleware) => {\n if (typeof middleware === 'function') {\n app.use(middleware);\n } else {\n app.use(middleware.path, middleware.middleware);\n }\n });\n // Call the register method of each endpoint\n this.endpoints.forEach((endpoint) => {\n endpoint.register(app);\n });\n // Add error middleware\n [...this.errorMiddleware, ...defaultErrorMiddleware].forEach(\n (middleware) => {\n if (typeof middleware === 'function') {\n app.use(middleware);\n } else {\n app.use(middleware.path, middleware.middleware);\n }\n }\n );\n }\n\n /** Add a handler for WebSocket connections */\n private attachWebSocket(options: ServerWebSocketConfig): void {\n this.wss = new WebSocketServer({\n ...options.server,\n server: this.httpServer\n })\n .on('connection', (webSocket, request) => {\n new SocketClient(webSocket, request, options.client);\n })\n .on('error', (error) => {\n reportError(error);\n });\n }\n\n /** Call shutdown if signal gets sent to the process */\n private handleSignal(): void {\n let isShuttingDown = false;\n \n shutdownSignals.forEach((signal) =>\n process.on(signal, () => {\n // Prevent multiple shutdown attempts\n if (isShuttingDown) {\n reportInfo(`Already shutting down, ignoring ${signal}`);\n return;\n }\n \n isShuttingDown = true;\n reportInfo(`Received shutdown signal [${signal}]`);\n \n this.shutdown()\n .then(() => {\n reportInfo('Graceful shutdown completed successfully');\n process.exit(0);\n })\n .catch((error) => {\n reportError(error);\n process.exit(1);\n });\n })\n );\n }\n\n /** Watch the TLS certificate change event */\n private watchTlsCaFileChange(): void {\n [\n 'TLS_REQUEST_KEY',\n 'TLS_REQUEST_CERT',\n 'TLS_REQUEST_CA',\n 'TLS_SERVER_KEY',\n 'TLS_SERVER_CERT',\n 'TLS_CA'\n ].forEach((key) => {\n const file = process.env[key];\n if (file) {\n const watcher = fs.watch(path.resolve(file), (event) => {\n if (event !== 'change') return;\n reportInfo(`Reloading TLS config [${file} changed]`);\n loadTlsConfig();\n (this.httpServer as https.Server).setSecureContext(\n tlsConfig as TlsConfig\n );\n });\n this.fileWatchers.push(watcher);\n }\n });\n }\n\n /** Executes a recurring job */\n private runCronJob(job: ServerCronJon): void {\n (async (): Promise<void> => {\n reportInfo({ message: `Starting scheduled job \"${job.handler.name}\"` });\n try {\n await job.handler();\n reportInfo({\n message: `Job \"${job.handler.name}\" finished, starting again in ${job.interval} seconds`\n });\n await setTimeoutPromise(job.interval * 1000, undefined, {\n signal: this.abortController.signal\n });\n this.runCronJob(job);\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n reportDebug({\n namespace,\n message: `Scheduled job \"${job.handler?.name}\" has been aborted`\n });\n } else {\n throw error;\n }\n }\n })().catch((error) => {\n reportError(error);\n });\n }\n\n /** Run a shutdown/init callback */\n private runCallback(callback: ServerCallback): unknown {\n return typeof callback === 'function'\n ? callback()\n : callback.function.apply(null, callback.parameters ?? []);\n }\n\n /**\n * Validate the Server constructor configuration\n */\n private validate(config: ServerOptions): void {\n if (\n !config.endpoints ||\n config.endpoints.some((endpoint) => !(endpoint instanceof Endpoint))\n )\n throw new EngineError(\n 'Server endpoints should be declared and all be Endpoint instances'\n );\n\n if (\n config.checkEnvironment &&\n Object.values(config.checkEnvironment).some(\n (validator) => typeof validator !== 'function'\n )\n )\n throw new EngineError(\n 'Some of the environment checks are not valid functions'\n );\n\n if (\n config.initCallbacks &&\n (!(config.initCallbacks instanceof Array) ||\n config.initCallbacks.some(\n (callback) =>\n !(\n typeof callback === 'function' ||\n typeof callback?.function === 'function'\n )\n ))\n )\n throw new EngineError('Init callbacks is not a list of functions');\n\n if (\n config.shutdownCallbacks &&\n (!(config.shutdownCallbacks instanceof Array) ||\n config.shutdownCallbacks.some(\n (callback) =>\n !(\n typeof callback === 'function' ||\n typeof callback?.function === 'function'\n )\n ))\n )\n throw new EngineError('Shutdown callbacks is not a list of functions');\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,GAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAeA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,oBAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,cAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,IAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AACA,IAAAgB,UAAA,GAAAhB,OAAA;AAEA,MAAMiB,SAAS,GAAG,eAAe;;AAEjC;AAAA,IACaC,MAAM,GAAAC,OAAA,CAAAD,MAAA;EAuCjB;EACA,SAAAA,OAAmBE,MAAqB,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAJ,MAAA;IAvC1C;IAAA,IAAAK,gBAAA,CAAAD,OAAA;IAEA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAEA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAEA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAEA;IACA;IA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Endpoint } from '../../entities/Endpoint';
|
|
5
5
|
import { SocketClientOptions } from '../../entities/SocketClient';
|
|
6
|
+
import { SecretManagerOptions } from '../../entities/SecretManager';
|
|
6
7
|
/** Options to create a server */
|
|
7
8
|
export interface ServerOptions {
|
|
8
9
|
/** List of endpoint instances that the server should handle */
|
|
@@ -25,6 +26,8 @@ export interface ServerOptions {
|
|
|
25
26
|
auth?: ServerAuthConfig;
|
|
26
27
|
/** Configuration to enable webSocket connections to the server */
|
|
27
28
|
webSocket?: ServerWebSocketConfig;
|
|
29
|
+
/** Configuration for GCP Secret Manager to load secrets at startup */
|
|
30
|
+
secretManager?: SecretManagerOptions;
|
|
28
31
|
}
|
|
29
32
|
/** Options for a CRON task on the server */
|
|
30
33
|
export interface ServerCronJon {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.types.js","names":[],"sources":["../../../src/entities/Server/Server.types.ts"],"sourcesContent":["import { ValidatorSpec } from 'envalid';\nimport { ErrorRequestHandler, RequestHandler } from 'express';\nimport { ServerOptions as WebSocketServerOptions } from 'ws';\nimport { Endpoint } from 'entities/Endpoint';\nimport { SocketClientOptions } from 'entities/SocketClient';\n\n/** Options to create a server */\nexport interface ServerOptions {\n /** List of endpoint instances that the server should handle */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n endpoints: Array<Endpoint<any>>;\n /** Mapping of env variable name with functions that should run to check their validity */\n checkEnvironment?: Record<string, ValidatorSpec<unknown>>;\n /** Middleware that should run on every request before the endpoint specific logic */\n globalMiddleware?: Array<ServerGlobalMiddleware>;\n /** Error middleware that should run on every request after the endpoint specific logic, but before the generic global middleware */\n errorMiddleware?: Array<ServerGlobalMiddleware | ServerErrorMiddleWare>;\n /** Functions that should be called on server startup */\n initCallbacks?: Array<ServerCallback>;\n /** Functions that should be called on server shutdown */\n shutdownCallbacks?: Array<ServerCallback>;\n /** When set to true, this indicates that init callbacks should run synchronously in the order they are declared. By default they all run in parallel */\n syncCallbacks?: boolean;\n /** Config to set regularly running jobs on the server */\n cron?: Array<ServerCronJon>;\n /** Global auth related configuration */\n auth?: ServerAuthConfig;\n /** Configuration to enable webSocket connections to the server */\n webSocket?: ServerWebSocketConfig;\n}\n\n/** Options for a CRON task on the server */\nexport interface ServerCronJon {\n /** Function that is called when the job needs to run */\n handler: () => unknown;\n /** Interval (in seconds) between each job execution. The interval starts after the previous execution finished */\n interval: number;\n /** When this is set, the job is only run on the instance that is that has been elected leader of the service */\n leaderOnly?: boolean;\n}\n\n/** Common server authentication related config */\nexport interface ServerAuthConfig {\n /** Do not fetch JWT authentication parameters, this should be used on servers that do not receive public requests and therefore do not need access to the authentication service */\n noFetch?: boolean;\n}\n\n/** Configuration for WebSocket on this server */\nexport interface ServerWebSocketConfig {\n /** Options to pass to create the webSocket server */\n server: WebSocketServerOptions;\n /** Options to pass when creating socket client instances */\n client: SocketClientOptions;\n}\n\n/** Middleware function definition with path */\nexport interface ServerObjectGlobalMiddleware {\n /** Path on which the middleware is used */\n path: string;\n /** Middleware function */\n middleware: RequestHandler;\n}\nexport type ServerGlobalMiddleware =\n | RequestHandler\n | ServerObjectGlobalMiddleware;\n\n/** Error middleware function definition with path */\nexport interface ServerObjectErrorMiddleware {\n /** Path on which the middleware is used */\n path: string;\n /** Middleware function */\n middleware: ErrorRequestHandler;\n}\nexport type ServerErrorMiddleWare =\n | ErrorRequestHandler\n | ServerObjectErrorMiddleware;\n\ntype ServerFunctionCallback = (...args: Array<unknown>) => unknown;\n\n/** Callback definition with parameters */\ninterface ServerObjectCallback {\n /** Callback function */\n function: ServerFunctionCallback;\n /** Parameters to pass to the callback function */\n parameters?: Parameters<ServerFunctionCallback>;\n}\n\nexport type ServerCallback = ServerFunctionCallback | ServerObjectCallback;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Server.types.js","names":[],"sources":["../../../src/entities/Server/Server.types.ts"],"sourcesContent":["import { ValidatorSpec } from 'envalid';\nimport { ErrorRequestHandler, RequestHandler } from 'express';\nimport { ServerOptions as WebSocketServerOptions } from 'ws';\nimport { Endpoint } from 'entities/Endpoint';\nimport { SocketClientOptions } from 'entities/SocketClient';\nimport { SecretManagerOptions } from 'entities/SecretManager';\n\n/** Options to create a server */\nexport interface ServerOptions {\n /** List of endpoint instances that the server should handle */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n endpoints: Array<Endpoint<any>>;\n /** Mapping of env variable name with functions that should run to check their validity */\n checkEnvironment?: Record<string, ValidatorSpec<unknown>>;\n /** Middleware that should run on every request before the endpoint specific logic */\n globalMiddleware?: Array<ServerGlobalMiddleware>;\n /** Error middleware that should run on every request after the endpoint specific logic, but before the generic global middleware */\n errorMiddleware?: Array<ServerGlobalMiddleware | ServerErrorMiddleWare>;\n /** Functions that should be called on server startup */\n initCallbacks?: Array<ServerCallback>;\n /** Functions that should be called on server shutdown */\n shutdownCallbacks?: Array<ServerCallback>;\n /** When set to true, this indicates that init callbacks should run synchronously in the order they are declared. By default they all run in parallel */\n syncCallbacks?: boolean;\n /** Config to set regularly running jobs on the server */\n cron?: Array<ServerCronJon>;\n /** Global auth related configuration */\n auth?: ServerAuthConfig;\n /** Configuration to enable webSocket connections to the server */\n webSocket?: ServerWebSocketConfig;\n /** Configuration for GCP Secret Manager to load secrets at startup */\n secretManager?: SecretManagerOptions;\n}\n\n/** Options for a CRON task on the server */\nexport interface ServerCronJon {\n /** Function that is called when the job needs to run */\n handler: () => unknown;\n /** Interval (in seconds) between each job execution. The interval starts after the previous execution finished */\n interval: number;\n /** When this is set, the job is only run on the instance that is that has been elected leader of the service */\n leaderOnly?: boolean;\n}\n\n/** Common server authentication related config */\nexport interface ServerAuthConfig {\n /** Do not fetch JWT authentication parameters, this should be used on servers that do not receive public requests and therefore do not need access to the authentication service */\n noFetch?: boolean;\n}\n\n/** Configuration for WebSocket on this server */\nexport interface ServerWebSocketConfig {\n /** Options to pass to create the webSocket server */\n server: WebSocketServerOptions;\n /** Options to pass when creating socket client instances */\n client: SocketClientOptions;\n}\n\n/** Middleware function definition with path */\nexport interface ServerObjectGlobalMiddleware {\n /** Path on which the middleware is used */\n path: string;\n /** Middleware function */\n middleware: RequestHandler;\n}\nexport type ServerGlobalMiddleware =\n | RequestHandler\n | ServerObjectGlobalMiddleware;\n\n/** Error middleware function definition with path */\nexport interface ServerObjectErrorMiddleware {\n /** Path on which the middleware is used */\n path: string;\n /** Middleware function */\n middleware: ErrorRequestHandler;\n}\nexport type ServerErrorMiddleWare =\n | ErrorRequestHandler\n | ServerObjectErrorMiddleware;\n\ntype ServerFunctionCallback = (...args: Array<unknown>) => unknown;\n\n/** Callback definition with parameters */\ninterface ServerObjectCallback {\n /** Callback function */\n function: ServerFunctionCallback;\n /** Parameters to pass to the callback function */\n parameters?: Parameters<ServerFunctionCallback>;\n}\n\nexport type ServerCallback = ServerFunctionCallback | ServerObjectCallback;\n"],"mappings":"","ignoreList":[]}
|
package/dist/entities/index.d.ts
CHANGED
package/dist/entities/index.js
CHANGED
|
@@ -190,4 +190,15 @@ Object.keys(_PushNotification).forEach(function (key) {
|
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
192
|
});
|
|
193
|
+
var _SecretManager = require("./SecretManager");
|
|
194
|
+
Object.keys(_SecretManager).forEach(function (key) {
|
|
195
|
+
if (key === "default" || key === "__esModule") return;
|
|
196
|
+
if (key in exports && exports[key] === _SecretManager[key]) return;
|
|
197
|
+
Object.defineProperty(exports, key, {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function () {
|
|
200
|
+
return _SecretManager[key];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
193
204
|
//# sourceMappingURL=index.js.map
|
|
@@ -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","_GoogleCloudStorage","_AWSS","_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 './GoogleCloudStorage';\nexport * from './AWSS3';\nexport * from './Sequelize';\nexport * from './ElasticSearch';\nexport * from './LifecycleController';\nexport * from './PubSub';\nexport * from './PushNotification';\
|
|
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","_GoogleCloudStorage","_AWSS","_Sequelize","_ElasticSearch","_LifecycleController","_PubSub","_PushNotification","_SecretManager"],"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 './GoogleCloudStorage';\nexport * from './AWSS3';\nexport * from './Sequelize';\nexport * from './ElasticSearch';\nexport * from './LifecycleController';\nexport * from './PubSub';\nexport * from './PushNotification';\nexport * from './SecretManager';"],"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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,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -21,7 +21,9 @@ const requestMetrics = (request, response, next) => {
|
|
|
21
21
|
// Increment in-flight
|
|
22
22
|
try {
|
|
23
23
|
_metrics.httpInFlight.inc();
|
|
24
|
-
} catch {
|
|
24
|
+
} catch {
|
|
25
|
+
// Ignore metric collection errors
|
|
26
|
+
}
|
|
25
27
|
|
|
26
28
|
// Ensure we decrement on finish/close (only once)
|
|
27
29
|
let inflightDecremented = false;
|
|
@@ -30,7 +32,9 @@ const requestMetrics = (request, response, next) => {
|
|
|
30
32
|
inflightDecremented = true;
|
|
31
33
|
try {
|
|
32
34
|
_metrics.httpInFlight.dec();
|
|
33
|
-
} catch {
|
|
35
|
+
} catch {
|
|
36
|
+
// Ignore metric collection errors
|
|
37
|
+
}
|
|
34
38
|
};
|
|
35
39
|
response.once('finish', () => {
|
|
36
40
|
// record errors
|
|
@@ -43,7 +47,9 @@ const requestMetrics = (request, response, next) => {
|
|
|
43
47
|
status: statusClass,
|
|
44
48
|
method: request.method
|
|
45
49
|
});
|
|
46
|
-
} catch {
|
|
50
|
+
} catch {
|
|
51
|
+
// Ignore metric collection errors
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
// observe response size if content-length header available
|
|
@@ -57,7 +63,9 @@ const requestMetrics = (request, response, next) => {
|
|
|
57
63
|
method: request.method,
|
|
58
64
|
status: statusClass
|
|
59
65
|
}, len);
|
|
60
|
-
} catch {
|
|
66
|
+
} catch {
|
|
67
|
+
// Ignore metric collection errors
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
cleanup();
|
|
63
71
|
});
|
|
@@ -74,7 +82,9 @@ const requestMetrics = (request, response, next) => {
|
|
|
74
82
|
try {
|
|
75
83
|
_metrics.httpRequestCount.inc(labels);
|
|
76
84
|
_metrics.httpRequestDuration.observe(labels, time / 1000);
|
|
77
|
-
} catch {
|
|
85
|
+
} catch {
|
|
86
|
+
// Ignore metric collection errors
|
|
87
|
+
}
|
|
78
88
|
});
|
|
79
89
|
|
|
80
90
|
// Call the response-time middleware which will call next when done
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestMetrics.js","names":["_responseTime","_interopRequireDefault","require","_metrics","excludedPrefixes","requestMetrics","request","response","next","path","route","prefix","startsWith","httpInFlight","inc","inflightDecremented","cleanup","dec","once","statusCode","statusClass","toString","substring","httpErrorCount","service","process","env","CHART","status","method","lenHeader","getHeader","len","parseInt","String","NaN","Number","isNaN","httpResponseSize","observe","rt","responseTime","req","res","time","labels","httpRequestCount","httpRequestDuration","exports"],"sources":["../../../src/middleware/requestMetrics/requestMetrics.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\nimport responseTime from 'response-time';\nimport {\n httpRequestCount,\n httpRequestDuration,\n httpInFlight,\n httpErrorCount,\n httpResponseSize\n} from 'metrics';\n\nconst excludedPrefixes = ['/swagger', '/docs', '/api-docs', '/metrics', '/favicon.ico', '/.well-known'];\n\n/** Composite middleware that tracks in-flight requests, errors, response size and timings */\nexport const requestMetrics = (request: Request, response: Response, next: NextFunction) => {\n const path = (request.route?.path ?? request.path) as string;\n\n // Skip operational/static routes\n for (const prefix of excludedPrefixes) {\n if (path.startsWith(prefix)) return next();\n }\n\n // Increment in-flight\n try {\n httpInFlight.inc();\n } catch {}\n\n // Ensure we decrement on finish/close (only once)\n let inflightDecremented = false;\n const cleanup = () => {\n if (inflightDecremented) return;\n inflightDecremented = true;\n try {\n httpInFlight.dec();\n } catch {}\n };\n\n response.once('finish', () => {\n // record errors\n const statusCode = response.statusCode ?? 0;\n const statusClass = statusCode ? `${statusCode.toString().substring(0, 1)}XX` : '';\n if (statusCode >= 400) {\n try {\n httpErrorCount.inc({ service: process.env.CHART, status: statusClass, method: request.method });\n } catch {}\n }\n\n // observe response size if content-length header available\n const lenHeader = response.getHeader('content-length');\n const len = lenHeader ? parseInt(String(lenHeader), 10) : NaN;\n if (!Number.isNaN(len)) {\n try {\n httpResponseSize.observe({ service: process.env.CHART, path, method: request.method, status: statusClass }, len);\n } catch {}\n }\n\n cleanup();\n });\n\n response.once('close', cleanup);\n\n // Use response-time to record duration and request counts\n const rt = responseTime((req: Request, res: Response, time: number) => {\n const labels = {\n path,\n method: request.method,\n status: res.statusCode ? `${res.statusCode.toString().substring(0, 1)}XX` : '',\n service: process.env.CHART || 'unknown'\n };\n\n try {\n httpRequestCount.inc(labels);\n httpRequestDuration.observe(labels, time / 1000);\n } catch {}\n });\n\n // Call the response-time middleware which will call next when done\n rt(request as Request, response as Response, next as NextFunction);\n};\n"],"mappings":";;;;;;;AACA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAQA,MAAME,gBAAgB,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,CAAC;;AAEvG;AACO,MAAMC,cAAc,GAAGA,CAACC,OAAgB,EAAEC,QAAkB,EAAEC,IAAkB,KAAK;EAC1F,MAAMC,IAAI,GAAIH,OAAO,CAACI,KAAK,EAAED,IAAI,IAAIH,OAAO,CAACG,IAAe;;EAE5D;EACA,KAAK,MAAME,MAAM,IAAIP,gBAAgB,EAAE;IACrC,IAAIK,IAAI,CAACG,UAAU,CAACD,MAAM,CAAC,EAAE,OAAOH,IAAI,CAAC,CAAC;EAC5C;;EAEA;EACA,IAAI;IACFK,qBAAY,CAACC,GAAG,CAAC,CAAC;EACpB,CAAC,CAAC,MAAM
|
|
1
|
+
{"version":3,"file":"requestMetrics.js","names":["_responseTime","_interopRequireDefault","require","_metrics","excludedPrefixes","requestMetrics","request","response","next","path","route","prefix","startsWith","httpInFlight","inc","inflightDecremented","cleanup","dec","once","statusCode","statusClass","toString","substring","httpErrorCount","service","process","env","CHART","status","method","lenHeader","getHeader","len","parseInt","String","NaN","Number","isNaN","httpResponseSize","observe","rt","responseTime","req","res","time","labels","httpRequestCount","httpRequestDuration","exports"],"sources":["../../../src/middleware/requestMetrics/requestMetrics.ts"],"sourcesContent":["import { Request, Response, NextFunction } from 'express';\nimport responseTime from 'response-time';\nimport {\n httpRequestCount,\n httpRequestDuration,\n httpInFlight,\n httpErrorCount,\n httpResponseSize\n} from 'metrics';\n\nconst excludedPrefixes = ['/swagger', '/docs', '/api-docs', '/metrics', '/favicon.ico', '/.well-known'];\n\n/** Composite middleware that tracks in-flight requests, errors, response size and timings */\nexport const requestMetrics = (request: Request, response: Response, next: NextFunction) => {\n const path = (request.route?.path ?? request.path) as string;\n\n // Skip operational/static routes\n for (const prefix of excludedPrefixes) {\n if (path.startsWith(prefix)) return next();\n }\n\n // Increment in-flight\n try {\n httpInFlight.inc();\n } catch {\n // Ignore metric collection errors\n }\n\n // Ensure we decrement on finish/close (only once)\n let inflightDecremented = false;\n const cleanup = () => {\n if (inflightDecremented) return;\n inflightDecremented = true;\n try {\n httpInFlight.dec();\n } catch {\n // Ignore metric collection errors\n }\n };\n\n response.once('finish', () => {\n // record errors\n const statusCode = response.statusCode ?? 0;\n const statusClass = statusCode ? `${statusCode.toString().substring(0, 1)}XX` : '';\n if (statusCode >= 400) {\n try {\n httpErrorCount.inc({ service: process.env.CHART, status: statusClass, method: request.method });\n } catch {\n // Ignore metric collection errors\n }\n }\n\n // observe response size if content-length header available\n const lenHeader = response.getHeader('content-length');\n const len = lenHeader ? parseInt(String(lenHeader), 10) : NaN;\n if (!Number.isNaN(len)) {\n try {\n httpResponseSize.observe({ service: process.env.CHART, path, method: request.method, status: statusClass }, len);\n } catch {\n // Ignore metric collection errors\n }\n }\n\n cleanup();\n });\n\n response.once('close', cleanup);\n\n // Use response-time to record duration and request counts\n const rt = responseTime((req: Request, res: Response, time: number) => {\n const labels = {\n path,\n method: request.method,\n status: res.statusCode ? `${res.statusCode.toString().substring(0, 1)}XX` : '',\n service: process.env.CHART || 'unknown'\n };\n\n try {\n httpRequestCount.inc(labels);\n httpRequestDuration.observe(labels, time / 1000);\n } catch {\n // Ignore metric collection errors\n }\n });\n\n // Call the response-time middleware which will call next when done\n rt(request as Request, response as Response, next as NextFunction);\n};\n"],"mappings":";;;;;;;AACA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAQA,MAAME,gBAAgB,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,CAAC;;AAEvG;AACO,MAAMC,cAAc,GAAGA,CAACC,OAAgB,EAAEC,QAAkB,EAAEC,IAAkB,KAAK;EAC1F,MAAMC,IAAI,GAAIH,OAAO,CAACI,KAAK,EAAED,IAAI,IAAIH,OAAO,CAACG,IAAe;;EAE5D;EACA,KAAK,MAAME,MAAM,IAAIP,gBAAgB,EAAE;IACrC,IAAIK,IAAI,CAACG,UAAU,CAACD,MAAM,CAAC,EAAE,OAAOH,IAAI,CAAC,CAAC;EAC5C;;EAEA;EACA,IAAI;IACFK,qBAAY,CAACC,GAAG,CAAC,CAAC;EACpB,CAAC,CAAC,MAAM;IACN;EAAA;;EAGF;EACA,IAAIC,mBAAmB,GAAG,KAAK;EAC/B,MAAMC,OAAO,GAAGA,CAAA,KAAM;IACpB,IAAID,mBAAmB,EAAE;IACzBA,mBAAmB,GAAG,IAAI;IAC1B,IAAI;MACFF,qBAAY,CAACI,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ,CAAC;EAEDV,QAAQ,CAACW,IAAI,CAAC,QAAQ,EAAE,MAAM;IAC5B;IACA,MAAMC,UAAU,GAAGZ,QAAQ,CAACY,UAAU,IAAI,CAAC;IAC3C,MAAMC,WAAW,GAAGD,UAAU,GAAG,GAAGA,UAAU,CAACE,QAAQ,CAAC,CAAC,CAACC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,EAAE;IAClF,IAAIH,UAAU,IAAI,GAAG,EAAE;MACrB,IAAI;QACFI,uBAAc,CAACT,GAAG,C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C5BE,4BAAmB,CAACR,OAAO,CAACM,MAAM,EAAED,IAAI,GAAG,IAAI,CAAC;IAClD,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ,CAAC,CAAC;;EAEF;EACAJ,EAAE,CAAClC,OAAO,EAAaC,QAAQ,EAAcC,IAAoB,CAAC;AACpE,CAAC;AAACwC,OAAA,CAAA3C,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -168,17 +168,6 @@ Object.keys(_trimPathSlash).forEach(function (key) {
|
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
});
|
|
171
|
-
var _secretManager = require("./secretManager");
|
|
172
|
-
Object.keys(_secretManager).forEach(function (key) {
|
|
173
|
-
if (key === "default" || key === "__esModule") return;
|
|
174
|
-
if (key in exports && exports[key] === _secretManager[key]) return;
|
|
175
|
-
Object.defineProperty(exports, key, {
|
|
176
|
-
enumerable: true,
|
|
177
|
-
get: function () {
|
|
178
|
-
return _secretManager[key];
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
171
|
var _geminiFileUpload = require("./geminiFileUpload");
|
|
183
172
|
Object.keys(_geminiFileUpload).forEach(function (key) {
|
|
184
173
|
if (key === "default" || key === "__esModule") return;
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_report","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_filter","_semverCompare","_dbMigration","_checkEnvironment","_envAssert","_createSortedObject","_jwt","_hmac","_createHttpServer","_request","_tlsConfig","_sendPush","_sendEmail","_trimPathSlash","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_report","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_filter","_semverCompare","_dbMigration","_checkEnvironment","_envAssert","_createSortedObject","_jwt","_hmac","_createHttpServer","_request","_tlsConfig","_sendPush","_sendEmail","_trimPathSlash","_geminiFileUpload"],"sources":["../../src/utils/index.ts"],"sourcesContent":["// general\nexport * from './report';\nexport * from './filter';\nexport * from './semverCompare';\nexport * from './dbMigration';\n\n// env\nexport * from './checkEnvironment';\nexport * from './envAssert';\n\n// auth\nexport * from './createSortedObject';\nexport * from './jwt';\nexport * from './hmac';\n\n// Networking\nexport * from './createHttpServer';\nexport * from './request';\nexport * from './tlsConfig';\nexport * from './sendPush';\nexport * from './sendEmail';\n\n// String manipulation\nexport * from './trimPathSlash';\n\n// File Upload\nexport * from './geminiFileUpload';\n"],"mappings":";;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,OAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,OAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,OAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,OAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,cAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,cAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAA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;EAAA;AAAA","ignoreList":[]}
|
package/dist/utils/jwt/jwt.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -9,6 +10,7 @@ exports.jwtVerify = jwtVerify;
|
|
|
9
10
|
exports.keySet = void 0;
|
|
10
11
|
exports.shutdownKeySets = shutdownKeySets;
|
|
11
12
|
var _jsonwebtoken = require("jsonwebtoken");
|
|
13
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
14
|
var _const = require("../../const");
|
|
13
15
|
var _EngineError = require("../../entities/EngineError");
|
|
14
16
|
var _KeySet = require("../../entities/KeySet");
|
|
@@ -16,7 +18,6 @@ var _WebError = require("../../entities/WebError");
|
|
|
16
18
|
var _checkEnvironment = require("../checkEnvironment");
|
|
17
19
|
var _envAssert = require("../envAssert");
|
|
18
20
|
var _report = require("../report");
|
|
19
|
-
var _ = require("./..");
|
|
20
21
|
let keySet = exports.keySet = void 0;
|
|
21
22
|
const namespace = 'engine:utils:jwt';
|
|
22
23
|
|
|
@@ -165,7 +166,29 @@ function generateJwtToken(user) {
|
|
|
165
166
|
audience: process.env.ACCESS_TOKEN_AUDIENCE,
|
|
166
167
|
keyid: Object.keys(keySet?.getKeys() ?? {})[0]
|
|
167
168
|
};
|
|
168
|
-
|
|
169
|
+
|
|
170
|
+
// Get private key - can be either the key content directly or a file path
|
|
171
|
+
let privateKey;
|
|
172
|
+
if (process.env.PRIVATE_KEY) {
|
|
173
|
+
// Direct key content in environment variable
|
|
174
|
+
privateKey = process.env.PRIVATE_KEY;
|
|
175
|
+
} else if (process.env.PRIVATE_KEY_PATH) {
|
|
176
|
+
// File path in environment variable - read the file
|
|
177
|
+
try {
|
|
178
|
+
privateKey = _fs.default.readFileSync(process.env.PRIVATE_KEY_PATH, 'utf8');
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw new _EngineError.EngineError({
|
|
181
|
+
message: `Failed to read private key from path: ${process.env.PRIVATE_KEY_PATH}`,
|
|
182
|
+
data: {
|
|
183
|
+
error: error instanceof Error ? error.message : String(error)
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
throw new _EngineError.EngineError({
|
|
189
|
+
message: 'Neither PRIVATE_KEY nor PRIVATE_KEY_PATH environment variable is set'
|
|
190
|
+
});
|
|
191
|
+
}
|
|
169
192
|
const token = (0, _jsonwebtoken.sign)({
|
|
170
193
|
user
|
|
171
194
|
}, privateKey, signOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.js","names":["_jsonwebtoken","require","_const","_EngineError","_KeySet","_WebError","_checkEnvironment","_envAssert","_report","_","keySet","exports","namespace","initKeySets","process","env","CHART","ECDSA_PUBLIC_KEY","EngineError","message","KeySet","file","AUTH_SERVICE_URL","internal","promise","init","bind","Promise","all","shutdownKeySets","shutdown","jwtGetKey","header","callback","NODE_ENV","JWT_SECRET","kid","data","reportDebug","key","getKey","error","Error","WebError","statusCode","errorCode","jwtVerify","token","issuer","TokenIssuer","AUTH_SERVICE","algorithms","assertEnvironment","envAssert","isString","ACCESS_TOKEN_AUDIENCE","ACCESS_TOKEN_ISSUER","ACCESS_TOKEN_EXPIRATION_TIME","options","audience","resolve","reject","verify","result","undefined","generateJwtToken","user","signOptions","algorithm","expiresIn","parseInt","keyid","Object","keys","getKeys","privateKey","getSecretOrFile","sign"],"sources":["../../../src/utils/jwt/jwt.ts"],"sourcesContent":["import {\n verify,\n JwtHeader,\n SigningKeyCallback,\n Algorithm,\n VerifyOptions,\n sign\n} from 'jsonwebtoken';\nimport { UserTokenPayload } from './jwt.types';\nimport { TokenIssuer } from 'const';\nimport { EngineError } from 'entities/EngineError';\nimport { KeySet } from 'entities/KeySet';\nimport { WebError } from 'entities/WebError';\nimport { assertEnvironment } from 'utils/checkEnvironment';\nimport { envAssert } from 'utils/envAssert';\nimport { reportDebug } from 'utils/report';\nimport { getSecretOrFile } from 'utils';\n\nexport let keySet: KeySet | undefined;\n\nconst namespace = 'engine:utils:jwt';\n\n/** Initiate key fetching mechanism */\nexport async function initKeySets(): Promise<void> {\n // Create the KeySet instance\n // The auth-service fetches its key from its disk and not from a network request\n // This prevents fetch failures the first time the auth-service is started\n if (process.env.CHART === 'auth-service') {\n if (!process.env.ECDSA_PUBLIC_KEY)\n throw new EngineError({\n message: 'Environment variable \"ECDSA_PUBLIC_KEY\" is not defined'\n });\n keySet = new KeySet(process.env.ECDSA_PUBLIC_KEY, { file: true });\n } else {\n if (process.env.AUTH_SERVICE_URL)\n keySet = new KeySet(\n `${process.env.AUTH_SERVICE_URL}/.well-known/jwks.json`,\n { internal: true }\n );\n else\n keySet = new KeySet(`./keys/jwks.json`, { internal: true, file: true });\n\n if (!keySet)\n throw new EngineError({\n message:\n 'Environment variable \"AUTH_SERVICE_URL\" is not defined or JWKS not found'\n });\n }\n const promise = [keySet.init.bind(keySet)()];\n\n await Promise.all(promise);\n}\n\n/** Stop fetching keys regularly */\nexport function shutdownKeySets(): void {\n if (keySet) keySet.shutdown.bind(keySet)();\n}\n\n/** Get the JWT public key */\nfunction jwtGetKey(header: JwtHeader, callback: SigningKeyCallback): void {\n // In test environment we return the symmetric signature secret\n if (process.env.NODE_ENV === 'test') {\n callback(null, process.env.JWT_SECRET);\n return;\n }\n // Check that KeySet has been initialized\n if (!keySet) {\n callback(new EngineError({ message: 'KeySet has not been initialized' }));\n return;\n }\n // Check that the token has a key ID\n if (!header.kid) {\n callback(\n new EngineError({\n message:\n 'Token has not key ID in header, impossible to match with known key',\n data: header\n })\n );\n return;\n }\n\n // In test environment we use a symmetrical secret bases signature\n if (process.env.NODE_ENV === 'test') {\n callback(null, process.env.JWT_SECRET);\n return;\n }\n reportDebug({\n namespace,\n message: `Looking for key with ID \"${header.kid}\"`\n });\n // Go through each key set to check if the token's key is in one of them\n let key;\n try {\n key = keySet.getKey(header.kid);\n } catch (error: Error | null | unknown) {\n callback(error instanceof Error ? error : null);\n return;\n }\n\n if (key) {\n reportDebug({ namespace, message: `Found key with ID \"${header.kid}\"` });\n callback(null, key);\n return;\n }\n callback(\n new WebError({\n statusCode: 401,\n errorCode: 'unauthorized',\n message: 'Could not find the tokens key in any key set',\n data: { kid: header.kid }\n })\n );\n}\n\n/** Verify an user Json Web Token */\nexport async function jwtVerify(\n token: string,\n issuer: TokenIssuer = TokenIssuer.AUTH_SERVICE\n): Promise<UserTokenPayload> {\n let algorithms = ['ES256' as Algorithm];\n if (process.env.NODE_ENV === 'test') {\n assertEnvironment({ JWT_SECRET: envAssert.isString() });\n algorithms = ['HS256' as Algorithm];\n }\n assertEnvironment({\n ACCESS_TOKEN_AUDIENCE: envAssert.isString(),\n ACCESS_TOKEN_ISSUER: envAssert.isString(),\n ACCESS_TOKEN_EXPIRATION_TIME: envAssert.isString()\n });\n let options: VerifyOptions | undefined;\n\n switch (issuer) {\n case TokenIssuer.AUTH_SERVICE:\n options = {\n audience: [process.env.ACCESS_TOKEN_AUDIENCE as string],\n issuer: [process.env.ACCESS_TOKEN_ISSUER as string],\n algorithms\n };\n break;\n default:\n throw new EngineError({\n message: `Invalid token issuer specified \"${issuer as string}\"`\n });\n }\n\n return new Promise<UserTokenPayload>((resolve, reject) => {\n verify(token, jwtGetKey, options, (error, result) => {\n if (error) {\n reject(\n new WebError({\n errorCode: 'unauthorized',\n statusCode: 401,\n message: 'Invalid token supplied',\n data: { token },\n error: error instanceof Error ? error : undefined\n })\n );\n return;\n }\n resolve(result as UserTokenPayload);\n });\n });\n}\n\nexport function generateJwtToken(user: unknown) {\n const signOptions = {\n algorithm: 'ES256' as const, // or 'ES256' as Algorithm\n expiresIn: process.env.ACCESS_TOKEN_EXPIRATION_TIME\n ? parseInt(process.env.ACCESS_TOKEN_EXPIRATION_TIME, 10)\n : 3600,\n issuer: process.env.ACCESS_TOKEN_ISSUER,\n audience: process.env.ACCESS_TOKEN_AUDIENCE,\n keyid: Object.keys(keySet?.getKeys() ?? {})[0]\n };\n\n const privateKey = getSecretOrFile('PRIVATE_KEY_PATH');\n\n const token = sign({ user }, privateKey, signOptions);\n\n return token;\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,CAAA,GAAAR,OAAA;AAEO,IAAIS,MAA0B,GAAAC,OAAA,CAAAD,MAAA;AAErC,MAAME,SAAS,GAAG,kBAAkB;;AAEpC;AACO,eAAeC,WAAWA,CAAA,EAAkB;EACjD;EACA;EACA;EACA,IAAIC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,cAAc,EAAE;IACxC,IAAI,CAACF,OAAO,CAACC,GAAG,CAACE,gBAAgB,EAC/B,MAAM,IAAIC,wBAAW,CAAC;MACpBC,OAAO,EAAE;IACX,CAAC,CAAC;IACJR,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAG,IAAIU,cAAM,CAACN,OAAO,CAACC,GAAG,CAACE,gBAAgB,EAAE;MAAEI,IAAI,EAAE;IAAK,CAAC,CAAC;EACnE,CAAC,MAAM;IACL,IAAIP,OAAO,CAACC,GAAG,CAACO,gBAAgB,EAC9BX,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAG,IAAIU,cAAM,CACjB,GAAGN,OAAO,CAACC,GAAG,CAACO,gBAAgB,wBAAwB,EACvD;MAAEC,QAAQ,EAAE;IAAK,CACnB,CAAC,CAAC,KAEFZ,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAG,IAAIU,cAAM,C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C,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;EAC/C,CAAC;EAED,MAAMC,UAAU,GAAG,IAAAC,iBAAe,EAAC,kBAAkB,CAAC;EAEtD,MAAM7B,KAAK,GAAG,IAAA8B,kBAAI,EAAC;IAAEX;EAAK,CAAC,EAAES,UAAU,EAAER,WAAW,CAAC;EAErD,OAAOpB,KAAK;AACd","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"jwt.js","names":["_jsonwebtoken","require","_fs","_interopRequireDefault","_const","_EngineError","_KeySet","_WebError","_checkEnvironment","_envAssert","_report","keySet","exports","namespace","initKeySets","process","env","CHART","ECDSA_PUBLIC_KEY","EngineError","message","KeySet","file","AUTH_SERVICE_URL","internal","promise","init","bind","Promise","all","shutdownKeySets","shutdown","jwtGetKey","header","callback","NODE_ENV","JWT_SECRET","kid","data","reportDebug","key","getKey","error","Error","WebError","statusCode","errorCode","jwtVerify","token","issuer","TokenIssuer","AUTH_SERVICE","algorithms","assertEnvironment","envAssert","isString","ACCESS_TOKEN_AUDIENCE","ACCESS_TOKEN_ISSUER","ACCESS_TOKEN_EXPIRATION_TIME","options","audience","resolve","reject","verify","result","undefined","generateJwtToken","user","signOptions","algorithm","expiresIn","parseInt","keyid","Object","keys","getKeys","privateKey","PRIVATE_KEY","PRIVATE_KEY_PATH","fs","readFileSync","String","sign"],"sources":["../../../src/utils/jwt/jwt.ts"],"sourcesContent":["import {\n verify,\n JwtHeader,\n SigningKeyCallback,\n Algorithm,\n VerifyOptions,\n sign\n} from 'jsonwebtoken';\nimport fs from 'fs';\nimport { UserTokenPayload } from './jwt.types';\nimport { TokenIssuer } from 'const';\nimport { EngineError } from 'entities/EngineError';\nimport { KeySet } from 'entities/KeySet';\nimport { WebError } from 'entities/WebError';\nimport { assertEnvironment } from 'utils/checkEnvironment';\nimport { envAssert } from 'utils/envAssert';\nimport { reportDebug } from 'utils/report';\n\nexport let keySet: KeySet | undefined;\n\nconst namespace = 'engine:utils:jwt';\n\n/** Initiate key fetching mechanism */\nexport async function initKeySets(): Promise<void> {\n // Create the KeySet instance\n // The auth-service fetches its key from its disk and not from a network request\n // This prevents fetch failures the first time the auth-service is started\n if (process.env.CHART === 'auth-service') {\n if (!process.env.ECDSA_PUBLIC_KEY)\n throw new EngineError({\n message: 'Environment variable \"ECDSA_PUBLIC_KEY\" is not defined'\n });\n keySet = new KeySet(process.env.ECDSA_PUBLIC_KEY, { file: true });\n } else {\n if (process.env.AUTH_SERVICE_URL)\n keySet = new KeySet(\n `${process.env.AUTH_SERVICE_URL}/.well-known/jwks.json`,\n { internal: true }\n );\n else\n keySet = new KeySet(`./keys/jwks.json`, { internal: true, file: true });\n\n if (!keySet)\n throw new EngineError({\n message:\n 'Environment variable \"AUTH_SERVICE_URL\" is not defined or JWKS not found'\n });\n }\n const promise = [keySet.init.bind(keySet)()];\n\n await Promise.all(promise);\n}\n\n/** Stop fetching keys regularly */\nexport function shutdownKeySets(): void {\n if (keySet) keySet.shutdown.bind(keySet)();\n}\n\n/** Get the JWT public key */\nfunction jwtGetKey(header: JwtHeader, callback: SigningKeyCallback): void {\n // In test environment we return the symmetric signature secret\n if (process.env.NODE_ENV === 'test') {\n callback(null, process.env.JWT_SECRET);\n return;\n }\n // Check that KeySet has been initialized\n if (!keySet) {\n callback(new EngineError({ message: 'KeySet has not been initialized' }));\n return;\n }\n // Check that the token has a key ID\n if (!header.kid) {\n callback(\n new EngineError({\n message:\n 'Token has not key ID in header, impossible to match with known key',\n data: header\n })\n );\n return;\n }\n\n // In test environment we use a symmetrical secret bases signature\n if (process.env.NODE_ENV === 'test') {\n callback(null, process.env.JWT_SECRET);\n return;\n }\n reportDebug({\n namespace,\n message: `Looking for key with ID \"${header.kid}\"`\n });\n // Go through each key set to check if the token's key is in one of them\n let key;\n try {\n key = keySet.getKey(header.kid);\n } catch (error: Error | null | unknown) {\n callback(error instanceof Error ? error : null);\n return;\n }\n\n if (key) {\n reportDebug({ namespace, message: `Found key with ID \"${header.kid}\"` });\n callback(null, key);\n return;\n }\n callback(\n new WebError({\n statusCode: 401,\n errorCode: 'unauthorized',\n message: 'Could not find the tokens key in any key set',\n data: { kid: header.kid }\n })\n );\n}\n\n/** Verify an user Json Web Token */\nexport async function jwtVerify(\n token: string,\n issuer: TokenIssuer = TokenIssuer.AUTH_SERVICE\n): Promise<UserTokenPayload> {\n let algorithms = ['ES256' as Algorithm];\n if (process.env.NODE_ENV === 'test') {\n assertEnvironment({ JWT_SECRET: envAssert.isString() });\n algorithms = ['HS256' as Algorithm];\n }\n assertEnvironment({\n ACCESS_TOKEN_AUDIENCE: envAssert.isString(),\n ACCESS_TOKEN_ISSUER: envAssert.isString(),\n ACCESS_TOKEN_EXPIRATION_TIME: envAssert.isString()\n });\n let options: VerifyOptions | undefined;\n\n switch (issuer) {\n case TokenIssuer.AUTH_SERVICE:\n options = {\n audience: [process.env.ACCESS_TOKEN_AUDIENCE as string],\n issuer: [process.env.ACCESS_TOKEN_ISSUER as string],\n algorithms\n };\n break;\n default:\n throw new EngineError({\n message: `Invalid token issuer specified \"${issuer as string}\"`\n });\n }\n\n return new Promise<UserTokenPayload>((resolve, reject) => {\n verify(token, jwtGetKey, options, (error, result) => {\n if (error) {\n reject(\n new WebError({\n errorCode: 'unauthorized',\n statusCode: 401,\n message: 'Invalid token supplied',\n data: { token },\n error: error instanceof Error ? error : undefined\n })\n );\n return;\n }\n resolve(result as UserTokenPayload);\n });\n });\n}\n\nexport function generateJwtToken(user: unknown) {\n const signOptions = {\n algorithm: 'ES256' as const, // or 'ES256' as Algorithm\n expiresIn: process.env.ACCESS_TOKEN_EXPIRATION_TIME\n ? parseInt(process.env.ACCESS_TOKEN_EXPIRATION_TIME, 10)\n : 3600,\n issuer: process.env.ACCESS_TOKEN_ISSUER,\n audience: process.env.ACCESS_TOKEN_AUDIENCE,\n keyid: Object.keys(keySet?.getKeys() ?? {})[0]\n };\n\n // Get private key - can be either the key content directly or a file path\n let privateKey: string;\n \n if (process.env.PRIVATE_KEY) {\n // Direct key content in environment variable\n privateKey = process.env.PRIVATE_KEY;\n } else if (process.env.PRIVATE_KEY_PATH) {\n // File path in environment variable - read the file\n try {\n privateKey = fs.readFileSync(process.env.PRIVATE_KEY_PATH, 'utf8');\n } catch (error) {\n throw new EngineError({\n message: `Failed to read private key from path: ${process.env.PRIVATE_KEY_PATH}`,\n data: { error: error instanceof Error ? error.message : String(error) }\n });\n }\n } else {\n throw new EngineError({ \n message: 'Neither PRIVATE_KEY nor PRIVATE_KEY_PATH environment variable is set' \n });\n }\n\n const token = sign({ user }, privateKey, signOptions);\n\n return token;\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAQA,IAAAC,GAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAEO,IAAIU,MAA0B,GAAAC,OAAA,CAAAD,MAAA;AAErC,MAAME,SAAS,GAAG,kBAAkB;;AAEpC;AACO,eAAeC,WAAWA,CAAA,EAAkB;EACjD;EACA;EACA;EACA,IAAIC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,cAAc,EAAE;IACxC,IAAI,CAACF,OAAO,CAACC,GAAG,CAACE,gBAAgB,EAC/B,MAAM,IAAIC,wBAAW,CAAC;MACpBC,OAAO,EAAE;IACX,CAAC,CAAC;IACJR,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAG,IAAIU,cAAM,CAACN,OAAO,CAACC,GAAG,CAACE,gBAAgB,EAAE;MAAEI,IAAI,EAAE;IAAK,CAAC,CAAC;EACnE,CAAC,MAAM;IACL,IAAIP,OAAO,CAACC,GAAG,CAACO,gBAAgB,EAC9BX,OAAA,CAAAD,MAA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ciphers: 'SSLv3',
|
|
27
|
+
rejectUnauthorized: false
|
|
28
|
+
},
|
|
29
|
+
requireTLS: true
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
// Construct email options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendEmail.js","names":["_nodemailer","_interopRequireDefault","require","sendEmail","emailOptions","transporter","nodemailer","createTransport","host","process","env","SMTP_HOST","port","parseInt","SMTP_PORT","secure","auth","user","SMTP_USER","pass","SMTP_PASS","tls","rejectUnauthorized","mailOptions","from","to","cc","bcc","subject","text","html","attachments","replyTo","headers","priority","info","sendMail","status","response","includes","messageId","error","message","exports"],"sources":["../../../src/utils/sendEmail/sendEmail.ts"],"sourcesContent":["import { EmailOptions, EmailResult, EmailStatus } from './sendEmail.types';\nimport nodemailer, {\n Transporter,\n SendMailOptions,\n SentMessageInfo\n} from 'nodemailer';\n\n/**\n * Sends an email using Nodemailer.\n * @param emailOptions - Configuration options for sending the email.\n * @returns A Promise that resolves with an EmailResult indicating success or failure.\n */\nexport const sendEmail = async (\n emailOptions: EmailOptions\n): Promise<EmailResult> => {\n try {\n // Create a transport with SMTP configuration\n const transporter: Transporter = nodemailer.createTransport({\n host: process.env.SMTP_HOST,\n port: parseInt(process.env.SMTP_PORT || '587', 10),\n secure: process.env.SMTP_PORT === '465' ? true : false,\n auth: {\n user: process.env.SMTP_USER,\n pass: process.env.SMTP_PASS\n },\n tls: {\n
|
|
1
|
+
{"version":3,"file":"sendEmail.js","names":["_nodemailer","_interopRequireDefault","require","sendEmail","emailOptions","transporter","nodemailer","createTransport","host","process","env","SMTP_HOST","port","parseInt","SMTP_PORT","secure","auth","user","SMTP_USER","pass","SMTP_PASS","tls","ciphers","rejectUnauthorized","requireTLS","mailOptions","from","to","cc","bcc","subject","text","html","attachments","replyTo","headers","priority","info","sendMail","status","response","includes","messageId","error","message","exports"],"sources":["../../../src/utils/sendEmail/sendEmail.ts"],"sourcesContent":["import { EmailOptions, EmailResult, EmailStatus } from './sendEmail.types';\nimport nodemailer, {\n Transporter,\n SendMailOptions,\n SentMessageInfo\n} from 'nodemailer';\n\n/**\n * Sends an email using Nodemailer.\n * @param emailOptions - Configuration options for sending the email.\n * @returns A Promise that resolves with an EmailResult indicating success or failure.\n */\nexport const sendEmail = async (\n emailOptions: EmailOptions\n): Promise<EmailResult> => {\n try {\n // Create a transport with SMTP configuration\n const transporter: Transporter = nodemailer.createTransport({\n host: process.env.SMTP_HOST,\n port: parseInt(process.env.SMTP_PORT || '587', 10),\n secure: process.env.SMTP_PORT === '465' ? true : false,\n auth: {\n user: process.env.SMTP_USER,\n pass: process.env.SMTP_PASS\n },\n tls: {\n ciphers: 'SSLv3',\n rejectUnauthorized: false\n },\n requireTLS: true\n });\n\n // Construct email options\n const mailOptions: SendMailOptions = {\n from: emailOptions.from,\n to: emailOptions.to,\n cc: emailOptions.cc,\n bcc: emailOptions.bcc,\n subject: emailOptions.subject,\n text: emailOptions.text,\n html: emailOptions.html,\n attachments: emailOptions.attachments,\n replyTo: emailOptions.replyTo,\n headers: emailOptions.headers,\n priority: emailOptions.priority\n };\n\n // Send email\n const info: SentMessageInfo = await transporter.sendMail(mailOptions);\n\n // Determine email status\n let status: EmailStatus = 'sent';\n if (info.response.includes('queued')) {\n status = 'queued';\n } else if (info.response.includes('delivered')) {\n status = 'delivered';\n }\n\n return { status, messageId: info.messageId };\n } catch (error) {\n return { status: 'failed', error: (error as Error).message };\n }\n};\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA;AACA;AACA;AACA;AACA;AACO,MAAMC,SAAS,GAAG,MACvBC,YAA0B,IACD;EACzB,IAAI;IACF;IACA,MAAMC,WAAwB,GAAGC,mBAAU,CAACC,eAAe,CAAC;MAC1DC,IAAI,EAAEC,OAAO,CAACC,GAAG,CAACC,SAAS;MAC3BC,IAAI,EAAEC,QAAQ,CAACJ,OAAO,CAACC,GAAG,CAACI,SAAS,IAAI,KAAK,EAA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