From 4b7d32fbc2944debe8de0bd6a496d696e2a2aaa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Tue, 16 Apr 2024 17:08:27 +0100 Subject: [PATCH 1/4] chore: Add `decrypt()` util to scripts (#3019) --- scripts/encrypt/decrypt.ts | 33 ++++++++++++++++++++++++ scripts/encrypt/{index.ts => encrypt.ts} | 10 +++---- scripts/encrypt/package.json | 3 ++- 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 scripts/encrypt/decrypt.ts rename scripts/encrypt/{index.ts => encrypt.ts} (79%) diff --git a/scripts/encrypt/decrypt.ts b/scripts/encrypt/decrypt.ts new file mode 100644 index 0000000000..532e40d1c9 --- /dev/null +++ b/scripts/encrypt/decrypt.ts @@ -0,0 +1,33 @@ +import { decrypt } from "@opensystemslab/planx-core"; + +/** + * Decrypt a secret + * Currently used to read secure secrets from the team_integrations table back to plain text + * e.g using API keys in another context, checking values + * + * @param encryptionKey - The encryption key - a 32-byte string + * @param secret - The encrypted secret and initialization vector in the format ${secret}:${iv} + * @returns The decrypted secret + * @example pnpm decrypt + */ +function main() { + try { + if (process.argv.length < 4) { + console.error("Usage: pnpm decrypt "); + process.exit(1); + } + + const encryptionKey = process.argv[2]; + const secret = process.argv[3]; + const decrypted = decrypt(secret, encryptionKey); + + console.log("Success!"); + console.log(decrypted); + } catch (error) { + console.log("Error!"); + console.error(error); + process.exit(1); + } +} + +main(); diff --git a/scripts/encrypt/index.ts b/scripts/encrypt/encrypt.ts similarity index 79% rename from scripts/encrypt/index.ts rename to scripts/encrypt/encrypt.ts index 3346e995d5..4b8e459382 100644 --- a/scripts/encrypt/index.ts +++ b/scripts/encrypt/encrypt.ts @@ -5,20 +5,20 @@ import { encrypt } from "@opensystemslab/planx-core"; * Currently used to generate secure secrets for the team_integrations table * e.g converting plain text 3rd-part API keys (such as BOPS tokens) to encrypted strings * - * @param secret - The secret to be encrypted. * @param encryptionKey - The encryption key - a 32-byte string + * @param secret - The secret to be encrypted. * @returns The encrypted secret and initialization vector in the format ${secret}:${iv} - * @example pnpm encode + * @example pnpm encrypt */ function main() { try { if (process.argv.length < 4) { - console.error("Usage: pnpm encode "); + console.error("Usage: pnpm encrypt "); process.exit(1); } - const secret = process.argv[2]; - const encryptionKey = process.argv[3]; + const encryptionKey = process.argv[2]; + const secret = process.argv[3]; const encrypted = encrypt(secret, encryptionKey); console.log("Success!"); diff --git a/scripts/encrypt/package.json b/scripts/encrypt/package.json index 449c8eb30b..2702d7383d 100644 --- a/scripts/encrypt/package.json +++ b/scripts/encrypt/package.json @@ -4,7 +4,8 @@ "description": "", "main": "index.ts", "scripts": { - "encrypt": "ts-node index.ts" + "encrypt": "ts-node encrypt.ts", + "decrypt": "ts-node decrypt.ts" }, "keywords": [], "dependencies": { From 8ce4397076a129eeff1803bdf019acdc97de80a3 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 16 Apr 2024 19:35:00 +0100 Subject: [PATCH 2/4] feat: add option to skipValidation when using `/digital-planning-application` admin endpoint (#3021) --- .../admin/session/digitalPlanningData.test.ts | 11 +++++++++++ .../modules/admin/session/digitalPlanningData.ts | 13 +++++++++++++ api.planx.uk/package.json | 2 +- api.planx.uk/pnpm-lock.yaml | 8 ++++---- e2e/tests/api-driven/package.json | 2 +- e2e/tests/api-driven/pnpm-lock.yaml | 8 ++++---- e2e/tests/ui-driven/package.json | 2 +- e2e/tests/ui-driven/pnpm-lock.yaml | 8 ++++---- editor.planx.uk/package.json | 2 +- editor.planx.uk/pnpm-lock.yaml | 10 +++++----- 10 files changed, 45 insertions(+), 21 deletions(-) diff --git a/api.planx.uk/modules/admin/session/digitalPlanningData.test.ts b/api.planx.uk/modules/admin/session/digitalPlanningData.test.ts index c8fb078cb3..30c66564af 100644 --- a/api.planx.uk/modules/admin/session/digitalPlanningData.test.ts +++ b/api.planx.uk/modules/admin/session/digitalPlanningData.test.ts @@ -66,4 +66,15 @@ describe("Digital Planning Application payload admin endpoint", () => { expect(res.body).toEqual(expectedPlanningPermissionPayload), ); }); + + it("returns an invalid JSON payload if the skipValidation query param is set", async () => { + await supertest(app) + .get(endpoint`123`.concat("?skipValidation=true")) + .set(authHeader({ role: "platformAdmin" })) + .expect(200) + .expect("content-type", "application/json; charset=utf-8") + .then((res) => + expect(res.body).toEqual(expectedPlanningPermissionPayload), + ); + }); }); diff --git a/api.planx.uk/modules/admin/session/digitalPlanningData.ts b/api.planx.uk/modules/admin/session/digitalPlanningData.ts index eb76b97d0c..f974839b28 100644 --- a/api.planx.uk/modules/admin/session/digitalPlanningData.ts +++ b/api.planx.uk/modules/admin/session/digitalPlanningData.ts @@ -11,6 +11,11 @@ import { $api } from "../../../client"; * - admin * parameters: * - $ref: '#/components/parameters/sessionId' + * - in: query + * name: skipValidation + * type: boolean + * required: false + * description: If invalid JSON data should still be returned, instead of logging validation errors * security: * - bearerAuth: [] */ @@ -20,9 +25,17 @@ export const getDigitalPlanningApplicationPayload = async ( next: NextFunction, ) => { try { + let skipValidation = false; + if (req.query?.skipValidation) { + skipValidation = + (req.query.skipValidation as string).toLowerCase() === "true"; + } + const data = await $api.export.digitalPlanningDataPayload( req.params.sessionId, + skipValidation, ); + res.set("content-type", "application/json"); return res.send(data); } catch (error) { diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index 2f87ff431f..4f8cca4fde 100644 --- a/api.planx.uk/package.json +++ b/api.planx.uk/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@airbrake/node": "^2.1.8", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#7ff62e4", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#15bde6b", "@types/isomorphic-fetch": "^0.0.36", "adm-zip": "^0.5.10", "aws-sdk": "^2.1467.0", diff --git a/api.planx.uk/pnpm-lock.yaml b/api.planx.uk/pnpm-lock.yaml index b03ad0d96f..12362c985b 100644 --- a/api.planx.uk/pnpm-lock.yaml +++ b/api.planx.uk/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^2.1.8 version: 2.1.8 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#7ff62e4 - version: github.com/theopensystemslab/planx-core/7ff62e4 + specifier: git+https://github.com/theopensystemslab/planx-core#15bde6b + version: github.com/theopensystemslab/planx-core/15bde6b '@types/isomorphic-fetch': specifier: ^0.0.36 version: 0.0.36 @@ -8411,8 +8411,8 @@ packages: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} dev: false - github.com/theopensystemslab/planx-core/7ff62e4: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/7ff62e4} + github.com/theopensystemslab/planx-core/15bde6b: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/15bde6b} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/e2e/tests/api-driven/package.json b/e2e/tests/api-driven/package.json index c1bb41a729..f588363618 100644 --- a/e2e/tests/api-driven/package.json +++ b/e2e/tests/api-driven/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@cucumber/cucumber": "^9.3.0", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#7ff62e4", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#15bde6b", "axios": "^1.6.8", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", diff --git a/e2e/tests/api-driven/pnpm-lock.yaml b/e2e/tests/api-driven/pnpm-lock.yaml index a838f4d59c..e9f0e220e9 100644 --- a/e2e/tests/api-driven/pnpm-lock.yaml +++ b/e2e/tests/api-driven/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^9.3.0 version: 9.3.0 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#7ff62e4 - version: github.com/theopensystemslab/planx-core/7ff62e4 + specifier: git+https://github.com/theopensystemslab/planx-core#15bde6b + version: github.com/theopensystemslab/planx-core/15bde6b axios: specifier: ^1.6.8 version: 1.6.8 @@ -2943,8 +2943,8 @@ packages: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} dev: false - github.com/theopensystemslab/planx-core/7ff62e4: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/7ff62e4} + github.com/theopensystemslab/planx-core/15bde6b: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/15bde6b} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index 655e504ebf..c3305e837f 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -8,7 +8,7 @@ "postinstall": "./install-dependencies.sh" }, "dependencies": { - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#7ff62e4", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#15bde6b", "axios": "^1.6.8", "dotenv": "^16.3.1", "eslint": "^8.56.0", diff --git a/e2e/tests/ui-driven/pnpm-lock.yaml b/e2e/tests/ui-driven/pnpm-lock.yaml index c4569ca2ab..e39ecbf311 100644 --- a/e2e/tests/ui-driven/pnpm-lock.yaml +++ b/e2e/tests/ui-driven/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#7ff62e4 - version: github.com/theopensystemslab/planx-core/7ff62e4 + specifier: git+https://github.com/theopensystemslab/planx-core#15bde6b + version: github.com/theopensystemslab/planx-core/15bde6b axios: specifier: ^1.6.8 version: 1.6.8 @@ -2609,8 +2609,8 @@ packages: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} dev: false - github.com/theopensystemslab/planx-core/7ff62e4: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/7ff62e4} + github.com/theopensystemslab/planx-core/15bde6b: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/15bde6b} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/editor.planx.uk/package.json b/editor.planx.uk/package.json index 6d8f797287..d0ca0360f7 100644 --- a/editor.planx.uk/package.json +++ b/editor.planx.uk/package.json @@ -12,7 +12,7 @@ "@mui/material": "^5.15.2", "@mui/utils": "^5.15.2", "@opensystemslab/map": "^0.8.1", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#7ff62e4", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#15bde6b", "@tiptap/core": "^2.0.3", "@tiptap/extension-bold": "^2.0.3", "@tiptap/extension-bubble-menu": "^2.1.13", diff --git a/editor.planx.uk/pnpm-lock.yaml b/editor.planx.uk/pnpm-lock.yaml index 1b3a055c0b..2643798e8f 100644 --- a/editor.planx.uk/pnpm-lock.yaml +++ b/editor.planx.uk/pnpm-lock.yaml @@ -38,8 +38,8 @@ dependencies: specifier: ^0.8.1 version: 0.8.1 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#7ff62e4 - version: github.com/theopensystemslab/planx-core/7ff62e4(@types/react@18.2.45) + specifier: git+https://github.com/theopensystemslab/planx-core#15bde6b + version: github.com/theopensystemslab/planx-core/15bde6b(@types/react@18.2.45) '@tiptap/core': specifier: ^2.0.3 version: 2.0.3(@tiptap/pm@2.0.3) @@ -21139,9 +21139,9 @@ packages: use-sync-external-store: 1.2.0(react@18.2.0) dev: false - github.com/theopensystemslab/planx-core/7ff62e4(@types/react@18.2.45): - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/7ff62e4} - id: github.com/theopensystemslab/planx-core/7ff62e4 + github.com/theopensystemslab/planx-core/15bde6b(@types/react@18.2.45): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/15bde6b} + id: github.com/theopensystemslab/planx-core/15bde6b name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true From 6979f2bfe0627e42e36d742505ae9cf81a26aaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Tue, 16 Apr 2024 20:17:22 +0100 Subject: [PATCH 3/4] fix: Add zIndex value to settings to cover badge (#3024) --- .../src/pages/FlowEditor/components/Settings/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/index.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/index.tsx index 46bf7a105d..42ec847356 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/index.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/index.tsx @@ -105,6 +105,7 @@ const Root = styled(Box)(({ theme }) => ({ backgroundColor: "#f2f2f2", zIndex: 0, }, + zIndex: theme.zIndex.appBar, })); const Settings: React.FC = ({ currentTab, tabs }) => { From a79b79eb97073218d33bcc70eb58bf468e773c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Wed, 17 Apr 2024 08:23:21 +0100 Subject: [PATCH 4/4] fix: Editor layout overflow bug (#3025) --- editor.planx.uk/src/pages/FlowEditor/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/index.tsx b/editor.planx.uk/src/pages/FlowEditor/index.tsx index f9a1cb93a4..2d9386170d 100644 --- a/editor.planx.uk/src/pages/FlowEditor/index.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/index.tsx @@ -99,7 +99,14 @@ const FlowEditor: React.FC = ({ flow, breadcrumbs }) => { return ( - +