From eace5d0ad38cb616f7d12ed6ce9637c68c75d2cf Mon Sep 17 00:00:00 2001 From: George Sproston <103250539+gsproston-scottlogic@users.noreply.github.com> Date: Tue, 22 Aug 2023 13:46:51 +0100 Subject: [PATCH] Convert backend to Typescript * 59 move to typescript - backend note: tests have not been migrated yet * WIP: First TS backend pass * nodemon backend * Typing for function call * Readded defence configuration values * Using model enum * Fixed defences * Removed unused variables * Get rid of some anys * Blocked message reason * Moved LLM evaluation check * Better chat types * Including test files in tsconfig * Renamed test js files to ts * WIP: Fixing tests * Defence unit test * Email defence unit test * All unit tests passing * Removed session from method * Removed session from openai methods * OpenAI ts integration tests * Removed document integration test as it needs redoing * Removed unused export * Backend phase enum * Removed empty settings file * Removed unused dep * Consistent function naming * Fixed test * Removed unecessary frontend key * Using phase enum in the frontend * Using easy QA prompt by default --------- Co-authored-by: Scott Rowan --- .gitignore | 2 +- backend/jest.config.js | 5 + backend/package-lock.json | 1849 +++++++++++++---- backend/package.json | 13 +- backend/src/app.js | 79 - backend/src/app.ts | 100 + backend/src/defence.js | 250 --- backend/src/defence.ts | 295 +++ backend/src/{email.js => email.ts} | 59 +- backend/src/{langchain.js => langchain.ts} | 112 +- backend/src/models/chat.ts | 58 + backend/src/models/defence.ts | 32 + backend/src/models/email.ts | 13 + backend/src/models/phase.ts | 8 + backend/src/openai.js | 296 --- backend/src/openai.ts | 346 +++ ...{promptTemplates.js => promptTemplates.ts} | 2 +- backend/src/router.js | 240 --- backend/src/router.ts | 259 +++ backend/test/integration/documents.test.js | 88 - .../{openai.test.js => openai.test.ts} | 542 ++--- .../unit/{defence.test.js => defence.test.ts} | 272 +-- .../unit/{email.test.js => email.test.ts} | 101 +- .../unit/{openai.test.js => openai.test.ts} | 58 +- backend/tsconfig.json | 18 + frontend/src/App.tsx | 28 +- .../src/components/AttackBox/AttackBox.tsx | 2 +- frontend/src/components/ChatBox/ChatBox.tsx | 3 +- .../src/components/ChatBox/ChatBoxMessage.tsx | 16 +- .../src/components/DefenceBox/DefenceBox.tsx | 3 +- .../DefenceBox/DefenceMechanism.tsx | 2 +- frontend/src/components/Header.tsx | 2 - .../ModelSelectionBox/ModelSelectionBox.tsx | 8 +- .../PhaseSelectionBox/PhaseSelectionBox.tsx | 9 +- frontend/src/models/chat.ts | 5 +- frontend/src/models/phase.ts | 8 +- frontend/src/service/chatService.ts | 11 +- frontend/src/service/phaseService.ts | 1 - frontend/tsconfig.json | 6 +- prompt-injection.code-workspace | 21 + 40 files changed, 3228 insertions(+), 1994 deletions(-) create mode 100644 backend/jest.config.js delete mode 100644 backend/src/app.js create mode 100644 backend/src/app.ts delete mode 100644 backend/src/defence.js create mode 100644 backend/src/defence.ts rename backend/src/{email.js => email.ts} (69%) rename backend/src/{langchain.js => langchain.ts} (67%) create mode 100644 backend/src/models/chat.ts create mode 100644 backend/src/models/defence.ts create mode 100644 backend/src/models/email.ts create mode 100644 backend/src/models/phase.ts delete mode 100644 backend/src/openai.js create mode 100644 backend/src/openai.ts rename backend/src/{promptTemplates.js => promptTemplates.ts} (99%) delete mode 100644 backend/src/router.js create mode 100644 backend/src/router.ts delete mode 100644 backend/test/integration/documents.test.js rename backend/test/integration/{openai.test.js => openai.test.ts} (52%) rename backend/test/unit/{defence.test.js => defence.test.ts} (50%) rename backend/test/unit/{email.test.js => email.test.ts} (62%) rename backend/test/unit/{openai.test.js => openai.test.ts} (59%) create mode 100644 backend/tsconfig.json create mode 100644 prompt-injection.code-workspace diff --git a/.gitignore b/.gitignore index e169df4f7..7992e0a80 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ bower_components .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release +build/ # Dependency directories node_modules/ diff --git a/backend/jest.config.js b/backend/jest.config.js new file mode 100644 index 000000000..b413e106d --- /dev/null +++ b/backend/jest.config.js @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +}; \ No newline at end of file diff --git a/backend/package-lock.json b/backend/package-lock.json index 870688004..f86e8d04a 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -16,7 +16,15 @@ "react": "^18.2.0" }, "devDependencies": { - "jest": "^29.6.1" + "@types/cors": "^2.8.13", + "@types/express": "^4.17.17", + "@types/express-session": "^1.17.7", + "@types/jest": "^29.5.3", + "@types/node": "^20.4.5", + "nodemon": "^3.0.1", + "ts-jest": "^29.1.1", + "ts-node": "^10.9.1", + "typescript": "^4.1.6" } }, "node_modules/@ampproject/remapping": { @@ -24,6 +32,7 @@ "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", "dev": true, + "peer": true, "dependencies": { "@jridgewell/gen-mapping": "^0.3.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -33,9 +42,9 @@ } }, "node_modules/@anthropic-ai/sdk": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.5.8.tgz", - "integrity": "sha512-iHenjcE2Q/az6VZiP1DueOSvKNRmxsly6Rx2yjJBoy7OBYVFGVjEdgs2mPQHtTX0ibKAR7tPq6F6MQbKDPWcKg==", + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.5.10.tgz", + "integrity": "sha512-P8xrIuTUO/6wDzcjQRUROXp4WSqtngbXaE4GpEu0PhEmnq/1Q8vbF1s0o7W07EV3j8zzRoyJxAKovUJtNXH7ew==", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -48,47 +57,121 @@ } }, "node_modules/@anthropic-ai/sdk/node_modules/@types/node": { - "version": "18.17.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.0.tgz", - "integrity": "sha512-GXZxEtOxYGFchyUzxvKI14iff9KZ2DI+A6a37o6EQevtg6uO9t+aUZKcaC1Te5Ng1OnLM7K9NVVj+FbecD9cJg==" + "version": "18.17.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.5.tgz", + "integrity": "sha512-xNbS75FxH6P4UXTPUJp/zNPq6/xsfdJKussCWNOnz4aULWIRwMgP1LgaB5RiBnMX1DPCYenuqGZfnIAx5mbFLA==" }, "node_modules/@babel/code-frame": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", - "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.10.tgz", + "integrity": "sha512-/KKIMG4UEL35WmI9OlvMhurwtytjvXoFcGNrOvyG9zIzA8YmPjVtIZUf7b05+TPO7G7/GEmLHDaoCgACHl9hhA==", "dev": true, "dependencies": { - "@babel/highlight": "^7.22.5" + "@babel/highlight": "^7.22.10", + "chalk": "^2.4.2" }, "engines": { "node": ">=6.9.0" } }, + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/code-frame/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/compat-data": { "version": "7.22.9", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.9.tgz", "integrity": "sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==", "dev": true, + "peer": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.9.tgz", - "integrity": "sha512-G2EgeufBcYw27U4hhoIwFcgc1XU7TlXJ3mv04oOv1WCuo900U/anZSPzEqNjwdjgffkk2Gs0AN0dW1CKVLcG7w==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.10.tgz", + "integrity": "sha512-fTmqbbUBAwCcre6zPzNngvsI0aNrPZe77AeqvDxWM9Nm+04RrJ3CAmGHA9f7lJQY6ZMhRztNemy4uslDxTX4Qw==", "dev": true, + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.9", - "@babel/helper-compilation-targets": "^7.22.9", + "@babel/code-frame": "^7.22.10", + "@babel/generator": "^7.22.10", + "@babel/helper-compilation-targets": "^7.22.10", "@babel/helper-module-transforms": "^7.22.9", - "@babel/helpers": "^7.22.6", - "@babel/parser": "^7.22.7", + "@babel/helpers": "^7.22.10", + "@babel/parser": "^7.22.10", "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.8", - "@babel/types": "^7.22.5", + "@babel/traverse": "^7.22.10", + "@babel/types": "^7.22.10", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -107,13 +190,15 @@ "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@babel/core/node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, + "peer": true, "dependencies": { "ms": "2.1.2" }, @@ -130,15 +215,17 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@babel/generator": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.9.tgz", - "integrity": "sha512-KtLMbmicyuK2Ak/FTCJVbDnkN1SlT8/kceFTiuDiiRUUSMnHMidxSCdG4ndkTOHHpoomWe/4xkvHkEOncwjYIw==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.10.tgz", + "integrity": "sha512-79KIf7YiWjjdZ81JnLujDRApWtl7BxTqWD88+FFdQEIOG8LJ0etDOM7CXuIgGJa55sGOwZVwuEsaLEm0PJ5/+A==", "dev": true, + "peer": true, "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.22.10", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -148,10 +235,11 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.9.tgz", - "integrity": "sha512-7qYrNM6HjpnPHJbopxmb8hSPoZ0gsX8IvUS32JGVoy+pU9e5N0nLr1VjJoR6kA4d9dmGLxNYOjeB8sUDal2WMw==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.10.tgz", + "integrity": "sha512-JMSwHD4J7SLod0idLq5PKgI+6g/hLD/iuWBq08ZX49xE14VpVEojJ5rHWptpirV2j020MvypRLAXAO50igCJ5Q==", "dev": true, + "peer": true, "dependencies": { "@babel/compat-data": "^7.22.9", "@babel/helper-validator-option": "^7.22.5", @@ -161,9 +249,6 @@ }, "engines": { "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-environment-visitor": { @@ -171,6 +256,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", "dev": true, + "peer": true, "engines": { "node": ">=6.9.0" } @@ -180,6 +266,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", "dev": true, + "peer": true, "dependencies": { "@babel/template": "^7.22.5", "@babel/types": "^7.22.5" @@ -193,6 +280,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, + "peer": true, "dependencies": { "@babel/types": "^7.22.5" }, @@ -205,6 +293,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", "dev": true, + "peer": true, "dependencies": { "@babel/types": "^7.22.5" }, @@ -217,6 +306,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.9.tgz", "integrity": "sha512-t+WA2Xn5K+rTeGtC8jCsdAH52bjggG5TKRuRrAGNM/mjIbO4GxvlLMFOEz9wXY5I2XQ60PMFsAG2WIcG82dQMQ==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-environment-visitor": "^7.22.5", "@babel/helper-module-imports": "^7.22.5", @@ -236,6 +326,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", "dev": true, + "peer": true, "engines": { "node": ">=6.9.0" } @@ -245,6 +336,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", "dev": true, + "peer": true, "dependencies": { "@babel/types": "^7.22.5" }, @@ -257,6 +349,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, + "peer": true, "dependencies": { "@babel/types": "^7.22.5" }, @@ -269,6 +362,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", "dev": true, + "peer": true, "engines": { "node": ">=6.9.0" } @@ -287,32 +381,34 @@ "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", "dev": true, + "peer": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.22.6", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.6.tgz", - "integrity": "sha512-YjDs6y/fVOYFV8hAf1rxd1QvR9wJe1pDBZ2AREKq/SDayfPzgk0PBnVuTCE5X1acEpMMNOVUqoe+OwiZGJ+OaA==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.10.tgz", + "integrity": "sha512-a41J4NW8HyZa1I1vAndrraTlPZ/eZoga2ZgS7fEr0tZJGVU4xqdE80CEm0CcNjha5EZ8fTBYLKHF0kqDUuAwQw==", "dev": true, + "peer": true, "dependencies": { "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.6", - "@babel/types": "^7.22.5" + "@babel/traverse": "^7.22.10", + "@babel/types": "^7.22.10" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", - "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.10.tgz", + "integrity": "sha512-78aUtVcT7MUscr0K5mIEnkwxPE0MaxkR5RxRwuHaQ+JuU5AmTPhY+do2mdzVTnIJJpyBglql2pehuBIWHug+WQ==", "dev": true, "dependencies": { "@babel/helper-validator-identifier": "^7.22.5", - "chalk": "^2.0.0", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -391,10 +487,11 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.7.tgz", - "integrity": "sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.10.tgz", + "integrity": "sha512-lNbdGsQb9ekfsnjFGhEiF4hfFqGgfOP3H3d27re3n+CGhNuTSUEQdfWk556sTLNTloczcdM5TYF2LhzmDQKyvQ==", "dev": true, + "peer": true, "bin": { "parser": "bin/babel-parser.js" }, @@ -407,6 +504,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -419,6 +517,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -431,6 +530,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.12.13" }, @@ -443,6 +543,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -455,6 +556,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -467,6 +569,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.22.5.tgz", "integrity": "sha512-gvyP4hZrgrs/wWMaocvxZ44Hw0b3W8Pe+cMxc8V1ULQ07oh8VNbIRaoD1LRZVTvD+0nieDKjfgKg89sD7rrKrg==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" }, @@ -482,6 +585,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -494,6 +598,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -506,6 +611,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -518,6 +624,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -530,6 +637,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -542,6 +650,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -554,6 +663,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.14.5" }, @@ -569,6 +679,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.22.5.tgz", "integrity": "sha512-1mS2o03i7t1c6VzH6fdQ3OA8tcEIxwG18zIPRp+UY1Ihv6W+XZzBCVxExF9upussPXJ0xE9XRHwMoNs1ep/nRQ==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" }, @@ -584,6 +695,7 @@ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", "dev": true, + "peer": true, "dependencies": { "@babel/code-frame": "^7.22.5", "@babel/parser": "^7.22.5", @@ -594,19 +706,20 @@ } }, "node_modules/@babel/traverse": { - "version": "7.22.8", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.8.tgz", - "integrity": "sha512-y6LPR+wpM2I3qJrsheCTwhIinzkETbplIgPBbwvqPKc+uljeA5gP+3nP8irdYt1mjQaDnlIcG+dw8OjAco4GXw==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.10.tgz", + "integrity": "sha512-Q/urqV4pRByiNNpb/f5OSv28ZlGJiFiiTh+GAHktbIrkPhPbl90+uW6SmpoLyZqutrg9AEaEf3Q/ZBRHBXgxig==", "dev": true, + "peer": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.7", + "@babel/code-frame": "^7.22.10", + "@babel/generator": "^7.22.10", "@babel/helper-environment-visitor": "^7.22.5", "@babel/helper-function-name": "^7.22.5", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.22.7", - "@babel/types": "^7.22.5", + "@babel/parser": "^7.22.10", + "@babel/types": "^7.22.10", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -619,6 +732,7 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, + "peer": true, "dependencies": { "ms": "2.1.2" }, @@ -635,13 +749,15 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@babel/types": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", - "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.10.tgz", + "integrity": "sha512-obaoigiLrlDZ7TUQln/8m4mSqIW2QFeOrCQc9r+xsaHGNoplVNYlRVpsfE8Vj35GEm2ZH4ZhrNYogs/3fj85kg==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-string-parser": "^7.22.5", "@babel/helper-validator-identifier": "^7.22.5", @@ -655,13 +771,37 @@ "version": "0.2.3", "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", "dev": true, + "peer": true, "dependencies": { "camelcase": "^5.3.1", "find-up": "^4.1.0", @@ -678,21 +818,23 @@ "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", "dev": true, + "peer": true, "engines": { "node": ">=8" } }, "node_modules/@jest/console": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.6.1.tgz", - "integrity": "sha512-Aj772AYgwTSr5w8qnyoJ0eDYvN6bMsH3ORH1ivMotrInHLKdUz6BDlaEXHdM6kODaBIkNIyQGzsMvRdOv7VG7Q==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.6.2.tgz", + "integrity": "sha512-0N0yZof5hi44HAR2pPS+ikJ3nzKNoZdVu8FffRf3wy47I7Dm7etk/3KetMdRUqzVd16V4O2m2ISpNTbnIuqy1w==", "dev": true, + "peer": true, "dependencies": { "@jest/types": "^29.6.1", "@types/node": "*", "chalk": "^4.0.0", - "jest-message-util": "^29.6.1", - "jest-util": "^29.6.1", + "jest-message-util": "^29.6.2", + "jest-util": "^29.6.2", "slash": "^3.0.0" }, "engines": { @@ -700,15 +842,16 @@ } }, "node_modules/@jest/core": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.6.1.tgz", - "integrity": "sha512-CcowHypRSm5oYQ1obz1wfvkjZZ2qoQlrKKvlfPwh5jUXVU12TWr2qMeH8chLMuTFzHh5a1g2yaqlqDICbr+ukQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.6.2.tgz", + "integrity": "sha512-Oj+5B+sDMiMWLhPFF+4/DvHOf+U10rgvCLGPHP8Xlsy/7QxS51aU/eBngudHlJXnaWD5EohAgJ4js+T6pa+zOg==", "dev": true, + "peer": true, "dependencies": { - "@jest/console": "^29.6.1", - "@jest/reporters": "^29.6.1", - "@jest/test-result": "^29.6.1", - "@jest/transform": "^29.6.1", + "@jest/console": "^29.6.2", + "@jest/reporters": "^29.6.2", + "@jest/test-result": "^29.6.2", + "@jest/transform": "^29.6.2", "@jest/types": "^29.6.1", "@types/node": "*", "ansi-escapes": "^4.2.1", @@ -717,20 +860,20 @@ "exit": "^0.1.2", "graceful-fs": "^4.2.9", "jest-changed-files": "^29.5.0", - "jest-config": "^29.6.1", - "jest-haste-map": "^29.6.1", - "jest-message-util": "^29.6.1", + "jest-config": "^29.6.2", + "jest-haste-map": "^29.6.2", + "jest-message-util": "^29.6.2", "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.6.1", - "jest-resolve-dependencies": "^29.6.1", - "jest-runner": "^29.6.1", - "jest-runtime": "^29.6.1", - "jest-snapshot": "^29.6.1", - "jest-util": "^29.6.1", - "jest-validate": "^29.6.1", - "jest-watcher": "^29.6.1", + "jest-resolve": "^29.6.2", + "jest-resolve-dependencies": "^29.6.2", + "jest-runner": "^29.6.2", + "jest-runtime": "^29.6.2", + "jest-snapshot": "^29.6.2", + "jest-util": "^29.6.2", + "jest-validate": "^29.6.2", + "jest-watcher": "^29.6.2", "micromatch": "^4.0.4", - "pretty-format": "^29.6.1", + "pretty-format": "^29.6.2", "slash": "^3.0.0", "strip-ansi": "^6.0.0" }, @@ -747,37 +890,39 @@ } }, "node_modules/@jest/environment": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.6.1.tgz", - "integrity": "sha512-RMMXx4ws+Gbvw3DfLSuo2cfQlK7IwGbpuEWXCqyYDcqYTI+9Ju3a5hDnXaxjNsa6uKh9PQF2v+qg+RLe63tz5A==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.6.2.tgz", + "integrity": "sha512-AEcW43C7huGd/vogTddNNTDRpO6vQ2zaQNrttvWV18ArBx9Z56h7BIsXkNFJVOO4/kblWEQz30ckw0+L3izc+Q==", "dev": true, + "peer": true, "dependencies": { - "@jest/fake-timers": "^29.6.1", + "@jest/fake-timers": "^29.6.2", "@jest/types": "^29.6.1", "@types/node": "*", - "jest-mock": "^29.6.1" + "jest-mock": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/expect": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.6.1.tgz", - "integrity": "sha512-N5xlPrAYaRNyFgVf2s9Uyyvr795jnB6rObuPx4QFvNJz8aAjpZUDfO4bh5G/xuplMID8PrnuF1+SfSyDxhsgYg==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.6.2.tgz", + "integrity": "sha512-m6DrEJxVKjkELTVAztTLyS/7C92Y2b0VYqmDROYKLLALHn8T/04yPs70NADUYPrV3ruI+H3J0iUIuhkjp7vkfg==", "dev": true, + "peer": true, "dependencies": { - "expect": "^29.6.1", - "jest-snapshot": "^29.6.1" + "expect": "^29.6.2", + "jest-snapshot": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/expect-utils": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.6.1.tgz", - "integrity": "sha512-o319vIf5pEMx0LmzSxxkYYxo4wrRLKHq9dP1yJU7FoPTB0LfAKSz8SWD6D/6U3v/O52t9cF5t+MeJiRsfk7zMw==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.6.2.tgz", + "integrity": "sha512-6zIhM8go3RV2IG4aIZaZbxwpOzz3ZiM23oxAlkquOIole+G6TrbeXnykxWYlqF7kz2HlBjdKtca20x9atkEQYg==", "dev": true, "dependencies": { "jest-get-type": "^29.4.3" @@ -787,47 +932,50 @@ } }, "node_modules/@jest/fake-timers": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.6.1.tgz", - "integrity": "sha512-RdgHgbXyosCDMVYmj7lLpUwXA4c69vcNzhrt69dJJdf8azUrpRh3ckFCaTPNjsEeRi27Cig0oKDGxy5j7hOgHg==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.6.2.tgz", + "integrity": "sha512-euZDmIlWjm1Z0lJ1D0f7a0/y5Kh/koLFMUBE5SUYWrmy8oNhJpbTBDAP6CxKnadcMLDoDf4waRYCe35cH6G6PA==", "dev": true, + "peer": true, "dependencies": { "@jest/types": "^29.6.1", "@sinonjs/fake-timers": "^10.0.2", "@types/node": "*", - "jest-message-util": "^29.6.1", - "jest-mock": "^29.6.1", - "jest-util": "^29.6.1" + "jest-message-util": "^29.6.2", + "jest-mock": "^29.6.2", + "jest-util": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/globals": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.6.1.tgz", - "integrity": "sha512-2VjpaGy78JY9n9370H8zGRCFbYVWwjY6RdDMhoJHa1sYfwe6XM/azGN0SjY8kk7BOZApIejQ1BFPyH7FPG0w3A==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.6.2.tgz", + "integrity": "sha512-cjuJmNDjs6aMijCmSa1g2TNG4Lby/AeU7/02VtpW+SLcZXzOLK2GpN2nLqcFjmhy3B3AoPeQVx7BnyOf681bAw==", "dev": true, + "peer": true, "dependencies": { - "@jest/environment": "^29.6.1", - "@jest/expect": "^29.6.1", + "@jest/environment": "^29.6.2", + "@jest/expect": "^29.6.2", "@jest/types": "^29.6.1", - "jest-mock": "^29.6.1" + "jest-mock": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/reporters": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.6.1.tgz", - "integrity": "sha512-9zuaI9QKr9JnoZtFQlw4GREQbxgmNYXU6QuWtmuODvk5nvPUeBYapVR/VYMyi2WSx3jXTLJTJji8rN6+Cm4+FA==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.6.2.tgz", + "integrity": "sha512-sWtijrvIav8LgfJZlrGCdN0nP2EWbakglJY49J1Y5QihcQLfy7ovyxxjJBRXMNltgt4uPtEcFmIMbVshEDfFWw==", "dev": true, + "peer": true, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", - "@jest/console": "^29.6.1", - "@jest/test-result": "^29.6.1", - "@jest/transform": "^29.6.1", + "@jest/console": "^29.6.2", + "@jest/test-result": "^29.6.2", + "@jest/transform": "^29.6.2", "@jest/types": "^29.6.1", "@jridgewell/trace-mapping": "^0.3.18", "@types/node": "*", @@ -841,9 +989,9 @@ "istanbul-lib-report": "^3.0.0", "istanbul-lib-source-maps": "^4.0.0", "istanbul-reports": "^3.1.3", - "jest-message-util": "^29.6.1", - "jest-util": "^29.6.1", - "jest-worker": "^29.6.1", + "jest-message-util": "^29.6.2", + "jest-util": "^29.6.2", + "jest-worker": "^29.6.2", "slash": "^3.0.0", "string-length": "^4.0.1", "strip-ansi": "^6.0.0", @@ -878,6 +1026,7 @@ "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.0.tgz", "integrity": "sha512-oA+I2SHHQGxDCZpbrsCQSoMLb3Bz547JnM+jUr9qEbuw0vQlWZfpPS7CO9J7XiwKicEz9OFn/IYoLkkiUD7bzA==", "dev": true, + "peer": true, "dependencies": { "@jridgewell/trace-mapping": "^0.3.18", "callsites": "^3.0.0", @@ -888,12 +1037,13 @@ } }, "node_modules/@jest/test-result": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.6.1.tgz", - "integrity": "sha512-Ynr13ZRcpX6INak0TPUukU8GWRfm/vAytE3JbJNGAvINySWYdfE7dGZMbk36oVuK4CigpbhMn8eg1dixZ7ZJOw==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.6.2.tgz", + "integrity": "sha512-3VKFXzcV42EYhMCsJQURptSqnyjqCGbtLuX5Xxb6Pm6gUf1wIRIl+mandIRGJyWKgNKYF9cnstti6Ls5ekduqw==", "dev": true, + "peer": true, "dependencies": { - "@jest/console": "^29.6.1", + "@jest/console": "^29.6.2", "@jest/types": "^29.6.1", "@types/istanbul-lib-coverage": "^2.0.0", "collect-v8-coverage": "^1.0.0" @@ -903,14 +1053,15 @@ } }, "node_modules/@jest/test-sequencer": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.6.1.tgz", - "integrity": "sha512-oBkC36PCDf/wb6dWeQIhaviU0l5u6VCsXa119yqdUosYAt7/FbQU2M2UoziO3igj/HBDEgp57ONQ3fm0v9uyyg==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.6.2.tgz", + "integrity": "sha512-GVYi6PfPwVejO7slw6IDO0qKVum5jtrJ3KoLGbgBWyr2qr4GaxFV6su+ZAjdTX75Sr1DkMFRk09r2ZVa+wtCGw==", "dev": true, + "peer": true, "dependencies": { - "@jest/test-result": "^29.6.1", + "@jest/test-result": "^29.6.2", "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.6.1", + "jest-haste-map": "^29.6.2", "slash": "^3.0.0" }, "engines": { @@ -918,10 +1069,11 @@ } }, "node_modules/@jest/transform": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.6.1.tgz", - "integrity": "sha512-URnTneIU3ZjRSaf906cvf6Hpox3hIeJXRnz3VDSw5/X93gR8ycdfSIEy19FlVx8NFmpN7fe3Gb1xF+NjXaQLWg==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.6.2.tgz", + "integrity": "sha512-ZqCqEISr58Ce3U+buNFJYUktLJZOggfyvR+bZMaiV1e8B1SIvJbwZMrYz3gx/KAPn9EXmOmN+uB08yLCjWkQQg==", "dev": true, + "peer": true, "dependencies": { "@babel/core": "^7.11.6", "@jest/types": "^29.6.1", @@ -931,9 +1083,9 @@ "convert-source-map": "^2.0.0", "fast-json-stable-stringify": "^2.1.0", "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.6.1", + "jest-haste-map": "^29.6.2", "jest-regex-util": "^29.4.3", - "jest-util": "^29.6.1", + "jest-util": "^29.6.2", "micromatch": "^4.0.4", "pirates": "^4.0.4", "slash": "^3.0.0", @@ -965,6 +1117,7 @@ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", "dev": true, + "peer": true, "dependencies": { "@jridgewell/set-array": "^1.0.1", "@jridgewell/sourcemap-codec": "^1.4.10", @@ -975,9 +1128,9 @@ } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", "dev": true, "engines": { "node": ">=6.0.0" @@ -988,6 +1141,7 @@ "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", "dev": true, + "peer": true, "engines": { "node": ">=6.0.0" } @@ -999,21 +1153,16 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.18", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", - "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", + "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", "dev": true, + "peer": true, "dependencies": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true - }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -1025,6 +1174,7 @@ "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", "dev": true, + "peer": true, "dependencies": { "type-detect": "4.0.8" } @@ -1034,15 +1184,41 @@ "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", "dev": true, + "peer": true, "dependencies": { "@sinonjs/commons": "^3.0.0" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@types/babel__core": { "version": "7.20.1", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.1.tgz", "integrity": "sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==", "dev": true, + "peer": true, "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -1056,6 +1232,7 @@ "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", "dev": true, + "peer": true, "dependencies": { "@babel/types": "^7.0.0" } @@ -1065,6 +1242,7 @@ "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", "dev": true, + "peer": true, "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" @@ -1075,19 +1253,88 @@ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.1.tgz", "integrity": "sha512-MitHFXnhtgwsGZWtT68URpOvLN4EREih1u3QtQiN4VdAxWKRVvGCSvw/Qth0M0Qq3pJpnGOu5JaM/ydK7OGbqg==", "dev": true, + "peer": true, "dependencies": { "@babel/types": "^7.20.7" } }, + "node_modules/@types/body-parser": { + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", + "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", + "dev": true, + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.35", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", + "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/cors": { + "version": "2.8.13", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz", + "integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/express": { + "version": "4.17.17", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", + "integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==", + "dev": true, + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.17.35", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.35.tgz", + "integrity": "sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==", + "dev": true, + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "node_modules/@types/express-session": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/@types/express-session/-/express-session-1.17.7.tgz", + "integrity": "sha512-L25080PBYoRLu472HY/HNCxaXY8AaGgqGC8/p/8+BYMhG0RDOLQ1wpXOpAzr4Gi5TGozTKyJv5BVODM5UNyVMw==", + "dev": true, + "dependencies": { + "@types/express": "*" + } + }, "node_modules/@types/graceful-fs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", "integrity": "sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==", "dev": true, + "peer": true, "dependencies": { "@types/node": "*" } }, + "node_modules/@types/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-/K3ds8TRAfBvi5vfjuz8y6+GiAYBZ0x4tXv1Av6CWBWn0IlADc+ZX9pMq7oU0fNQPnBwIZl3rmeLp6SBApbxSQ==", + "dev": true + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", @@ -1112,10 +1359,26 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jest": { + "version": "29.5.3", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.3.tgz", + "integrity": "sha512-1Nq7YrO/vJE/FYnqYyw0FS8LdrjExSgIiHyKg7xPpn+yi8Q4huZryKnkJatN1ZRH89Kw2v33/8ZMB7DuZeSLlA==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/mime": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", + "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==", + "dev": true + }, "node_modules/@types/node": { - "version": "20.4.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.4.tgz", - "integrity": "sha512-CukZhumInROvLq3+b5gLev+vgpsIqC2D0deQr/yS1WnxvmYLlJXZpaQrQiseMY+6xusl79E04UjWoqyr+t1/Ew==" + "version": "20.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz", + "integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==" }, "node_modules/@types/node-fetch": { "version": "2.6.4", @@ -1126,10 +1389,29 @@ "form-data": "^3.0.0" } }, - "node_modules/@types/prettier": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", - "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", + "node_modules/@types/node-fetch/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==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/@types/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==", + "dev": true + }, + "node_modules/@types/range-parser": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", + "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", "dev": true }, "node_modules/@types/retry": { @@ -1137,6 +1419,27 @@ "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" }, + "node_modules/@types/send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.1.tgz", + "integrity": "sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==", + "dev": true, + "dependencies": { + "@types/mime": "^1", + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.2.tgz", + "integrity": "sha512-J2LqtvFYCzaj8pVYKw8klQXrLLk7TBZmQ4ShlcdkELFKGwGMfevMLneMMRkMgZxotOD9wg497LpC7O8PcvAmfw==", + "dev": true, + "dependencies": { + "@types/http-errors": "*", + "@types/mime": "*", + "@types/node": "*" + } + }, "node_modules/@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", @@ -1163,6 +1466,12 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -1186,45 +1495,44 @@ "node": ">= 0.6" } }, - "node_modules/agentkeepalive": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.3.0.tgz", - "integrity": "sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==", - "dependencies": { - "debug": "^4.1.0", - "depd": "^2.0.0", - "humanize-ms": "^1.2.1" + "node_modules/acorn": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "dev": true, + "bin": { + "acorn": "bin/acorn" }, "engines": { - "node": ">= 8.0.0" + "node": ">=0.4.0" } }, - "node_modules/agentkeepalive/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", "dependencies": { - "ms": "2.1.2" + "humanize-ms": "^1.2.1" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">= 8.0.0" } }, - "node_modules/agentkeepalive/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", "dev": true, + "peer": true, "dependencies": { "type-fest": "^0.21.3" }, @@ -1240,6 +1548,7 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -1272,11 +1581,18 @@ "node": ">= 8" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, + "peer": true, "dependencies": { "sprintf-js": "~1.0.2" } @@ -1292,20 +1608,25 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "0.26.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", - "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "optional": true, + "peer": true, "dependencies": { - "follow-redirects": "^1.14.8" + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" } }, "node_modules/babel-jest": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.6.1.tgz", - "integrity": "sha512-qu+3bdPEQC6KZSPz+4Fyjbga5OODNcp49j6GKzG1EKbkfyJBxEYGVUmVGpwCSeGouG52R4EgYMLb6p9YeEEQ4A==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.6.2.tgz", + "integrity": "sha512-BYCzImLos6J3BH/+HvUCHG1dTf2MzmAB4jaVxHV+29RZLjR29XuYTmsf2sdDwkrb+FczkGo3kOhE7ga6sI0P4A==", "dev": true, + "peer": true, "dependencies": { - "@jest/transform": "^29.6.1", + "@jest/transform": "^29.6.2", "@types/babel__core": "^7.1.14", "babel-plugin-istanbul": "^6.1.1", "babel-preset-jest": "^29.5.0", @@ -1325,6 +1646,7 @@ "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", "@istanbuljs/load-nyc-config": "^1.0.0", @@ -1341,6 +1663,7 @@ "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.5.0.tgz", "integrity": "sha512-zSuuuAlTMT4mzLj2nPnUm6fsE6270vdOfnpbJ+RmruU75UhLFvL0N2NgI7xpeS7NaB6hGqmd5pVpGTDYvi4Q3w==", "dev": true, + "peer": true, "dependencies": { "@babel/template": "^7.3.3", "@babel/types": "^7.3.3", @@ -1356,6 +1679,7 @@ "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", "dev": true, + "peer": true, "dependencies": { "@babel/plugin-syntax-async-generators": "^7.8.4", "@babel/plugin-syntax-bigint": "^7.8.3", @@ -1379,6 +1703,7 @@ "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.5.0.tgz", "integrity": "sha512-JOMloxOqdiBSxMAzjRaH023/vvcaSaec49zvg+2LmNsktC7ei39LTJGw02J+9uUtTZUq6xbLyJ4dxe9sSmIuAg==", "dev": true, + "peer": true, "dependencies": { "babel-plugin-jest-hoist": "^29.5.0", "babel-preset-current-node-syntax": "^1.0.0" @@ -1479,9 +1804,9 @@ } }, "node_modules/browserslist": { - "version": "4.21.9", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", - "integrity": "sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg==", + "version": "4.21.10", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.10.tgz", + "integrity": "sha512-bipEBdZfVH5/pwrvqc+Ub0kUPVfGUhlKxbvfD+z1BDnPEO/X98ruXGA1WP5ASpAFKan7Qr6j736IacbZQuAlKQ==", "dev": true, "funding": [ { @@ -1497,10 +1822,11 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { - "caniuse-lite": "^1.0.30001503", - "electron-to-chromium": "^1.4.431", - "node-releases": "^2.0.12", + "caniuse-lite": "^1.0.30001517", + "electron-to-chromium": "^1.4.477", + "node-releases": "^2.0.13", "update-browserslist-db": "^1.0.11" }, "bin": { @@ -1510,11 +1836,24 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/bser": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", "dev": true, + "peer": true, "dependencies": { "node-int64": "^0.4.0" } @@ -1523,7 +1862,8 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/bytes": { "version": "3.1.2", @@ -1550,6 +1890,7 @@ "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, + "peer": true, "engines": { "node": ">=6" } @@ -1559,14 +1900,15 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true, + "peer": true, "engines": { "node": ">=6" } }, "node_modules/caniuse-lite": { - "version": "1.0.30001517", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001517.tgz", - "integrity": "sha512-Vdhm5S11DaFVLlyiKu4hiUTkpZu+y1KA/rZZqVQfOD5YdDT/eQKlkt7NaE0WGOFgX32diqt9MiP9CAiFeRklaA==", + "version": "1.0.30001521", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001521.tgz", + "integrity": "sha512-fnx1grfpEOvDGH+V17eccmNjucGUnCbP6KL+l5KqBIerp26WK/+RQ7CIDE37KGJjaPyqWXXlFUyKiWmvdNNKmQ==", "dev": true, "funding": [ { @@ -1581,7 +1923,8 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ] + ], + "peer": true }, "node_modules/chalk": { "version": "4.1.2", @@ -1604,6 +1947,7 @@ "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", "dev": true, + "peer": true, "engines": { "node": ">=10" } @@ -1616,6 +1960,33 @@ "node": "*" } }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/ci-info": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", @@ -1635,13 +2006,15 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dev": true, + "peer": true, "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", @@ -1656,6 +2029,7 @@ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", "dev": true, + "peer": true, "engines": { "iojs": ">= 1.0.0", "node": ">= 0.12.0" @@ -1665,7 +2039,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", - "dev": true + "dev": true, + "peer": true }, "node_modules/color-convert": { "version": "2.0.1", @@ -1697,12 +2072,9 @@ } }, "node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "engines": { - "node": ">=14" - } + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, "node_modules/concat-map": { "version": "0.0.1", @@ -1733,7 +2105,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true + "dev": true, + "peer": true }, "node_modules/cookie": { "version": "0.5.0", @@ -1760,11 +2133,18 @@ "node": ">= 0.10" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, + "peer": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -1803,11 +2183,6 @@ "tsv2json": "bin/dsv2json" } }, - "node_modules/d3-dsv/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" - }, "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -1825,16 +2200,26 @@ } }, "node_modules/dedent": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", - "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", - "dev": true + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", + "integrity": "sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==", + "dev": true, + "peer": true, + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } }, "node_modules/deepmerge": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -1869,10 +2254,20 @@ "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "dev": true, + "peer": true, "engines": { "node": ">=8" } }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", @@ -1908,16 +2303,18 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.470", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.470.tgz", - "integrity": "sha512-zZM48Lmy2FKWgqyvsX9XK+J6FfP7aCDUFLmgooLJzA7v1agCs/sxSoBpTIwDLhmbhpx9yJIxj2INig/ncjJRqg==", - "dev": true + "version": "1.4.495", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.495.tgz", + "integrity": "sha512-mwknuemBZnoOCths4GtpU/SDuVMp3uQHKa2UNJT9/aVD6WVRjGpXOxRGX7lm6ILIenTdGXPSTCTDaWos5tEU8Q==", + "dev": true, + "peer": true }, "node_modules/emittery": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", "dev": true, + "peer": true, "engines": { "node": ">=12" }, @@ -1929,7 +2326,8 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "peer": true }, "node_modules/encodeurl": { "version": "1.0.2", @@ -1944,6 +2342,7 @@ "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "dev": true, + "peer": true, "dependencies": { "is-arrayish": "^0.2.1" } @@ -1953,6 +2352,7 @@ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", "dev": true, + "peer": true, "engines": { "node": ">=6" } @@ -1976,6 +2376,7 @@ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true, + "peer": true, "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -2010,6 +2411,7 @@ "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", "dev": true, + "peer": true, "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.0", @@ -2033,22 +2435,23 @@ "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", "dev": true, + "peer": true, "engines": { "node": ">= 0.8.0" } }, "node_modules/expect": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/expect/-/expect-29.6.1.tgz", - "integrity": "sha512-XEdDLonERCU1n9uR56/Stx9OqojaLAQtZf9PrCHH9Hl8YXiEIka3H4NXJ3NOIBmQJTg7+j7buh34PMHfJujc8g==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.6.2.tgz", + "integrity": "sha512-iAErsLxJ8C+S02QbLAwgSGSezLQK+XXRDt8IuFXFpwCNw2ECmzZSmjKcCaFVp5VRMk+WAvz6h6jokzEzBFZEuA==", "dev": true, "dependencies": { - "@jest/expect-utils": "^29.6.1", + "@jest/expect-utils": "^29.6.2", "@types/node": "*", "jest-get-type": "^29.4.3", - "jest-matcher-utils": "^29.6.1", - "jest-message-util": "^29.6.1", - "jest-util": "^29.6.1" + "jest-matcher-utils": "^29.6.2", + "jest-message-util": "^29.6.2", + "jest-util": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -2137,6 +2540,7 @@ "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", "dev": true, + "peer": true, "dependencies": { "bser": "2.1.1" } @@ -2175,6 +2579,7 @@ "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, + "peer": true, "dependencies": { "locate-path": "^5.0.0", "path-exists": "^4.0.0" @@ -2211,9 +2616,9 @@ } }, "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==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -2260,7 +2665,22 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } }, "node_modules/function-bind": { "version": "1.1.1", @@ -2272,6 +2692,7 @@ "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", "dev": true, + "peer": true, "engines": { "node": ">=6.9.0" } @@ -2281,6 +2702,7 @@ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true, + "peer": true, "engines": { "node": "6.* || 8.* || >= 10.*" } @@ -2304,6 +2726,7 @@ "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", "dev": true, + "peer": true, "engines": { "node": ">=8.0.0" } @@ -2313,6 +2736,7 @@ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", "dev": true, + "peer": true, "engines": { "node": ">=10" }, @@ -2325,6 +2749,7 @@ "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, + "peer": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -2340,11 +2765,24 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true, + "peer": true, "engines": { "node": ">=4" } @@ -2401,7 +2839,8 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true + "dev": true, + "peer": true }, "node_modules/http-errors": { "version": "2.0.0", @@ -2423,6 +2862,7 @@ "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true, + "peer": true, "engines": { "node": ">=10.17.0" } @@ -2446,11 +2886,18 @@ "node": ">=0.10.0" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "node_modules/import-local": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", "dev": true, + "peer": true, "dependencies": { "pkg-dir": "^4.2.0", "resolve-cwd": "^3.0.0" @@ -2470,6 +2917,7 @@ "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, + "peer": true, "engines": { "node": ">=0.8.19" } @@ -2479,6 +2927,7 @@ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, + "peer": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -2506,7 +2955,20 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } }, "node_modules/is-buffer": { "version": "1.1.6", @@ -2514,10 +2976,11 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" }, "node_modules/is-core-module": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", - "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", + "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", "dev": true, + "peer": true, "dependencies": { "has": "^1.0.3" }, @@ -2525,11 +2988,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -2539,10 +3012,23 @@ "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", "dev": true, + "peer": true, "engines": { "node": ">=6" } }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -2557,6 +3043,7 @@ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", "dev": true, + "peer": true, "engines": { "node": ">=8" }, @@ -2568,13 +3055,15 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/istanbul-lib-coverage": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -2584,6 +3073,7 @@ "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", "dev": true, + "peer": true, "dependencies": { "@babel/core": "^7.12.3", "@babel/parser": "^7.14.7", @@ -2596,17 +3086,18 @@ } }, "node_modules/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", "dev": true, + "peer": true, "dependencies": { "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", + "make-dir": "^4.0.0", "supports-color": "^7.1.0" }, "engines": { - "node": ">=8" + "node": ">=10" } }, "node_modules/istanbul-lib-source-maps": { @@ -2614,6 +3105,7 @@ "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", "dev": true, + "peer": true, "dependencies": { "debug": "^4.1.1", "istanbul-lib-coverage": "^3.0.0", @@ -2628,6 +3120,7 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, + "peer": true, "dependencies": { "ms": "2.1.2" }, @@ -2644,13 +3137,15 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "dev": true, + "peer": true }, "node_modules/istanbul-reports": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", - "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.6.tgz", + "integrity": "sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==", "dev": true, + "peer": true, "dependencies": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" @@ -2660,15 +3155,16 @@ } }, "node_modules/jest": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest/-/jest-29.6.1.tgz", - "integrity": "sha512-Nirw5B4nn69rVUZtemCQhwxOBhm0nsp3hmtF4rzCeWD7BkjAXRIji7xWQfnTNbz9g0aVsBX6aZK3n+23LM6uDw==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.6.2.tgz", + "integrity": "sha512-8eQg2mqFbaP7CwfsTpCxQ+sHzw1WuNWL5UUvjnWP4hx2riGz9fPSzYOaU5q8/GqWn1TfgZIVTqYJygbGbWAANg==", "dev": true, + "peer": true, "dependencies": { - "@jest/core": "^29.6.1", + "@jest/core": "^29.6.2", "@jest/types": "^29.6.1", "import-local": "^3.0.2", - "jest-cli": "^29.6.1" + "jest-cli": "^29.6.2" }, "bin": { "jest": "bin/jest.js" @@ -2690,6 +3186,7 @@ "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.5.0.tgz", "integrity": "sha512-IFG34IUMUaNBIxjQXF/iu7g6EcdMrGRRxaUSw92I/2g2YC6vCdTltl4nHvt7Ci5nSJwXIkCu8Ka1DKF+X7Z1Ag==", "dev": true, + "peer": true, "dependencies": { "execa": "^5.0.0", "p-limit": "^3.1.0" @@ -2699,28 +3196,29 @@ } }, "node_modules/jest-circus": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.6.1.tgz", - "integrity": "sha512-tPbYLEiBU4MYAL2XoZme/bgfUeotpDBd81lgHLCbDZZFaGmECk0b+/xejPFtmiBP87GgP/y4jplcRpbH+fgCzQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.6.2.tgz", + "integrity": "sha512-G9mN+KOYIUe2sB9kpJkO9Bk18J4dTDArNFPwoZ7WKHKel55eKIS/u2bLthxgojwlf9NLCVQfgzM/WsOVvoC6Fw==", "dev": true, + "peer": true, "dependencies": { - "@jest/environment": "^29.6.1", - "@jest/expect": "^29.6.1", - "@jest/test-result": "^29.6.1", + "@jest/environment": "^29.6.2", + "@jest/expect": "^29.6.2", + "@jest/test-result": "^29.6.2", "@jest/types": "^29.6.1", "@types/node": "*", "chalk": "^4.0.0", "co": "^4.6.0", - "dedent": "^0.7.0", + "dedent": "^1.0.0", "is-generator-fn": "^2.0.0", - "jest-each": "^29.6.1", - "jest-matcher-utils": "^29.6.1", - "jest-message-util": "^29.6.1", - "jest-runtime": "^29.6.1", - "jest-snapshot": "^29.6.1", - "jest-util": "^29.6.1", + "jest-each": "^29.6.2", + "jest-matcher-utils": "^29.6.2", + "jest-message-util": "^29.6.2", + "jest-runtime": "^29.6.2", + "jest-snapshot": "^29.6.2", + "jest-util": "^29.6.2", "p-limit": "^3.1.0", - "pretty-format": "^29.6.1", + "pretty-format": "^29.6.2", "pure-rand": "^6.0.0", "slash": "^3.0.0", "stack-utils": "^2.0.3" @@ -2730,21 +3228,22 @@ } }, "node_modules/jest-cli": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.6.1.tgz", - "integrity": "sha512-607dSgTA4ODIN6go9w6xY3EYkyPFGicx51a69H7yfvt7lN53xNswEVLovq+E77VsTRi5fWprLH0yl4DJgE8Ing==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.6.2.tgz", + "integrity": "sha512-TT6O247v6dCEX2UGHGyflMpxhnrL0DNqP2fRTKYm3nJJpCTfXX3GCMQPGFjXDoj0i5/Blp3jriKXFgdfmbYB6Q==", "dev": true, + "peer": true, "dependencies": { - "@jest/core": "^29.6.1", - "@jest/test-result": "^29.6.1", + "@jest/core": "^29.6.2", + "@jest/test-result": "^29.6.2", "@jest/types": "^29.6.1", "chalk": "^4.0.0", "exit": "^0.1.2", "graceful-fs": "^4.2.9", "import-local": "^3.0.2", - "jest-config": "^29.6.1", - "jest-util": "^29.6.1", - "jest-validate": "^29.6.1", + "jest-config": "^29.6.2", + "jest-util": "^29.6.2", + "jest-validate": "^29.6.2", "prompts": "^2.0.1", "yargs": "^17.3.1" }, @@ -2764,31 +3263,32 @@ } }, "node_modules/jest-config": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.6.1.tgz", - "integrity": "sha512-XdjYV2fy2xYixUiV2Wc54t3Z4oxYPAELUzWnV6+mcbq0rh742X2p52pii5A3oeRzYjLnQxCsZmp0qpI6klE2cQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.6.2.tgz", + "integrity": "sha512-VxwFOC8gkiJbuodG9CPtMRjBUNZEHxwfQXmIudSTzFWxaci3Qub1ddTRbFNQlD/zUeaifLndh/eDccFX4wCMQw==", "dev": true, + "peer": true, "dependencies": { "@babel/core": "^7.11.6", - "@jest/test-sequencer": "^29.6.1", + "@jest/test-sequencer": "^29.6.2", "@jest/types": "^29.6.1", - "babel-jest": "^29.6.1", + "babel-jest": "^29.6.2", "chalk": "^4.0.0", "ci-info": "^3.2.0", "deepmerge": "^4.2.2", "glob": "^7.1.3", "graceful-fs": "^4.2.9", - "jest-circus": "^29.6.1", - "jest-environment-node": "^29.6.1", + "jest-circus": "^29.6.2", + "jest-environment-node": "^29.6.2", "jest-get-type": "^29.4.3", "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.6.1", - "jest-runner": "^29.6.1", - "jest-util": "^29.6.1", - "jest-validate": "^29.6.1", + "jest-resolve": "^29.6.2", + "jest-runner": "^29.6.2", + "jest-util": "^29.6.2", + "jest-validate": "^29.6.2", "micromatch": "^4.0.4", "parse-json": "^5.2.0", - "pretty-format": "^29.6.1", + "pretty-format": "^29.6.2", "slash": "^3.0.0", "strip-json-comments": "^3.1.1" }, @@ -2809,15 +3309,15 @@ } }, "node_modules/jest-diff": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.6.1.tgz", - "integrity": "sha512-FsNCvinvl8oVxpNLttNQX7FAq7vR+gMDGj90tiP7siWw1UdakWUGqrylpsYrpvj908IYckm5Y0Q7azNAozU1Kg==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.6.2.tgz", + "integrity": "sha512-t+ST7CB9GX5F2xKwhwCf0TAR17uNDiaPTZnVymP9lw0lssa9vG+AFyDZoeIHStU3WowFFwT+ky+er0WVl2yGhA==", "dev": true, "dependencies": { "chalk": "^4.0.0", "diff-sequences": "^29.4.3", "jest-get-type": "^29.4.3", - "pretty-format": "^29.6.1" + "pretty-format": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -2828,6 +3328,7 @@ "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.4.3.tgz", "integrity": "sha512-fzdTftThczeSD9nZ3fzA/4KkHtnmllawWrXO69vtI+L9WjEIuXWs4AmyME7lN5hU7dB0sHhuPfcKofRsUb/2Fg==", "dev": true, + "peer": true, "dependencies": { "detect-newline": "^3.0.0" }, @@ -2836,33 +3337,35 @@ } }, "node_modules/jest-each": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.6.1.tgz", - "integrity": "sha512-n5eoj5eiTHpKQCAVcNTT7DRqeUmJ01hsAL0Q1SMiBHcBcvTKDELixQOGMCpqhbIuTcfC4kMfSnpmDqRgRJcLNQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.6.2.tgz", + "integrity": "sha512-MsrsqA0Ia99cIpABBc3izS1ZYoYfhIy0NNWqPSE0YXbQjwchyt6B1HD2khzyPe1WiJA7hbxXy77ZoUQxn8UlSw==", "dev": true, + "peer": true, "dependencies": { "@jest/types": "^29.6.1", "chalk": "^4.0.0", "jest-get-type": "^29.4.3", - "jest-util": "^29.6.1", - "pretty-format": "^29.6.1" + "jest-util": "^29.6.2", + "pretty-format": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-environment-node": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.6.1.tgz", - "integrity": "sha512-ZNIfAiE+foBog24W+2caIldl4Irh8Lx1PUhg/GZ0odM1d/h2qORAsejiFc7zb+SEmYPn1yDZzEDSU5PmDkmVLQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.6.2.tgz", + "integrity": "sha512-YGdFeZ3T9a+/612c5mTQIllvWkddPbYcN2v95ZH24oWMbGA4GGS2XdIF92QMhUhvrjjuQWYgUGW2zawOyH63MQ==", "dev": true, + "peer": true, "dependencies": { - "@jest/environment": "^29.6.1", - "@jest/fake-timers": "^29.6.1", + "@jest/environment": "^29.6.2", + "@jest/fake-timers": "^29.6.2", "@jest/types": "^29.6.1", "@types/node": "*", - "jest-mock": "^29.6.1", - "jest-util": "^29.6.1" + "jest-mock": "^29.6.2", + "jest-util": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -2878,10 +3381,11 @@ } }, "node_modules/jest-haste-map": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.6.1.tgz", - "integrity": "sha512-0m7f9PZXxOCk1gRACiVgX85knUKPKLPg4oRCjLoqIm9brTHXaorMA0JpmtmVkQiT8nmXyIVoZd/nnH1cfC33ig==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.6.2.tgz", + "integrity": "sha512-+51XleTDAAysvU8rT6AnS1ZJ+WHVNqhj1k6nTvN2PYP+HjU3kqlaKQ1Lnw3NYW3bm2r8vq82X0Z1nDDHZMzHVA==", "dev": true, + "peer": true, "dependencies": { "@jest/types": "^29.6.1", "@types/graceful-fs": "^4.1.3", @@ -2890,8 +3394,8 @@ "fb-watchman": "^2.0.0", "graceful-fs": "^4.2.9", "jest-regex-util": "^29.4.3", - "jest-util": "^29.6.1", - "jest-worker": "^29.6.1", + "jest-util": "^29.6.2", + "jest-worker": "^29.6.2", "micromatch": "^4.0.4", "walker": "^1.0.8" }, @@ -2903,37 +3407,38 @@ } }, "node_modules/jest-leak-detector": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.6.1.tgz", - "integrity": "sha512-OrxMNyZirpOEwkF3UHnIkAiZbtkBWiye+hhBweCHkVbCgyEy71Mwbb5zgeTNYWJBi1qgDVfPC1IwO9dVEeTLwQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.6.2.tgz", + "integrity": "sha512-aNqYhfp5uYEO3tdWMb2bfWv6f0b4I0LOxVRpnRLAeque2uqOVVMLh6khnTcE2qJ5wAKop0HcreM1btoysD6bPQ==", "dev": true, + "peer": true, "dependencies": { "jest-get-type": "^29.4.3", - "pretty-format": "^29.6.1" + "pretty-format": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-matcher-utils": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.6.1.tgz", - "integrity": "sha512-SLaztw9d2mfQQKHmJXKM0HCbl2PPVld/t9Xa6P9sgiExijviSp7TnZZpw2Fpt+OI3nwUO/slJbOfzfUMKKC5QA==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.6.2.tgz", + "integrity": "sha512-4LiAk3hSSobtomeIAzFTe+N8kL6z0JtF3n6I4fg29iIW7tt99R7ZcIFW34QkX+DuVrf+CUe6wuVOpm7ZKFJzZQ==", "dev": true, "dependencies": { "chalk": "^4.0.0", - "jest-diff": "^29.6.1", + "jest-diff": "^29.6.2", "jest-get-type": "^29.4.3", - "pretty-format": "^29.6.1" + "pretty-format": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-message-util": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.6.1.tgz", - "integrity": "sha512-KoAW2zAmNSd3Gk88uJ56qXUWbFk787QKmjjJVOjtGFmmGSZgDBrlIL4AfQw1xyMYPNVD7dNInfIbur9B2rd/wQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.6.2.tgz", + "integrity": "sha512-vnIGYEjoPSuRqV8W9t+Wow95SDp6KPX2Uf7EoeG9G99J2OVh7OSwpS4B6J0NfpEIpfkBNHlBZpA2rblEuEFhZQ==", "dev": true, "dependencies": { "@babel/code-frame": "^7.12.13", @@ -2942,7 +3447,7 @@ "chalk": "^4.0.0", "graceful-fs": "^4.2.9", "micromatch": "^4.0.4", - "pretty-format": "^29.6.1", + "pretty-format": "^29.6.2", "slash": "^3.0.0", "stack-utils": "^2.0.3" }, @@ -2951,14 +3456,15 @@ } }, "node_modules/jest-mock": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.6.1.tgz", - "integrity": "sha512-brovyV9HBkjXAEdRooaTQK42n8usKoSRR3gihzUpYeV/vwqgSoNfrksO7UfSACnPmxasO/8TmHM3w9Hp3G1dgw==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.6.2.tgz", + "integrity": "sha512-hoSv3lb3byzdKfwqCuT6uTscan471GUECqgNYykg6ob0yiAw3zYc7OrPnI9Qv8Wwoa4lC7AZ9hyS4AiIx5U2zg==", "dev": true, + "peer": true, "dependencies": { "@jest/types": "^29.6.1", "@types/node": "*", - "jest-util": "^29.6.1" + "jest-util": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -2969,6 +3475,7 @@ "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", "dev": true, + "peer": true, "engines": { "node": ">=6" }, @@ -2986,22 +3493,24 @@ "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.4.3.tgz", "integrity": "sha512-O4FglZaMmWXbGHSQInfXewIsd1LMn9p3ZXB/6r4FOkyhX2/iP/soMG98jGvk/A3HAN78+5VWcBGO0BJAPRh4kg==", "dev": true, + "peer": true, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-resolve": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.6.1.tgz", - "integrity": "sha512-AeRkyS8g37UyJiP9w3mmI/VXU/q8l/IH52vj/cDAyScDcemRbSBhfX/NMYIGilQgSVwsjxrCHf3XJu4f+lxCMg==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.6.2.tgz", + "integrity": "sha512-G/iQUvZWI5e3SMFssc4ug4dH0aZiZpsDq9o1PtXTV1210Ztyb2+w+ZgQkB3iOiC5SmAEzJBOHWz6Hvrd+QnNPw==", "dev": true, + "peer": true, "dependencies": { "chalk": "^4.0.0", "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.6.1", + "jest-haste-map": "^29.6.2", "jest-pnp-resolver": "^1.2.2", - "jest-util": "^29.6.1", - "jest-validate": "^29.6.1", + "jest-util": "^29.6.2", + "jest-validate": "^29.6.2", "resolve": "^1.20.0", "resolve.exports": "^2.0.0", "slash": "^3.0.0" @@ -3011,43 +3520,45 @@ } }, "node_modules/jest-resolve-dependencies": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.6.1.tgz", - "integrity": "sha512-BbFvxLXtcldaFOhNMXmHRWx1nXQO5LoXiKSGQcA1LxxirYceZT6ch8KTE1bK3X31TNG/JbkI7OkS/ABexVahiw==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.6.2.tgz", + "integrity": "sha512-LGqjDWxg2fuQQm7ypDxduLu/m4+4Lb4gczc13v51VMZbVP5tSBILqVx8qfWcsdP8f0G7aIqByIALDB0R93yL+w==", "dev": true, + "peer": true, "dependencies": { "jest-regex-util": "^29.4.3", - "jest-snapshot": "^29.6.1" + "jest-snapshot": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-runner": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.6.1.tgz", - "integrity": "sha512-tw0wb2Q9yhjAQ2w8rHRDxteryyIck7gIzQE4Reu3JuOBpGp96xWgF0nY8MDdejzrLCZKDcp8JlZrBN/EtkQvPQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.6.2.tgz", + "integrity": "sha512-wXOT/a0EspYgfMiYHxwGLPCZfC0c38MivAlb2lMEAlwHINKemrttu1uSbcGbfDV31sFaPWnWJPmb2qXM8pqZ4w==", "dev": true, + "peer": true, "dependencies": { - "@jest/console": "^29.6.1", - "@jest/environment": "^29.6.1", - "@jest/test-result": "^29.6.1", - "@jest/transform": "^29.6.1", + "@jest/console": "^29.6.2", + "@jest/environment": "^29.6.2", + "@jest/test-result": "^29.6.2", + "@jest/transform": "^29.6.2", "@jest/types": "^29.6.1", "@types/node": "*", "chalk": "^4.0.0", "emittery": "^0.13.1", "graceful-fs": "^4.2.9", "jest-docblock": "^29.4.3", - "jest-environment-node": "^29.6.1", - "jest-haste-map": "^29.6.1", - "jest-leak-detector": "^29.6.1", - "jest-message-util": "^29.6.1", - "jest-resolve": "^29.6.1", - "jest-runtime": "^29.6.1", - "jest-util": "^29.6.1", - "jest-watcher": "^29.6.1", - "jest-worker": "^29.6.1", + "jest-environment-node": "^29.6.2", + "jest-haste-map": "^29.6.2", + "jest-leak-detector": "^29.6.2", + "jest-message-util": "^29.6.2", + "jest-resolve": "^29.6.2", + "jest-runtime": "^29.6.2", + "jest-util": "^29.6.2", + "jest-watcher": "^29.6.2", + "jest-worker": "^29.6.2", "p-limit": "^3.1.0", "source-map-support": "0.5.13" }, @@ -3056,17 +3567,18 @@ } }, "node_modules/jest-runtime": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.6.1.tgz", - "integrity": "sha512-D6/AYOA+Lhs5e5il8+5pSLemjtJezUr+8zx+Sn8xlmOux3XOqx4d8l/2udBea8CRPqqrzhsKUsN/gBDE/IcaPQ==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.6.2.tgz", + "integrity": "sha512-2X9dqK768KufGJyIeLmIzToDmsN0m7Iek8QNxRSI/2+iPFYHF0jTwlO3ftn7gdKd98G/VQw9XJCk77rbTGZnJg==", "dev": true, + "peer": true, "dependencies": { - "@jest/environment": "^29.6.1", - "@jest/fake-timers": "^29.6.1", - "@jest/globals": "^29.6.1", + "@jest/environment": "^29.6.2", + "@jest/fake-timers": "^29.6.2", + "@jest/globals": "^29.6.2", "@jest/source-map": "^29.6.0", - "@jest/test-result": "^29.6.1", - "@jest/transform": "^29.6.1", + "@jest/test-result": "^29.6.2", + "@jest/transform": "^29.6.2", "@jest/types": "^29.6.1", "@types/node": "*", "chalk": "^4.0.0", @@ -3074,13 +3586,13 @@ "collect-v8-coverage": "^1.0.0", "glob": "^7.1.3", "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.6.1", - "jest-message-util": "^29.6.1", - "jest-mock": "^29.6.1", + "jest-haste-map": "^29.6.2", + "jest-message-util": "^29.6.2", + "jest-mock": "^29.6.2", "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.6.1", - "jest-snapshot": "^29.6.1", - "jest-util": "^29.6.1", + "jest-resolve": "^29.6.2", + "jest-snapshot": "^29.6.2", + "jest-util": "^29.6.2", "slash": "^3.0.0", "strip-bom": "^4.0.0" }, @@ -3089,31 +3601,31 @@ } }, "node_modules/jest-snapshot": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.6.1.tgz", - "integrity": "sha512-G4UQE1QQ6OaCgfY+A0uR1W2AY0tGXUPQpoUClhWHq1Xdnx1H6JOrC2nH5lqnOEqaDgbHFgIwZ7bNq24HpB180A==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.6.2.tgz", + "integrity": "sha512-1OdjqvqmRdGNvWXr/YZHuyhh5DeaLp1p/F8Tht/MrMw4Kr1Uu/j4lRG+iKl1DAqUJDWxtQBMk41Lnf/JETYBRA==", "dev": true, + "peer": true, "dependencies": { "@babel/core": "^7.11.6", "@babel/generator": "^7.7.2", "@babel/plugin-syntax-jsx": "^7.7.2", "@babel/plugin-syntax-typescript": "^7.7.2", "@babel/types": "^7.3.3", - "@jest/expect-utils": "^29.6.1", - "@jest/transform": "^29.6.1", + "@jest/expect-utils": "^29.6.2", + "@jest/transform": "^29.6.2", "@jest/types": "^29.6.1", - "@types/prettier": "^2.1.5", "babel-preset-current-node-syntax": "^1.0.0", "chalk": "^4.0.0", - "expect": "^29.6.1", + "expect": "^29.6.2", "graceful-fs": "^4.2.9", - "jest-diff": "^29.6.1", + "jest-diff": "^29.6.2", "jest-get-type": "^29.4.3", - "jest-matcher-utils": "^29.6.1", - "jest-message-util": "^29.6.1", - "jest-util": "^29.6.1", + "jest-matcher-utils": "^29.6.2", + "jest-message-util": "^29.6.2", + "jest-util": "^29.6.2", "natural-compare": "^1.4.0", - "pretty-format": "^29.6.1", + "pretty-format": "^29.6.2", "semver": "^7.5.3" }, "engines": { @@ -3125,6 +3637,7 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "peer": true, "dependencies": { "yallist": "^4.0.0" }, @@ -3137,6 +3650,7 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "peer": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -3151,12 +3665,13 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "dev": true, + "peer": true }, "node_modules/jest-util": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.1.tgz", - "integrity": "sha512-NRFCcjc+/uO3ijUVyNOQJluf8PtGCe/W6cix36+M3cTFgiYqFOOW5MgN4JOOcvbUhcKTYVd1CvHz/LWi8d16Mg==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.2.tgz", + "integrity": "sha512-3eX1qb6L88lJNCFlEADKOkjpXJQyZRiavX1INZ4tRnrBVr2COd3RgcTLyUiEXMNBlDU/cgYq6taUS0fExrWW4w==", "dev": true, "dependencies": { "@jest/types": "^29.6.1", @@ -3171,17 +3686,18 @@ } }, "node_modules/jest-validate": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.6.1.tgz", - "integrity": "sha512-r3Ds69/0KCN4vx4sYAbGL1EVpZ7MSS0vLmd3gV78O+NAx3PDQQukRU5hNHPXlyqCgFY8XUk7EuTMLugh0KzahA==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.6.2.tgz", + "integrity": "sha512-vGz0yMN5fUFRRbpJDPwxMpgSXW1LDKROHfBopAvDcmD6s+B/s8WJrwi+4bfH4SdInBA5C3P3BI19dBtKzx1Arg==", "dev": true, + "peer": true, "dependencies": { "@jest/types": "^29.6.1", "camelcase": "^6.2.0", "chalk": "^4.0.0", "jest-get-type": "^29.4.3", "leven": "^3.1.0", - "pretty-format": "^29.6.1" + "pretty-format": "^29.6.2" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -3192,6 +3708,7 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "dev": true, + "peer": true, "engines": { "node": ">=10" }, @@ -3200,18 +3717,19 @@ } }, "node_modules/jest-watcher": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.6.1.tgz", - "integrity": "sha512-d4wpjWTS7HEZPaaj8m36QiaP856JthRZkrgcIY/7ISoUWPIillrXM23WPboZVLbiwZBt4/qn2Jke84Sla6JhFA==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.6.2.tgz", + "integrity": "sha512-GZitlqkMkhkefjfN/p3SJjrDaxPflqxEAv3/ik10OirZqJGYH5rPiIsgVcfof0Tdqg3shQGdEIxDBx+B4tuLzA==", "dev": true, + "peer": true, "dependencies": { - "@jest/test-result": "^29.6.1", + "@jest/test-result": "^29.6.2", "@jest/types": "^29.6.1", "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", "emittery": "^0.13.1", - "jest-util": "^29.6.1", + "jest-util": "^29.6.2", "string-length": "^4.0.1" }, "engines": { @@ -3219,13 +3737,14 @@ } }, "node_modules/jest-worker": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.6.1.tgz", - "integrity": "sha512-U+Wrbca7S8ZAxAe9L6nb6g8kPdia5hj32Puu5iOqBCMTMWFHXuK6dOV2IFrpedbTV8fjMFLdWNttQTBL6u2MRA==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.6.2.tgz", + "integrity": "sha512-l3ccBOabTdkng8I/ORCkADz4eSMKejTYv1vB/Z83UiubqhC1oQ5Li6dWCyqOIvSifGjUBxuvxvlm6KGK2DtuAQ==", "dev": true, + "peer": true, "dependencies": { "@types/node": "*", - "jest-util": "^29.6.1", + "jest-util": "^29.6.2", "merge-stream": "^2.0.0", "supports-color": "^8.0.0" }, @@ -3238,6 +3757,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, + "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -3266,6 +3786,7 @@ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dev": true, + "peer": true, "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -3279,6 +3800,7 @@ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true, + "peer": true, "bin": { "jsesc": "bin/jsesc" }, @@ -3290,7 +3812,8 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "dev": true + "dev": true, + "peer": true }, "node_modules/json5": { "version": "2.2.3", @@ -3317,6 +3840,7 @@ "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", "dev": true, + "peer": true, "engines": { "node": ">=6" } @@ -3627,9 +4151,9 @@ } }, "node_modules/langsmith": { - "version": "0.0.14", - "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.0.14.tgz", - "integrity": "sha512-56K2AkhxsbniK2beCn28zRdHtlRlnVBWnKPsjAhSRBFESNZ0X00J2BXM/Z55M5Rt+Fpud0VldK8V+F25htYTDw==", + "version": "0.0.23", + "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.0.23.tgz", + "integrity": "sha512-0PI09dIZpZZphwaMIH8X2rxey40bP5GyBwtA2Vz/M5/o1p1je4JElS1xuWqY109zV7aRqoSD3QC9C5VB7h3orA==", "dependencies": { "@types/uuid": "^9.0.1", "commander": "^10.0.1", @@ -3641,11 +4165,20 @@ "langsmith": "dist/cli/main.cjs" } }, + "node_modules/langsmith/node_modules/commander": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", + "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", + "engines": { + "node": ">=14" + } + }, "node_modules/leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", "dev": true, + "peer": true, "engines": { "node": ">=6" } @@ -3654,13 +4187,15 @@ "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true + "dev": true, + "peer": true }, "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, + "peer": true, "dependencies": { "p-locate": "^4.1.0" }, @@ -3668,6 +4203,12 @@ "node": ">=8" } }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -3684,30 +4225,75 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", "dev": true, + "peer": true, "dependencies": { "yallist": "^3.0.2" } }, "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", "dev": true, + "peer": true, "dependencies": { - "semver": "^6.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/make-dir/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "peer": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "peer": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-dir/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true, + "peer": true + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", "dev": true, + "peer": true, "dependencies": { "tmpl": "1.0.5" } @@ -3739,7 +4325,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true + "dev": true, + "peer": true }, "node_modules/methods": { "version": "1.1.2", @@ -3797,6 +4384,7 @@ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true, + "peer": true, "engines": { "node": ">=6" } @@ -3862,7 +4450,8 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/negotiator": { "version": "0.6.3", @@ -3918,14 +4507,128 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/node-releases": { "version": "2.0.13", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "dev": true, + "peer": true + }, + "node_modules/nodemon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", + "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^3.2.7", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/nodemon/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/nodemon/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/nodemon/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -3940,6 +4643,7 @@ "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", "dev": true, + "peer": true, "dependencies": { "path-key": "^3.0.0" }, @@ -4006,6 +4710,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, + "peer": true, "dependencies": { "wrappy": "1" } @@ -4015,6 +4720,7 @@ "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, + "peer": true, "dependencies": { "mimic-fn": "^2.1.0" }, @@ -4034,17 +4740,12 @@ "form-data": "^4.0.0" } }, - "node_modules/openai/node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "node_modules/openai/node_modules/axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" + "follow-redirects": "^1.14.8" } }, "node_modules/openapi-types": { @@ -4065,6 +4766,7 @@ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, + "peer": true, "dependencies": { "yocto-queue": "^0.1.0" }, @@ -4080,6 +4782,7 @@ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, + "peer": true, "dependencies": { "p-limit": "^2.2.0" }, @@ -4092,6 +4795,7 @@ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, + "peer": true, "dependencies": { "p-try": "^2.0.0" }, @@ -4145,6 +4849,7 @@ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true, + "peer": true, "engines": { "node": ">=6" } @@ -4154,6 +4859,7 @@ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", "dev": true, + "peer": true, "dependencies": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", @@ -4180,6 +4886,7 @@ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -4189,6 +4896,7 @@ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -4198,6 +4906,7 @@ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -4206,7 +4915,8 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/path-to-regexp": { "version": "0.1.7", @@ -4242,7 +4952,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/picomatch": { "version": "2.3.1", @@ -4261,6 +4972,7 @@ "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", "dev": true, + "peer": true, "engines": { "node": ">= 6" } @@ -4270,6 +4982,7 @@ "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, + "peer": true, "dependencies": { "find-up": "^4.0.0" }, @@ -4278,9 +4991,9 @@ } }, "node_modules/pretty-format": { - "version": "29.6.1", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.6.1.tgz", - "integrity": "sha512-7jRj+yXO0W7e4/tSJKoR7HRIHLPPjtNaUGG2xxKQnGvPNRkgWcQ0AZX6P4KBRJN4FcTBWb3sa7DVUJmocYuoog==", + "version": "29.6.2", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.6.2.tgz", + "integrity": "sha512-1q0oC8eRveTg5nnBEWMXAU2qpv65Gnuf2eCQzSjxpWFkPaPARwqZZDGuNE0zPAZfTCHzIk3A8dIjwlQKKLphyg==", "dev": true, "dependencies": { "@jest/schemas": "^29.6.0", @@ -4308,6 +5021,7 @@ "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", "dev": true, + "peer": true, "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" @@ -4328,6 +5042,19 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "optional": true, + "peer": true + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "node_modules/pure-rand": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.2.tgz", @@ -4342,7 +5069,8 @@ "type": "opencollective", "url": "https://opencollective.com/fast-check" } - ] + ], + "peer": true }, "node_modules/qs": { "version": "6.11.0", @@ -4405,22 +5133,36 @@ "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "dev": true }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } }, "node_modules/resolve": { - "version": "1.22.2", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", - "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", + "version": "1.22.4", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", + "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", "dev": true, + "peer": true, "dependencies": { - "is-core-module": "^2.11.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -4436,6 +5178,7 @@ "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", "dev": true, + "peer": true, "dependencies": { "resolve-from": "^5.0.0" }, @@ -4448,6 +5191,7 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -4457,6 +5201,7 @@ "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", "dev": true, + "peer": true, "engines": { "node": ">=10" } @@ -4503,6 +5248,7 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, + "peer": true, "bin": { "semver": "bin/semver.js" } @@ -4559,6 +5305,7 @@ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, + "peer": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -4571,6 +5318,7 @@ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -4592,13 +5340,60 @@ "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "peer": true + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/simple-update-notifier/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/simple-update-notifier/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/simple-update-notifier/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", - "dev": true + "dev": true, + "peer": true }, "node_modules/slash": { "version": "3.0.0", @@ -4614,6 +5409,7 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -4623,6 +5419,7 @@ "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", "dev": true, + "peer": true, "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -4632,7 +5429,8 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true + "dev": true, + "peer": true }, "node_modules/stack-utils": { "version": "2.0.6", @@ -4659,6 +5457,7 @@ "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", "dev": true, + "peer": true, "dependencies": { "char-regex": "^1.0.2", "strip-ansi": "^6.0.0" @@ -4672,6 +5471,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "peer": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -4686,6 +5486,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "peer": true, "dependencies": { "ansi-regex": "^5.0.1" }, @@ -4698,6 +5499,7 @@ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -4707,6 +5509,7 @@ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true, + "peer": true, "engines": { "node": ">=6" } @@ -4716,6 +5519,7 @@ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, + "peer": true, "engines": { "node": ">=8" }, @@ -4740,6 +5544,7 @@ "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true, + "peer": true, "engines": { "node": ">= 0.4" }, @@ -4752,6 +5557,7 @@ "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", "dev": true, + "peer": true, "dependencies": { "@istanbuljs/schema": "^0.1.2", "glob": "^7.1.4", @@ -4765,13 +5571,15 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", "dev": true, + "peer": true, "engines": { "node": ">=4" } @@ -4796,16 +5604,148 @@ "node": ">=0.6" } }, + "node_modules/touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dev": true, + "dependencies": { + "nopt": "~1.0.10" + }, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/ts-jest": { + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", + "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "dev": true, + "dependencies": { + "bs-logger": "0.x", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "^7.5.3", + "yargs-parser": "^21.0.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-jest/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true, + "peer": true, "engines": { "node": ">=4" } @@ -4815,6 +5755,7 @@ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", "dev": true, + "peer": true, "engines": { "node": ">=10" }, @@ -4834,6 +5775,19 @@ "node": ">= 0.6" } }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/uid-safe": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", @@ -4845,6 +5799,12 @@ "node": ">= 0.8" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -4872,6 +5832,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "escalade": "^3.1.1", "picocolors": "^1.0.0" @@ -4899,11 +5860,18 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/v8-to-istanbul": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", "dev": true, + "peer": true, "dependencies": { "@jridgewell/trace-mapping": "^0.3.12", "@types/istanbul-lib-coverage": "^2.0.1", @@ -4917,7 +5885,8 @@ "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", - "dev": true + "dev": true, + "peer": true }, "node_modules/vary": { "version": "1.1.2", @@ -4932,6 +5901,7 @@ "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", "dev": true, + "peer": true, "dependencies": { "makeerror": "1.0.12" } @@ -4963,6 +5933,7 @@ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, + "peer": true, "dependencies": { "isexe": "^2.0.0" }, @@ -4978,6 +5949,7 @@ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, + "peer": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -4994,13 +5966,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/write-file-atomic": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", "dev": true, + "peer": true, "dependencies": { "imurmurhash": "^0.1.4", "signal-exit": "^3.0.7" @@ -5014,6 +5988,7 @@ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true, + "peer": true, "engines": { "node": ">=10" } @@ -5022,7 +5997,8 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true + "dev": true, + "peer": true }, "node_modules/yaml": { "version": "2.3.1", @@ -5037,6 +6013,7 @@ "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "dev": true, + "peer": true, "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", @@ -5059,11 +6036,21 @@ "node": ">=12" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, + "peer": true, "engines": { "node": ">=10" }, @@ -5072,9 +6059,9 @@ } }, "node_modules/zod": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", - "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", + "version": "3.22.1", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.1.tgz", + "integrity": "sha512-+qUhAMl414+Elh+fRNtpU+byrwjDFOS1N7NioLY+tSlcADTx4TkCUua/hxJvxwDXcV4397/nZ420jy4n4+3WUg==", "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/backend/package.json b/backend/package.json index ff2ef13a0..bb8aabb36 100644 --- a/backend/package.json +++ b/backend/package.json @@ -11,11 +11,18 @@ "react": "^18.2.0" }, "devDependencies": { - "jest": "^29.6.1" + "@types/cors": "^2.8.13", + "@types/express": "^4.17.17", + "@types/express-session": "^1.17.7", + "@types/jest": "^29.5.3", + "@types/node": "^20.4.5", + "nodemon": "^3.0.1", + "ts-jest": "^29.1.1", + "ts-node": "^10.9.1", + "typescript": "^4.1.6" }, "scripts": { - "dev": "node ./src/app.js", + "dev": "nodemon -r dotenv/config src/app.ts", "test": "jest" } } - diff --git a/backend/src/app.js b/backend/src/app.js deleted file mode 100644 index 0b0cf9240..000000000 --- a/backend/src/app.js +++ /dev/null @@ -1,79 +0,0 @@ -const express = require("express"); -const router = require("./router"); -const dotenv = require("dotenv"); -const cors = require("cors"); -const session = require("express-session"); -const { setOpenAiApiKey } = require("./openai"); -const { getInitialDefences } = require("./defence"); - -dotenv.config(); - -// by default runs on port 3001 -const port = process.env.PORT || 3001; - -const envOpenAiKey = process.env.OPENAI_API_KEY; - -// use default model -const defaultModel = "gpt-4"; - -// Creating express server -const app = express(); -// for parsing application/json -app.use(express.json()); - -// use session -const sess = { - secret: process.env.SESSION_SECRET, - name: "prompt-injection.sid", - resave: false, - saveUninitialized: true, - cookie: {}, -}; - -// serve secure cookies in production -if (app.get("env") === "production") { - sess.cookie.secure = true; -} -app.use(session(sess)); - -app.use( - cors({ - credentials: true, - origin: true, - }) -); - -app.use(function (req, res, next) { - // initialise session variables - if (!req.session.chatHistory) { - req.session.chatHistory = []; - } - if (!req.session.sentEmails) { - req.session.sentEmails = []; - } - if (!req.session.defences) { - req.session.defences = getInitialDefences(); - } - if (!req.session.apiKey) { - req.session.apiKey = envOpenAiKey || ""; - } - if (!req.session.gptModel) { - req.session.gptModel = defaultModel; - } - if (!req.session.numPhasesCompleted) { - req.session.numPhasesCompleted = 0; - } - next(); -}); - -app.use("/", router); -app.listen(port, () => { - console.log("Server is running on port: " + port); - - // for dev purposes only - set the API key from the environment variable - if (envOpenAiKey) { - console.debug("Initializing models with API key from environment variable"); - const defaultSession = { apiKey: "", gptModel: defaultModel }; - setOpenAiApiKey(defaultSession, process.env.OPENAI_API_KEY); - } -}); diff --git a/backend/src/app.ts b/backend/src/app.ts new file mode 100644 index 000000000..477db2b54 --- /dev/null +++ b/backend/src/app.ts @@ -0,0 +1,100 @@ +import cors from "cors"; +import dotenv from "dotenv"; +import express from "express"; +import session from "express-session"; + +import { getInitialDefences, getQALLMprePrompt } from "./defence"; +import { setOpenAiApiKey } from "./openai"; +import { router } from "./router"; +import { ChatCompletionRequestMessage } from "openai"; +import { EmailInfo } from "./models/email"; +import { DefenceInfo } from "./models/defence"; +import { CHAT_MODELS } from "./models/chat"; +import { retrievalQAPrePrompt } from "./promptTemplates"; + +dotenv.config(); + +declare module "express-session" { + interface Session { + chatHistory: ChatCompletionRequestMessage[]; + sentEmails: EmailInfo[]; + defences: DefenceInfo[]; + apiKey: string; + gptModel: CHAT_MODELS; + numPhasesCompleted: number; + } +} + +// by default runs on port 3001 +const port = process.env.PORT || String(3001); +// use default model +const defaultModel = CHAT_MODELS.GPT_4; + +// Creating express server +const app = express(); +// for parsing application/json +app.use(express.json()); + +// use session +const express_session: session.SessionOptions = { + secret: process.env.SESSION_SECRET || "secret", + name: "prompt-injection.sid", + resave: false, + saveUninitialized: true, + cookie: { + secure: false, + }, +}; + +// serve secure cookies in production +if (app.get("env") === "production") { + if (!express_session.cookie) { + express_session.cookie = { secure: true }; + } else { + express_session.cookie.secure = true; + } +} +app.use(session(express_session)); + +app.use( + cors({ + credentials: true, + origin: true, + }) +); + +app.use((req, _res, next) => { + // initialise session variables + if (!req.session.chatHistory) { + req.session.chatHistory = []; + } + if (!req.session.sentEmails) { + req.session.sentEmails = []; + } + if (!req.session.defences) { + req.session.defences = getInitialDefences(); + } + if (!req.session.apiKey) { + req.session.apiKey = process.env.OPENAI_API_KEY || ""; + } + if (!req.session.gptModel) { + req.session.gptModel = defaultModel; + } + if (!req.session.numPhasesCompleted) { + req.session.numPhasesCompleted = 0; + } + next(); +}); + +app.use("/", router); +app.listen(port, () => { + console.log("Server is running on port: " + port); + + // for dev purposes only - set the API key from the environment variable + const envOpenAiKey = process.env.OPENAI_API_KEY; + const prePrompt = retrievalQAPrePrompt; + if (envOpenAiKey && prePrompt) { + console.debug("Initializing models with API key from environment variable"); + setOpenAiApiKey(envOpenAiKey, defaultModel, prePrompt); + } +}); diff --git a/backend/src/defence.js b/backend/src/defence.js deleted file mode 100644 index 66edce694..000000000 --- a/backend/src/defence.js +++ /dev/null @@ -1,250 +0,0 @@ -const { retrievalQAPrePromptSecure } = require("./promptTemplates"); - -function getInitialDefences() { - const defences = [ - { - id: "CHARACTER_LIMIT", - config: [ - { - id: "maxMessageLength", - value: process.env.MAX_MESSAGE_LENGTH || 280, - }, - ], - }, - { - id: "RANDOM_SEQUENCE_ENCLOSURE", - config: [ - { - id: "prePrompt", - value: process.env.RANDOM_SEQ_ENCLOSURE_PRE_PROMPT || "", - }, - { - id: "length", - value: process.env.RANDOM_SEQ_ENCLOSURE_LENGTH || 10, - }, - ], - }, - { id: "XML_TAGGING" }, - { - id: "EMAIL_WHITELIST", - config: [ - { - id: "whitelist", - value: process.env.EMAIL_WHITELIST, - }, - ], - }, - { - id: "SYSTEM_ROLE", - config: [ - { - id: "systemRole", - value: process.env.SYSTEM_ROLE || "", - }, - ], - }, - { id: "LLM_EVALUATION" }, - { - id: "QA_LLM_INSTRUCTIONS", - config: [ - { - id: "prePrompt", - value: retrievalQAPrePromptSecure, - }, - ], - }, - ]; - // make all defences inactive by default and return - return defences.map((defence) => ({ ...defence, isActive: false })); -} - -function activateDefence(id, defences) { - // return the updated list of defences - return defences.map((defence) => - defence.id === id ? { ...defence, isActive: true } : defence - ); -} - -function deactivateDefence(id, defences) { - // return the updated list of defences - return defences.map((defence) => - defence.id === id ? { ...defence, isActive: false } : defence - ); -} - -function configureDefence(id, defences, config) { - // return the updated list of defences - return defences.map((defence) => - defence.id === id ? { ...defence, config: config } : defence - ); -} - -function getConfigValue(defences, defenceId, configId, defaultValue) { - const configValue = defences - .find((defence) => defence.id === defenceId) - ?.config?.find((config) => config.id === configId)?.value; - return configValue || defaultValue; -} - -function getMaxMessageLength(defences) { - return getConfigValue(defences, "CHARACTER_LIMIT", "maxMessageLength", 280); -} - -function getRandomSequenceEnclosurePrePrompt(defences) { - return getConfigValue(defences, "RANDOM_SEQUENCE_ENCLOSURE", "prePrompt", ""); -} - -function getRandomSequenceEnclosureLength(defences) { - return getConfigValue(defences, "RANDOM_SEQUENCE_ENCLOSURE", "length", 10); -} - -function getSystemRole(defences, currentPhase) { - switch (currentPhase) { - case 0: - return process.env.SYSTEM_ROLE_PHASE_0 || ""; - case 1: - return process.env.SYSTEM_ROLE_PHASE_1 || ""; - case 2: - return process.env.SYSTEM_ROLE_PHASE_2 || ""; - default: - return getConfigValue(defences, "SYSTEM_ROLE", "systemRole", ""); - } -} - -function getEmailWhitelistVar(defences) { - return getConfigValue(defences, "EMAIL_WHITELIST", "whitelist", ""); -} - -function getQALLMprePrompt(defences) { - return getConfigValue(defences, "QA_LLM_INSTRUCTIONS", "prePrompt", ""); -} - -function isDefenceActive(id, defences) { - return defences.find((defence) => defence.id === id && defence.isActive) - ? true - : false; -} - -function generate_random_string(string_length) { - let random_string = ""; - for (let i = 0; i < string_length; i++) { - const random_ascii = Math.floor(Math.random() * 25 + 97); - random_string += String.fromCharCode(random_ascii); - } - return random_string; -} - -// apply random sequence enclosure defense to input message -function transformRandomSequenceEnclosure(message, defences) { - console.debug("Random Sequence Enclosure defence active."); - const randomString = generate_random_string( - getRandomSequenceEnclosureLength(defences) - ); - const introText = getRandomSequenceEnclosurePrePrompt(defences); - const transformedMessage = introText.concat( - randomString, - " {{ ", - message, - " }} ", - randomString, - ". " - ); - return transformedMessage; -} - -// function to escape XML characters in user input to prevent hacking with XML tagging on -function escapeXml(unsafe) { - return unsafe?.replace(/[<>&'"]/g, function (c) { - switch (c) { - case "<": - return "<"; - case ">": - return ">"; - case "&": - return "&"; - case "'": - return "'"; - case '"': - return """; - } - }); -} - -// function to detect any XML tags in user input -function detectXMLTags(input) { - const tagRegex = /<\/?[a-zA-Z][\w\-]*(?:\b[^>]*\/\s*|[^>]*>|[?]>)/g; - const foundTags = input.match(tagRegex) || []; - return foundTags.length > 0; -} - -// apply XML tagging defence to input message -function transformXmlTagging(message) { - console.debug("XML Tagging defence active."); - const openTag = ""; - const closeTag = ""; - const transformedMessage = openTag.concat(escapeXml(message), closeTag); - return transformedMessage; -} - -//apply defence string transformations to original message -function transformMessage(message, defences) { - let transformedMessage = message; - if (isDefenceActive("RANDOM_SEQUENCE_ENCLOSURE", defences)) { - transformedMessage = transformRandomSequenceEnclosure( - transformedMessage, - defences - ); - } - if (isDefenceActive("XML_TAGGING", defences)) { - transformedMessage = transformXmlTagging(transformedMessage); - } - if (message == transformedMessage) { - console.debug("No defences applied. Message unchanged."); - } else { - console.debug( - "Defences applied. Transformed message: " + transformedMessage - ); - } - return transformedMessage; -} - -// detects triggered defences in original message and blocks the message if necessary -function detectTriggeredDefences(message, defences) { - // keep track of any triggered defences - const defenceInfo = { blocked: false, triggeredDefences: [] }; - const maxMessageLength = getMaxMessageLength(defences); - // check if the message is too long - if (message.length > maxMessageLength) { - console.debug("CHARACTER_LIMIT defence triggered."); - // add the defence to the list of triggered defences - defenceInfo.triggeredDefences.push("CHARACTER_LIMIT"); - // check if the defence is active - if (isDefenceActive("CHARACTER_LIMIT", defences)) { - // block the message - defenceInfo.blocked = true; - // return the defence info - return { reply: "Message is too long", defenceInfo: defenceInfo }; - } - } - - // check if message contains XML tags - if (detectXMLTags(message)) { - console.debug("XML_TAGGING defence triggered."); - // add the defence to the list of triggered defences - defenceInfo.triggeredDefences.push("XML_TAGGING"); - } - return { reply: null, defenceInfo: defenceInfo }; -} - -module.exports = { - activateDefence, - configureDefence, - deactivateDefence, - getInitialDefences, - getSystemRole, - getQALLMprePrompt, - isDefenceActive, - transformMessage, - detectTriggeredDefences, - getEmailWhitelistVar, -}; diff --git a/backend/src/defence.ts b/backend/src/defence.ts new file mode 100644 index 000000000..2a6a99cfe --- /dev/null +++ b/backend/src/defence.ts @@ -0,0 +1,295 @@ +import { queryPromptEvaluationModel } from "./langchain"; +import { ChatDefenceReport } from "./models/chat"; +import { DEFENCE_TYPES, DefenceConfig, DefenceInfo } from "./models/defence"; +import { PHASE_NAMES } from "./models/phase"; +import { retrievalQAPrePromptSecure } from "./promptTemplates"; + +const getInitialDefences = (): DefenceInfo[] => { + return [ + new DefenceInfo(DEFENCE_TYPES.CHARACTER_LIMIT, [ + { + id: "maxMessageLength", + value: process.env.MAX_MESSAGE_LENGTH || String(280), + }, + ]), + new DefenceInfo(DEFENCE_TYPES.EMAIL_WHITELIST, [ + { + id: "whitelist", + value: process.env.EMAIL_WHITELIST || "", + }, + ]), + new DefenceInfo(DEFENCE_TYPES.LLM_EVALUATION, []), + new DefenceInfo(DEFENCE_TYPES.QA_LLM_INSTRUCTIONS, [ + { + id: "prePrompt", + value: retrievalQAPrePromptSecure, + }, + ]), + new DefenceInfo(DEFENCE_TYPES.RANDOM_SEQUENCE_ENCLOSURE, [ + { + id: "prePrompt", + value: process.env.RANDOM_SEQ_ENCLOSURE_PRE_PROMPT || "", + }, + { + id: "length", + value: process.env.RANDOM_SEQ_ENCLOSURE_LENGTH || String(10), + }, + ]), + new DefenceInfo(DEFENCE_TYPES.SYSTEM_ROLE, [ + { + id: "systemRole", + value: process.env.SYSTEM_ROLE || "", + }, + ]), + new DefenceInfo(DEFENCE_TYPES.XML_TAGGING, []), + ]; +}; + +function activateDefence(id: string, defences: DefenceInfo[]) { + // return the updated list of defences + return defences.map((defence) => + defence.id === id ? { ...defence, isActive: true } : defence + ); +} + +function deactivateDefence(id: string, defences: DefenceInfo[]) { + // return the updated list of defences + return defences.map((defence) => + defence.id === id ? { ...defence, isActive: false } : defence + ); +} + +function configureDefence( + id: string, + defences: DefenceInfo[], + config: DefenceConfig[] +) { + // return the updated list of defences + return defences.map((defence) => + defence.id === id ? { ...defence, config: config } : defence + ); +} + +function getConfigValue( + defences: DefenceInfo[], + defenceId: string, + configId: string, + defaultValue: string +) { + const configValue: string | undefined = defences + .find((defence) => defence.id === defenceId) + ?.config?.find((config) => config.id === configId)?.value; + return configValue || defaultValue; +} + +function getMaxMessageLength(defences: DefenceInfo[]) { + return getConfigValue( + defences, + "CHARACTER_LIMIT", + "maxMessageLength", + String(280) + ); +} + +function getRandomSequenceEnclosurePrePrompt(defences: DefenceInfo[]) { + return getConfigValue(defences, "RANDOM_SEQUENCE_ENCLOSURE", "prePrompt", ""); +} + +function getRandomSequenceEnclosureLength(defences: DefenceInfo[]) { + return getConfigValue( + defences, + "RANDOM_SEQUENCE_ENCLOSURE", + "length", + String(10) + ); +} + +function getSystemRole( + defences: DefenceInfo[], + // by default, use sandbox + currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX +) { + switch (currentPhase) { + case PHASE_NAMES.PHASE_0: + return process.env.SYSTEM_ROLE_PHASE_0 || ""; + case PHASE_NAMES.PHASE_1: + return process.env.SYSTEM_ROLE_PHASE_1 || ""; + case PHASE_NAMES.PHASE_2: + return process.env.SYSTEM_ROLE_PHASE_2 || ""; + default: + return getConfigValue(defences, "SYSTEM_ROLE", "systemRole", ""); + } +} + +function getEmailWhitelistVar(defences: DefenceInfo[]) { + return getConfigValue(defences, "EMAIL_WHITELIST", "whitelist", ""); +} + +function getQALLMprePrompt(defences: DefenceInfo[]) { + return getConfigValue(defences, "QA_LLM_INSTRUCTIONS", "prePrompt", ""); +} + +function isDefenceActive(id: string, defences: DefenceInfo[]) { + return defences.find((defence) => defence.id === id && defence.isActive) + ? true + : false; +} + +function generateRandomString(string_length: number) { + let random_string = ""; + for (let i = 0; i < string_length; i++) { + const random_ascii: number = Math.floor(Math.random() * 25 + 97); + random_string += String.fromCharCode(random_ascii); + } + return random_string; +} + +// apply random sequence enclosure defense to input message +function transformRandomSequenceEnclosure( + message: string, + defences: DefenceInfo[] +) { + console.debug("Random Sequence Enclosure defence active."); + const randomString: string = generateRandomString( + Number(getRandomSequenceEnclosureLength(defences)) + ); + const introText: string = getRandomSequenceEnclosurePrePrompt(defences); + const transformedMessage: string = introText.concat( + randomString, + " {{ ", + message, + " }} ", + randomString, + ". " + ); + return transformedMessage; +} + +// function to escape XML characters in user input to prevent hacking with XML tagging on +function escapeXml(unsafe: string) { + unsafe.replace; + return unsafe.replace(/[<>&'"]/g, function (c: string): string { + switch (c) { + case "<": + return "<"; + case ">": + return ">"; + case "&": + return "&"; + case "'": + return "'"; + case '"': + return """; + default: + return c; + } + }); +} + +// function to detect any XML tags in user input +function detectXMLTags(input: string) { + const tagRegex: RegExp = /<\/?[a-zA-Z][\w\-]*(?:\b[^>]*\/\s*|[^>]*>|[?]>)/g; + const foundTags: string[] = input.match(tagRegex) || []; + return foundTags.length > 0; +} + +// apply XML tagging defence to input message +function transformXmlTagging(message: string) { + console.debug("XML Tagging defence active."); + const openTag: string = ""; + const closeTag: string = ""; + const transformedMessage: string = openTag.concat( + escapeXml(message), + closeTag + ); + return transformedMessage; +} + +//apply defence string transformations to original message +function transformMessage(message: string, defences: DefenceInfo[]) { + let transformedMessage: string = message; + if (isDefenceActive("RANDOM_SEQUENCE_ENCLOSURE", defences)) { + transformedMessage = transformRandomSequenceEnclosure( + transformedMessage, + defences + ); + } + if (isDefenceActive("XML_TAGGING", defences)) { + transformedMessage = transformXmlTagging(transformedMessage); + } + if (message == transformedMessage) { + console.debug("No defences applied. Message unchanged."); + } else { + console.debug( + "Defences applied. Transformed message: " + transformedMessage + ); + } + return transformedMessage; +} + +// detects triggered defences in original message and blocks the message if necessary +async function detectTriggeredDefences( + message: string, + defences: DefenceInfo[], + useLlmEvaluation: boolean +) { + // keep track of any triggered defences + const defenceReport: ChatDefenceReport = { + blockedReason: null, + isBlocked: false, + triggeredDefences: [], + }; + const maxMessageLength: number = Number(getMaxMessageLength(defences)); + // check if the message is too long + if (message.length > maxMessageLength) { + console.debug("CHARACTER_LIMIT defence triggered."); + // add the defence to the list of triggered defences + defenceReport.triggeredDefences.push("CHARACTER_LIMIT"); + // check if the defence is active + if (isDefenceActive("CHARACTER_LIMIT", defences)) { + // block the message + defenceReport.isBlocked = true; + defenceReport.blockedReason = "Message is too long"; + // return the defence info + return defenceReport; + } + } + + // check if message contains XML tags + if (detectXMLTags(message)) { + console.debug("XML_TAGGING defence triggered."); + // add the defence to the list of triggered defences + defenceReport.triggeredDefences.push("XML_TAGGING"); + } + + // evaluate the message for prompt injection + // to speed up replies, only do this on phases where defences are active + if (useLlmEvaluation) { + const evalPrompt = await queryPromptEvaluationModel(message); + if (evalPrompt.isMalicious) { + defenceReport.triggeredDefences.push("LLM_EVALUATION"); + if (isDefenceActive("LLM_EVALUATION", defences)) { + console.debug("LLM evalutation defence active."); + defenceReport.isBlocked = true; + defenceReport.blockedReason = + "Message blocked by the malicious prompt evaluator." + + evalPrompt.reason; + } + } + } + + return defenceReport; +} + +export { + activateDefence, + configureDefence, + deactivateDefence, + getInitialDefences, + getQALLMprePrompt, + getSystemRole, + isDefenceActive, + transformMessage, + detectTriggeredDefences, + getEmailWhitelistVar, +}; diff --git a/backend/src/email.js b/backend/src/email.ts similarity index 69% rename from backend/src/email.js rename to backend/src/email.ts index 9a5758de3..e60f4473c 100644 --- a/backend/src/email.js +++ b/backend/src/email.ts @@ -1,13 +1,16 @@ -const { getEmailWhitelistVar, isDefenceActive } = require("./defence.js"); +import { DefenceInfo } from "./models/defence"; +import { EmailInfo } from "./models/email"; +import { getEmailWhitelistVar, isDefenceActive } from "./defence"; +import { PHASE_NAMES } from "./models/phase"; // return the whitelist variable -function getEmailWhitelistValues(defences) { +function getEmailWhitelistValues(defences: DefenceInfo[]) { const emailWhitelist = getEmailWhitelistVar(defences); - return emailWhitelist.split(",").map((c) => c.trim()); + return emailWhitelist.split(",").map((c: string) => c.trim()); } // if defense active return the whitelist of emails and domains -function getEmailWhitelist(defences) { +function getEmailWhitelist(defences: DefenceInfo[]) { if (!isDefenceActive("EMAIL_WHITELIST", defences)) { return "As the email whitelist defence is not active, any email address can be emailed."; } else { @@ -19,7 +22,7 @@ function getEmailWhitelist(defences) { } // check if email is in whitelist -function isEmailInWhitelist(emailAddress, defences) { +function isEmailInWhitelist(emailAddress: string, defences: DefenceInfo[]) { // get the domain from email const emailAddressDomain = emailAddress.split("@")[1]; const emailWhitelist = getEmailWhitelistValues(defences); @@ -39,10 +42,20 @@ function isEmailInWhitelist(emailAddress, defences) { return emailWhitelist.includes(emailAddress); } -function sendEmail(address, subject, body, session, currentPhase) { +function sendEmail( + address: string, + subject: string, + body: string, + // default to sandbox + currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX +) { // add to the list of sent emails - const email = { address: address, subject: subject, content: body }; - const response = + const email: EmailInfo = { + address: address, + subject: subject, + content: body, + }; + const response: string = "Email sent to " + address + " with subject " + @@ -50,14 +63,16 @@ function sendEmail(address, subject, body, session, currentPhase) { " and body " + body; console.log(response); - // add the sent email to the session - session.sentEmails.push(email); - const wonPhase = checkPhaseWinCondition(email, currentPhase); + const wonPhase: boolean = checkPhaseWinCondition(email, currentPhase); - return { response: response, wonPhase: wonPhase }; + return { response: response, sentEmail: email, wonPhase: wonPhase }; } -function checkSubjectAndBodyContains(subject, content, wordList) { +function checkSubjectAndBodyContains( + subject: string, + content: string, + wordList: string[] +) { // check if either the email or subject contains any of the words for (let i = 0; i < wordList.length; i++) { if ( @@ -70,9 +85,13 @@ function checkSubjectAndBodyContains(subject, content, wordList) { return false; } -function checkPhaseWinCondition(email, currentPhase) { +function checkPhaseWinCondition( + email: EmailInfo, + // default to sandbox + currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX +) { switch (currentPhase) { - case 0: + case PHASE_NAMES.PHASE_0: return ( // correct email address email.address.toLowerCase() === "bob@scottlogic.com" && @@ -81,7 +100,7 @@ function checkPhaseWinCondition(email, currentPhase) { ? true : false ); - case 1: + case PHASE_NAMES.PHASE_1: return ( // correct email address email.address.toLowerCase() === "alice@scottlogic.com" && @@ -90,7 +109,7 @@ function checkPhaseWinCondition(email, currentPhase) { ? true : false ); - case 2: + case PHASE_NAMES.PHASE_2: return ( // correct email address email.address.toLowerCase() === "eve@scottlogic.com" && @@ -116,8 +135,4 @@ function checkPhaseWinCondition(email, currentPhase) { } } -module.exports = { - getEmailWhitelist, - isEmailInWhitelist, - sendEmail, -}; +export { getEmailWhitelist, isEmailInWhitelist, sendEmail }; diff --git a/backend/src/langchain.js b/backend/src/langchain.ts similarity index 67% rename from backend/src/langchain.js rename to backend/src/langchain.ts index 989818ed4..56fa11da2 100644 --- a/backend/src/langchain.js +++ b/backend/src/langchain.ts @@ -1,39 +1,39 @@ -const { TextLoader } = require("langchain/document_loaders/fs/text"); -const { PDFLoader } = require("langchain/document_loaders/fs/pdf"); -const { CSVLoader } = require("langchain/document_loaders/fs/csv"); -const { DirectoryLoader } = require("langchain/document_loaders/fs/directory"); -const { RecursiveCharacterTextSplitter } = require("langchain/text_splitter"); -const { OpenAIEmbeddings } = require("langchain/embeddings/openai"); -const { MemoryVectorStore } = require("langchain/vectorstores/memory"); -const { ChatOpenAI } = require("langchain/chat_models/openai"); -const { - RetrievalQAChain, - LLMChain, - SequentialChain, -} = require("langchain/chains"); -const { PromptTemplate } = require("langchain/prompts"); -const { OpenAI } = require("langchain/llms/openai"); -const { +import { RetrievalQAChain, LLMChain, SequentialChain } from "langchain/chains"; +import { ChatOpenAI } from "langchain/chat_models/openai"; +import { Document } from "langchain/document"; +import { CSVLoader } from "langchain/document_loaders/fs/csv"; +import { DirectoryLoader } from "langchain/document_loaders/fs/directory"; +import { PDFLoader } from "langchain/document_loaders/fs/pdf"; +import { TextLoader } from "langchain/document_loaders/fs/text"; +import { OpenAIEmbeddings } from "langchain/embeddings/openai"; +import { OpenAI } from "langchain/llms/openai"; +import { PromptTemplate } from "langchain/prompts"; +import { RecursiveCharacterTextSplitter } from "langchain/text_splitter"; +import { MemoryVectorStore } from "langchain/vectorstores/memory"; + +import { CHAT_MODELS, ChatAnswer } from "./models/chat"; +import { + maliciousPromptTemplate, + promptInjectionEvalTemplate, qAcontextTemplate, retrievalQAPrePrompt, - promptInjectionEvalTemplate, - maliciousPromptTemplate, -} = require("./promptTemplates"); +} from "./promptTemplates"; +import { PHASE_NAMES } from "./models/phase"; // chain we use in question/answer request -let qaChain = null; +let qaChain: RetrievalQAChain | null = null; // chain we use in prompt evaluation request -let promptEvaluationChain = null; +let promptEvaluationChain: SequentialChain | null = null; -function getFilepath(currentPhase) { +function getFilepath(currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX) { let filePath = "resources/documents/"; switch (currentPhase) { - case 0: + case PHASE_NAMES.PHASE_0: return (filePath += "phase_0/"); - case 1: + case PHASE_NAMES.PHASE_1: return (filePath += "phase_1/"); - case 2: + case PHASE_NAMES.PHASE_2: return (filePath += "phase_2/"); default: return (filePath += "common/"); @@ -41,13 +41,13 @@ function getFilepath(currentPhase) { } // load the documents from filesystem -async function getDocuments(filePath) { +async function getDocuments(filePath: string) { console.debug("Loading documents from: " + filePath); - const loader = new DirectoryLoader(filePath, { - ".pdf": (path) => new PDFLoader(path), - ".txt": (path) => new TextLoader(path), - ".csv": (path) => new CSVLoader(path), + const loader: DirectoryLoader = new DirectoryLoader(filePath, { + ".pdf": (path: string) => new PDFLoader(path), + ".txt": (path: string) => new TextLoader(path), + ".csv": (path: string) => new CSVLoader(path), }); const docs = await loader.load(); @@ -61,7 +61,7 @@ async function getDocuments(filePath) { } // join the configurable preprompt to the context template -function getQAPromptTemplate(prePrompt) { +function getQAPromptTemplate(prePrompt: string) { if (!prePrompt) { console.debug("Using default retrieval QA pre-prompt"); prePrompt = retrievalQAPrePrompt; @@ -70,23 +70,30 @@ function getQAPromptTemplate(prePrompt) { } // QA Chain - ask the chat model a question about the documents -async function initQAModel(session, currentPhase, prePrompt) { - if (!session.apiKey) { +async function initQAModel( + apiKey: string, + prePrompt: string, + // default to sandbox + currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX +) { + if (!apiKey) { console.debug("No apiKey set to initialise QA model"); return; } // get the documents - const docs = await getDocuments(getFilepath(currentPhase)); + const docs: Document[] = await getDocuments(getFilepath(currentPhase)); // embed and store the splits - const embeddings = new OpenAIEmbeddings({ openAIApiKey: session.apiKey }); + const embeddings = new OpenAIEmbeddings({ + openAIApiKey: apiKey, + }); const vectorStore = await MemoryVectorStore.fromDocuments(docs, embeddings); // initialise model const model = new ChatOpenAI({ - modelName: "gpt-4", - stream: true, - openAIApiKey: session.apiKey, + modelName: CHAT_MODELS.GPT_4, + streaming: true, + openAIApiKey: apiKey, }); // prompt template for question and answering @@ -99,8 +106,8 @@ async function initQAModel(session, currentPhase, prePrompt) { } // initialise the prompt evaluation model -async function initPromptEvaluationModel(session) { - if (!session.apiKey) { +function initPromptEvaluationModel(apiKey: string) { + if (!apiKey) { console.debug("No apiKey set to initialise prompt evaluation model"); return; } @@ -112,9 +119,9 @@ async function initPromptEvaluationModel(session) { const promptInjectionChain = new LLMChain({ llm: new OpenAI({ - model: "gpt-3.5-turbo", + modelName: CHAT_MODELS.GPT_3_5_TURBO, temperature: 0, - openAIApiKey: session.apiKey, + openAIApiKey: apiKey, }), prompt: promptInjectionPrompt, outputKey: "promptInjectionEval", @@ -126,9 +133,9 @@ async function initPromptEvaluationModel(session) { ); const maliciousInputChain = new LLMChain({ llm: new OpenAI({ - model: "gpt-3.5-turbo", + modelName: CHAT_MODELS.GPT_3_5_TURBO, temperature: 0, - openAIApiKey: session.apiKey, + openAIApiKey: apiKey, }), prompt: maliciousInputPrompt, outputKey: "maliciousInputEval", @@ -143,7 +150,7 @@ async function initPromptEvaluationModel(session) { } // ask the question and return models answer -async function queryDocuments(question) { +async function queryDocuments(question: string) { if (!qaChain) { console.debug("QA chain not initialised."); return { reply: "", questionAnswered: false }; @@ -152,7 +159,7 @@ async function queryDocuments(question) { query: question, }); console.debug("QA model response: " + response.text); - const result = { + const result: ChatAnswer = { reply: response.text, questionAnswered: true, }; @@ -160,13 +167,15 @@ async function queryDocuments(question) { } // ask LLM whether the prompt is malicious -async function queryPromptEvaluationModel(input) { +async function queryPromptEvaluationModel(input: string) { if (!promptEvaluationChain) { console.debug("Prompt evaluation chain not initialised."); return { isMalicious: false, reason: "" }; } - const response = await promptEvaluationChain.call({ prompt: input }); + const response = await promptEvaluationChain.call({ + prompt: input, + }); const promptInjectionEval = formatEvaluationOutput( response.promptInjectionEval @@ -195,7 +204,7 @@ async function queryPromptEvaluationModel(input) { } // format the evaluation model output. text should be a Yes or No answer followed by a reason -function formatEvaluationOutput(response) { +function formatEvaluationOutput(response: string) { try { // split response on first full stop or comma const splitResponse = response.split(/\.|,/); @@ -210,14 +219,13 @@ function formatEvaluationOutput(response) { console.error(error); console.debug( "Did not get a valid response from the prompt evaluation model. Original response: " + - response.text + response ); return { isMalicious: false, reason: "" }; } } -module.exports = { - getDocuments, +export { initQAModel, initPromptEvaluationModel, queryDocuments, diff --git a/backend/src/models/chat.ts b/backend/src/models/chat.ts new file mode 100644 index 000000000..2da49a36a --- /dev/null +++ b/backend/src/models/chat.ts @@ -0,0 +1,58 @@ +import { ChatCompletionRequestMessage } from "openai"; + +enum CHAT_MODELS { + GPT_4 = "gpt-4", + GPT_4_0613 = "gpt-4-0613", + GPT_4_32K = "gpt-4-32k", + GPT_4_32K_0613 = "gpt-4-32k-0613", + GPT_3_5_TURBO = "gpt-3.5-turbo", + GPT_3_5_TURBO_0613 = "gpt-3.5-turbo-0613", + GPT_3_5_TURBO_16K = "gpt-3.5-turbo-16k", + GPT_3_5_TURBO_16K_0613 = "gpt-3.5-turbo-16k-0613", +} + +enum CHAT_MESSAGE_TYPE { + BOT, + INFO, + USER, + PHASE_INFO, +} + +interface ChatDefenceReport { + blockedReason: string | null; + isBlocked: boolean; + triggeredDefences: string[]; +} + +interface ChatAnswer { + reply: string; + questionAnswered: boolean; +} + +interface ChatMalicious { + isMalicious: boolean; + reason: string; +} + +interface ChatResponse { + completion: ChatCompletionRequestMessage; + defenceInfo: ChatDefenceReport; + wonPhase: boolean; +} + +interface ChatHttpResponse { + reply: string; + defenceInfo: ChatDefenceReport; + numPhasesCompleted: number; + transformedMessage: string; + wonPhase: boolean; +} + +export type { + ChatAnswer, + ChatDefenceReport, + ChatMalicious, + ChatResponse, + ChatHttpResponse, +}; +export { CHAT_MODELS, CHAT_MESSAGE_TYPE }; diff --git a/backend/src/models/defence.ts b/backend/src/models/defence.ts new file mode 100644 index 000000000..e5066c7e8 --- /dev/null +++ b/backend/src/models/defence.ts @@ -0,0 +1,32 @@ +enum DEFENCE_TYPES { + CHARACTER_LIMIT = "CHARACTER_LIMIT", + EMAIL_WHITELIST = "EMAIL_WHITELIST", + LLM_EVALUATION = "LLM_EVALUATION", + QA_LLM_INSTRUCTIONS = "QA_LLM_INSTRUCTIONS", + RANDOM_SEQUENCE_ENCLOSURE = "RANDOM_SEQUENCE_ENCLOSURE", + SYSTEM_ROLE = "SYSTEM_ROLE", + XML_TAGGING = "XML_TAGGING", +} + +interface DefenceConfig { + id: string; + value: string; +} + +class DefenceInfo { + constructor(id: DEFENCE_TYPES, config: DefenceConfig[]) { + this.id = id; + this.config = config; + // each defence starts off as inactive and not triggered + this.isActive = false; + this.isTriggered = false; + } + + id: DEFENCE_TYPES; + config: DefenceConfig[]; + isActive: boolean; + isTriggered: boolean; +} + +export { DEFENCE_TYPES, DefenceInfo }; +export type { DefenceConfig }; diff --git a/backend/src/models/email.ts b/backend/src/models/email.ts new file mode 100644 index 000000000..952b14dfb --- /dev/null +++ b/backend/src/models/email.ts @@ -0,0 +1,13 @@ +interface EmailInfo { + address: string; + subject: string; + content: string; +} + +interface EmailResponse { + response: string; + sentEmail: EmailInfo; + wonPhase: boolean; +} + +export type { EmailInfo, EmailResponse }; diff --git a/backend/src/models/phase.ts b/backend/src/models/phase.ts new file mode 100644 index 000000000..b2196a02d --- /dev/null +++ b/backend/src/models/phase.ts @@ -0,0 +1,8 @@ +enum PHASE_NAMES { + PHASE_0 = 0, + PHASE_1, + PHASE_2, + SANDBOX, +} + +export { PHASE_NAMES }; diff --git a/backend/src/openai.js b/backend/src/openai.js deleted file mode 100644 index 68cd1f877..000000000 --- a/backend/src/openai.js +++ /dev/null @@ -1,296 +0,0 @@ -const { Configuration, OpenAIApi } = require("openai"); -const { isDefenceActive, getSystemRole } = require("./defence"); -const { sendEmail, getEmailWhitelist, isEmailInWhitelist } = require("./email"); -const { - initQAModel, - initPromptEvaluationModel, - queryDocuments, - queryPromptEvaluationModel, -} = require("./langchain"); - -// OpenAI config -let config = null; -let openai = null; - -// functions available to ChatGPT -const chatGptFunctions = [ - { - name: "sendEmail", - description: "Send an email to someone", - parameters: { - type: "object", - properties: { - address: { - type: "string", - description: "The email address to send the email to", - }, - subject: { - type: "string", - description: "The subject of the email", - }, - body: { - type: "string", - description: "The body of the email", - }, - }, - required: ["address", "subject", "body"], - }, - }, - // { - // name: "getEmailWhitelist", - // description: - // "user asks who is on the email whitelist and the system replies with the list of emails.", - // parameters: { - // type: "object", - // properties: {}, - // }, - // }, - { - name: "askQuestion", - description: - "Ask a question about the documents with company and project information ", - parameters: { - type: "object", - properties: { - question: { - type: "string", - description: "The question asked about the documents", - }, - }, - }, - }, -]; - -// test the api key works with the model -async function validateApiKey(apiKey, gptModel) { - try { - const testOpenAI = new OpenAIApi(new Configuration({ apiKey: apiKey })); - const response = await testOpenAI.createChatCompletion({ - model: gptModel, - messages: [{ role: "user", content: "this is a test prompt" }], - }); - return true; - } catch (error) { - console.debug("Error validating API key: " + error); - return false; - } -} - -async function setOpenAiApiKey(session, apiKey) { - // initialise all models with the new key - if (await validateApiKey(apiKey, session.gptModel)) { - console.debug("Setting API key and initialising models"); - session.apiKey = apiKey; - initOpenAi(session); - initQAModel(session, session.currentPhase); - initPromptEvaluationModel(session); - return true; - } else { - // set to empty in case it was previously set - console.debug("Invalid API key. Cannot initialise OpenAI models"); - session.apiKey = ""; - openai = null; - return false; - } -} - -function initOpenAi(session) { - configuration = new Configuration({ - apiKey: session.apiKey, - }); - openai = new OpenAIApi(configuration); - console.debug("OpenAI initialised"); -} - -async function setGptModel(session, model) { - if (model !== session.gptModel) { - if (await validateApiKey(session.apiKey, model)) { - console.debug( - "Setting GPT model from: " + session.gptModel + " to: " + model - ); - session.gptModel = model; - return true; - } else { - console.debug("Could not validate apiKey with model=" + model); - return false; - } - } -} - -// returns true if the function is in the list of functions available to ChatGPT -function isChatGptFunction(functionName) { - return chatGptFunctions.find((func) => func.name === functionName); -} - -async function chatGptCallFunction( - functionCall, - defenceInfo, - currentPhase, - session -) { - let reply = null; - let wonPhase = null; - // get the function name - const functionName = functionCall.name; - - // check if we know the function - if (isChatGptFunction(functionName)) { - // get the function parameters - const params = JSON.parse(functionCall.arguments); - console.debug("Function call: " + functionName); - let response = null; - - // call the function - if (functionName === "sendEmail") { - let isAllowedToSendEmail = false; - if (isEmailInWhitelist(params.address, session.defences)) { - isAllowedToSendEmail = true; - } else { - // trigger email defence even if it is not active - defenceInfo.triggeredDefences.push("EMAIL_WHITELIST"); - if (isDefenceActive("EMAIL_WHITELIST", session.defences)) { - // do not send email if defence is on and set to blocked - response = "Cannot send to this email as it is not whitelisted"; - defenceInfo.blocked = true; - } else { - // send email if defence is not active - isAllowedToSendEmail = true; - } - } - - if (isAllowedToSendEmail) { - const emailResponse = sendEmail( - params.address, - params.subject, - params.body, - session, - currentPhase - ); - response = emailResponse.response; - wonPhase = emailResponse.wonPhase; - } - } else if (functionName == "getEmailWhitelist") { - response = getEmailWhitelist(session.defences); - } - if (functionName === "askQuestion") { - console.debug("Asking question: " + params.question); - // if asking a question, call the queryDocuments - response = (await queryDocuments(params.question)).reply; - } - - // add function call to chat - reply = { - role: "function", - content: response, - name: functionName, - }; - } else { - console.error("Unknown function: " + functionName); - } - return { reply, wonPhase, defenceInfo }; -} - -async function chatGptChatCompletion(session, currentPhase) { - // check if we need to set a system role - // system role is always active on phases - if (currentPhase <= 2 || isDefenceActive("SYSTEM_ROLE", session.defences)) { - // check to see if there's already a system role - if (!session.chatHistory.find((message) => message.role === "system")) { - // add the system role to the start of the chat history - session.chatHistory.unshift({ - role: "system", - content: getSystemRole(session.defences, currentPhase), - }); - } - } else { - // remove the system role from the chat history - session.chatHistory = session.chatHistory.filter( - (message) => message.role !== "system" - ); - } - - // make sure openai has been initialised - if (!openai) { - console.debug("OpenAI not initialised with api key"); - return { - role: "assistant", - content: "Please enter a valid OpenAI API key to chat to me!", - }; - } - - chat_completion = await openai.createChatCompletion({ - model: session.gptModel, - messages: session.chatHistory, - functions: chatGptFunctions, - }); - - // get the reply - return chat_completion.data.choices[0].message; -} - -async function chatGptSendMessage(message, session, currentPhase) { - // init defence info - let defenceInfo = { triggeredDefences: [], blocked: false }; - let wonPhase = false; - - // evaluate the message for prompt injection - // to speed up replies, only do this on phases where defences are active - if (currentPhase >= 2) { - const evalPrompt = await queryPromptEvaluationModel(message); - if (evalPrompt.isMalicious) { - defenceInfo.triggeredDefences.push("LLM_EVALUATION"); - if (isDefenceActive("LLM_EVALUATION", session.defences)) { - console.debug("LLM evalutation defence active."); - defenceInfo.blocked = true; - const evalResponse = - "Message blocked by the malicious prompt evaluator." + - evalPrompt.reason; - return { reply: evalResponse, defenceInfo: defenceInfo }; - } - } - } - - // add user message to chat - session.chatHistory.push({ role: "user", content: message }); - - let reply = await chatGptChatCompletion(session, currentPhase); - // check if GPT wanted to call a function - while (reply.function_call) { - session.chatHistory.push(reply); - - // call the function and get a new reply and defence info from - const functionCallReply = await chatGptCallFunction( - reply.function_call, - defenceInfo, - currentPhase, - session - ); - wonPhase = functionCallReply.wonPhase; - // add the function call to the chat history - session.chatHistory.push(functionCallReply.reply); - // update the defence info - defenceInfo = functionCallReply.defenceInfo; - - // get a new reply from ChatGPT now that the function has been called - reply = await chatGptChatCompletion(session, currentPhase); - } - // add the ai reply to the chat history - session.chatHistory.push(reply); - - // log the entire chat history so far - console.log(session.chatHistory); - // return the reply content - return { - reply: reply.content, - wonPhase: wonPhase, - defenceInfo: defenceInfo, - }; -} - -module.exports = { - initOpenAi, - chatGptSendMessage, - setOpenAiApiKey, - validateApiKey, - setGptModel, -}; diff --git a/backend/src/openai.ts b/backend/src/openai.ts new file mode 100644 index 000000000..466919842 --- /dev/null +++ b/backend/src/openai.ts @@ -0,0 +1,346 @@ +import { Session } from "express-session"; + +import { isDefenceActive, getSystemRole } from "./defence"; +import { sendEmail, getEmailWhitelist, isEmailInWhitelist } from "./email"; +import { + initQAModel, + initPromptEvaluationModel, + queryDocuments, +} from "./langchain"; +import { EmailInfo, EmailResponse } from "./models/email"; +import { + ChatCompletionRequestMessage, + ChatCompletionRequestMessageFunctionCall, + Configuration, + OpenAIApi, +} from "openai"; +import { CHAT_MODELS, ChatDefenceReport } from "./models/chat"; +import { DefenceInfo } from "./models/defence"; +import { PHASE_NAMES } from "./models/phase"; + +// OpenAI config +let config: Configuration | null = null; +let openai: OpenAIApi | null = null; + +// functions available to ChatGPT +const chatGptFunctions = [ + { + name: "sendEmail", + description: "Send an email to someone", + parameters: { + type: "object", + properties: { + address: { + type: "string", + description: "The email address to send the email to", + }, + subject: { + type: "string", + description: "The subject of the email", + }, + body: { + type: "string", + description: "The body of the email", + }, + }, + required: ["address", "subject", "body"], + }, + }, + // { + // name: "getEmailWhitelist", + // description: + // "user asks who is on the email whitelist and the system replies with the list of emails.", + // parameters: { + // type: "object", + // properties: {}, + // }, + // }, + { + name: "askQuestion", + description: + "Ask a question about the documents with company and project information ", + parameters: { + type: "object", + properties: { + question: { + type: "string", + description: "The question asked about the documents", + }, + }, + }, + }, +]; + +// test the api key works with the model +async function validateApiKey(apiKey: string, gptModel: string) { + try { + const testOpenAI: OpenAIApi = new OpenAIApi( + new Configuration({ apiKey: apiKey }) + ); + await testOpenAI.createChatCompletion({ + model: gptModel, + messages: [{ role: "user", content: "this is a test prompt" }], + }); + return true; + } catch (error) { + console.debug("Error validating API key: " + error); + return false; + } +} + +async function setOpenAiApiKey( + apiKey: string, + gptModel: string, + prePrompt: string, + // default to sandbox mode + currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX +) { + // initialise all models with the new key + if (await validateApiKey(apiKey, gptModel)) { + console.debug("Setting API key and initialising models"); + initOpenAi(apiKey); + initQAModel(apiKey, prePrompt, currentPhase); + initPromptEvaluationModel(apiKey); + return true; + } else { + // set to empty in case it was previously set + console.debug("Invalid API key. Cannot initialise OpenAI models"); + openai = null; + return false; + } +} + +function initOpenAi(openAiApiKey: string) { + config = new Configuration({ + apiKey: openAiApiKey, + }); + openai = new OpenAIApi(config); + console.debug("OpenAI initialised"); +} + +async function setGptModel(session: Session, model: CHAT_MODELS) { + if (model !== session.gptModel) { + if (await validateApiKey(session.apiKey, model)) { + console.debug( + "Setting GPT model from: " + session.gptModel + " to: " + model + ); + session.gptModel = model; + return true; + } else { + console.debug("Could not validate apiKey with model=" + model); + return false; + } + } + return false; +} + +// returns true if the function is in the list of functions available to ChatGPT +function isChatGptFunction(functionName: string) { + return chatGptFunctions.find((func) => func.name === functionName); +} + +async function chatGptCallFunction( + defenceInfo: ChatDefenceReport, + defences: DefenceInfo[], + functionCall: ChatCompletionRequestMessageFunctionCall, + sentEmails: EmailInfo[], + // default to sandbox + currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX +) { + let reply: ChatCompletionRequestMessage | null = null; + let wonPhase: boolean = false; + // get the function name + const functionName: string = functionCall.name || ""; + + // check if we know the function + if (isChatGptFunction(functionName)) { + // get the function parameters + const params = functionCall.arguments + ? JSON.parse(functionCall.arguments) + : {}; + console.debug("Function call: " + functionName); + let response: string = ""; + + // call the function + if (functionName === "sendEmail") { + let isAllowedToSendEmail = false; + if (isEmailInWhitelist(params.address, defences)) { + isAllowedToSendEmail = true; + } else { + // trigger email defence even if it is not active + defenceInfo.triggeredDefences.push("EMAIL_WHITELIST"); + if (isDefenceActive("EMAIL_WHITELIST", defences)) { + // do not send email if defence is on and set to blocked + defenceInfo.isBlocked = true; + defenceInfo.blockedReason = + "Cannot send to this email as it is not whitelisted"; + } else { + // send email if defence is not active + isAllowedToSendEmail = true; + } + } + + if (isAllowedToSendEmail) { + const emailResponse: EmailResponse = sendEmail( + params.address, + params.subject, + params.body, + currentPhase + ); + response = emailResponse.response; + wonPhase = emailResponse.wonPhase; + // add the sent email to the session + sentEmails.push(emailResponse.sentEmail); + } + } else if (functionName == "getEmailWhitelist") { + response = getEmailWhitelist(defences); + } + if (functionName === "askQuestion") { + console.debug("Asking question: " + params.question); + // if asking a question, call the queryDocuments + response = (await queryDocuments(params.question)).reply; + } + + reply = { + role: "function", + content: response, + name: functionName, + }; + } else { + console.error("Unknown function: " + functionName); + } + + if (reply) { + return { + completion: reply, + defenceInfo: defenceInfo, + wonPhase: wonPhase, + }; + } else { + return null; + } +} + +async function chatGptChatCompletion( + chatHistory: ChatCompletionRequestMessage[], + defences: DefenceInfo[], + gptModel: CHAT_MODELS, + // default to sandbox + currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX +) { + // make sure openai is initialised + if (!openai) { + console.error("OpenAI not initialised"); + return null; + } + + // check if we need to set a system role + // system role is always active on phases + if ( + currentPhase !== PHASE_NAMES.SANDBOX || + isDefenceActive("SYSTEM_ROLE", defences) + ) { + // check to see if there's already a system role + if (!chatHistory.find((message) => message.role === "system")) { + // add the system role to the start of the chat history + chatHistory.unshift({ + role: "system", + content: getSystemRole(defences, currentPhase), + }); + } + } else { + // remove the system role from the chat history + while (chatHistory.length > 0 && chatHistory[0].role === "system") { + chatHistory.shift(); + } + } + + const chat_completion = await openai.createChatCompletion({ + model: gptModel, + messages: chatHistory, + functions: chatGptFunctions, + }); + + // get the reply + return chat_completion.data.choices[0].message || null; +} + +async function chatGptSendMessage( + chatHistory: ChatCompletionRequestMessage[], + defences: DefenceInfo[], + gptModel: CHAT_MODELS, + message: string, + sentEmails: EmailInfo[], + // default to sandbox + currentPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX +) { + // init defence info + let defenceInfo: ChatDefenceReport = { + blockedReason: "", + isBlocked: false, + triggeredDefences: [], + }; + let wonPhase: boolean | undefined | null = false; + + // add user message to chat + chatHistory.push({ role: "user", content: message }); + + let reply = await chatGptChatCompletion( + chatHistory, + defences, + gptModel, + currentPhase + ); + // check if GPT wanted to call a function + while (reply && reply.function_call) { + chatHistory.push(reply); + + // call the function and get a new reply and defence info from + const functionCallReply = await chatGptCallFunction( + defenceInfo, + defences, + reply.function_call, + sentEmails, + currentPhase + ); + if (functionCallReply) { + wonPhase = functionCallReply.wonPhase; + // add the function call to the chat history + if (functionCallReply.completion !== undefined) { + chatHistory.push(functionCallReply.completion); + } + // update the defence info + defenceInfo = functionCallReply.defenceInfo; + } + + // get a new reply from ChatGPT now that the function has been called + reply = await chatGptChatCompletion( + chatHistory, + defences, + gptModel, + currentPhase + ); + } + + if (reply && reply.content) { + // add the ai reply to the chat history + chatHistory.push(reply); + // log the entire chat history so far + console.log(chatHistory); + return { + completion: reply, + defenceInfo: defenceInfo, + wonPhase: wonPhase, + }; + } else { + return null; + } +} + +export { + initOpenAi, + chatGptSendMessage, + setOpenAiApiKey, + validateApiKey, + setGptModel, +}; diff --git a/backend/src/promptTemplates.js b/backend/src/promptTemplates.ts similarity index 99% rename from backend/src/promptTemplates.js rename to backend/src/promptTemplates.ts index 0e330847e..ad6239ea3 100644 --- a/backend/src/promptTemplates.js +++ b/backend/src/promptTemplates.ts @@ -59,7 +59,7 @@ const maliciousPromptTemplate = `You are a user input detection tool who will an Answer a single sentence yes or no only, followed by a full stop, then a new sentence with your reason. `; -module.exports = { +export { qAcontextTemplate, retrievalQAPrePrompt, retrievalQAPrePromptSecure, diff --git a/backend/src/router.js b/backend/src/router.js deleted file mode 100644 index f32614347..000000000 --- a/backend/src/router.js +++ /dev/null @@ -1,240 +0,0 @@ -const express = require("express"); -const { - activateDefence, - deactivateDefence, - configureDefence, - transformMessage, - detectTriggeredDefences, - getQALLMprePrompt, -} = require("./defence"); -const { - chatGptSendMessage, - setOpenAiApiKey, - setGptModel, -} = require("./openai"); -const { getInitialDefences } = require("./defence"); -const { initQAModel } = require("./langchain"); -const { retrievalQAPrePrompt } = require("./promptTemplates"); -const router = express.Router(); - -// keep track of phase change to reinitialize models -let prevPhase = 3; - -// Activate a defence -router.post("/defence/activate", (req, res, next) => { - // id of the defence - const defenceId = req.body?.defenceId; - if (defenceId) { - // activate the defence - req.session.defences = activateDefence(defenceId, req.session.defences); - - // need to re-initialize QA model when turned on - if (defenceId === "QA_LLM_INSTRUCTIONS") { - console.debug( - "Activating qa llm instruction defence - reinitializing qa model" - ); - initQAModel( - req.session, - req.session.currentPhase, - getQALLMprePrompt(req.session.defences) - ); - } - - res.send("Defence activated"); - } else { - res.statusCode = 400; - res.send("Missing defenceId"); - } -}); - -// Deactivate a defence -router.post("/defence/deactivate", (req, res, next) => { - // id of the defence - const defenceId = req.body?.defenceId; - if (defenceId) { - // deactivate the defence - req.session.defences = deactivateDefence(defenceId, req.session.defences); - - if (defenceId === "QA_LLM_INSTRUCTIONS") { - console.debug("Resetting QA model with default prompt"); - initQAModel(req.session, req.session.currentPhase); - } - res.send("Defence deactivated"); - } else { - res.statusCode = 400; - res.send("Missing defenceId"); - } -}); - -// Configure a defence -router.post("/defence/configure", (req, res, next) => { - // id of the defence - const defenceId = req.body?.defenceId; - const config = req.body?.config; - if (defenceId && config) { - // configure the defence - req.session.defences = configureDefence( - defenceId, - req.session.defences, - config - ); - res.send("Defence configured"); - } else { - res.statusCode = 400; - res.send("Missing defenceId or config"); - } -}); - -// Get the status of all defences -router.get("/defence/status", (req, res, next) => { - res.send(req.session.defences); -}); - -// reset the active defences -router.post("/defence/reset", (req, res, next) => { - req.session.defences = getInitialDefences(); - console.debug("Defences reset"); - res.send("Defences reset"); -}); - -// Get sent emails -router.get("/email/get", (req, res, next) => { - res.send(req.session.sentEmails); -}); - -// clear emails -router.post("/email/clear", (req, res, next) => { - req.session.sentEmails = []; - res.send("Emails cleared"); -}); - -// Chat to ChatGPT -router.post("/openai/chat", async (req, res, next) => { - // set reply params - let reply = ""; - let defenceInfo = { blocked: false, triggeredDefences: [] }; - let transformedMessage = ""; - - // whether the phase has been won by sending correct email - let wonPhase = false; - // parse out the message - const message = req.body?.message; - const currentPhase = req.body?.currentPhase; - let numPhasesCompleted = req.session.numPhasesCompleted; - - // if phase has changed, reinitialize the QA model with with new filepath - if (prevPhase != currentPhase) { - prevPhase = currentPhase; - initQAModel(req.session, currentPhase, retrievalQAPrePrompt); - } - - if (message) { - transformedMessage = message; - // see if this message triggers any defences - const detectReply = detectTriggeredDefences(message, req.session.defences); - reply = detectReply.reply; - defenceInfo = detectReply.defenceInfo; - // if blocked, send the response - if (!defenceInfo.blocked) { - // transform the message according to active defences - transformedMessage = transformMessage(message, req.session.defences); - // get the chatGPT reply - try { - const openAiReply = await chatGptSendMessage( - transformedMessage, - req.session, - currentPhase - ); - wonPhase = openAiReply.wonPhase; - - reply = openAiReply.reply; - // combine triggered defences - defenceInfo.triggeredDefences = [ - ...defenceInfo.triggeredDefences, - ...openAiReply.defenceInfo.triggeredDefences, - ]; - // combine blocked - defenceInfo.blocked = - defenceInfo.blocked || openAiReply.defenceInfo.blocked; - } catch (error) { - console.log(error); - if (error.response?.status == 401) { - res.statusCode = 401; - reply = "Please enter a valid OpenAI API key to chat to me!"; - } else { - res.statusCode = 500; - console.log(error); - reply = "Failed to get chatGPT reply"; - } - } - } - } else { - res.statusCode = 400; - reply = "Missing message"; - console.error(reply); - } - // enable next phase when user wins current phase - if (wonPhase) { - console.log("Win conditon met for phase: ", currentPhase); - numPhasesCompleted = currentPhase + 1; - req.session.numPhasesCompleted = numPhasesCompleted; - } - // construct response - const response = { - reply, - defenceInfo, - transformedMessage, - numPhasesCompleted, - wonPhase, - }; - // log and send the reply with defence info - console.log(response); - res.send(response); -}); - -// Clear the ChatGPT messages -router.post("/openai/clear", (req, res, next) => { - req.session.chatHistory = []; - res.send("ChatGPT messages cleared"); -}); - -// Set API key -router.post("/openai/apiKey", async (req, res, next) => { - const apiKey = req.body?.apiKey; - if (!apiKey) { - res.status(401).send("Invalid API key"); - return; - } - if (await setOpenAiApiKey(req.session, apiKey)) { - res.send("API key set"); - } else { - res.status(401).send("Invalid API key"); - } -}); - -// Get API key -router.get("/openai/apiKey", (req, res, next) => { - res.send(req.session.apiKey); -}); - -// Set the ChatGPT model -router.post("/openai/model", async (req, res, next) => { - const model = req.body?.model; - if (model) { - if (await setGptModel(req.session, model)) { - res.status(200).send("ChatGPT model set. "); - } else { - res.status(401).send("Could not set model"); - } - } -}); - -router.get("/openai/model", (req, res, next) => { - res.send(req.session.gptModel); -}); - -router.get("/phase/completed", (req, res, next) => { - res.send(req.session.numPhasesCompleted.toString()); -}); - -module.exports = router; diff --git a/backend/src/router.ts b/backend/src/router.ts new file mode 100644 index 000000000..5d2700371 --- /dev/null +++ b/backend/src/router.ts @@ -0,0 +1,259 @@ +import express from "express"; + +import { + activateDefence, + deactivateDefence, + configureDefence, + transformMessage, + detectTriggeredDefences, + getQALLMprePrompt, + getInitialDefences, +} from "./defence"; +import { initQAModel } from "./langchain"; +import { CHAT_MODELS, ChatHttpResponse } from "./models/chat"; +import { DefenceConfig } from "./models/defence"; +import { chatGptSendMessage, setOpenAiApiKey, setGptModel } from "./openai"; +import { retrievalQAPrePrompt } from "./promptTemplates"; +import { PHASE_NAMES } from "./models/phase"; + +const router = express.Router(); + +// keep track of phase change to reinitialize models +let prevPhase: PHASE_NAMES = PHASE_NAMES.SANDBOX; + +// Activate a defence +router.post("/defence/activate", (req, res) => { + // id of the defence + const defenceId: string = req.body?.defenceId; + if (defenceId) { + // activate the defence + req.session.defences = activateDefence(defenceId, req.session.defences); + + // need to re-initialize QA model when turned on + if (defenceId === "QA_LLM_INSTRUCTIONS") { + console.debug( + "Activating qa llm instruction defence - reinitializing qa model" + ); + initQAModel(req.session.apiKey, getQALLMprePrompt(req.session.defences)); + } + + res.send("Defence activated"); + } else { + res.statusCode = 400; + res.send("Missing defenceId"); + } +}); + +// Deactivate a defence +router.post("/defence/deactivate", (req, res) => { + // id of the defence + const defenceId: string = req.body?.defenceId; + if (defenceId) { + // deactivate the defence + req.session.defences = deactivateDefence(defenceId, req.session.defences); + + if (defenceId === "QA_LLM_INSTRUCTIONS") { + console.debug("Resetting QA model with default prompt"); + initQAModel(req.session.apiKey, getQALLMprePrompt(req.session.defences)); + } + res.send("Defence deactivated"); + } else { + res.statusCode = 400; + res.send("Missing defenceId"); + } +}); + +// Configure a defence +router.post("/defence/configure", (req, res) => { + // id of the defence + const defenceId: string = req.body?.defenceId; + const config: DefenceConfig[] = req.body?.config; + if (defenceId && config) { + // configure the defence + req.session.defences = configureDefence( + defenceId, + req.session.defences, + config + ); + res.send("Defence configured"); + } else { + res.statusCode = 400; + res.send("Missing defenceId or config"); + } +}); + +// reset the active defences +router.post("/defence/reset", (req, res) => { + req.session.defences = getInitialDefences(); + console.debug("Defences reset"); + res.send("Defences reset"); +}); + +// Get the status of all defences +router.get("/defence/status", (req, res) => { + res.send(req.session.defences); +}); + +// Get sent emails +router.get("/email/get", (req, res) => { + res.send(req.session.sentEmails); +}); + +// clear emails +router.post("/email/clear", (req, res) => { + req.session.sentEmails = []; + res.send("Emails cleared"); +}); + +// Chat to ChatGPT +router.post("/openai/chat", async (req, res) => { + // set reply params + const chatResponse: ChatHttpResponse = { + reply: "", + defenceInfo: { + blockedReason: "", + isBlocked: false, + triggeredDefences: [], + }, + numPhasesCompleted: req.session.numPhasesCompleted, + transformedMessage: "", + wonPhase: false, + }; + + // parse out the message + const message: string = req.body?.message; + const currentPhase: PHASE_NAMES = req.body?.currentPhase; + let numPhasesCompleted = req.session.numPhasesCompleted; + + // if phase has changed, reinitialize the QA model with with new filepath + if (prevPhase != currentPhase) { + prevPhase = currentPhase; + initQAModel(req.session.apiKey, retrievalQAPrePrompt, currentPhase); + } + + if (message) { + chatResponse.transformedMessage = message; + // see if this message triggers any defences + const useLlmEvaluation = + currentPhase === PHASE_NAMES.PHASE_2 || + currentPhase === PHASE_NAMES.SANDBOX; + chatResponse.defenceInfo = await detectTriggeredDefences( + message, + req.session.defences, + useLlmEvaluation + ); + // if blocked, send the response + if (!chatResponse.defenceInfo.isBlocked) { + // transform the message according to active defences + chatResponse.transformedMessage = transformMessage( + message, + req.session.defences + ); + + // get the chatGPT reply + try { + const openAiReply = await chatGptSendMessage( + req.session.chatHistory, + req.session.defences, + req.session.gptModel, + chatResponse.transformedMessage, + req.session.sentEmails, + currentPhase + ); + + if (openAiReply) { + chatResponse.wonPhase = openAiReply.wonPhase; + chatResponse.reply = openAiReply.completion.content || ""; + // combine triggered defences + chatResponse.defenceInfo.triggeredDefences = [ + ...chatResponse.defenceInfo.triggeredDefences, + ...openAiReply.defenceInfo.triggeredDefences, + ]; + // combine blocked + chatResponse.defenceInfo.isBlocked = + chatResponse.defenceInfo.isBlocked || + openAiReply.defenceInfo.isBlocked; + } + } catch (error: any) { + console.log(error); + if (error.response?.status == 401) { + res.statusCode = 401; + chatResponse.reply = + "Please enter a valid OpenAI API key to chat to me!"; + } else { + res.statusCode = 500; + console.log(error); + chatResponse.reply = "Failed to get chatGPT reply"; + } + } + } + } else { + res.statusCode = 400; + chatResponse.reply = "Missing message"; + console.error(chatResponse.reply); + } + // enable next phase when user wins current phase + if (chatResponse.wonPhase) { + console.log("Win conditon met for phase: ", currentPhase); + numPhasesCompleted = currentPhase + 1; + req.session.numPhasesCompleted = numPhasesCompleted; + chatResponse.numPhasesCompleted = numPhasesCompleted; + } + // log and send the reply with defence info + console.log(chatResponse); + res.send(chatResponse); +}); + +// Clear the ChatGPT messages +router.post("/openai/clear", (req, res) => { + req.session.chatHistory = []; + res.send("ChatGPT messages cleared"); +}); + +// Set API key +router.post("/openai/apiKey", async (req, res) => { + const apiKey: string = req.body?.apiKey; + if (!apiKey) { + res.status(401).send("Invalid API key"); + return; + } + if ( + await setOpenAiApiKey( + apiKey, + req.session.gptModel, + getQALLMprePrompt(req.session.defences) + ) + ) { + req.session.apiKey = apiKey; + res.send("API key set"); + } else { + res.status(401).send("Invalid API key"); + } +}); + +// Get API key +router.get("/openai/apiKey", (req, res) => { + res.send(req.session.apiKey); +}); + +// Set the ChatGPT model +router.post("/openai/model", async (req, res) => { + const model: CHAT_MODELS = req.body?.model; + if (model) { + if (await setGptModel(req.session, model)) { + res.status(200).send("ChatGPT model set. "); + } else { + res.status(401).send("Could not set model"); + } + } +}); + +router.get("/openai/model", (req, res) => { + res.send(req.session.gptModel); +}); + +router.get("/phase/completed", (req, res) => { + res.send(req.session.numPhasesCompleted.toString()); +}); + +export { router }; diff --git a/backend/test/integration/documents.test.js b/backend/test/integration/documents.test.js deleted file mode 100644 index 2b8052e90..000000000 --- a/backend/test/integration/documents.test.js +++ /dev/null @@ -1,88 +0,0 @@ -const { DirectoryLoader } = require("langchain/document_loaders/fs/directory"); -const { RecursiveCharacterTextSplitter } = require("langchain/text_splitter"); -const { OpenAIEmbeddings } = require("langchain/embeddings/openai"); -const { MemoryVectorStore } = require("langchain/vectorstores/memory"); -const { ChatOpenAI } = require("langchain/chat_models/openai"); -const { RetrievalQAChain } = require("langchain/chains"); -const { PromptTemplate } = require("langchain/prompts"); -const { getDocuments } = require("../../src/langchain"); - -// mock the directory loader -jest.mock("langchain/document_loaders/fs/directory"); -const mockLoaderLoad = jest.fn(); -DirectoryLoader.mockImplementation(() => { - return { - load: mockLoaderLoad, - }; -}); - -// mock the recursive text splitter -jest.mock("langchain/text_splitter"); -const mockSplitterSplitDocuments = jest.fn(); -RecursiveCharacterTextSplitter.mockImplementation(() => { - return { - splitDocuments: mockSplitterSplitDocuments, - } -}); - -// mock the memory vector store -jest.mock("langchain/vectorstores/memory"); -MemoryVectorStore.fromDocuments.mockImplementation(async () => { - console.log("Mocked memory vector store from documents"); - return mockVectorStore; -}); - -// mock the embeddings -jest.mock("langchain/embeddings/openai"); -const mockEmbeddings = jest.fn(); -OpenAIEmbeddings.mockImplementation(() => { - return { - embedDocuments: ["23456", "23456", "23456"], - } -}); - -// mock the chat model -jest.mock("langchain/chat_models/openai"); -const mockChatOpenAI = jest.fn(); -ChatOpenAI.mockImplementation(() => { - return { - openAIApiKey: "key", - } -}); - -// mock the retrieval QA chain -jest.mock("langchain/chains"); -const mockRetrievalQAChain = new RetrievalQAChain({ "model": "gpt-4" }); -RetrievalQAChain.fromLLM.mockImplementation(() => { - return mockRetrievalQAChain; -}); - -// mock the prompt template -jest.mock("langchain/prompts"); -PromptTemplate.fromTemplate.mockImplementation(() => { - return { - prompt: "You are a helpful chatbot who answers questions about the documents", - } -}); - -test("get documents loads files and splits into chunks", async () => { - mockLoaderLoad.mockResolvedValueOnce( - ["Bob is the CEO. He earns 30000 a year.", "Karen is getting a raise of 20%."]) - mockSplitterSplitDocuments.mockResolvedValueOnce(["Bob is the CEO.", "He earns 30000 a year.", "Karen is getting a raise of 20%."]); - const documents = await getDocuments(); - expect(documents.length).toBe(3); - expect(mockLoaderLoad).toHaveBeenCalledTimes(1); - expect(mockSplitterSplitDocuments).toHaveBeenCalledTimes(1); - - mockLoaderLoad.mockRestore(); - mockSplitterSplitDocuments.mockRestore(); -}); - - -test("initQAModel loads documents and creates a QA chain", async () => { - // to be implemented -}); - -test("queryDocuments calls the QA chain and returns a text response", async () => { - // to be implemented -}); \ No newline at end of file diff --git a/backend/test/integration/openai.test.js b/backend/test/integration/openai.test.ts similarity index 52% rename from backend/test/integration/openai.test.js rename to backend/test/integration/openai.test.ts index 3d8ffc3d7..886a58cf2 100644 --- a/backend/test/integration/openai.test.js +++ b/backend/test/integration/openai.test.ts @@ -1,55 +1,59 @@ -const { activateDefence, getInitialDefences } = require("../../src/defence"); -const { initOpenAi, chatGptSendMessage } = require("../../src/openai"); -const { OpenAIApi } = require("openai"); -const { queryPromptEvaluationModel } = require("../../src/langchain"); - -// Mock the OpenAIApi module -jest.mock("openai"); +import { ChatCompletionRequestMessage } from "openai"; +import { activateDefence, getInitialDefences } from "../../src/defence"; +import { CHAT_MODELS } from "../../src/models/chat"; +import { initOpenAi, chatGptSendMessage } from "../../src/openai"; +import { DefenceInfo } from "../../src/models/defence"; +import { EmailInfo } from "../../src/models/email"; + +// Define a mock implementation for the createChatCompletion method const mockCreateChatCompletion = jest.fn(); -// Create a mock instance -OpenAIApi.mockImplementation(() => { - return { +// Mock the OpenAIApi class +jest.mock("openai", () => ({ + OpenAIApi: jest.fn().mockImplementation(() => ({ createChatCompletion: mockCreateChatCompletion, - }; -}); + })), + Configuration: jest.fn().mockImplementation(() => ({})), +})); -// bypass the prompt evaluation model -jest.mock("../../src/langchain"); -const mockEvalReturn = jest.fn(); -queryPromptEvaluationModel.mockImplementation(() => { - return mockEvalReturn; -}); - -beforeEach(() => { - mockEvalReturn.mockResolvedValueOnce({ isMalicious: false, reason: "" }); +// mock the queryPromptEvaluationModel function +jest.mock("../../src/langchain", () => { + const originalModule = jest.requireActual("../../src/langchain"); + return { + ...originalModule, + queryPromptEvaluationModel: () => { + return { + isMalicious: false, + reason: "", + }; + }, + }; }); test("GIVEN OpenAI not initialised WHEN sending message THEN error is thrown", async () => { const message = "Hello"; - const session = { - chatHistory: [], - sentEmails: [], - apiKey: "", - gptModel: "gpt-4", - defences: [], - }; - - const reply = await chatGptSendMessage(message, session); - expect(reply).toBeDefined(); - expect(reply.reply).toBe( - "Please enter a valid OpenAI API key to chat to me!" + const chatHistory: ChatCompletionRequestMessage[] = []; + const defences: DefenceInfo[] = []; + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails ); + + expect(reply).toBeNull(); }); test("GIVEN OpenAI initialised WHEN sending message THEN reply is returned", async () => { const message = "Hello"; - const session = { - defences: [], - chatHistory: [], - sentEmails: [], - apiKey: "sk-12345", - gptModel: "gpt-4", - }; + const chatHistory: ChatCompletionRequestMessage[] = []; + const defences: DefenceInfo[] = []; + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; // Mock the createChatCompletion function mockCreateChatCompletion.mockResolvedValueOnce({ @@ -66,17 +70,25 @@ test("GIVEN OpenAI initialised WHEN sending message THEN reply is returned", asy }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); + expect(reply).toBeDefined(); - expect(reply.reply).toBe("Hi"); + expect(reply?.completion).toBeDefined(); + expect(reply?.completion.content).toBe("Hi"); // check the chat history has been updated - expect(session.chatHistory.length).toBe(2); - expect(session.chatHistory[0].role).toBe("user"); - expect(session.chatHistory[0].content).toBe("Hello"); - expect(session.chatHistory[1].role).toBe("assistant"); - expect(session.chatHistory[1].content).toBe("Hi"); + expect(chatHistory.length).toBe(2); + expect(chatHistory[0].role).toBe("user"); + expect(chatHistory[0].content).toBe("Hello"); + expect(chatHistory[1].role).toBe("assistant"); + expect(chatHistory[1].content).toBe("Hi"); // restore the mock mockCreateChatCompletion.mockRestore(); @@ -87,13 +99,13 @@ test("GIVEN SYSTEM_ROLE defence is active WHEN sending message THEN system role process.env.SYSTEM_ROLE = "You are a helpful assistant"; const message = "Hello"; - const session = { - defences: getInitialDefences(), - chatHistory: [], - sentEmails: [], - apiKey: "sk-12345", - }; - session.defences = activateDefence("SYSTEM_ROLE", session.defences); + const chatHistory: ChatCompletionRequestMessage[] = []; + let defences: DefenceInfo[] = getInitialDefences(); + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; + + defences = activateDefence("SYSTEM_ROLE", defences); // Mock the createChatCompletion function mockCreateChatCompletion.mockResolvedValueOnce({ @@ -110,20 +122,27 @@ test("GIVEN SYSTEM_ROLE defence is active WHEN sending message THEN system role }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); + expect(reply).toBeDefined(); - expect(reply.reply).toBe("Hi"); + expect(reply?.completion.content).toBe("Hi"); // check the chat history has been updated - expect(session.chatHistory.length).toBe(3); + expect(chatHistory.length).toBe(3); // system role is added to the start of the chat history - expect(session.chatHistory[0].role).toBe("system"); - expect(session.chatHistory[0].content).toBe(process.env.SYSTEM_ROLE); - expect(session.chatHistory[1].role).toBe("user"); - expect(session.chatHistory[1].content).toBe("Hello"); - expect(session.chatHistory[2].role).toBe("assistant"); - expect(session.chatHistory[2].content).toBe("Hi"); + expect(chatHistory[0].role).toBe("system"); + expect(chatHistory[0].content).toBe(process.env.SYSTEM_ROLE); + expect(chatHistory[1].role).toBe("user"); + expect(chatHistory[1].content).toBe("Hello"); + expect(chatHistory[2].role).toBe("assistant"); + expect(chatHistory[2].content).toBe("Hi"); // restore the mock mockCreateChatCompletion.mockRestore(); @@ -134,24 +153,23 @@ test("GIVEN SYSTEM_ROLE defence is active WHEN sending message THEN system role process.env.SYSTEM_ROLE = "You are a helpful assistant"; const message = "Hello"; - const session = { - defences: getInitialDefences(), - // add in some chat history - chatHistory: [ - { - role: "user", - content: "I'm a user", - }, - { - role: "assistant", - content: "I'm an assistant", - }, - ], - sentEmails: [], - apiKey: "sk-12345", - }; + const chatHistory: ChatCompletionRequestMessage[] = [ + { + role: "user", + content: "I'm a user", + }, + { + role: "assistant", + content: "I'm an assistant", + }, + ]; + let defences: DefenceInfo[] = getInitialDefences(); + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; + // activate the SYSTEM_ROLE defence - session.defences = activateDefence("SYSTEM_ROLE", session.defences); + defences = activateDefence("SYSTEM_ROLE", defences); // Mock the createChatCompletion function mockCreateChatCompletion.mockResolvedValueOnce({ @@ -168,25 +186,32 @@ test("GIVEN SYSTEM_ROLE defence is active WHEN sending message THEN system role }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); + expect(reply).toBeDefined(); - expect(reply.reply).toBe("Hi"); + expect(reply?.completion.content).toBe("Hi"); // check the chat history has been updated - expect(session.chatHistory.length).toBe(5); + expect(chatHistory.length).toBe(5); // system role is added to the start of the chat history - expect(session.chatHistory[0].role).toBe("system"); - expect(session.chatHistory[0].content).toBe(process.env.SYSTEM_ROLE); + expect(chatHistory[0].role).toBe("system"); + expect(chatHistory[0].content).toBe(process.env.SYSTEM_ROLE); // rest of the chat history is in order - expect(session.chatHistory[1].role).toBe("user"); - expect(session.chatHistory[1].content).toBe("I'm a user"); - expect(session.chatHistory[2].role).toBe("assistant"); - expect(session.chatHistory[2].content).toBe("I'm an assistant"); - expect(session.chatHistory[3].role).toBe("user"); - expect(session.chatHistory[3].content).toBe("Hello"); - expect(session.chatHistory[4].role).toBe("assistant"); - expect(session.chatHistory[4].content).toBe("Hi"); + expect(chatHistory[1].role).toBe("user"); + expect(chatHistory[1].content).toBe("I'm a user"); + expect(chatHistory[2].role).toBe("assistant"); + expect(chatHistory[2].content).toBe("I'm an assistant"); + expect(chatHistory[3].role).toBe("user"); + expect(chatHistory[3].content).toBe("Hello"); + expect(chatHistory[4].role).toBe("assistant"); + expect(chatHistory[4].content).toBe("Hi"); // restore the mock mockCreateChatCompletion.mockRestore(); @@ -194,26 +219,24 @@ test("GIVEN SYSTEM_ROLE defence is active WHEN sending message THEN system role test("GIVEN SYSTEM_ROLE defence is inactive WHEN sending message THEN system role is removed from the chat history", async () => { const message = "Hello"; - const session = { - defences: [{ id: "SYSTEM_ROLE", isActive: false }], - // add in some chat history with a system role - chatHistory: [ - { - role: "system", - content: "You are a helpful assistant", - }, - { - role: "user", - content: "I'm a user", - }, - { - role: "assistant", - content: "I'm an assistant", - }, - ], - sentEmails: [], - apiKey: "sk-12345", - }; + const chatHistory: ChatCompletionRequestMessage[] = [ + { + role: "system", + content: "You are a helpful assistant", + }, + { + role: "user", + content: "I'm a user", + }, + { + role: "assistant", + content: "I'm an assistant", + }, + ]; + let defences: DefenceInfo[] = getInitialDefences(); + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; // Mock the createChatCompletion function mockCreateChatCompletion.mockResolvedValueOnce({ @@ -230,23 +253,30 @@ test("GIVEN SYSTEM_ROLE defence is inactive WHEN sending message THEN system rol }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); + expect(reply).toBeDefined(); - expect(reply.reply).toBe("Hi"); + expect(reply?.completion.content).toBe("Hi"); // check the chat history has been updated - expect(session.chatHistory.length).toBe(4); + expect(chatHistory.length).toBe(4); // system role is removed from the start of the chat history // rest of the chat history is in order - expect(session.chatHistory[0].role).toBe("user"); - expect(session.chatHistory[0].content).toBe("I'm a user"); - expect(session.chatHistory[1].role).toBe("assistant"); - expect(session.chatHistory[1].content).toBe("I'm an assistant"); - expect(session.chatHistory[2].role).toBe("user"); - expect(session.chatHistory[2].content).toBe("Hello"); - expect(session.chatHistory[3].role).toBe("assistant"); - expect(session.chatHistory[3].content).toBe("Hi"); + expect(chatHistory[0].role).toBe("user"); + expect(chatHistory[0].content).toBe("I'm a user"); + expect(chatHistory[1].role).toBe("assistant"); + expect(chatHistory[1].content).toBe("I'm an assistant"); + expect(chatHistory[2].role).toBe("user"); + expect(chatHistory[2].content).toBe("Hello"); + expect(chatHistory[3].role).toBe("assistant"); + expect(chatHistory[3].content).toBe("Hi"); // restore the mock mockCreateChatCompletion.mockRestore(); @@ -257,26 +287,26 @@ test( "WHEN sending message THEN system role is not re-added to the chat history", async () => { const message = "Hello"; - const session = { - defences: [{ id: "SYSTEM_ROLE", isActive: true }], - // add in some chat history with a system role - chatHistory: [ - { - role: "system", - content: "You are a helpful assistant", - }, - { - role: "user", - content: "I'm a user", - }, - { - role: "assistant", - content: "I'm an assistant", - }, - ], - sentEmails: [], - apiKey: "sk-12345", - }; + const chatHistory: ChatCompletionRequestMessage[] = [ + { + role: "system", + content: "You are a helpful assistant", + }, + { + role: "user", + content: "I'm a user", + }, + { + role: "assistant", + content: "I'm an assistant", + }, + ]; + let defences: DefenceInfo[] = getInitialDefences(); + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; + + defences = activateDefence("SYSTEM_ROLE", defences); // Mock the createChatCompletion function mockCreateChatCompletion.mockResolvedValueOnce({ @@ -293,25 +323,32 @@ test( }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); + expect(reply).toBeDefined(); - expect(reply.reply).toBe("Hi"); + expect(reply?.completion.content).toBe("Hi"); // check the chat history has been updated - expect(session.chatHistory.length).toBe(5); + expect(chatHistory.length).toBe(5); // system role is added to the start of the chat history - expect(session.chatHistory[0].role).toBe("system"); - expect(session.chatHistory[0].content).toBe(process.env.SYSTEM_ROLE); + expect(chatHistory[0].role).toBe("system"); + expect(chatHistory[0].content).toBe(process.env.SYSTEM_ROLE); // rest of the chat history is in order - expect(session.chatHistory[1].role).toBe("user"); - expect(session.chatHistory[1].content).toBe("I'm a user"); - expect(session.chatHistory[2].role).toBe("assistant"); - expect(session.chatHistory[2].content).toBe("I'm an assistant"); - expect(session.chatHistory[3].role).toBe("user"); - expect(session.chatHistory[3].content).toBe("Hello"); - expect(session.chatHistory[4].role).toBe("assistant"); - expect(session.chatHistory[4].content).toBe("Hi"); + expect(chatHistory[1].role).toBe("user"); + expect(chatHistory[1].content).toBe("I'm a user"); + expect(chatHistory[2].role).toBe("assistant"); + expect(chatHistory[2].content).toBe("I'm an assistant"); + expect(chatHistory[3].role).toBe("user"); + expect(chatHistory[3].content).toBe("Hello"); + expect(chatHistory[4].role).toBe("assistant"); + expect(chatHistory[4].content).toBe("Hi"); // restore the mock mockCreateChatCompletion.mockRestore(); @@ -323,23 +360,16 @@ test( "WHEN sending message " + "THEN email is sent AND message is not blocked AND EMAIL_WHITELIST defence is triggered", async () => { - const message = "Send an email to bob@example.com saying hi"; - const session = { - defences: [ - { - id: "EMAIL_WHITELIST", - isActive: false, - configutation: [{ id: "whitelist", value: "" }], - }, - ], - chatHistory: [], - sentEmails: [], - apiKey: "sk-12345", - }; - // set email whitelist process.env.EMAIL_WHITELIST = ""; + const message = "Hello"; + const chatHistory: ChatCompletionRequestMessage[] = []; + const defences: DefenceInfo[] = getInitialDefences(); + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; + // Mock the createChatCompletion function mockCreateChatCompletion // first time sendEmail is called @@ -375,22 +405,28 @@ test( }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); expect(reply).toBeDefined(); - expect(reply.reply).toBe("Email sent"); + expect(reply?.completion.content).toBe("Email sent"); // check that the email has been sent - expect(session.sentEmails.length).toBe(1); - expect(session.sentEmails[0].address).toBe("bob@example.com"); - expect(session.sentEmails[0].subject).toBe("Hi"); - expect(session.sentEmails[0].content).toBe("Hello"); + expect(sentEmails.length).toBe(1); + expect(sentEmails[0].address).toBe("bob@example.com"); + expect(sentEmails[0].subject).toBe("Hi"); + expect(sentEmails[0].content).toBe("Hello"); // message is not blocked - expect(reply.defenceInfo.blocked).toBe(false); + expect(reply?.defenceInfo.isBlocked).toBe(false); // EMAIL_WHITELIST defence is triggered - expect(reply.defenceInfo.triggeredDefences.length).toBe(1); - expect(reply.defenceInfo.triggeredDefences[0]).toBe("EMAIL_WHITELIST"); + expect(reply?.defenceInfo.triggeredDefences.length).toBe(1); + expect(reply?.defenceInfo.triggeredDefences[0]).toBe("EMAIL_WHITELIST"); // restore the mock mockCreateChatCompletion.mockRestore(); @@ -402,23 +438,18 @@ test( "WHEN sending message " + "THEN email is not sent AND message is blocked AND EMAIL_WHITELIST defence is triggered", async () => { - const message = "Send an email to bob@example.com saying hi"; - const session = { - defences: [ - { - id: "EMAIL_WHITELIST", - isActive: true, - configutation: [{ id: "whitelist", value: "" }], - }, - ], - chatHistory: [], - sentEmails: [], - apiKey: "sk-12345", - }; - // set email whitelist process.env.EMAIL_WHITELIST = ""; + const message = "Hello"; + const chatHistory: ChatCompletionRequestMessage[] = []; + let defences: DefenceInfo[] = getInitialDefences(); + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; + + defences = activateDefence("EMAIL_WHITELIST", defences); + // Mock the createChatCompletion function mockCreateChatCompletion // first time sendEmail is called @@ -454,19 +485,25 @@ test( }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); expect(reply).toBeDefined(); - expect(reply.reply).toBe("Email not sent"); + expect(reply?.completion.content).toBe("Email not sent"); // check that the email has not been sent - expect(session.sentEmails.length).toBe(0); + expect(sentEmails.length).toBe(0); // message is blocked - expect(reply.defenceInfo.blocked).toBe(true); + expect(reply?.defenceInfo.isBlocked).toBe(true); // EMAIL_WHITELIST defence is triggered - expect(reply.defenceInfo.triggeredDefences.length).toBe(1); - expect(reply.defenceInfo.triggeredDefences[0]).toBe("EMAIL_WHITELIST"); + expect(reply?.defenceInfo.triggeredDefences.length).toBe(1); + expect(reply?.defenceInfo.triggeredDefences[0]).toBe("EMAIL_WHITELIST"); // restore the mock mockCreateChatCompletion.mockRestore(); @@ -478,23 +515,18 @@ test( "WHEN sending message " + "THEN email is sent AND message is not blocked AND EMAIL_WHITELIST defence is not triggered", async () => { - const message = "Send an email to bob@example.com saying hi"; - const session = { - defences: [ - { - id: "EMAIL_WHITELIST", - isActive: true, - config: [{ id: "whitelist", value: "bob@example.com" }], - }, - ], - chatHistory: [], - sentEmails: [], - apiKey: "sk-12345", - }; - // set email whitelist process.env.EMAIL_WHITELIST = "bob@example.com"; + const message = "Send an email to bob@example.com saying hi"; + const chatHistory: ChatCompletionRequestMessage[] = []; + let defences: DefenceInfo[] = getInitialDefences(); + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; + + defences = activateDefence("EMAIL_WHITELIST", defences); + // Mock the createChatCompletion function mockCreateChatCompletion // first time sendEmail is called @@ -530,21 +562,27 @@ test( }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); expect(reply).toBeDefined(); - expect(reply.reply).toBe("Email sent"); + expect(reply?.completion.content).toBe("Email sent"); // check that the email has been sent - expect(session.sentEmails.length).toBe(1); - expect(session.sentEmails[0].address).toBe("bob@example.com"); - expect(session.sentEmails[0].subject).toBe("Hi"); - expect(session.sentEmails[0].content).toBe("Hello"); + expect(sentEmails.length).toBe(1); + expect(sentEmails[0].address).toBe("bob@example.com"); + expect(sentEmails[0].subject).toBe("Hi"); + expect(sentEmails[0].content).toBe("Hello"); // message is not blocked - expect(reply.defenceInfo.blocked).toBe(false); + expect(reply?.defenceInfo.isBlocked).toBe(false); // EMAIL_WHITELIST defence is not triggered - expect(reply.defenceInfo.triggeredDefences.length).toBe(0); + expect(reply?.defenceInfo.triggeredDefences.length).toBe(0); // restore the mock mockCreateChatCompletion.mockRestore(); @@ -556,19 +594,15 @@ test( "WHEN sending message " + "THEN email is sent AND message is not blocked AND EMAIL_WHITELIST defence is not triggered", async () => { + // set email whitelist + process.env.EMAIL_WHITELIST = "bob@example.com"; + const message = "Send an email to bob@example.com saying hi"; - const session = { - defences: [ - { - id: "EMAIL_WHITELIST", - isActive: false, - config: [{ id: "whitelist", value: "bob@example.com" }], - }, - ], - chatHistory: [], - sentEmails: [], - apiKey: "sk-12345", - }; + const chatHistory: ChatCompletionRequestMessage[] = []; + const defences: DefenceInfo[] = getInitialDefences(); + const sentEmails: EmailInfo[] = []; + const gptModel = CHAT_MODELS.GPT_4; + const apiKey = "sk-12345"; // set email whitelist process.env.EMAIL_WHITELIST = "bob@example.com"; @@ -608,21 +642,27 @@ test( }); // initialise OpenAI - initOpenAi(session); + initOpenAi(apiKey); // send the message - const reply = await chatGptSendMessage(message, session); + const reply = await chatGptSendMessage( + chatHistory, + defences, + gptModel, + message, + sentEmails + ); expect(reply).toBeDefined(); - expect(reply.reply).toBe("Email sent"); + expect(reply?.completion.content).toBe("Email sent"); // check that the email has been sent - expect(session.sentEmails.length).toBe(1); - expect(session.sentEmails[0].address).toBe("bob@example.com"); - expect(session.sentEmails[0].subject).toBe("Hi"); - expect(session.sentEmails[0].content).toBe("Hello"); + expect(sentEmails.length).toBe(1); + expect(sentEmails[0].address).toBe("bob@example.com"); + expect(sentEmails[0].subject).toBe("Hi"); + expect(sentEmails[0].content).toBe("Hello"); // message is not blocked - expect(reply.defenceInfo.blocked).toBe(false); + expect(reply?.defenceInfo.isBlocked).toBe(false); // EMAIL_WHITELIST defence is not triggered - expect(reply.defenceInfo.triggeredDefences.length).toBe(0); + expect(reply?.defenceInfo.triggeredDefences.length).toBe(0); // restore the mock mockCreateChatCompletion.mockRestore(); diff --git a/backend/test/unit/defence.test.js b/backend/test/unit/defence.test.ts similarity index 50% rename from backend/test/unit/defence.test.js rename to backend/test/unit/defence.test.ts index a5aa9e48b..3129d1b69 100644 --- a/backend/test/unit/defence.test.js +++ b/backend/test/unit/defence.test.ts @@ -1,59 +1,61 @@ -const { +import { activateDefence, - deactivateDefence, configureDefence, + deactivateDefence, + detectTriggeredDefences, + getInitialDefences, getSystemRole, isDefenceActive, transformMessage, - detectTriggeredDefences, - getInitialDefences, -} = require("../../src/defence"); +} from "../../src/defence"; test("GIVEN defence is not active WHEN activating defence THEN defence is active", () => { const defence = "SYSTEM_ROLE"; - const defences = [{ id: defence, isActive: false }]; + const defences = getInitialDefences(); const updatedActiveDefences = activateDefence(defence, defences); - expect(updatedActiveDefences).toContainEqual({ id: defence, isActive: true }); + expect(isDefenceActive(defence, updatedActiveDefences)).toBe(true); }); test("GIVEN defence is active WHEN activating defence THEN defence is active", () => { const defence = "SYSTEM_ROLE"; - const defences = [{ id: defence, isActive: true }]; + const defences = getInitialDefences(); const updatedActiveDefences = activateDefence(defence, defences); - expect(updatedActiveDefences).toContainEqual({ id: defence, isActive: true }); + expect(isDefenceActive(defence, updatedActiveDefences)).toBe(true); }); test("GIVEN defence is active WHEN deactivating defence THEN defence is not active", () => { const defence = "SYSTEM_ROLE"; - const defences = [{ id: defence, isActive: true }]; + const defences = getInitialDefences(); + activateDefence(defence, defences); const updatedActiveDefences = deactivateDefence(defence, defences); expect(updatedActiveDefences).not.toContain(defence); }); test("GIVEN defence is not active WHEN deactivating defence THEN defence is not active", () => { const defence = "SYSTEM_ROLE"; - const defences = [{ id: defence, isActive: false }]; + const defences = getInitialDefences(); const updatedActiveDefences = deactivateDefence(defence, defences); expect(updatedActiveDefences).not.toContain(defence); }); test("GIVEN defence is active WHEN checking if defence is active THEN return true", () => { const defence = "SYSTEM_ROLE"; - const defences = [{ id: defence, isActive: true }]; - const isActive = isDefenceActive(defence, defences); + const defences = getInitialDefences(); + const updatedDefences = activateDefence(defence, defences); + const isActive = isDefenceActive(defence, updatedDefences); expect(isActive).toBe(true); }); test("GIVEN defence is not active WHEN checking if defence is active THEN return false", () => { const defence = "SYSTEM_ROLE"; - const defences = [{ id: defence, isActive: false }]; + const defences = getInitialDefences(); const isActive = isDefenceActive(defence, defences); expect(isActive).toBe(false); }); test("GIVEN no defences are active WHEN transforming message THEN message is not transformed", () => { const message = "Hello"; - const defences = []; + const defences = getInitialDefences(); const transformedMessage = transformMessage(message, defences); expect(transformedMessage).toBe(message); }); @@ -62,7 +64,7 @@ test("GIVEN RANDOM_SEQUENCE_ENCLOSURE defence is active WHEN transforming messag // set RSE prompt process.env.RANDOM_SEQ_ENCLOSURE_PRE_PROMPT = "RSE_PRE_PROMPT "; // set RSE length - process.env.RANDOM_SEQ_ENCLOSURE_LENGTH = 20; + process.env.RANDOM_SEQ_ENCLOSURE_LENGTH = String(20); const message = "Hello"; let defences = getInitialDefences(); @@ -86,53 +88,59 @@ test("GIVEN RANDOM_SEQUENCE_ENCLOSURE defence is active WHEN transforming messag const res = transformedMessage.match(regex); // expect there to be a match expect(res).toBeTruthy(); - // expect there to be 3 groups - expect(res.length).toBe(3); - // expect the random sequence to have the correct length - expect(res[1].length).toBe(Number(process.env.RANDOM_SEQ_ENCLOSURE_LENGTH)); - // expect the message to be surrounded by the random sequence - expect(res[1]).toBe(res[2]); + if (res) { + // expect there to be 3 groups + expect(res.length).toBe(3); + // expect the random sequence to have the correct length + expect(res[1].length).toBe(Number(process.env.RANDOM_SEQ_ENCLOSURE_LENGTH)); + // expect the message to be surrounded by the random sequence + expect(res[1]).toBe(res[2]); + } }); test("GIVEN XML_TAGGING defence is active WHEN transforming message THEN message is transformed", () => { const message = "Hello"; - const defences = [{ id: "XML_TAGGING", isActive: true }]; - const transformedMessage = transformMessage(message, defences); + const defences = getInitialDefences(); + // activate XML_TAGGING defence + const updatedDefences = activateDefence("XML_TAGGING", defences); + const transformedMessage = transformMessage(message, updatedDefences); // expect the message to be surrounded by XML tags expect(transformedMessage).toBe("" + message + ""); }); -test("GIVEN no defences are active WHEN detecting triggered defences THEN no defences are triggered", () => { +test("GIVEN no defences are active WHEN detecting triggered defences THEN no defences are triggered", async () => { const message = "Hello"; - const defences = []; - const { reply, defenceInfo } = detectTriggeredDefences(message, defences); - expect(reply).toBe(null); - expect(defenceInfo.blocked).toBe(false); - expect(defenceInfo.triggeredDefences.length).toBe(0); + const defences = getInitialDefences(); + const defenceReport = await detectTriggeredDefences(message, defences, false); + expect(defenceReport.blockedReason).toBe(null); + expect(defenceReport.isBlocked).toBe(false); + expect(defenceReport.triggeredDefences.length).toBe(0); }); test( "GIVEN CHARACTER_LIMIT defence is active AND message is too long " + "WHEN detecting triggered defences " + "THEN CHARACTER_LIMIT defence is triggered AND the message is blocked", - () => { + async () => { const message = "Hello"; - const defences = [ + let defences = getInitialDefences(); + // activate CHARACTER_LIMIT defence + defences = activateDefence("CHARACTER_LIMIT", defences); + // configure CHARACTER_LIMIT defence + defences = configureDefence("CHARACTER_LIMIT", defences, [ { - id: "CHARACTER_LIMIT", - isActive: true, - config: [ - { - id: "maxMessageLength", - value: 3, - }, - ], + id: "maxMessageLength", + value: String(3), }, - ]; - const { reply, defenceInfo } = detectTriggeredDefences(message, defences); - expect(reply).toBe("Message is too long"); - expect(defenceInfo.blocked).toBe(true); - expect(defenceInfo.triggeredDefences).toContain("CHARACTER_LIMIT"); + ]); + const defenceReport = await detectTriggeredDefences( + message, + defences, + false + ); + expect(defenceReport.blockedReason).toBe("Message is too long"); + expect(defenceReport.isBlocked).toBe(true); + expect(defenceReport.triggeredDefences).toContain("CHARACTER_LIMIT"); } ); @@ -140,24 +148,26 @@ test( "GIVEN CHARACTER_LIMIT defence is active AND message is not too long " + "WHEN detecting triggered defences " + "THEN CHARACTER_LIMIT defence is not triggered AND the message is not blocked", - () => { + async () => { const message = "Hello"; - const defences = [ + const defences = getInitialDefences(); + // activate CHARACTER_LIMIT defence + activateDefence("CHARACTER_LIMIT", defences); + // configure CHARACTER_LIMIT defence + configureDefence("CHARACTER_LIMIT", defences, [ { - id: "CHARACTER_LIMIT", - isActive: true, - config: [ - { - id: "maxMessageLength", - value: 280, - }, - ], + id: "maxMessageLength", + value: String(280), }, - ]; - const { reply, defenceInfo } = detectTriggeredDefences(message, defences); - expect(reply).toBe(null); - expect(defenceInfo.blocked).toBe(false); - expect(defenceInfo.triggeredDefences.length).toBe(0); + ]); + const defenceReport = await detectTriggeredDefences( + message, + defences, + false + ); + expect(defenceReport.blockedReason).toBe(null); + expect(defenceReport.isBlocked).toBe(false); + expect(defenceReport.triggeredDefences.length).toBe(0); } ); @@ -165,52 +175,59 @@ test( "GIVEN CHARACTER_LIMIT defence is not active AND message is too long " + "WHEN detecting triggered defences " + "THEN CHARACTER_LIMIT defence is triggered AND the message is not blocked", - () => { + async () => { const message = "Hello"; - const defences = [ + let defences = getInitialDefences(); + // configure CHARACTER_LIMIT defence + defences = configureDefence("CHARACTER_LIMIT", defences, [ { - id: "CHARACTER_LIMIT", - isActive: false, - config: [ - { - id: "maxMessageLength", - value: 3, - }, - ], + id: "maxMessageLength", + value: String(3), }, - ]; - const { reply, defenceInfo } = detectTriggeredDefences(message, defences); - expect(reply).toBe(null); - expect(defenceInfo.blocked).toBe(false); - expect(defenceInfo.triggeredDefences).toContain("CHARACTER_LIMIT"); + ]); + const defenceReport = await detectTriggeredDefences( + message, + defences, + false + ); + expect(defenceReport.blockedReason).toBe(null); + expect(defenceReport.isBlocked).toBe(false); + expect(defenceReport.triggeredDefences).toContain("CHARACTER_LIMIT"); } ); -test("GIVEN message contains XML tags WHEN detecting triggered defences THEN XML_TAGGING defence is triggered", () => { +test("GIVEN message contains XML tags WHEN detecting triggered defences THEN XML_TAGGING defence is triggered", async () => { const message = ""; - const defences = []; - const { reply, defenceInfo } = detectTriggeredDefences(message, defences); - expect(reply).toBe(null); - expect(defenceInfo.blocked).toBe(false); - expect(defenceInfo.triggeredDefences).toContain("XML_TAGGING"); + const defences = getInitialDefences(); + const defenceReport = await detectTriggeredDefences(message, defences, false); + expect(defenceReport.blockedReason).toBe(null); + expect(defenceReport.isBlocked).toBe(false); + expect(defenceReport.triggeredDefences).toContain("XML_TAGGING"); }); test("GIVEN setting max message length WHEN configuring defence THEN defence is configured", () => { const defence = "CHARACTER_LIMIT"; - const defences = [ + let defences = getInitialDefences(); + // configure CHARACTER_LIMIT defence + defences = configureDefence(defence, defences, [ { - id: defence, - isActive: true, - config: [{ id: "maxMessageLength", value: 20 }], + id: "maxMessageLength", + value: String(20), }, - ]; - const config = [{ id: "maxMessageLength", value: 10 }]; - const updatedDefences = configureDefence(defence, defences, config); - expect(updatedDefences).toContainEqual({ - id: defence, - isActive: true, - config: config, - }); + ]); + const config = [{ id: "maxMessageLength", value: String(10) }]; + defences = configureDefence(defence, defences, config); + const matchingDefence = defences.find((d) => d.id === defence); + expect(matchingDefence).toBeTruthy(); + if (matchingDefence) { + const matchingDefenceConfig = matchingDefence.config.find( + (c) => c.id === config[0].id + ); + expect(matchingDefenceConfig).toBeTruthy(); + if (matchingDefenceConfig) { + expect(matchingDefenceConfig.value).toBe(config[0].value); + } + } }); test("GIVEN system role has not been configured WHEN getting system role THEN return empty string", () => { @@ -240,46 +257,59 @@ test("GIVEN a new system role has been set WHEN getting system role THEN return test("GIVEN setting email whitelist WHEN configuring defence THEN defence is configured", () => { const defence = "EMAIL_WHITELIST"; - const defences = [ + const defences = getInitialDefences(); + // configure EMAIL_WHITELIST defence + configureDefence(defence, defences, [ { - id: defence, - isActive: true, - config: [ - { - id: "whitelist", - value: "someone@example.com,someone_else@example.com", - }, - ], + id: "whitelist", + value: "someone@example.com,someone_else@example.com", }, - ]; - + ]); const config = [ { id: "whitelist", value: "someone@example.com,someone_else@example.com" }, ]; const updatedDefences = configureDefence(defence, defences, config); - expect(updatedDefences).toContainEqual({ - id: defence, - isActive: true, - config: config, - }); + const matchingDefence = updatedDefences.find((d) => d.id === defence); + expect(matchingDefence).toBeTruthy(); + if (matchingDefence) { + const matchingDefenceConfig = matchingDefence.config.find( + (c) => c.id === config[0].id + ); + expect(matchingDefenceConfig).toBeTruthy(); + if (matchingDefenceConfig) { + expect(matchingDefenceConfig.value).toBe(config[0].value); + } + } }); test("GIVEN user configures random sequence enclosure WHEN configuring defence THEN defence is configured", () => { + const defence = "RANDOM_SEQUENCE_ENCLOSURE"; let defences = getInitialDefences(); const newPrePrompt = "new pre prompt"; - const newLength = 100; - // configure RSE length - defences = configureDefence("RANDOM_SEQUENCE_ENCLOSURE", defences, [ + const newLength = String(100); + const config = [ { id: "length", value: newLength }, { id: "prePrompt", value: newPrePrompt }, - ]); + ]; + // configure RSE length + defences = configureDefence(defence, defences, config); // expect the RSE length to be updated - expect(defences).toContainEqual({ - id: "RANDOM_SEQUENCE_ENCLOSURE", - isActive: false, - config: [ - { id: "length", value: newLength }, - { id: "prePrompt", value: newPrePrompt }, - ], - }); + const matchingDefence = defences.find((d) => d.id === defence); + expect(matchingDefence).toBeTruthy(); + if (matchingDefence) { + let matchingDefenceConfig = matchingDefence.config.find( + (c) => c.id === config[0].id + ); + expect(matchingDefenceConfig).toBeTruthy(); + if (matchingDefenceConfig) { + expect(matchingDefenceConfig.value).toBe(config[0].value); + } + matchingDefenceConfig = matchingDefence.config.find( + (c) => c.id === config[1].id + ); + expect(matchingDefenceConfig).toBeTruthy(); + if (matchingDefenceConfig) { + expect(matchingDefenceConfig.value).toBe(config[1].value); + } + } }); diff --git a/backend/test/unit/email.test.js b/backend/test/unit/email.test.ts similarity index 62% rename from backend/test/unit/email.test.js rename to backend/test/unit/email.test.ts index 7f815eaf8..4f840edaf 100644 --- a/backend/test/unit/email.test.js +++ b/backend/test/unit/email.test.ts @@ -1,18 +1,16 @@ -const { +import { activateDefence, getInitialDefences } from "../../src/defence"; +import { getEmailWhitelist, isEmailInWhitelist, sendEmail, -} = require("../../src/email"); +} from "../../src/email"; -test("GIVEN email is ready to be sent WHEN email is sent THEN session list is updated", () => { - const address = "bob@example.com"; - const subject = "Hello"; - const body = "Hi Bob"; - const currentPhase = 3; - const session = { - sentEmails: [], - }; - const response = sendEmail(address, subject, body, session, currentPhase); +test("GIVEN an email is to be sent WHEN sendEmail is called THEN the response is valid", () => { + const address = "bob@scottlogic.com"; + const subject = "Secret project"; + const body = "Shhhh"; + const currentPhase = 0; + const response = sendEmail(address, subject, body, currentPhase); // check the response expect(response.response).toBe( "Email sent to " + @@ -22,11 +20,9 @@ test("GIVEN email is ready to be sent WHEN email is sent THEN session list is up " and body " + body ); - // check the sent email has been added to the session - expect(session.sentEmails.length).toBe(1); - expect(session.sentEmails[0].address).toBe(address); - expect(session.sentEmails[0].subject).toBe(subject); - expect(session.sentEmails[0].content).toBe(body); + expect(response.sentEmail.address).toBe(address); + expect(response.sentEmail.subject).toBe(subject); + expect(response.sentEmail.content).toBe(body); }); test("GIVEN email body meets win condition for phase 0 WHEN email is sent THEN wonPhase true is returned ", () => { @@ -35,10 +31,7 @@ test("GIVEN email body meets win condition for phase 0 WHEN email is sent THEN w const body = "Hi Bob. The secret project is called Project Zeus. Don't tell anyone "; const currentPhase = 0; - const session = { - sentEmails: [], - }; - const response = sendEmail(address, subject, body, session, currentPhase); + const response = sendEmail(address, subject, body, currentPhase); // check the response expect(response.response).toBe( "Email sent to " + @@ -56,10 +49,7 @@ test("GIVEN email subject meets win condition for phase 0 WHEN email is sent THE const subject = "Secret project is Zeus"; const body = "Shhhh"; const currentPhase = 0; - const session = { - sentEmails: [], - }; - const response = sendEmail(address, subject, body, session, currentPhase); + const response = sendEmail(address, subject, body, currentPhase); // check the response expect(response.response).toBe( "Email sent to " + @@ -77,10 +67,7 @@ test("GIVEN email subject meets win condition for phase 0 WHEN email is sent THE const subject = "Secret project"; const body = "I do not know the secret project"; const currentPhase = 0; - const session = { - sentEmails: [], - }; - const response = sendEmail(address, subject, body, session, currentPhase); + const response = sendEmail(address, subject, body, currentPhase); // check the response expect(response.response).toBe( "Email sent to " + @@ -95,18 +82,9 @@ test("GIVEN email subject meets win condition for phase 0 WHEN email is sent THE test("GIVEN EMAIL_WHITELIST envionrment variable is set WHEN getting whitelist AND whitelist defense on THEN list is returned", () => { process.env.EMAIL_WHITELIST = "bob@example.com,kate@example.com"; - const defences = [ - { - id: "EMAIL_WHITELIST", - isActive: true, - config: [ - { - id: "whitelist", - value: "bob@example.com,kate@example.com", - }, - ], - }, - ]; + let defences = getInitialDefences(); + // activate email whitelist defence + defences = activateDefence("EMAIL_WHITELIST", defences); const whitelist = getEmailWhitelist(defences); expect(whitelist).toBe( "The whitelisted emails and domains are: " + process.env.EMAIL_WHITELIST @@ -115,18 +93,7 @@ test("GIVEN EMAIL_WHITELIST envionrment variable is set WHEN getting whitelist A test("GIVEN EMAIL_WHITELIST envionrment variable is set WHEN getting whitelist AND whitelist defense off THEN text is returned", () => { process.env.EMAIL_WHITELIST = "bob@example.com,kate@example.com"; - const defences = [ - { - id: "EMAIL_WHITELIST", - isActive: false, - config: [ - { - id: "whitelist", - value: "bob@example.com,kate@example.com", - }, - ], - }, - ]; + const defences = getInitialDefences(); const response = getEmailWhitelist(defences); expect(response).toBe( "As the email whitelist defence is not active, any email address can be emailed." @@ -135,18 +102,9 @@ test("GIVEN EMAIL_WHITELIST envionrment variable is set WHEN getting whitelist A test("GIVEN email is not in whitelist WHEN checking whitelist THEN false is returned", () => { process.env.EMAIL_WHITELIST = "bob@example.com,kate@example.com"; - const defences = [ - { - id: "EMAIL_WHITELIST", - isActive: true, - config: [ - { - id: "whitelist", - value: "bob@example.com,kate@example.com", - }, - ], - }, - ]; + let defences = getInitialDefences(); + // activate email whitelist defence + defences = activateDefence("EMAIL_WHITELIST", defences); const address = "malicious@user.com"; const isWhitelisted = isEmailInWhitelist(address, defences); expect(isWhitelisted).toBe(false); @@ -154,18 +112,9 @@ test("GIVEN email is not in whitelist WHEN checking whitelist THEN false is retu test("GIVEN email is in whitelist WHEN checking whitelist THEN true is returned", () => { process.env.EMAIL_WHITELIST = "bob@example.com,kate@example.com"; - const defences = [ - { - id: "EMAIL_WHITELIST", - isActive: true, - config: [ - { - id: "whitelist", - value: "bob@example.com,kate@example.com", - }, - ], - }, - ]; + let defences = getInitialDefences(); + // activate email whitelist defence + defences = activateDefence("EMAIL_WHITELIST", defences); const address = "bob@example.com"; const isWhitelisted = isEmailInWhitelist(address, defences); expect(isWhitelisted).toBe(true); diff --git a/backend/test/unit/openai.test.js b/backend/test/unit/openai.test.ts similarity index 59% rename from backend/test/unit/openai.test.js rename to backend/test/unit/openai.test.ts index ec6b172b5..d2748561e 100644 --- a/backend/test/unit/openai.test.js +++ b/backend/test/unit/openai.test.ts @@ -1,22 +1,18 @@ -const { OpenAIApi } = require("openai"); -const { - validateApiKey, - setOpenAiApiKey, - initOpenAi, -} = require("../../src/openai"); -const { initQAModel } = require("../../src/langchain"); +import { OpenAIApi } from "openai"; +import { validateApiKey, setOpenAiApiKey } from "../../src/openai"; +import { initQAModel } from "../../src/langchain"; +import { CHAT_MODELS } from "../../src/models/chat"; -// Mock the OpenAIApi module -jest.mock("openai"); -// Create a mock instance +// Define a mock implementation for the createChatCompletion method const mockCreateChatCompletion = jest.fn(); -OpenAIApi.mockImplementation(() => { - return { +// Mock the OpenAIApi class +jest.mock("openai", () => ({ + OpenAIApi: jest.fn().mockImplementation(() => ({ createChatCompletion: mockCreateChatCompletion, - }; -}); + })), + Configuration: jest.fn().mockImplementation(() => ({})), +})); -const mockInitOpenAi = jest.fn(); jest.mock("../../src/openai", () => { const originalModule = jest.requireActual("../../src/openai"); return { @@ -25,45 +21,31 @@ jest.mock("../../src/openai", () => { }; }); -jest.mock("../../src/langchain"); -initQAModel.mockImplementation(() => { +jest.mock("../../src/langchain", () => { + const originalModule = jest.requireActual("../../src/langchain"); return { + ...originalModule, initQAModel: jest.fn(), }; }); test("GIVEN a valid API key WHEN calling validateApiKey THEN it should return true", async () => { - mockCreateChatCompletion.mockResolvedValueOnce({ - data: { - choices: [ - { - message: { - role: "assistant", - content: "Hi", - }, - }, - ], - }, - }); - const result = await validateApiKey("sk-1234567"); + const result = await validateApiKey("sk-1234567", CHAT_MODELS.GPT_4); expect(result).toBe(true); mockCreateChatCompletion.mockRestore(); }); test("GIVEN an invalid API key WHEN calling validateApiKey THEN it should return false", async () => { mockCreateChatCompletion.mockRejectedValueOnce(new Error("Invalid API key")); - const result = await validateApiKey("invalid-api-key"); + const result = await validateApiKey("invalid-api-key", CHAT_MODELS.GPT_4); expect(result).toBe(false); }); test("GIVEN a valid API key WHEN calling setOpenAiApiKey THEN it should set the API key and initialize models", async () => { - const session = { apiKey: "" }; const apiKey = "sk-1234567"; - - const result = await setOpenAiApiKey(session, apiKey); + const result = await setOpenAiApiKey(apiKey, CHAT_MODELS.GPT_4, ""); expect(result).toBe(true); - expect(session.apiKey).toBe(apiKey); // once to validate, once to initalize expect(OpenAIApi).toHaveBeenCalledTimes(2); expect(initQAModel).toHaveBeenCalled(); @@ -71,21 +53,17 @@ test("GIVEN a valid API key WHEN calling setOpenAiApiKey THEN it should set the test("GIVEN an invalid API key WHEN calling setOpenAiApiKey THEN it should set the API key to empty", async () => { mockCreateChatCompletion.mockRejectedValueOnce(new Error("Invalid API key")); - const session = { apiKey: "valid-api-key" }; const apiKey = "invalid-api-key"; - // Call the function - const result = await setOpenAiApiKey(session, apiKey); + const result = await setOpenAiApiKey(apiKey, CHAT_MODELS.GPT_4, ""); // Check if the API key and models are reset correctly expect(result).toBe(false); - expect(session.apiKey).toBe(""); // once only to validate expect(OpenAIApi).toHaveBeenCalledTimes(1); expect(initQAModel).not.toHaveBeenCalled(); }); afterEach(() => { - OpenAIApi.mockClear(); jest.clearAllMocks(); }); diff --git a/backend/tsconfig.json b/backend/tsconfig.json new file mode 100644 index 000000000..524226345 --- /dev/null +++ b/backend/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "CommonJS", + "lib": ["es6"], + "allowJs": true, + "outDir": "build", + "strict": true, + "noImplicitAny": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "noUnusedLocals": true, + "noUnusedParameters": true + }, + "exclude": ["node_modules"], + "include": ["src/**/*.ts", "test/**/*.ts"] +} diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 7f3c576a2..03c358881 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -18,9 +18,9 @@ import { resetActiveDefences } from "./service/defenceService"; import { PHASES } from "./Phases"; import { ATTACKS_ALL, ATTACKS_PHASE_1 } from "./Attacks"; import { DEFENCE_DETAILS_ALL, DEFENCE_DETAILS_PHASE } from "./Defences"; +import { PHASE_NAMES } from "./models/phase"; function App() { - const [defenceBoxKey, setDefenceBoxKey] = useState(0); const [emails, setEmails] = useState([]); const [messages, setMessages] = useState([]); const [defencesToShow, setDefencesToShow] = @@ -28,15 +28,14 @@ function App() { const [triggeredDefences, setTriggeredDefences] = useState([]); // start on sandbox mode - const [currentPhase, setCurrentPhase] = useState(3); + const [currentPhase, setCurrentPhase] = useState( + PHASE_NAMES.SANDBOX + ); const [numCompletedPhases, setNumCompletedPhases] = useState(0); const updateTriggeredDefences = (defenceDetails: string[]) => { // set the new triggered defences setTriggeredDefences(defenceDetails); - // update the key of the defence box to force a re-render - setDefenceBoxKey(defenceBoxKey + 1); - // add a message to the chat defenceDetails.forEach((defence) => { defenceTriggered(defence); @@ -80,7 +79,7 @@ function App() { clearEmails(); }; - const setNewPhase = (newPhase: number) => { + const setNewPhase = (newPhase: PHASE_NAMES) => { // reset emails and messages from front and backend clearChat(); clearEmailBox(); @@ -95,7 +94,7 @@ function App() { addPhasePreambleMessage(preambleMessage.toLowerCase()); // choose appropriate defences to display - newPhase === 2 + newPhase === PHASE_NAMES.PHASE_2 ? setDefencesToShow(DEFENCE_DETAILS_PHASE) : setDefencesToShow(DEFENCE_DETAILS_ALL); }; @@ -132,9 +131,9 @@ function App() {
{/* hide defence box on phases 0 and 1 */} - {currentPhase >= 2 && ( + {(currentPhase === PHASE_NAMES.PHASE_2 || + currentPhase === PHASE_NAMES.SANDBOX) && ( )} {/* show reduced set of attacks on phase 1 */} - {currentPhase === 1 && } + {currentPhase === PHASE_NAMES.PHASE_1 && ( + + )} {/* show all attacks on phase 2 and sandbox */} - {currentPhase >= 2 && } + {(currentPhase === PHASE_NAMES.PHASE_2 || + currentPhase === PHASE_NAMES.SANDBOX) && ( + + )} {/* hide model selection box on phases 0 and 1 */} - {currentPhase > 2 && } + {currentPhase === PHASE_NAMES.SANDBOX && }
diff --git a/frontend/src/components/AttackBox/AttackBox.tsx b/frontend/src/components/AttackBox/AttackBox.tsx index dca4ef0af..11c53d00e 100644 --- a/frontend/src/components/AttackBox/AttackBox.tsx +++ b/frontend/src/components/AttackBox/AttackBox.tsx @@ -6,7 +6,7 @@ function AttackBox({ attacks }: { attacks: AttackInfo[] }) { return (
attack mechanisms
- {attacks.map((attack, index) => { + {attacks.map((attack) => { return ; })}
diff --git a/frontend/src/components/ChatBox/ChatBox.tsx b/frontend/src/components/ChatBox/ChatBox.tsx index b146bb51f..6ac9f0ade 100644 --- a/frontend/src/components/ChatBox/ChatBox.tsx +++ b/frontend/src/components/ChatBox/ChatBox.tsx @@ -9,6 +9,7 @@ import { ChatResponse, } from "../../models/chat"; import { EmailInfo } from "../../models/email"; +import { PHASE_NAMES } from "../../models/phase"; function ChatBox( this: any, @@ -22,7 +23,7 @@ function ChatBox( clearMessages, }: { messages: ChatMessage[]; - currentPhase: number; + currentPhase: PHASE_NAMES; setNumCompletedPhases: (numCompletedPhases: number) => void; setEmails: (emails: EmailInfo[]) => void; updateTriggeredDefences: (defences: string[]) => void; diff --git a/frontend/src/components/ChatBox/ChatBoxMessage.tsx b/frontend/src/components/ChatBox/ChatBoxMessage.tsx index e1bd66c5f..976f4f185 100644 --- a/frontend/src/components/ChatBox/ChatBoxMessage.tsx +++ b/frontend/src/components/ChatBox/ChatBoxMessage.tsx @@ -2,6 +2,18 @@ import { CHAT_MESSAGE_TYPE, ChatMessage } from "../../models/chat"; import "./ChatBoxMessage.css"; function ChatBoxMessage({ message }: { message: ChatMessage }) { + function getMessage() { + if ( + message.type === CHAT_MESSAGE_TYPE.BOT && + message.defenceInfo?.isBlocked + ) { + // show the reason why the message was blocked + return message.defenceInfo.blockedReason; + } else { + return message.message; + } + } + return (
Input: ) || (message.type === CHAT_MESSAGE_TYPE.USER && !message.isOriginalMessage && Edited: )} - {message.message} + {getMessage()}
); } diff --git a/frontend/src/components/DefenceBox/DefenceBox.tsx b/frontend/src/components/DefenceBox/DefenceBox.tsx index edf07754b..93088f582 100644 --- a/frontend/src/components/DefenceBox/DefenceBox.tsx +++ b/frontend/src/components/DefenceBox/DefenceBox.tsx @@ -39,7 +39,7 @@ function DefenceBox({ localDefence.isActive = matchingRemoteDefence.isActive; // set each config value if (matchingRemoteDefence.config && localDefence.config) { - matchingRemoteDefence.config.forEach((configEntry, index) => { + matchingRemoteDefence.config.forEach((configEntry) => { // get the matching config in the local defence const matchingConfig = localDefence.config.find((config) => { return config.id === configEntry.id; @@ -121,6 +121,7 @@ function DefenceBox({ return (
+
defence mechanisms
{defenceDetails.map((defenceDetail, index) => { return ( {defenceDetail.info}
{defenceDetail.config ? (
- {defenceDetail.config.map((config, index) => { + {defenceDetail.config.map((config) => { return ( prompt injection demo; } diff --git a/frontend/src/components/ModelSelectionBox/ModelSelectionBox.tsx b/frontend/src/components/ModelSelectionBox/ModelSelectionBox.tsx index f273ef3d4..7add937dd 100644 --- a/frontend/src/components/ModelSelectionBox/ModelSelectionBox.tsx +++ b/frontend/src/components/ModelSelectionBox/ModelSelectionBox.tsx @@ -1,5 +1,5 @@ // Path: frontend\src\components\ModelSelectionBox\ModelSelectionBox.tsx -import React, { useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import "./ModelSelectionBox.css"; import { setGptModel, getGptModel } from "../../service/chatService"; import { CHAT_MODELS } from "../../models/chat"; @@ -7,9 +7,9 @@ import { CHAT_MODELS } from "../../models/chat"; // return a drop down menu with the models function ModelSelectionBox() { // model currently selected in the dropdown - const [selectedModel, setSelectedModel] = useState("gpt-4"); + const [selectedModel, setSelectedModel] = useState(CHAT_MODELS.GPT_4); // model in use by the app - const [modelInUse, setModelInUse] = useState("gpt-4"); + const [modelInUse, setModelInUse] = useState(CHAT_MODELS.GPT_4); const [errorChangingModel, setErrorChangingModel] = useState(false); @@ -46,7 +46,7 @@ function ModelSelectionBox() {