{"_id":"@amora95/commons","_rev":"6-a6b3fca234621b86f0e6d129cc10a4f3","name":"@amora95/commons","dist-tags":{"latest":"2.0.92"},"versions":{"2.0.86":{"name":"@amora95/commons","version":"2.0.86","author":{"name":"Aure Games"},"license":"MIT","_id":"@amora95/commons@2.0.86","maintainers":[{"name":"amora95","email":"albertoamp95@gmail.com"}],"dist":{"shasum":"36b9a5e337cb0394b6c98a793348f609c5bf97db","tarball":"https://registry.npmjs.org/@amora95/commons/-/commons-2.0.86.tgz","fileCount":87,"integrity":"sha512-jXt2T9rKIlSGUb4hqqhvpGs0i1UaLil5RrwWNZgD3XWbrHzWVVa0Sc6gNPpQdqooWT1HGMpo8wKMiTyFKDznqw==","signatures":[{"sig":"MEUCIDykx8OEzb7LClNhFfiFQWJJWJrdzJQj3Db9ztzBCg30AiEAgbJchl5oWx/+w/vjrF+pBKBLY3VLGbP83ogx9afvMks=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4771011},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs"},"./dist":{"import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsc && node scripts/build.js","compile":"copyfiles -u 1 src/resources/** dist/ && tsc -w","prepare":"yarn build && npm version patch"},"_npmUser":{"name":"amora95","email":"albertoamp95@gmail.com"},"_npmVersion":"10.5.2","description":"Amora95 commons packages and dependencies used in microservices","directories":{},"_nodeVersion":"20.13.1","dependencies":{"uuid":"^11.1.0","axios":"^1.8.4","dotenv":"^17.2.1","log4js":"^6.9.1","moment":"^2.30.1","xmldom":"^0.6.0","express":"^5.1.0","mongoose":"^8.13.1","node-rsa":"^1.1.1","geoip-lite":"^1.4.10","node-vault":"^0.10.5","jsonwebtoken":"^9.0.2","@types/node-vault":"^0.9.13","express-validator":"^7.2.1","@aws-sdk/client-s3":"^3.896.0","@aws-sdk/s3-request-presigner":"^3.896.0"},"_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.2","copyfiles":"^2.4.1","typescript":"^5.8.2","@types/node":"^22.13.17","@types/xmldom":"^0.1.34","@types/express":"^5.0.1","@types/request":"^2.48.13","@types/node-rsa":"^1.1.4","@types/geoip-lite":"^1.4.4","@types/jsonwebtoken":"^9.0.9"},"_npmOperationalInternal":{"tmp":"tmp/commons_2.0.86_1777503649235_0.9604503006414655","host":"s3://npm-registry-packages-npm-production"}},"2.0.87":{"name":"@amora95/commons","version":"2.0.87","author":{"name":"Aure Games"},"license":"MIT","_id":"@amora95/commons@2.0.87","maintainers":[{"name":"amora95","email":"albertoamp95@gmail.com"}],"dist":{"shasum":"748b54eb39f24ce9144c1eaf7adba0d202a65f1c","tarball":"https://registry.npmjs.org/@amora95/commons/-/commons-2.0.87.tgz","fileCount":87,"integrity":"sha512-C9gWz5Jz1WvC84AJGQ2DhsIVqFkHFE1ObBnD67dV44cS+uvX8il5yv6pFuffXBDyD1ZggZSxeqoSemYoh9UhLg==","signatures":[{"sig":"MEQCIGNEIlmALdn0s3Nj2Nhf6glx7X1ixwacnqsU0UqTvJYBAiAbdufet5pm9WitkK1yK/yRMa/eXXR3ZG/pwhYJ3GWj+g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4776202},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs"},"./dist":{"import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsc && node scripts/build.js","compile":"copyfiles -u 1 src/resources/** dist/ && tsc -w","prepare":"yarn build && npm version patch"},"_npmUser":{"name":"amora95","email":"albertoamp95@gmail.com"},"_npmVersion":"9.2.0","description":"Amora95 commons packages and dependencies used in microservices","directories":{},"_nodeVersion":"22.22.1","dependencies":{"uuid":"^11.1.0","axios":"^1.8.4","dotenv":"^17.2.1","log4js":"^6.9.1","moment":"^2.30.1","xmldom":"^0.6.0","express":"^5.1.0","mongoose":"^8.13.1","node-rsa":"^1.1.1","geoip-lite":"^1.4.10","node-vault":"^0.10.5","jsonwebtoken":"^9.0.2","@types/node-vault":"^0.9.13","express-validator":"^7.2.1","@aws-sdk/client-s3":"^3.896.0","@aws-sdk/s3-request-presigner":"^3.896.0"},"_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.2","copyfiles":"^2.4.1","typescript":"^5.8.2","@types/node":"^22.13.17","@types/xmldom":"^0.1.34","@types/express":"^5.0.1","@types/request":"^2.48.13","@types/node-rsa":"^1.1.4","@types/geoip-lite":"^1.4.4","@types/jsonwebtoken":"^9.0.9"},"_npmOperationalInternal":{"tmp":"tmp/commons_2.0.87_1778084352025_0.9302906743282044","host":"s3://npm-registry-packages-npm-production"}},"2.0.88":{"name":"@amora95/commons","version":"2.0.88","author":{"name":"Aure Games"},"license":"MIT","_id":"@amora95/commons@2.0.88","maintainers":[{"name":"amora95","email":"albertoamp95@gmail.com"}],"dist":{"shasum":"b3edc40727d17a2c184577d79713a3bd94df1cd2","tarball":"https://registry.npmjs.org/@amora95/commons/-/commons-2.0.88.tgz","fileCount":87,"integrity":"sha512-0JA+QQBigU03wQQ/GUHFMWCMA0M9LGbSTb15Qc3QA9s1SORTY230/4FhMatVnPBS8NyfnMEoRF/SKYvTEnZ2tA==","signatures":[{"sig":"MEQCIAUK4VYprcblnHEij/xHaqq1yHpOY7CR2U85Oyt5F0OHAiBLMiepOadgSEPWjj+irnCy4Bi0EeOEH8E0Hy+/GbNE6w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4776202},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs"},"./dist":{"import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsc && node scripts/build.js","compile":"copyfiles -u 1 src/resources/** dist/ && tsc -w","prepare":"yarn build && npm version patch"},"_npmUser":{"name":"amora95","email":"albertoamp95@gmail.com"},"_npmVersion":"9.2.0","description":"Amora95 commons packages and dependencies used in microservices","directories":{},"_nodeVersion":"22.22.1","dependencies":{"uuid":"^11.1.0","axios":"^1.8.4","dotenv":"^17.2.1","log4js":"^6.9.1","moment":"^2.30.1","xmldom":"^0.6.0","express":"^5.1.0","mongoose":"^8.13.1","node-rsa":"^1.1.1","geoip-lite":"^1.4.10","node-vault":"^0.10.5","jsonwebtoken":"^9.0.2","@types/node-vault":"^0.9.13","express-validator":"^7.2.1","@aws-sdk/client-s3":"^3.896.0","@aws-sdk/s3-request-presigner":"^3.896.0"},"_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.2","copyfiles":"^2.4.1","typescript":"^5.8.2","@types/node":"^22.13.17","@types/xmldom":"^0.1.34","@types/express":"^5.0.1","@types/request":"^2.48.13","@types/node-rsa":"^1.1.4","@types/geoip-lite":"^1.4.4","@types/jsonwebtoken":"^9.0.9"},"_npmOperationalInternal":{"tmp":"tmp/commons_2.0.88_1778084392620_0.03635359907469149","host":"s3://npm-registry-packages-npm-production"}},"2.0.90":{"name":"@amora95/commons","version":"2.0.90","author":{"name":"Aure Games"},"license":"MIT","_id":"@amora95/commons@2.0.90","maintainers":[{"name":"amora95","email":"albertoamp95@gmail.com"}],"dist":{"shasum":"089ca5d63c4677face12cdb533cb0621bc4656cd","tarball":"https://registry.npmjs.org/@amora95/commons/-/commons-2.0.90.tgz","fileCount":87,"integrity":"sha512-zpqaPUIA6guN+UKX5AS6/k494PIS+UYkqPltS21hgXAkXyzoW+Uck82TYZxLvg8QCPXqxCT0IzlIjdwvChsdbA==","signatures":[{"sig":"MEYCIQDygtwCm3wSXLtnGF+wMw6W4FW1W9UPZh7g8Vhq1IopOgIhAJsdYktPDmo0e9lM3FcXwTNadEjcA9d8XADVdIQJNqcm","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4776288},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./dist":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsc && node scripts/build.js","compile":"copyfiles -u 1 src/resources/** dist/ && tsc -w","prepare":"yarn build && npm version patch"},"_npmUser":{"name":"amora95","email":"albertoamp95@gmail.com"},"_npmVersion":"9.2.0","description":"Amora95 commons packages and dependencies used in microservices","directories":{},"_nodeVersion":"22.22.1","dependencies":{"uuid":"^11.1.0","axios":"^1.8.4","dotenv":"^17.2.1","log4js":"^6.9.1","moment":"^2.30.1","xmldom":"^0.6.0","express":"^5.1.0","mongoose":"^8.13.1","node-rsa":"^1.1.1","geoip-lite":"^1.4.10","node-vault":"^0.10.5","jsonwebtoken":"^9.0.2","@types/node-vault":"^0.9.13","express-validator":"^7.2.1","@aws-sdk/client-s3":"^3.896.0","@aws-sdk/s3-request-presigner":"^3.896.0"},"_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.2","copyfiles":"^2.4.1","typescript":"^5.8.2","@types/node":"^22.13.17","@types/xmldom":"^0.1.34","@types/express":"^5.0.1","@types/request":"^2.48.13","@types/node-rsa":"^1.1.4","@types/geoip-lite":"^1.4.4","@types/jsonwebtoken":"^9.0.9"},"_npmOperationalInternal":{"tmp":"tmp/commons_2.0.90_1778776790334_0.3987944308627662","host":"s3://npm-registry-packages-npm-production"}},"2.0.91":{"name":"@amora95/commons","version":"2.0.91","author":{"name":"Aure Games"},"license":"MIT","_id":"@amora95/commons@2.0.91","maintainers":[{"name":"amora95","email":"albertoamp95@gmail.com"}],"dist":{"shasum":"7b569243c4c082824316ccabc90caa1c3b4fcbf1","tarball":"https://registry.npmjs.org/@amora95/commons/-/commons-2.0.91.tgz","fileCount":87,"integrity":"sha512-adpoFC199dm7CYD98vVkhrhdg8vvt2Zpwpg2tsAxOjTI6p68YjX3ko2YTUIs0bJ56Kz1/JCpHWbOR29e6RG2ig==","signatures":[{"sig":"MEYCIQC7I0Eqv6Zg9iQaz55dHWXe3OvQcat+iUeHPaQzY8L83AIhAKq1F+8mBDL7ONEgD30Mtyh02WmtMegYoMw7famlkexu","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4789531},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./dist":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsc && node scripts/build.js","compile":"copyfiles -u 1 src/resources/** dist/ && tsc -w","prepare":"yarn build && npm version patch"},"_npmUser":{"name":"amora95","email":"albertoamp95@gmail.com"},"_npmVersion":"9.2.0","description":"Amora95 commons packages and dependencies used in microservices","directories":{},"_nodeVersion":"22.22.1","dependencies":{"uuid":"^11.1.0","axios":"^1.8.4","dotenv":"^17.2.1","log4js":"^6.9.1","moment":"^2.30.1","xmldom":"^0.6.0","express":"^5.1.0","mongoose":"^8.13.1","node-rsa":"^1.1.1","geoip-lite":"^1.4.10","node-vault":"^0.10.5","jsonwebtoken":"^9.0.2","@types/node-vault":"^0.9.13","express-validator":"^7.2.1","@aws-sdk/client-s3":"^3.896.0","@aws-sdk/s3-request-presigner":"^3.896.0"},"_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.2","copyfiles":"^2.4.1","typescript":"^5.8.2","@types/node":"^22.13.17","@types/xmldom":"^0.1.34","@types/express":"^5.0.1","@types/request":"^2.48.13","@types/node-rsa":"^1.1.4","@types/geoip-lite":"^1.4.4","@types/jsonwebtoken":"^9.0.9"},"_npmOperationalInternal":{"tmp":"tmp/commons_2.0.91_1778777053466_0.609591106316606","host":"s3://npm-registry-packages-npm-production"}},"2.0.92":{"name":"@amora95/commons","version":"2.0.92","description":"Amora95 commons packages and dependencies used in microservices","type":"module","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./dist":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"compile":"copyfiles -u 1 src/resources/** dist/ && tsc -w","build":"tsc && node scripts/build.js","prepare":"yarn build && npm version patch"},"author":{"name":"Aure Games"},"license":"MIT","devDependencies":{"@types/express":"^5.0.1","@types/geoip-lite":"^1.4.4","@types/jsonwebtoken":"^9.0.9","@types/node":"^22.13.17","@types/node-rsa":"^1.1.4","@types/request":"^2.48.13","@types/xmldom":"^0.1.34","copyfiles":"^2.4.1","esbuild":"^0.25.2","typescript":"^5.8.2"},"dependencies":{"@aws-sdk/client-s3":"^3.896.0","@aws-sdk/s3-request-presigner":"^3.896.0","@types/node-vault":"^0.9.13","axios":"^1.8.4","dotenv":"^17.2.1","express":"^5.1.0","express-validator":"^7.2.1","geoip-lite":"^1.4.10","jsonwebtoken":"^9.0.2","log4js":"^6.9.1","moment":"^2.30.1","mongoose":"^8.13.1","node-rsa":"^1.1.1","node-vault":"^0.10.5","uuid":"^11.1.0","xmldom":"^0.6.0"},"_id":"@amora95/commons@2.0.92","_nodeVersion":"22.22.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-fcEJzBDHwOH2Cy2elzaHwUZLUENc/40APCSuWpTr771rFntzfNI4q43K0IOBSm0Xcs2KN2nr+SHrQ8TjvQFouA==","shasum":"50a87856b79f81c57a190291eb837d2a05fc9e9d","tarball":"https://registry.npmjs.org/@amora95/commons/-/commons-2.0.92.tgz","fileCount":88,"unpackedSize":4790569,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCWW2jSapGCd6FSrGgbwFWWReEB1JT8pAD+xrJd5vYWkwIgMZwLPGlwaAK7mGa/EzKjlIVlvePbIpiM04VOIo9mRUY="}]},"_npmUser":{"name":"amora95","email":"albertoamp95@gmail.com"},"directories":{},"maintainers":[{"name":"amora95","email":"albertoamp95@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/commons_2.0.92_1778777234374_0.5937779739424076"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-29T23:00:49.107Z","modified":"2026-05-14T16:47:14.674Z","2.0.86":"2026-04-29T23:00:49.493Z","2.0.87":"2026-05-06T16:19:12.205Z","2.0.88":"2026-05-06T16:19:52.868Z","2.0.90":"2026-05-14T16:39:50.548Z","2.0.91":"2026-05-14T16:44:13.751Z","2.0.92":"2026-05-14T16:47:14.533Z"},"author":{"name":"Aure Games"},"license":"MIT","description":"Amora95 commons packages and dependencies used in microservices","maintainers":[{"name":"amora95","email":"albertoamp95@gmail.com"}],"readme":"# @amora95/commons\r\n\r\nShared utilities, constants, middleware, and service clients for the Aure Games backend.\r\n\r\n## Installation\r\n\r\n```sh\r\nnpm install @amora95/commons\r\n# or\r\nyarn add @amora95/commons\r\n```\r\n\r\n## Contents\r\n\r\n### Constants\r\n\r\n| Module                        | Description                                                              |\r\n| ----------------------------- | ------------------------------------------------------------------------ |\r\n| `dbConstants`                 | Database status values (`pending`, `done`)                               |\r\n| `httpCodes` / `responseCodes` | Standard HTTP status codes and response code strings                     |\r\n| `webErrors`                   | Pre-defined error objects with `id` and `msg` for auth and server errors |\r\n| `loggerConstants`             | Logger categories, levels, and types                                     |\r\n| `webConstants`                | General web-related constants                                            |\r\n| `websocketConstants`          | WebSocket-related constants                                              |\r\n| `serviceConstants`            | Service-level constants (e.g. S3 signed URL expiry)                      |\r\n\r\n### Middleware\r\n\r\n#### `checkTokenMiddleware`\r\n\r\nExpress middleware that validates a Bearer token by calling the auth service's `check-session-token`\r\nendpoint. Requires `AUTH_SERVICE_URL` to be set in the environment.\r\n\r\n```ts\r\nimport { checkTokenMiddleware } from '@amora95/commons';\r\n\r\nrouter.get('/protected', checkTokenMiddleware, handler);\r\n```\r\n\r\n### Utils\r\n\r\n#### Logger (`logData`, `logDBRegistry`, `sendOkResponse`, `sendClientError`, `sendServerError`)\r\n\r\nLog4js-based logger that writes to file and console. Optionally ships log entries to a remote logger\r\nservice when `LOGGER_STATUS=ON`.\r\n\r\n| Function          | Description                                         |\r\n| ----------------- | --------------------------------------------------- |\r\n| `logData`         | Writes a log entry at the given level and category  |\r\n| `logDBRegistry`   | Posts a structured log to the remote logger service |\r\n| `sendOkResponse`  | Sends a 200 JSON response                           |\r\n| `sendClientError` | Sends a 4xx JSON error response                     |\r\n| `sendServerError` | Sends a 500 JSON error response                     |\r\n\r\nEnvironment variables:\r\n\r\n- `LOG_PATH` — directory for log files\r\n- `LOGGER_STATUS` — set to `ON` to enable remote logging\r\n- `LOGGER_URL` — URL of the remote logger service\r\n\r\n#### RSA Manager (`encrypt`, `decrypt`, `sign`, `verifySign`, `verifySpkiSignature`)\r\n\r\nWrappers around Node's `crypto` module for RSA encryption, decryption, signing, and signature\r\nverification. Supports XML-format public keys (converts to PEM internally).\r\n\r\n#### Tokenizer (`createJWT`, `getTokenInfo`, `getTokenData`)\r\n\r\nJWT helpers that retrieve signing secrets from OpenBao/Vault at runtime.\r\n\r\n| Function       | Description                                              |\r\n| -------------- | -------------------------------------------------------- |\r\n| `createJWT`    | Signs and returns a JWT using the secret stored in Vault |\r\n| `getTokenInfo` | Verifies a JWT and returns its decoded payload           |\r\n| `getTokenData` | Decodes a JWT without verification                       |\r\n\r\n#### String Utils (`getNewCode`, `getSafeMail`, `avoidNanParseInt`, `avoidNanParseFloat`)\r\n\r\nMiscellaneous string helpers.\r\n\r\n#### Thread Utils (`sleep`)\r\n\r\nAsync sleep helper.\r\n\r\n### Services\r\n\r\n#### `OpenbaoVaultClient`\r\n\r\nSingleton client for [OpenBao](https://openbao.org/) (Vault-compatible). Handles token-based\r\nauthentication with wrapping token support and automatic re-authentication.\r\n\r\n```ts\r\nimport { OpenbaoVaultClient } from '@amora95/commons';\r\n\r\nconst vault = OpenbaoVaultClient.getInstance();\r\nconst secret = await vault.getSecret<MySecretType>('secret/path');\r\n```\r\n\r\nEnvironment variables:\r\n\r\n- `VAULT_ADDR` — Vault URL (default: `http://localhost:8200`)\r\n- `DOCKER_SHARED_FOLDER` — path to shared volume for wrapping tokens\r\n\r\n#### `S3ClientService`\r\n\r\nAWS S3 client wrapper with presigned URL support. Credentials are fetched from Vault at init time.\r\n\r\n```ts\r\nimport { S3ClientService } from '@amora95/commons';\r\n\r\nconst s3 = await new S3ClientService().init(bucketId, secretPath);\r\nconst url = await s3.getPresignedUrl('path/to/object');\r\n```\r\n\r\nEnvironment variables:\r\n\r\n- `S3_REGION`\r\n- `S3_URL`\r\n- `S3_SHOULD_FORCE_PATH`\r\n- `AWS_DEFAULT_MODE`\r\n\r\n### Types\r\n\r\n- `GenericObject` — `{ [key: string]: any }`\r\n- `S3ValidDefaultsMode` — valid values for the AWS SDK `defaultsMode` option\r\n- `ErrorType` — `{ msg: string; id: string }`\r\n\r\n### Controllers\r\n\r\nBase controller class/interface shared across backend services.\r\n\r\n## Development\r\n\r\n```sh\r\n# Build (TypeScript + esbuild bundle)\r\nyarn build\r\n\r\n# Build in watch mode\r\nyarn compile\r\n```\r\n\r\nBuild output is placed in `dist/` and supports both ESM (`dist/index.js`) and CJS\r\n(`dist/index.cjs`).\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.md"}