π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(web): update memory link parsing and public-memory fetch
AmanRajSinghMouryab239b6ddb25b
diff --git a/web/apps/memories/src/pages/index.tsx b/web/apps/memories/src/pages/index.tsxindex c561f54487..1d7ca29f16 100644--- a/web/apps/memories/src/pages/index.tsx+++ b/web/apps/memories/src/pages/index.tsx@@ -44,6 +44,32 @@ const extractMemoryShareKeyFromURL = async (return await extractCollectionKeyFromShareURL(url);};+const extractAccessTokenFromURL = (url: URL): string | null => {+ const tokenFromQuery =+ url.searchParams.get("t") ?? url.searchParams.get("accessToken");+ if (tokenFromQuery) {+ return tokenFromQuery;+ }++ // Ignore route prefixes and pick the final non-prefix path segment.+ // Supports:+ // - /<TOKEN>#<SECRET>+ // - /memory/<TOKEN>#<SECRET>+ // - /memories/<TOKEN>#<SECRET>+ const routePrefixes = new Set(["memory", "memories"]);+ const pathSegments = url.pathname+ .split("/")+ .filter((segment) => segment.length > 0);+ for (let i = pathSegments.length - 1; i >= 0; i--) {+ const segment = pathSegments[i]!;+ if (!routePrefixes.has(segment.toLowerCase())) {+ return segment;+ }+ }++ return null;+};+/*** Index page that handles both root redirect and memory share links*@@ -68,23 +94,7 @@ export default function PublicMemoryPage() {try {const currentURL = new URL(window.location.href);- // Extract token from either:- // - query param ?t=TOKEN (from server-generated URLs)- // - pathname /TOKEN (direct links)- let token = currentURL.searchParams.get("t");- if (!token) {- // Ignore routing prefixes like /memory and pick the first- // non-empty path segment as token.- const tokenFromPath = currentURL.pathname- .split("/")- .find(- (segment) =>- segment.length > 0 && segment !== "memory",- );- if (tokenFromPath) {- token = tokenFromPath;- }- }+ const token = extractAccessTokenFromURL(currentURL);// Root path β redirect to ente.io/memories (or show landing)if (!token) {diff --git a/web/packages/new/albums/services/public-memory.ts b/web/packages/new/albums/services/public-memory.tsindex 071417f166..264b18cd4e 100644--- a/web/packages/new/albums/services/public-memory.ts+++ b/web/packages/new/albums/services/public-memory.ts@@ -36,7 +36,7 @@ export const authenticatedPublicMemoryRequestHeaders = ({*/export interface PublicMemoryShareInfo {id: number;- type: string;+ type: "share" | "lane";memoryHash?: string;metadataCipher: string;metadataNonce: string;@@ -47,7 +47,7 @@ export interface PublicMemoryShareInfo {const PublicMemoryShareInfoResponse = z.object({memoryShare: z.object({id: z.number(),- type: z.string().optional().default("share"),+ type: z.enum(["share", "lane"]).optional().default("share"),memoryHash: z.string().optional(),metadataCipher: z.string().optional().default(""),metadataNonce: z.string().optional().default(""),