From 87eacc10f79c8d8338eaca10e4f15ac28eb50b55 Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Thu, 12 Dec 2024 18:53:36 +0530 Subject: [PATCH 1/2] feat(kleros-app): add-restrictions-check-in-upload-file --- .../src/lib/atlas/hooks/useSessionStorage.ts | 3 + .../src/lib/atlas/providers/AtlasProvider.tsx | 35 +- .../src/lib/atlas/utils/fetchRestrictions.ts | 40 ++ package.json | 3 +- web/src/pages/Home/CourtOverview/Header.tsx | 4 +- yarn.lock | 459 +++++++++++++++++- 6 files changed, 526 insertions(+), 18 deletions(-) create mode 100644 kleros-app/src/lib/atlas/utils/fetchRestrictions.ts diff --git a/kleros-app/src/lib/atlas/hooks/useSessionStorage.ts b/kleros-app/src/lib/atlas/hooks/useSessionStorage.ts index 5cac8fb6e..0d5e6e79b 100644 --- a/kleros-app/src/lib/atlas/hooks/useSessionStorage.ts +++ b/kleros-app/src/lib/atlas/hooks/useSessionStorage.ts @@ -7,6 +7,9 @@ export function useSessionStorage(keyName: string, defaultValue: T) { return value ? JSON.parse(value) : defaultValue; } catch (err) { + // eslint-disable-next-line no-console + console.log("useSessionStorage:", { err }); + return defaultValue; } }); diff --git a/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx b/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx index 89178035c..a99bf8577 100644 --- a/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx +++ b/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx @@ -25,6 +25,7 @@ import { import { GraphQLError } from "graphql"; import { isUndefined } from "../../../utils"; import { useSessionStorage } from "../hooks/useSessionStorage"; +import { fetchRestrictions, Role } from "../utils/fetchRestrictions"; interface IAtlasProvider { isVerified: boolean; @@ -44,6 +45,7 @@ interface IAtlasProvider { isError: boolean; } >; + roleRestrictions: Role[] | undefined; } const Context = createContext(undefined); @@ -73,7 +75,7 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea } : undefined; return new GraphQLClient(`${config.uri}/graphql`, { headers }); - }, [authToken]); + }, [authToken, config.uri]); /** * @description verifies user authorisation @@ -142,6 +144,22 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea queryClient ); + const { data: roleRestrictions } = useQuery( + { + queryKey: [`RoleRestrictions`], + enabled: Boolean(config.product), + staleTime: Infinity, + queryFn: async () => { + try { + return await fetchRestrictions(atlasGqlClient, config.product); + } catch { + return undefined; + } + }, + }, + queryClient + ); + useEffect(() => { if (!isVerified) return; refetchUser(); @@ -255,6 +273,17 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea async (file: File, role: Roles) => { try { if (!address || !isVerified || !config.uri || !authToken) return null; + + if (roleRestrictions) { + const restrictions = roleRestrictions.find((supportedRoles) => Roles[supportedRoles.name] === role); + + if (!restrictions) throw new Error("Unsupported role."); + if (!restrictions.restriction.allowedMimeTypes.includes(file.type)) throw new Error("Unsupported file type."); + if (file.size > restrictions.restriction.maxSize) + throw new Error( + `File too big. Max allowed size : ${((restrictions.restriction.maxSize / 1024) * 1024).toFixed(2)} mb.` + ); + } setIsUploadingFile(true); const hash = await fetchWithAuthErrorHandling(() => @@ -267,7 +296,7 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea setIsUploadingFile(false); } }, - [address, isVerified, setIsUploadingFile, authToken, config.uri, config.product] + [address, isVerified, setIsUploadingFile, authToken, config.uri, config.product, roleRestrictions] ); /** @@ -309,6 +338,7 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea isUploadingFile, uploadFile, confirmEmail, + roleRestrictions, }), [ isVerified, @@ -324,6 +354,7 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea isUploadingFile, uploadFile, confirmEmail, + roleRestrictions, ] )} > diff --git a/kleros-app/src/lib/atlas/utils/fetchRestrictions.ts b/kleros-app/src/lib/atlas/utils/fetchRestrictions.ts new file mode 100644 index 000000000..8a0b27347 --- /dev/null +++ b/kleros-app/src/lib/atlas/utils/fetchRestrictions.ts @@ -0,0 +1,40 @@ +import { gql, type GraphQLClient } from "graphql-request"; +import { Products } from "."; + +export type Role = { + name: string; + restriction: { + maxSize: number; + allowedMimeTypes: string[]; + }; +}; + +type FetchRolesResponse = { + roles: Role[]; +}; + +const query = gql` + query Roles($product: Products!) { + roles(product: $product) { + name + restriction { + maxSize + allowedMimeTypes + } + } + } +`; + +export async function fetchRestrictions(client: GraphQLClient, product: Products): Promise { + return client + .request(query, { product }) + .then((response) => response.roles) + .catch((errors) => { + // eslint-disable-next-line no-console + console.log("Error fetching roles :", { errors }); + const errorMessage = Array.isArray(errors?.response?.errors) + ? errors.response.errors[0]?.message + : "Error fetching roles"; + throw Error(errorMessage); + }); +} diff --git a/package.json b/package.json index 8a52d3627..9bb845c7b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "web-devtools", "eslint-config", "prettier-config", - "tsconfig" + "tsconfig", + "kleros-app" ], "packageManager": "yarn@4.5.1", "volta": { diff --git a/web/src/pages/Home/CourtOverview/Header.tsx b/web/src/pages/Home/CourtOverview/Header.tsx index fa54bf4a2..9135119e4 100644 --- a/web/src/pages/Home/CourtOverview/Header.tsx +++ b/web/src/pages/Home/CourtOverview/Header.tsx @@ -1,14 +1,14 @@ import React from "react"; import styled from "styled-components"; -import { responsiveSize } from "styles/responsiveSize"; - import { Link } from "react-router-dom"; import { Button } from "@kleros/ui-components-library"; import Bookmark from "svgs/icons/bookmark.svg"; +import { responsiveSize } from "styles/responsiveSize"; + const StyledHeader = styled.div` display: flex; flex-wrap: wrap; diff --git a/yarn.lock b/yarn.lock index fcde08d2e..27446420c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -532,6 +532,17 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.25.3": + version: 7.26.3 + resolution: "@babel/parser@npm:7.26.3" + dependencies: + "@babel/types": "npm:^7.26.3" + bin: + parser: ./bin/babel-parser.js + checksum: 10/e7e3814b2dc9ee3ed605d38223471fa7d3a84cbe9474d2b5fa7ac57dc1ddf75577b1fd3a93bf7db8f41f28869bda795cddd80223f980be23623b6434bf4c88a8 + languageName: node + linkType: hard + "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:^7.24.7": version: 7.24.7 resolution: "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:7.24.7" @@ -1856,6 +1867,16 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.26.3": + version: 7.26.3 + resolution: "@babel/types@npm:7.26.3" + dependencies: + "@babel/helper-string-parser": "npm:^7.25.9" + "@babel/helper-validator-identifier": "npm:^7.25.9" + checksum: 10/c31d0549630a89abfa11410bf82a318b0c87aa846fbf5f9905e47ba5e2aa44f41cc746442f105d622c519e4dc532d35a8d8080460ff4692f9fc7485fbf3a00eb + languageName: node + linkType: hard + "@balena/dockerignore@npm:^1.0.2": version: 1.0.2 resolution: "@balena/dockerignore@npm:1.0.2" @@ -5009,6 +5030,40 @@ __metadata: languageName: node linkType: hard +"@kleros/kleros-app@workspace:kleros-app": + version: 0.0.0-use.local + resolution: "@kleros/kleros-app@workspace:kleros-app" + dependencies: + "@eslint/compat": "npm:^1.2.3" + "@eslint/eslintrc": "npm:^3.2.0" + "@eslint/js": "npm:^9.15.0" + "@kleros/kleros-v2-eslint-config": "workspace:^" + "@kleros/kleros-v2-prettier-config": "workspace:^" + "@types/react": "npm:^18.3.12" + "@types/react-dom": "npm:^18.3.1" + "@typescript-eslint/eslint-plugin": "npm:^8.15.0" + "@typescript-eslint/parser": "npm:^8.15.0" + eslint: "npm:^9.15.0" + eslint-config-prettier: "npm:^9.1.0" + eslint-plugin-import: "npm:^2.31.0" + globals: "npm:^15.12.0" + jose: "npm:^5.9.6" + rimraf: "npm:^6.0.1" + typescript: "npm:^5.6.3" + vite: "npm:^5.4.11" + vite-plugin-dts: "npm:^4.3.0" + vite-plugin-node-polyfills: "npm:^0.22.0" + peerDependencies: + "@tanstack/react-query": ^5.59.20 + graphql: ^16.9.0 + graphql-request: ^7.1.2 + react: ^18.3.1 + react-dom: ^18.3.1 + viem: ^2.21.42 + wagmi: ^2.13.0 + languageName: unknown + linkType: soft + "@kleros/kleros-sdk@workspace:^, @kleros/kleros-sdk@workspace:kleros-sdk": version: 0.0.0-use.local resolution: "@kleros/kleros-sdk@workspace:kleros-sdk" @@ -5989,6 +6044,59 @@ __metadata: languageName: node linkType: hard +"@microsoft/api-extractor-model@npm:7.30.0": + version: 7.30.0 + resolution: "@microsoft/api-extractor-model@npm:7.30.0" + dependencies: + "@microsoft/tsdoc": "npm:~0.15.1" + "@microsoft/tsdoc-config": "npm:~0.17.1" + "@rushstack/node-core-library": "npm:5.10.0" + checksum: 10/7556760448fee6bbc0b7d4f32bd70a5d2f0b78153e2614d9834d007130f81d42338c1ccbc63e95b270bc8c3f9a50d943c4bbfe48e588e3acbbf4d8553cf40631 + languageName: node + linkType: hard + +"@microsoft/api-extractor@npm:^7.47.11": + version: 7.48.0 + resolution: "@microsoft/api-extractor@npm:7.48.0" + dependencies: + "@microsoft/api-extractor-model": "npm:7.30.0" + "@microsoft/tsdoc": "npm:~0.15.1" + "@microsoft/tsdoc-config": "npm:~0.17.1" + "@rushstack/node-core-library": "npm:5.10.0" + "@rushstack/rig-package": "npm:0.5.3" + "@rushstack/terminal": "npm:0.14.3" + "@rushstack/ts-command-line": "npm:4.23.1" + lodash: "npm:~4.17.15" + minimatch: "npm:~3.0.3" + resolve: "npm:~1.22.1" + semver: "npm:~7.5.4" + source-map: "npm:~0.6.1" + typescript: "npm:5.4.2" + bin: + api-extractor: bin/api-extractor + checksum: 10/18db5236b65a727dfd6c29a508ec9affdc31648dedf82461d4c1ecb01c2fb04ba00da6c40dff478e365dc9491d477d3462c8edb04262cf066df3cb6ef9fc8912 + languageName: node + linkType: hard + +"@microsoft/tsdoc-config@npm:~0.17.1": + version: 0.17.1 + resolution: "@microsoft/tsdoc-config@npm:0.17.1" + dependencies: + "@microsoft/tsdoc": "npm:0.15.1" + ajv: "npm:~8.12.0" + jju: "npm:~1.4.0" + resolve: "npm:~1.22.2" + checksum: 10/19f57b752413916c7ad14466650f48ba1acaf674411b6a44065e93f762d391e501cb553eeb8ae3834f1f1f064ddc83a26bdbd8026c9b2c0c194fe90818078eb9 + languageName: node + linkType: hard + +"@microsoft/tsdoc@npm:0.15.1, @microsoft/tsdoc@npm:~0.15.1": + version: 0.15.1 + resolution: "@microsoft/tsdoc@npm:0.15.1" + checksum: 10/1a92612883088fe184dba596e7ba7a0daef0e6981caeca22bad6ad551d2247294f12e368537d0d8192525cf5743f7f15fcc2ad7b3b849f26a09a15ffdd89fd0c + languageName: node + linkType: hard + "@motionone/animation@npm:^10.15.1": version: 10.15.1 resolution: "@motionone/animation@npm:10.15.1" @@ -7601,7 +7709,7 @@ __metadata: languageName: node linkType: hard -"@rollup/pluginutils@npm:^5.0.1, @rollup/pluginutils@npm:^5.1.3": +"@rollup/pluginutils@npm:^5.0.1, @rollup/pluginutils@npm:^5.1.0, @rollup/pluginutils@npm:^5.1.3": version: 5.1.3 resolution: "@rollup/pluginutils@npm:5.1.3" dependencies: @@ -7743,6 +7851,64 @@ __metadata: languageName: node linkType: hard +"@rushstack/node-core-library@npm:5.10.0": + version: 5.10.0 + resolution: "@rushstack/node-core-library@npm:5.10.0" + dependencies: + ajv: "npm:~8.13.0" + ajv-draft-04: "npm:~1.0.0" + ajv-formats: "npm:~3.0.1" + fs-extra: "npm:~7.0.1" + import-lazy: "npm:~4.0.0" + jju: "npm:~1.4.0" + resolve: "npm:~1.22.1" + semver: "npm:~7.5.4" + peerDependencies: + "@types/node": "*" + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10/4cfe66726ad07647177a86831bcdf54cfeb5d2b8a940dac9c5df886c8e4acd7dd1fccb5236660320c59043d42dcef3f84f2ee6789eb0a07c2d6302c70dc217c9 + languageName: node + linkType: hard + +"@rushstack/rig-package@npm:0.5.3": + version: 0.5.3 + resolution: "@rushstack/rig-package@npm:0.5.3" + dependencies: + resolve: "npm:~1.22.1" + strip-json-comments: "npm:~3.1.1" + checksum: 10/b58a3925a41d7a0e79f4fde7c400a379683cc7b0073c447aba6d36231529a37e7d2f4559f459be785ad862ecb01b618b2d0ff60661046e5223437356155ccb14 + languageName: node + linkType: hard + +"@rushstack/terminal@npm:0.14.3": + version: 0.14.3 + resolution: "@rushstack/terminal@npm:0.14.3" + dependencies: + "@rushstack/node-core-library": "npm:5.10.0" + supports-color: "npm:~8.1.1" + peerDependencies: + "@types/node": "*" + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10/80c603f984293488cc988d17baa95e6d4ce1c70ff44b2ed7196aa156b4480f5a63213026709668db062a94564b59c006eff21a0ef3b74f6633b648624e4a0f89 + languageName: node + linkType: hard + +"@rushstack/ts-command-line@npm:4.23.1": + version: 4.23.1 + resolution: "@rushstack/ts-command-line@npm:4.23.1" + dependencies: + "@rushstack/terminal": "npm:0.14.3" + "@types/argparse": "npm:1.0.38" + argparse: "npm:~1.0.9" + string-argv: "npm:~0.3.1" + checksum: 10/4cfa4ede60b37299c93efec3be3770adf95680aeae9d0c28fcc9fb4f04dbf63958e9a37c1cf947b47cff25bbc3596a65f0a64c094e544a60e47c026d6b9a8c70 + languageName: node + linkType: hard + "@safe-global/safe-apps-provider@npm:0.18.4": version: 0.18.4 resolution: "@safe-global/safe-apps-provider@npm:0.18.4" @@ -9056,6 +9222,13 @@ __metadata: languageName: node linkType: hard +"@types/argparse@npm:1.0.38": + version: 1.0.38 + resolution: "@types/argparse@npm:1.0.38" + checksum: 10/26ed7e3f1e3595efdb883a852f5205f971b798e4c28b7e30a32c5298eee596e8b45834ce831f014d250b9730819ab05acff5b31229666d3af4ba465b4697d0eb + languageName: node + linkType: hard + "@types/babel__core@npm:^7.0.0, @types/babel__core@npm:^7.1.14": version: 7.20.1 resolution: "@types/babel__core@npm:7.20.1" @@ -10218,6 +10391,56 @@ __metadata: languageName: node linkType: hard +"@volar/language-core@npm:2.4.10, @volar/language-core@npm:~2.4.1": + version: 2.4.10 + resolution: "@volar/language-core@npm:2.4.10" + dependencies: + "@volar/source-map": "npm:2.4.10" + checksum: 10/2bfc33a5cf215810ff9f9e058e2cb3d1148e21ff69164fa854b6933673db0521cfac8313f7ad3fba8f314d22945fbe2a8ae572888bdf816a820cfa17d4c75ee3 + languageName: node + linkType: hard + +"@volar/source-map@npm:2.4.10": + version: 2.4.10 + resolution: "@volar/source-map@npm:2.4.10" + checksum: 10/8067c4a52bb54709bb74639419242ada294348f05cd5e22bc4a3cdfe4f7b18b9292c8b231805a56bda306890b97a3969e57d4da49d294e2b6122ec1e74f707e2 + languageName: node + linkType: hard + +"@volar/typescript@npm:^2.4.4": + version: 2.4.10 + resolution: "@volar/typescript@npm:2.4.10" + dependencies: + "@volar/language-core": "npm:2.4.10" + path-browserify: "npm:^1.0.1" + vscode-uri: "npm:^3.0.8" + checksum: 10/dab415048adac8c260d824092ccac47023600cc580032c3f409d88953bacd3f2568ff666cfcf49d63ef2babec86325886d5dc32ed492335248bfd5580bbadc29 + languageName: node + linkType: hard + +"@vue/compiler-core@npm:3.5.13": + version: 3.5.13 + resolution: "@vue/compiler-core@npm:3.5.13" + dependencies: + "@babel/parser": "npm:^7.25.3" + "@vue/shared": "npm:3.5.13" + entities: "npm:^4.5.0" + estree-walker: "npm:^2.0.2" + source-map-js: "npm:^1.2.0" + checksum: 10/22f042bb47c8a1edb9d602e24da8092ab542d5640f0459a9b99ecf35f90e96678f870209dd30f774f5340c6d817d3c5a46ca49cefb9659ee5b228bd42d1f076a + languageName: node + linkType: hard + +"@vue/compiler-dom@npm:^3.4.0": + version: 3.5.13 + resolution: "@vue/compiler-dom@npm:3.5.13" + dependencies: + "@vue/compiler-core": "npm:3.5.13" + "@vue/shared": "npm:3.5.13" + checksum: 10/5dc628c52091264a443c2d7326b759d7d3999c7e9c00078c2eb370b778e60b9f2ef258a8decf2fd97c8fa0923f895d449eabc1e5bc3d8a45d3ef99c9eb0599d7 + languageName: node + linkType: hard + "@vue/compiler-sfc@npm:2.7.14": version: 2.7.14 resolution: "@vue/compiler-sfc@npm:2.7.14" @@ -10229,6 +10452,16 @@ __metadata: languageName: node linkType: hard +"@vue/compiler-vue2@npm:^2.7.16": + version: 2.7.16 + resolution: "@vue/compiler-vue2@npm:2.7.16" + dependencies: + de-indent: "npm:^1.0.2" + he: "npm:^1.2.0" + checksum: 10/739ad06be19206b2715707c226a070509bcf28c31b539a6fc932d220eb7b0c09109d71fded573ed0c4073429793a3513ca4a4e69ad4f7afc0c5bc3c28639e871 + languageName: node + linkType: hard + "@vue/component-compiler-utils@npm:^3.1.0": version: 3.3.0 resolution: "@vue/component-compiler-utils@npm:3.3.0" @@ -10249,6 +10482,34 @@ __metadata: languageName: node linkType: hard +"@vue/language-core@npm:2.1.6": + version: 2.1.6 + resolution: "@vue/language-core@npm:2.1.6" + dependencies: + "@volar/language-core": "npm:~2.4.1" + "@vue/compiler-dom": "npm:^3.4.0" + "@vue/compiler-vue2": "npm:^2.7.16" + "@vue/shared": "npm:^3.4.0" + computeds: "npm:^0.0.1" + minimatch: "npm:^9.0.3" + muggle-string: "npm:^0.4.1" + path-browserify: "npm:^1.0.1" + peerDependencies: + typescript: "*" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/640d4af0031975620cd3a8050bb4b0f4ed333f241ded195e3bf8c4e571c720b4e3bec3947caf2b10e4e2de19deb7621982d15439de3732d510cd43e325c74a50 + languageName: node + linkType: hard + +"@vue/shared@npm:3.5.13, @vue/shared@npm:^3.4.0": + version: 3.5.13 + resolution: "@vue/shared@npm:3.5.13" + checksum: 10/5c0c24f443533392dde08c3e4272ff2e19af9762f90baeaa808850e05106537bbd9e2d2ad2081d979b8c4bc89902395b46036b67f74c60b76025924de37833b1 + languageName: node + linkType: hard + "@wagmi/cli@npm:^2.1.18": version: 2.1.18 resolution: "@wagmi/cli@npm:2.1.18" @@ -11891,6 +12152,18 @@ __metadata: languageName: node linkType: hard +"ajv-draft-04@npm:~1.0.0": + version: 1.0.0 + resolution: "ajv-draft-04@npm:1.0.0" + peerDependencies: + ajv: ^8.5.0 + peerDependenciesMeta: + ajv: + optional: true + checksum: 10/3f11fa0e7f7359bef6608657f02ab78e9cc62b1fb7bdd860db0d00351b3863a1189c1a23b72466d2d82726cab4eb20725c76f5e7c134a89865e2bfd0e6828137 + languageName: node + linkType: hard + "ajv-formats@npm:^2.1.1": version: 2.1.1 resolution: "ajv-formats@npm:2.1.1" @@ -11905,6 +12178,20 @@ __metadata: languageName: node linkType: hard +"ajv-formats@npm:~3.0.1": + version: 3.0.1 + resolution: "ajv-formats@npm:3.0.1" + dependencies: + ajv: "npm:^8.0.0" + peerDependencies: + ajv: ^8.0.0 + peerDependenciesMeta: + ajv: + optional: true + checksum: 10/5679b9f9ced9d0213a202a37f3aa91efcffe59a6de1a6e3da5c873344d3c161820a1f11cc29899661fee36271fd2895dd3851b6461c902a752ad661d1c1e8722 + languageName: node + linkType: hard + "ajv-keywords@npm:^3.4.1, ajv-keywords@npm:^3.5.2": version: 3.5.2 resolution: "ajv-keywords@npm:3.5.2" @@ -11949,7 +12236,7 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^8.0.0, ajv@npm:^8.0.1, ajv@npm:^8.11.0, ajv@npm:^8.12.0, ajv@npm:^8.6.0, ajv@npm:^8.9.0": +"ajv@npm:^8.0.0, ajv@npm:^8.0.1, ajv@npm:^8.11.0, ajv@npm:^8.12.0, ajv@npm:^8.6.0, ajv@npm:^8.9.0, ajv@npm:~8.13.0": version: 8.13.0 resolution: "ajv@npm:8.13.0" dependencies: @@ -11961,6 +12248,18 @@ __metadata: languageName: node linkType: hard +"ajv@npm:~8.12.0": + version: 8.12.0 + resolution: "ajv@npm:8.12.0" + dependencies: + fast-deep-equal: "npm:^3.1.1" + json-schema-traverse: "npm:^1.0.0" + require-from-string: "npm:^2.0.2" + uri-js: "npm:^4.2.2" + checksum: 10/b406f3b79b5756ac53bfe2c20852471b08e122bc1ee4cde08ae4d6a800574d9cd78d60c81c69c63ff81e4da7cd0b638fafbb2303ae580d49cf1600b9059efb85 + languageName: node + linkType: hard + "amdefine@npm:>=0.0.4": version: 1.0.1 resolution: "amdefine@npm:1.0.1" @@ -12211,7 +12510,7 @@ __metadata: languageName: node linkType: hard -"argparse@npm:^1.0.7": +"argparse@npm:^1.0.7, argparse@npm:~1.0.9": version: 1.0.10 resolution: "argparse@npm:1.0.10" dependencies: @@ -14673,6 +14972,13 @@ __metadata: languageName: node linkType: hard +"compare-versions@npm:^6.1.1": + version: 6.1.1 + resolution: "compare-versions@npm:6.1.1" + checksum: 10/9325c0fadfba81afa0ec17e6fc2ef823ba785c693089698b8d9374e5460509f1916a88591644d4cb4045c9a58e47fafbcc0724fe8bf446d2a875a3d6eeddf165 + languageName: node + linkType: hard + "compressible@npm:~2.0.16": version: 2.0.18 resolution: "compressible@npm:2.0.18" @@ -14704,6 +15010,13 @@ __metadata: languageName: node linkType: hard +"computeds@npm:^0.0.1": + version: 0.0.1 + resolution: "computeds@npm:0.0.1" + checksum: 10/738625ccec6e483124d0ac79ec5474ab5c9df103ea05afc1fd840eed7d9004e3d6009b7bc806df564d66ad915c1ee1fb017bd91b2b32606a252ea9870b6a4026 + languageName: node + linkType: hard + "concat-map@npm:0.0.1": version: 0.0.1 resolution: "concat-map@npm:0.0.1" @@ -15887,6 +16200,18 @@ __metadata: languageName: node linkType: hard +"debug@npm:^4.3.6": + version: 4.4.0 + resolution: "debug@npm:4.4.0" + dependencies: + ms: "npm:^2.1.3" + peerDependenciesMeta: + supports-color: + optional: true + checksum: 10/1847944c2e3c2c732514b93d11886575625686056cd765336212dc15de2d2b29612b6cd80e1afba767bb8e1803b778caf9973e98169ef1a24a7a7009e1820367 + languageName: node + linkType: hard + "decamelize-keys@npm:^1.1.0": version: 1.1.1 resolution: "decamelize-keys@npm:1.1.1" @@ -16893,7 +17218,7 @@ __metadata: languageName: node linkType: hard -"entities@npm:^4.2.0, entities@npm:^4.4.0": +"entities@npm:^4.2.0, entities@npm:^4.4.0, entities@npm:^4.5.0": version: 4.5.0 resolution: "entities@npm:4.5.0" checksum: 10/ede2a35c9bce1aeccd055a1b445d41c75a14a2bb1cd22e242f20cf04d236cdcd7f9c859eb83f76885327bfae0c25bf03303665ee1ce3d47c5927b98b0e3e3d48 @@ -19093,7 +19418,7 @@ __metadata: languageName: node linkType: hard -"fs-extra@npm:^7.0.0, fs-extra@npm:^7.0.1": +"fs-extra@npm:^7.0.0, fs-extra@npm:^7.0.1, fs-extra@npm:~7.0.1": version: 7.0.1 resolution: "fs-extra@npm:7.0.1" dependencies: @@ -21011,6 +21336,13 @@ __metadata: languageName: node linkType: hard +"import-lazy@npm:~4.0.0": + version: 4.0.0 + resolution: "import-lazy@npm:4.0.0" + checksum: 10/943309cc8eb01ada12700448c288b0384f77a1bc33c7e00fa4cb223c665f467a13ce9aaceb8d2e4cf586b07c1d2828040263dcc069873ce63cfc2ac6fd087971 + languageName: node + linkType: hard + "import-local@npm:^3.0.2": version: 3.1.0 resolution: "import-local@npm:3.1.0" @@ -23136,6 +23468,13 @@ __metadata: languageName: node linkType: hard +"jju@npm:~1.4.0": + version: 1.4.0 + resolution: "jju@npm:1.4.0" + checksum: 10/1067ff8ce02221faac5a842116ed0ec79a53312a111d0bf8342a80bd02c0a3fdf0b8449694a65947db0a3e8420e8b326dffb489c7dd5866efc380c0d1708a707 + languageName: node + linkType: hard + "jmespath@npm:^0.16.0": version: 0.16.0 resolution: "jmespath@npm:0.16.0" @@ -23636,6 +23975,13 @@ __metadata: languageName: node linkType: hard +"kolorist@npm:^1.8.0": + version: 1.8.0 + resolution: "kolorist@npm:1.8.0" + checksum: 10/71d5d122951cc65f2f14c3e1d7f8fd91694b374647d4f6deec3816d018cd04a44edd9578d93e00c82c2053b925e5d30a0565746c4171f4ca9fce1a13bd5f3315 + languageName: node + linkType: hard + "kubo-rpc-client@npm:^3.0.1": version: 3.0.1 resolution: "kubo-rpc-client@npm:3.0.1" @@ -24290,7 +24636,7 @@ __metadata: languageName: node linkType: hard -"lodash@npm:^4.17.11, lodash@npm:^4.17.12, lodash@npm:^4.17.15, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.7.0, lodash@npm:~4.17.0": +"lodash@npm:^4.17.11, lodash@npm:^4.17.12, lodash@npm:^4.17.15, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.7.0, lodash@npm:~4.17.0, lodash@npm:~4.17.15": version: 4.17.21 resolution: "lodash@npm:4.17.21" checksum: 10/c08619c038846ea6ac754abd6dd29d2568aa705feb69339e836dfa8d8b09abbb2f859371e86863eda41848221f9af43714491467b5b0299122431e202bb0c532 @@ -24509,6 +24855,15 @@ __metadata: languageName: node linkType: hard +"magic-string@npm:^0.30.11": + version: 0.30.15 + resolution: "magic-string@npm:0.30.15" + dependencies: + "@jridgewell/sourcemap-codec": "npm:^1.5.0" + checksum: 10/321f6e3156ac65d938fb7e08b3eaef9f4f5718180b7507f37bb55273f1faf979ab42e3b550a9e5dbbacf1c9a0f416157ab01c08619938734dcbbe02e2ef10872 + languageName: node + linkType: hard + "magic-string@npm:^0.30.3, magic-string@npm:^0.30.4, magic-string@npm:^0.30.5": version: 0.30.13 resolution: "magic-string@npm:0.30.13" @@ -25629,7 +25984,7 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:^9.0.4, minimatch@npm:^9.0.5": +"minimatch@npm:^9.0.3, minimatch@npm:^9.0.4, minimatch@npm:^9.0.5": version: 9.0.5 resolution: "minimatch@npm:9.0.5" dependencies: @@ -25638,6 +25993,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:~3.0.3": + version: 3.0.8 + resolution: "minimatch@npm:3.0.8" + dependencies: + brace-expansion: "npm:^1.1.7" + checksum: 10/6df5373cb1ea79020beb6887ff5576c58cfabcfd32c5a65c2cf58f326e4ee8eae84f129e5fa50b8a4347fa1d1e583f931285c9fb3040d984bdfb5109ef6607ec + languageName: node + linkType: hard + "minimist-options@npm:4.1.0": version: 4.1.0 resolution: "minimist-options@npm:4.1.0" @@ -25915,6 +26279,13 @@ __metadata: languageName: node linkType: hard +"muggle-string@npm:^0.4.1": + version: 0.4.1 + resolution: "muggle-string@npm:0.4.1" + checksum: 10/8fa2ea08f497c04069718bd3fd1909b382114dacbad832d10967ca72690de43f5f8492d8ccfbf827d6be63868ed5fc10395e7b7c082aa95997eea498586c6620 + languageName: node + linkType: hard + "multiaddr-to-uri@npm:^8.0.0": version: 8.0.0 resolution: "multiaddr-to-uri@npm:8.0.0" @@ -30388,7 +30759,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.1.6, resolve@npm:^1.1.7, resolve@npm:^1.10.0, resolve@npm:^1.10.1, resolve@npm:^1.14.2, resolve@npm:^1.17.0, resolve@npm:^1.19.0, resolve@npm:^1.20.0, resolve@npm:^1.22.2, resolve@npm:^1.22.4": +"resolve@npm:^1.1.6, resolve@npm:^1.1.7, resolve@npm:^1.10.0, resolve@npm:^1.10.1, resolve@npm:^1.14.2, resolve@npm:^1.17.0, resolve@npm:^1.19.0, resolve@npm:^1.20.0, resolve@npm:^1.22.2, resolve@npm:^1.22.4, resolve@npm:~1.22.1, resolve@npm:~1.22.2": version: 1.22.8 resolution: "resolve@npm:1.22.8" dependencies: @@ -30430,7 +30801,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@npm%3A^1.1.6#optional!builtin, resolve@patch:resolve@npm%3A^1.1.7#optional!builtin, resolve@patch:resolve@npm%3A^1.10.0#optional!builtin, resolve@patch:resolve@npm%3A^1.10.1#optional!builtin, resolve@patch:resolve@npm%3A^1.14.2#optional!builtin, resolve@patch:resolve@npm%3A^1.17.0#optional!builtin, resolve@patch:resolve@npm%3A^1.19.0#optional!builtin, resolve@patch:resolve@npm%3A^1.20.0#optional!builtin, resolve@patch:resolve@npm%3A^1.22.2#optional!builtin, resolve@patch:resolve@npm%3A^1.22.4#optional!builtin": +"resolve@patch:resolve@npm%3A^1.1.6#optional!builtin, resolve@patch:resolve@npm%3A^1.1.7#optional!builtin, resolve@patch:resolve@npm%3A^1.10.0#optional!builtin, resolve@patch:resolve@npm%3A^1.10.1#optional!builtin, resolve@patch:resolve@npm%3A^1.14.2#optional!builtin, resolve@patch:resolve@npm%3A^1.17.0#optional!builtin, resolve@patch:resolve@npm%3A^1.19.0#optional!builtin, resolve@patch:resolve@npm%3A^1.20.0#optional!builtin, resolve@patch:resolve@npm%3A^1.22.2#optional!builtin, resolve@patch:resolve@npm%3A^1.22.4#optional!builtin, resolve@patch:resolve@npm%3A~1.22.1#optional!builtin, resolve@patch:resolve@npm%3A~1.22.2#optional!builtin": version: 1.22.8 resolution: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin::version=1.22.8&hash=c3c19d" dependencies: @@ -31079,7 +31450,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.5.4": +"semver@npm:7.5.4, semver@npm:~7.5.4": version: 7.5.4 resolution: "semver@npm:7.5.4" dependencies: @@ -32166,7 +32537,7 @@ __metadata: languageName: node linkType: hard -"string-argv@npm:0.3.2": +"string-argv@npm:0.3.2, string-argv@npm:~0.3.1": version: 0.3.2 resolution: "string-argv@npm:0.3.2" checksum: 10/f9d3addf887026b4b5f997a271149e93bf71efc8692e7dc0816e8807f960b18bcb9787b45beedf0f97ff459575ee389af3f189d8b649834cac602f2e857e75af @@ -32476,7 +32847,7 @@ __metadata: languageName: node linkType: hard -"strip-json-comments@npm:^3.1.0, strip-json-comments@npm:^3.1.1": +"strip-json-comments@npm:^3.1.0, strip-json-comments@npm:^3.1.1, strip-json-comments@npm:~3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" checksum: 10/492f73e27268f9b1c122733f28ecb0e7e8d8a531a6662efbd08e22cccb3f9475e90a1b82cab06a392f6afae6d2de636f977e231296400d0ec5304ba70f166443 @@ -32683,7 +33054,7 @@ __metadata: languageName: node linkType: hard -"supports-color@npm:^8.0.0, supports-color@npm:^8.1.1": +"supports-color@npm:^8.0.0, supports-color@npm:^8.1.1, supports-color@npm:~8.1.1": version: 8.1.1 resolution: "supports-color@npm:8.1.1" dependencies: @@ -33855,6 +34226,16 @@ __metadata: languageName: node linkType: hard +"typescript@npm:5.4.2": + version: 5.4.2 + resolution: "typescript@npm:5.4.2" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/f8cfdc630ab1672f004e9561eb2916935b2d267792d07ce93e97fc601c7a65191af32033d5e9c0169b7dc37da7db9bf320f7432bc84527cb7697effaa4e4559d + languageName: node + linkType: hard + "typescript@npm:^4.6.4 || ^5.2.2, typescript@npm:^5.6.3": version: 5.6.3 resolution: "typescript@npm:5.6.3" @@ -33865,6 +34246,16 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@npm%3A5.4.2#optional!builtin": + version: 5.4.2 + resolution: "typescript@patch:typescript@npm%3A5.4.2#optional!builtin::version=5.4.2&hash=5adc0c" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/f5f9a4133c2670761f0166eae5b3bafbc4a3fc24f0f42a93c9c893d9e9d6e66ea066969c5e7483fa66b4ae0e99125592553f3b92fd3599484de8be13b0615176 + languageName: node + linkType: hard + "typescript@patch:typescript@npm%3A^4.6.4 || ^5.2.2#optional!builtin, typescript@patch:typescript@npm%3A^5.6.3#optional!builtin": version: 5.6.3 resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40" @@ -34833,6 +35224,29 @@ __metadata: languageName: node linkType: hard +"vite-plugin-dts@npm:^4.3.0": + version: 4.3.0 + resolution: "vite-plugin-dts@npm:4.3.0" + dependencies: + "@microsoft/api-extractor": "npm:^7.47.11" + "@rollup/pluginutils": "npm:^5.1.0" + "@volar/typescript": "npm:^2.4.4" + "@vue/language-core": "npm:2.1.6" + compare-versions: "npm:^6.1.1" + debug: "npm:^4.3.6" + kolorist: "npm:^1.8.0" + local-pkg: "npm:^0.5.0" + magic-string: "npm:^0.30.11" + peerDependencies: + typescript: "*" + vite: "*" + peerDependenciesMeta: + vite: + optional: true + checksum: 10/bbf59fb9d4ab9420f3fd2be2090439a072c4a57194cf6ee987ae990d1d95e2d9b16fae1a7c26578705d6a396a81eb6346ec522216e1f7cfc4f4d891fc29bd839 + languageName: node + linkType: hard + "vite-plugin-node-polyfills@npm:^0.21.0": version: 0.21.0 resolution: "vite-plugin-node-polyfills@npm:0.21.0" @@ -34845,6 +35259,18 @@ __metadata: languageName: node linkType: hard +"vite-plugin-node-polyfills@npm:^0.22.0": + version: 0.22.0 + resolution: "vite-plugin-node-polyfills@npm:0.22.0" + dependencies: + "@rollup/plugin-inject": "npm:^5.0.5" + node-stdlib-browser: "npm:^1.2.0" + peerDependencies: + vite: ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 + checksum: 10/004a68987d271c04e1a7b9df38f8fca32b1e4a261b464f69895af5ea90e40cbb31e18170435613cb9f2edc735589267ff51772c8793f6f567ba2849da8d36ec4 + languageName: node + linkType: hard + "vite-plugin-svgr@npm:^4.3.0": version: 4.3.0 resolution: "vite-plugin-svgr@npm:4.3.0" @@ -34981,6 +35407,13 @@ __metadata: languageName: node linkType: hard +"vscode-uri@npm:^3.0.8": + version: 3.0.8 + resolution: "vscode-uri@npm:3.0.8" + checksum: 10/e882d6b679e0d053cbc042893c0951a135d899a192b62cd07f0a8924f11ae722067a8d6b1b5b147034becf57faf9fff9fb543b17b749fd0f17db1f54f783f07c + languageName: node + linkType: hard + "vue-hot-reload-api@npm:^2.3.0": version: 2.3.4 resolution: "vue-hot-reload-api@npm:2.3.4" From b454a3c7fa67230ae94360dbb8416772d28504f8 Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Thu, 12 Dec 2024 19:03:19 +0530 Subject: [PATCH 2/2] fix: size-calculation --- kleros-app/src/lib/atlas/providers/AtlasProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx b/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx index a99bf8577..1701faf47 100644 --- a/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx +++ b/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx @@ -281,7 +281,7 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea if (!restrictions.restriction.allowedMimeTypes.includes(file.type)) throw new Error("Unsupported file type."); if (file.size > restrictions.restriction.maxSize) throw new Error( - `File too big. Max allowed size : ${((restrictions.restriction.maxSize / 1024) * 1024).toFixed(2)} mb.` + `File too big. Max allowed size : ${(restrictions.restriction.maxSize / (1024 * 1024)).toFixed(2)} mb.` ); } setIsUploadingFile(true);