From a636843ed7809d480b8ac995a03c3a310583c0b9 Mon Sep 17 00:00:00 2001 From: Vysakh Premkumar <84713473+tellmeY18@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:18:10 +0530 Subject: [PATCH 1/2] enable livekit plugin; fixed dockerfile (#8910) Co-authored-by: rithviknishad --- .dockerignore | 1 + .env | 4 +++- Dockerfile | 7 +++--- package-lock.json | 45 +++++++++++++++++++++++++++----------- scripts/setup-care-apps.js | 14 ++++++------ 5 files changed, 47 insertions(+), 24 deletions(-) diff --git a/.dockerignore b/.dockerignore index 8744ba7daec..c0d7ac9cd23 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ build .dockerignore Dockerfile .git +apps \ No newline at end of file diff --git a/.env b/.env index 6b3e9013d81..ebc0ebd5be3 100644 --- a/.env +++ b/.env @@ -12,4 +12,6 @@ REACT_CARE_API_URL=https://careapi.ohc.network # Dev envs ESLINT_NO_DEV_ERRORS=true CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3-patient-data-10bedicu.s3.amazonaws.com http://localhost:4566" -REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn" \ No newline at end of file +REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn" + +REACT_ENABLED_APPS="ohcnetwork/care_livekit_fe@main" diff --git a/Dockerfile b/Dockerfile index 3a96ab3c28a..4ab5ed7dbc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,10 @@ WORKDIR /app ENV NODE_OPTIONS="--max-old-space-size=4096" -RUN if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then apt-get update && apt-get install -y python3-dev make g++; fi +RUN apt-get update && apt-get install -y git + +RUN if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then apt-get install -y python3-dev make g++; fi + COPY package.json package-lock.json ./ @@ -13,8 +16,6 @@ RUN npm install COPY . . -RUN npm run setup - RUN npm run build diff --git a/package-lock.json b/package-lock.json index bd7bb8423c6..a4276cb3d35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1889,7 +1889,8 @@ "node_modules/@bufbuild/protobuf": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.10.0.tgz", - "integrity": "sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==" + "integrity": "sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==", + "license": "(Apache-2.0 AND BSD-3-Clause)" }, "node_modules/@colors/colors": { "version": "1.5.0", @@ -2792,9 +2793,10 @@ } }, "node_modules/@livekit/components-core": { - "version": "0.11.9", - "resolved": "https://registry.npmjs.org/@livekit/components-core/-/components-core-0.11.9.tgz", - "integrity": "sha512-LPE1BZ+YTaqsVqGy/GAlpiO5rEI8XpEaf1TQcGdZN1BCBas9hTHt7/aHMbHQJ0K5xuAFQx8is6dFe451T4qXIQ==", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@livekit/components-core/-/components-core-0.11.10.tgz", + "integrity": "sha512-PvFlKq1W64b9GfFjG7L4/o7ulAl5yFFpDTvG+JHQiXkaPaecMPt/qPbs6zdvUlC7om1TGMuW/pIN7o585Xz9Fg==", + "license": "Apache-2.0", "dependencies": { "@floating-ui/dom": "1.6.11", "loglevel": "1.9.1", @@ -2809,11 +2811,12 @@ } }, "node_modules/@livekit/components-react": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/@livekit/components-react/-/components-react-2.6.5.tgz", - "integrity": "sha512-G3BpBlKy+lWTV9MH3/oBTBC17Z8CWqZ9GnjcG/xmYI0IvqmY89tVWph7cj2Bq0taniA+mD3U9EMPr68fOb1m1g==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/@livekit/components-react/-/components-react-2.6.7.tgz", + "integrity": "sha512-z8dgrBrRXIe7oagwFyjehdwL/4zpySJyPdAjeMDXZVbTXYNAugb3a88Ws9yQz4PZFECLkIPXJCN3C3YR+bgh5Q==", + "license": "Apache-2.0", "dependencies": { - "@livekit/components-core": "0.11.9", + "@livekit/components-core": "0.11.10", "clsx": "2.1.1", "usehooks-ts": "3.1.0" }, @@ -2837,14 +2840,22 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/@livekit/components-styles/-/components-styles-1.1.4.tgz", "integrity": "sha512-QCupn7tQ/dy/WZclrfsgtDe8peiGYS6Ied1IGkKOysaXo04l90t62SIUTKyxgd0dNDhUDC0p34qCggGZs/44lQ==", + "license": "Apache-2.0", "engines": { "node": ">=18" } }, + "node_modules/@livekit/mutex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@livekit/mutex/-/mutex-1.0.0.tgz", + "integrity": "sha512-aiUhoThBNF9UyGTxEURFzJLhhPLIVTnQiEVMjRhPnfHNKLfo2JY9xovHKIus7B78UD5hsP6DlgpmAsjrz4U0Iw==", + "license": "Apache-2.0" + }, "node_modules/@livekit/protocol": { "version": "1.24.0", "resolved": "https://registry.npmjs.org/@livekit/protocol/-/protocol-1.24.0.tgz", "integrity": "sha512-9dCsqnkMn7lvbI4NGh18zhLDsrXyUcpS++TEFgEk5Xv1WM3R2kT3EzqgL1P/mr3jaabM6rJ8wZA/KJLuQNpF5w==", + "license": "Apache-2.0", "dependencies": { "@bufbuild/protobuf": "^1.10.0" } @@ -11693,10 +11704,12 @@ } }, "node_modules/livekit-client": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/livekit-client/-/livekit-client-2.5.9.tgz", - "integrity": "sha512-oDpK6SKYB1F+mNO+25DA0bF0cD2XoOJeD8ji4YQpzDBQv2IxeyKrQhoqXAqrYgIKuiMNkImSf+yg2v7EHSl4Og==", + "version": "2.5.10", + "resolved": "https://registry.npmjs.org/livekit-client/-/livekit-client-2.5.10.tgz", + "integrity": "sha512-H7EeIb19LAH8ejlvhh0JWtWkvXDan6Yf3bpFGlDMb54uPmyRgBY+McfgQsFgJCB9WJL0X+GYUoV1Cmnn8iAoIQ==", + "license": "Apache-2.0", "dependencies": { + "@livekit/mutex": "1.0.0", "@livekit/protocol": "1.24.0", "events": "^3.3.0", "loglevel": "^1.8.0", @@ -11710,7 +11723,8 @@ "node_modules/livekit-client/node_modules/tslib": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "license": "0BSD" }, "node_modules/load-plugin": { "version": "6.0.3", @@ -11921,6 +11935,7 @@ "version": "1.9.1", "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.1.tgz", "integrity": "sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==", + "license": "MIT", "engines": { "node": ">= 0.6.0" }, @@ -17188,6 +17203,7 @@ "version": "2.14.2", "resolved": "https://registry.npmjs.org/sdp-transform/-/sdp-transform-2.14.2.tgz", "integrity": "sha512-icY6jVao7MfKCieyo1AyxFYm1baiM+fA00qW/KrNNVlkxHAd34riEKuEkUe4bBb3gJwLJZM+xT60Yj1QL8rHiA==", + "license": "MIT", "bin": { "sdp-verify": "checker.js" } @@ -18520,7 +18536,8 @@ "node_modules/ts-debounce": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/ts-debounce/-/ts-debounce-4.0.0.tgz", - "integrity": "sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==" + "integrity": "sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==", + "license": "MIT" }, "node_modules/ts-interface-checker": { "version": "0.1.13", @@ -18706,6 +18723,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-2.1.0.tgz", "integrity": "sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==", + "license": "MIT", "optionalDependencies": { "rxjs": "*" } @@ -19291,6 +19309,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-3.1.0.tgz", "integrity": "sha512-bBIa7yUyPhE1BCc0GmR96VU/15l/9gP1Ch5mYdLcFBaFGQsdmXkvjV0TtOqW1yUd6VjIwDunm+flSciCQXujiw==", + "license": "MIT", "dependencies": { "lodash.debounce": "^4.0.8" }, diff --git a/scripts/setup-care-apps.js b/scripts/setup-care-apps.js index 4106775e63e..870c73bd247 100644 --- a/scripts/setup-care-apps.js +++ b/scripts/setup-care-apps.js @@ -1,5 +1,5 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires -const { execSync } = require("child_process"); +const { execSync, spawnSync } = require("child_process"); // eslint-disable-next-line @typescript-eslint/no-var-requires const fs = require("fs"); // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -33,12 +33,12 @@ const installApp = (app) => { const appDir = path.join(appsDir, app.package.split("/")[1]); console.log(`Cloning ${app.package}...`); - execSync( - `npx -y gitget ${app.package}${app.branch ? `#${app.branch}` : ""} apps/${app.package.split("/")[1]} `, - { - stdio: "inherit", - }, - ); + + const cloneUrl = `https://github.com/${app.package.replace("github:", "")}.git`; + const branchOption = app.branch ? ["--branch", app.branch] : []; + + spawnSync("git", ["clone", ...branchOption, cloneUrl, appDir]); + // Create a care-package.lock file fs.writeFileSync( path.join(appDir, "care-package.lock"), From c62b36dae1e6b6f1a313d3d6fc8bcea1ea80dd71 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Thu, 24 Oct 2024 20:56:24 +0530 Subject: [PATCH 2/2] Fixes security issue with Avatar Edit Modal (#8917) --- src/components/Common/AvatarEditModal.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/Common/AvatarEditModal.tsx b/src/components/Common/AvatarEditModal.tsx index e17a8bffa88..4fcd61b2b66 100644 --- a/src/components/Common/AvatarEditModal.tsx +++ b/src/components/Common/AvatarEditModal.tsx @@ -35,6 +35,8 @@ const VideoConstraints = { }, } as const; +const isImageFile = (file?: File) => file?.type.split("/")[0] === "image"; + type IVideoConstraint = (typeof VideoConstraints)[keyof typeof VideoConstraints]; @@ -87,11 +89,12 @@ const AvatarEditModal = ({ }; useEffect(() => { - if (selectedFile) { - const objectUrl = URL.createObjectURL(selectedFile); - setPreview(objectUrl); - return () => URL.revokeObjectURL(objectUrl); + if (!isImageFile(selectedFile)) { + return; } + const objectUrl = URL.createObjectURL(selectedFile!); + setPreview(objectUrl); + return () => URL.revokeObjectURL(objectUrl); }, [selectedFile]); const onSelectFile: ChangeEventHandler = (e) => { @@ -99,7 +102,7 @@ const AvatarEditModal = ({ setSelectedFile(undefined); return; } - if (e.target.files[0]?.type.split("/")[0] !== "image") { + if (!isImageFile(e.target.files[0])) { Warn({ msg: "Please upload an image file!" }); return; } @@ -134,7 +137,7 @@ const AvatarEditModal = ({ dragProps.setDragOver(false); setIsDragging(false); const droppedFile = e?.dataTransfer?.files[0]; - if (droppedFile.type.split("/")[0] !== "image") + if (!isImageFile(droppedFile)) return dragProps.setFileDropError("Please drop an image file to upload!"); setSelectedFile(droppedFile); };