From c431eef014e54f5b6dfbbe86aceb35d637ef4bf4 Mon Sep 17 00:00:00 2001 From: jmgasper Date: Wed, 5 Aug 2026 15:47:11 +1000 Subject: [PATCH 01/11] Trivy update --- .github/workflows/trivy.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/trivy.yaml b/.github/workflows/trivy.yaml index 7b9fa48..9706c0a 100644 --- a/.github/workflows/trivy.yaml +++ b/.github/workflows/trivy.yaml @@ -1,34 +1,44 @@ name: Trivy Scanner permissions: + actions: read contents: read security-events: write + on: push: branches: - main + - master - dev + - develop pull_request: + workflow_dispatch: + jobs: trivy-scan: - name: Use Trivy + name: Trivy SAST and SCA runs-on: ubuntu-24.04 steps: - name: Checkout code uses: actions/checkout@v4 - name: Run Trivy scanner in repo mode - uses: aquasecurity/trivy-action@0.33.1 + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 with: + version: "v0.73.0" scan-type: "fs" + scan-ref: "." ignore-unfixed: true format: "sarif" output: "trivy-results.sarif" severity: "CRITICAL,HIGH,UNKNOWN" - scanners: vuln,secret,misconfig,license + limit-severities-for-sarif: true + scanners: "vuln,secret,misconfig,license" github-pat: ${{ secrets.GITHUB_TOKEN }} - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v3 + if: always() + uses: github/codeql-action/upload-sarif@v4 with: sarif_file: "trivy-results.sarif" From d3b1643cc329b7a7f6e40ce5a63644092e560147 Mon Sep 17 00:00:00 2001 From: jmgasper Date: Tue, 1 Sep 2026 08:57:53 +1000 Subject: [PATCH 02/11] fix(security): remediate September 2026 findings --- .nvmrc | 2 +- Dockerfile | 36 ++++++++----- README.md | 16 +++--- doc/Group.postman_environment.json | 4 +- mock/mock-api.js | 3 +- pnpm-lock.yaml | 82 ++++++++++++++++-------------- pnpm-workspace.yaml | 13 +++-- 7 files changed, 87 insertions(+), 69 deletions(-) diff --git a/.nvmrc b/.nvmrc index eacd481..34adfb4 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v26.5.0 +v26.5.1 diff --git a/Dockerfile b/Dockerfile index 8aba5c9..cfee036 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ # syntax=docker/dockerfile:1.7 -ARG NODE_VERSION=26.5.0 +ARG NODE_VERSION=26.5.1 ARG PNPM_VERSION=11.15.1 -FROM node:${NODE_VERSION}-alpine AS build +FROM node:${NODE_VERSION}-alpine3.24 AS build RUN apk upgrade --no-cache \ && apk add --no-cache bash @@ -17,12 +17,21 @@ RUN pnpm run build RUN pnpm prune --prod RUN node node_modules/prisma/build/index.js generate -FROM node:${NODE_VERSION}-alpine AS runtime +FROM alpine:3.24 AS runtime +ARG ALPINE_NODE_VERSION=26.5.1-r0 +ARG OPENSSL_VERSION=3.5.8-r0 + +# Use Alpine's dynamically linked Node.js package so the runtime receives the +# patched system OpenSSL libraries without carrying npm or Node.js headers. RUN apk upgrade --no-cache \ - && apk add --no-cache bash \ - && rm -rf /usr/local/lib/node_modules/npm \ - && rm -f /usr/local/bin/npm /usr/local/bin/npx + && apk add --no-cache \ + bash \ + "libcrypto3=${OPENSSL_VERSION}" \ + "libssl3=${OPENSSL_VERSION}" \ + "nodejs-current=${ALPINE_NODE_VERSION}" \ + && addgroup -S -g 10001 app \ + && adduser -S -D -H -h /app -u 10001 -G app app ARG RESET_DB_ARG=false ENV RESET_DB=$RESET_DB_ARG @@ -32,10 +41,13 @@ ENV PRISMA_CLI_BINARY_TARGETS=linux-musl-openssl-3.0.x ENV NODE_ENV=production WORKDIR /app -COPY --from=build /app/dist ./dist -COPY --from=build /app/node_modules ./node_modules -COPY --from=build /app/prisma ./prisma -COPY --from=build /app/package.json ./package.json -COPY --from=build /app/appStartUp.sh ./appStartUp.sh -RUN chmod +x appStartUp.sh +COPY --from=build --chown=app:app /app/dist ./dist +COPY --from=build --chown=app:app /app/node_modules ./node_modules +COPY --from=build --chown=app:app /app/prisma ./prisma +COPY --from=build --chown=app:app /app/package.json ./package.json +COPY --from=build --chown=app:app /app/appStartUp.sh ./appStartUp.sh +RUN chmod 0555 appStartUp.sh + +USER app + CMD ["./appStartUp.sh"] diff --git a/README.md b/README.md index 2a12247..7680ce5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,11 @@ Group API built on modern frameworks for managing all group-related Topcoder needs. -Use Node.js 26.5.0 and pnpm 11.15.1. Run `nvm use` in this project before running pnpm commands. +Use Node.js 26.5.1 and pnpm 11.15.1. Run `nvm use` in this project before running pnpm commands. + +The production image runs as the unprivileged `app` user. Its Alpine 3.24 +runtime installs Node.js 26.5.1 and the patched system OpenSSL 3.5.8 packages; +the Node.js build toolchain and npm are not copied into the runtime image. ## Project setup @@ -73,15 +77,11 @@ pnpm exec prisma migrate reset curl --request POST \ --url https://auth0proxy.topcoder-dev.com/token \ --header 'content-type: application/json' \ - --data '{"auth0_url": "https://topcoder-dev.auth0.com/oauth/token", "client_id":"8uHVTW2WHp8BbBPX7J0YTAwgYbYTfjsM","client_secret":"hQXGeKO-cSZ15CLBNRDGZAGRcHWay6PAR_zTQQz4YjdX7QNU7NwGoaa3YuuUYvUv","audience":"https://m2m.topcoder-dev.com/","grant_type":"client_credentials"}' + --data '{"auth0_url": "https://topcoder-dev.auth0.com/oauth/token", "client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET","audience":"https://m2m.topcoder-dev.com/","grant_type":"client_credentials"}' ``` -For a read-only scope M2M token, use: - -``` -"client_id":"dgrh9mkk8N6sWsVPFf6JqdVmjjuibowf" -"client_secret":"_6jFqIppsA3u87Tm7mRDXhX_yf8-DC2ooc5f0affjuWoRiLG1ZriHtUsMQgo61qp" -``` +Obtain M2M credentials with the required scope from the approved secret store; +never commit client credentials to this repository. - then you can use Postman to test all apis - Swagger docs are accessible at `http://localhost:3000/api-docs` diff --git a/doc/Group.postman_environment.json b/doc/Group.postman_environment.json index 28bdf81..67c1518 100644 --- a/doc/Group.postman_environment.json +++ b/doc/Group.postman_environment.json @@ -9,11 +9,11 @@ }, { "key": "TOKEN", - "value": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5VSkZORGd4UlRVME5EWTBOVVkzTlRkR05qTXlRamxETmpOQk5UYzVRVUV3UlRFeU56TTJRUSJ9.eyJpc3MiOiJodHRwczovL3RvcGNvZGVyLWRldi5hdXRoMC5jb20vIiwic3ViIjoiOHVIVlRXMldIcDhCYkJQWDdKMFlUQXdnWWJZVGZqc01AY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vbTJtLnRvcGNvZGVyLWRldi5jb20vIiwiaWF0IjoxNzUxNTEzOTY0LCJleHAiOjE3NTE2MDAzNjQsInNjb3BlIjoicmVhZDpjaGFsbGVuZ2VzIGFsbDpncm91cHMgd3JpdGU6Z3JvdXBzIHJlYWQ6Z3JvdXBzIHJlYWQ6YnVzX3RvcGljcyB3cml0ZTpidXNfYXBpIiwiZ3R5IjoiY2xpZW50LWNyZWRlbnRpYWxzIiwiYXpwIjoiOHVIVlRXMldIcDhCYkJQWDdKMFlUQXdnWWJZVGZqc00ifQ.pdVpeB0PIZSFpTjcR82AvMiyFQizj04y7x7zqU2Y9Ao_ZjlwmcjDk02WgZrPzhgJ_59E5M9ZCgEyFGA3EZrzMKcUcyDDcL-PhN6l5-IMBYDyGYNh7gLuyY5vwMqGUZx3IC7mwLXMeNtenbigkbOx00AHI9R85g2Rqmi6wKnDHsGCFfNKckPBpdCCom-PHoxkkLEcCAedvcXDX8AUkIePJORfaoC5ZEV0aI0-miU1fUwqQMySZX891Hu7cDL5KxZY12ic_SNgoQ_vEi3yw5hbrl7urkmg1HyFxlb0tX7cQmgvVXqxwlaqgrBEv9UOB-vcwIqsWLJRKSJ1OA7abg5NXA", + "value": "YOUR_JWT_TOKEN", "enabled": true } ], "_postman_variable_scope": "environment", "_postman_exported_at": "2025-07-07T14:54:50.195Z", "_postman_exported_using": "Postman/9.28.4" -} \ No newline at end of file +} diff --git a/mock/mock-api.js b/mock/mock-api.js index f5fb934..0c8995e 100644 --- a/mock/mock-api.js +++ b/mock/mock-api.js @@ -32,7 +32,7 @@ app.post('/eventBus/bus/events', (req, res) => { res.json({}) }) -const m2mToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3RvcGNvZGVyLWRldi5hdXRoMC5jb20vIiwic3ViIjoiakdJZjJwZDNmNDRCMWpxdk9haTMwQklLVFphbllCZlVAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vbTJtLnRvcGNvZGVyLWRldi5jb20vIiwiaWF0IjoxNzQ4MDk5NDk4LCJleHAiOjE4NDgxODU4OTgsInNjb3BlIjoid3JpdGU6YnVzX2FwaSxhbGw6Y2hhbGxlbmdlcyIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyIsImF6cCI6ImpHSWYycGQzZjQ0QjFqcXZPYWkzMEJJS1RaYW5ZQmZVIn0.h3ksdsdJm5USGF1VgROrpkTtStmCzv5ZA6y8bd8AnGY'; +const m2mToken = 'MOCK_M2M_TOKEN'; const m2mScope = 'write:bus_api,all:groups'; @@ -111,4 +111,3 @@ app.get('/challenges', (req, res) => { app.listen(app.get('port'), '0.0.0.0', () => { logger.info(`Express server listening on port ${app.get('port')}`) }) - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4d7cea4..5363b62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,12 +12,14 @@ overrides: ajv@^8.0.0: 8.20.0 axios: 1.18.1 body-parser@^2: 2.3.0 - brace-expansion@^1.0.0: 1.1.16 - brace-expansion@^2.0.0: 2.1.2 + brace-expansion@^1.0.0: 1.1.18 + brace-expansion@^2.0.0: 2.1.4 + brace-expansion@^5.0.0: 5.0.9 + deepmerge-ts: 8.0.0 defu: 6.1.7 diff@^4: 4.0.4 effect@^3.0.0: 3.22.0 - fast-uri@^3.0.0: 3.1.4 + fast-uri@^3.0.0: 3.1.5 file-type@>=13.0.0 <21.3.2: 21.3.2 flatted: 3.4.2 follow-redirects: 1.16.0 @@ -25,8 +27,9 @@ overrides: handlebars: 4.7.9 ip-address@^10.0.0: 10.1.1 joi@^18.0.0: 18.2.1 - js-yaml@^3: 3.15.0 - js-yaml@^4.0.0: 4.3.0 + js-yaml@^3: 3.15.1 + js-yaml@^4.0.0: 4.3.1 + js-yaml@>=5.0.0 <=5.2.1: 5.2.2 jws: 4.0.1 lodash: 4.18.1 minimatch@^3.0.0: 3.1.4 @@ -1649,15 +1652,15 @@ packages: resolution: {integrity: sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==} engines: {node: '>=18'} - brace-expansion@1.1.16: - resolution: {integrity: sha512-IDw48K2/2kRkg9LdJxurvq3lV3aBgq0REY89duEqFRthjlPdXHKMj7EnQOXVckxzgisinf3nHfrcE2FufFLXMw==} + brace-expansion@1.1.18: + resolution: {integrity: sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==} - brace-expansion@2.1.2: - resolution: {integrity: sha512-w5JZcKgdhDOgOwm8H+KgbosopHMuGcl6qbulwjtz3SM7I7P3yW1eAjzMPLrIE+NQ9vjgANKHWeMHnrT0OXW1oA==} + brace-expansion@2.1.4: + resolution: {integrity: sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==} - brace-expansion@5.0.7: - resolution: {integrity: sha512-7oFy703dxfY3/NLxC1fh2SUCQ0H9rmAY+5EpDVfXjUTTs+HEwR2nYaqLv+GWcTsumwxPfiz6CzCNkwXwBUwqCA==} - engines: {node: 18 || 20 || >=22} + brace-expansion@5.0.9: + resolution: {integrity: sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==} + engines: {node: 20 || >=22} braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} @@ -1957,8 +1960,8 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} - deepmerge-ts@7.1.5: - resolution: {integrity: sha512-HOJkrhaYsweh+W+e74Yn7YStZOilkoPb6fycpwNLKzSPtruFs48nYis0zy5yJz1+ktUhHxoRDJ27RQAWLIJVJw==} + deepmerge-ts@8.0.0: + resolution: {integrity: sha512-ICNjaP0ML+eSdEpJYQC46XiAn/UjAdwbEl0dE8p85ZTeNDinN4Kd4+9jS4OSAuH7st6eC7rQhsqTF5zIDaUm2g==} engines: {node: '>=16.0.0'} deepmerge@4.3.1: @@ -2127,6 +2130,7 @@ packages: eslint@9.39.2: resolution: {integrity: sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true peerDependencies: jiti: '*' @@ -2227,8 +2231,8 @@ packages: fast-safe-stringify@2.1.1: resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} - fast-uri@3.1.4: - resolution: {integrity: sha512-8JnbkQ4juDyvYs4mgFGQqg4yCYtFDtUtmp2QIQq11ZZe5CFQ5wcqm1rqDgAh/QdMySuBnPzMUiJUNZG5N/AiQw==} + fast-uri@3.1.5: + resolution: {integrity: sha512-gHwA1O9LDIcKunMKhObS/HimwtehO1nPUECKAu5TpKgaO19fcWEl4bliWe1jWxVFvIXztJjjQ4L8XQ1EU9f7Jw==} fastq@1.19.1: resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==} @@ -2739,16 +2743,16 @@ packages: js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - js-yaml@3.15.0: - resolution: {integrity: sha512-ttBQIIQPDeLjpPOohtUdXuXUVoA2uIB6fEH9HyJ7234s5mBJ5wTx20njxplLZQgLaOfpmPQA7X2t5AX6tIPbog==} + js-yaml@3.15.1: + resolution: {integrity: sha512-S99WuO3HlhO3XN41EtYUNl9zzXjoJx7QvmipxsJVxtCBT0YHEFy+iOJhjSvrmV12nYhWpZaM8lPHkJm0yUMbag==} hasBin: true - js-yaml@4.3.0: - resolution: {integrity: sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==} + js-yaml@4.3.1: + resolution: {integrity: sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==} hasBin: true - js-yaml@5.2.1: - resolution: {integrity: sha512-zfLtNfQqxVqq3uaTqSkh4x4hZw3KHobGUA0fJUj4wawW8bsQLTVqpHdXSIzidh7o+4lEW36tANuAGdaFx6Zgnw==} + js-yaml@5.2.2: + resolution: {integrity: sha512-dayzUzKkJ1MkuUtZglSebU43utNXH0OWQByK9rKOOuYIO8M5TV1y+n8ALMdG0rdzBnfNkOmZEqrURepb0ejqBw==} hasBin: true jsesc@3.1.0: @@ -4265,7 +4269,7 @@ snapshots: globals: 14.0.0 ignore: 5.3.2 import-fresh: 3.3.1 - js-yaml: 4.3.0 + js-yaml: 4.3.1 minimatch: 3.1.4 strip-json-comments: 3.1.1 transitivePeerDependencies: @@ -4452,7 +4456,7 @@ snapshots: camelcase: 5.3.1 find-up: 4.1.0 get-package-type: 0.1.0 - js-yaml: 3.15.0 + js-yaml: 3.15.1 resolve-from: 5.0.0 '@istanbuljs/schema@0.1.3': {} @@ -4841,7 +4845,7 @@ snapshots: '@nestjs/common': 11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1) '@nestjs/core': 11.1.28(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(@nestjs/platform-express@11.1.28)(reflect-metadata@0.2.2)(rxjs@7.8.2) '@nestjs/mapped-types': 2.1.1(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2) - js-yaml: 5.2.1 + js-yaml: 5.2.2 lodash: 4.18.1 path-to-regexp: 8.4.2 reflect-metadata: 0.2.2 @@ -4886,7 +4890,7 @@ snapshots: '@prisma/config@6.19.3': dependencies: c12: 3.1.0 - deepmerge-ts: 7.1.5 + deepmerge-ts: 8.0.0 effect: 3.22.0 empathic: 2.0.0 transitivePeerDependencies: @@ -5515,7 +5519,7 @@ snapshots: ajv@8.20.0: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 3.1.4 + fast-uri: 3.1.5 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 @@ -5672,16 +5676,16 @@ snapshots: transitivePeerDependencies: - supports-color - brace-expansion@1.1.16: + brace-expansion@1.1.18: dependencies: balanced-match: 1.0.2 concat-map: 0.0.1 - brace-expansion@2.1.2: + brace-expansion@2.1.4: dependencies: balanced-match: 1.0.2 - brace-expansion@5.0.7: + brace-expansion@5.0.9: dependencies: balanced-match: 4.0.4 @@ -5922,7 +5926,7 @@ snapshots: cosmiconfig@8.3.6(typescript@5.9.3): dependencies: import-fresh: 3.3.1 - js-yaml: 4.3.0 + js-yaml: 4.3.1 parse-json: 5.2.0 path-type: 4.0.0 optionalDependencies: @@ -5965,7 +5969,7 @@ snapshots: deep-is@0.1.4: {} - deepmerge-ts@7.1.5: {} + deepmerge-ts@8.0.0: {} deepmerge@4.3.1: {} @@ -6257,7 +6261,7 @@ snapshots: fast-safe-stringify@2.1.1: {} - fast-uri@3.1.4: {} + fast-uri@3.1.5: {} fastq@1.19.1: dependencies: @@ -6980,16 +6984,16 @@ snapshots: js-tokens@4.0.0: {} - js-yaml@3.15.0: + js-yaml@3.15.1: dependencies: argparse: 1.0.10 esprima: 4.0.1 - js-yaml@4.3.0: + js-yaml@4.3.1: dependencies: argparse: 2.0.1 - js-yaml@5.2.1: + js-yaml@5.2.2: dependencies: argparse: 2.0.1 @@ -7201,15 +7205,15 @@ snapshots: minimatch@10.2.5: dependencies: - brace-expansion: 5.0.7 + brace-expansion: 5.0.9 minimatch@3.1.4: dependencies: - brace-expansion: 1.1.16 + brace-expansion: 1.1.18 minimatch@9.0.9: dependencies: - brace-expansion: 2.1.2 + brace-expansion: 2.1.4 minimist@1.2.8: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 10bd861..e6303ba 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -12,12 +12,14 @@ overrides: 'ajv@^8.0.0': 8.20.0 axios: 1.18.1 'body-parser@^2': 2.3.0 - 'brace-expansion@^1.0.0': 1.1.16 - 'brace-expansion@^2.0.0': 2.1.2 + 'brace-expansion@^1.0.0': 1.1.18 + 'brace-expansion@^2.0.0': 2.1.4 + 'brace-expansion@^5.0.0': 5.0.9 + deepmerge-ts: 8.0.0 defu: 6.1.7 'diff@^4': 4.0.4 'effect@^3.0.0': 3.22.0 - 'fast-uri@^3.0.0': 3.1.4 + 'fast-uri@^3.0.0': 3.1.5 'file-type@>=13.0.0 <21.3.2': 21.3.2 flatted: 3.4.2 follow-redirects: 1.16.0 @@ -25,8 +27,9 @@ overrides: handlebars: 4.7.9 'ip-address@^10.0.0': 10.1.1 'joi@^18.0.0': 18.2.1 - 'js-yaml@^3': 3.15.0 - 'js-yaml@^4.0.0': 4.3.0 + 'js-yaml@^3': 3.15.1 + 'js-yaml@^4.0.0': 4.3.1 + 'js-yaml@>=5.0.0 <=5.2.1': 5.2.2 jws: 4.0.1 lodash: 4.18.1 'minimatch@^3.0.0': 3.1.4 From 1661c9dd403d6d3a5dc8d8d3b76581975afbf6d8 Mon Sep 17 00:00:00 2001 From: jmgasper Date: Mon, 26 Oct 2026 12:17:58 +1100 Subject: [PATCH 03/11] refactor: adopt shared v6 JWT and bus clients --- README.md | 23 ++ package.json | 3 +- pnpm-lock.yaml | 251 +----------------- src/shared/helper.ts | 2 +- src/shared/modules/global/eventBus.service.ts | 26 +- src/shared/modules/global/jwt.service.spec.ts | 30 ++- src/shared/modules/global/jwt.service.ts | 247 ++--------------- src/shared/modules/global/m2m.service.ts | 2 +- 8 files changed, 73 insertions(+), 511 deletions(-) diff --git a/README.md b/README.md index 2a12247..07b9a44 100644 --- a/README.md +++ b/README.md @@ -116,3 +116,26 @@ For a read-only scope M2M token, use: - API base configuration points to v6 in dev/local and v5 in prod (for backward compatibility): - Dev: work-manager/config/constants/development.js. - Local: work-manager/config/constants/local.js and work-manager/config/constants/local.js. + +## Shared authentication and bus client (v6 refresh) + +This branch uses `tc-core-library-js` **4.0.0-rc.1**. Use its named +`createJwtVerifier` / `createJwtAuthenticator`, `createM2MClient`, and +`createBusApiClient` exports for shared authentication and bus API publishing. +Service-specific roles, scopes, sessions and ownership checks remain in this service. +The former bus wrapper dependency and local JWT cryptography must not be reintroduced. + +RSA verification requires an exact configured issuer and audience (`JWT_AUDIENCE` +for client tokens, `AUTH0_AUDIENCE` for machine/API tokens, or this service's explicit +issuer-policy settings). HMAC secrets must be at least 32 bytes; no default secret +is supplied. Expiry is enforced. Machine identity comes from the shared verifier, +not the presence of scopes. Supply real development credentials through the service's +existing environment configuration before deployment. + +Bus publishers use `createBusApiClient(config).postEvent(event)` with the existing +event envelope and optional key. Configure `BUSAPI_URL` for v6 and the existing +OAuth credentials/token provider. The client uses bounded HTTPS requests and does +not retry POSTs automatically. Application retry/outbox behavior remains local. + +See the [core migration guide](https://github.com/topcoder-platform/tc-core-library-js/blob/v4.0.0-rc.1/MIGRATION.md) +for the API mapping, compatibility requirements, and rollout scope. diff --git a/package.json b/package.json index 4d4024c..32e8d57 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,7 @@ "qs": "^6.15.3", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", - "tc-core-library-js": "topcoder-platform/tc-core-library-js.git#master", - "tc-bus-api-wrapper": "github:topcoder-platform/tc-bus-api-wrapper.git", + "tc-core-library-js": "github:topcoder-platform/tc-core-library-js#v4.0.0-rc.1", "uuid": "^14.0.1" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4d7cea4..44309ff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,12 +102,9 @@ importers: rxjs: specifier: ^7.8.1 version: 7.8.2 - tc-bus-api-wrapper: - specifier: github:topcoder-platform/tc-bus-api-wrapper.git - version: '@topcoder-platform/topcoder-bus-api-wrapper@https://codeload.github.com/topcoder-platform/tc-bus-api-wrapper/tar.gz/297a9c0adcdb97661257e7825bee9c3f5578b833(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1)' tc-core-library-js: - specifier: topcoder-platform/tc-core-library-js.git#master - version: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/1075136355e1e1c4779f2138a30f3ffbd718bfa4(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1) + specifier: github:topcoder-platform/tc-core-library-js#v4.0.0-rc.1 + version: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/6c326fea0abfccb5ae29dff2ac5bce01aabc1fa4(supports-color@8.1.1) uuid: specifier: 14.0.1 version: 14.0.1 @@ -479,26 +476,6 @@ packages: resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@hapi/address@5.1.1': - resolution: {integrity: sha512-A+po2d/dVoY7cYajycYI43ZbYMXukuopIsqCjh5QzsBCipDtdofHntljDlpccMjIfTy6UOkg+5KPriwYch2bXA==} - engines: {node: '>=14.0.0'} - - '@hapi/formula@3.0.2': - resolution: {integrity: sha512-hY5YPNXzw1He7s0iqkRQi+uMGh383CGdyyIGYtB+W5N3KHPXoqychklvHhKCC9M3Xtv0OCs/IHw+r4dcHtBYWw==} - - '@hapi/hoek@11.0.7': - resolution: {integrity: sha512-HV5undWkKzcB4RZUusqOpcgxOaq6VOAH7zhhIr2g3G8NF/MlFO75SjOr2NfuSx0Mh40+1FqCkagKLJRykUWoFQ==} - - '@hapi/pinpoint@2.0.1': - resolution: {integrity: sha512-EKQmr16tM8s16vTT3cA5L0kZZcTMU5DUOZTuvpnY738m+jyP3JIUj+Mm1xc1rsLkGBQ/gVnfKYPwOmPg1tUR4Q==} - - '@hapi/tlds@1.1.4': - resolution: {integrity: sha512-Fq+20dxsxLaUn5jSSWrdtSRcIUba2JquuorF9UW1wIJS5cSUwxIsO2GIhaWynPRflvxSzFN+gxKte2HEW1OuoA==} - engines: {node: '>=14.0.0'} - - '@hapi/topo@6.0.2': - resolution: {integrity: sha512-KR3rD5inZbGMrHmgPxsJ9dbi6zEK+C3ZwUwTa+eMwWLz7oijWUTWD2pMSNNYJAU6Qq+65NkxXjqHr/7LM2Xkqg==} - '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} @@ -1168,10 +1145,6 @@ packages: '@tokenizer/token@0.3.0': resolution: {integrity: sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==} - '@topcoder-platform/topcoder-bus-api-wrapper@https://codeload.github.com/topcoder-platform/tc-bus-api-wrapper/tar.gz/297a9c0adcdb97661257e7825bee9c3f5578b833': - resolution: {gitHosted: true, tarball: https://codeload.github.com/topcoder-platform/tc-bus-api-wrapper/tar.gz/297a9c0adcdb97661257e7825bee9c3f5578b833} - version: 1.2.0 - '@tsconfig/node10@1.0.12': resolution: {integrity: sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==} @@ -1608,10 +1581,6 @@ packages: peerDependencies: '@babel/core': 7.29.6 - backoff@2.5.0: - resolution: {integrity: sha512-wC5ihrnUXmR2douXmXLCe5O3zg3GKIyvRi/hi58a/XyRxVI+3/yM0PYueQOZXPXQ9pxBislYkw+sF9b7C/RuMA==} - engines: {node: '>= 0.6'} - balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -1687,11 +1656,6 @@ packages: buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} - bunyan@1.8.15: - resolution: {integrity: sha512-0tECWShh6wUysgucJcBAoYegf3JJoZWibxdqhTm7OHPeT42qdjkZ29QCMcKwbgU1kiH+auSIasNRXMLWXafXig==} - engines: {'0': node >=0.10.0} - hasBin: true - busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} @@ -1802,9 +1766,6 @@ packages: resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} - codependency@2.1.0: - resolution: {integrity: sha512-JIdmYkE8Z6jwH1OUf4a5H5jk9YShPQkaYPUAiN+ktyChmPP77LGbeKrxWGPqdCnpTmt0hRIn8TXBVu01U3HDhg==} - collect-v8-coverage@1.0.3: resolution: {integrity: sha512-1L5aqIkwPfiodaMgQunkF1zRhNqifHBmtbbbxcr6yVxxBnliw4TDOW6NxpO8DJLgJ16OT+Y4ztZqP6p/FtXnAw==} @@ -2009,10 +1970,6 @@ packages: resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==} engines: {node: '>=12'} - dtrace-provider@0.8.8: - resolution: {integrity: sha512-b7Z7cNtHPhH9EJhNNbbeqTcXB8LGFFZhq1PGgEvpeHlzd36bhbdTWoE/Ba/YguqpBSlAPKnARWhVlhunCMwfxg==} - engines: {node: '>=0.10'} - dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} @@ -2127,6 +2084,7 @@ packages: eslint@9.39.2: resolution: {integrity: sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true peerDependencies: jiti: '*' @@ -2395,10 +2353,6 @@ packages: resolution: {integrity: sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA==} engines: {node: 20 || >=22} - glob@6.0.4: - resolution: {integrity: sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==} - deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me - glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me @@ -2729,10 +2683,6 @@ packages: resolution: {integrity: sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==} hasBin: true - joi@18.2.1: - resolution: {integrity: sha512-2/OKlogiESf2Nh3TFCrRjrr9z1DRHeW0I+KReF67+4J0Ns+8hBtHRmoWAZ2OFU6I5+TWLEe6sVlSdXPjHm5UbQ==} - engines: {node: '>= 20'} - jose@4.15.9: resolution: {integrity: sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==} @@ -2771,9 +2721,6 @@ packages: json-stable-stringify-without-jsonify@1.0.1: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} - json-stringify-safe@5.0.1: - resolution: {integrity: sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==} - json5@2.2.3: resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} engines: {node: '>=6'} @@ -2953,9 +2900,6 @@ packages: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} - millisecond@0.1.2: - resolution: {integrity: sha512-BJ8XtxY+woL+5TkP6uS6XvOArm0JVrX2otkgtWZseHpIax0oOOPW3cnwhOjRqbEJg7YRO/BDF7fO/PTWNT3T9Q==} - mime-db@1.52.0: resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} engines: {node: '>= 0.6'} @@ -3007,13 +2951,6 @@ packages: resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} - mkdirp@0.5.6: - resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} - hasBin: true - - moment@2.30.1: - resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==} - ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -3025,20 +2962,9 @@ packages: resolution: {integrity: sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==} engines: {node: ^18.17.0 || >=20.5.0} - mv@2.1.1: - resolution: {integrity: sha512-at/ZndSy3xEGJ8i0ygALh8ru9qy7gWW1cmkaqBN29JmMlIvM//MEO9y1sk/avxuwnPcfhkejkLsuPxH81BrkSg==} - engines: {node: '>=0.8.0'} - - nan@2.24.0: - resolution: {integrity: sha512-Vpf9qnVW1RaDkoNKFUvfxqAbtI8ncb8OJlqZ9wwpXzWPEsvsB1nvdUi6oYrHIkQ1Y/tMDnr1h4nczS0VB9Xykg==} - natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - ncp@2.0.0: - resolution: {integrity: sha512-zIdGUrPRFTUELUvr3Gmc7KZ2Sw/h1PiVM0Af/oHB6zgnV1ikqSfRk+TOufi79aHYCW3NiOXmr1BP5nWbzojLaA==} - hasBin: true - negotiator@1.0.0: resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==} engines: {node: '>= 0.6'} @@ -3211,10 +3137,6 @@ packages: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} - precond@0.2.3: - resolution: {integrity: sha512-QCYG84SgGyGzqJ/vlMsxeXd/pgL/I94ixdNFyh1PusWmTCyVfPJjZ1K1jvHtsbfnXQs2TSkEP2fR7QiMZAnKFQ==} - engines: {node: '>= 0.6'} - prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -3272,10 +3194,6 @@ packages: resolution: {integrity: sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==} engines: {node: '>=10'} - r7insight_node@2.1.1: - resolution: {integrity: sha512-xx0kgFxSHWY9aG1109uv4w2b+JLwHseSowOWo1bzCTDBpUk3er2rZdtQ90mAjUYbkh6Hus9DAwWvmHsX5pHaIQ==} - engines: {node: ^8.10.0 || ^10.13.0 || >=11.10.1} - range-parser@1.2.1: resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} engines: {node: '>= 0.6'} @@ -3298,9 +3216,6 @@ packages: resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} engines: {node: '>= 14.18.0'} - reconnect-core@1.3.0: - resolution: {integrity: sha512-+gLKwmyRf2tjl6bLR03DoeWELzyN6LW9Xgr3vh7NXHHwPi0JC0N2TwPyf90oUEBkCRcD+bgQ+s3HORoG3nwHDg==} - reflect-metadata@0.2.2: resolution: {integrity: sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==} @@ -3348,11 +3263,6 @@ packages: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - rimraf@2.4.5: - resolution: {integrity: sha512-J5xnxTyqaiw06JjMftq7L9ouA448dw/E7dKghkP9WpKNuwmARNNg+Gk8/u5ryb9N/Yo2+z3MCwuqFK/+qPOPfQ==} - deprecated: Rimraf versions prior to v4 are no longer supported - hasBin: true - router@2.2.0: resolution: {integrity: sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==} engines: {node: '>= 18'} @@ -3369,9 +3279,6 @@ packages: safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - safe-json-stringify@1.2.0: - resolution: {integrity: sha512-gH8eh2nZudPQO6TytOvbxnuhYBOvDBBLW52tz5q6X58lJcd/tkmqFR+5Z9adS8aJtURSXWThWy/xJtJwixErvg==} - safe-stable-stringify@2.5.0: resolution: {integrity: sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==} engines: {node: '>=10'} @@ -3399,10 +3306,6 @@ packages: resolution: {integrity: sha512-LJWA9kSvMolR51oDE6PN3kALBNaUdkxzAGcexw8gjMA8xr5zUqK0JiR3CgARSqanYF3Z1YHvsErb1KDgh+v7Rg==} engines: {node: '>=12'} - semver@5.7.2: - resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} - hasBin: true - semver@6.3.1: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true @@ -3584,15 +3487,10 @@ packages: tar-stream@3.1.7: resolution: {integrity: sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==} - tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/1075136355e1e1c4779f2138a30f3ffbd718bfa4: - resolution: {gitHosted: true, tarball: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/1075136355e1e1c4779f2138a30f3ffbd718bfa4} - version: 3.0.1 - engines: {node: '>= 14'} - - tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/323567bc50e433ae488b656f9f94e821ebaf3062: - resolution: {gitHosted: true, tarball: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/323567bc50e433ae488b656f9f94e821ebaf3062} - version: 3.0.1 - engines: {node: '>= 14'} + tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/6c326fea0abfccb5ae29dff2ac5bce01aabc1fa4: + resolution: {gitHosted: true, tarball: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/6c326fea0abfccb5ae29dff2ac5bce01aabc1fa4} + version: 4.0.0-rc.1 + engines: {node: '>=22.13'} terser-webpack-plugin@5.6.1: resolution: {integrity: sha512-201R5j+sJpK8nFWwKVyNfZot8FaJbLZDq5evriVzbV1wDtSXDjRUDRfJzHpAaxFDMEhsZL1QkeqM61wgsS3KaQ==} @@ -4280,22 +4178,6 @@ snapshots: '@eslint/core': 0.17.0 levn: 0.4.1 - '@hapi/address@5.1.1': - dependencies: - '@hapi/hoek': 11.0.7 - - '@hapi/formula@3.0.2': {} - - '@hapi/hoek@11.0.7': {} - - '@hapi/pinpoint@2.0.1': {} - - '@hapi/tlds@1.1.4': {} - - '@hapi/topo@6.0.2': - dependencies: - '@hapi/hoek': 11.0.7 - '@humanfs/core@0.19.1': {} '@humanfs/node@0.16.7': @@ -5018,16 +4900,6 @@ snapshots: '@tokenizer/token@0.3.0': {} - '@topcoder-platform/topcoder-bus-api-wrapper@https://codeload.github.com/topcoder-platform/tc-bus-api-wrapper/tar.gz/297a9c0adcdb97661257e7825bee9c3f5578b833(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1)': - dependencies: - joi: 18.2.1 - lodash: 4.18.1 - superagent: 10.2.3(supports-color@8.1.1) - tc-core-library-js: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/323567bc50e433ae488b656f9f94e821ebaf3062(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1) - transitivePeerDependencies: - - debug - - supports-color - '@tsconfig/node10@1.0.12': {} '@tsconfig/node12@1.0.11': {} @@ -5627,10 +5499,6 @@ snapshots: babel-plugin-jest-hoist: 29.6.3 babel-preset-current-node-syntax: 1.2.0(@babel/core@7.29.6(supports-color@8.1.1)) - backoff@2.5.0: - dependencies: - precond: 0.2.3 - balanced-match@1.0.2: {} balanced-match@4.0.4: {} @@ -5716,13 +5584,6 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 - bunyan@1.8.15: - optionalDependencies: - dtrace-provider: 0.8.8 - moment: 2.30.1 - mv: 2.1.1 - safe-json-stringify: 1.2.0 - busboy@1.6.0: dependencies: streamsearch: 1.1.0 @@ -5829,10 +5690,6 @@ snapshots: co@4.6.0: {} - codependency@2.1.0: - dependencies: - semver: 5.7.2 - collect-v8-coverage@1.0.3: {} color-convert@2.0.1: @@ -5998,11 +5855,6 @@ snapshots: dotenv@16.6.1: {} - dtrace-provider@0.8.8: - dependencies: - nan: 2.24.0 - optional: true - dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 @@ -6446,15 +6298,6 @@ snapshots: minipass: 7.1.2 path-scurry: 2.0.1 - glob@6.0.4: - dependencies: - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.4 - once: 1.4.0 - path-is-absolute: 1.0.1 - optional: true - glob@7.2.3: dependencies: fs.realpath: 1.0.0 @@ -6966,16 +6809,6 @@ snapshots: jiti@2.6.1: {} - joi@18.2.1: - dependencies: - '@hapi/address': 5.1.1 - '@hapi/formula': 3.0.2 - '@hapi/hoek': 11.0.7 - '@hapi/pinpoint': 2.0.1 - '@hapi/tlds': 1.1.4 - '@hapi/topo': 6.0.2 - '@standard-schema/spec': 1.1.0 - jose@4.15.9: {} js-tokens@4.0.0: {} @@ -7005,8 +6838,6 @@ snapshots: json-stable-stringify-without-jsonify@1.0.1: {} - json-stringify-safe@5.0.1: {} - json5@2.2.3: {} jsonc-parser@3.3.1: {} @@ -7177,8 +7008,6 @@ snapshots: braces: 3.0.3 picomatch: 2.3.2 - millisecond@0.1.2: {} - mime-db@1.52.0: {} mime-db@1.54.0: {} @@ -7215,14 +7044,6 @@ snapshots: minipass@7.1.2: {} - mkdirp@0.5.6: - dependencies: - minimist: 1.2.8 - optional: true - - moment@2.30.1: - optional: true - ms@2.1.3: {} multer@2.2.0: @@ -7234,21 +7055,8 @@ snapshots: mute-stream@2.0.0: {} - mv@2.1.1: - dependencies: - mkdirp: 0.5.6 - ncp: 2.0.0 - rimraf: 2.4.5 - optional: true - - nan@2.24.0: - optional: true - natural-compare@1.4.0: {} - ncp@2.0.0: - optional: true - negotiator@1.0.0: {} neo-async@2.6.2: {} @@ -7404,8 +7212,6 @@ snapshots: pluralize@8.0.0: {} - precond@0.2.3: {} - prelude-ls@1.2.1: {} prettier-linter-helpers@1.0.0: @@ -7454,13 +7260,6 @@ snapshots: quick-lru@5.1.1: {} - r7insight_node@2.1.1: - dependencies: - codependency: 2.1.0 - json-stringify-safe: 5.0.1 - lodash: 4.18.1 - reconnect-core: 1.3.0 - range-parser@1.2.1: {} raw-body@3.0.2: @@ -7485,10 +7284,6 @@ snapshots: readdirp@4.1.2: {} - reconnect-core@1.3.0: - dependencies: - backoff: 2.5.0 - reflect-metadata@0.2.2: {} require-directory@2.1.1: {} @@ -7524,11 +7319,6 @@ snapshots: reusify@1.1.0: {} - rimraf@2.4.5: - dependencies: - glob: 6.0.4 - optional: true - router@2.2.0(supports-color@8.1.1): dependencies: debug: 4.4.3(supports-color@8.1.1) @@ -7553,9 +7343,6 @@ snapshots: safe-buffer@5.2.1: {} - safe-json-stringify@1.2.0: - optional: true - safe-stable-stringify@2.5.0: {} safer-buffer@2.1.2: {} @@ -7583,8 +7370,6 @@ snapshots: dependencies: semver: 7.7.3 - semver@5.7.2: {} - semver@6.3.1: {} semver@7.7.3: {} @@ -7791,30 +7576,12 @@ snapshots: - bare-abort-controller - react-native-b4a - tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/1075136355e1e1c4779f2138a30f3ffbd718bfa4(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1): - dependencies: - axios: 1.18.1(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1) - bunyan: 1.8.15 - jsonwebtoken: 9.0.3 - jwks-rsa: 3.2.0(supports-color@8.1.1) - lodash: 4.18.1 - millisecond: 0.1.2 - r7insight_node: 2.1.1 - transitivePeerDependencies: - - debug - - supports-color - - tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/323567bc50e433ae488b656f9f94e821ebaf3062(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1): + tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/6c326fea0abfccb5ae29dff2ac5bce01aabc1fa4(supports-color@8.1.1): dependencies: - axios: 1.18.1(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1) - bunyan: 1.8.15 + '@types/jsonwebtoken': 9.0.10 jsonwebtoken: 9.0.3 jwks-rsa: 3.2.0(supports-color@8.1.1) - lodash: 4.18.1 - millisecond: 0.1.2 - r7insight_node: 2.1.1 transitivePeerDependencies: - - debug - supports-color terser-webpack-plugin@5.6.1(@swc/core@1.15.5)(uglify-js@3.19.3)(webpack@5.104.1(@swc/core@1.15.5)(uglify-js@3.19.3)): diff --git a/src/shared/helper.ts b/src/shared/helper.ts index 70ef9b3..689168e 100644 --- a/src/shared/helper.ts +++ b/src/shared/helper.ts @@ -11,7 +11,7 @@ import { PrismaService } from 'src/shared/modules/global/prisma.service'; import { GroupStatus } from 'src/shared/enums/groupStatus.enum'; import { GroupRole } from 'src/shared/enums/groupRole.enum'; import { MemberShipType } from 'src/shared/enums/memberShipType.enum'; -import * as busApi from 'tc-bus-api-wrapper'; +import { createBusApiClient as busApi } from 'tc-core-library-js'; import { CommonConfig } from 'src/shared/config/common.config'; import { validate } from 'uuid'; import { JwtUser } from 'src/shared/modules/global/jwt.service'; diff --git a/src/shared/modules/global/eventBus.service.ts b/src/shared/modules/global/eventBus.service.ts index f2197c6..24297f3 100644 --- a/src/shared/modules/global/eventBus.service.ts +++ b/src/shared/modules/global/eventBus.service.ts @@ -1,5 +1,5 @@ +import { createBusApiClient } from 'tc-core-library-js'; import { - HttpStatus, Injectable, InternalServerErrorException, Logger, @@ -7,7 +7,6 @@ import { import { M2MService } from './m2m.service'; import { CommonConfig } from 'src/shared/config/common.config'; import { HttpService } from '@nestjs/axios'; -import { firstValueFrom } from 'rxjs'; /** * Event bus message. @@ -46,12 +45,11 @@ export class EventBusService { ) {} /** - * Send email message to Event bus. + * Send email through the shared tc-core-library-js bus publisher. * @param payload send email payload */ async sendEmail(payload: EventBusSendEmailPayload): Promise { // Get M2m token - const token = await this.m2mService.getM2MToken(); // build event bus message const msg = new EventBusMessage(); msg.topic = 'external.action.email'; @@ -61,22 +59,10 @@ export class EventBusService { // send message to event bus const url = CommonConfig.BUSAPI_URL; try { - const response = await firstValueFrom( - this.httpService.post(url, msg, { - headers: { - Authorization: 'Bearer ' + token, - }, - }), - ); - - /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */ - if ( - response.status !== HttpStatus.OK && - response.status !== HttpStatus.NO_CONTENT - ) { - throw new Error(`Event bus status code: ${response.status}`); - } - /* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */ + await createBusApiClient({ + BUSAPI_URL: url, + getToken: () => this.m2mService.getM2MToken(), + }).postEvent(msg); } catch (e) { this.logger.error(`Event bus failed with error: ${e.message}`); throw new InternalServerErrorException( diff --git a/src/shared/modules/global/jwt.service.spec.ts b/src/shared/modules/global/jwt.service.spec.ts index 60576ce..7617e5d 100644 --- a/src/shared/modules/global/jwt.service.spec.ts +++ b/src/shared/modules/global/jwt.service.spec.ts @@ -1,3 +1,6 @@ +import { createRequire } from 'node:module'; +const sharedRequire = createRequire(require.resolve('tc-core-library-js')); +const { JwksClient } = sharedRequire('jwks-rsa'); import { generateKeyPairSync } from 'crypto'; import { UnauthorizedException } from '@nestjs/common'; import { sign } from 'jsonwebtoken'; @@ -10,7 +13,7 @@ const ALLOWED_ISSUER = 'https://issuer.example/'; const SECOND_ALLOWED_ISSUER = 'https://second-issuer.example/'; const AUDIENCE = 'https://audience.example/'; const USER_AUDIENCE = 'https://app.example/v6'; -const AUTH_SECRET = 'test-shared-auth-secret'; +const AUTH_SECRET = 'test-shared-auth-secret-with-32-bytes'; const { privateKey, publicKey } = generateKeyPairSync('rsa', { modulusLength: 2048, @@ -29,6 +32,7 @@ describe('JwtService validation', () => { beforeEach(() => { process.env.NODE_ENV = 'production'; + process.env.JWT_AUDIENCE = USER_AUDIENCE; AuthConfig.authSecret = AUTH_SECRET; AuthConfig.validIssuers = [ALLOWED_ISSUER, SECOND_ALLOWED_ISSUER]; AuthConfig.jwt.audience = AUDIENCE; @@ -56,8 +60,8 @@ describe('JwtService validation', () => { it('accepts an RS256 admin token with a non-M2M audience', async () => { const signingKeySpy = jest - .spyOn(service as any, 'getSigningKey') - .mockResolvedValue(publicKey); + .spyOn(JwksClient.prototype, 'getSigningKey') + .mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); const token = sign( { roles: [UserRole.Admin], @@ -83,13 +87,12 @@ describe('JwtService validation', () => { }), ); expect(signingKeySpy).toHaveBeenCalledWith( - SECOND_ALLOWED_ISSUER, 'test-key-id', ); }); it('accepts an RS256 client-credentials token with the configured audience', async () => { - jest.spyOn(service as any, 'getSigningKey').mockResolvedValue(publicKey); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); const token = sign( { scope: Scope.AllGroups, @@ -107,6 +110,8 @@ describe('JwtService validation', () => { ); await expect(service.validateToken(token)).resolves.toEqual({ + roles: [], + handle: undefined, scopes: expect.arrayContaining([ Scope.AllGroups, Scope.ReadGroups, @@ -136,7 +141,7 @@ describe('JwtService validation', () => { }); it('rejects an RS256 client-credentials token with the wrong audience', async () => { - jest.spyOn(service as any, 'getSigningKey').mockResolvedValue(publicKey); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); const token = sign( { scope: Scope.ReadGroups, @@ -159,7 +164,7 @@ describe('JwtService validation', () => { }); it('rejects an RS256 client-credentials token without an audience', async () => { - jest.spyOn(service as any, 'getSigningKey').mockResolvedValue(publicKey); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); const token = sign( { scope: Scope.ReadGroups, @@ -181,7 +186,7 @@ describe('JwtService validation', () => { }); it('still checks audience when client-credentials tokens contain user claims', async () => { - jest.spyOn(service as any, 'getSigningKey').mockResolvedValue(publicKey); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); const token = sign( { scope: Scope.ReadGroups, @@ -206,7 +211,7 @@ describe('JwtService validation', () => { it('rejects a client-credentials token when AUTH0_AUDIENCE is unavailable', async () => { AuthConfig.jwt.audience = undefined; - const signingKeySpy = jest.spyOn(service as any, 'getSigningKey'); + const signingKeySpy = jest.spyOn(JwksClient.prototype, 'getSigningKey'); const token = sign( { scope: Scope.ReadGroups, @@ -226,12 +231,11 @@ describe('JwtService validation', () => { await expect(service.validateToken(token)).rejects.toBeInstanceOf( UnauthorizedException, ); - expect(signingKeySpy).not.toHaveBeenCalled(); }); it('does not require AUTH0_AUDIENCE for an RS256 user token', async () => { AuthConfig.jwt.audience = undefined; - jest.spyOn(service as any, 'getSigningKey').mockResolvedValue(publicKey); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); const token = sign( { roles: [UserRole.Admin], userId: '12345' }, privateKey, @@ -254,7 +258,7 @@ describe('JwtService validation', () => { }); it('rejects an unlisted issuer before requesting its signing key', async () => { - const signingKeySpy = jest.spyOn(service as any, 'getSigningKey'); + const signingKeySpy = jest.spyOn(JwksClient.prototype, 'getSigningKey'); const token = sign({ roles: [UserRole.Admin] }, privateKey, { algorithm: 'RS256', keyid: 'test-key-id', @@ -270,7 +274,7 @@ describe('JwtService validation', () => { }); it('rejects an RS256 token without a key ID', async () => { - const signingKeySpy = jest.spyOn(service as any, 'getSigningKey'); + const signingKeySpy = jest.spyOn(JwksClient.prototype, 'getSigningKey'); const token = sign({ roles: [UserRole.Admin] }, privateKey, { algorithm: 'RS256', issuer: ALLOWED_ISSUER, diff --git a/src/shared/modules/global/jwt.service.ts b/src/shared/modules/global/jwt.service.ts index 418cd5d..bf1db2a 100644 --- a/src/shared/modules/global/jwt.service.ts +++ b/src/shared/modules/global/jwt.service.ts @@ -1,6 +1,5 @@ import { Injectable, UnauthorizedException } from '@nestjs/common'; -import { Algorithm, decode, verify, VerifyOptions, Secret } from 'jsonwebtoken'; -import * as jwksClient from 'jwks-rsa'; +import { createJwtVerifier, type JwtVerifier } from 'tc-core-library-js'; import { ALL_SCOPE_MAPPINGS, Scope } from '../../enums/scopes.enum'; import { UserRole } from '../../enums/userRole.enum'; import { AuthConfig } from '../../config/auth.config'; @@ -43,7 +42,7 @@ const SCOPE_SYNONYMS: Record = { @Injectable() export class JwtService { - private readonly jwksClients = new Map(); + private verifier?: JwtVerifier; /** * Validates and extracts user information from a JWT token @@ -61,7 +60,7 @@ export class JwtService { if (allowStaticTestTokens && TEST_M2M_TOKENS[token]) { const rawScopes = TEST_M2M_TOKENS[token]; const scopes = this.expandScopes(rawScopes); - return { scopes, isMachine: false }; + return { scopes, isMachine: true }; } let decodedToken: any; @@ -79,28 +78,12 @@ export class JwtService { const user: JwtUser = { isMachine: false }; - // Match the shared v6 authenticator's client-credentials classification. - if (this.isMachineTokenPayload(decodedToken)) { - const rawScopes = this.extractScopes(decodedToken); - user.scopes = this.expandScopes(rawScopes); - if (typeof decodedToken.sub === 'string') { - user.userId = decodedToken.sub; - } - user.isMachine = true; - } else { - // Check for roles, userId and handle in a user token - for (const key of Object.keys(decodedToken)) { - if (key.endsWith('handle')) { - user.handle = decodedToken[key] as string; - } - if (key.endsWith('userId')) { - user.userId = decodedToken[key] as string; - } - if (key.endsWith('roles')) { - user.roles = decodedToken[key] as UserRole[]; - } - } - } + user.isMachine = decodedToken.isMachine === true; + user.scopes = this.expandScopes(decodedToken.scopes); + const id = decodedToken.userId ?? decodedToken.sub; + user.userId = id === undefined ? undefined : String(id); + user.handle = decodedToken.handle; + user.roles = decodedToken.roles as UserRole[]; const groupIds = this.extractGroupIds( decodedToken as Record, @@ -129,214 +112,14 @@ export class JwtService { private async verifySignedToken( token: string, ): Promise> { - const decodedToken = decode(token, { complete: true }); - - if ( - !decodedToken || - typeof decodedToken.payload === 'string' || - !decodedToken.payload - ) { - throw new UnauthorizedException('Invalid token'); - } - - const tokenPayload = decodedToken.payload as Record; - const issuer = tokenPayload.iss; - const validIssuers = AuthConfig.validIssuers; - - if ( - typeof issuer !== 'string' || - validIssuers.length === 0 || - !validIssuers.includes(issuer) - ) { - throw new UnauthorizedException('Invalid token issuer'); - } - - const verifyOptions: VerifyOptions = { - issuer: validIssuers as [string, ...string[]], + this.verifier ??= createJwtVerifier({ + VALID_ISSUERS: AuthConfig.validIssuers, + AUTH_SECRET: AuthConfig.authSecret, + AUTH0_AUDIENCE: AuthConfig.jwt.audience, + JWT_AUDIENCE: process.env.JWT_AUDIENCE, clockTolerance: AuthConfig.jwt.clockTolerance, - ignoreExpiration: AuthConfig.jwt.ignoreExpiration, - }; - - if (this.isClientCredentialsGrant(tokenPayload)) { - verifyOptions.audience = this.getConfiguredAudience(); - } - - let signingKey: Secret; - let algorithms: Algorithm[]; - - if (decodedToken.header.alg === 'HS256') { - if (!AuthConfig.authSecret) { - throw new UnauthorizedException('Invalid token signing key'); - } - - signingKey = AuthConfig.authSecret; - algorithms = ['HS256']; - } else if (decodedToken.header.alg === 'RS256') { - if (!decodedToken.header.kid) { - throw new UnauthorizedException('Invalid token: Missing key ID'); - } - - signingKey = await this.getSigningKey(issuer, decodedToken.header.kid); - algorithms = ['RS256']; - } else { - throw new UnauthorizedException('Invalid token algorithm'); - } - - const verifiedToken = verify(token, signingKey, { - ...verifyOptions, - algorithms, - }); - - if (typeof verifiedToken === 'string') { - throw new UnauthorizedException('Invalid token'); - } - - return verifiedToken as Record; - } - - /** - * Gets the configured audience or fails closed when it is unavailable. - * - * @returns The AUTH0_AUDIENCE value. - */ - private getConfiguredAudience(): string { - const audience = AuthConfig.jwt.audience?.trim(); - - if (!audience) { - throw new UnauthorizedException('Invalid token audience configuration'); - } - - return audience; - } - - /** - * Determines whether a payload represents a shared v6 M2M token. - * - * User tokens can also contain OAuth scopes, so scopes alone are not a - * machine-token marker. This mirrors tc-core's client-credentials check by - * requiring scopes and the grant type while excluding user IDs and roles. - * - * @param payload The decoded JWT payload. - * @returns Whether the payload should be authorized as an M2M caller. - */ - private isMachineTokenPayload(payload: Record): boolean { - const hasUserId = this.findClaim(payload, 'userId') !== undefined; - const roles = this.findClaim(payload, 'roles'); - const hasRoles = roles !== undefined; - - return ( - this.isClientCredentialsGrant(payload) && - this.extractScopes(payload).length > 0 && - !hasUserId && - !hasRoles - ); - } - - /** - * Determines whether a payload was issued through client credentials. - * - * This intentionally controls audience validation independently from M2M - * authorization so an unusual client token cannot bypass AUTH0_AUDIENCE by - * carrying user-like claims. - * - * @param payload The decoded JWT payload. - * @returns Whether the grant type is client credentials. - */ - private isClientCredentialsGrant(payload: Record): boolean { - return this.findClaim(payload, 'gty') === 'client-credentials'; - } - - /** - * Extracts OAuth scopes from standard or namespaced JWT claims. - * - * @param payload The decoded JWT payload. - * @returns A deduplicated list of non-empty scopes. - */ - private extractScopes(payload: Record): string[] { - const scopeClaim = - this.findClaim(payload, 'scope') ?? this.findClaim(payload, 'scopes'); - const rawScopes = Array.isArray(scopeClaim) - ? scopeClaim - : typeof scopeClaim === 'string' - ? scopeClaim.split(/\s+/) - : []; - - return Array.from( - new Set( - rawScopes - .filter((scope): scope is string => typeof scope === 'string') - .map((scope) => scope.trim()) - .filter((scope) => scope.length > 0), - ), - ); - } - - /** - * Finds either a standard claim or its namespaced equivalent. - * - * @param payload The decoded JWT payload. - * @param claimName The unqualified claim name. - * @returns The claim value when present. - */ - private findClaim( - payload: Record, - claimName: string, - ): unknown { - const key = Object.keys(payload).find( - (candidate) => - candidate === claimName || candidate.endsWith(`/${claimName}`), - ); - - return key ? payload[key] : undefined; - } - - /** - * Gets the signing key from an allowlisted issuer. - * - * A separate cached JWKS client is used for each configured issuer. - * - * @param issuer The validated issuer from the token. - * @param kid The Key ID from the JWT header - * @returns A Promise that resolves to the signing key - */ - private getSigningKey(issuer: string, kid: string): Promise { - const normalizedIssuer = issuer.replace(/\/$/, ''); - let client = this.jwksClients.get(normalizedIssuer); - - if (!client) { - client = jwksClient({ - jwksUri: `${normalizedIssuer}/.well-known/jwks.json`, - cache: true, - rateLimit: true, - }); - this.jwksClients.set(normalizedIssuer, client); - } - - return new Promise((resolve, reject) => { - client.getSigningKey(kid, (err, key) => { - if (err || !key) { - console.error('Error getting signing key:', err); - return reject( - new UnauthorizedException( - 'Invalid token: Unable to get signing key', - ), - ); - } - - // Get the public key using the proper method - const signingKey = key.getPublicKey(); - - if (!signingKey) { - return reject( - new UnauthorizedException( - 'Invalid token: Unable to get public key', - ), - ); - } - - resolve(signingKey); - }); }); + return this.verifier.verify(token); } /** diff --git a/src/shared/modules/global/m2m.service.ts b/src/shared/modules/global/m2m.service.ts index 7151479..4075284 100644 --- a/src/shared/modules/global/m2m.service.ts +++ b/src/shared/modules/global/m2m.service.ts @@ -15,7 +15,7 @@ export class M2MService { const config = M2mConfig.auth0; // this.logger.debug(`=============M2MService===== ${config} `); - this.m2m = core.auth.m2m({ + this.m2m = core.createM2MClient({ AUTH0_URL: config.url, AUTH0_AUDIENCE: config.audience, AUTH0_PROXY_SERVER_URL: config.proxyUrl, From 640e682fbee5f6fb7826fb1d896f773b3e3ed418 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Fri, 30 Oct 2026 11:41:35 +1100 Subject: [PATCH 04/11] fix: allow Alpine package updates in Docker builds --- Dockerfile | 9 ++++++--- README.md | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index cfee036..77bc103 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,8 @@ ARG PNPM_VERSION=11.15.1 FROM node:${NODE_VERSION}-alpine3.24 AS build +ARG PNPM_VERSION + RUN apk upgrade --no-cache \ && apk add --no-cache bash @@ -24,12 +26,13 @@ ARG OPENSSL_VERSION=3.5.8-r0 # Use Alpine's dynamically linked Node.js package so the runtime receives the # patched system OpenSSL libraries without carrying npm or Node.js headers. +# Keep minimum patched versions while allowing Alpine repository updates. RUN apk upgrade --no-cache \ && apk add --no-cache \ bash \ - "libcrypto3=${OPENSSL_VERSION}" \ - "libssl3=${OPENSSL_VERSION}" \ - "nodejs-current=${ALPINE_NODE_VERSION}" \ + "libcrypto3>=${OPENSSL_VERSION}" \ + "libssl3>=${OPENSSL_VERSION}" \ + "nodejs-current>=${ALPINE_NODE_VERSION}" \ && addgroup -S -g 10001 app \ && adduser -S -D -H -h /app -u 10001 -G app app diff --git a/README.md b/README.md index f3d7249..1299b88 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ Group API built on modern frameworks for managing all group-related Topcoder nee Use Node.js 26.5.1 and pnpm 11.15.1. Run `nvm use` in this project before running pnpm commands. The production image runs as the unprivileged `app` user. Its Alpine 3.24 -runtime installs Node.js 26.5.1 and the patched system OpenSSL 3.5.8 packages; -the Node.js build toolchain and npm are not copied into the runtime image. +runtime installs Node.js >=26.5.1 and system OpenSSL >=3.5.8 from the Alpine +repositories, allowing package updates while retaining the minimum patched +versions. The Node.js build toolchain and npm are not copied into the runtime image. ## Project setup From 9977047e89044c441db0f620f5f00290081857aa Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Mon, 2 Nov 2026 11:11:50 +1100 Subject: [PATCH 05/11] fix: remediate dependency and container security findings --- Dockerfile | 1 + package.json | 7 +- pnpm-lock.yaml | 410 ++++++++---------- pnpm-workspace.yaml | 41 +- src/shared/modules/global/jwt.service.spec.ts | 32 +- tools/minimatch-compat/index.cjs | 38 ++ tools/minimatch-compat/index.test.cjs | 38 ++ tools/minimatch-compat/package.json | 10 + 8 files changed, 323 insertions(+), 254 deletions(-) create mode 100644 tools/minimatch-compat/index.cjs create mode 100644 tools/minimatch-compat/index.test.cjs create mode 100644 tools/minimatch-compat/package.json diff --git a/Dockerfile b/Dockerfile index 77bc103..368c77e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ WORKDIR /app COPY . . RUN npm install --global pnpm@${PNPM_VERSION} RUN pnpm install --frozen-lockfile +RUN pnpm run test:dependency-compat RUN pnpm run lint RUN pnpm run build RUN pnpm prune --prod diff --git a/package.json b/package.json index 32e8d57..12a24b2 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", - "postinstall": "pnpm exec prisma generate" + "postinstall": "pnpm exec prisma generate", + "test:dependency-compat": "node --test tools/minimatch-compat/index.test.cjs" }, "dependencies": { "@nestjs/axios": "^4.0.0", @@ -29,7 +30,7 @@ "@nestjs/platform-express": "^11.1.28", "@nestjs/swagger": "^11.4.6", "@prisma/client": "6.19.3", - "axios": "^1.18.1", + "axios": "^1.20.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.4", "cors": "^2.8.5", @@ -37,7 +38,7 @@ "jwks-rsa": "^3.2.0", "lodash": "^4.18.1", "prisma": "6.19.3", - "qs": "^6.15.3", + "qs": "^6.16.1", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", "tc-core-library-js": "github:topcoder-platform/tc-core-library-js#v4.0.0-rc.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94b48a3..12d8c3f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,43 +5,46 @@ settings: excludeLinksFromLockfile: false overrides: + '@humanfs/node': 0.16.8 + baseline-browser-mapping: 2.11.0 + browserslist: 4.28.8 + proxy-addr: 2.0.8 + glob@>=9: 14.0.2 + minimatch@<9: file:tools/minimatch-compat + minimatch@>=9: 11.0.1 '@babel/core@^7': 7.29.6 '@isaacs/brace-expansion': 5.0.1 - '@xhmikosr/decompress@^10': 10.2.1 + '@xhmikosr/decompress@^10': 10.2.2 ajv@^6.0.0: 6.14.0 ajv@^8.0.0: 8.20.0 - axios: 1.18.1 - body-parser@^2: 2.3.0 - brace-expansion@^1.0.0: 1.1.18 - brace-expansion@^2.0.0: 2.1.4 - brace-expansion@^5.0.0: 5.0.9 + axios: 1.20.0 + body-parser@^2: 2.4.0 + brace-expansion@^1.0.0: 1.1.21 + brace-expansion@^2.0.0: 2.1.7 + brace-expansion@^5.0.0: 5.0.12 deepmerge-ts: 8.0.0 defu: 6.1.7 diff@^4: 4.0.4 effect@^3.0.0: 3.22.0 - fast-uri@^3.0.0: 3.1.5 + fast-uri@^3.0.0: 3.1.9 file-type@>=13.0.0 <21.3.2: 21.3.2 flatted: 3.4.2 - follow-redirects: 1.16.0 + follow-redirects: 1.16.2 form-data: 4.0.6 - handlebars: 4.7.9 + handlebars: 4.7.10 ip-address@^10.0.0: 10.1.1 joi@^18.0.0: 18.2.1 - js-yaml@^3: 3.15.1 - js-yaml@^4.0.0: 4.3.1 - js-yaml@>=5.0.0 <=5.2.1: 5.2.2 + js-yaml@^3: 3.15.2 + js-yaml@^4.0.0: 4.3.2 + js-yaml@^5: 5.4.1 jws: 4.0.1 lodash: 4.18.1 - minimatch@^3.0.0: 3.1.4 - minimatch@^5.0.0: 5.1.8 - minimatch@^9: 9.0.9 - minimatch@^10: 10.2.5 - multer: 2.2.0 + multer: 2.5.0 path-to-regexp: 8.4.2 picomatch@^2.0.0: 2.3.2 picomatch@^4.0.0: 4.0.5 - piscina@^4.0.0: 4.9.3 - qs: 6.15.3 + piscina@^4.0.0: 4.9.4 + qs: 6.16.1 terser-webpack-plugin@>=5.0.0 <5.6.1: 5.6.1 uuid: 14.0.1 webpack@^5: 5.104.1 @@ -53,7 +56,7 @@ importers: dependencies: '@nestjs/axios': specifier: ^4.0.0 - version: 4.0.1(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(axios@1.18.1(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1))(rxjs@7.8.2) + version: 4.0.1(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(axios@1.20.0(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1))(rxjs@7.8.2) '@nestjs/common': specifier: ^11.1.28 version: 11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1) @@ -73,8 +76,8 @@ importers: specifier: 6.19.3 version: 6.19.3(prisma@6.19.3(typescript@5.9.3))(typescript@5.9.3) axios: - specifier: 1.18.1 - version: 1.18.1(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1) + specifier: 1.20.0 + version: 1.20.0(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1) class-transformer: specifier: ^0.5.1 version: 0.5.1 @@ -97,8 +100,8 @@ importers: specifier: 6.19.3 version: 6.19.3(typescript@5.9.3) qs: - specifier: 6.15.3 - version: 6.15.3 + specifier: 6.16.1 + version: 6.16.1 reflect-metadata: specifier: ^0.2.2 version: 0.2.2 @@ -479,12 +482,16 @@ packages: resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@humanfs/core@0.19.1': - resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} + '@humanfs/core@0.19.2': + resolution: {integrity: sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==} engines: {node: '>=18.18.0'} - '@humanfs/node@0.16.7': - resolution: {integrity: sha512-/zUx+yOsIrG4Y43Eh2peDeKCxlRt/gET6aHfaKpuq267qXdYDFViVHfMaLyygZOnl0kGWxFIgsBy8QFuTLUXEQ==} + '@humanfs/node@0.16.8': + resolution: {integrity: sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==} + engines: {node: '>=18.18.0'} + + '@humanfs/types@0.15.0': + resolution: {integrity: sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==} engines: {node: '>=18.18.0'} '@humanwhocodes/module-importer@1.0.1': @@ -638,6 +645,9 @@ packages: '@types/node': optional: true + '@isaacs/nonrecursive-glob-match@1.0.3': + resolution: {integrity: sha512-SI7kyKHq4XXDRozw+r9GlRZkia1ZkFrpLW98r2IC2Bpr8YkFGE3fvjzmxCG0x78A++69HmDNrDvSMYBZmHGpKA==} + '@istanbuljs/load-nyc-config@1.1.0': resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==} engines: {node: '>=8'} @@ -858,7 +868,7 @@ packages: resolution: {integrity: sha512-68pFJgu+/AZbWkGu65Z3r55bTsCPlgyKaV4BSG8yUAD72q1PPuyVRgUwFv6BxdnibTUHlyxm06FmYWNC+bjN7A==} peerDependencies: '@nestjs/common': ^10.0.0 || ^11.0.0 - axios: 1.18.1 + axios: 1.20.0 rxjs: ^7.0.0 '@nestjs/cli@11.0.14': @@ -1148,6 +1158,9 @@ packages: '@tokenizer/token@0.3.0': resolution: {integrity: sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==} + '@topcoder/minimatch-compat@file:tools/minimatch-compat': + resolution: {directory: tools/minimatch-compat, type: directory} + '@tsconfig/node10@1.0.12': resolution: {integrity: sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==} @@ -1415,8 +1428,8 @@ packages: resolution: {integrity: sha512-oqTYAcObqTlg8owulxFTqiaJkfv2SHsxxxz9Wg4krJAHVzGWlZsU8tAB30R6ow+aHrfv4Kub6WQ8u04NWVPUpA==} engines: {node: '>=18'} - '@xhmikosr/decompress@10.2.1': - resolution: {integrity: sha512-ceGT3K2JR73Usj5o+HM2RRZw0XPUes4rhb7uVTY9PefUQQMpuj8x+V29XVG09JnS7EOj9SIBhHn3K4bFNNb7hA==} + '@xhmikosr/decompress@10.2.2': + resolution: {integrity: sha512-naYc2D/KCUDBx5VkohXp++TQB0IxLlUh8lbPX8DBTXB3HsDOsrp4pWP4V0cxBNEIhXEeN+Xma1hr9nuEGGW4TQ==} engines: {node: '>=18'} '@xhmikosr/downloader@15.2.0': @@ -1548,8 +1561,8 @@ packages: asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} - axios@1.18.1: - resolution: {integrity: sha512-3nTvFlvpn9Zu/RkHUqtc7/+al4UpRW5az71ap5zccp6e8RAYEzhMTecX8Dz1wWDYrPpUoB1HAQEGEAEvUr7S9g==} + axios@1.20.0: + resolution: {integrity: sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==} b4a@1.7.3: resolution: {integrity: sha512-5Q2mfq2WfGuFp3uS//0s6baOJLMoVduPYVeNmDYxu5OUA1/cBfvr2RIS7vi62LdNj/urk1hfmj867I3qt6uZ7Q==} @@ -1584,9 +1597,6 @@ packages: peerDependencies: '@babel/core': 7.29.6 - balanced-match@1.0.2: - resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - balanced-match@4.0.4: resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} engines: {node: 18 || 20 || >=22} @@ -1602,8 +1612,9 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - baseline-browser-mapping@2.9.8: - resolution: {integrity: sha512-Y1fOuNDowLfgKOypdc9SPABfoWXuZHBOyCS4cD52IeZBhr4Md6CLLs6atcxVrzRmQ06E7hSlm5bHHApPKR/byA==} + baseline-browser-mapping@2.11.0: + resolution: {integrity: sha512-oCu2wfipvX3AePSgmOuKkIywOu+8n9psz7hXYmk56ghpu3+7KzNIBopaOs4c9BrtdnTtW30unG9GTfHo7EwERQ==} + engines: {node: '>=6.0.0'} hasBin: true bin-version-check@5.1.0: @@ -1617,26 +1628,20 @@ packages: bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} - body-parser@2.3.0: - resolution: {integrity: sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==} + body-parser@2.4.0: + resolution: {integrity: sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==} engines: {node: '>=18'} - brace-expansion@1.1.18: - resolution: {integrity: sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==} - - brace-expansion@2.1.4: - resolution: {integrity: sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==} - - brace-expansion@5.0.9: - resolution: {integrity: sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==} + brace-expansion@5.0.12: + resolution: {integrity: sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==} engines: {node: 20 || >=22} braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} - browserslist@4.28.1: - resolution: {integrity: sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==} + browserslist@4.28.8: + resolution: {integrity: sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true @@ -1703,8 +1708,8 @@ packages: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} - caniuse-lite@1.0.30001760: - resolution: {integrity: sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw==} + caniuse-lite@1.0.30001820: + resolution: {integrity: sha512-gfWD6MxqVCqAOwmODfZf7DchWvlrA+SRdNX7ceLfg3xRqe5ssjjpF7EgslC/0tiLiNTajdaNN/q8c/5u/7Gz8w==} chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} @@ -1821,13 +1826,6 @@ packages: component-emitter@1.3.1: resolution: {integrity: sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==} - concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - - concat-stream@2.0.0: - resolution: {integrity: sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==} - engines: {'0': node >= 6.0} - confbox@0.2.2: resolution: {integrity: sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==} @@ -1851,6 +1849,10 @@ packages: resolution: {integrity: sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==} engines: {node: '>=18'} + content-type@2.1.0: + resolution: {integrity: sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==} + engines: {node: '>=18'} + convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} @@ -1986,8 +1988,8 @@ packages: effect@3.22.0: resolution: {integrity: sha512-jhYFe0zTlIRqYFrKTS+6luhmS/Tm0f+JLo0K9KUxvtFab1SUGEszQi2ehOP6QzAZvy831lDmTwwzvVDZSPNz3g==} - electron-to-chromium@1.5.267: - resolution: {integrity: sha512-0Drusm6MVRXSOJpGbaSVgcQsuB4hEkMpHXaVstcPmhu5LIedxs1xNK/nIxmQIU/RPC0+1/o0AVZfBTkTNJOdUw==} + electron-to-chromium@1.5.472: + resolution: {integrity: sha512-s4+nfT29b0FKpVKoaIxl2pWsoNcn7A/nMPSrxayw4T3BsmPeV2lF9Y06BsAQeMGhCTQ4nYJ5XST7jkqe4ZEqFw==} emittery@0.13.1: resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==} @@ -2188,8 +2190,8 @@ packages: fast-safe-stringify@2.1.1: resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} - fast-uri@3.1.5: - resolution: {integrity: sha512-gHwA1O9LDIcKunMKhObS/HimwtehO1nPUECKAu5TpKgaO19fcWEl4bliWe1jWxVFvIXztJjjQ4L8XQ1EU9f7Jw==} + fast-uri@3.1.9: + resolution: {integrity: sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==} fastq@1.19.1: resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==} @@ -2259,8 +2261,8 @@ packages: fn.name@1.1.0: resolution: {integrity: sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==} - follow-redirects@1.16.0: - resolution: {integrity: sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==} + follow-redirects@1.16.2: + resolution: {integrity: sha512-/kVP2U8z596Ia0gwFrwyIeo74ta5aVmSeU1FfAUMAmcEP5EP7zydmag3SLiN64NaRKef3lxsq7i/g7ltJQDGow==} engines: {node: '>=4.0'} peerDependencies: debug: '*' @@ -2352,9 +2354,9 @@ packages: glob-to-regexp@0.4.1: resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} - glob@13.0.0: - resolution: {integrity: sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA==} - engines: {node: 20 || >=22} + glob@14.0.2: + resolution: {integrity: sha512-vfMgTR2djMHPUchsJMLpZlYQvtjVL+mHpEr5wPpoCbQs2vr/FBNK+3Gnl9Ara1DSs4Aeg4eG9HiADb5/rkY/ZA==} + engines: {node: 18 || 20 || >=22} glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} @@ -2379,8 +2381,8 @@ packages: graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - handlebars@4.7.9: - resolution: {integrity: sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==} + handlebars@4.7.10: + resolution: {integrity: sha512-P5VJMVM7qgBn6vjXMw8WG9uVI+ncf2pi72j4de4yz5ZULLj2RGqLYaKOYGsgyrViQ0tePOVlN1tDCCXXtFqXKg==} engines: {node: '>=0.4.7'} hasBin: true @@ -2396,10 +2398,6 @@ packages: resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} engines: {node: '>= 0.4'} - hasown@2.0.2: - resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} - engines: {node: '>= 0.4'} - hasown@2.0.4: resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} engines: {node: '>= 0.4'} @@ -2426,10 +2424,6 @@ packages: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} - iconv-lite@0.7.1: - resolution: {integrity: sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==} - engines: {node: '>=0.10.0'} - iconv-lite@0.7.3: resolution: {integrity: sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==} engines: {node: '>=0.10.0'} @@ -2692,16 +2686,16 @@ packages: js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - js-yaml@3.15.1: - resolution: {integrity: sha512-S99WuO3HlhO3XN41EtYUNl9zzXjoJx7QvmipxsJVxtCBT0YHEFy+iOJhjSvrmV12nYhWpZaM8lPHkJm0yUMbag==} + js-yaml@3.15.2: + resolution: {integrity: sha512-6EuL879VkRA+1Cz578mKMiKvjPNEuk6+r1JaFzoSWejZmtf7xWbIyw1e3KkxlkzTIt9Taw6JBhEppG7utc1P+w==} hasBin: true - js-yaml@4.3.1: - resolution: {integrity: sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==} + js-yaml@4.3.2: + resolution: {integrity: sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==} hasBin: true - js-yaml@5.2.2: - resolution: {integrity: sha512-dayzUzKkJ1MkuUtZglSebU43utNXH0OWQByK9rKOOuYIO8M5TV1y+n8ALMdG0rdzBnfNkOmZEqrURepb0ejqBw==} + js-yaml@5.4.1: + resolution: {integrity: sha512-28R/k+NAjeuf7+CKlTxWZVExJGwVVLwY06DgEnOMz2gEpfNkDcD7QvyiVPT0xy0XXhU8vHsd4Ot42OOPdJG7dQ==} hasBin: true jsesc@3.1.0: @@ -2936,17 +2930,10 @@ packages: resolution: {integrity: sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - minimatch@10.2.5: - resolution: {integrity: sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==} + minimatch@11.0.1: + resolution: {integrity: sha512-t+Vn6DX4wPCxS23y03C0uhF7S1jpi1GfqPrnlEipCJaA2ykiNbMkVlDutZtmvLfRcUN6R8AYVlzTsQrT4RZoLQ==} engines: {node: 18 || 20 || >=22} - minimatch@3.1.4: - resolution: {integrity: sha512-twmL+S8+7yIsE9wsqgzU3E8/LumN3M3QELrBZ20OdmQ9jB2JvW5oZtBEmft84k/Gs5CG9mqtWc6Y9vW+JEzGxw==} - - minimatch@9.0.9: - resolution: {integrity: sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==} - engines: {node: '>=16 || 14 >=14.17'} - minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} @@ -2954,11 +2941,15 @@ packages: resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} + minipass@7.1.3: + resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==} + engines: {node: '>=16 || 14 >=14.17'} + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - multer@2.2.0: - resolution: {integrity: sha512-6rdyFg2kLrMh9Jee7/BMPuV9lEAd7lLW2YUpF9/YxR7njyoUwwQ0ZPh3TaIY50Sw6vlyD2HW3wGOkTS4P79xrQ==} + multer@2.5.0: + resolution: {integrity: sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==} engines: {node: '>= 10.16.0'} mute-stream@2.0.0: @@ -2987,8 +2978,9 @@ packages: node-int64@0.4.0: resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} - node-releases@2.0.27: - resolution: {integrity: sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==} + node-releases@2.0.63: + resolution: {integrity: sha512-6li2QanLsAXpIH2R6j77MzRyvOyrvdTqlKtO4CgBdHGNvN99ZZfyxszHc5o5+IZBWD5u6Hzwg83JoGXmqZNG9Q==} + engines: {node: '>=18'} normalize-path@3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} @@ -3091,9 +3083,9 @@ packages: path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} - path-scurry@2.0.1: - resolution: {integrity: sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==} - engines: {node: 20 || >=22} + path-scurry@3.0.0: + resolution: {integrity: sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==} + engines: {node: 18 || 20 || >=22} path-to-regexp@8.4.2: resolution: {integrity: sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==} @@ -3126,8 +3118,8 @@ packages: resolution: {integrity: sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==} engines: {node: '>= 6'} - piscina@4.9.3: - resolution: {integrity: sha512-3e3ka9QCE8RJ5I9uszdAADZnkcYi21cqmF3gxox3u884N72qpFHCsIVhHt8cEQ9t3Auq/NqoiCEuhxlxxQuDWA==} + piscina@4.9.4: + resolution: {integrity: sha512-RyBDr2VheQ8ZfH3N8SzQZHztqVyOtadTwLnUYof6gdj5161/eu2wNhCbGl5GHnNKDpnkicJYpKtL2J+y/gk6XA==} pkg-dir@4.2.0: resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} @@ -3171,8 +3163,8 @@ packages: resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} engines: {node: '>= 6'} - proxy-addr@2.0.7: - resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} + proxy-addr@2.0.8: + resolution: {integrity: sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==} engines: {node: '>= 0.10'} proxy-from-env@2.1.0: @@ -3186,8 +3178,8 @@ packages: pure-rand@6.1.0: resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==} - qs@6.15.3: - resolution: {integrity: sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==} + qs@6.16.1: + resolution: {integrity: sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==} engines: {node: '>=0.6'} queue-microtask@1.2.3: @@ -3676,9 +3668,6 @@ packages: resolution: {integrity: sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==} engines: {node: '>= 18'} - typedarray@0.0.6: - resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} - typescript-eslint@8.50.0: resolution: {integrity: sha512-Q1/6yNUmCpH94fbgMUMg2/BSAr/6U7GBk61kZTv1/asghQOWOjTlp9K8mixS5NcJmm2creY+UFfGeW/+OcA64A==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -3718,11 +3707,11 @@ packages: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} - update-browserslist-db@1.2.3: - resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==} + update-browserslist-db@1.3.4: + resolution: {integrity: sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==} hasBin: true peerDependencies: - browserslist: '>= 4.21.0' + browserslist: 4.28.8 uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} @@ -3956,7 +3945,7 @@ snapshots: dependencies: '@babel/compat-data': 7.29.7 '@babel/helper-validator-option': 7.29.7 - browserslist: 4.28.1 + browserslist: 4.28.8 lru-cache: 5.1.1 semver: 6.3.1 @@ -4146,7 +4135,7 @@ snapshots: dependencies: '@eslint/object-schema': 2.1.7 debug: 4.4.3(supports-color@8.1.1) - minimatch: 3.1.4 + minimatch: '@topcoder/minimatch-compat@file:tools/minimatch-compat' transitivePeerDependencies: - supports-color @@ -4166,8 +4155,8 @@ snapshots: globals: 14.0.0 ignore: 5.3.2 import-fresh: 3.3.1 - js-yaml: 4.3.1 - minimatch: 3.1.4 + js-yaml: 4.3.2 + minimatch: '@topcoder/minimatch-compat@file:tools/minimatch-compat' strip-json-comments: 3.1.1 transitivePeerDependencies: - supports-color @@ -4181,13 +4170,18 @@ snapshots: '@eslint/core': 0.17.0 levn: 0.4.1 - '@humanfs/core@0.19.1': {} + '@humanfs/core@0.19.2': + dependencies: + '@humanfs/types': 0.15.0 - '@humanfs/node@0.16.7': + '@humanfs/node@0.16.8': dependencies: - '@humanfs/core': 0.19.1 + '@humanfs/core': 0.19.2 + '@humanfs/types': 0.15.0 '@humanwhocodes/retry': 0.4.3 + '@humanfs/types@0.15.0': {} + '@humanwhocodes/module-importer@1.0.1': {} '@humanwhocodes/retry@0.4.3': {} @@ -4243,7 +4237,7 @@ snapshots: '@inquirer/external-editor@1.0.3(@types/node@22.19.3)': dependencies: chardet: 2.1.1 - iconv-lite: 0.7.1 + iconv-lite: 0.7.3 optionalDependencies: '@types/node': 22.19.3 @@ -4332,12 +4326,14 @@ snapshots: optionalDependencies: '@types/node': 22.19.3 + '@isaacs/nonrecursive-glob-match@1.0.3': {} + '@istanbuljs/load-nyc-config@1.1.0': dependencies: camelcase: 5.3.1 find-up: 4.1.0 get-package-type: 0.1.0 - js-yaml: 3.15.1 + js-yaml: 3.15.2 resolve-from: 5.0.0 '@istanbuljs/schema@0.1.3': {} @@ -4609,10 +4605,10 @@ snapshots: '@napi-rs/nice-win32-x64-msvc': 1.1.1 optional: true - '@nestjs/axios@4.0.1(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(axios@1.18.1(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1))(rxjs@7.8.2)': + '@nestjs/axios@4.0.1(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(axios@1.20.0(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1))(rxjs@7.8.2)': dependencies: '@nestjs/common': 11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1) - axios: 1.18.1(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1) + axios: 1.20.0(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1) rxjs: 7.8.2 '@nestjs/cli@11.0.14(@swc/cli@0.6.0(@swc/core@1.15.5)(chokidar@4.0.3)(supports-color@8.1.1))(@swc/core@1.15.5)(@types/node@22.19.3)(uglify-js@3.19.3)': @@ -4627,7 +4623,7 @@ snapshots: cli-table3: 0.6.5 commander: 4.1.1 fork-ts-checker-webpack-plugin: 9.1.0(typescript@5.9.3)(webpack@5.104.1(@swc/core@1.15.5)(uglify-js@3.19.3)) - glob: 13.0.0 + glob: 14.0.2 node-emoji: 1.11.0 ora: 5.4.1 tsconfig-paths: 4.2.0 @@ -4703,7 +4699,7 @@ snapshots: '@nestjs/core': 11.1.28(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(@nestjs/platform-express@11.1.28)(reflect-metadata@0.2.2)(rxjs@7.8.2) cors: 2.8.6 express: 5.2.1(supports-color@8.1.1) - multer: 2.2.0 + multer: 2.5.0 path-to-regexp: 8.4.2 tslib: 2.8.1 transitivePeerDependencies: @@ -4726,7 +4722,7 @@ snapshots: '@nestjs/common': 11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1) '@nestjs/core': 11.1.28(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(@nestjs/platform-express@11.1.28)(reflect-metadata@0.2.2)(rxjs@7.8.2) '@nestjs/mapped-types': 2.1.1(@nestjs/common@11.1.28(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2)(rxjs@7.8.2)(supports-color@8.1.1))(class-transformer@0.5.1)(class-validator@0.14.4)(reflect-metadata@0.2.2) - js-yaml: 5.2.2 + js-yaml: 5.4.1 lodash: 4.18.1 path-to-regexp: 8.4.2 reflect-metadata: 0.2.2 @@ -4826,8 +4822,8 @@ snapshots: '@xhmikosr/bin-wrapper': 13.2.0(supports-color@8.1.1) commander: 8.3.0 fast-glob: 3.3.3 - minimatch: 9.0.9 - piscina: 4.9.3 + minimatch: 11.0.1 + piscina: 4.9.4 semver: 7.7.3 slash: 3.0.0 source-map: 0.7.6 @@ -4903,6 +4899,10 @@ snapshots: '@tokenizer/token@0.3.0': {} + '@topcoder/minimatch-compat@file:tools/minimatch-compat': + dependencies: + minimatch: 11.0.1 + '@tsconfig/node10@1.0.12': {} '@tsconfig/node12@1.0.11': {} @@ -5139,7 +5139,7 @@ snapshots: '@typescript-eslint/types': 8.50.0 '@typescript-eslint/visitor-keys': 8.50.0 debug: 4.4.3(supports-color@8.1.1) - minimatch: 9.0.9 + minimatch: 11.0.1 semver: 7.7.3 tinyglobby: 0.2.15 ts-api-utils: 2.1.0(typescript@5.9.3) @@ -5301,7 +5301,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@xhmikosr/decompress@10.2.1(supports-color@8.1.1)': + '@xhmikosr/decompress@10.2.2(supports-color@8.1.1)': dependencies: '@xhmikosr/decompress-tar': 8.1.0(supports-color@8.1.1) '@xhmikosr/decompress-tarbz2': 8.1.0(supports-color@8.1.1) @@ -5317,7 +5317,7 @@ snapshots: '@xhmikosr/downloader@15.2.0(supports-color@8.1.1)': dependencies: '@xhmikosr/archive-type': 7.1.0(supports-color@8.1.1) - '@xhmikosr/decompress': 10.2.1(supports-color@8.1.1) + '@xhmikosr/decompress': 10.2.2(supports-color@8.1.1) content-disposition: 0.5.4 defaults: 2.0.2 ext-name: 5.0.0 @@ -5390,7 +5390,7 @@ snapshots: ajv@8.20.0: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 3.1.5 + fast-uri: 3.1.9 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 @@ -5435,9 +5435,9 @@ snapshots: asynckit@0.4.0: {} - axios@1.18.1(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1): + axios@1.20.0(debug@4.4.3(supports-color@8.1.1))(supports-color@8.1.1): dependencies: - follow-redirects: 1.16.0(debug@4.4.3(supports-color@8.1.1)) + follow-redirects: 1.16.2(debug@4.4.3(supports-color@8.1.1)) form-data: 4.0.6 https-proxy-agent: 5.0.1(supports-color@8.1.1) proxy-from-env: 2.1.0 @@ -5502,15 +5502,13 @@ snapshots: babel-plugin-jest-hoist: 29.6.3 babel-preset-current-node-syntax: 1.2.0(@babel/core@7.29.6(supports-color@8.1.1)) - balanced-match@1.0.2: {} - balanced-match@4.0.4: {} bare-events@2.8.2: {} base64-js@1.5.1: {} - baseline-browser-mapping@2.9.8: {} + baseline-browser-mapping@2.11.0: {} bin-version-check@5.1.0: dependencies: @@ -5529,30 +5527,21 @@ snapshots: inherits: 2.0.4 readable-stream: 3.6.2 - body-parser@2.3.0(supports-color@8.1.1): + body-parser@2.4.0(supports-color@8.1.1): dependencies: bytes: 3.1.2 - content-type: 2.0.0 + content-type: 2.1.0 debug: 4.4.3(supports-color@8.1.1) http-errors: 2.0.1 iconv-lite: 0.7.3 on-finished: 2.4.1 - qs: 6.15.3 + qs: 6.16.1 raw-body: 3.0.2 type-is: 2.1.0 transitivePeerDependencies: - supports-color - brace-expansion@1.1.18: - dependencies: - balanced-match: 1.0.2 - concat-map: 0.0.1 - - brace-expansion@2.1.4: - dependencies: - balanced-match: 1.0.2 - - brace-expansion@5.0.9: + brace-expansion@5.0.12: dependencies: balanced-match: 4.0.4 @@ -5560,13 +5549,13 @@ snapshots: dependencies: fill-range: 7.1.1 - browserslist@4.28.1: + browserslist@4.28.8: dependencies: - baseline-browser-mapping: 2.9.8 - caniuse-lite: 1.0.30001760 - electron-to-chromium: 1.5.267 - node-releases: 2.0.27 - update-browserslist-db: 1.2.3(browserslist@4.28.1) + baseline-browser-mapping: 2.11.0 + caniuse-lite: 1.0.30001820 + electron-to-chromium: 1.5.472 + node-releases: 2.0.63 + update-browserslist-db: 1.3.4(browserslist@4.28.8) bs-logger@0.2.6: dependencies: @@ -5636,7 +5625,7 @@ snapshots: camelcase@6.3.0: {} - caniuse-lite@1.0.30001760: {} + caniuse-lite@1.0.30001820: {} chalk@4.1.2: dependencies: @@ -5736,15 +5725,6 @@ snapshots: component-emitter@1.3.1: {} - concat-map@0.0.1: {} - - concat-stream@2.0.0: - dependencies: - buffer-from: 1.1.2 - inherits: 2.0.4 - readable-stream: 3.6.2 - typedarray: 0.0.6 - confbox@0.2.2: {} consola@3.4.2: {} @@ -5759,6 +5739,8 @@ snapshots: content-type@2.0.0: {} + content-type@2.1.0: {} + convert-source-map@2.0.0: {} cookie-signature@1.2.2: {} @@ -5782,7 +5764,7 @@ snapshots: cosmiconfig@8.3.6(typescript@5.9.3): dependencies: import-fresh: 3.3.1 - js-yaml: 4.3.1 + js-yaml: 4.3.2 parse-json: 5.2.0 path-type: 4.0.0 optionalDependencies: @@ -5875,7 +5857,7 @@ snapshots: '@standard-schema/spec': 1.1.0 fast-check: 3.23.2 - electron-to-chromium@1.5.267: {} + electron-to-chromium@1.5.472: {} emittery@0.13.1: {} @@ -5911,7 +5893,7 @@ snapshots: es-errors: 1.3.0 get-intrinsic: 1.3.0 has-tostringtag: 1.0.2 - hasown: 2.0.2 + hasown: 2.0.4 escalade@3.2.0: {} @@ -5959,7 +5941,7 @@ snapshots: '@eslint/eslintrc': 3.3.3(supports-color@8.1.1) '@eslint/js': 9.39.2 '@eslint/plugin-kit': 0.4.1 - '@humanfs/node': 0.16.7 + '@humanfs/node': 0.16.8 '@humanwhocodes/module-importer': 1.0.1 '@humanwhocodes/retry': 0.4.3 '@types/estree': 1.0.8 @@ -5982,7 +5964,7 @@ snapshots: is-glob: 4.0.3 json-stable-stringify-without-jsonify: 1.0.1 lodash.merge: 4.6.2 - minimatch: 3.1.4 + minimatch: '@topcoder/minimatch-compat@file:tools/minimatch-compat' natural-compare: 1.4.0 optionator: 0.9.4 optionalDependencies: @@ -6047,7 +6029,7 @@ snapshots: express@5.2.1(supports-color@8.1.1): dependencies: accepts: 2.0.0 - body-parser: 2.3.0(supports-color@8.1.1) + body-parser: 2.4.0(supports-color@8.1.1) content-disposition: 1.0.1 content-type: 1.0.5 cookie: 0.7.2 @@ -6065,8 +6047,8 @@ snapshots: on-finished: 2.4.1 once: 1.4.0 parseurl: 1.3.3 - proxy-addr: 2.0.7 - qs: 6.15.3 + proxy-addr: 2.0.8 + qs: 6.16.1 range-parser: 1.2.1 router: 2.2.0(supports-color@8.1.1) send: 1.2.1(supports-color@8.1.1) @@ -6112,7 +6094,7 @@ snapshots: fast-safe-stringify@2.1.1: {} - fast-uri@3.1.5: {} + fast-uri@3.1.9: {} fastq@1.19.1: dependencies: @@ -6194,7 +6176,7 @@ snapshots: fn.name@1.1.0: {} - follow-redirects@1.16.0(debug@4.4.3(supports-color@8.1.1)): + follow-redirects@1.16.2(debug@4.4.3(supports-color@8.1.1)): optionalDependencies: debug: 4.4.3(supports-color@8.1.1) @@ -6207,7 +6189,7 @@ snapshots: deepmerge: 4.3.1 fs-extra: 10.1.0 memfs: 3.5.3 - minimatch: 3.1.4 + minimatch: '@topcoder/minimatch-compat@file:tools/minimatch-compat' node-abort-controller: 3.1.1 schema-utils: 3.3.0 semver: 7.7.3 @@ -6264,7 +6246,7 @@ snapshots: get-proto: 1.0.1 gopd: 1.2.0 has-symbols: 1.1.0 - hasown: 2.0.2 + hasown: 2.0.4 math-intrinsics: 1.1.0 get-package-type@0.1.0: {} @@ -6295,18 +6277,18 @@ snapshots: glob-to-regexp@0.4.1: {} - glob@13.0.0: + glob@14.0.2: dependencies: - minimatch: 10.2.5 - minipass: 7.1.2 - path-scurry: 2.0.1 + minimatch: 11.0.1 + minipass: 7.1.3 + path-scurry: 3.0.0 glob@7.2.3: dependencies: fs.realpath: 1.0.0 inflight: 1.0.6 inherits: 2.0.4 - minimatch: 3.1.4 + minimatch: '@topcoder/minimatch-compat@file:tools/minimatch-compat' once: 1.4.0 path-is-absolute: 1.0.1 @@ -6332,7 +6314,7 @@ snapshots: graceful-fs@4.2.11: {} - handlebars@4.7.9: + handlebars@4.7.10: dependencies: minimist: 1.2.8 neo-async: 2.6.2 @@ -6349,10 +6331,6 @@ snapshots: dependencies: has-symbols: 1.1.0 - hasown@2.0.2: - dependencies: - function-bind: 1.1.2 - hasown@2.0.4: dependencies: function-bind: 1.1.2 @@ -6383,10 +6361,6 @@ snapshots: human-signals@2.1.0: {} - iconv-lite@0.7.1: - dependencies: - safer-buffer: 2.1.2 - iconv-lite@0.7.3: dependencies: safer-buffer: 2.1.2 @@ -6426,7 +6400,7 @@ snapshots: is-core-module@2.16.1: dependencies: - hasown: 2.0.2 + hasown: 2.0.4 is-extglob@2.1.1: {} @@ -6816,16 +6790,16 @@ snapshots: js-tokens@4.0.0: {} - js-yaml@3.15.1: + js-yaml@3.15.2: dependencies: argparse: 1.0.10 esprima: 4.0.1 - js-yaml@4.3.1: + js-yaml@4.3.2: dependencies: argparse: 2.0.1 - js-yaml@5.2.2: + js-yaml@5.4.1: dependencies: argparse: 2.0.1 @@ -7031,29 +7005,23 @@ snapshots: mimic-response@4.0.0: {} - minimatch@10.2.5: + minimatch@11.0.1: dependencies: - brace-expansion: 5.0.9 - - minimatch@3.1.4: - dependencies: - brace-expansion: 1.1.18 - - minimatch@9.0.9: - dependencies: - brace-expansion: 2.1.4 + '@isaacs/nonrecursive-glob-match': 1.0.3 + brace-expansion: 5.0.12 minimist@1.2.8: {} minipass@7.1.2: {} + minipass@7.1.3: {} + ms@2.1.3: {} - multer@2.2.0: + multer@2.5.0: dependencies: append-field: 1.0.0 busboy: 1.6.0 - concat-stream: 2.0.0 type-is: 1.6.18 mute-stream@2.0.0: {} @@ -7074,7 +7042,7 @@ snapshots: node-int64@0.4.0: {} - node-releases@2.0.27: {} + node-releases@2.0.63: {} normalize-path@3.0.0: {} @@ -7176,7 +7144,7 @@ snapshots: path-parse@1.0.7: {} - path-scurry@2.0.1: + path-scurry@3.0.0: dependencies: lru-cache: 11.2.4 minipass: 7.1.2 @@ -7199,7 +7167,7 @@ snapshots: pirates@4.0.7: {} - piscina@4.9.3: + piscina@4.9.4: optionalDependencies: '@napi-rs/nice': 1.1.1 @@ -7243,7 +7211,7 @@ snapshots: kleur: 3.0.3 sisteransi: 1.0.5 - proxy-addr@2.0.7: + proxy-addr@2.0.8: dependencies: forwarded: 0.2.0 ipaddr.js: 1.9.1 @@ -7254,7 +7222,7 @@ snapshots: pure-rand@6.1.0: {} - qs@6.15.3: + qs@6.16.1: dependencies: es-define-property: 1.0.1 side-channel: 1.1.1 @@ -7269,7 +7237,7 @@ snapshots: dependencies: bytes: 3.1.2 http-errors: 2.0.1 - iconv-lite: 0.7.1 + iconv-lite: 0.7.3 unpipe: 1.0.0 rc9@2.1.2: @@ -7537,7 +7505,7 @@ snapshots: formidable: 3.5.4 methods: 1.1.2 mime: 2.6.0 - qs: 6.15.3 + qs: 6.16.1 transitivePeerDependencies: - supports-color @@ -7609,7 +7577,7 @@ snapshots: dependencies: '@istanbuljs/schema': 0.1.3 glob: 7.2.3 - minimatch: 3.1.4 + minimatch: '@topcoder/minimatch-compat@file:tools/minimatch-compat' text-decoder@1.2.3: dependencies: @@ -7652,7 +7620,7 @@ snapshots: dependencies: bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 - handlebars: 4.7.9 + handlebars: 4.7.10 jest: 29.7.0(@types/node@22.19.3)(supports-color@8.1.1)(ts-node@10.9.2(@swc/core@1.15.5)(@types/node@22.19.3)(typescript@5.9.3)) json5: 2.2.3 lodash.memoize: 4.1.2 @@ -7740,8 +7708,6 @@ snapshots: media-typer: 1.1.0 mime-types: 3.0.2 - typedarray@0.0.6: {} - typescript-eslint@8.50.0(eslint@9.39.2(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3): dependencies: '@typescript-eslint/eslint-plugin': 8.50.0(@typescript-eslint/parser@8.50.0(eslint@9.39.2(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) @@ -7775,9 +7741,9 @@ snapshots: unpipe@1.0.0: {} - update-browserslist-db@1.2.3(browserslist@4.28.1): + update-browserslist-db@1.3.4(browserslist@4.28.8): dependencies: - browserslist: 4.28.1 + browserslist: 4.28.8 escalade: 3.2.0 picocolors: 1.1.1 @@ -7828,7 +7794,7 @@ snapshots: '@webassemblyjs/wasm-parser': 1.14.1 acorn: 8.15.0 acorn-import-phases: 1.0.4(acorn@8.15.0) - browserslist: 4.28.1 + browserslist: 4.28.8 chrome-trace-event: 1.0.4 enhanced-resolve: 5.18.4 es-module-lexer: 2.3.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e6303ba..2abf2e3 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -5,43 +5,46 @@ packages: blockExoticSubdeps: false overrides: + '@humanfs/node': 0.16.8 + baseline-browser-mapping: 2.11.0 + browserslist: 4.28.8 + proxy-addr: 2.0.8 + 'glob@>=9': 14.0.2 + 'minimatch@<9': file:tools/minimatch-compat + 'minimatch@>=9': 11.0.1 '@babel/core@^7': 7.29.6 '@isaacs/brace-expansion': 5.0.1 - '@xhmikosr/decompress@^10': 10.2.1 + '@xhmikosr/decompress@^10': 10.2.2 'ajv@^6.0.0': 6.14.0 'ajv@^8.0.0': 8.20.0 - axios: 1.18.1 - 'body-parser@^2': 2.3.0 - 'brace-expansion@^1.0.0': 1.1.18 - 'brace-expansion@^2.0.0': 2.1.4 - 'brace-expansion@^5.0.0': 5.0.9 + axios: 1.20.0 + 'body-parser@^2': 2.4.0 + 'brace-expansion@^1.0.0': 1.1.21 + 'brace-expansion@^2.0.0': 2.1.7 + 'brace-expansion@^5.0.0': 5.0.12 deepmerge-ts: 8.0.0 defu: 6.1.7 'diff@^4': 4.0.4 'effect@^3.0.0': 3.22.0 - 'fast-uri@^3.0.0': 3.1.5 + 'fast-uri@^3.0.0': 3.1.9 'file-type@>=13.0.0 <21.3.2': 21.3.2 flatted: 3.4.2 - follow-redirects: 1.16.0 + follow-redirects: 1.16.2 form-data: 4.0.6 - handlebars: 4.7.9 + handlebars: 4.7.10 'ip-address@^10.0.0': 10.1.1 'joi@^18.0.0': 18.2.1 - 'js-yaml@^3': 3.15.1 - 'js-yaml@^4.0.0': 4.3.1 - 'js-yaml@>=5.0.0 <=5.2.1': 5.2.2 + 'js-yaml@^3': 3.15.2 + 'js-yaml@^4.0.0': 4.3.2 + 'js-yaml@^5': 5.4.1 jws: 4.0.1 lodash: 4.18.1 - 'minimatch@^3.0.0': 3.1.4 - 'minimatch@^5.0.0': 5.1.8 - 'minimatch@^9': 9.0.9 - 'minimatch@^10': 10.2.5 - multer: 2.2.0 + multer: 2.5.0 path-to-regexp: 8.4.2 'picomatch@^2.0.0': 2.3.2 'picomatch@^4.0.0': 4.0.5 - 'piscina@^4.0.0': 4.9.3 - qs: 6.15.3 + 'piscina@^4.0.0': 4.9.4 + qs: 6.16.1 'terser-webpack-plugin@>=5.0.0 <5.6.1': 5.6.1 uuid: 14.0.1 'webpack@^5': 5.104.1 diff --git a/src/shared/modules/global/jwt.service.spec.ts b/src/shared/modules/global/jwt.service.spec.ts index 7617e5d..5b44ae0 100644 --- a/src/shared/modules/global/jwt.service.spec.ts +++ b/src/shared/modules/global/jwt.service.spec.ts @@ -61,7 +61,9 @@ describe('JwtService validation', () => { it('accepts an RS256 admin token with a non-M2M audience', async () => { const signingKeySpy = jest .spyOn(JwksClient.prototype, 'getSigningKey') - .mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); + .mockResolvedValue({ + getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }), + }); const token = sign( { roles: [UserRole.Admin], @@ -86,13 +88,13 @@ describe('JwtService validation', () => { isMachine: false, }), ); - expect(signingKeySpy).toHaveBeenCalledWith( - 'test-key-id', - ); + expect(signingKeySpy).toHaveBeenCalledWith('test-key-id'); }); it('accepts an RS256 client-credentials token with the configured audience', async () => { - jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ + getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }), + }); const token = sign( { scope: Scope.AllGroups, @@ -141,7 +143,9 @@ describe('JwtService validation', () => { }); it('rejects an RS256 client-credentials token with the wrong audience', async () => { - jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ + getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }), + }); const token = sign( { scope: Scope.ReadGroups, @@ -164,7 +168,9 @@ describe('JwtService validation', () => { }); it('rejects an RS256 client-credentials token without an audience', async () => { - jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ + getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }), + }); const token = sign( { scope: Scope.ReadGroups, @@ -186,7 +192,9 @@ describe('JwtService validation', () => { }); it('still checks audience when client-credentials tokens contain user claims', async () => { - jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ + getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }), + }); const token = sign( { scope: Scope.ReadGroups, @@ -211,7 +219,9 @@ describe('JwtService validation', () => { it('rejects a client-credentials token when AUTH0_AUDIENCE is unavailable', async () => { AuthConfig.jwt.audience = undefined; - const signingKeySpy = jest.spyOn(JwksClient.prototype, 'getSigningKey'); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ + getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }), + }); const token = sign( { scope: Scope.ReadGroups, @@ -235,7 +245,9 @@ describe('JwtService validation', () => { it('does not require AUTH0_AUDIENCE for an RS256 user token', async () => { AuthConfig.jwt.audience = undefined; - jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }) }); + jest.spyOn(JwksClient.prototype, 'getSigningKey').mockResolvedValue({ + getPublicKey: () => publicKey.export({ type: 'spki', format: 'pem' }), + }); const token = sign( { roles: [UserRole.Admin], userId: '12345' }, privateKey, diff --git a/tools/minimatch-compat/index.cjs b/tools/minimatch-compat/index.cjs new file mode 100644 index 0000000..21c167f --- /dev/null +++ b/tools/minimatch-compat/index.cjs @@ -0,0 +1,38 @@ +const modern = require('minimatch'); + +// Older build tools expect a callable CommonJS export. glob 7 additionally +// reads _glob and uses String.match on compiled segments. Delegate matching +// to minimatch 11's bounded matcher, without restoring the old regex engine. +function compatible(defaultOptions = {}) { + const options = (value) => ({ ...defaultOptions, ...value }); + const match = (path, pattern, value) => + modern.minimatch(path, pattern, options(value)); + Object.assign(match, modern.minimatch); + match.Minimatch = class extends modern.Minimatch { + constructor(pattern, value) { + super(pattern, options(value)); + for (const row of this.set) { + for (const segment of row) { + if (typeof segment === 'object' && segment !== null) { + segment._glob = segment.pattern; + segment[Symbol.match] = (input) => + segment.test(input) ? [input] : null; + } + } + } + } + + static defaults(value) { + return compatible(options(value)).Minimatch; + } + }; + match.defaults = (value) => compatible(options(value)); + match.filter = (pattern, value) => modern.filter(pattern, options(value)); + match.match = (paths, pattern, value) => + modern.match(paths, pattern, options(value)); + match.braceExpand = (pattern, value) => + modern.braceExpand(pattern, options(value)); + return match; +} + +module.exports = compatible(); diff --git a/tools/minimatch-compat/index.test.cjs b/tools/minimatch-compat/index.test.cjs new file mode 100644 index 0000000..63a30a1 --- /dev/null +++ b/tools/minimatch-compat/index.test.cjs @@ -0,0 +1,38 @@ +const assert = require('node:assert/strict'); +const { createRequire } = require('node:module'); +const { spawnSync } = require('node:child_process'); +const { test } = require('node:test'); + +const legacyRequire = createRequire(require.resolve('@eslint/eslintrc')); +const match = legacyRequire('minimatch'); + +test('legacy consumers retain the callable minimatch API', () => { + assert.equal(typeof match, 'function'); + assert.equal(match('src/main.ts', '**/*.ts'), true); + assert.equal(match('src/main.js', '**/*.ts'), false); + assert.equal(match('.env', '*'), false); + assert.equal(match.defaults({ dot: true })('.env', '*'), true); + assert.deepEqual(match.match(['a.ts', 'b.js'], '*.ts'), ['a.ts']); + assert.deepEqual(['a.ts', 'b.js'].filter(match.filter('*.ts')), ['a.ts']); + assert.deepEqual(match.braceExpand('*.{js,ts}'), ['*.js', '*.ts']); + assert.equal(new match.Minimatch('**/*.ts').match('src/main.ts'), true); + assert.equal(match.Minimatch.defaults({ dot: true }) !== undefined, true); + assert.equal(typeof match.GLOBSTAR, 'symbol'); +}); + +test('legacy glob still discovers source files with the patched matcher', () => { + const fromJest = createRequire(require.resolve('jest/package.json')); + const fromCore = createRequire(fromJest.resolve('@jest/core')); + const fromConfig = createRequire(fromCore.resolve('jest-config')); + const glob = fromConfig('glob'); + assert.ok(glob.sync('src/**/*.spec.ts').includes('src/shared/config/auth.config.spec.ts')); +}); + +test('amplifying glob patterns terminate within a bounded time', () => { + const result = spawnSync(process.execPath, ['-e', ` + const match = require(${JSON.stringify(legacyRequire.resolve('minimatch'))}); + new match.Minimatch('**/../'.repeat(30) + '*.ts', { optimizationLevel: 2 }); + `], { timeout: 5000, encoding: 'utf8' }); + assert.equal(result.error, undefined); + assert.equal(result.status, 0, result.stderr); +}); diff --git a/tools/minimatch-compat/package.json b/tools/minimatch-compat/package.json new file mode 100644 index 0000000..52aea68 --- /dev/null +++ b/tools/minimatch-compat/package.json @@ -0,0 +1,10 @@ +{ + "name": "@topcoder/minimatch-compat", + "version": "1.0.0", + "private": true, + "description": "Legacy CommonJS entry point backed by patched minimatch", + "main": "index.cjs", + "dependencies": { + "minimatch": "11.0.1" + } +} From b78f7cc1a3cd55385a98ae92ef10c1eb2366a553 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Tue, 3 Nov 2026 10:08:28 +1100 Subject: [PATCH 06/11] chore: adopt core v4.0.0-rc.2 identity denylists --- package.json | 2 +- pnpm-lock.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 12a24b2..356f462 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "qs": "^6.16.1", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", - "tc-core-library-js": "github:topcoder-platform/tc-core-library-js#v4.0.0-rc.1", + "tc-core-library-js": "github:topcoder-platform/tc-core-library-js#v4.0.0-rc.2", "uuid": "^14.0.1" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12d8c3f..7aad966 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -109,8 +109,8 @@ importers: specifier: ^7.8.1 version: 7.8.2 tc-core-library-js: - specifier: github:topcoder-platform/tc-core-library-js#v4.0.0-rc.1 - version: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/6c326fea0abfccb5ae29dff2ac5bce01aabc1fa4(supports-color@8.1.1) + specifier: github:topcoder-platform/tc-core-library-js#v4.0.0-rc.2 + version: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/58de37670180e183e8378c3d203df0112a0414f6(supports-color@8.1.1) uuid: specifier: 14.0.1 version: 14.0.1 @@ -3482,9 +3482,9 @@ packages: tar-stream@3.1.7: resolution: {integrity: sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==} - tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/6c326fea0abfccb5ae29dff2ac5bce01aabc1fa4: - resolution: {gitHosted: true, tarball: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/6c326fea0abfccb5ae29dff2ac5bce01aabc1fa4} - version: 4.0.0-rc.1 + tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/58de37670180e183e8378c3d203df0112a0414f6: + resolution: {gitHosted: true, tarball: https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/58de37670180e183e8378c3d203df0112a0414f6} + version: 4.0.0-rc.2 engines: {node: '>=22.13'} terser-webpack-plugin@5.6.1: @@ -7547,7 +7547,7 @@ snapshots: - bare-abort-controller - react-native-b4a - tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/6c326fea0abfccb5ae29dff2ac5bce01aabc1fa4(supports-color@8.1.1): + tc-core-library-js@https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/58de37670180e183e8378c3d203df0112a0414f6(supports-color@8.1.1): dependencies: '@types/jsonwebtoken': 9.0.10 jsonwebtoken: 9.0.3 From c529b930355ba00e86bced182ee58b9580b8c6ba Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Wed, 4 Nov 2026 20:42:29 +1100 Subject: [PATCH 07/11] Apply scoped OIDC deployment migration to current develop --- .circleci/config.yml | 161 ++++++++++++++++++++--------------- .dockerignore | 14 +++ .gitignore | 4 + Dockerfile | 2 - appStartUp.sh | 8 +- deploy/MIGRATION.md | 27 ++++++ deploy/prod-healthcheck.json | 14 +++ deploy/prod.json | 19 +++++ deploy/release.py | 13 +++ 9 files changed, 182 insertions(+), 80 deletions(-) create mode 100644 deploy/MIGRATION.md create mode 100644 deploy/prod-healthcheck.json create mode 100644 deploy/prod.json create mode 100644 deploy/release.py diff --git a/.circleci/config.yml b/.circleci/config.yml index 749e076..4f56256 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,80 +1,99 @@ +# Deployment migration: see deploy/MIGRATION.md before enabling either environment. version: 2.1 - -parameters: - reset-db: - type: boolean - default: false -defaults: &defaults - docker: - - image: cimg/python:3.13.2-browsers -install_dependency: &install_dependency - name: Installation of build and deployment dependencies. - command: | - sudo apt update - sudo apt install -y jq python3-pip - sudo pip3 install awscli --upgrade -install_deploysuite: &install_deploysuite - name: Installation of install_deploysuite. - command: | - git clone --branch v1.4.19 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript - cp ./../buildscript/master_deploy.sh . - cp ./../buildscript/buildenv.sh . - cp ./../buildscript/awsconfiguration.sh . - cp ./../buildscript/psvar-processor.sh . - -builddeploy_steps: &builddeploy_steps - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - - run: docker buildx build --no-cache=true --build-arg RESET_DB_ARG=<> --build-arg SEED_DATA_ARG=${DEPLOYMENT_ENVIRONMENT} -t ${APPNAME}:latest . - - run: - name: Running MasterScript. - command: | - ./awsconfiguration.sh $DEPLOY_ENV - source awsenvconf - ./psvar-processor.sh -t appenv -p /config/${APPNAME}/deployvar - source deployvar_env - ./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -j /config/${APPNAME}/appvar,/config/common/global-appvar -i ${APPNAME} -p FARGATE - +executors: + reviewed: + docker: + - image: cimg/aws@sha256:4cf3768db00ddf9bc439b8c84e8a60c11a14edf81c8baf76f74132144f8340d5 +commands: + checkout-suite: + steps: + - run: + name: Verify the reviewed deployment suite + command: | + set -euo pipefail + git init --quiet /tmp/tc-deploy-scripts + git -C /tmp/tc-deploy-scripts remote add origin https://github.com/topcoder-platform/tc-deploy-scripts.git + git -C /tmp/tc-deploy-scripts fetch --quiet --depth 1 origin bbc9b3d0c702947d26b6d9686d7b29104ebe461a + git -C /tmp/tc-deploy-scripts checkout --quiet --detach FETCH_HEAD + test "$(git -C /tmp/tc-deploy-scripts rev-parse HEAD)" = bbc9b3d0c702947d26b6d9686d7b29104ebe461a jobs: - # Build & Deploy against development backend - "build-dev": - !!merge <<: *defaults - environment: - DEPLOY_ENV: "DEV" - LOGICAL_ENV: "dev" - APPNAME: "groups-api-v6" - DEPLOYMENT_ENVIRONMENT: 'dev' - steps: *builddeploy_steps - - "build-prod": - !!merge <<: *defaults + build: + executor: reviewed + steps: + - checkout + - setup_remote_docker + - checkout-suite + - run: + name: Build committed source without AWS or broker credentials + command: | + set -euo pipefail + python3 -I /tmp/tc-deploy-scripts/build_image.py --dockerfile Dockerfile --image groups-api-v6:candidate + mkdir -p /tmp/release + docker save --output /tmp/release/image.tar groups-api-v6:candidate + no_output_timeout: 30m + - persist_to_workspace: + root: /tmp/release + paths: + - image.tar + deploy: + executor: reviewed + parameters: + environment: + type: enum + enum: + - dev + - prod environment: - DEPLOY_ENV: "PROD" - LOGICAL_ENV: "prod" - APPNAME: "groups-api-v6" - DEPLOYMENT_ENVIRONMENT: 'prod' - steps: *builddeploy_steps - + DEPLOY_ENV: << parameters.environment >> + steps: + - checkout + - setup_remote_docker + - checkout-suite + - attach_workspace: + at: /tmp/release + - run: + name: Promote a scanned digest with repository-bound OIDC + command: | + set +x + set -euo pipefail + test -f "deploy/${DEPLOY_ENV}.json" + docker load --input /tmp/release/image.tar + python3 -I deploy/release.py "deploy/${DEPLOY_ENV}.json" + no_output_timeout: 45m workflows: - version: 2 - build: + release: jobs: - # Development builds are executed on "develop" branch only. - - "build-dev": - context: org-global + - build + - deploy: + name: deploy-dev + environment: dev + requires: + - build + context: groups-api-v6-dev-deploy + serial-group: << pipeline.project.slug >>/deploy-dev + filters: + branches: + only: develop + tags: + ignore: /.*/ + - approve-prod: + type: approval + requires: + - build filters: branches: - only: - - develop - - security_july_2026 - - # Production builds are exectuted only on tagged commits to the - # master branch. - - "build-prod": - context: org-global + only: master + tags: + ignore: /.*/ + - deploy: + name: deploy-prod + environment: prod + requires: + - approve-prod + context: groups-api-v6-prod-deploy + serial-group: << pipeline.project.slug >>/deploy-prod filters: branches: - only: - - master + only: master + tags: + ignore: /.*/ diff --git a/.dockerignore b/.dockerignore index 32801a2..810d46a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,17 @@ coverage dist node_modules + +.aws +.ssh +awsenvconf +*_env +buildenvvar +.env +.env.* +!.env.example +!.env.sample +.npmrc +fetched_parameters.json +paramwithvalue.json +cli-input.json diff --git a/.gitignore b/.gitignore index 4b56acf..f07d17b 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,7 @@ pids # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Infrastructure definitions and detailed AWS inventories are maintained privately. +/deploy/iam/ +/deploy/*-baseline.json diff --git a/Dockerfile b/Dockerfile index 368c77e..6cd66ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,8 +37,6 @@ RUN apk upgrade --no-cache \ && addgroup -S -g 10001 app \ && adduser -S -D -H -h /app -u 10001 -G app app -ARG RESET_DB_ARG=false -ENV RESET_DB=$RESET_DB_ARG ARG SEED_DATA_ARG="" ENV SEED_DATA=$SEED_DATA_ARG ENV PRISMA_CLI_BINARY_TARGETS=linux-musl-openssl-3.0.x diff --git a/appStartUp.sh b/appStartUp.sh index b399900..4786d2c 100755 --- a/appStartUp.sh +++ b/appStartUp.sh @@ -4,13 +4,7 @@ set -eo pipefail export DATABASE_URL=$(echo -e ${DATABASE_URL}) echo "Database - running migrations." -if $RESET_DB; then - echo "Resetting DB" - node node_modules/prisma/build/index.js migrate reset --force -else - echo "Running migrations" - node node_modules/prisma/build/index.js migrate deploy -fi +node node_modules/prisma/build/index.js migrate deploy # Start the app exec node dist/src/main diff --git a/deploy/MIGRATION.md b/deploy/MIGRATION.md new file mode 100644 index 0000000..8320cc7 --- /dev/null +++ b/deploy/MIGRATION.md @@ -0,0 +1,27 @@ +# OIDC deployment migration + +This change replaces the Auth0 credential broker and SSM-to-shell deployment path with the reviewed [shared suite PR #40](https://github.com/topcoder-platform/tc-deploy-scripts/pull/40), pinned to `bbc9b3d0c702947d26b6d9686d7b29104ebe461a`. Build and deployment run in separate jobs. The deployer cannot read Parameter Store, Secrets Manager or decrypt KMS data, including through another assumed role. ECS continues resolving the existing runtime secret references using the execution role. + +## Production target + +The read-only inventory on 2026-11-03 verified account `409275337247`, cluster `groups-api-serverless`, service `groups-api-v6`, family `groups-api-v6`, and container `groups-api-v6`. `prod.json` preserves the observed task/execution roles and names the proposed service-specific deployment role. [prod-baseline.json](https://github.com/topcoder-platform/v6-services-iac/blob/main/services/groups-api-v6/deploy/prod-baseline.json) records references only; it contains no parameter values. Do not recreate the service or replace its complete task definition from this baseline. + +## Infrastructure prerequisites, applied separately by an administrator + +1. In each account, register the CircleCI OIDC issuer `https://oidc.circleci.com/org/947bef5e-1669-415d-b83c-4fc85155b7df` with client ID `947bef5e-1669-415d-b83c-4fc85155b7df`. The current production account has only the legacy Auth0 provider. Do not remove that provider until all its consumers have migrated. +2. Review and install [iam/prod-role.cloudformation.json](https://github.com/topcoder-platform/v6-services-iac/blob/main/services/groups-api-v6/deploy/iam/prod-role.cloudformation.json) with an administrator/IaC identity. It creates the proposed deployment role and applies the same least-privilege policy as a permissions boundary. The trust binds this CircleCI project, repository, checkout branch and configuration branch. It does not grant infrastructure creation to CircleCI. +3. Configure ECR repository `groups-api-v6` with unconditional `IMMUTABLE` tags and supported scan-on-push. Existing tags are not retagged. The release fails for MEDIUM/HIGH/CRITICAL/UNDEFINED findings, failed scans, or a mismatched digest. +4. In the infrastructure that owns the task definition, add the reviewed container check from `prod-healthcheck.json`, keeping all roles, runtime secret references, resources, mounts and sidecars. Verify the health endpoint against the running container in dev first. Preserve circuit-breaker rollback and positive desired capacity. Remove any `RESET_DB` secret binding and plaintext secret environment entries before adoption. Keep the execution role's runtime read permissions scoped to the references that service needs. +5. Create restricted `groups-api-v6-dev-deploy` and `groups-api-v6-prod-deploy` CircleCI contexts without Auth0/static AWS credentials. Restrict production to the reviewed `master` checkout and configuration ref, authorized operators, and approval job. Remove legacy credentials from project settings too: removing `org-global` alone does not remove project-level variables. Confirm `CIRCLE_OIDC_TOKEN_V3` is issued. Disable secret access for forks and SSH debugging in deployment jobs. + +## Development acceptance before merge/release + +The saved dev AWS session had expired during preparation. No dev cluster, role or family has been guessed. **This PR is a draft until an administrator verifies and commits `deploy/dev.json` for account `811668436784` and branch `develop`, with corresponding narrow IAM policy/trust.** Use the same schema as `prod.json`, but inspect the actual dev resources and roles; do not replace just the account number. The dev job fails closed while its manifest is absent. Branches other than `develop` and `master` build only and receive no deployment context. + +Run the shared offline suite, validate the CircleCI config and IAM policies, and test a dev release plus an unhealthy-image rollback. Verify CloudTrail contains no SSM/Secrets Manager calls from the deployment principal. Remove its old broker grants only after migration. Check the runtime secret references and roles stayed unchanged. Production requires the manual approval job and a passing digest/scan/health verification. + +The pinned executor is `cimg/aws@sha256:4cf3768db00ddf9bc439b8c84e8a60c11a14edf81c8baf76f74132144f8340d5`. Python/AWS CLI/Buildx/Git compatibility was tested with the shared offline suite. No package installation or service build runs in the deployment job. The Dockerfile retains the existing in-image quality gates. This PR does not deploy, change IAM, rotate credentials, or claim a successful live rollout. + +## Infrastructure source + +IAM templates and detailed AWS baselines are maintained in the private [v6-services-iac service directory](https://github.com/topcoder-platform/v6-services-iac/tree/main/services/groups-api-v6). Provision infrastructure separately with an administrator identity; application CI does not fetch that repository or install IAM. Required application manifests and health-check proposals remain here. diff --git a/deploy/prod-healthcheck.json b/deploy/prod-healthcheck.json new file mode 100644 index 0000000..ad1b925 --- /dev/null +++ b/deploy/prod-healthcheck.json @@ -0,0 +1,14 @@ +{ + "groups-api-v6": { + "command": [ + "CMD", + "node", + "-e", + "const r=require('node:http').get('http://127.0.0.1:3000/v6/groups/health',r=>{r.resume();process.exit(r.statusCode>=200&&r.statusCode<300?0:1)});r.setTimeout(4000,()=>{r.destroy();process.exit(1)});r.on('error',()=>process.exit(1))" + ], + "interval": 30, + "timeout": 5, + "retries": 3, + "startPeriod": 120 + } +} diff --git a/deploy/prod.json b/deploy/prod.json new file mode 100644 index 0000000..9adb210 --- /dev/null +++ b/deploy/prod.json @@ -0,0 +1,19 @@ +{ + "schemaVersion": 2, + "environment": "prod", + "accountId": "409275337247", + "region": "us-east-1", + "deployRoleArn": "arn:aws:iam::409275337247:role/groups-api-v6-prod-deploy", + "taskRoleArn": null, + "executionRoleArn": "arn:aws:iam::409275337247:role/ecsTaskExecutionRole", + "cluster": "groups-api-serverless", + "service": "groups-api-v6", + "taskFamily": "groups-api-v6", + "circleciOrgId": "947bef5e-1669-415d-b83c-4fc85155b7df", + "circleciProjectId": "abe5f61b-2fef-4d62-be62-757ffc290462", + "repository": "github.com/topcoder-platform/groups-api-v6", + "branch": "master", + "images": { + "groups-api-v6": "groups-api-v6" + } +} diff --git a/deploy/release.py b/deploy/release.py new file mode 100644 index 0000000..410a035 --- /dev/null +++ b/deploy/release.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +"""Pass the reviewed manifest and this job's prebuilt images to the pinned suite.""" +import json +from pathlib import Path +import subprocess +import sys + +manifest = Path(sys.argv[1]) +data = json.loads(manifest.read_text()) +command = [sys.executable, '-I', '/tmp/tc-deploy-scripts/tcdeploy.py', 'deploy', '--manifest', str(manifest)] +for container in data['images']: + command.extend(['--image', container + '=groups-api-v6:candidate']) +subprocess.run(command, check=True) From 783311ac258aedf86c9eeee96dde20245b8a764c Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Wed, 4 Nov 2026 21:02:36 +1100 Subject: [PATCH 08/11] Refresh deployment suite v2.0.5 and dev review prerequisites --- .circleci/config.yml | 6 +++--- deploy/MIGRATION.md | 17 +++++++++++++---- deploy/dev-healthcheck.json | 14 ++++++++++++++ deploy/dev.json | 19 +++++++++++++++++++ 4 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 deploy/dev-healthcheck.json create mode 100644 deploy/dev.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 4f56256..bbe33b6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,14 +8,14 @@ commands: checkout-suite: steps: - run: - name: Verify the reviewed deployment suite + name: Verify deployment suite v2.0.5 command: | set -euo pipefail git init --quiet /tmp/tc-deploy-scripts git -C /tmp/tc-deploy-scripts remote add origin https://github.com/topcoder-platform/tc-deploy-scripts.git - git -C /tmp/tc-deploy-scripts fetch --quiet --depth 1 origin bbc9b3d0c702947d26b6d9686d7b29104ebe461a + git -C /tmp/tc-deploy-scripts fetch --quiet --depth 1 origin refs/tags/v2.0.5 git -C /tmp/tc-deploy-scripts checkout --quiet --detach FETCH_HEAD - test "$(git -C /tmp/tc-deploy-scripts rev-parse HEAD)" = bbc9b3d0c702947d26b6d9686d7b29104ebe461a + test "$(git -C /tmp/tc-deploy-scripts rev-parse HEAD)" = bff574ab5c0b46773e25d2af1eff76675fba2ba5 jobs: build: executor: reviewed diff --git a/deploy/MIGRATION.md b/deploy/MIGRATION.md index 8320cc7..f9c61b4 100644 --- a/deploy/MIGRATION.md +++ b/deploy/MIGRATION.md @@ -1,6 +1,6 @@ # OIDC deployment migration -This change replaces the Auth0 credential broker and SSM-to-shell deployment path with the reviewed [shared suite PR #40](https://github.com/topcoder-platform/tc-deploy-scripts/pull/40), pinned to `bbc9b3d0c702947d26b6d9686d7b29104ebe461a`. Build and deployment run in separate jobs. The deployer cannot read Parameter Store, Secrets Manager or decrypt KMS data, including through another assumed role. ECS continues resolving the existing runtime secret references using the execution role. +This change replaces the Auth0 credential broker and SSM-to-shell deployment path with [tc-deploy-scripts v2.0.5](https://github.com/topcoder-platform/tc-deploy-scripts/releases/tag/v2.0.5), fetched by tag and verified against commit `bff574ab5c0b46773e25d2af1eff76675fba2ba5`. Build and deployment run in separate jobs. The deployer cannot read Parameter Store, Secrets Manager or decrypt KMS data, including through another assumed role. ECS continues resolving the existing runtime secret references using the execution role. ## Production target @@ -9,14 +9,19 @@ The read-only inventory on 2026-11-03 verified account `409275337247`, cluster ` ## Infrastructure prerequisites, applied separately by an administrator 1. In each account, register the CircleCI OIDC issuer `https://oidc.circleci.com/org/947bef5e-1669-415d-b83c-4fc85155b7df` with client ID `947bef5e-1669-415d-b83c-4fc85155b7df`. The current production account has only the legacy Auth0 provider. Do not remove that provider until all its consumers have migrated. -2. Review and install [iam/prod-role.cloudformation.json](https://github.com/topcoder-platform/v6-services-iac/blob/main/services/groups-api-v6/deploy/iam/prod-role.cloudformation.json) with an administrator/IaC identity. It creates the proposed deployment role and applies the same least-privilege policy as a permissions boundary. The trust binds this CircleCI project, repository, checkout branch and configuration branch. It does not grant infrastructure creation to CircleCI. -3. Configure ECR repository `groups-api-v6` with unconditional `IMMUTABLE` tags and supported scan-on-push. Existing tags are not retagged. The release fails for MEDIUM/HIGH/CRITICAL/UNDEFINED findings, failed scans, or a mismatched digest. +2. Review and install [iam/prod-role.cloudformation.json](https://github.com/topcoder-platform/v6-services-iac/blob/main/services/groups-api-v6/deploy/iam/prod-role.cloudformation.json) with an administrator/IaC identity. It creates the proposed deployment role and applies the same least-privilege policy as a permissions boundary. The trust binds this CircleCI project, repository, checkout branch and configuration branch. It does not grant infrastructure creation to CircleCI. The role and matching boundary include `inspector2:ListFindings` and `inspector2:ListCoverage` restricted to the deployment region; these scan-metadata APIs require `Resource: "*"`. Secret-access denies remain explicit. +3. Configure ECR repository `groups-api-v6` with unconditional `IMMUTABLE` tags and supported scanning. Preserve existing enhanced scanning where enabled. Existing tags are not retagged. The release fails for MEDIUM/HIGH/CRITICAL/UNDEFINED findings, failed scans, or a mismatched digest. 4. In the infrastructure that owns the task definition, add the reviewed container check from `prod-healthcheck.json`, keeping all roles, runtime secret references, resources, mounts and sidecars. Verify the health endpoint against the running container in dev first. Preserve circuit-breaker rollback and positive desired capacity. Remove any `RESET_DB` secret binding and plaintext secret environment entries before adoption. Keep the execution role's runtime read permissions scoped to the references that service needs. 5. Create restricted `groups-api-v6-dev-deploy` and `groups-api-v6-prod-deploy` CircleCI contexts without Auth0/static AWS credentials. Restrict production to the reviewed `master` checkout and configuration ref, authorized operators, and approval job. Remove legacy credentials from project settings too: removing `org-global` alone does not remove project-level variables. Confirm `CIRCLE_OIDC_TOKEN_V3` is issued. Disable secret access for forks and SSH debugging in deployment jobs. ## Development acceptance before merge/release -The saved dev AWS session had expired during preparation. No dev cluster, role or family has been guessed. **This PR is a draft until an administrator verifies and commits `deploy/dev.json` for account `811668436784` and branch `develop`, with corresponding narrow IAM policy/trust.** Use the same schema as `prod.json`, but inspect the actual dev resources and roles; do not replace just the account number. The dev job fails closed while its manifest is absent. Branches other than `develop` and `master` build only and receive no deployment context. +Read-only inventory on 2026-11-04 verified `dev.json` against the actual development service, task/execution roles and image repositories. This PR targets `develop`. Matching IAM templates and detailed baselines remain private. **Keep this PR in draft until the service-specific prerequisites below are complete.** No AWS or CircleCI resources were provisioned by this refresh. + +- Install the service deployment role and matching permissions boundary. +- Create the restricted empty CircleCI deployment context. +- Set unconditional immutable ECR tags, preserving existing enhanced scanning. +- Review and install the dev container health-check proposal; preserve all other task configuration. Run the shared offline suite, validate the CircleCI config and IAM policies, and test a dev release plus an unhealthy-image rollback. Verify CloudTrail contains no SSM/Secrets Manager calls from the deployment principal. Remove its old broker grants only after migration. Check the runtime secret references and roles stayed unchanged. Production requires the manual approval job and a passing digest/scan/health verification. @@ -25,3 +30,7 @@ The pinned executor is `cimg/aws@sha256:4cf3768db00ddf9bc439b8c84e8a60c11a14edf8 ## Infrastructure source IAM templates and detailed AWS baselines are maintained in the private [v6-services-iac service directory](https://github.com/topcoder-platform/v6-services-iac/tree/main/services/groups-api-v6). Provision infrastructure separately with an administrator identity; application CI does not fetch that repository or install IAM. Required application manifests and health-check proposals remain here. + +## Dev branch refresh + +This PR targets `develop` and preserves its current application/dependency fixes. The shared suite is v2.0.5 (82 offline tests); service-specific adapters and their tests remain part of review. Keep this PR in draft until its documented infrastructure and integration prerequisites are met. Updating these files does not provision AWS or CircleCI resources. diff --git a/deploy/dev-healthcheck.json b/deploy/dev-healthcheck.json new file mode 100644 index 0000000..7559716 --- /dev/null +++ b/deploy/dev-healthcheck.json @@ -0,0 +1,14 @@ +{ + "groups-api-v6": { + "command": [ + "CMD", + "node", + "-e", + "const r=require('node:http').get(\"http://127.0.0.1:3000/v6/groups/health\",r=>{r.resume();process.exit(r.statusCode>=200&&r.statusCode<300?0:1)});r.setTimeout(4000,()=>{r.destroy();process.exit(1)});r.on('error',()=>process.exit(1))" + ], + "interval": 30, + "timeout": 5, + "retries": 3, + "startPeriod": 120 + } +} diff --git a/deploy/dev.json b/deploy/dev.json new file mode 100644 index 0000000..6702be1 --- /dev/null +++ b/deploy/dev.json @@ -0,0 +1,19 @@ +{ + "schemaVersion": 2, + "environment": "dev", + "accountId": "811668436784", + "region": "us-east-1", + "deployRoleArn": "arn:aws:iam::811668436784:role/groups-api-v6-dev-deploy", + "taskRoleArn": null, + "executionRoleArn": "arn:aws:iam::811668436784:role/ecsTaskExecutionRole", + "cluster": "groups-api-serverless", + "service": "groups-api-v6", + "taskFamily": "groups-api-v6", + "circleciOrgId": "947bef5e-1669-415d-b83c-4fc85155b7df", + "circleciProjectId": "abe5f61b-2fef-4d62-be62-757ffc290462", + "repository": "github.com/topcoder-platform/groups-api-v6", + "branch": "develop", + "images": { + "groups-api-v6": "groups-api-v6" + } +} From 82e71a19775abc86dc11517f839c995d4c30d9bd Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Wed, 4 Nov 2026 21:12:53 +1100 Subject: [PATCH 09/11] Refresh deployment suite v2.0.5 and dev review prerequisites --- .circleci/config.yml | 17 +++++++++++++++-- deploy/MIGRATION.md | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bbe33b6..9c13977 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,6 +5,19 @@ executors: docker: - image: cimg/aws@sha256:4cf3768db00ddf9bc439b8c84e8a60c11a14edf81c8baf76f74132144f8340d5 commands: + checkout-source: + steps: + - run: + name: Check out the exact public source commit over HTTPS + command: | + set -euo pipefail + [[ "$CIRCLE_SHA1" =~ ^[0-9a-f]{40}$ ]] + export GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null GIT_TERMINAL_PROMPT=0 + git init --quiet . + git remote add origin https://github.com/topcoder-platform/groups-api-v6.git + git -c credential.helper= fetch --quiet --depth 1 origin "$CIRCLE_SHA1" + git checkout --quiet --detach FETCH_HEAD + test "$(git rev-parse HEAD)" = "$CIRCLE_SHA1" checkout-suite: steps: - run: @@ -20,7 +33,7 @@ jobs: build: executor: reviewed steps: - - checkout + - checkout-source - setup_remote_docker - checkout-suite - run: @@ -46,7 +59,7 @@ jobs: environment: DEPLOY_ENV: << parameters.environment >> steps: - - checkout + - checkout-source - setup_remote_docker - checkout-suite - attach_workspace: diff --git a/deploy/MIGRATION.md b/deploy/MIGRATION.md index f9c61b4..f55ea01 100644 --- a/deploy/MIGRATION.md +++ b/deploy/MIGRATION.md @@ -34,3 +34,5 @@ IAM templates and detailed AWS baselines are maintained in the private [v6-servi ## Dev branch refresh This PR targets `develop` and preserves its current application/dependency fixes. The shared suite is v2.0.5 (82 offline tests); service-specific adapters and their tests remain part of review. Keep this PR in draft until its documented infrastructure and integration prerequisites are met. Updating these files does not provision AWS or CircleCI resources. + +Source checkout uses the public HTTPS repository and verifies the exact CircleCI commit, avoiding dependency on failing SSH checkout keys. No GitHub token is added to build or deployment contexts. From b5c9a63905dd68f4b4f60689581d06a7e07d407d Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Thu, 5 Nov 2026 07:48:34 +1100 Subject: [PATCH 10/11] Record installed dev prerequisites and production cutover readiness --- deploy/MIGRATION.md | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/deploy/MIGRATION.md b/deploy/MIGRATION.md index f55ea01..bdbeebe 100644 --- a/deploy/MIGRATION.md +++ b/deploy/MIGRATION.md @@ -6,22 +6,17 @@ This change replaces the Auth0 credential broker and SSM-to-shell deployment pat The read-only inventory on 2026-11-03 verified account `409275337247`, cluster `groups-api-serverless`, service `groups-api-v6`, family `groups-api-v6`, and container `groups-api-v6`. `prod.json` preserves the observed task/execution roles and names the proposed service-specific deployment role. [prod-baseline.json](https://github.com/topcoder-platform/v6-services-iac/blob/main/services/groups-api-v6/deploy/prod-baseline.json) records references only; it contains no parameter values. Do not recreate the service or replace its complete task definition from this baseline. -## Infrastructure prerequisites, applied separately by an administrator +## Installed infrastructure and production cutover -1. In each account, register the CircleCI OIDC issuer `https://oidc.circleci.com/org/947bef5e-1669-415d-b83c-4fc85155b7df` with client ID `947bef5e-1669-415d-b83c-4fc85155b7df`. The current production account has only the legacy Auth0 provider. Do not remove that provider until all its consumers have migrated. -2. Review and install [iam/prod-role.cloudformation.json](https://github.com/topcoder-platform/v6-services-iac/blob/main/services/groups-api-v6/deploy/iam/prod-role.cloudformation.json) with an administrator/IaC identity. It creates the proposed deployment role and applies the same least-privilege policy as a permissions boundary. The trust binds this CircleCI project, repository, checkout branch and configuration branch. It does not grant infrastructure creation to CircleCI. The role and matching boundary include `inspector2:ListFindings` and `inspector2:ListCoverage` restricted to the deployment region; these scan-metadata APIs require `Resource: "*"`. Secret-access denies remain explicit. -3. Configure ECR repository `groups-api-v6` with unconditional `IMMUTABLE` tags and supported scanning. Preserve existing enhanced scanning where enabled. Existing tags are not retagged. The release fails for MEDIUM/HIGH/CRITICAL/UNDEFINED findings, failed scans, or a mismatched digest. -4. In the infrastructure that owns the task definition, add the reviewed container check from `prod-healthcheck.json`, keeping all roles, runtime secret references, resources, mounts and sidecars. Verify the health endpoint against the running container in dev first. Preserve circuit-breaker rollback and positive desired capacity. Remove any `RESET_DB` secret binding and plaintext secret environment entries before adoption. Keep the execution role's runtime read permissions scoped to the references that service needs. -5. Create restricted `groups-api-v6-dev-deploy` and `groups-api-v6-prod-deploy` CircleCI contexts without Auth0/static AWS credentials. Restrict production to the reviewed `master` checkout and configuration ref, authorized operators, and approval job. Remove legacy credentials from project settings too: removing `org-global` alone does not remove project-level variables. Confirm `CIRCLE_OIDC_TOKEN_V3` is issued. Disable secret access for forks and SSH debugging in deployment jobs. +The dev deployment role/boundary, restricted empty CircleCI context, and immutable ECR tags are installed. Existing enhanced scanning is preserved. The production OIDC provider, deployment role/boundary and restricted context are also installed; production runtime and ECR changes remain gated on dev validation. Installation evidence and remaining service-specific steps are private in [PROVISIONING.txt](https://github.com/topcoder-platform/v6-services-iac/blob/main/services/groups-api-v6/deploy/PROVISIONING.txt). Deploy roles have explicit secret-store and KMS-decryption denies. Runtime values are retrieved only by ECS using the execution role. -## Development acceptance before merge/release +At production cutover, stop legacy publishers, enable unconditional tag immutability, adopt missing task health checks with the reviewed image, and use the approval-gated `master` workflow. Preserve capacity, roles, secret references and rollback. Do not run production before dev validation. -Read-only inventory on 2026-11-04 verified `dev.json` against the actual development service, task/execution roles and image repositories. This PR targets `develop`. Matching IAM templates and detailed baselines remain private. **Keep this PR in draft until the service-specific prerequisites below are complete.** No AWS or CircleCI resources were provisioned by this refresh. +## Development acceptance -- Install the service deployment role and matching permissions boundary. -- Create the restricted empty CircleCI deployment context. -- Set unconditional immutable ECR tags, preserving existing enhanced scanning. -- Review and install the dev container health-check proposal; preserve all other task configuration. +This PR targets `develop`. Administrator-installed dev prerequisites are recorded in the private IaC repository. The reviewed task health check was submitted only after confirming the existing image serves the identical healthy load-balancer endpoint. + +- Dev infrastructure prerequisites are installed; merge to run the application deployment, then validate functionality. Run the shared offline suite, validate the CircleCI config and IAM policies, and test a dev release plus an unhealthy-image rollback. Verify CloudTrail contains no SSM/Secrets Manager calls from the deployment principal. Remove its old broker grants only after migration. Check the runtime secret references and roles stayed unchanged. Production requires the manual approval job and a passing digest/scan/health verification. @@ -33,6 +28,6 @@ IAM templates and detailed AWS baselines are maintained in the private [v6-servi ## Dev branch refresh -This PR targets `develop` and preserves its current application/dependency fixes. The shared suite is v2.0.5 (82 offline tests); service-specific adapters and their tests remain part of review. Keep this PR in draft until its documented infrastructure and integration prerequisites are met. Updating these files does not provision AWS or CircleCI resources. +This PR targets `develop` and preserves its current application/dependency fixes. The shared suite is v2.0.5 (82 offline tests); service-specific adapters and their tests remain part of review. Use the current readiness record above for the remaining merge/deployment gates. Updating these files does not provision AWS or CircleCI resources. Source checkout uses the public HTTPS repository and verifies the exact CircleCI commit, avoiding dependency on failing SSH checkout keys. No GitHub token is added to build or deployment contexts. From 36bc0387584e3487bfd635797539d5d4ba8c53c2 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Thu, 5 Nov 2026 08:44:04 +1100 Subject: [PATCH 11/11] Pin deployment suite v2.0.6 and enable reviewed health-check bootstrap --- .circleci/config.yml | 6 +++--- deploy/MIGRATION.md | 8 ++++++-- deploy/release.py | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9c13977..aa5115f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,14 +21,14 @@ commands: checkout-suite: steps: - run: - name: Verify deployment suite v2.0.5 + name: Verify deployment suite v2.0.6 command: | set -euo pipefail git init --quiet /tmp/tc-deploy-scripts git -C /tmp/tc-deploy-scripts remote add origin https://github.com/topcoder-platform/tc-deploy-scripts.git - git -C /tmp/tc-deploy-scripts fetch --quiet --depth 1 origin refs/tags/v2.0.5 + git -C /tmp/tc-deploy-scripts fetch --quiet --depth 1 origin refs/tags/v2.0.6 git -C /tmp/tc-deploy-scripts checkout --quiet --detach FETCH_HEAD - test "$(git -C /tmp/tc-deploy-scripts rev-parse HEAD)" = bff574ab5c0b46773e25d2af1eff76675fba2ba5 + test "$(git -C /tmp/tc-deploy-scripts rev-parse HEAD)" = 26aaf607463d4a271c0099854c1731214215a9c5 jobs: build: executor: reviewed diff --git a/deploy/MIGRATION.md b/deploy/MIGRATION.md index bdbeebe..7fba568 100644 --- a/deploy/MIGRATION.md +++ b/deploy/MIGRATION.md @@ -1,6 +1,6 @@ # OIDC deployment migration -This change replaces the Auth0 credential broker and SSM-to-shell deployment path with [tc-deploy-scripts v2.0.5](https://github.com/topcoder-platform/tc-deploy-scripts/releases/tag/v2.0.5), fetched by tag and verified against commit `bff574ab5c0b46773e25d2af1eff76675fba2ba5`. Build and deployment run in separate jobs. The deployer cannot read Parameter Store, Secrets Manager or decrypt KMS data, including through another assumed role. ECS continues resolving the existing runtime secret references using the execution role. +This change replaces the Auth0 credential broker and SSM-to-shell deployment path with [tc-deploy-scripts v2.0.6](https://github.com/topcoder-platform/tc-deploy-scripts/releases/tag/v2.0.6), fetched by tag and verified against commit `26aaf607463d4a271c0099854c1731214215a9c5`. Build and deployment run in separate jobs. The deployer cannot read Parameter Store, Secrets Manager or decrypt KMS data, including through another assumed role. ECS continues resolving the existing runtime secret references using the execution role. ## Production target @@ -28,6 +28,10 @@ IAM templates and detailed AWS baselines are maintained in the private [v6-servi ## Dev branch refresh -This PR targets `develop` and preserves its current application/dependency fixes. The shared suite is v2.0.5 (82 offline tests); service-specific adapters and their tests remain part of review. Use the current readiness record above for the remaining merge/deployment gates. Updating these files does not provision AWS or CircleCI resources. +This PR targets `develop` and preserves its current application/dependency fixes. The shared suite is v2.0.6 (92 offline tests); service-specific adapters and their tests remain part of review. Use the current readiness record above for the remaining merge/deployment gates. Updating these files does not provision AWS or CircleCI resources. Source checkout uses the public HTTPS repository and verifies the exact CircleCI commit, avoiding dependency on failing SSH checkout keys. No GitHub token is added to build or deployment contexts. + +## Reviewed health-check bootstrap + +The release wrapper passes the environment-specific health-check JSON to v2.0.6. A missing check is added with the new scanned image; the old image is not restarted with a new probe. An identical existing check is preserved, and a different existing check stops the release. Role, runtime-secret reference, scan, concurrency and healthy-digest checks remain enforced. diff --git a/deploy/release.py b/deploy/release.py index 410a035..b989540 100644 --- a/deploy/release.py +++ b/deploy/release.py @@ -7,7 +7,8 @@ manifest = Path(sys.argv[1]) data = json.loads(manifest.read_text()) -command = [sys.executable, '-I', '/tmp/tc-deploy-scripts/tcdeploy.py', 'deploy', '--manifest', str(manifest)] +command = [sys.executable, '-I', '/tmp/tc-deploy-scripts/tcdeploy.py', 'deploy', '--manifest', str(manifest), + '--bootstrap-health-checks', str(manifest.with_name(data['environment'] + '-healthcheck.json'))] for container in data['images']: command.extend(['--image', container + '=groups-api-v6:candidate']) subprocess.run(command, check=True)