diff --git a/.github/renovate.json b/.github/renovate.json index be0091af..c61849e9 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -30,7 +30,7 @@ "extractVersion": "^v(?.*)$" }, { - "matchPackageNames": ["@types/node", "node-fetch", "long", "protobufjs"], + "matchPackageNames": ["@types/node", "long", "protobufjs"], "matchUpdateTypes": ["major"], "enabled": false }, diff --git a/.node-version b/.node-version index 7cc20699..5538e1c3 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -20.5.1 +20.6.1 diff --git a/package-lock.json b/package-lock.json index f7dbcf5e..c006a265 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,8 @@ "devDependencies": { "@microsoft/api-documenter": "7.22.33", "@microsoft/api-extractor": "7.36.4", - "@tsconfig/node16": "16.1.1", - "@types/node": "16.18.46", + "@tsconfig/node18": "18.2.1", + "@types/node": "18.17.15", "@typescript-eslint/eslint-plugin": "6.5.0", "@typescript-eslint/parser": "6.5.0", "concurrently": "8.2.1", @@ -31,8 +31,8 @@ "typescript": "5.2.2" }, "engines": { - "node": "20.5.1", - "npm": "9.8.1" + "node": "20.6.1", + "npm": "10.1.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1751,10 +1751,10 @@ "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", "dev": true }, - "node_modules/@tsconfig/node16": { - "version": "16.1.1", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-16.1.1.tgz", - "integrity": "sha512-+pio93ejHN4nINX4pXqfnR/fPLRtJBaT4ORaa5RH0Oc1zoYmo2B2koG+M328CQhHKn1Wj6FcOxCDFXAot9NhvA==", + "node_modules/@tsconfig/node18": { + "version": "18.2.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node18/-/node18-18.2.1.tgz", + "integrity": "sha512-RDDZFuofwkcKpl8Vpj5wFbY+H53xOtqK7ckEL1sXsbPwvKwDdjQf3LkHbtt9sxIHn9nWIEwkmCwBRZ6z5TKU2A==", "dev": true }, "node_modules/@types/argparse": { @@ -1850,19 +1850,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.18.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.46.tgz", - "integrity": "sha512-Mnq3O9Xz52exs3mlxMcQuA7/9VFe/dXcrgAyfjLkABIqxXKOgBRjyazTxUbjsxDa4BP7hhPliyjVTP9RDP14xg==" - }, - "node_modules/@types/node-fetch": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.4.tgz", - "integrity": "sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg==", - "dev": true, - "dependencies": { - "@types/node": "*", - "form-data": "^3.0.0" - } + "version": "18.17.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.15.tgz", + "integrity": "sha512-2yrWpBk32tvV/JAd3HNHWuZn/VDN1P+72hWirHnvsvTGSqbANi+kSeuQR9yAHnbvaBvHDsoTdXV0Fe+iRtHLKA==" }, "node_modules/@types/qs": { "version": "6.9.7", @@ -2349,12 +2339,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true - }, "node_modules/at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", @@ -2752,18 +2736,6 @@ "node": ">=0.1.90" } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/commander": { "version": "9.5.0", "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", @@ -2910,15 +2882,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", @@ -3799,20 +3762,6 @@ "is-callable": "^1.1.3" } }, - "node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dev": true, - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -5460,27 +5409,6 @@ "node": ">=8.6" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -5527,26 +5455,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/node-fetch": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", - "integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==", - "dev": true, - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -6748,12 +6656,6 @@ "node": ">=8.0" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true - }, "node_modules/tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", @@ -7187,22 +7089,6 @@ "makeerror": "1.0.12" } }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dev": true, - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -7387,7 +7273,7 @@ "@types/uuid": "9.0.2" }, "engines": { - "node": ">= 16" + "node": ">= 18" } }, "packages/files": { @@ -7399,7 +7285,7 @@ "yaml": "^2.3.2" }, "engines": { - "node": ">= 16" + "node": ">= 18" } }, "packages/grpc": { @@ -7413,7 +7299,7 @@ "protobufjs": "^7.2.5" }, "engines": { - "node": ">= 16" + "node": ">= 18" } }, "packages/http": { @@ -7428,7 +7314,7 @@ "@types/qs": "6.9.7" }, "engines": { - "node": ">= 16" + "node": ">= 18" } }, "packages/lite": { @@ -7439,7 +7325,7 @@ "@cerbos/core": "^0.13.0" }, "engines": { - "node": ">= 16" + "node": ">= 18" } }, "packages/opentelemetry": { @@ -7453,7 +7339,7 @@ "@opentelemetry/semantic-conventions": "^1.15.2" }, "engines": { - "node": ">= 16" + "node": ">= 18" } }, "packages/test": { @@ -7472,11 +7358,9 @@ "@opentelemetry/sdk-trace-base": "1.15.2", "@opentelemetry/sdk-trace-node": "1.15.2", "@opentelemetry/semantic-conventions": "1.15.2", - "@types/node-fetch": "2.6.4", "@types/semver": "7.5.0", "jest": "29.6.4", "jose": "4.14.4", - "node-fetch": "2.6.12", "semver": "7.5.4" } } diff --git a/package.json b/package.json index c2dc8d0d..fc768180 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "packages/*" ], "engines": { - "node": "20.5.1", - "npm": "9.8.1" + "node": "20.6.1", + "npm": "10.1.0" }, "scripts": { "all:parallel": "concurrently --group --prefix=none", @@ -55,8 +55,8 @@ "devDependencies": { "@microsoft/api-documenter": "7.22.33", "@microsoft/api-extractor": "7.36.4", - "@tsconfig/node16": "16.1.1", - "@types/node": "16.18.46", + "@tsconfig/node18": "18.2.1", + "@types/node": "18.17.15", "@typescript-eslint/eslint-plugin": "6.5.0", "@typescript-eslint/parser": "6.5.0", "concurrently": "8.2.1", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 5a55c5c4..a5d33d9e 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,6 +1,8 @@ ## [Unreleased] -No notable changes. +### Removed + +- Support for Node.js 16, which is now [end-of-life](https://github.com/nodejs/release#end-of-life-releases) ([#669](https://github.com/cerbos/cerbos-sdk-javascript/pull/669)) ## [0.13.0] - 2023-08-16 diff --git a/packages/core/package.json b/packages/core/package.json index f8be111d..67115a32 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -14,7 +14,7 @@ "author": "Cerbos (https://cerbos.dev)", "license": "Apache-2.0", "engines": { - "node": ">= 16" + "node": ">= 18" }, "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/files/CHANGELOG.md b/packages/files/CHANGELOG.md index f532e153..73daefaf 100644 --- a/packages/files/CHANGELOG.md +++ b/packages/files/CHANGELOG.md @@ -4,6 +4,10 @@ - Bump dependency on [yaml](https://github.com/eemeli/yaml) to 2.3.2 ([#658](https://github.com/cerbos/cerbos-sdk-javascript/pull/658)) +### Removed + +- Support for Node.js 16, which is now [end-of-life](https://github.com/nodejs/release#end-of-life-releases) ([#669](https://github.com/cerbos/cerbos-sdk-javascript/pull/669)) + ## [0.1.1] - 2023-08-16 ### Changed diff --git a/packages/files/README.md b/packages/files/README.md index feedda12..eda3118f 100644 --- a/packages/files/README.md +++ b/packages/files/README.md @@ -6,7 +6,7 @@ Load Cerbos policies from YAML or JSON files. ## Prerequisites -- Node.js 16+ +- Node.js 18+ ## Installation @@ -14,12 +14,6 @@ Load Cerbos policies from YAML or JSON files. $ npm install @cerbos/files ``` -or - -```console -$ yarn add @cerbos/files -``` - ## Example usage ```typescript diff --git a/packages/files/package.json b/packages/files/package.json index 3ed2c077..bdc07143 100644 --- a/packages/files/package.json +++ b/packages/files/package.json @@ -14,7 +14,7 @@ "author": "Cerbos (https://cerbos.dev)", "license": "Apache-2.0", "engines": { - "node": ">= 16" + "node": ">= 18" }, "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/grpc/CHANGELOG.md b/packages/grpc/CHANGELOG.md index 17e81c3a..8a463446 100644 --- a/packages/grpc/CHANGELOG.md +++ b/packages/grpc/CHANGELOG.md @@ -5,6 +5,10 @@ - Bump dependency on [@grpc/grpc-js](https://github.com/grpc/grpc-node) to 1.9.1 ([#654](https://github.com/cerbos/cerbos-sdk-javascript/pull/654)) - Bump dependency on [protobufjs](https://github.com/protobufjs/protobuf.js) to 7.2.5 ([#651](https://github.com/cerbos/cerbos-sdk-javascript/pull/651)) +### Removed + +- Support for Node.js 16, which is now [end-of-life](https://github.com/nodejs/release#end-of-life-releases) ([#669](https://github.com/cerbos/cerbos-sdk-javascript/pull/669)) + ## [0.13.0] - 2023-08-16 ### Added diff --git a/packages/grpc/README.md b/packages/grpc/README.md index 4e015c53..69ae9549 100644 --- a/packages/grpc/README.md +++ b/packages/grpc/README.md @@ -7,7 +7,7 @@ Client library for interacting with the Cerbos policy decision point over gRPC f ## Prerequisites - Cerbos 0.16+ -- Node.js 16+ +- Node.js 18+ ## Installation @@ -15,12 +15,6 @@ Client library for interacting with the Cerbos policy decision point over gRPC f $ npm install @cerbos/grpc ``` -or - -```console -$ yarn add @cerbos/grpc -``` - ## Example usage ```typescript diff --git a/packages/grpc/package.json b/packages/grpc/package.json index a497b1f6..905c2c26 100644 --- a/packages/grpc/package.json +++ b/packages/grpc/package.json @@ -14,7 +14,7 @@ "author": "Cerbos (https://cerbos.dev)", "license": "Apache-2.0", "engines": { - "node": ">= 16" + "node": ">= 18" }, "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/http/CHANGELOG.md b/packages/http/CHANGELOG.md index cbec1775..381a6115 100644 --- a/packages/http/CHANGELOG.md +++ b/packages/http/CHANGELOG.md @@ -1,6 +1,8 @@ ## [Unreleased] -No notable changes. +### Removed + +- Support for Node.js 16, which is now [end-of-life](https://github.com/nodejs/release#end-of-life-releases) ([#669](https://github.com/cerbos/cerbos-sdk-javascript/pull/669)) ## [0.14.0] - 2023-08-16 diff --git a/packages/http/README.md b/packages/http/README.md index 177088e7..e9ba9497 100644 --- a/packages/http/README.md +++ b/packages/http/README.md @@ -9,14 +9,10 @@ If you're targeting [old browsers](https://caniuse.com/fetch), you'll need to ap You can use it in server-side Node.js applications, but the [gRPC client](../grpc/README.md) might be more appropriate. -- For Node.js up to 17.4, you'll need [a polyfill](https://www.npmjs.com/package/cross-fetch) to make `fetch` happen. -- From Node.js 17.5, you can instead enable the [`--experimental-fetch`](https://nodejs.org/dist/latest-v17.x/docs/api/cli.html#--experimental-fetch) option at the command line or via `NODE_OPTIONS`. -- From Node.js 18 onwards `fetch` is available without any additional configuration. - ## Prerequisites - Cerbos 0.16+ -- Node.js 16+ +- Node.js 18+ - `fetch` ## Installation @@ -25,12 +21,6 @@ You can use it in server-side Node.js applications, but the [gRPC client](../grp $ npm install @cerbos/http ``` -or - -```console -$ yarn add @cerbos/http -``` - ## Example usage ```typescript diff --git a/packages/http/package.json b/packages/http/package.json index e69c684b..874aa23c 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -14,7 +14,7 @@ "author": "Cerbos (https://cerbos.dev)", "license": "Apache-2.0", "engines": { - "node": ">= 16" + "node": ">= 18" }, "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/lite/CHANGELOG.md b/packages/lite/CHANGELOG.md index 9a841409..ddd57f4c 100644 --- a/packages/lite/CHANGELOG.md +++ b/packages/lite/CHANGELOG.md @@ -1,6 +1,8 @@ ## [Unreleased] -No notable changes. +### Removed + +- Support for Node.js 16, which is now [end-of-life](https://github.com/nodejs/release#end-of-life-releases) ([#669](https://github.com/cerbos/cerbos-sdk-javascript/pull/669)) ## [0.4.1-beta] - 2023-08-16 diff --git a/packages/lite/README.md b/packages/lite/README.md index 34c36ab4..e069234d 100644 --- a/packages/lite/README.md +++ b/packages/lite/README.md @@ -6,7 +6,7 @@ Client library for interacting with WebAssembly Cerbos policy bundles from serve ## Prerequisites -- Node.js 16+ +- Node.js 18+ ## Installation @@ -14,12 +14,6 @@ Client library for interacting with WebAssembly Cerbos policy bundles from serve $ npm install @cerbos/lite ``` -or - -```console -$ yarn add @cerbos/lite -``` - ## Example usage ```typescript diff --git a/packages/lite/package.json b/packages/lite/package.json index 734e1058..4269ec63 100644 --- a/packages/lite/package.json +++ b/packages/lite/package.json @@ -14,7 +14,7 @@ "author": "Cerbos (https://cerbos.dev)", "license": "Apache-2.0", "engines": { - "node": ">= 16" + "node": ">= 18" }, "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/opentelemetry/CHANGELOG.md b/packages/opentelemetry/CHANGELOG.md index 3eb86c32..ea934dd1 100644 --- a/packages/opentelemetry/CHANGELOG.md +++ b/packages/opentelemetry/CHANGELOG.md @@ -1,6 +1,8 @@ ## [Unreleased] -No notable changes. +### Removed + +- Support for Node.js 16, which is now [end-of-life](https://github.com/nodejs/release#end-of-life-releases) ([#669](https://github.com/cerbos/cerbos-sdk-javascript/pull/669)) ## [0.3.0] - 2023-08-16 diff --git a/packages/opentelemetry/README.md b/packages/opentelemetry/README.md index c212c6cf..1c1edb01 100644 --- a/packages/opentelemetry/README.md +++ b/packages/opentelemetry/README.md @@ -6,7 +6,7 @@ ## Prerequisites -- Node.js 16+ +- Node.js 18+ ## Installation @@ -14,12 +14,6 @@ $ npm install @cerbos/opentelemetry ``` -or - -```console -$ yarn add @cerbos/opentelemetry -``` - ## Example usage Register [`CerbosInstrumentation`](../../docs/opentelemetry.cerbosinstrumentation.md) with your other [OpenTelemetry instrumentation](https://opentelemetry.io/docs/instrumentation/js/instrumentation/): diff --git a/packages/opentelemetry/package.json b/packages/opentelemetry/package.json index 45f81b88..ad260631 100644 --- a/packages/opentelemetry/package.json +++ b/packages/opentelemetry/package.json @@ -14,7 +14,7 @@ "author": "Cerbos (https://cerbos.dev)", "license": "Apache-2.0", "engines": { - "node": ">= 16" + "node": ">= 18" }, "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/test/package.json b/packages/test/package.json index fc0b2a14..f3972bbf 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -21,11 +21,9 @@ "@opentelemetry/sdk-trace-base": "1.15.2", "@opentelemetry/sdk-trace-node": "1.15.2", "@opentelemetry/semantic-conventions": "1.15.2", - "@types/node-fetch": "2.6.4", "@types/semver": "7.5.0", "jest": "29.6.4", "jose": "4.14.4", - "node-fetch": "2.6.12", "semver": "7.5.4" } } diff --git a/packages/test/src/CerbosInstrumentation.test.ts b/packages/test/src/CerbosInstrumentation.test.ts index 9623f2f9..5d25c226 100644 --- a/packages/test/src/CerbosInstrumentation.test.ts +++ b/packages/test/src/CerbosInstrumentation.test.ts @@ -1,7 +1,5 @@ /* eslint-disable jest/no-conditional-expect */ -import "./fetch-polyfill"; - import { readFileSync } from "fs"; import { resolve } from "path"; @@ -39,6 +37,7 @@ import { captureSpan, expectMetrics, fetchSpans, + invalidArgumentDetails, } from "./helpers"; import { QueryServiceClient } from "./protobuf/jaeger/proto/api_v3/query_service"; import type { KeyValue as KeyValueProto } from "./protobuf/opentelemetry/proto/common/v1/common"; @@ -232,16 +231,14 @@ describe("CerbosInstrumentation", () => { [SemanticAttributes.RPC_SERVICE]: "cerbos.svc.v1.CerbosService", [SemanticAttributes.RPC_METHOD]: "CheckResources", [SemanticAttributes.RPC_GRPC_STATUS_CODE]: Status.INVALID_ARGUMENT, - "cerbos.error": expect.stringContaining( - "invalid CheckResourcesRequest", - ) as unknown as AttributeValue, + "cerbos.error": invalidArgumentDetails as unknown as AttributeValue, }; expect(result).toEqual({ error: expect.objectContaining({ constructor: NotOK, code: Status.INVALID_ARGUMENT, - details: expect.stringContaining("invalid CheckResourcesRequest"), + details: invalidArgumentDetails, }), }); diff --git a/packages/test/src/Client.test.ts b/packages/test/src/Client.test.ts index 86e6ae4a..f5e8d989 100644 --- a/packages/test/src/Client.test.ts +++ b/packages/test/src/Client.test.ts @@ -1,7 +1,5 @@ /* eslint-disable jest/no-conditional-expect */ -import "./fetch-polyfill"; - import { readFileSync, readdirSync } from "fs"; import { resolve } from "path"; import { createSecureContext } from "tls"; @@ -36,6 +34,7 @@ import { afterAll, beforeAll, describe, expect, it, jest } from "@jest/globals"; import { UnsecuredJWT } from "jose"; import { compare as semverCompare, lte as semverLte } from "semver"; +import { invalidArgumentDetails as invalidArgumentDetails } from "./helpers"; import type { Ports } from "./servers"; import { cerbosVersion, @@ -625,20 +624,23 @@ describe("Client", () => { }); it("handles errors", async () => { - await expect( - clients.default.checkResources({ + try { + await clients.default.checkResources({ principal: { id: "", roles: [], }, resources: [], - }), - ).rejects.toThrow( - new NotOK( - Status.INVALID_ARGUMENT, - "invalid CheckResourcesRequest.Principal: embedded message failed validation | caused by: invalid Principal.Id: value length must be at least 1 runes", - ), - ); + }); + + throw new Error("expected an error to be thrown"); + } catch (error) { + expect(error).toMatchObject({ + constructor: NotOK, + code: Status.INVALID_ARGUMENT, + details: invalidArgumentDetails, + }); + } }); }, ); diff --git a/packages/test/src/HTTP.test.ts b/packages/test/src/HTTP.test.ts index edb946e6..f2a6112c 100644 --- a/packages/test/src/HTTP.test.ts +++ b/packages/test/src/HTTP.test.ts @@ -1,5 +1,3 @@ -import "./fetch-polyfill"; - import type { IncomingHttpHeaders } from "http"; import { createServer } from "http"; import type { AddressInfo } from "net"; diff --git a/packages/test/src/Lite.test.ts b/packages/test/src/Lite.test.ts index 2aae73b3..ea7a72ad 100644 --- a/packages/test/src/Lite.test.ts +++ b/packages/test/src/Lite.test.ts @@ -1,5 +1,3 @@ -import "./fetch-polyfill"; - import { readFileSync } from "fs"; import { resolve } from "path"; diff --git a/packages/test/src/fetch-polyfill.ts b/packages/test/src/fetch-polyfill.ts deleted file mode 100644 index 7aeeb31f..00000000 --- a/packages/test/src/fetch-polyfill.ts +++ /dev/null @@ -1,10 +0,0 @@ -import fetch, { Headers, Request, Response } from "node-fetch"; - -if (!("fetch" in globalThis)) { - Object.assign(globalThis, { - fetch, - Headers, - Request, - Response, - }); -} diff --git a/packages/test/src/helpers.ts b/packages/test/src/helpers.ts index 9260384b..2045ab0d 100644 --- a/packages/test/src/helpers.ts +++ b/packages/test/src/helpers.ts @@ -27,6 +27,7 @@ import type { SpansResponseChunk, } from "./protobuf/jaeger/proto/api_v3/query_service"; import type { Span as SpanProto } from "./protobuf/opentelemetry/proto/trace/v1/trace"; +import { cerbosVersionIsAtLeast } from "./servers"; export function buildResultsForResources({ id, @@ -200,3 +201,9 @@ export async function expectMetrics( function hrTimeToMilliseconds([seconds, nanoseconds]: HrTime): number { return seconds * 1e3 + nanoseconds * 1e-6; } + +export const invalidArgumentDetails = expect.stringContaining( + cerbosVersionIsAtLeast("0.30.0") + ? "validation error" + : "invalid CheckResourcesRequest", +); diff --git a/packages/test/src/servers.ts b/packages/test/src/servers.ts index 31dae866..12ccd8da 100644 --- a/packages/test/src/servers.ts +++ b/packages/test/src/servers.ts @@ -49,28 +49,34 @@ export async function ports(): Promise { "json", ]); - const output = JSON.parse(stdout) as DockerComposeContainer[]; + const containers = stdout + .split("\n") + .filter((line) => line !== "") + .flatMap( + (line) => + JSON.parse(line) as DockerComposeContainer | DockerComposeContainer[], + ); return { grpc: { - plaintext: port(output, "plaintext", 3593), - tls: port(output, "tls", 3593), - mtls: port(output, "mtls", 3593), - mutable: port(output, "mutable", 3593), + plaintext: port(containers, "plaintext", 3593), + tls: port(containers, "tls", 3593), + mtls: port(containers, "mtls", 3593), + mutable: port(containers, "mutable", 3593), get tracing(): number { - return port(output, "tracing", 3593); + return port(containers, "tracing", 3593); }, }, http: { - plaintext: port(output, "plaintext", 3592), - tls: port(output, "tls", 3592), - mutable: port(output, "mutable", 3592), + plaintext: port(containers, "plaintext", 3592), + tls: port(containers, "tls", 3592), + mutable: port(containers, "mutable", 3592), get tracing(): number { - return port(output, "tracing", 3592); + return port(containers, "tracing", 3592); }, }, get jaeger(): number { - return port(output, "jaeger", 16685); + return port(containers, "jaeger", 16685); }, }; } diff --git a/packages/tsconfig.base.json b/packages/tsconfig.base.json index e046b47b..d7184647 100644 --- a/packages/tsconfig.base.json +++ b/packages/tsconfig.base.json @@ -1,5 +1,5 @@ { - "extends": "@tsconfig/node16/tsconfig.json", + "extends": "@tsconfig/node18/tsconfig.json", "compilerOptions": { "composite": true, "declarationMap": true, diff --git a/scripts/test-matrix b/scripts/test-matrix index 9d9bfd54..074077fd 100755 --- a/scripts/test-matrix +++ b/scripts/test-matrix @@ -12,7 +12,7 @@ response.value schedule = JSON.parse(response.body) node_versions = schedule.filter_map do |version, dates| - version.delete_prefix("v") if (Date.iso8601(dates.fetch("start"))...Date.iso8601(dates.fetch("end"))).include?(Date.today - 7) + version.delete_prefix("v") if (Date.iso8601(dates.fetch("start"))...Date.iso8601(dates.fetch("end"))).include?(Date.today) end latest_node_version = node_versions.last