π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add zod
Manav Rathif663c436cbd0
diff --git a/web/docs/dependencies.md b/web/docs/dependencies.mdindex fba1eb66da..a0eee351fa 100644--- a/web/docs/dependencies.md+++ b/web/docs/dependencies.md@@ -154,6 +154,19 @@ It is more lower level than Next, but the bells and whistles it doesn't have arethe bells and whistles (and the accompanying complexity) that we don't need insome cases.+## General++- [comlink](https://github.com/GoogleChromeLabs/comlink) provides a minimal+ layer on top of Web Workers to make them more easier to use.++- [idb](https://github.com/jakearchibald/idb) provides a promise API over the+ browser-native IndexedDB APIs.++ > For more details about IDB and its role, see [storage.md](storage.md).++- [zod](https://github.com/colinhacks/zod) is used for runtime typechecking+ (e.g. verifying that API responses match the expected TypeScript shape).+## Media- [jszip](https://github.com/Stuk/jszip) is used for reading zip files in@@ -167,16 +180,6 @@ some cases.- [heic-convert](https://github.com/catdad-experiments/heic-convert) is usedfor converting HEIC files (which browsers don't natively support) into JPEG.-## General--- [comlink](https://github.com/GoogleChromeLabs/comlink) provides a minimal- layer on top of Web Workers to make them more easier to use.--- [idb](https://github.com/jakearchibald/idb) provides a promise API over the- browser-native IndexedDB APIs.-- > For more details about IDB and its role, see [storage.md](storage.md).-## Photos app specific- [react-dropzone](https://github.com/react-dropzone/react-dropzone/) is adiff --git a/web/packages/new/package.json b/web/packages/new/package.jsonindex a54bd4ac7b..6b3e55a065 100644--- a/web/packages/new/package.json+++ b/web/packages/new/package.json@@ -5,7 +5,8 @@"dependencies": {"@/next": "*","@/utils": "*",- "@ente/shared": "*"+ "@ente/shared": "*",+ "zod": "^3.23.8"},"devDependencies": {}}diff --git a/web/packages/new/photos/services/feature-flags.ts b/web/packages/new/photos/services/feature-flags.tsindex 2dbca26731..340963ab84 100644--- a/web/packages/new/photos/services/feature-flags.ts+++ b/web/packages/new/photos/services/feature-flags.ts@@ -2,6 +2,7 @@ import log from "@/next/log";import { ensure } from "@/utils/ensure";import { apiOrigin } from "@ente/shared/network/api";import { getToken } from "@ente/shared/storage/localStorage/helpers";+import { z } from "zod";let _fetchTimeout: ReturnType<typeof setTimeout> | undefined;let _haveFetched = false;@@ -64,6 +65,19 @@ const remoteFeatureFlags = () => {return JSON.parse(s);};+const FeatureFlags = z.object({+ internalUser: z+ .boolean()+ .nullish()+ .transform((v) => (v === null ? undefined : v)),+ betaUser: z+ .boolean()+ .nullish()+ .transform((v) => (v === null ? undefined : v)),+});++type FeatureFlags =+const remoteFeatureFlagsFetchingIfNeeded = async () => {let ff = await remoteFeatureFlags();if (!ff) {diff --git a/web/yarn.lock b/web/yarn.lockindex 226b3add6b..eaf097a431 100644--- a/web/yarn.lock+++ b/web/yarn.lock@@ -3355,7 +3355,7 @@ [email protected]:dependencies:libsodium "^0.7.0"[email protected], libsodium@^0.7.0:+libsodium@^0.7.0:version "0.7.9"resolved "https://registry.yarnpkg.com/libsodium/-/libsodium-0.7.9.tgz#4bb7bcbf662ddd920d8795c227ae25bbbfa3821b"integrity sha512-gfeADtR4D/CM0oRUviKBViMGXZDgnFdMKMzHsvBdqLBHd9ySi6EtYnmuhHVDDYgYpAO8eU8hEY+F8vIUAPh08A==@@ -4992,6 +4992,11 @@ yup@^1.4:toposort "^2.0.2"type-fest "^2.19.0"+zod@^3.23.8:+ version "3.23.8"+ resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d"+ integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==+zxcvbn@^4.4.2:version "4.4.2"resolved "https://registry.yarnpkg.com/zxcvbn/-/zxcvbn-4.4.2.tgz#28ec17cf09743edcab056ddd8b1b06262cc73c30"