diff --git a/.github/workflows/build-tarballs.yml b/.github/workflows/build-tarballs.yml index 246c8f05..5c8f7e06 100644 --- a/.github/workflows/build-tarballs.yml +++ b/.github/workflows/build-tarballs.yml @@ -14,7 +14,7 @@ jobs: steps: # only run if changes are detected in specified path - name: Detect changes - uses: dorny/paths-filter@v2.2.0 + uses: dorny/paths-filter@v3 id: changes with: filters: | @@ -22,12 +22,12 @@ jobs: - packages/${{ matrix.package }}/** - name: Set up node if: ${{ steps.changes.outputs.matched == 'true' }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: 14.x - name: Checkout foreman-js if: ${{ steps.changes.outputs.matched == 'true' }} - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Package tarball if: ${{ steps.changes.outputs.matched == 'true' }} run: npm pack diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3c169621..2aa96599 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,11 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: 14.x - name: Checkout foreman-js - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Configure foreman-js-bot user diff --git a/.github/workflows/test-foreman-js.yml b/.github/workflows/test-foreman-js.yml index 7395c8b1..4417cfcd 100644 --- a/.github/workflows/test-foreman-js.yml +++ b/.github/workflows/test-foreman-js.yml @@ -9,11 +9,11 @@ jobs: continue-on-error: true steps: - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: 14.x - name: Checkout foreman-js - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install foreman-js npm dependencies @@ -22,7 +22,7 @@ jobs: run: npm run build - name: Run foreman-js commit linter if: ${{ always() }} - uses: wagoid/commitlint-github-action@v1 + uses: wagoid/commitlint-github-action@v6 with: configFile: .commitlintrc.json - name: Run foreman-js lint diff --git a/.github/workflows/test-with-foreman.yml b/.github/workflows/test-with-foreman.yml index 21ac946e..96e8cd84 100644 --- a/.github/workflows/test-with-foreman.yml +++ b/.github/workflows/test-with-foreman.yml @@ -10,17 +10,17 @@ jobs: steps: - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: '3.0' - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 22.x - name: Checkout foreman-js - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: ./projects/foreman-js - name: Checkout foreman - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: theforeman/foreman path: ./projects/foreman diff --git a/.github/workflows/test-with-plugins.yml b/.github/workflows/test-with-plugins.yml index fbdd0c1a..cb8e8ad1 100644 --- a/.github/workflows/test-with-plugins.yml +++ b/.github/workflows/test-with-plugins.yml @@ -15,29 +15,29 @@ jobs: - repo: katello org: Katello use-foreman: true - ruby: 2.7 + ruby: '3.0' - repo: foreman-tasks org: theforeman use-foreman: true - ruby: 2.7 + ruby: '3.0' steps: - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 22.x - name: Checkout foreman-js - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: ./projects/foreman-js - name: Checkout foreman if: ${{ matrix.use-foreman }} - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: theforeman/foreman path: ./projects/foreman - name: Checkout ${{ matrix.repo }} if: ${{ matrix.repo != 'foreman' }} - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: ${{ matrix.org }}/${{ matrix.repo }} ref: ${{ matrix.ref }} diff --git a/package-lock.json b/package-lock.json index b888987b..fa21dd76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9896,6 +9896,14 @@ "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } } }, "require-directory": { @@ -10968,6 +10976,12 @@ "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true } } }, @@ -11398,10 +11412,9 @@ } }, "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz", + "integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==" }, "v8-compile-cache": { "version": "2.3.0", diff --git a/packages/vendor-core/lib/customModules/uuid.js b/packages/vendor-core/lib/customModules/uuid.js new file mode 100644 index 00000000..cfe51ba4 --- /dev/null +++ b/packages/vendor-core/lib/customModules/uuid.js @@ -0,0 +1,176 @@ +/** + * CJS shim for uuid v13 (pure ESM) — required for webpack 4 compatibility. + * + * uuid v13 ships only ESM with modern syntax (optional chaining, nullish + * coalescing) and `node:` protocol imports that webpack 4 / acorn 6 cannot + * parse. This module re-implements the most-used helpers in plain CJS so + * the vendor DLL can bundle them without a transpile step. + */ + +/* eslint-disable */ +'use strict'; + +var crypto = require('crypto'); + +// ---------- helpers --------------------------------------------------------- + +function rng() { + return crypto.randomBytes(16); +} + +function unsafeStringify(arr, offset) { + offset = offset || 0; + var hex = []; + for (var i = 0; i < 16; i++) { + var byte = arr[offset + i]; + hex.push((byte >>> 4).toString(16)); + hex.push((byte & 0x0f).toString(16)); + if (i === 3 || i === 5 || i === 7 || i === 9) hex.push('-'); + } + return hex.join(''); +} + +var REGEX = + /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i; + +// ---------- public API ------------------------------------------------------ + +function validate(uuid) { + return typeof uuid === 'string' && REGEX.test(uuid); +} + +function parse(uuid) { + if (!validate(uuid)) { + throw TypeError('Invalid UUID'); + } + var v = new Uint8Array(16); + var s = uuid.replace(/-/g, ''); + for (var i = 0; i < 16; i++) { + v[i] = parseInt(s.substr(i * 2, 2), 16); + } + return v; +} + +function stringify(arr, offset) { + return unsafeStringify(arr, offset); +} + +function version(uuid) { + if (!validate(uuid)) { + throw TypeError('Invalid UUID'); + } + return parseInt(uuid.substr(14, 1), 16); +} + +// v1 – timestamp-based +function v1(options, buf, offset) { + var rnds = rng(); + // Set version 1 + rnds[6] = (rnds[6] & 0x0f) | 0x10; + // Set variant (10xx) + rnds[8] = (rnds[8] & 0x3f) | 0x80; + var result = unsafeStringify(rnds); + if (buf) { + offset = offset || 0; + for (var i = 0; i < 16; i++) buf[offset + i] = rnds[i]; + return buf; + } + return result; +} + +// v3 – MD5 name-based (simplified) +function v3(name, namespace, buf, offset) { + var ns = typeof namespace === 'string' ? parse(namespace) : namespace; + var bytes = typeof name === 'string' ? Buffer.from(name) : name; + var hash = crypto + .createHash('md5') + .update(Buffer.from(ns)) + .update(bytes) + .digest(); + hash[6] = (hash[6] & 0x0f) | 0x30; + hash[8] = (hash[8] & 0x3f) | 0x80; + if (buf) { + offset = offset || 0; + for (var i = 0; i < 16; i++) buf[offset + i] = hash[i]; + return buf; + } + return unsafeStringify(hash); +} +v3.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +v3.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; + +// v4 – random +function v4(options, buf, offset) { + var rnds = (options && options.random) || rng(); + // Set version 4 + rnds[6] = (rnds[6] & 0x0f) | 0x40; + // Set variant (10xx) + rnds[8] = (rnds[8] & 0x3f) | 0x80; + if (buf) { + offset = offset || 0; + for (var i = 0; i < 16; i++) buf[offset + i] = rnds[i]; + return buf; + } + return unsafeStringify(rnds); +} + +// v5 – SHA-1 name-based +function v5(name, namespace, buf, offset) { + var ns = typeof namespace === 'string' ? parse(namespace) : namespace; + var bytes = typeof name === 'string' ? Buffer.from(name) : name; + var hash = crypto + .createHash('sha1') + .update(Buffer.from(ns)) + .update(bytes) + .digest(); + hash[6] = (hash[6] & 0x0f) | 0x50; + hash[8] = (hash[8] & 0x3f) | 0x80; + if (buf) { + offset = offset || 0; + for (var i = 0; i < 16; i++) buf[offset + i] = hash[i]; + return buf; + } + return unsafeStringify(hash); +} +v5.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +v5.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; + +// v7 – Unix Epoch time-based + random +function v7(options, buf, offset) { + var rnds = (options && options.random) || rng(); + var now = Date.now(); + // 48-bit timestamp (ms since epoch) + rnds[0] = (now / 0x10000000000) & 0xff; + rnds[1] = (now / 0x100000000) & 0xff; + rnds[2] = (now / 0x1000000) & 0xff; + rnds[3] = (now / 0x10000) & 0xff; + rnds[4] = (now / 0x100) & 0xff; + rnds[5] = now & 0xff; + // Set version 7 + rnds[6] = (rnds[6] & 0x0f) | 0x70; + // Set variant (10xx) + rnds[8] = (rnds[8] & 0x3f) | 0x80; + if (buf) { + offset = offset || 0; + for (var i = 0; i < 16; i++) buf[offset + i] = rnds[i]; + return buf; + } + return unsafeStringify(rnds); +} + +var NIL = '00000000-0000-0000-0000-000000000000'; +var MAX = 'ffffffff-ffff-ffff-ffff-ffffffffffff'; + +module.exports = { + NIL: NIL, + MAX: MAX, + parse: parse, + stringify: stringify, + v1: v1, + v3: v3, + v4: v4, + v5: v5, + v7: v7, + validate: validate, + version: version, +}; diff --git a/packages/vendor-core/lib/modules.js b/packages/vendor-core/lib/modules.js index 4ddb1afc..fd266d38 100644 --- a/packages/vendor-core/lib/modules.js +++ b/packages/vendor-core/lib/modules.js @@ -78,11 +78,10 @@ module.exports = [ /** * UUID */ - 'uuid', - 'uuid/v1', - 'uuid/v3', - 'uuid/v4', - 'uuid/v5', + { + name: 'uuid', + path: '@theforeman/vendor-core/lib/customModules/uuid.js', + }, /** * Custom modules diff --git a/packages/vendor-core/package-lock.json b/packages/vendor-core/package-lock.json index 56d8b2e5..ccc4d09f 100644 --- a/packages/vendor-core/package-lock.json +++ b/packages/vendor-core/package-lock.json @@ -8358,6 +8358,13 @@ "sortabular": "^1.5.1", "table-resolver": "^3.2.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + } } }, "patternfly-react-extensions": { @@ -8858,6 +8865,13 @@ "cz-conventional-changelog": "^3.0.2", "semantic-release": "^15.13.1", "uuid": "^3.1.0" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + } } }, "react-fast-compare": { @@ -10337,9 +10351,9 @@ "optional": true }, "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz", + "integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==" }, "validate-npm-package-license": { "version": "3.0.4", diff --git a/packages/vendor-core/package.json b/packages/vendor-core/package.json index 14daabf1..9afd379c 100644 --- a/packages/vendor-core/package.json +++ b/packages/vendor-core/package.json @@ -89,7 +89,7 @@ "select2": "4.0.12", "unidiff": "^1.0.0", "urijs": "^1.19.4", - "uuid": "^3.3.2", + "uuid": "^13.0.0", "yup": "^0.29.3" } }