From 8fc1f67697aeae76824c0edb722299bcfaf9c4e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Feb 2023 05:56:46 -0800 Subject: [PATCH 1/5] chore(deps): bump react-i18next from 12.1.1 to 12.1.5 (#4872) Bumps [react-i18next](https://github.com/i18next/react-i18next) from 12.1.1 to 12.1.5. - [Release notes](https://github.com/i18next/react-i18next/releases) - [Changelog](https://github.com/i18next/react-i18next/blob/master/CHANGELOG.md) - [Commits](https://github.com/i18next/react-i18next/compare/v12.1.1...v12.1.5) --- updated-dependencies: - dependency-name: react-i18next dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c0417ef7c9f2..900bcf6c6657 100644 --- a/package.json +++ b/package.json @@ -179,7 +179,7 @@ "react-dropzone": "^11.3.2", "react-helmet": "^6.1.0", "react-hook-form": "^7.41.5", - "react-i18next": "^12.1.1", + "react-i18next": "^12.1.5", "react-merge-refs": "^2.0.1", "react-portal": "^4.2.0", "react-router-dom": "^5.2.0", diff --git a/yarn.lock b/yarn.lock index 9cdc4081a029..16056b15d468 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1013,7 +1013,7 @@ core-js-pure "^3.0.0" regenerator-runtime "^0.13.4" -"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.14.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.17.8", "@babel/runtime@^7.20.6", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2": +"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.15.4", "@babel/runtime@^7.17.8", "@babel/runtime@^7.20.6", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.7.tgz#fcb41a5a70550e04a7b708037c7c32f7f356d8fd" integrity sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ== @@ -13062,12 +13062,12 @@ react-hook-form@^7.41.5: resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.41.5.tgz#dcd0e7438c15044eadc99df6deb889da5858a03b" integrity sha512-DAKjSJ7X9f16oQrP3TW2/eD9N6HOgrmIahP4LOdFphEWVfGZ2LulFd6f6AQ/YS/0cx/5oc4j8a1PXxuaurWp/Q== -react-i18next@^12.1.1: - version "12.1.1" - resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-12.1.1.tgz#2626cdbfe6bcb76ef833861c0184a5c4e5e3c089" - integrity sha512-mFdieOI0LDy84q3JuZU6Aou1DoWW2fhapcTGeBS8+vWSJuViuoCLQAMYSb0QoHhXS8B0WKUOPpx4cffAP7r/aA== +react-i18next@^12.1.5: + version "12.1.5" + resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-12.1.5.tgz#b65f5733dd2f96188a9359c009b7dbe27443f009" + integrity sha512-7PQAv6DA0TcStG96fle+8RfTwxVbHVlZZJPoEszwUNvDuWpGldJmNWa3ZPesEsZQZGF6GkzwvEh6p57qpFD2gQ== dependencies: - "@babel/runtime" "^7.14.5" + "@babel/runtime" "^7.20.6" html-parse-stringify "^3.0.1" react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.6: From ab7b20958b21487b941615e82ad5dd7b6091a548 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Feb 2023 05:57:10 -0800 Subject: [PATCH 2/5] chore(deps): bump fs-extra and @types/fs-extra (#4871) Bumps [fs-extra](https://github.com/jprichardson/node-fs-extra) and [@types/fs-extra](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/fs-extra). These dependencies needed to be updated together. Updates `fs-extra` from 4.0.3 to 11.1.0 - [Release notes](https://github.com/jprichardson/node-fs-extra/releases) - [Changelog](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md) - [Commits](https://github.com/jprichardson/node-fs-extra/compare/4.0.3...11.1.0) Updates `@types/fs-extra` from 9.0.13 to 11.0.1 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/fs-extra) --- updated-dependencies: - dependency-name: fs-extra dependency-type: direct:production update-type: version-update:semver-major - dependency-name: "@types/fs-extra" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 4 ++-- yarn.lock | 34 +++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 900bcf6c6657..5ee6aa30f38a 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "focus-visible": "^5.2.0", "fractional-index": "^1.0.0", "framer-motion": "^4.1.17", - "fs-extra": "^4.0.2", + "fs-extra": "^11.1.0", "fuzzy-search": "^3.2.1", "gemoji": "6.x", "glob": "^8.1.0", @@ -239,7 +239,7 @@ "@types/enzyme-adapter-react-16": "^1.0.6", "@types/express-useragent": "^1.0.2", "@types/formidable": "^2.0.5", - "@types/fs-extra": "^9.0.13", + "@types/fs-extra": "^11.0.1", "@types/fuzzy-search": "^2.1.2", "@types/glob": "^8.0.1", "@types/google.analytics": "^0.0.42", diff --git a/yarn.lock b/yarn.lock index 16056b15d468..171fb2712bcf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2973,11 +2973,12 @@ dependencies: "@types/node" "*" -"@types/fs-extra@^9.0.13": - version "9.0.13" - resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45" - integrity sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA== +"@types/fs-extra@^11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.1.tgz#f542ec47810532a8a252127e6e105f487e0a6ea5" + integrity sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA== dependencies: + "@types/jsonfile" "*" "@types/node" "*" "@types/fuzzy-search@^2.1.2": @@ -3098,6 +3099,13 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= +"@types/jsonfile@*": + version "6.1.1" + resolved "https://registry.yarnpkg.com/@types/jsonfile/-/jsonfile-6.1.1.tgz#ac84e9aefa74a2425a0fb3012bdea44f58970f1b" + integrity sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png== + dependencies: + "@types/node" "*" + "@types/jsonwebtoken@^8.5.8": version "8.5.8" resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-8.5.8.tgz#01b39711eb844777b7af1d1f2b4cf22fda1c0c44" @@ -8112,6 +8120,15 @@ fs-extra@^10.0.0: jsonfile "^6.0.1" universalify "^2.0.0" +fs-extra@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.0.tgz#5784b102104433bb0e090f48bfc4a30742c357ed" + integrity sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-extra@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291" @@ -8121,15 +8138,6 @@ fs-extra@^3.0.1: jsonfile "^3.0.0" universalify "^0.1.0" -fs-extra@^4.0.2: - version "4.0.3" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" - integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg== - dependencies: - graceful-fs "^4.1.2" - jsonfile "^4.0.0" - universalify "^0.1.0" - fs-extra@^8.0.1, fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" From 0976e85a1a00e6366e1fbe060917efdcd66d35f7 Mon Sep 17 00:00:00 2001 From: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> Date: Tue, 14 Feb 2023 23:49:24 +0100 Subject: [PATCH 3/5] refactor: add server side validation schema for authProviders (#4876) * refactor: move files to subfolder * refactor: schema for authenticationProviders.info * refactor: schema for authenticationProviders.update * refactor: use validated body --- server/routes/api/apiKeys/apiKeys.ts | 4 +-- .../authenticationProviders.test.ts | 0 .../authenticationProviders.ts | 20 +++++++------- .../api/authenticationProviders/index.ts | 1 + .../api/authenticationProviders/schema.ts | 27 +++++++++++++++++++ 5 files changed, 40 insertions(+), 12 deletions(-) rename server/routes/api/{ => authenticationProviders}/authenticationProviders.test.ts (100%) rename server/routes/api/{ => authenticationProviders}/authenticationProviders.ts (86%) create mode 100644 server/routes/api/authenticationProviders/index.ts create mode 100644 server/routes/api/authenticationProviders/schema.ts diff --git a/server/routes/api/apiKeys/apiKeys.ts b/server/routes/api/apiKeys/apiKeys.ts index 542f15a520ee..970eba562378 100644 --- a/server/routes/api/apiKeys/apiKeys.ts +++ b/server/routes/api/apiKeys/apiKeys.ts @@ -15,7 +15,7 @@ router.post( auth({ member: true }), validate(T.APIKeysCreateSchema), async (ctx: APIContext) => { - const { name } = ctx.request.body; + const { name } = ctx.input.body; const { user } = ctx.state.auth; authorize(user, "createApiKey", user.team); @@ -68,7 +68,7 @@ router.post( auth({ member: true }), validate(T.APIKeysDeleteSchema), async (ctx: APIContext) => { - const { id } = ctx.request.body; + const { id } = ctx.input.body; const { user } = ctx.state.auth; const key = await ApiKey.findByPk(id); diff --git a/server/routes/api/authenticationProviders.test.ts b/server/routes/api/authenticationProviders/authenticationProviders.test.ts similarity index 100% rename from server/routes/api/authenticationProviders.test.ts rename to server/routes/api/authenticationProviders/authenticationProviders.test.ts diff --git a/server/routes/api/authenticationProviders.ts b/server/routes/api/authenticationProviders/authenticationProviders.ts similarity index 86% rename from server/routes/api/authenticationProviders.ts rename to server/routes/api/authenticationProviders/authenticationProviders.ts index 62b51d9e5f70..29a68c288e0d 100644 --- a/server/routes/api/authenticationProviders.ts +++ b/server/routes/api/authenticationProviders/authenticationProviders.ts @@ -1,6 +1,7 @@ import Router from "koa-router"; import { sequelize } from "@server/database/sequelize"; import auth from "@server/middlewares/authentication"; +import validate from "@server/middlewares/validate"; import { AuthenticationProvider, Event } from "@server/models"; import { authorize } from "@server/policies"; import { @@ -8,19 +9,19 @@ import { presentPolicies, } from "@server/presenters"; import { APIContext } from "@server/types"; -import { assertUuid, assertPresent } from "@server/validation"; -import allAuthenticationProviders from "../auth/providers"; +import allAuthenticationProviders from "../../auth/providers"; +import * as T from "./schema"; const router = new Router(); router.post( "authenticationProviders.info", auth({ admin: true }), - async (ctx: APIContext) => { - const { id } = ctx.request.body; - assertUuid(id, "id is required"); - + validate(T.AuthenticationProvidersInfoSchema), + async (ctx: APIContext) => { + const { id } = ctx.input.body; const { user } = ctx.state.auth; + const authenticationProvider = await AuthenticationProvider.findByPk(id); authorize(user, "read", authenticationProvider); @@ -34,10 +35,9 @@ router.post( router.post( "authenticationProviders.update", auth({ admin: true }), - async (ctx: APIContext) => { - const { id, isEnabled } = ctx.request.body; - assertUuid(id, "id is required"); - assertPresent(isEnabled, "isEnabled is required"); + validate(T.AuthenticationProvidersUpdateSchema), + async (ctx: APIContext) => { + const { id, isEnabled } = ctx.input.body; const { user } = ctx.state.auth; const authenticationProvider = await sequelize.transaction( diff --git a/server/routes/api/authenticationProviders/index.ts b/server/routes/api/authenticationProviders/index.ts new file mode 100644 index 000000000000..34594445ddec --- /dev/null +++ b/server/routes/api/authenticationProviders/index.ts @@ -0,0 +1 @@ +export { default } from "./authenticationProviders"; diff --git a/server/routes/api/authenticationProviders/schema.ts b/server/routes/api/authenticationProviders/schema.ts new file mode 100644 index 000000000000..2fd6e1169101 --- /dev/null +++ b/server/routes/api/authenticationProviders/schema.ts @@ -0,0 +1,27 @@ +import { z } from "zod"; +import BaseSchema from "@server/routes/api/BaseSchema"; + +export const AuthenticationProvidersInfoSchema = BaseSchema.extend({ + body: z.object({ + /** Authentication Provider Id */ + id: z.string().uuid(), + }), +}); + +export type AuthenticationProvidersInfoReq = z.infer< + typeof AuthenticationProvidersInfoSchema +>; + +export const AuthenticationProvidersUpdateSchema = BaseSchema.extend({ + body: z.object({ + /** Authentication Provider Id */ + id: z.string().uuid(), + + /** Whether the Authentication Provider is enabled or not */ + isEnabled: z.boolean(), + }), +}); + +export type AuthenticationProvidersUpdateReq = z.infer< + typeof AuthenticationProvidersUpdateSchema +>; From b50bee1ec75461030a75b5651fcfc3ddeceeef80 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 14 Feb 2023 00:00:41 -0500 Subject: [PATCH 4/5] fix: ga is not defined --- app/utils/Analytics.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/utils/Analytics.ts b/app/utils/Analytics.ts index 8b07b5032f72..3d260f750225 100644 --- a/app/utils/Analytics.ts +++ b/app/utils/Analytics.ts @@ -14,13 +14,17 @@ export default class Analytics { metadata?: Record ) => { // GA3 - ga?.("send", "event", event, action); + if (window.ga) { + window.ga("send", "event", event, action); + } // GA4 - window.dataLayer?.push({ - event, - action, - ...metadata, - }); + if (window.dataLayer) { + window.dataLayer.push({ + event, + action, + ...metadata, + }); + } }; } From 490d05b68b8412c97d581f39d31f73ac600660d5 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 14 Feb 2023 19:09:44 -0500 Subject: [PATCH 5/5] fix: Incorrect key events trigger on non-qwerty layouts --- app/hooks/useKeyDown.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/hooks/useKeyDown.ts b/app/hooks/useKeyDown.ts index 032362c8d197..5dce5c091d3a 100644 --- a/app/hooks/useKeyDown.ts +++ b/app/hooks/useKeyDown.ts @@ -28,9 +28,7 @@ const createKeyPredicate = (keyFilter: KeyFilter) => typeof keyFilter === "function" ? keyFilter : typeof keyFilter === "string" - ? (event: KeyboardEvent) => - event.key === keyFilter || - event.code === `Key${keyFilter.toUpperCase()}` + ? (event: KeyboardEvent) => event.key === keyFilter : keyFilter ? (_event: KeyboardEvent) => true : (_event: KeyboardEvent) => false;