From 42cd66f79f33f21c025ae90e2e41523ef76c3af1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 25 Jul 2026 14:21:46 -0400 Subject: [PATCH 01/34] Reorder search in command menu, remove Fuse workers (#13137) --- app/actions/definitions/documents.tsx | 4 +- app/components/CommandBar/SearchIndex.test.ts | 82 +++++++++---------- app/components/CommandBar/SearchIndex.ts | 50 ++--------- app/components/CommandBar/useSearchIndex.ts | 42 ++-------- tsconfig.json | 3 +- 5 files changed, 60 insertions(+), 121 deletions(-) diff --git a/app/actions/definitions/documents.tsx b/app/actions/definitions/documents.tsx index 1818a499c8..59d55e817f 100644 --- a/app/actions/definitions/documents.tsx +++ b/app/actions/definitions/documents.tsx @@ -66,6 +66,7 @@ import { import { ActiveDocumentSection, DocumentSection, + SearchResultsSection, TrashSection, } from "~/actions/sections"; import { setPersistedState } from "~/hooks/usePersistedState"; @@ -1227,7 +1228,8 @@ export const searchDocumentsForQueryActionFactory = (query: string) => name: ({ t }) => t(`Search documents for "{{searchQuery}}"`, { searchQuery: query }), analyticsName: "Search documents", - section: DocumentSection, + section: SearchResultsSection, + priority: -1, icon: , to: searchPath({ query }), visible: ({ location }) => location.pathname !== searchPath(), diff --git a/app/components/CommandBar/SearchIndex.test.ts b/app/components/CommandBar/SearchIndex.test.ts index 617ee3e107..8fd7640999 100644 --- a/app/components/CommandBar/SearchIndex.test.ts +++ b/app/components/CommandBar/SearchIndex.test.ts @@ -1,26 +1,26 @@ import { SearchIndex } from "./SearchIndex"; describe("SearchIndex", () => { - it("returns no results for an empty query", async () => { + it("returns no results for an empty query", () => { const index = new SearchIndex(); index.update([{ id: "1", title: "Engineering Handbook", url: "/doc/1" }]); - expect(await index.search("")).toEqual([]); - expect(await index.search(" ")).toEqual([]); + expect(index.search("")).toEqual([]); + expect(index.search(" ")).toEqual([]); }); - it("matches titles despite spelling mistakes", async () => { + it("matches titles despite spelling mistakes", () => { const index = new SearchIndex(); index.update([ { id: "1", title: "Engineering Handbook", url: "/doc/1" }, { id: "2", title: "Marketing Plan", url: "/doc/2" }, ]); - const results = await index.search("enginering handbok"); + const results = index.search("enginering handbok"); expect(results[0]?.document.id).toBe("1"); }); - it("matches document content and highlights the context", async () => { + it("matches document content and highlights the context", () => { const index = new SearchIndex(); index.update([ { @@ -31,12 +31,12 @@ describe("SearchIndex", () => { }, ]); - const results = await index.search("revenue"); + const results = index.search("revenue"); expect(results[0]?.document.id).toBe("1"); expect(results[0]?.context).toContain("revenue"); }); - it("highlights only exact matches, not fuzzy character runs", async () => { + it("highlights only exact matches, not fuzzy character runs", () => { const index = new SearchIndex(); index.update([ { @@ -49,14 +49,14 @@ describe("SearchIndex", () => { // The typo "numbrs" has no literal occurrence, so only whole contiguous // matches are marked rather than the scattered characters Fuse matched on. - const results = await index.search("revenu numbrs"); + const results = index.search("revenu numbrs"); expect(results[0]?.document.id).toBe("1"); expect(results[0]?.context).toContain("revenu"); expect(results[0]?.context).not.toContain("numbrs"); expect(results[0]?.context?.match(//g)).toHaveLength(1); }); - it("highlights the query where it appears inside a longer word", async () => { + it("highlights the query where it appears inside a longer word", () => { const index = new SearchIndex(); index.update([ { @@ -68,12 +68,10 @@ describe("SearchIndex", () => { ]); // Partway through typing "revenue", the typed prefix is still marked. - expect((await index.search("revenu"))[0]?.context).toContain( - "revenu" - ); + expect(index.search("revenu")[0]?.context).toContain("revenu"); }); - it("highlights each term of a multi-word query separately", async () => { + it("highlights each term of a multi-word query separately", () => { const index = new SearchIndex(); index.update([ { @@ -84,11 +82,11 @@ describe("SearchIndex", () => { }, ]); - const context = (await index.search("revenue numbers"))[0]?.context; + const context = index.search("revenue numbers")[0]?.context; expect(context).toContain("revenue numbers"); }); - it("marks a match as one contiguous run rather than letter runs", async () => { + it("marks a match as one contiguous run rather than letter runs", () => { const index = new SearchIndex(); index.update([ { @@ -99,13 +97,13 @@ describe("SearchIndex", () => { }, ]); - const context = (await index.search("deployment"))[0]?.context; + const context = index.search("deployment")[0]?.context; // The whole word is marked once, rather than scattered letter runs. expect(context).toContain("deployment"); expect(context?.match(//g)).toHaveLength(1); }); - it("preserves previously indexed content when a later update omits it", async () => { + it("preserves previously indexed content when a later update omits it", () => { const index = new SearchIndex(); index.update([ { @@ -118,10 +116,10 @@ describe("SearchIndex", () => { // A subsequent update (e.g. a title-only tree pass) must not drop content. index.update([{ id: "1", title: "Report", url: "/doc/1" }]); - expect((await index.search("pineapple"))[0]?.document.id).toBe("1"); + expect(index.search("pineapple")[0]?.document.id).toBe("1"); }); - it("clears content when an update sets text to an empty string", async () => { + it("clears content when an update sets text to an empty string", () => { const index = new SearchIndex(); index.update([ { @@ -134,10 +132,10 @@ describe("SearchIndex", () => { // An explicit empty string (e.g. content emptied) must replace stale text. index.update([{ id: "1", title: "Report", url: "/doc/1", text: "" }]); - expect(await index.search("pineapple")).toEqual([]); + expect(index.search("pineapple")).toEqual([]); }); - it("previews content for a title match that has no content match", async () => { + it("previews content for a title match that has no content match", () => { const index = new SearchIndex(); index.update([ { @@ -148,18 +146,18 @@ describe("SearchIndex", () => { }, ]); - const context = (await index.search("engineering"))[0]?.context; + const context = index.search("engineering")[0]?.context; expect(context).toBe("Everything a new hire needs to know about our team."); }); - it("has no context for a document with no content", async () => { + it("has no context for a document with no content", () => { const index = new SearchIndex(); index.update([{ id: "1", title: "Engineering Handbook", url: "/doc/1" }]); - expect((await index.search("engineering"))[0]?.context).toBeUndefined(); + expect(index.search("engineering")[0]?.context).toBeUndefined(); }); - it("truncates a long preview", async () => { + it("truncates a long preview", () => { const index = new SearchIndex(); index.update([ { @@ -170,12 +168,12 @@ describe("SearchIndex", () => { }, ]); - const context = (await index.search("engineering"))[0]?.context ?? ""; + const context = index.search("engineering")[0]?.context ?? ""; expect(context.endsWith("…")).toBe(true); expect(context.length).toBeLessThan(220); }); - it("orders a title prefix ahead of a shorter mid-title match", async () => { + it("orders a title prefix ahead of a shorter mid-title match", () => { const index = new SearchIndex(); index.update([ // Fuse scores this higher on its own, as the field is shorter and @@ -188,10 +186,10 @@ describe("SearchIndex", () => { }, ]); - expect((await index.search("design"))[0]?.document.id).toBe("prefix"); + expect(index.search("design")[0]?.document.id).toBe("prefix"); }); - it("orders a title prefix ahead of a shorter trailing-word match", async () => { + it("orders a title prefix ahead of a shorter trailing-word match", () => { const index = new SearchIndex(); index.update([ { id: "mid", title: "Team Onboarding", url: "/doc/mid" }, @@ -202,10 +200,10 @@ describe("SearchIndex", () => { }, ]); - expect((await index.search("onboarding"))[0]?.document.id).toBe("prefix"); + expect(index.search("onboarding")[0]?.document.id).toBe("prefix"); }); - it("orders a title prefix ahead of an equally scored mid-title match", async () => { + it("orders a title prefix ahead of an equally scored mid-title match", () => { const index = new SearchIndex(); index.update([ // Both score identically in Fuse, leaving the order arbitrary. @@ -213,10 +211,10 @@ describe("SearchIndex", () => { { id: "prefix", title: "Design Is A Guide", url: "/doc/prefix" }, ]); - expect((await index.search("design"))[0]?.document.id).toBe("prefix"); + expect(index.search("design")[0]?.document.id).toBe("prefix"); }); - it("orders a title prefix ahead of a content-only match", async () => { + it("orders a title prefix ahead of a content-only match", () => { const index = new SearchIndex(); index.update([ { id: "content", title: "Q3", url: "/doc/content", text: "revenue" }, @@ -227,10 +225,10 @@ describe("SearchIndex", () => { }, ]); - expect((await index.search("revenue"))[0]?.document.id).toBe("prefix"); + expect(index.search("revenue")[0]?.document.id).toBe("prefix"); }); - it("breaks ties within a tier by fuzzy score", async () => { + it("breaks ties within a tier by fuzzy score", () => { const index = new SearchIndex(); index.update([ { id: "long", title: "Design System Guidelines", url: "/doc/long" }, @@ -238,10 +236,10 @@ describe("SearchIndex", () => { ]); // Both are prefix matches, so the closer title wins. - expect((await index.search("design"))[0]?.document.id).toBe("short"); + expect(index.search("design")[0]?.document.id).toBe("short"); }); - it("weights title matches above content matches", async () => { + it("weights title matches above content matches", () => { const index = new SearchIndex(); index.update([ { id: "1", title: "Onboarding", url: "/doc/1", text: "unrelated body" }, @@ -253,21 +251,21 @@ describe("SearchIndex", () => { }, ]); - const results = await index.search("onboarding"); + const results = index.search("onboarding"); expect(results[0]?.document.id).toBe("1"); }); - it("reports whether an update changed the collection", async () => { + it("reports whether an update changed the collection", () => { const index = new SearchIndex(); expect(index.update([{ id: "1", title: "A", url: "/doc/1" }])).toBe(true); expect(index.update([{ id: "1", title: "A", url: "/doc/1" }])).toBe(false); }); - it("clears all indexed documents", async () => { + it("clears all indexed documents", () => { const index = new SearchIndex(); index.update([{ id: "1", title: "Engineering", url: "/doc/1" }]); index.clear(); - expect(await index.search("engineering")).toEqual([]); + expect(index.search("engineering")).toEqual([]); }); }); diff --git a/app/components/CommandBar/SearchIndex.ts b/app/components/CommandBar/SearchIndex.ts index dbe944360e..8b4f54008e 100644 --- a/app/components/CommandBar/SearchIndex.ts +++ b/app/components/CommandBar/SearchIndex.ts @@ -1,6 +1,5 @@ import { escapeRegExp } from "es-toolkit/compat"; import Fuse, { type IFuseOptions } from "fuse.js"; -import { FuseWorker } from "fuse.js/worker"; /** A document as represented within the search index. */ export interface SearchIndexDocument { @@ -40,18 +39,11 @@ const options: IFuseOptions = { ], includeScore: true, ignoreLocation: true, + useTokenSearch: true, threshold: 0.3, minMatchCharLength: minTermLength, }; -/** - * Scanning document content is the expensive part of a query, so it is sharded - * across web workers to keep it off the main thread. Indices here hold at most - * a few hundred documents, where more shards cost more in messaging overhead - * and worker startup than they win back in parallelism. - */ -const workerOptions = { numWorkers: 2 }; - const resultLimit = 25; const contextLead = 40; const contextLength = 200; @@ -179,12 +171,7 @@ function buildContext( export class SearchIndex { private records = new Map(); - // Workers are unavailable when server rendering and under jsdom, where the - // main-thread implementation stands in with an identical API. - private fuse: Fuse | FuseWorker = - typeof Worker === "undefined" - ? new Fuse([], { ...options, useTokenSearch: true }) - : new FuseWorker([], options, workerOptions); + private fuse = new Fuse([], options); /** * Merges documents into the index, rebuilding the collection only when @@ -223,7 +210,7 @@ export class SearchIndex { } if (changed) { - this.setCollection(Array.from(this.records.values())); + this.fuse.setCollection(Array.from(this.records.values())); } return changed; @@ -234,17 +221,7 @@ export class SearchIndex { */ public clear(): void { this.records.clear(); - this.setCollection([]); - } - - /** - * Releases the workers backing the index. The index must not be used again - * afterwards. - */ - public dispose(): void { - if (this.fuse instanceof FuseWorker) { - this.fuse.terminate(); - } + this.fuse.setCollection([]); } /** @@ -255,17 +232,16 @@ export class SearchIndex { * @param query the search query. * @returns the matching documents ordered by relevance. */ - public async search(query: string): Promise { + public search(query: string): SearchIndexResult[] { const trimmed = query.trim(); if (!trimmed) { return []; } - const matches = await this.fuse.search(trimmed); - // Building context scans the full text of a document, so it is deferred // until the results have been truncated to those actually displayed. - return matches + return this.fuse + .search(trimmed) .map((result) => ({ document: result.item, score: result.score ?? 1, @@ -279,16 +255,4 @@ export class SearchIndex { context: buildContext(document.text, trimmed), })); } - - /** - * Replaces the indexed collection. Workers apply this asynchronously, but - * they process messages in order, so a search issued afterwards always sees - * the new collection. - */ - private setCollection(documents: SearchIndexDocument[]): void { - void Promise.resolve(this.fuse.setCollection(documents)).catch(() => { - // A worker that failed to accept the collection will also fail the next - // search, which is where the error surfaces. - }); - } } diff --git a/app/components/CommandBar/useSearchIndex.ts b/app/components/CommandBar/useSearchIndex.ts index 3f887f5a2e..7c2c88b4d8 100644 --- a/app/components/CommandBar/useSearchIndex.ts +++ b/app/components/CommandBar/useSearchIndex.ts @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useRef, useState } from "react"; +import { useCallback, useMemo, useRef, useState } from "react"; import type Document from "~/models/Document"; import { ProsemirrorHelper } from "~/models/helpers/ProsemirrorHelper"; import { @@ -78,7 +78,7 @@ export interface UseSearchIndex { /** * Maintains a client-side fuzzy search index and searches it for the given * query. The index is fed incrementally via the returned `feed` function, and - * matching runs in web workers so that typing is never blocked by it. + * results are computed synchronously so they never lag behind the query. * * @param query the current search query. * @returns the current results and functions to feed or reset the index. @@ -90,9 +90,8 @@ export function useSearchIndex(query: string): UseSearchIndex { } const index = indexRef.current; - // Bumped whenever the index changes, to re-run the search below. + // Bumped whenever the index changes, to re-run the memoized search below. const [version, setVersion] = useState(0); - const [results, setResults] = useState([]); const feed = useCallback( (documents: SearchIndexDocument[]) => { @@ -108,35 +107,12 @@ export function useSearchIndex(query: string): UseSearchIndex { setVersion((v) => v + 1); }, [index]); - useEffect(() => { - if (!query) { - setResults([]); - return; - } - - // Searches resolve out of order, so a stale response must not overwrite the - // results of a query the user has since moved on from. - let disposed = false; - - void index - .search(query) - .then((next) => { - if (!disposed) { - setResults(next); - } - }) - .catch(() => { - if (!disposed) { - setResults([]); - } - }); - - return () => { - disposed = true; - }; - }, [index, query, version]); - - useEffect(() => () => index.dispose(), [index]); + const results = useMemo( + () => (query ? index.search(query) : []), + // The index mutates in place, so `version` is what marks the memo stale. + // eslint-disable-next-line react-hooks/exhaustive-deps + [index, query, version] + ); return { results, feed, reset }; } diff --git a/tsconfig.json b/tsconfig.json index bda7f0678b..a1ef8db7e3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,8 +37,7 @@ // Vite 8 and its plugins ship types only via their exports map, which // resolvePackageJsonExports disables; point tsc at their declaration entries. "vite": ["./node_modules/vite/dist/node/index.d.ts"], - "@vitejs/plugin-react": ["./node_modules/@vitejs/plugin-react/dist/index.d.ts"], - "fuse.js/worker": ["./node_modules/fuse.js/dist/fuse-worker.d.ts"] + "@vitejs/plugin-react": ["./node_modules/@vitejs/plugin-react/dist/index.d.ts"] } }, "exclude": ["node_modules", "build", "server/migrations"] From 44b1529b3d1c9b3c973f9ffbbac54774449de6b1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 07:57:43 -0400 Subject: [PATCH 02/34] chore: Remove redundant fast-uri resolution (#13146) The `fast-uri@npm:^3.0.1` resolution was redundant. The ^3.0.1 range naturally resolves to 3.1.4 without the resolution override, so removing it produces identical yarn.lock output and does not introduce any new vulnerabilities per `yarn npm audit --severity high --recursive --environment production`. All other resolutions remain necessary either to prevent lower/vulnerable versions from being installed transitively or to enforce a single package version required for TypeScript type consistency (React, Koa, prosemirror-transform, markdown-it types). Co-authored-by: Claude --- package.json | 1 - yarn.lock | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 32edc52dfd..b3753953b7 100644 --- a/package.json +++ b/package.json @@ -382,7 +382,6 @@ "ws@npm:~8.17.1": "^8.21.0", "uuid": "^11.1.1", "nodemailer@npm:9.0.0": "^9.0.1", - "fast-uri@npm:^3.0.1": "3.1.4", "linkify-it@npm:5.0.1": "5.0.2" }, "version": "1.9.1", diff --git a/yarn.lock b/yarn.lock index c0e3b29270..bfed688357 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11160,7 +11160,7 @@ __metadata: languageName: node linkType: hard -"fast-uri@npm:3.1.4": +"fast-uri@npm:^3.0.1": version: 3.1.4 resolution: "fast-uri@npm:3.1.4" checksum: 10c0/f90948821ceb49980f64f89b8216ba498f5957f26035be813526a55b6145d26cbd63ef5618d5205a3292b31edc9c08589749350cd72bd86c7095eb434dceb757 From 9d066c2a92864008525846f278aaade7ad15ea0f Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 08:17:09 -0400 Subject: [PATCH 03/34] fix: Avoid user serialization on public share response (#13144) * fix: Avoid user serialization on public share response * fix: shares.list does not return shares from deleted users --- server/presenters/share.ts | 22 +++++++-- server/routes/api/shares/shares.test.ts | 66 +++++++++++++++++++++++++ server/routes/api/shares/shares.ts | 19 +++++-- 3 files changed, 99 insertions(+), 8 deletions(-) diff --git a/server/presenters/share.ts b/server/presenters/share.ts index e126e93573..8cd03682aa 100644 --- a/server/presenters/share.ts +++ b/server/presenters/share.ts @@ -1,7 +1,21 @@ import type { Share } from "@server/models"; import { presentUser } from "."; -export default function presentShare(share: Share, isAdmin = false) { +interface Options { + /** Whether the viewer is an admin of the team that owns the share. */ + isAdmin?: boolean; + /** Whether the share is presented to a viewer without access to it. */ + isPublic?: boolean; +} + +/** + * Serializes a share for the API. + * + * @param share the share to present. + * @param options options controlling which fields are included. + * @returns the serialized share. + */ +export default function presentShare(share: Share, options: Options = {}) { const data = { id: share.id, sourceTitle: share.collection?.name ?? share.document?.title, @@ -13,7 +27,9 @@ export default function presentShare(share: Share, isAdmin = false) { published: share.published, url: share.canonicalUrl, urlId: share.urlId, - createdBy: presentUser(share.user), + ...(options.isPublic || !share.user + ? {} + : { createdBy: presentUser(share.user) }), includeChildDocuments: share.includeChildDocuments, allowIndexing: share.allowIndexing, allowSubscriptions: share.allowSubscriptions, @@ -28,7 +44,7 @@ export default function presentShare(share: Share, isAdmin = false) { updatedAt: share.updatedAt, }; - if (!isAdmin) { + if (!options.isAdmin) { delete data.lastAccessedAt; } diff --git a/server/routes/api/shares/shares.test.ts b/server/routes/api/shares/shares.test.ts index 6aa88cbd28..b8c54bc635 100644 --- a/server/routes/api/shares/shares.test.ts +++ b/server/routes/api/shares/shares.test.ts @@ -177,6 +177,27 @@ describe("#shares.list", () => { expect(body.data[0].documentTitle).toBe(document.title); }); + it("admins should return shares created by a deleted user", async () => { + const team = await buildTeam(); + const admin = await buildAdmin({ teamId: team.id }); + const user = await buildUser({ teamId: team.id }); + const document = await buildDocument({ userId: admin.id, teamId: team.id }); + const share = await buildShare({ + documentId: document.id, + teamId: team.id, + userId: user.id, + }); + await user.destroy(); + + const res = await server.post("/api/shares.list", admin); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.length).toEqual(1); + expect(body.pagination.total).toEqual(1); + expect(body.data[0].id).toEqual(share.id); + expect(body.data[0].createdBy).toBeUndefined(); + }); + it("admins should not return shares in collection not a member of", async () => { const team = await buildTeam(); const user = await buildUser({ teamId: team.id }); @@ -703,6 +724,51 @@ describe("#shares.info", () => { expect(body.data.shares[0].id).toEqual(share.id); }); + it("should not return the sharer for an unauthenticated viewer", async () => { + const user = await buildUser(); + const document = await buildDocument({ + createdById: user.id, + teamId: user.teamId, + }); + const share = await buildShare({ + documentId: document.id, + teamId: user.teamId, + userId: user.id, + published: true, + }); + const res = await server.post("/api/shares.info", { + body: { + id: share.id, + }, + }); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.shares[0].id).toEqual(share.id); + expect(body.data.shares[0].createdBy).toBeUndefined(); + }); + + it("should return the sharer for a viewer with access to the share", async () => { + const user = await buildUser(); + const document = await buildDocument({ + createdById: user.id, + teamId: user.teamId, + }); + const share = await buildShare({ + documentId: document.id, + teamId: user.teamId, + userId: user.id, + published: true, + }); + const res = await server.post("/api/shares.info", user, { + body: { + id: share.id, + }, + }); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.shares[0].createdBy.id).toEqual(user.id); + }); + it("should allow reading share by documentId", async () => { const user = await buildUser(); const document = await buildDocument({ diff --git a/server/routes/api/shares/shares.ts b/server/routes/api/shares/shares.ts index 377eb7fbde..a49538ac15 100644 --- a/server/routes/api/shares/shares.ts +++ b/server/routes/api/shares/shares.ts @@ -104,7 +104,12 @@ router.post( ctx.body = { data: { - shares: [presentShare(share, user?.isAdmin ?? false)], + shares: [ + presentShare(share, { + isAdmin: user?.isAdmin ?? false, + isPublic: cannot(user, "read", share), + }), + ], sharedTree, team: serializedTeam, collection: serializedCollection, @@ -135,7 +140,9 @@ router.post( ctx.body = { data: { - shares: shares.map((s) => presentShare(s, user.isAdmin ?? false)), + shares: shares.map((s) => + presentShare(s, { isAdmin: user.isAdmin ?? false }) + ), }, policies: presentPolicies(user, shares), }; @@ -221,7 +228,7 @@ router.post( }, { model: User, - required: true, + required: false, as: "user", }, { @@ -245,7 +252,9 @@ router.post( ctx.body = { pagination: { ...ctx.state.pagination, total }, - data: shares.map((share) => presentShare(share, user.isAdmin)), + data: shares.map((share) => + presentShare(share, { isAdmin: user.isAdmin }) + ), policies: presentPolicies(user, shares), }; } @@ -406,7 +415,7 @@ router.post( await share.saveWithCtx(ctx); ctx.body = { - data: presentShare(share, user.isAdmin), + data: presentShare(share, { isAdmin: user.isAdmin }), policies: presentPolicies(user, [share]), }; } From 22cb3f1baf605d2acca1a90229e6980bf7d04c46 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 08:18:01 -0400 Subject: [PATCH 04/34] chore: Tighten rate limits on document mutations (#13142) --- server/routes/api/documents/documents.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index 26b58dc9e9..468acbb186 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -982,6 +982,7 @@ router.post( router.post( "documents.restore", auth({ role: UserRole.Member }), + rateLimiter(RateLimiterStrategy.OneHundredPerMinute), validate(T.DocumentsRestoreSchema), transaction(), async (ctx: APIContext) => { @@ -1326,6 +1327,7 @@ router.post( router.post( "documents.duplicate", auth(), + rateLimiter(RateLimiterStrategy.TwentyFivePerMinute), validate(T.DocumentsDuplicateSchema), transaction(), async (ctx: APIContext) => { @@ -1384,6 +1386,7 @@ router.post( router.post( "documents.move", auth(), + rateLimiter(RateLimiterStrategy.OneHundredPerMinute), validate(T.DocumentsMoveSchema), transaction(), async (ctx: APIContext) => { @@ -1439,6 +1442,7 @@ router.post( router.post( "documents.archive", auth(), + rateLimiter(RateLimiterStrategy.OneHundredPerMinute), validate(T.DocumentsArchiveSchema), transaction(), async (ctx: APIContext) => { @@ -1465,6 +1469,7 @@ router.post( router.post( "documents.delete", auth(), + rateLimiter(RateLimiterStrategy.OneHundredPerMinute), validate(T.DocumentsDeleteSchema), transaction(), async (ctx: APIContext) => { @@ -1509,6 +1514,7 @@ router.post( router.post( "documents.unpublish", auth(), + rateLimiter(RateLimiterStrategy.OneHundredPerMinute), validate(T.DocumentsUnpublishSchema), transaction(), async (ctx: APIContext) => { @@ -1793,6 +1799,7 @@ router.post( router.post( "documents.remove_user", auth(), + rateLimiter(RateLimiterStrategy.OneHundredPerHour), validate(T.DocumentsRemoveUserSchema), transaction(), async (ctx: APIContext) => { @@ -1838,6 +1845,7 @@ router.post( router.post( "documents.add_group", auth(), + rateLimiter(RateLimiterStrategy.OneHundredPerHour), validate(T.DocumentsAddGroupSchema), transaction(), async (ctx: APIContext) => { @@ -1898,6 +1906,7 @@ router.post( router.post( "documents.remove_group", auth(), + rateLimiter(RateLimiterStrategy.OneHundredPerHour), validate(T.DocumentsRemoveGroupSchema), transaction(), async (ctx: APIContext) => { @@ -2064,6 +2073,7 @@ router.post( router.post( "documents.empty_trash", auth({ role: UserRole.Admin }), + rateLimiter(RateLimiterStrategy.TenPerHour), async (ctx: APIContext) => { const { user } = ctx.state.auth; From 6268bc149a0b4f639d64af987d3d8a90fb30463f Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 08:25:25 -0400 Subject: [PATCH 05/34] fix: Add missing zod schema check for incoming document.text (#13143) * fix: Add missing zod schema check for incoming document.text * feedback * test --- server/models/Document.ts | 4 +++ server/routes/api/documents/documents.test.ts | 27 +++++++++++++++++++ server/routes/api/documents/schema.ts | 5 ++-- shared/validations.ts | 3 +++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/server/models/Document.ts b/server/models/Document.ts index e835d427fe..6f50b88e83 100644 --- a/server/models/Document.ts +++ b/server/models/Document.ts @@ -356,6 +356,10 @@ class Document extends ArchivableModel< * @deprecated Use `content` instead, or `DocumentHelper.toMarkdown` if exporting lossy markdown. * This column will be removed in a future migration. */ + @SimpleLength({ + max: DocumentValidation.maxLength, + msg: `Document text content must be ${DocumentValidation.maxLength} characters or less`, + }) @Column(DataType.TEXT) @SkipChangeset text: string; diff --git a/server/routes/api/documents/documents.test.ts b/server/routes/api/documents/documents.test.ts index 3d67928c2f..9872b55dbd 100644 --- a/server/routes/api/documents/documents.test.ts +++ b/server/routes/api/documents/documents.test.ts @@ -10,6 +10,7 @@ import { UserRole, } from "@shared/types"; import { TextHelper } from "@shared/utils/TextHelper"; +import { DocumentValidation } from "@shared/validations"; import { createContext } from "@server/context"; import { parser } from "@server/editor"; import type { Group, User } from "@server/models"; @@ -3456,6 +3457,17 @@ describe("#documents.create", () => { expect(body.data.title).toEqual(""); }); + it("should not create a document with text over the maximum length", async () => { + const user = await buildUser(); + const res = await server.post("/api/documents.create", user, { + body: { + title: "title", + text: "a".repeat(DocumentValidation.maxLength + 1), + }, + }); + expect(res.status).toEqual(400); + }); + it("should use template title when doc is created using a template and title is not explicitly passed", async () => { const user = await buildUser(); const template = await buildTemplate({ @@ -3794,6 +3806,21 @@ describe("#documents.update", () => { expect(events.length).toEqual(1); }); + it("should not update a document with text over the maximum length", async () => { + const user = await buildUser(); + const document = await buildDocument({ + userId: user.id, + teamId: user.teamId, + }); + const res = await server.post("/api/documents.update", user, { + body: { + id: document.id, + text: "a".repeat(DocumentValidation.maxLength + 1), + }, + }); + expect(res.status).toEqual(400); + }); + it("should not allow publishing a draft without specifying the collection", async () => { const team = await buildTeam(); const user = await buildUser({ teamId: team.id }); diff --git a/server/routes/api/documents/schema.ts b/server/routes/api/documents/schema.ts index d50844cd15..c314a6d110 100644 --- a/server/routes/api/documents/schema.ts +++ b/server/routes/api/documents/schema.ts @@ -8,6 +8,7 @@ import { TextEditMode, SortFilter, } from "@shared/types"; +import { DocumentValidation } from "@shared/validations"; import { BaseSchema } from "@server/routes/api/schema"; import { zodIconType, zodIdType, zodShareIdType } from "@server/utils/zod"; import { ValidateColor } from "@server/validation"; @@ -264,7 +265,7 @@ export const DocumentsUpdateSchema = BaseSchema.extend({ title: z.string().optional(), /** Doc text to be updated */ - text: z.string().optional(), + text: z.string().max(DocumentValidation.maxLength).optional(), /** Icon displayed alongside doc title */ icon: zodIconType().nullish(), @@ -428,7 +429,7 @@ export const DocumentsCreateSchema = BaseSchema.extend({ title: z.string().optional(), /** Document text */ - text: z.string().optional(), + text: z.string().max(DocumentValidation.maxLength).optional(), /** Icon displayed alongside doc title */ icon: zodIconType().optional(), diff --git a/shared/validations.ts b/shared/validations.ts index 612f6cc26f..1dbe024386 100644 --- a/shared/validations.ts +++ b/shared/validations.ts @@ -64,6 +64,9 @@ export const DocumentValidation = { /** The maximum recommended size of the document content */ maxRecommendedLength: 250000, + + /** The maximum length of the document text content */ + maxLength: 1500 * 1024, }; export const GroupValidation = { From 6190684d594f43ce3863e64a7f4cafc5ccf47add Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 11:41:55 -0400 Subject: [PATCH 06/34] fix: `collaboratorIds `async/distributed nature should not guard persistence (#13145) * fix: collaboratorIds async/distributed should not guard persistence * feedback --- server/collaboration/PersistenceExtension.ts | 40 ++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/server/collaboration/PersistenceExtension.ts b/server/collaboration/PersistenceExtension.ts index b73e697b88..b0cb8e86cb 100644 --- a/server/collaboration/PersistenceExtension.ts +++ b/server/collaboration/PersistenceExtension.ts @@ -1,6 +1,7 @@ import type { onStoreDocumentPayload, onLoadDocumentPayload, + afterLoadDocumentPayload, onChangePayload, Extension, } from "@hocuspocus/server"; @@ -17,6 +18,9 @@ import type { withContext } from "./types"; @trace() export default class PersistenceExtension implements Extension { + /** The names of documents that have changed since they were last persisted. */ + private unsavedDocumentNames = new Set(); + async onLoadDocument({ documentName, ...data @@ -96,6 +100,18 @@ export default class PersistenceExtension implements Extension { }); } + async afterLoadDocument({ + documentName, + document, + }: afterLoadDocumentPayload) { + // Track changes from the ydoc itself rather than the onChange hook, which + // runs behind other extensions in an async chain and so may not have + // recorded the change by the time the document is stored on disconnect. + document.on("update", () => { + this.unsavedDocumentNames.add(documentName); + }); + } + async onChange({ context, documentName }: withContext) { const [, documentId] = documentName.split("."); @@ -120,13 +136,28 @@ export default class PersistenceExtension implements Extension { const [, documentId] = documentName.split("."); const clientVersion = requestParameters.get("editorVersion"); - const key = Document.getCollaboratorKey(documentId); - const sessionCollaboratorIds = await Redis.defaultClient.smembers(key); - if (!sessionCollaboratorIds || sessionCollaboratorIds.length === 0) { + // Nothing to do if the document hasn't changed since it was last persisted. + // Note the flag is cleared before writing so that changes received while + // persisting will schedule another store. + if (!this.unsavedDocumentNames.delete(documentName)) { Logger.debug("multiplayer", `No changes for ${documentName}`); return; } + // Collaborators are used for attribution only, failure to load them must + // not prevent the document itself from being persisted. + let sessionCollaboratorIds: string[] = []; + + try { + const key = Document.getCollaboratorKey(documentId); + sessionCollaboratorIds = await Redis.defaultClient.smembers(key); + } catch (err) { + Logger.warn("Unable to load collaborators for document", { + documentId, + message: toError(err).message, + }); + } + try { await documentCollaborativeUpdater({ documentId, @@ -136,6 +167,9 @@ export default class PersistenceExtension implements Extension { clientVersion, }); } catch (err) { + // Restore the flag so that a subsequent store will retry the write. + this.unsavedDocumentNames.add(documentName); + Logger.error("Unable to persist document", toError(err), { documentId, userId: context.user?.id, From 84c4cbc43122961476f75d417ea6fc5bd1761f13 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 16:49:24 -0400 Subject: [PATCH 07/34] fix: Narrow validation on relationships.list (#13147) --- .../api/relationships/relationships.test.ts | 89 ++++++++++++++++--- .../routes/api/relationships/relationships.ts | 41 ++++++--- server/routes/api/relationships/schema.ts | 5 +- 3 files changed, 109 insertions(+), 26 deletions(-) diff --git a/server/routes/api/relationships/relationships.test.ts b/server/routes/api/relationships/relationships.test.ts index e9353ec689..4d2c87c7de 100644 --- a/server/routes/api/relationships/relationships.test.ts +++ b/server/routes/api/relationships/relationships.test.ts @@ -232,21 +232,33 @@ describe("#relationships.list", () => { expect(body.message).toEqual("Authentication required"); }); - it("should succeed with status 200 ok returning all relationships", async () => { + it("should fail with status 400 bad request when no anchor document is supplied", async () => { const res = await server.post("/api/relationships.list", admin); const body = await res.json(); - expect(res.status).toEqual(200); - expect(body.data).toBeTruthy(); - expect(body.data.relationships).toBeTruthy(); - expect(body.data.relationships.length).toBeGreaterThanOrEqual(3); - expect(body.data.documents).toBeTruthy(); - expect(body.pagination).toBeTruthy(); - expect(body.policies).toBeTruthy(); + expect(res.status).toEqual(400); + expect(body.message).toContain( + "One of documentId or reverseDocumentId is required" + ); + }); + + it("should fail with status 400 bad request when both anchor documents are supplied", async () => { + const res = await server.post("/api/relationships.list", admin, { + body: { + documentId: documents[0].id, + reverseDocumentId: documents[1].id, + }, + }); + const body = await res.json(); + expect(res.status).toEqual(400); + expect(body.message).toContain( + "One of documentId or reverseDocumentId is required" + ); }); it("should succeed with status 200 ok returning relationships filtered by type", async () => { const res = await server.post("/api/relationships.list", admin, { body: { + documentId: documents[0].id, type: RelationshipType.Backlink, }, }); @@ -339,6 +351,7 @@ describe("#relationships.list", () => { it("should respect pagination", async () => { const res = await server.post("/api/relationships.list", admin, { body: { + documentId: documents[1].id, limit: 1, offset: 0, }, @@ -351,16 +364,31 @@ describe("#relationships.list", () => { expect(body.pagination.offset).toEqual(0); }); - it("should return empty results when no relationships match filters", async () => { + it("should fail with status 404 not found when the anchor document does not exist", async () => { const res = await server.post("/api/relationships.list", admin, { body: { documentId: "550e8400-e29b-41d4-a716-446655440000", }, }); - const body = await res.json(); - expect(res.status).toEqual(200); - expect(body.data.relationships).toHaveLength(0); - expect(body.data.documents).toHaveLength(0); + expect(res.status).toEqual(404); + }); + + it("should fail with status 403 forbidden when user cannot read the anchor document", async () => { + const cannotAccessCollection = await buildCollection({ + teamId: user.teamId, + permission: null, + }); + const cannotAccessDocument = await buildDocument({ + collectionId: cannotAccessCollection.id, + teamId: user.teamId, + }); + + const res = await server.post("/api/relationships.list", user, { + body: { + documentId: cannotAccessDocument.id, + }, + }); + expect(res.status).toEqual(403); }); it("should only return documents that the user can read", async () => { @@ -400,4 +428,39 @@ describe("#relationships.list", () => { expect(body.data.relationships).toHaveLength(0); expect(body.data.documents).toHaveLength(0); }); + + it("should not disclose documents that the user cannot read when anchored on reverseDocumentId", async () => { + const cannotAccessCollection = await buildCollection({ + teamId: user.teamId, + permission: null, + }); + const collection = await buildCollection({ + teamId: user.teamId, + permission: CollectionPermission.Read, + }); + const userDocument = await buildDocument({ + collectionId: collection.id, + teamId: user.teamId, + }); + const cannotAccessDocument = await buildDocument({ + collectionId: cannotAccessCollection.id, + teamId: user.teamId, + }); + + await buildRelationship({ + userId: user.id, + documentId: cannotAccessDocument.id, + reverseDocumentId: userDocument.id, + }); + + const res = await server.post("/api/relationships.list", user, { + body: { + reverseDocumentId: userDocument.id, + }, + }); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.relationships).toHaveLength(0); + expect(body.data.documents).toHaveLength(0); + }); }); diff --git a/server/routes/api/relationships/relationships.ts b/server/routes/api/relationships/relationships.ts index 28c880ad9c..eb51547a5c 100644 --- a/server/routes/api/relationships/relationships.ts +++ b/server/routes/api/relationships/relationships.ts @@ -1,4 +1,5 @@ import Router from "koa-router"; +import { InvalidRequestError } from "@server/errors"; import auth from "@server/middlewares/authentication"; import validate from "@server/middlewares/validate"; import { Document, Relationship } from "@server/models"; @@ -58,32 +59,48 @@ router.post( pagination(), validate(T.RelationshipsListSchema), async (ctx: APIContext) => { + const { type, documentId, reverseDocumentId } = ctx.input.body; const { user } = ctx.state.auth; - const where = ctx.input.body || {}; + + // Results are anchored to a single document, which the user must be able to + // read. Documents on the opposite side of each relationship are filtered by + // access below. + const anchorId = documentId ?? reverseDocumentId; + if (!anchorId) { + throw InvalidRequestError( + "One of documentId or reverseDocumentId is required" + ); + } + + const anchorDocument = await Document.findByPk(anchorId, { + userId: user.id, + rejectOnEmpty: true, + }); + authorize(user, "read", anchorDocument); const relationships = await Relationship.findAll({ - where, + where: { + ...(type ? { type } : {}), + ...(documentId + ? { documentId: anchorDocument.id } + : { reverseDocumentId: anchorDocument.id }), + }, order: [["createdAt", "DESC"]], offset: ctx.state.pagination.offset, limit: ctx.state.pagination.limit, }); + const relatedDocumentId = (relationship: Relationship) => + documentId ? relationship.reverseDocumentId : relationship.documentId; + const documents = await Document.findByIds( - relationships.flatMap((relationship) => - where.reverseDocumentId - ? relationship.documentId - : relationship.reverseDocumentId - ), + relationships.map(relatedDocumentId), { userId: user.id } ); const documentIds = new Set(documents.map((d) => d.id)); const filteredRelationships = relationships.filter((relationship) => - documentIds.has( - where.reverseDocumentId - ? relationship.documentId - : relationship.reverseDocumentId - ) + documentIds.has(relatedDocumentId(relationship)) ); ctx.body = { diff --git a/server/routes/api/relationships/schema.ts b/server/routes/api/relationships/schema.ts index ae76c11499..7bdc228060 100644 --- a/server/routes/api/relationships/schema.ts +++ b/server/routes/api/relationships/schema.ts @@ -28,7 +28,10 @@ export const RelationshipsListSchema = BaseSchema.extend({ }) .optional(), }) - .optional(), + .refine( + (body) => !!body.documentId !== !!body.reverseDocumentId, + "One of documentId or reverseDocumentId is required" + ), }); export type RelationshipsListReq = z.infer; From fc409888914ed73b57fa88b2ad4c3be78463616f Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 17:35:15 -0400 Subject: [PATCH 08/34] fix: Lock contention on `documents.create` (#13149) * wip * fix: Lock contention on documents.create * revert --- server/models/Document.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/models/Document.ts b/server/models/Document.ts index 6f50b88e83..5ac8d59d5c 100644 --- a/server/models/Document.ts +++ b/server/models/Document.ts @@ -1088,7 +1088,7 @@ class Document extends ArchivableModel< const collection = await Collection.findByPk(this.collectionId, { includeDocumentStructure: true, transaction, - lock: Transaction.LOCK.UPDATE, + lock: Transaction.LOCK.NO_KEY_UPDATE, }); if (collection) { From 17452bda5b08e608b0ec3c9fbd5db6b6b2c40f28 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 17:47:34 -0400 Subject: [PATCH 09/34] Move socket management from client -> server (#13120) * Move socket management from client -> server * feedback * fix: Reconcile collection rooms on visibility change Handle collections.update transitions between private and team-visible by joining or rebuilding the collection channel, route collection events through the members channel so guests are excluded, and use removeData for the collection ids cache invalidation. --------- Co-authored-by: Claude --- app/components/WebsocketProvider.tsx | 21 +- server/models/User.test.ts | 16 ++ server/models/User.ts | 39 +++- .../queues/processors/WebsocketsProcessor.ts | 192 ++++++++++++------ server/services/websockets.ts | 57 +----- 5 files changed, 194 insertions(+), 131 deletions(-) diff --git a/app/components/WebsocketProvider.tsx b/app/components/WebsocketProvider.tsx index 17009e790e..a7d3960594 100644 --- a/app/components/WebsocketProvider.tsx +++ b/app/components/WebsocketProvider.tsx @@ -120,16 +120,6 @@ function useConnectionHandlers() { data, }); }); - - // received a message from the API server that we should request - // to join or leave a specific room. Forward that to the ws server. - socket.on("join", (event) => { - socket.emit("join", event); - }); - - socket.on("leave", (event) => { - socket.emit("leave", event); - }); }; } @@ -641,19 +631,24 @@ function useUserHandlers() { users.add(event); }); - socket.on("users.demote", async (event: PartialExcept) => { + // the current user's role changed, so their policies are invalid and the + // set of accessible collections may have changed. + const handleRoleChange = async (event: PartialExcept) => { if (event.id === auth.user?.id) { documents.all.forEach((document) => policies.remove(document.id)); try { await collections.fetchAll(); } catch (err) { Logger.error( - "Failed to fetch collections after demote", + "Failed to fetch collections after role change", toError(err) ); } } - }); + }; + + socket.on("users.promote", handleRoleChange); + socket.on("users.demote", handleRoleChange); socket.on("users.delete", (event: WebsocketEntityDeletedEvent) => { users.remove(event.modelId); diff --git a/server/models/User.test.ts b/server/models/User.test.ts index ec372570f1..b5bbc4c167 100644 --- a/server/models/User.test.ts +++ b/server/models/User.test.ts @@ -229,6 +229,22 @@ describe("user model", () => { expect(response[0]).toEqual(collection.id); }); + it("should not return a cached response after a role change", async () => { + const team = await buildTeam(); + const user = await buildGuestUser({ + teamId: team.id, + }); + const collection = await buildCollection({ + teamId: team.id, + permission: CollectionPermission.ReadWrite, + }); + expect(await user.collectionIds()).toEqual([]); + + await user.update({ role: UserRole.Member }); + + expect(await user.collectionIds()).toEqual([collection.id]); + }); + it("should not return private collections", async () => { const team = await buildTeam(); const user = await buildUser({ diff --git a/server/models/User.ts b/server/models/User.ts index 7b8577632b..10c33974b6 100644 --- a/server/models/User.ts +++ b/server/models/User.ts @@ -482,12 +482,17 @@ class User extends ParanoidModel< * Returns the user's active collection ids. This includes collections the user * has access to through group memberships. * - * @param options Additional options to pass to the find + * @param options Additional options to pass to the find, set `skipCache` to bypass the cached response * @returns An array of collection ids */ - public collectionIds = async (options: FindOptions = {}) => { + public collectionIds = async ( + options: FindOptions & { skipCache?: boolean } = {} + ) => { + const { skipCache, ...findOptions } = options; const hasOptions = - options.transaction || options.paranoid === false || options.lock; + findOptions.transaction || + findOptions.paranoid === false || + findOptions.lock; const fetchCollectionIds = async () => { const collectionStubs = await Collection.findAll({ @@ -545,13 +550,13 @@ class User extends ParanoidModel< }, ], paranoid: true, - ...options, + ...findOptions, }); return Array.from(new Set(collectionStubs.map((c) => c.id))); }; - if (hasOptions) { + if (hasOptions || skipCache) { return fetchCollectionIds(); } @@ -863,6 +868,30 @@ class User extends ParanoidModel< } } + // When a user's role changes their set of accessible collections may also + // change, so invalidate the cached collection ids. + @AfterUpdate + static async invalidateCollectionIdsAfterRoleChange( + model: User, + options: InstanceUpdateOptions> + ) { + if (!model.changed("role")) { + return; + } + + const invalidate = () => + CacheHelper.removeData( + RedisPrefixHelper.getUserCollectionIdsKey(model.id) + ); + + if (options.transaction) { + const transaction = options.transaction.parent || options.transaction; + transaction.afterCommit(invalidate); + } else { + await invalidate(); + } + } + // When a user's suspension state changes, invalidate the cached member count // for every group they belong to so the count reflects only active members. @AfterUpdate diff --git a/server/queues/processors/WebsocketsProcessor.ts b/server/queues/processors/WebsocketsProcessor.ts index 5a5717774f..987afba620 100644 --- a/server/queues/processors/WebsocketsProcessor.ts +++ b/server/queues/processors/WebsocketsProcessor.ts @@ -332,16 +332,17 @@ export default class WebsocketsProcessor { return; } + // guests are excluded as they cannot read team-visible collections + // without an explicit membership. + const rooms = collection.isPrivate + ? [`user-${event.actorId}`] + : [`user-${event.actorId}`, `team-${collection.teamId}.members`]; + socketio - .to(this.getCollectionEventChannels(event, collection)) + .to(rooms) .emit(event.name, await presentCollection(undefined, collection)); - return socketio - .to(this.getCollectionEventChannels(event, collection)) - .emit("join", { - event: event.name, - collectionId: collection.id, - }); + return socketio.in(rooms).socketsJoin(`collection-${collection.id}`); } case "collections.update": { @@ -352,9 +353,44 @@ export default class WebsocketsProcessor { return; } - return socketio + socketio .to(this.getCollectionEventChannels(event, collection)) .emit(event.name, await presentCollection(undefined, collection)); + + const { attributes, previous } = event.changes ?? {}; + + // the collection became team-visible, all team members gain access. + if (attributes?.permission && previous?.permission === null) { + return socketio + .in(`team-${collection.teamId}.members`) + .socketsJoin(`collection-${collection.id}`); + } + + // the collection became private, rebuild the channel from explicit + // memberships only. + if (attributes?.permission === null && previous?.permission) { + socketio + .in(`collection-${collection.id}`) + .socketsLeave(`collection-${collection.id}`); + + const [memberships, groupMemberships] = await Promise.all([ + UserMembership.findAll({ + where: { collectionId: collection.id }, + }), + GroupMembership.findAll({ + where: { collectionId: collection.id }, + }), + ]); + const rooms = [ + ...memberships.map((m) => `user-${m.userId}`), + ...groupMemberships.map((m) => `group-${m.groupId}`), + ]; + if (rooms.length) { + socketio.in(rooms).socketsJoin(`collection-${collection.id}`); + } + } + + return; } case "collections.delete": { @@ -412,12 +448,9 @@ export default class WebsocketsProcessor { .to(`user-${membership.userId}`) .to(`collection-${membership.collectionId}`) .emit(event.name, presentMembership(membership)); - - // tell any user clients to connect to the websocket channel for the collection - socketio.to(`user-${event.userId}`).emit("join", { - event: event.name, - collectionId: event.collectionId, - }); + socketio + .in(`user-${event.userId}`) + .socketsJoin(`collection-${event.collectionId}`); return; } @@ -444,11 +477,9 @@ export default class WebsocketsProcessor { .emit("collections.remove_user", membership); if (cannot(user, "read", collection)) { - // tell any user clients to disconnect from the websocket channel for the collection - socketio.to(`user-${event.userId}`).emit("leave", { - event: event.name, - collectionId: event.collectionId, - }); + socketio + .in(`user-${event.userId}`) + .socketsLeave(`collection-${event.collectionId}`); } return; @@ -466,11 +497,9 @@ export default class WebsocketsProcessor { .to(`group-${membership.groupId}`) .to(`collection-${membership.collectionId}`) .emit(event.name, presentGroupMembership(membership)); - - socketio.to(`group-${membership.groupId}`).emit("join", { - event: event.name, - collectionId: event.collectionId, - }); + socketio + .in(`group-${membership.groupId}`) + .socketsJoin(`collection-${event.collectionId}`); return; } @@ -504,11 +533,9 @@ export default class WebsocketsProcessor { } if (cannot(user, "read", collection)) { - // tell any user clients to disconnect from the websocket channel for the collection - socketio.to(`user-${groupUser.userId}`).emit("leave", { - event: event.name, - collectionId: event.collectionId, - }); + socketio + .in(`user-${groupUser.userId}`) + .socketsLeave(`collection-${event.collectionId}`); } } } @@ -700,11 +727,9 @@ export default class WebsocketsProcessor { socketio .to(`team-${event.teamId}`) .emit("groups.add_user", presentGroupUser(groupUser)); - - socketio.to(`user-${event.userId}`).emit("join", { - event: event.name, - groupId: event.modelId, - }); + socketio + .in(`user-${event.userId}`) + .socketsJoin(`group-${event.modelId}`); await GroupMembership.findAllInBatches( { @@ -722,12 +747,9 @@ export default class WebsocketsProcessor { "collections.add_group", presentGroupMembership(groupMembership) ); - - // tell any user clients to connect to the websocket channel for the collection - socketio.to(`user-${event.userId}`).emit("join", { - event: event.name, - collectionId: groupMembership.collectionId, - }); + socketio + .in(`user-${event.userId}`) + .socketsJoin(`collection-${groupMembership.collectionId}`); } if (groupMembership.documentId) { socketio @@ -755,11 +777,9 @@ export default class WebsocketsProcessor { socketio .to(`team-${event.teamId}`) .emit("groups.remove_user", membership); - - socketio.to(`user-${event.userId}`).emit("leave", { - event: event.name, - groupId: event.modelId, - }); + socketio + .in(`user-${event.userId}`) + .socketsLeave(`group-${event.modelId}`); const user = await User.findByPk(event.userId); if (!user) { @@ -794,11 +814,9 @@ export default class WebsocketsProcessor { ); if (cannot(user, "read", collection)) { - // tell any user clients to disconnect from the websocket channel for the collection - socketio.to(`user-${event.userId}`).emit("leave", { - event: event.name, - collectionId: groupMembership.collectionId, - }); + socketio + .in(`user-${event.userId}`) + .socketsLeave(`collection-${groupMembership.collectionId}`); } } } @@ -811,10 +829,9 @@ export default class WebsocketsProcessor { socketio.to(`team-${event.teamId}`).emit(event.name, { modelId: event.modelId, }); - socketio.to(`group-${event.modelId}`).emit("leave", { - event: event.name, - groupId: event.modelId, - }); + socketio + .in(`group-${event.modelId}`) + .socketsLeave(`group-${event.modelId}`); const groupMemberships = await GroupMembership.findAll({ where: { @@ -853,11 +870,11 @@ export default class WebsocketsProcessor { ); if (cannot(groupUser.user, "read", collection)) { - // tell any user clients to disconnect from the websocket channel for the collection - socketio.to(`user-${groupUser.userId}`).emit("leave", { - event: event.name, - collectionId: groupMembership.collectionId, - }); + socketio + .in(`user-${groupUser.userId}`) + .socketsLeave( + `collection-${groupMembership.collectionId}` + ); } } } @@ -915,16 +932,60 @@ export default class WebsocketsProcessor { return; } + case "users.promote": case "users.demote": { - return socketio + socketio .to(`user-${event.userId}`) .emit(event.name, { id: event.userId }); + + // the user's accessible collections may have changed with their role. + const user = await User.findByPk(event.userId); + if (!user) { + return; + } + + const membersRoom = `team-${user.teamId}.members`; + const accessibleCollectionIds = await user.collectionIds({ + skipCache: true, + }); + + if (user.isGuest) { + const teamCollections = await Collection.findAll({ + attributes: ["id"], + where: { teamId: user.teamId }, + }); + const accessibleCollectionIdsSet = new Set(accessibleCollectionIds); + const inaccessibleRooms = teamCollections + .map((collection) => collection.id) + .filter((id) => !accessibleCollectionIdsSet.has(id)) + .map((id) => `collection-${id}`); + + return socketio + .in(`user-${user.id}`) + .socketsLeave([membersRoom, ...inaccessibleRooms]); + } + + return socketio + .in(`user-${user.id}`) + .socketsJoin([ + membersRoom, + ...accessibleCollectionIds.map((id) => `collection-${id}`), + ]); + } + + case "users.signout": + case "users.suspend": { + // authentication is no longer valid, disconnect all of the user's clients. + return socketio.in(`user-${event.userId}`).disconnectSockets(true); } case "users.delete": { - return socketio + socketio .to(`team-${event.teamId}`) .emit(event.name, { modelId: event.userId }); + + // authentication is no longer valid, disconnect all of the user's clients. + return socketio.in(`user-${event.userId}`).disconnectSockets(true); } case "userMemberships.update": { @@ -948,10 +1009,11 @@ export default class WebsocketsProcessor { channels.push(`user-${event.actorId}`); } - if (collection.isPrivate) { - channels.push(`collection-${collection.id}`); - } else { - channels.push(`team-${collection.teamId}`); + // guests are never included in the team members channel, they receive + // events via the collection channel when they have an explicit membership. + channels.push(`collection-${collection.id}`); + if (!collection.isPrivate) { + channels.push(`team-${collection.teamId}.members`); } return channels; diff --git a/server/services/websockets.ts b/server/services/websockets.ts index ec65d2b73a..9705c6f15f 100644 --- a/server/services/websockets.ts +++ b/server/services/websockets.ts @@ -12,8 +12,7 @@ import Logger from "@server/logging/Logger"; import Metrics from "@server/logging/Metrics"; import * as Tracing from "@server/logging/tracer"; import { traceFunction } from "@server/logging/tracing"; -import { Collection, Group, User } from "@server/models"; -import { can } from "@server/policies"; +import type { User } from "@server/models"; import Redis from "@server/storage/redis"; import ShutdownHelper, { ShutdownOrder } from "@server/utils/ShutdownHelper"; import { getUserForJWT } from "@server/utils/jwt"; @@ -183,9 +182,14 @@ async function authenticated( // and user so we can send authenticated events const rooms = [`team-${user.teamId}`, `user-${user.id}`]; - // the rooms associated with collections this user has access to on - // connection. New collection and group subscriptions are managed - // from the client as needed through the 'join' event. + // the room of non-guest team members, who have access to all + // team-visible collections. + if (!user.isGuest) { + rooms.push(`team-${user.teamId}.members`); + } + + // the rooms associated with collections and groups this user + // has access to on connection. const [collectionIds, groupIds] = await Promise.all([ user.collectionIds(), user.groupIds(), @@ -194,49 +198,6 @@ async function authenticated( collectionIds.forEach((colId) => rooms.push(`collection-${colId}`)); groupIds.forEach((groupId) => rooms.push(`group-${groupId}`)); - const { id: userId } = user; - - // allow the client to request to join rooms - socket.on("join", async (event) => { - // The user is reloaded here rather than captured by this handler so the - // full model is not retained for the lifetime of the connection. - const authUser = await User.findByPk(userId); - if (!authUser) { - return; - } - - // user is joining a collection channel, because their permissions have - // changed, granting them access. - if (event.collectionId) { - const collection = await Collection.findByPk(event.collectionId, { - userId: authUser.id, - }); - - if (can(authUser, "read", collection)) { - await socket.join(`collection-${event.collectionId}`); - } - } - if (event.groupId) { - const group = await Group.scope({ - method: ["withMembership", authUser.id], - }).findByPk(event.groupId); - - if (can(authUser, "read", group)) { - await socket.join(`group-${event.groupId}`); - } - } - }); - - // allow the client to request to leave rooms - socket.on("leave", async (event) => { - if (event.collectionId) { - await socket.leave(`collection-${event.collectionId}`); - } - if (event.groupId) { - await socket.leave(`group-${event.groupId}`); - } - }); - // join all of the rooms at once await socket.join(rooms); } From 053a3fd438d3acdbdb956942d408787c3634d2a3 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 26 Jul 2026 18:51:54 -0400 Subject: [PATCH 10/34] fix: Respect move policy in sidebar drag and drop (#13150) Drop targets that reorder or reparent an item now require the `move` ability on the dragged item, so no drop cursor or highlight appears where the move would be rejected by the server. Co-authored-by: Claude --- app/components/Sidebar/components/Collections.tsx | 8 +++++--- .../Sidebar/components/DraggableCollectionLink.tsx | 2 +- app/components/Sidebar/hooks/useDragAndDrop.tsx | 12 ++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/components/Sidebar/components/Collections.tsx b/app/components/Sidebar/components/Collections.tsx index 7d273e6477..e215dbbef9 100644 --- a/app/components/Sidebar/components/Collections.tsx +++ b/app/components/Sidebar/components/Collections.tsx @@ -23,7 +23,7 @@ import Text from "@shared/components/Text"; import usePolicy from "~/hooks/usePolicy"; function Collections() { - const { documents, auth, collections } = useStores(); + const { documents, auth, collections, policies } = useStores(); const { t } = useTranslation(); const can = usePolicy(auth.team?.id); const orderedCollections = collections.allActive; @@ -46,10 +46,12 @@ function Collections() { fractionalIndex(null, orderedCollections[0].index) ); }, - canDrop: (item) => item.id !== orderedCollections[0].id, + canDrop: (item) => + item.id !== orderedCollections[0]?.id && + !!policies.abilities(item.id).move, collect: (monitor) => ({ isCollectionDropping: monitor.isOver(), - isDraggingAnyCollection: monitor.getItemType() === "collection", + isDraggingAnyCollection: monitor.canDrop(), }), }); diff --git a/app/components/Sidebar/components/DraggableCollectionLink.tsx b/app/components/Sidebar/components/DraggableCollectionLink.tsx index 612287f5bc..33367be19d 100644 --- a/app/components/Sidebar/components/DraggableCollectionLink.tsx +++ b/app/components/Sidebar/components/DraggableCollectionLink.tsx @@ -58,7 +58,7 @@ function DraggableCollectionLink({ canDrop: (item) => collection.id !== item.id && (!belowCollection || item.id !== belowCollection.id) && - policies.abilities(item.id)?.move, + !!policies.abilities(item.id).move, collect: (monitor: DropTargetMonitor) => ({ isCollectionDropping: monitor.isOver(), isDraggingAnyCollection: monitor.canDrop(), diff --git a/app/components/Sidebar/hooks/useDragAndDrop.tsx b/app/components/Sidebar/hooks/useDragAndDrop.tsx index 095798b3d3..4021242d5c 100644 --- a/app/components/Sidebar/hooks/useDragAndDrop.tsx +++ b/app/components/Sidebar/hooks/useDragAndDrop.tsx @@ -226,7 +226,7 @@ export function useDropToChangeCollection( parentRef: React.RefObject ) { const { t } = useTranslation(); - const { documents, collections, dialogs } = useStores(); + const { documents, collections, dialogs, policies } = useStores(); const can = usePolicy(collection); const startHover = useHover(parentRef, expandNode); @@ -281,7 +281,7 @@ export function useDropToChangeCollection( } } }, - canDrop: () => can.createDocument, + canDrop: (item) => can.createDocument && !!policies.abilities(item.id).move, hover: (_, monitor) => { if ( collection.hasDocuments && @@ -311,7 +311,7 @@ export function useDropToReparentDocument( parentRef: React.RefObject ) { const { t } = useTranslation(); - const { documents, collections, dialogs } = useStores(); + const { documents, collections, dialogs, policies } = useStores(); const hasChildDocuments = !!node?.children.length; const document = node ? documents.get(node.id) : undefined; const pathToNode = React.useMemo( @@ -373,7 +373,7 @@ export function useDropToReparentDocument( } }, canDrop: (item) => { - if (!node || item.id === node.id) { + if (!node || item.id === node.id || !policies.abilities(item.id).move) { return false; } @@ -425,7 +425,7 @@ export function useDropToReorderDocument( } ) { const { t } = useTranslation(); - const { documents, collections, dialogs } = useStores(); + const { documents, collections, dialogs, policies } = useStores(); const document = documents.get(node.id); @@ -435,7 +435,7 @@ export function useDropToReorderDocument( if (item.id === node.id || (document && !document.isActive)) { return false; } - return true; + return !!policies.abilities(item.id).move; }, drop: async (item) => { if (!collection?.isManualSort && item.collectionId === collection?.id) { From 86335325e8b2f1acf9dece697a1861aaedb7d453 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 17:43:06 -0400 Subject: [PATCH 11/34] fix: attachments.redirect should be considered in read scope. (#13155) closes #13152 --- server/middlewares/authentication.ts | 5 ++++- shared/helpers/AuthenticationHelper.test.ts | 10 ++++++++++ shared/helpers/AuthenticationHelper.ts | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/server/middlewares/authentication.ts b/server/middlewares/authentication.ts index 014b8a8d8d..2b57e8c69f 100644 --- a/server/middlewares/authentication.ts +++ b/server/middlewares/authentication.ts @@ -1,5 +1,6 @@ import type { Next } from "koa"; import { capitalize } from "es-toolkit/compat"; +import httpErrors from "http-errors"; import type { UserRole } from "@shared/types"; import { UserRoleHelper } from "@shared/utils/UserRoleHelper"; import tracer, { @@ -64,7 +65,9 @@ export default function auth(options: AuthenticationOptions = {}) { ); } } catch (err) { - if (options.optional) { + // Credentials that are valid but insufficient are always surfaced, + // otherwise the request would be silently downgraded to anonymous. + if (options.optional && !(err instanceof httpErrors.Forbidden)) { ctx.state.auth = {}; } else { throw err; diff --git a/shared/helpers/AuthenticationHelper.test.ts b/shared/helpers/AuthenticationHelper.test.ts index cb279ff8a0..0cc654925f 100644 --- a/shared/helpers/AuthenticationHelper.test.ts +++ b/shared/helpers/AuthenticationHelper.test.ts @@ -93,6 +93,15 @@ describe("AuthenticationHelper", () => { expect(canAccess("/api/documents.memberships", scopes)).toBe(false); }); + it("attachments read scope grants access to redirect", async () => { + const scopes = ["attachments:read"]; + + expect(canAccess("/api/attachments.info", scopes)).toBe(true); + expect(canAccess("/api/attachments.redirect", scopes)).toBe(true); + expect(canAccess("/api/attachments.create", scopes)).toBe(false); + expect(canAccess("/api/attachments.delete", scopes)).toBe(false); + }); + it("write", async () => { const scopes = ["documents:write"]; @@ -132,6 +141,7 @@ describe("AuthenticationHelper", () => { expect(canAccess("/api/collections.group_memberships", scopes)).toBe( true ); + expect(canAccess("/api/attachments.redirect", scopes)).toBe(true); expect(canAccess("/api/documents.create", scopes)).toBe(false); expect(canAccess("/api/documents.update", scopes)).toBe(false); expect(canAccess("/api/users.create", scopes)).toBe(false); diff --git a/shared/helpers/AuthenticationHelper.ts b/shared/helpers/AuthenticationHelper.ts index b0293c1cf9..998977bfec 100644 --- a/shared/helpers/AuthenticationHelper.ts +++ b/shared/helpers/AuthenticationHelper.ts @@ -10,6 +10,7 @@ export default class AuthenticationHelper { * - `documents.info` -> `Scope.Read` * - `collections.memberships` -> `Scope.Read` * - `collections.group_memberships` -> `Scope.Read` + * - `attachments.redirect` -> `Scope.Read` */ private static methodToScope = { create: Scope.Create, @@ -21,6 +22,7 @@ export default class AuthenticationHelper { drafts: Scope.Read, viewed: Scope.Read, export: Scope.Read, + redirect: Scope.Read, memberships: Scope.Read, group_memberships: Scope.Read, }; From 758bc89a35e63f38fa9cd91228b2dab49d078172 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 17:43:24 -0400 Subject: [PATCH 12/34] chore(deps): bump the sentry group with 2 updates (#13157) Bumps the sentry group with 2 updates: [@sentry/node](https://github.com/getsentry/sentry-javascript) and [@sentry/react](https://github.com/getsentry/sentry-javascript). Updates `@sentry/node` from 10.65.0 to 10.68.0 - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/10.68.0/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-javascript/compare/10.65.0...10.68.0) Updates `@sentry/react` from 10.65.0 to 10.68.0 - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/10.68.0/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-javascript/compare/10.65.0...10.68.0) --- updated-dependencies: - dependency-name: "@sentry/node" dependency-version: 10.68.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: sentry - dependency-name: "@sentry/react" dependency-version: 10.68.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: sentry ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 4 +- yarn.lock | 195 +++++++++++++++++++++++++-------------------------- 2 files changed, 99 insertions(+), 100 deletions(-) diff --git a/package.json b/package.json index b3753953b7..73e784ad9b 100644 --- a/package.json +++ b/package.json @@ -102,8 +102,8 @@ "@radix-ui/react-toolbar": "^1.1.15", "@radix-ui/react-tooltip": "^1.2.12", "@radix-ui/react-visually-hidden": "^1.2.7", - "@sentry/node": "^10.65.0", - "@sentry/react": "^10.65.0", + "@sentry/node": "^10.68.0", + "@sentry/react": "^10.68.0", "@simplewebauthn/browser": "^13.3.0", "@simplewebauthn/server": "^13.3.1", "@tanstack/react-table": "^8.21.3", diff --git a/yarn.lock b/yarn.lock index bfed688357..87b9a525d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28,21 +28,21 @@ __metadata: languageName: node linkType: hard -"@apm-js-collab/code-transformer-bundler-plugins@npm:^0.5.0": - version: 0.5.0 - resolution: "@apm-js-collab/code-transformer-bundler-plugins@npm:0.5.0" +"@apm-js-collab/code-transformer-bundler-plugins@npm:0.7.1": + version: 0.7.1 + resolution: "@apm-js-collab/code-transformer-bundler-plugins@npm:0.7.1" dependencies: - "@apm-js-collab/code-transformer": "npm:^0.15.0" + "@apm-js-collab/code-transformer": "npm:^0.18.0" es-module-lexer: "npm:^2.1.0" magic-string: "npm:^0.30.21" module-details-from-path: "npm:^1.0.4" - checksum: 10c0/c3a049ea8d55004708172ba5063ada786f0c5f4f7593b37c8449d44fb77b75b965c236718dc6322b5e7bf623e94e6b4cc3a6bf1454d489341a5347101ebefcce + checksum: 10c0/430570eb8c64a20418bad98a5d09179f2911a69fbf39bcc284add0654acc66d5c07e629ac92dfa92569517d6220b4aedb94e5f7dd5e5b9a36095878dd53cad6b languageName: node linkType: hard -"@apm-js-collab/code-transformer@npm:^0.15.0": - version: 0.15.0 - resolution: "@apm-js-collab/code-transformer@npm:0.15.0" +"@apm-js-collab/code-transformer@npm:^0.18.0": + version: 0.18.1 + resolution: "@apm-js-collab/code-transformer@npm:0.18.1" dependencies: "@types/estree": "npm:^1.0.8" astring: "npm:^1.9.0" @@ -52,18 +52,18 @@ __metadata: source-map: "npm:^0.6.0" bin: code-transformer: cli.js - checksum: 10c0/675772aa5f9ed57e64fb26e56a3b2c69dc551421249f955f508817d0c9ba83ecc4a176156e71b427e33f1704fdea6cb60b1126188ec4fa0466651ba8861d7c95 + checksum: 10c0/253ba76f7efec39a337327e5f23029ab5a8c5b3e3db4e1c41b97636b8e842372c285301f7a3e3a19d344eb9a680091926f6f38e06bdd6233f33a958777094322 languageName: node linkType: hard -"@apm-js-collab/tracing-hooks@npm:^0.10.1": - version: 0.10.1 - resolution: "@apm-js-collab/tracing-hooks@npm:0.10.1" +"@apm-js-collab/tracing-hooks@npm:^0.13.0": + version: 0.13.0 + resolution: "@apm-js-collab/tracing-hooks@npm:0.13.0" dependencies: - "@apm-js-collab/code-transformer": "npm:^0.15.0" + "@apm-js-collab/code-transformer": "npm:^0.18.0" debug: "npm:^4.4.1" module-details-from-path: "npm:^1.0.4" - checksum: 10c0/4787052784177aa7be18577cd6c2adcf023193986b575b809cb157d0cd5d16865144c7b25bdba96aa131f515d8ac33b783f21e2dc0cc48f6c010c898f9bc89b7 + checksum: 10c0/2891fc52b8aa2b68d59674f40f1340ce71ac68f6aff07394146565a5afcc10d99b8efe2d05af1346c188d440fcbb53c9d48eb017012417109740207e8a85e390 languageName: node linkType: hard @@ -5659,62 +5659,62 @@ __metadata: languageName: node linkType: hard -"@sentry/browser-utils@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/browser-utils@npm:10.65.0" +"@sentry/browser-utils@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/browser-utils@npm:10.68.0" dependencies: - "@sentry/conventions": "npm:^0.15.1" - "@sentry/core": "npm:10.65.0" - checksum: 10c0/f396074e3349bc73c15c1c4f6e935ebd9288f78b8865f58bed48f99eb3dc33f8e4b8abcb66c1e0680e0878fab4c089ac8013b257f25bc9cff539314a7ec120ce + "@sentry/conventions": "npm:^0.16.0" + "@sentry/core": "npm:10.68.0" + checksum: 10c0/bffa78e8a6959da2307da23f1a2784cc263c5fd20bba782fa056ad8150cd0525e67ea5182258b23c319d2f9d2be8c9684ebd0a289da1272f1d3d12489615064b languageName: node linkType: hard -"@sentry/browser@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/browser@npm:10.65.0" +"@sentry/browser@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/browser@npm:10.68.0" dependencies: - "@sentry/browser-utils": "npm:10.65.0" - "@sentry/conventions": "npm:^0.15.1" - "@sentry/core": "npm:10.65.0" - "@sentry/feedback": "npm:10.65.0" - "@sentry/replay": "npm:10.65.0" - "@sentry/replay-canvas": "npm:10.65.0" - checksum: 10c0/52b791967280ab245cca8447cd22bc78c9610f1bea4e03f1eb477a6f67e4d2cbc43a663d8890991c6bc435df1c50796694e95125d37cadd6c8823d7d23603843 + "@sentry/browser-utils": "npm:10.68.0" + "@sentry/conventions": "npm:^0.16.0" + "@sentry/core": "npm:10.68.0" + "@sentry/feedback": "npm:10.68.0" + "@sentry/replay": "npm:10.68.0" + "@sentry/replay-canvas": "npm:10.68.0" + checksum: 10c0/9d2f4c3c2c269adc07a819d945e5396ae313f774342d5993e2dc4db252508b1c983a4569e5b8e43b0d5d83c4a6b88a4caee1e2c941b8f362e4b6580dabe52a1d languageName: node linkType: hard -"@sentry/conventions@npm:^0.15.1": - version: 0.15.1 - resolution: "@sentry/conventions@npm:0.15.1" - checksum: 10c0/b80f6ad6a76335bd92a599303297781c507a39b7d89301a82e887e88f8450a550a0e31c528b16d37f5d23c5bcfee16731cdc82ef8e2e788ebc5fe764cdeb7d50 +"@sentry/conventions@npm:^0.16.0": + version: 0.16.0 + resolution: "@sentry/conventions@npm:0.16.0" + checksum: 10c0/415aaa94cade2b8e0dd00ad9aa06d998d7fe95658a8f43b6e4ef382e3b4c115c8f199ca0fe9b74a98500e8270dc68d5333fd943f7dad6ed78f60d9372231fbe8 languageName: node linkType: hard -"@sentry/core@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/core@npm:10.65.0" +"@sentry/core@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/core@npm:10.68.0" dependencies: - "@sentry/conventions": "npm:^0.15.1" - checksum: 10c0/df8b205dcedabd5a28f66744e3f10ebe852709414ecbd61c26dc5c8d718778be462f1010ebfe948b9ea9e6af6d0a3fd094a9c8c9d97054b13ae3b9deccf20e06 + "@sentry/conventions": "npm:^0.16.0" + checksum: 10c0/bd69b7d949699020058bdd0f0de5d384c403636aeddba9feb7e37492e554b46b1193c5ed88598ad58d2f21c6b00c912ff216ec68af7a70a749df4b052b8e3e99 languageName: node linkType: hard -"@sentry/feedback@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/feedback@npm:10.65.0" +"@sentry/feedback@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/feedback@npm:10.68.0" dependencies: - "@sentry/core": "npm:10.65.0" - checksum: 10c0/043aa8a6a9cc5eaa64f650c09fa0f988275de54f73dc3e6bfebb3b91fce0ddca23e600ff4090c89d8ba82dbad76d1fce9dd5712798cfbb595434462551588157 + "@sentry/core": "npm:10.68.0" + checksum: 10c0/1e03ede884a2ac4dc8965c1bc1bc71344c408c76039eb13ef1c734ce1c5d9e1ce20a937e55ed14945b15d088cd8257556538e780c904512e1348a856c64e0250 languageName: node linkType: hard -"@sentry/node-core@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/node-core@npm:10.65.0" +"@sentry/node-core@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/node-core@npm:10.68.0" dependencies: - "@sentry/conventions": "npm:^0.15.1" - "@sentry/core": "npm:10.65.0" - "@sentry/opentelemetry": "npm:10.65.0" + "@sentry/conventions": "npm:^0.16.0" + "@sentry/core": "npm:10.68.0" + "@sentry/opentelemetry": "npm:10.68.0" import-in-the-middle: "npm:^3.0.0" peerDependencies: "@opentelemetry/api": ^1.9.0 @@ -5733,85 +5733,84 @@ __metadata: optional: true "@opentelemetry/sdk-trace-base": optional: true - checksum: 10c0/33110e9e435a05c1df39b340549bb0ad32c26d5d15a8b2eefe4fa858c4efca686cddf548b02eb541bdb4ac98a18c7163451e0962177eb6d47f5889324e614b73 + checksum: 10c0/47068db94111777e74a5aa119d5f4ca7ce2551479ccc465e08078323511e198f607698d6a56e57d586c66e0e97fb291475bd5c87f9fb04ad6a5e507f9b12f7d0 languageName: node linkType: hard -"@sentry/node@npm:^10.65.0": - version: 10.65.0 - resolution: "@sentry/node@npm:10.65.0" +"@sentry/node@npm:^10.68.0": + version: 10.68.0 + resolution: "@sentry/node@npm:10.68.0" dependencies: "@opentelemetry/api": "npm:^1.9.1" "@opentelemetry/instrumentation": "npm:^0.220.0" "@opentelemetry/sdk-trace-base": "npm:^2.9.0" - "@sentry/conventions": "npm:^0.15.1" - "@sentry/core": "npm:10.65.0" - "@sentry/node-core": "npm:10.65.0" - "@sentry/opentelemetry": "npm:10.65.0" - "@sentry/server-utils": "npm:10.65.0" + "@sentry/conventions": "npm:^0.16.0" + "@sentry/core": "npm:10.68.0" + "@sentry/node-core": "npm:10.68.0" + "@sentry/opentelemetry": "npm:10.68.0" + "@sentry/server-utils": "npm:10.68.0" import-in-the-middle: "npm:^3.0.0" - checksum: 10c0/b444e36bcb3d304152026185614ddea7299cea6c4a4e4e8e5f317381d0e4ef77309b609ba317f73524565e9ca0ef9ee4b12178984ba0840c39466cd8b7c2d4ae + checksum: 10c0/255fe87e6cf5b2d101c001a044e4ede6c79f0b040dafe1b639047c06afe6d677385008e2ad39875808f5fb2d3836a6e8338c3b8b24a9f583e89e001e6bc4c770 languageName: node linkType: hard -"@sentry/opentelemetry@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/opentelemetry@npm:10.65.0" +"@sentry/opentelemetry@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/opentelemetry@npm:10.68.0" dependencies: - "@sentry/conventions": "npm:^0.15.1" - "@sentry/core": "npm:10.65.0" + "@sentry/conventions": "npm:^0.16.0" + "@sentry/core": "npm:10.68.0" peerDependencies: "@opentelemetry/api": ^1.9.0 "@opentelemetry/core": ^1.30.1 || ^2.1.0 "@opentelemetry/sdk-trace-base": ^1.30.1 || ^2.1.0 - checksum: 10c0/695e608eb886eaa725d0e093019018771e876f64d4a4edaea2f38fc0809aa54df93ba1de8f843a6dfffc11e754e9fdaa0bbfaef025afe2de6f889dd190a273e0 + checksum: 10c0/00be0fe66339e1617e6dc076d64411ccf3604930a0030efc1f82e5f68cebd47199c18aa9766c775a9fa50276c35f0488a73e1a580af7a71ae069dfd35dd6596e languageName: node linkType: hard -"@sentry/react@npm:^10.65.0": - version: 10.65.0 - resolution: "@sentry/react@npm:10.65.0" +"@sentry/react@npm:^10.68.0": + version: 10.68.0 + resolution: "@sentry/react@npm:10.68.0" dependencies: - "@sentry/browser": "npm:10.65.0" - "@sentry/conventions": "npm:^0.15.1" - "@sentry/core": "npm:10.65.0" + "@sentry/browser": "npm:10.68.0" + "@sentry/conventions": "npm:^0.16.0" + "@sentry/core": "npm:10.68.0" peerDependencies: react: ^16.14.0 || 17.x || 18.x || 19.x - checksum: 10c0/da4300eb6b6b998ba46d7ecd2acf019c912a8f7dab9c88b3d3d2f02bb4bec947c7d3318a88673d4bd040d43d6e4ed26309cdbbde2dcc2c47f62efd99b4e63589 + checksum: 10c0/c839eb7f896415990839c52a0cfe55e9ec4ddd545b7592baf87410c626fc9c712ecda5cb3193a6d71a29cd90b5732b6a33e86dea801b83286b6f4d7c9b747faf languageName: node linkType: hard -"@sentry/replay-canvas@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/replay-canvas@npm:10.65.0" +"@sentry/replay-canvas@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/replay-canvas@npm:10.68.0" dependencies: - "@sentry/core": "npm:10.65.0" - "@sentry/replay": "npm:10.65.0" - checksum: 10c0/9889a3abf0b5ca9531e44fea768dda6ca04fa9cb2298f2ea1407619e5879539ed382f3b2b4576a6ae9706caef56259450faf520152120d942b9741022e124c58 + "@sentry/core": "npm:10.68.0" + "@sentry/replay": "npm:10.68.0" + checksum: 10c0/e421dd0f67a024a1eaf1b975e07c974f04272bcaf9fb73b258c2addacbe85fab1527b313cd8150fc0dcf19109387f04c79cc121831caa29825d8b1319d0d0be6 languageName: node linkType: hard -"@sentry/replay@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/replay@npm:10.65.0" +"@sentry/replay@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/replay@npm:10.68.0" dependencies: - "@sentry/browser-utils": "npm:10.65.0" - "@sentry/core": "npm:10.65.0" - checksum: 10c0/2d7d815549b8d590c936abcaa07916aefd40913762f89b0d053e98d7e170cc6be166adc5dad0001e47fa7d3cfe82bd5064da5f64b6a45d1b6da1b53fda567b3f + "@sentry/browser-utils": "npm:10.68.0" + "@sentry/core": "npm:10.68.0" + checksum: 10c0/1320834bc0b773a702cb94868d80c9357c4ceeafb62670c5f02344cd96df2e777e94dbbc212d559c2b7e0591046b6ff0900e88eeeeefbcb4b8a793d52ae3b91a languageName: node linkType: hard -"@sentry/server-utils@npm:10.65.0": - version: 10.65.0 - resolution: "@sentry/server-utils@npm:10.65.0" +"@sentry/server-utils@npm:10.68.0": + version: 10.68.0 + resolution: "@sentry/server-utils@npm:10.68.0" dependencies: - "@apm-js-collab/code-transformer": "npm:^0.15.0" - "@apm-js-collab/code-transformer-bundler-plugins": "npm:^0.5.0" - "@apm-js-collab/tracing-hooks": "npm:^0.10.1" - "@sentry/conventions": "npm:^0.15.1" - "@sentry/core": "npm:10.65.0" - magic-string: "npm:~0.30.0" - checksum: 10c0/10c23dd3a62ec3b179adab3cae1a63936b57dc8d7ed8d1cd757afe812d77dd1e015c6253c2fd79ae4e70dc1d30d807ab0bcbd3578787245eebadd6ff5db441cc + "@apm-js-collab/code-transformer-bundler-plugins": "npm:0.7.1" + "@apm-js-collab/tracing-hooks": "npm:^0.13.0" + "@sentry/conventions": "npm:^0.16.0" + "@sentry/core": "npm:10.68.0" + meriyah: "npm:^6.1.4" + checksum: 10c0/cd9ee4fd56bd4dcdb04b8a06c17da99490b027ffb06c00299f43d8030c701b23f2e5227c345e250fbf4a715d554b338722e6c68cb75024709f35adc31674b4b8 languageName: node linkType: hard @@ -14296,7 +14295,7 @@ __metadata: languageName: node linkType: hard -"magic-string@npm:^0.30.21, magic-string@npm:^0.30.3, magic-string@npm:~0.30.0": +"magic-string@npm:^0.30.21, magic-string@npm:^0.30.3": version: 0.30.21 resolution: "magic-string@npm:0.30.21" dependencies: @@ -15446,8 +15445,8 @@ __metadata: "@radix-ui/react-tooltip": "npm:^1.2.12" "@radix-ui/react-visually-hidden": "npm:^1.2.7" "@relative-ci/agent": "npm:^4.3.1" - "@sentry/node": "npm:^10.65.0" - "@sentry/react": "npm:^10.65.0" + "@sentry/node": "npm:^10.68.0" + "@sentry/react": "npm:^10.68.0" "@simplewebauthn/browser": "npm:^13.3.0" "@simplewebauthn/server": "npm:^13.3.1" "@swc/cli": "npm:^0.8.1" From 1bd800b7146668621c6b6e09c9c00924ab388c24 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 17:43:56 -0400 Subject: [PATCH 13/34] chore(deps-dev): bump @types/readable-stream from 4.0.23 to 4.0.24 (#13158) Bumps [@types/readable-stream](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/readable-stream) from 4.0.23 to 4.0.24. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/readable-stream) --- updated-dependencies: - dependency-name: "@types/readable-stream" dependency-version: 4.0.24 dependency-type: direct:development 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 | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 73e784ad9b..ac111d7dd2 100644 --- a/package.json +++ b/package.json @@ -331,7 +331,7 @@ "@types/react-router-dom": "^5.3.3", "@types/react-virtualized-auto-sizer": "^1.0.8", "@types/react-window": "^1.8.8", - "@types/readable-stream": "^4.0.23", + "@types/readable-stream": "^4.0.24", "@types/redis-info": "^3.0.3", "@types/refractor": "^3.4.1", "@types/resolve-path": "^1.4.3", diff --git a/yarn.lock b/yarn.lock index 87b9a525d0..1c8755511c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7276,12 +7276,12 @@ __metadata: languageName: node linkType: hard -"@types/readable-stream@npm:^4.0.23": - version: 4.0.23 - resolution: "@types/readable-stream@npm:4.0.23" +"@types/readable-stream@npm:^4.0.24": + version: 4.0.24 + resolution: "@types/readable-stream@npm:4.0.24" dependencies: "@types/node": "npm:*" - checksum: 10c0/89ae3f6a53d186252c4c957b715c8dc12b318be30aeb3546f6513163572e5eebe0f61261e70c6d3f7496d63741ed6f92fbc5d17bfe9a72b0abfe720ee8fa471a + checksum: 10c0/12498861c5868d6b887bf60e0d32d85db6c65730ecc7db0e7c15ab92942f6e107af276e23e4a7ebac6ed018f7ec43517fdf4fee4f1a279196752fe0e59b6aadc languageName: node linkType: hard @@ -15504,7 +15504,7 @@ __metadata: "@types/react-router-dom": "npm:^5.3.3" "@types/react-virtualized-auto-sizer": "npm:^1.0.8" "@types/react-window": "npm:^1.8.8" - "@types/readable-stream": "npm:^4.0.23" + "@types/readable-stream": "npm:^4.0.24" "@types/redis-info": "npm:^3.0.3" "@types/refractor": "npm:^3.4.1" "@types/resolve-path": "npm:^1.4.3" From 2a1c0fd2afb56aa0833bc67ac65a9c552c7bf4be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 17:44:05 -0400 Subject: [PATCH 14/34] chore(deps): bump dd-trace from 5.115.0 to 5.117.0 (#13160) Bumps [dd-trace](https://github.com/DataDog/dd-trace-js) from 5.115.0 to 5.117.0. - [Release notes](https://github.com/DataDog/dd-trace-js/releases) - [Commits](https://github.com/DataDog/dd-trace-js/compare/v5.115.0...v5.117.0) --- updated-dependencies: - dependency-name: dd-trace dependency-version: 5.117.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 46 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index ac111d7dd2..76b61b6eb9 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,7 @@ "core-js": "^3.49.0", "crypto-js": "^4.2.0", "date-fns": "^3.6.0", - "dd-trace": "^5.115.0", + "dd-trace": "^5.117.0", "diff": "^5.2.2", "email-providers": "^1.14.0", "emoji-mart": "^5.6.0", diff --git a/yarn.lock b/yarn.lock index 1c8755511c..cbed567b12 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1738,15 +1738,15 @@ __metadata: languageName: node linkType: hard -"@datadog/pprof@npm:5.15.1": - version: 5.15.1 - resolution: "@datadog/pprof@npm:5.15.1" +"@datadog/pprof@npm:5.17.0": + version: 5.17.0 + resolution: "@datadog/pprof@npm:5.17.0" dependencies: node-gyp: "npm:latest" node-gyp-build: "npm:^4.8.4" pprof-format: "npm:^2.2.1" - source-map: "npm:^0.7.4" - checksum: 10c0/20d4a8f7873e0ff501bfa0bc712556216d6f5fb2dbb1286846ff17545b985391cb59318b0dfd85801d208a3314ef075dd84c2a6441b6fd8e9e1b6b65f0285ef2 + source-map: "npm:^0.8.0" + checksum: 10c0/e3e405dbf387c748ed3c5f976d7a3c487233d6c9866f4125b9a008e32d174c7657c7c81925a1a1239684b4eb3bebcd2694d53bbe99b04514c93de61856e0aa02 languageName: node linkType: hard @@ -9932,21 +9932,21 @@ __metadata: languageName: node linkType: hard -"dd-trace@npm:^5.115.0": - version: 5.115.0 - resolution: "dd-trace@npm:5.115.0" +"dd-trace@npm:^5.117.0": + version: 5.117.0 + resolution: "dd-trace@npm:5.117.0" dependencies: "@datadog/libdatadog": "npm:0.9.4" "@datadog/native-appsec": "npm:11.0.1" "@datadog/native-iast-taint-tracking": "npm:4.2.0" "@datadog/native-metrics": "npm:3.1.2" "@datadog/openfeature-node-server": "npm:2.0.0" - "@datadog/pprof": "npm:5.15.1" + "@datadog/pprof": "npm:5.17.0" "@datadog/wasm-js-rewriter": "npm:5.0.1" "@opentelemetry/api": "npm:>=1.0.0 <1.10.0" "@opentelemetry/api-logs": "npm:<1.0.0" dc-polyfill: "npm:^0.1.11" - import-in-the-middle: "npm:^3.3.1" + import-in-the-middle: "npm:^3.3.2" opentracing: "npm:>=0.14.7" oxc-parser: "npm:^0.132.0" dependenciesMeta: @@ -9970,7 +9970,7 @@ __metadata: optional: true oxc-parser: optional: true - checksum: 10c0/fab3bfa5937f25aefd89255ec3ca36b71f4afc5a4928bb2c06c6335e4930186815320d6016216aef14f7ccc64022219b058d93cb01e7d07f9b42181faadefa32 + checksum: 10c0/14a4dff5897accf5953cfbc7244407ed0ffe25e7e65d0e62f8abfb09d99ce1b0c8f2e7c5c44266cd63e1fd9ef4e0a39fbb76fa73acdc16ea5ebf34d485a9b7ea languageName: node linkType: hard @@ -12522,7 +12522,7 @@ __metadata: languageName: node linkType: hard -"import-in-the-middle@npm:^3.0.0, import-in-the-middle@npm:^3.3.1": +"import-in-the-middle@npm:^3.0.0": version: 3.3.1 resolution: "import-in-the-middle@npm:3.3.1" dependencies: @@ -12533,6 +12533,17 @@ __metadata: languageName: node linkType: hard +"import-in-the-middle@npm:^3.3.2": + version: 3.3.2 + resolution: "import-in-the-middle@npm:3.3.2" + dependencies: + cjs-module-lexer: "npm:^2.2.0" + es-module-lexer: "npm:^2.2.0" + module-details-from-path: "npm:^1.0.4" + checksum: 10c0/b60a198b3739fb8d011ec435954793b187fa7764505b7bc4da45e7b080b311584c075f258a4a23abe8d25fe250251129a938a7ae4c79864c53766d60207bd62c + languageName: node + linkType: hard + "import-lazy@npm:~4.0.0": version: 4.0.0 resolution: "import-lazy@npm:4.0.0" @@ -15537,7 +15548,7 @@ __metadata: core-js: "npm:^3.49.0" crypto-js: "npm:^4.2.0" date-fns: "npm:^3.6.0" - dd-trace: "npm:^5.115.0" + dd-trace: "npm:^5.117.0" diff: "npm:^5.2.2" discord-api-types: "npm:^0.38.48" email-providers: "npm:^1.14.0" @@ -18825,13 +18836,20 @@ __metadata: languageName: node linkType: hard -"source-map@npm:^0.7.3, source-map@npm:^0.7.4": +"source-map@npm:^0.7.3": version: 0.7.6 resolution: "source-map@npm:0.7.6" checksum: 10c0/59f6f05538539b274ba771d2e9e32f6c65451982510564438e048bc1352f019c6efcdc6dd07909b1968144941c14015c2c7d4369fb7c4d7d53ae769716dcc16c languageName: node linkType: hard +"source-map@npm:^0.8.0": + version: 0.8.0 + resolution: "source-map@npm:0.8.0" + checksum: 10c0/fd2a5b81a1bf40f6155592f19c44abb46fc75b0f0f9473dd40c665b6f3866516a26218dad3d76b58b8b3e44560f3ab2191a837e1ce6631987e51a2db2e1cac56 + languageName: node + linkType: hard + "source-map@npm:^0.8.0-beta.0": version: 0.8.0-beta.0 resolution: "source-map@npm:0.8.0-beta.0" From fe4aea0c00dc9855432191b0342ca7d4ba16aaa6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 17:44:16 -0400 Subject: [PATCH 15/34] chore(deps): bump vite from 8.0.16 to 8.1.5 (#13161) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 8.0.16 to 8.1.5. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v8.1.5/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 8.1.5 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 293 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 291 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 76b61b6eb9..d04836fcff 100644 --- a/package.json +++ b/package.json @@ -266,7 +266,7 @@ "uuid": "^11.1.1", "validator": "13.15.35", "vaul": "^1.1.2", - "vite": "^8.0.16", + "vite": "^8.1.5", "vite-plugin-pwa": "1.3.0", "winston": "^3.17.0", "ws": "^7.5.11", diff --git a/yarn.lock b/yarn.lock index cbed567b12..e23826347e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1863,6 +1863,16 @@ __metadata: languageName: node linkType: hard +"@emnapi/core@npm:1.11.1": + version: 1.11.1 + resolution: "@emnapi/core@npm:1.11.1" + dependencies: + "@emnapi/wasi-threads": "npm:1.2.2" + tslib: "npm:^2.4.0" + checksum: 10c0/2c6defdac2d1d26090384655d7d6c9614fa553853b1760597686749e9375dc2aa0dae80a2615b81c254600f5d531d07d8466cde0d331a8caae64b93f3ca5937e + languageName: node + linkType: hard + "@emnapi/runtime@npm:1.10.0": version: 1.10.0 resolution: "@emnapi/runtime@npm:1.10.0" @@ -1872,6 +1882,15 @@ __metadata: languageName: node linkType: hard +"@emnapi/runtime@npm:1.11.1": + version: 1.11.1 + resolution: "@emnapi/runtime@npm:1.11.1" + dependencies: + tslib: "npm:^2.4.0" + checksum: 10c0/04332fb62076afc440aa23316c04bec42f584ca8b074e5507d08e2b33a47cbe0493b1aadb8f3c1057b64ae1e17f5bde1a7bc37f7facc9d0bc25c18197cbd366f + languageName: node + linkType: hard + "@emnapi/wasi-threads@npm:1.2.1": version: 1.2.1 resolution: "@emnapi/wasi-threads@npm:1.2.1" @@ -1881,6 +1900,15 @@ __metadata: languageName: node linkType: hard +"@emnapi/wasi-threads@npm:1.2.2": + version: 1.2.2 + resolution: "@emnapi/wasi-threads@npm:1.2.2" + dependencies: + tslib: "npm:^2.4.0" + checksum: 10c0/f0dc8269d6b20ae5a7c7b36e7a6a333452009d461038ef4febb29da2f3f78c1e2b1576d7e8970a5c5789ed3caedc1f80f5b0c2a5373bdaf8d03b20432bb55747 + languageName: node + linkType: hard + "@emoji-mart/data@npm:^1.2.1": version: 1.2.1 resolution: "@emoji-mart/data@npm:1.2.1" @@ -3168,6 +3196,18 @@ __metadata: languageName: node linkType: hard +"@napi-rs/wasm-runtime@npm:^1.1.6": + version: 1.1.6 + resolution: "@napi-rs/wasm-runtime@npm:1.1.6" + dependencies: + "@tybys/wasm-util": "npm:^0.10.3" + peerDependencies: + "@emnapi/core": ^1.7.1 + "@emnapi/runtime": ^1.7.1 + checksum: 10c0/344518bf3ef65051dda4c00969f293aa4a21ab7dc7822b3f48519b17cd5eaa3f0bc34898d115d50ba59b1817a0cb905d46f7a7223c8249239cd14c28db388e10 + languageName: node + linkType: hard + "@noble/ciphers@npm:^1.3.0": version: 1.3.0 resolution: "@noble/ciphers@npm:1.3.0" @@ -3819,6 +3859,13 @@ __metadata: languageName: node linkType: hard +"@oxc-project/types@npm:=0.139.0": + version: 0.139.0 + resolution: "@oxc-project/types@npm:0.139.0" + checksum: 10c0/ad57d1bee4b972ecf6784183da12ac6865edfff326bd83712fb75262b901868bc2b72d6fb502465a5f0dbaaded2910003f73365caf3821901dad565cc0b7fdf2 + languageName: node + linkType: hard + "@oxc-project/types@npm:^0.132.0": version: 0.132.0 resolution: "@oxc-project/types@npm:0.132.0" @@ -5226,6 +5273,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-android-arm64@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-android-arm64@npm:1.1.5" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + "@rolldown/binding-darwin-arm64@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-darwin-arm64@npm:1.0.3" @@ -5233,6 +5287,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-darwin-arm64@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-darwin-arm64@npm:1.1.5" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + "@rolldown/binding-darwin-x64@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-darwin-x64@npm:1.0.3" @@ -5240,6 +5301,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-darwin-x64@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-darwin-x64@npm:1.1.5" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + "@rolldown/binding-freebsd-x64@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-freebsd-x64@npm:1.0.3" @@ -5247,6 +5315,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-freebsd-x64@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-freebsd-x64@npm:1.1.5" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + "@rolldown/binding-linux-arm-gnueabihf@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-linux-arm-gnueabihf@npm:1.0.3" @@ -5254,6 +5329,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-linux-arm-gnueabihf@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-linux-arm-gnueabihf@npm:1.1.5" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + "@rolldown/binding-linux-arm64-gnu@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-linux-arm64-gnu@npm:1.0.3" @@ -5261,6 +5343,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-linux-arm64-gnu@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-linux-arm64-gnu@npm:1.1.5" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + "@rolldown/binding-linux-arm64-musl@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-linux-arm64-musl@npm:1.0.3" @@ -5268,6 +5357,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-linux-arm64-musl@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-linux-arm64-musl@npm:1.1.5" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + "@rolldown/binding-linux-ppc64-gnu@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-linux-ppc64-gnu@npm:1.0.3" @@ -5275,6 +5371,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-linux-ppc64-gnu@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-linux-ppc64-gnu@npm:1.1.5" + conditions: os=linux & cpu=ppc64 & libc=glibc + languageName: node + linkType: hard + "@rolldown/binding-linux-s390x-gnu@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-linux-s390x-gnu@npm:1.0.3" @@ -5282,6 +5385,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-linux-s390x-gnu@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-linux-s390x-gnu@npm:1.1.5" + conditions: os=linux & cpu=s390x & libc=glibc + languageName: node + linkType: hard + "@rolldown/binding-linux-x64-gnu@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-linux-x64-gnu@npm:1.0.3" @@ -5289,6 +5399,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-linux-x64-gnu@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-linux-x64-gnu@npm:1.1.5" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + "@rolldown/binding-linux-x64-musl@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-linux-x64-musl@npm:1.0.3" @@ -5296,6 +5413,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-linux-x64-musl@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-linux-x64-musl@npm:1.1.5" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + "@rolldown/binding-openharmony-arm64@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-openharmony-arm64@npm:1.0.3" @@ -5303,6 +5427,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-openharmony-arm64@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-openharmony-arm64@npm:1.1.5" + conditions: os=openharmony & cpu=arm64 + languageName: node + linkType: hard + "@rolldown/binding-wasm32-wasi@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-wasm32-wasi@npm:1.0.3" @@ -5314,6 +5445,17 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-wasm32-wasi@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-wasm32-wasi@npm:1.1.5" + dependencies: + "@emnapi/core": "npm:1.11.1" + "@emnapi/runtime": "npm:1.11.1" + "@napi-rs/wasm-runtime": "npm:^1.1.6" + conditions: cpu=wasm32 + languageName: node + linkType: hard + "@rolldown/binding-win32-arm64-msvc@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-win32-arm64-msvc@npm:1.0.3" @@ -5321,6 +5463,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-win32-arm64-msvc@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-win32-arm64-msvc@npm:1.1.5" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + "@rolldown/binding-win32-x64-msvc@npm:1.0.3": version: 1.0.3 resolution: "@rolldown/binding-win32-x64-msvc@npm:1.0.3" @@ -5328,6 +5477,13 @@ __metadata: languageName: node linkType: hard +"@rolldown/binding-win32-x64-msvc@npm:1.1.5": + version: 1.1.5 + resolution: "@rolldown/binding-win32-x64-msvc@npm:1.1.5" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@rolldown/pluginutils@npm:^1.0.0, @rolldown/pluginutils@npm:^1.0.1": version: 1.0.1 resolution: "@rolldown/pluginutils@npm:1.0.1" @@ -6200,6 +6356,15 @@ __metadata: languageName: node linkType: hard +"@tybys/wasm-util@npm:^0.10.3": + version: 0.10.3 + resolution: "@tybys/wasm-util@npm:0.10.3" + dependencies: + tslib: "npm:^2.4.0" + checksum: 10c0/fd2bd2a79c6cd8c79ed1cf7a0fa375c64589264c88a27acaf9756d556b453ea222b62a4f68dd2fbb8b3a78b6bab3b1f4fb2431b6afc6aeda8344b53a521a1cd3 + languageName: node + linkType: hard + "@types/accepts@npm:*": version: 1.3.7 resolution: "@types/accepts@npm:1.3.7" @@ -15705,7 +15870,7 @@ __metadata: uuid: "npm:^11.1.1" validator: "npm:13.15.35" vaul: "npm:^1.1.2" - vite: "npm:^8.0.16" + vite: "npm:^8.1.5" vite-plugin-pwa: "npm:1.3.0" vite-tsconfig-paths: "npm:^6.1.1" vitest: "npm:^4.1.5" @@ -16498,6 +16663,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^4.0.5": + version: 4.0.5 + resolution: "picomatch@npm:4.0.5" + checksum: 10c0/947bc6b6e1ff1e6c5aaf95b107a0839d12802f4f7b867663f67d47accba939ca1cb582cf99dfc30438efa1c4648ac5990967e783e8929c36b03e8440704ef1bd + languageName: node + linkType: hard + "pify@npm:^4.0.1": version: 4.0.1 resolution: "pify@npm:4.0.1" @@ -16610,7 +16782,7 @@ __metadata: languageName: node linkType: hard -"postcss@npm:^8.5.15": +"postcss@npm:^8.5.15, postcss@npm:^8.5.17": version: 8.5.22 resolution: "postcss@npm:8.5.22" dependencies: @@ -17936,6 +18108,64 @@ __metadata: languageName: node linkType: hard +"rolldown@npm:~1.1.5": + version: 1.1.5 + resolution: "rolldown@npm:1.1.5" + dependencies: + "@oxc-project/types": "npm:=0.139.0" + "@rolldown/binding-android-arm64": "npm:1.1.5" + "@rolldown/binding-darwin-arm64": "npm:1.1.5" + "@rolldown/binding-darwin-x64": "npm:1.1.5" + "@rolldown/binding-freebsd-x64": "npm:1.1.5" + "@rolldown/binding-linux-arm-gnueabihf": "npm:1.1.5" + "@rolldown/binding-linux-arm64-gnu": "npm:1.1.5" + "@rolldown/binding-linux-arm64-musl": "npm:1.1.5" + "@rolldown/binding-linux-ppc64-gnu": "npm:1.1.5" + "@rolldown/binding-linux-s390x-gnu": "npm:1.1.5" + "@rolldown/binding-linux-x64-gnu": "npm:1.1.5" + "@rolldown/binding-linux-x64-musl": "npm:1.1.5" + "@rolldown/binding-openharmony-arm64": "npm:1.1.5" + "@rolldown/binding-wasm32-wasi": "npm:1.1.5" + "@rolldown/binding-win32-arm64-msvc": "npm:1.1.5" + "@rolldown/binding-win32-x64-msvc": "npm:1.1.5" + "@rolldown/pluginutils": "npm:^1.0.0" + dependenciesMeta: + "@rolldown/binding-android-arm64": + optional: true + "@rolldown/binding-darwin-arm64": + optional: true + "@rolldown/binding-darwin-x64": + optional: true + "@rolldown/binding-freebsd-x64": + optional: true + "@rolldown/binding-linux-arm-gnueabihf": + optional: true + "@rolldown/binding-linux-arm64-gnu": + optional: true + "@rolldown/binding-linux-arm64-musl": + optional: true + "@rolldown/binding-linux-ppc64-gnu": + optional: true + "@rolldown/binding-linux-s390x-gnu": + optional: true + "@rolldown/binding-linux-x64-gnu": + optional: true + "@rolldown/binding-linux-x64-musl": + optional: true + "@rolldown/binding-openharmony-arm64": + optional: true + "@rolldown/binding-wasm32-wasi": + optional: true + "@rolldown/binding-win32-arm64-msvc": + optional: true + "@rolldown/binding-win32-x64-msvc": + optional: true + bin: + rolldown: ./bin/cli.mjs + checksum: 10c0/93072aa9d95882f9fa5cd57fe7db6a48efd6f85a25a32137425052ecca02df653651eed0c33a865c33511681bd6a40691d5c88900b8e95ce1334f4f75ba826ff + languageName: node + linkType: hard + "rollup-plugin-stats@npm:2.1.3": version: 2.1.3 resolution: "rollup-plugin-stats@npm:2.1.3" @@ -20513,7 +20743,7 @@ __metadata: languageName: node linkType: hard -"vite@npm:^6.0.0 || ^7.0.0 || ^8.0.0, vite@npm:^8.0.16": +"vite@npm:^6.0.0 || ^7.0.0 || ^8.0.0": version: 8.0.16 resolution: "vite@npm:8.0.16" dependencies: @@ -20570,6 +20800,63 @@ __metadata: languageName: node linkType: hard +"vite@npm:^8.1.5": + version: 8.1.5 + resolution: "vite@npm:8.1.5" + dependencies: + fsevents: "npm:~2.3.3" + lightningcss: "npm:^1.32.0" + picomatch: "npm:^4.0.5" + postcss: "npm:^8.5.17" + rolldown: "npm:~1.1.5" + tinyglobby: "npm:^0.2.17" + peerDependencies: + "@types/node": ^20.19.0 || >=22.12.0 + "@vitejs/devtools": ^0.3.0 + esbuild: ^0.27.0 || ^0.28.0 + jiti: ">=1.21.0" + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: ">=0.54.8" + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + dependenciesMeta: + fsevents: + optional: true + peerDependenciesMeta: + "@types/node": + optional: true + "@vitejs/devtools": + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + bin: + vite: bin/vite.js + checksum: 10c0/3231e24dd4394d0bc8b4f0f5d6d6a2eda8737e5053042892b4163564456a03d67f953c4c7498621f9517eebc30a492ea136c728a767a122eb84bf6d7cf60e1e6 + languageName: node + linkType: hard + "vitest@npm:^4.1.5": version: 4.1.5 resolution: "vitest@npm:4.1.5" From 6b60858226279fb7410d6dfd8c62bc22b032b608 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 17:44:32 -0400 Subject: [PATCH 16/34] fix: Never downgrade Node.js in update workflow (#13154) Co-authored-by: Claude --- .github/workflows/update-node.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/update-node.yml b/.github/workflows/update-node.yml index 1c17340d86..8fa7974a26 100644 --- a/.github/workflows/update-node.yml +++ b/.github/workflows/update-node.yml @@ -38,9 +38,15 @@ jobs: echo "latest=$LATEST_VERSION" >> "$GITHUB_OUTPUT" echo "Latest Node.js LTS version: $LATEST_VERSION" + # Only update when the latest LTS is strictly newer, never downgrade + NEWEST=$(printf '%s\n%s\n' "$CURRENT_VERSION" "$LATEST_VERSION" | sort -V | tail -n1) + if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then echo "updated=false" >> "$GITHUB_OUTPUT" echo "Already up to date." + elif [ "$NEWEST" = "$CURRENT_VERSION" ]; then + echo "updated=false" >> "$GITHUB_OUTPUT" + echo "Current version $CURRENT_VERSION is newer than the latest LTS $LATEST_VERSION, skipping." else echo "updated=true" >> "$GITHUB_OUTPUT" echo "Update available: $CURRENT_VERSION -> $LATEST_VERSION" From 3c53f4c75bf34010714d8c50bc0d7650954e9f4e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 17:58:43 -0400 Subject: [PATCH 17/34] fix: Evaluate of undefined in useKeyDown (#13163) --- app/hooks/useKeyDown.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/hooks/useKeyDown.ts b/app/hooks/useKeyDown.ts index daa81db888..94bf2b2a2a 100644 --- a/app/hooks/useKeyDown.ts +++ b/app/hooks/useKeyDown.ts @@ -53,6 +53,11 @@ const createKeyPredicate = (keyFilter: KeyFilter, options?: Options) => ? keyFilter : typeof keyFilter === "string" ? (event: KeyboardEvent) => { + // Synthetic events may be dispatched without a key. + if (!event.key) { + return false; + } + // Match case-insensitively only when Shift is required, since a // shifted letter reports an uppercase event.key (e.g. Cmd+Shift+P). // Otherwise match exactly so a bare shortcut does not fire when Shift From 7e6499e71fad915ec98bb18ba5677463fce7e5a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 18:13:07 -0400 Subject: [PATCH 18/34] chore(deps): bump ioredis from 5.10.1 to 5.11.1 (#13159) * chore(deps): bump ioredis from 5.10.1 to 5.11.1 Bumps [ioredis](https://github.com/luin/ioredis) from 5.10.1 to 5.11.1. - [Release notes](https://github.com/luin/ioredis/releases) - [Changelog](https://github.com/redis/ioredis/blob/main/CHANGELOG.md) - [Commits](https://github.com/luin/ioredis/compare/v5.10.1...v5.11.1) --- updated-dependencies: - dependency-name: ioredis dependency-version: 5.11.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * chore(deps): dedupe ioredis so bull shares the hoisted copy Co-Authored-By: Claude --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Moor Co-authored-by: Claude --- package.json | 2 +- yarn.lock | 63 ++++++++++++++++++++++++++++------------------------ 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index d04836fcff..b60b6831bc 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,7 @@ "i18next-fs-backend": "^2.6.6", "i18next-http-backend": "^3.0.6", "invariant": "^2.2.4", - "ioredis": "^5.10.1", + "ioredis": "^5.11.1", "ipaddr.js": "^2.4.0", "is-printable-key-event": "^1.0.0", "iso-639-3": "^3.0.1", diff --git a/yarn.lock b/yarn.lock index e23826347e..33b1621cd0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2503,10 +2503,10 @@ __metadata: languageName: node linkType: hard -"@ioredis/commands@npm:1.5.1, @ioredis/commands@npm:^1.0.2, @ioredis/commands@npm:^1.4.0": - version: 1.5.1 - resolution: "@ioredis/commands@npm:1.5.1" - checksum: 10c0/cb8f6d13cff0753e3e7ef001fb895491985d9a623248192538f13bc2fd9bfdfde3c18cf2ba6f20ec8ceaa681b0771070d3a09b82eed044c798bcfef5e3ae54b3 +"@ioredis/commands@npm:1.10.0, @ioredis/commands@npm:^1.0.2, @ioredis/commands@npm:^1.4.0": + version: 1.10.0 + resolution: "@ioredis/commands@npm:1.10.0" + checksum: 10c0/baf91e62d0e64ef2b5f7ca4413dc2456fe250e87483beac4a1c8ef1fe5ad0d2fcdeb9b89d4556d8ef6c7455c64a964359d729601fdb06b2f4c76c35dd59afa99 languageName: node linkType: hard @@ -9050,6 +9050,13 @@ __metadata: languageName: node linkType: hard +"cluster-key-slot@npm:1.1.1": + version: 1.1.1 + resolution: "cluster-key-slot@npm:1.1.1" + checksum: 10c0/079b1ae86b20e2d53308a877b08de5e830722a45c07810569d0dab4955bed569da33ac9f79998289d014adf02cca7223a0647cb0ee6548a12ab3c4f9beac1377 + languageName: node + linkType: hard + "cluster-key-slot@npm:^1.1.0": version: 1.1.2 resolution: "cluster-key-slot@npm:1.1.2" @@ -10139,7 +10146,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4, debug@npm:^4.0.1, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.4, debug@npm:^4.3.5, debug@npm:^4.3.6, debug@npm:^4.4.0, debug@npm:^4.4.1, debug@npm:^4.4.3, debug@npm:~4.4.1": +"debug@npm:4, debug@npm:4.4.3, debug@npm:^4, debug@npm:^4.0.1, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.4, debug@npm:^4.3.5, debug@npm:^4.3.6, debug@npm:^4.4.0, debug@npm:^4.4.1, debug@npm:^4.4.3, debug@npm:~4.4.1": version: 4.4.3 resolution: "debug@npm:4.4.3" dependencies: @@ -10282,6 +10289,13 @@ __metadata: languageName: node linkType: hard +"denque@npm:2.1.0": + version: 2.1.0 + resolution: "denque@npm:2.1.0" + checksum: 10c0/f9ef81aa0af9c6c614a727cb3bd13c5d7db2af1abf9e6352045b86e85873e629690f6222f4edd49d10e4ccf8f078bbeec0794fafaf61b659c0589d0c511ec363 + languageName: node + linkType: hard + "denque@npm:^1.1.0, denque@npm:^1.5.0": version: 1.5.1 resolution: "denque@npm:1.5.1" @@ -10289,13 +10303,6 @@ __metadata: languageName: node linkType: hard -"denque@npm:^2.1.0": - version: 2.1.0 - resolution: "denque@npm:2.1.0" - checksum: 10c0/f9ef81aa0af9c6c614a727cb3bd13c5d7db2af1abf9e6352045b86e85873e629690f6222f4edd49d10e4ccf8f078bbeec0794fafaf61b659c0589d0c511ec363 - languageName: node - linkType: hard - "depd@npm:^2.0.0, depd@npm:~2.0.0": version: 2.0.0 resolution: "depd@npm:2.0.0" @@ -12846,20 +12853,18 @@ __metadata: languageName: node linkType: hard -"ioredis@npm:^5.10.1, ioredis@npm:^5.3.2": - version: 5.10.1 - resolution: "ioredis@npm:5.10.1" +"ioredis@npm:^5.11.1, ioredis@npm:^5.3.2": + version: 5.11.1 + resolution: "ioredis@npm:5.11.1" dependencies: - "@ioredis/commands": "npm:1.5.1" - cluster-key-slot: "npm:^1.1.0" - debug: "npm:^4.3.4" - denque: "npm:^2.1.0" - lodash.defaults: "npm:^4.2.0" - lodash.isarguments: "npm:^3.1.0" - redis-errors: "npm:^1.2.0" - redis-parser: "npm:^3.0.0" - standard-as-callback: "npm:^2.1.0" - checksum: 10c0/d0507b52520d3bdd5dacaa33aed9dd3133794d8633b43a6b7fc3199a5e73f92cb77409f6904abe68e3221a95a630d97073b8c1c9e2c0c7613124db67e97c0eb0 + "@ioredis/commands": "npm:1.10.0" + cluster-key-slot: "npm:1.1.1" + debug: "npm:4.4.3" + denque: "npm:2.1.0" + redis-errors: "npm:1.2.0" + redis-parser: "npm:3.0.0" + standard-as-callback: "npm:2.1.0" + checksum: 10c0/a8b27043cf2c045dfc93f40a32ce24cf9f8b57799a37f4234c4b925c365ccf131629590f94a512f546fda2ba8ed034009c94c4933ecd44c50bc166636d929fd6 languageName: node linkType: hard @@ -15740,7 +15745,7 @@ __metadata: i18next-http-backend: "npm:^3.0.6" i18next-parser: "npm:^9.4.0" invariant: "npm:^2.2.4" - ioredis: "npm:^5.10.1" + ioredis: "npm:^5.11.1" ioredis-mock: "npm:^8.13.1" ipaddr.js: "npm:^2.4.0" is-printable-key-event: "npm:^1.0.0" @@ -17675,7 +17680,7 @@ __metadata: languageName: node linkType: hard -"redis-errors@npm:^1.0.0, redis-errors@npm:^1.2.0": +"redis-errors@npm:1.2.0, redis-errors@npm:^1.0.0, redis-errors@npm:^1.2.0": version: 1.2.0 resolution: "redis-errors@npm:1.2.0" checksum: 10c0/5b316736e9f532d91a35bff631335137a4f974927bb2fb42bf8c2f18879173a211787db8ac4c3fde8f75ed6233eb0888e55d52510b5620e30d69d7d719c8b8a7 @@ -17691,7 +17696,7 @@ __metadata: languageName: node linkType: hard -"redis-parser@npm:^3.0.0": +"redis-parser@npm:3.0.0, redis-parser@npm:^3.0.0": version: 3.0.0 resolution: "redis-parser@npm:3.0.0" dependencies: @@ -19170,7 +19175,7 @@ __metadata: languageName: node linkType: hard -"standard-as-callback@npm:^2.1.0": +"standard-as-callback@npm:2.1.0, standard-as-callback@npm:^2.1.0": version: 2.1.0 resolution: "standard-as-callback@npm:2.1.0" checksum: 10c0/012677236e3d3fdc5689d29e64ea8a599331c4babe86956bf92fc5e127d53f85411c5536ee0079c52c43beb0026b5ce7aa1d834dd35dd026e82a15d1bcaead1f From 3260153f9c237a01e955dc69c9b529419c1f140c Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 18:15:50 -0400 Subject: [PATCH 19/34] fix: Suppress 499 error reporting (#13165) --- app/utils/ApiClient.ts | 7 +++++++ app/utils/errors.ts | 3 +++ app/utils/sentry.ts | 2 ++ 3 files changed, 12 insertions(+) diff --git a/app/utils/ApiClient.ts b/app/utils/ApiClient.ts index af2a06c52c..488c20fa29 100644 --- a/app/utils/ApiClient.ts +++ b/app/utils/ApiClient.ts @@ -12,6 +12,7 @@ import { AuthorizationError, BadGatewayError, BadRequestError, + ClientClosedRequestError, NetworkError, NotFoundError, OfflineError, @@ -311,6 +312,12 @@ class ApiClient { ); } + // The client, or an intermediate proxy, closed the connection before the + // response was received – there is nothing actionable to report. + if (response.status === 499) { + throw new ClientClosedRequestError(error.message); + } + const err = new RequestError(`Error ${response.status}`); Logger.error("Request failed", err, { ...error, diff --git a/app/utils/errors.ts b/app/utils/errors.ts index aaa9f6b539..98dfc45d70 100644 --- a/app/utils/errors.ts +++ b/app/utils/errors.ts @@ -30,6 +30,9 @@ export class UnprocessableEntityError extends ExtendableError {} /** Error thrown when the client has exceeded the allowed request rate. */ export class RateLimitExceededError extends ExtendableError {} +/** Error thrown when the client closed the connection before a response. */ +export class ClientClosedRequestError extends ExtendableError {} + /** Error thrown when a request fails for a generic reason. */ export class RequestError extends ExtendableError {} diff --git a/app/utils/sentry.ts b/app/utils/sentry.ts index cb5443d94d..8240f09ad6 100644 --- a/app/utils/sentry.ts +++ b/app/utils/sentry.ts @@ -4,6 +4,7 @@ import env from "~/env"; import { AuthorizationError, BadRequestError, + ClientClosedRequestError, NetworkError, NotFoundError, OfflineError, @@ -22,6 +23,7 @@ export function initSentry(history: History) { const ignoredErrorTypes = [ AuthorizationError, BadRequestError, + ClientClosedRequestError, NetworkError, NotFoundError, OfflineError, From 854db7599571c123490ff71ef0225ad607c738ab Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 18:15:57 -0400 Subject: [PATCH 20/34] fix: Crash opening comment sidebar in Lightbox on public share (#13164) --- app/components/Lightbox.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/components/Lightbox.tsx b/app/components/Lightbox.tsx index 9834a3716c..45580531b9 100644 --- a/app/components/Lightbox.tsx +++ b/app/components/Lightbox.tsx @@ -65,6 +65,7 @@ import { HStack } from "./primitives/HStack"; import { useDocumentContext } from "./DocumentContext"; import LightboxComments from "~/scenes/Document/components/Comments/LightboxComments"; import { PortalContext } from "./Portal"; +import useCurrentUser from "~/hooks/useCurrentUser"; import useHideElement from "~/hooks/useHideElement"; import type { Status } from "./LightboxState"; import { @@ -272,10 +273,13 @@ function Lightbox({ images, activeImage, onUpdate, onClose, readOnly }: Props) { } | null>(null); const zoomPanPinchRef = useRef(null); const editor = useEditor(); + const user = useCurrentUser({ rejectOnEmpty: false }); const { document: contextDocument } = useDocumentContext(); const activeNode = editor?.view?.state?.doc?.nodeAt(activeImage.pos); + // Comments are unavailable without a signed in session, for example when + // viewing a publicly shared document. const canShowComments = - !!contextDocument && activeNode?.type.name === "image"; + !!user && !!contextDocument && activeNode?.type.name === "image"; const currentImageIndex = findIndex( images, From 8a375991a74357eaab78969813d931b7a7ad5e35 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 18:23:45 -0400 Subject: [PATCH 21/34] chore: Update brace-expansion (#13166) --- .yarnrc.yml | 1 + yarn.lock | 333 ++-------------------------------------------------- 2 files changed, 11 insertions(+), 323 deletions(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index 07c071cee6..e2a8e04f87 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -12,3 +12,4 @@ npmPreapprovedPackages: npmAuditIgnoreAdvisories: - "1113517" # GHSA-mw96-cpmx-2vgc rollup <2.80.0 path traversal (workbox-build, build-time) - "1113686" # GHSA-5c6j-r48x-rmvq serialize-javascript RCE (@rollup/plugin-terser, build-time) + - "1124334" # GHSA-mh99-v99m-4gvg brace-expansion DoS is a false positive diff --git a/yarn.lock b/yarn.lock index 33b1621cd0..97cfe9e1f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3184,19 +3184,7 @@ __metadata: languageName: node linkType: hard -"@napi-rs/wasm-runtime@npm:^1.1.4": - version: 1.1.5 - resolution: "@napi-rs/wasm-runtime@npm:1.1.5" - dependencies: - "@tybys/wasm-util": "npm:^0.10.2" - peerDependencies: - "@emnapi/core": ^1.7.1 - "@emnapi/runtime": ^1.7.1 - checksum: 10c0/727f2b6ae0e68bbe5d39aeb68aa6f183314e9f03dc50bb55a962849535b2db53ecc3fbf1554d8656a54488a608df5a2634670595cf5874dc4af2ee59f817c65d - languageName: node - linkType: hard - -"@napi-rs/wasm-runtime@npm:^1.1.6": +"@napi-rs/wasm-runtime@npm:^1.1.4, @napi-rs/wasm-runtime@npm:^1.1.6": version: 1.1.6 resolution: "@napi-rs/wasm-runtime@npm:1.1.6" dependencies: @@ -3852,13 +3840,6 @@ __metadata: languageName: node linkType: hard -"@oxc-project/types@npm:=0.133.0": - version: 0.133.0 - resolution: "@oxc-project/types@npm:0.133.0" - checksum: 10c0/70c57ba58644f7ec217b670c301801f4d06995f4ccdba6b2bd106ea3e5ee49d616573e6ef8d55530b87571a960696543687f3850e87ad173d3f88965c30cdd63 - languageName: node - linkType: hard - "@oxc-project/types@npm:=0.139.0": version: 0.139.0 resolution: "@oxc-project/types@npm:0.139.0" @@ -5266,13 +5247,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-android-arm64@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-android-arm64@npm:1.0.3" - conditions: os=android & cpu=arm64 - languageName: node - linkType: hard - "@rolldown/binding-android-arm64@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-android-arm64@npm:1.1.5" @@ -5280,13 +5254,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-darwin-arm64@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-darwin-arm64@npm:1.0.3" - conditions: os=darwin & cpu=arm64 - languageName: node - linkType: hard - "@rolldown/binding-darwin-arm64@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-darwin-arm64@npm:1.1.5" @@ -5294,13 +5261,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-darwin-x64@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-darwin-x64@npm:1.0.3" - conditions: os=darwin & cpu=x64 - languageName: node - linkType: hard - "@rolldown/binding-darwin-x64@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-darwin-x64@npm:1.1.5" @@ -5308,13 +5268,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-freebsd-x64@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-freebsd-x64@npm:1.0.3" - conditions: os=freebsd & cpu=x64 - languageName: node - linkType: hard - "@rolldown/binding-freebsd-x64@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-freebsd-x64@npm:1.1.5" @@ -5322,13 +5275,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-linux-arm-gnueabihf@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-linux-arm-gnueabihf@npm:1.0.3" - conditions: os=linux & cpu=arm - languageName: node - linkType: hard - "@rolldown/binding-linux-arm-gnueabihf@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-linux-arm-gnueabihf@npm:1.1.5" @@ -5336,13 +5282,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-linux-arm64-gnu@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-linux-arm64-gnu@npm:1.0.3" - conditions: os=linux & cpu=arm64 & libc=glibc - languageName: node - linkType: hard - "@rolldown/binding-linux-arm64-gnu@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-linux-arm64-gnu@npm:1.1.5" @@ -5350,13 +5289,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-linux-arm64-musl@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-linux-arm64-musl@npm:1.0.3" - conditions: os=linux & cpu=arm64 & libc=musl - languageName: node - linkType: hard - "@rolldown/binding-linux-arm64-musl@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-linux-arm64-musl@npm:1.1.5" @@ -5364,13 +5296,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-linux-ppc64-gnu@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-linux-ppc64-gnu@npm:1.0.3" - conditions: os=linux & cpu=ppc64 & libc=glibc - languageName: node - linkType: hard - "@rolldown/binding-linux-ppc64-gnu@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-linux-ppc64-gnu@npm:1.1.5" @@ -5378,13 +5303,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-linux-s390x-gnu@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-linux-s390x-gnu@npm:1.0.3" - conditions: os=linux & cpu=s390x & libc=glibc - languageName: node - linkType: hard - "@rolldown/binding-linux-s390x-gnu@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-linux-s390x-gnu@npm:1.1.5" @@ -5392,13 +5310,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-linux-x64-gnu@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-linux-x64-gnu@npm:1.0.3" - conditions: os=linux & cpu=x64 & libc=glibc - languageName: node - linkType: hard - "@rolldown/binding-linux-x64-gnu@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-linux-x64-gnu@npm:1.1.5" @@ -5406,13 +5317,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-linux-x64-musl@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-linux-x64-musl@npm:1.0.3" - conditions: os=linux & cpu=x64 & libc=musl - languageName: node - linkType: hard - "@rolldown/binding-linux-x64-musl@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-linux-x64-musl@npm:1.1.5" @@ -5420,13 +5324,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-openharmony-arm64@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-openharmony-arm64@npm:1.0.3" - conditions: os=openharmony & cpu=arm64 - languageName: node - linkType: hard - "@rolldown/binding-openharmony-arm64@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-openharmony-arm64@npm:1.1.5" @@ -5434,17 +5331,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-wasm32-wasi@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-wasm32-wasi@npm:1.0.3" - dependencies: - "@emnapi/core": "npm:1.10.0" - "@emnapi/runtime": "npm:1.10.0" - "@napi-rs/wasm-runtime": "npm:^1.1.4" - conditions: cpu=wasm32 - languageName: node - linkType: hard - "@rolldown/binding-wasm32-wasi@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-wasm32-wasi@npm:1.1.5" @@ -5456,13 +5342,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-win32-arm64-msvc@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-win32-arm64-msvc@npm:1.0.3" - conditions: os=win32 & cpu=arm64 - languageName: node - linkType: hard - "@rolldown/binding-win32-arm64-msvc@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-win32-arm64-msvc@npm:1.1.5" @@ -5470,13 +5349,6 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-win32-x64-msvc@npm:1.0.3": - version: 1.0.3 - resolution: "@rolldown/binding-win32-x64-msvc@npm:1.0.3" - conditions: os=win32 & cpu=x64 - languageName: node - linkType: hard - "@rolldown/binding-win32-x64-msvc@npm:1.1.5": version: 1.1.5 resolution: "@rolldown/binding-win32-x64-msvc@npm:1.1.5" @@ -6347,15 +6219,6 @@ __metadata: languageName: node linkType: hard -"@tybys/wasm-util@npm:^0.10.2": - version: 0.10.2 - resolution: "@tybys/wasm-util@npm:0.10.2" - dependencies: - tslib: "npm:^2.4.0" - checksum: 10c0/26165bcd1fd7269f42d7fbe3de318f854a8968de8397e89fc9a423bb3e2da35a52150f382e6323b3367595beb16d9800a6f35971a5599daf76da1742ec3afc25 - languageName: node - linkType: hard - "@tybys/wasm-util@npm:^0.10.3": version: 0.10.3 resolution: "@tybys/wasm-util@npm:0.10.3" @@ -8591,11 +8454,11 @@ __metadata: linkType: hard "brace-expansion@npm:^5.0.5": - version: 5.0.7 - resolution: "brace-expansion@npm:5.0.7" + version: 5.0.8 + resolution: "brace-expansion@npm:5.0.8" dependencies: balanced-match: "npm:^4.0.2" - checksum: 10c0/4769109c3c082de178e449a371bcad50d51ab468f644bce2dd9188efe0cf0a080ed102105d7fc8577382cedc45bad7e6443a91bf3d8102264ee8cf927dbaf205 + checksum: 10c0/73304caafd00fdc5b0168e693ac15bf25b6357dec76d1195fcd628fe2cf99c46f9c889a7ecfa3cfe236dbd2d5ce3e27a6ccc4370b46d475d0d19081e11f86019 languageName: node linkType: hard @@ -12694,18 +12557,7 @@ __metadata: languageName: node linkType: hard -"import-in-the-middle@npm:^3.0.0": - version: 3.3.1 - resolution: "import-in-the-middle@npm:3.3.1" - dependencies: - cjs-module-lexer: "npm:^2.2.0" - es-module-lexer: "npm:^2.2.0" - module-details-from-path: "npm:^1.0.4" - checksum: 10c0/b2bff9cb1499a749e395b97a8ce4cd45c76d5ed37c65949bdb04b6e962a666c7ae681ab90480affafc0670e284660631068c168455e5f37a168b08d06af15da6 - languageName: node - linkType: hard - -"import-in-the-middle@npm:^3.3.2": +"import-in-the-middle@npm:^3.0.0, import-in-the-middle@npm:^3.3.2": version: 3.3.2 resolution: "import-in-the-middle@npm:3.3.2" dependencies: @@ -14353,13 +14205,6 @@ __metadata: languageName: node linkType: hard -"lodash.sortby@npm:^4.7.0": - version: 4.7.0 - resolution: "lodash.sortby@npm:4.7.0" - checksum: 10c0/fc48fb54ff7669f33bb32997cab9460757ee99fafaf72400b261c3e10fde21538e47d8cfcbe6a25a31bcb5b7b727c27d52626386fc2de24eb059a6d64a89cdf5 - languageName: node - linkType: hard - "lodash.uniq@npm:^4.5.0": version: 4.5.0 resolution: "lodash.uniq@npm:4.5.0" @@ -16661,14 +16506,7 @@ __metadata: languageName: node linkType: hard -"picomatch@npm:^4.0.2, picomatch@npm:^4.0.3, picomatch@npm:^4.0.4": - version: 4.0.4 - resolution: "picomatch@npm:4.0.4" - checksum: 10c0/e2c6023372cc7b5764719a5ffb9da0f8e781212fa7ca4bd0562db929df8e117460f00dff3cb7509dacfc06b86de924b247f504d0ce1806a37fac4633081466b0 - languageName: node - linkType: hard - -"picomatch@npm:^4.0.5": +"picomatch@npm:^4.0.2, picomatch@npm:^4.0.3, picomatch@npm:^4.0.4, picomatch@npm:^4.0.5": version: 4.0.5 resolution: "picomatch@npm:4.0.5" checksum: 10c0/947bc6b6e1ff1e6c5aaf95b107a0839d12802f4f7b867663f67d47accba939ca1cb582cf99dfc30438efa1c4648ac5990967e783e8929c36b03e8440704ef1bd @@ -16787,7 +16625,7 @@ __metadata: languageName: node linkType: hard -"postcss@npm:^8.5.15, postcss@npm:^8.5.17": +"postcss@npm:^8.5.17": version: 8.5.22 resolution: "postcss@npm:8.5.22" dependencies: @@ -17167,7 +17005,7 @@ __metadata: languageName: node linkType: hard -"punycode@npm:^2.1.0, punycode@npm:^2.1.1, punycode@npm:^2.3.0, punycode@npm:^2.3.1": +"punycode@npm:^2.1.1, punycode@npm:^2.3.0, punycode@npm:^2.3.1": version: 2.3.1 resolution: "punycode@npm:2.3.1" checksum: 10c0/14f76a8206bc3464f794fb2e3d3cc665ae416c01893ad7a02b23766eb07159144ee612ad67af5e84fa4479ccfe67678c4feb126b0485651b302babf66f04f9e9 @@ -18055,64 +17893,6 @@ __metadata: languageName: node linkType: hard -"rolldown@npm:1.0.3": - version: 1.0.3 - resolution: "rolldown@npm:1.0.3" - dependencies: - "@oxc-project/types": "npm:=0.133.0" - "@rolldown/binding-android-arm64": "npm:1.0.3" - "@rolldown/binding-darwin-arm64": "npm:1.0.3" - "@rolldown/binding-darwin-x64": "npm:1.0.3" - "@rolldown/binding-freebsd-x64": "npm:1.0.3" - "@rolldown/binding-linux-arm-gnueabihf": "npm:1.0.3" - "@rolldown/binding-linux-arm64-gnu": "npm:1.0.3" - "@rolldown/binding-linux-arm64-musl": "npm:1.0.3" - "@rolldown/binding-linux-ppc64-gnu": "npm:1.0.3" - "@rolldown/binding-linux-s390x-gnu": "npm:1.0.3" - "@rolldown/binding-linux-x64-gnu": "npm:1.0.3" - "@rolldown/binding-linux-x64-musl": "npm:1.0.3" - "@rolldown/binding-openharmony-arm64": "npm:1.0.3" - "@rolldown/binding-wasm32-wasi": "npm:1.0.3" - "@rolldown/binding-win32-arm64-msvc": "npm:1.0.3" - "@rolldown/binding-win32-x64-msvc": "npm:1.0.3" - "@rolldown/pluginutils": "npm:^1.0.0" - dependenciesMeta: - "@rolldown/binding-android-arm64": - optional: true - "@rolldown/binding-darwin-arm64": - optional: true - "@rolldown/binding-darwin-x64": - optional: true - "@rolldown/binding-freebsd-x64": - optional: true - "@rolldown/binding-linux-arm-gnueabihf": - optional: true - "@rolldown/binding-linux-arm64-gnu": - optional: true - "@rolldown/binding-linux-arm64-musl": - optional: true - "@rolldown/binding-linux-ppc64-gnu": - optional: true - "@rolldown/binding-linux-s390x-gnu": - optional: true - "@rolldown/binding-linux-x64-gnu": - optional: true - "@rolldown/binding-linux-x64-musl": - optional: true - "@rolldown/binding-openharmony-arm64": - optional: true - "@rolldown/binding-wasm32-wasi": - optional: true - "@rolldown/binding-win32-arm64-msvc": - optional: true - "@rolldown/binding-win32-x64-msvc": - optional: true - bin: - rolldown: ./bin/cli.mjs - checksum: 10c0/5f9dd47b7abf203b16bc600db68542f245e974c800e59ff50b76157d1dada1403657690435b036fabca88e93d13a67c31abe5cfaa6f61ce33717f61720204cdf - languageName: node - linkType: hard - "rolldown@npm:~1.1.5": version: 1.1.5 resolution: "rolldown@npm:1.1.5" @@ -19078,22 +18858,13 @@ __metadata: languageName: node linkType: hard -"source-map@npm:^0.8.0": +"source-map@npm:^0.8.0, source-map@npm:^0.8.0-beta.0": version: 0.8.0 resolution: "source-map@npm:0.8.0" checksum: 10c0/fd2a5b81a1bf40f6155592f19c44abb46fc75b0f0f9473dd40c665b6f3866516a26218dad3d76b58b8b3e44560f3ab2191a837e1ce6631987e51a2db2e1cac56 languageName: node linkType: hard -"source-map@npm:^0.8.0-beta.0": - version: 0.8.0-beta.0 - resolution: "source-map@npm:0.8.0-beta.0" - dependencies: - whatwg-url: "npm:^7.0.0" - checksum: 10c0/fb4d9bde9a9fdb2c29b10e5eae6c71d10e09ef467e1afb75fdec2eb7e11fa5b343a2af553f74f18b695dbc0b81f9da2e9fa3d7a317d5985e9939499ec6087835 - languageName: node - linkType: hard - "space-separated-tokens@npm:^1.0.0": version: 1.1.5 resolution: "space-separated-tokens@npm:1.1.5" @@ -19940,15 +19711,6 @@ __metadata: languageName: node linkType: hard -"tr46@npm:^1.0.1": - version: 1.0.1 - resolution: "tr46@npm:1.0.1" - dependencies: - punycode: "npm:^2.1.0" - checksum: 10c0/41525c2ccce86e3ef30af6fa5e1464e6d8bb4286a58ea8db09228f598889581ef62347153f6636cd41553dc41685bdfad0a9d032ef58df9fbb0792b3447d0f04 - languageName: node - linkType: hard - "tr46@npm:^4.1.1": version: 4.1.1 resolution: "tr46@npm:4.1.1" @@ -20748,64 +20510,7 @@ __metadata: languageName: node linkType: hard -"vite@npm:^6.0.0 || ^7.0.0 || ^8.0.0": - version: 8.0.16 - resolution: "vite@npm:8.0.16" - dependencies: - fsevents: "npm:~2.3.3" - lightningcss: "npm:^1.32.0" - picomatch: "npm:^4.0.4" - postcss: "npm:^8.5.15" - rolldown: "npm:1.0.3" - tinyglobby: "npm:^0.2.17" - peerDependencies: - "@types/node": ^20.19.0 || >=22.12.0 - "@vitejs/devtools": ^0.1.18 - esbuild: ^0.27.0 || ^0.28.0 - jiti: ">=1.21.0" - less: ^4.0.0 - sass: ^1.70.0 - sass-embedded: ^1.70.0 - stylus: ">=0.54.8" - sugarss: ^5.0.0 - terser: ^5.16.0 - tsx: ^4.8.1 - yaml: ^2.4.2 - dependenciesMeta: - fsevents: - optional: true - peerDependenciesMeta: - "@types/node": - optional: true - "@vitejs/devtools": - optional: true - esbuild: - optional: true - jiti: - optional: true - less: - optional: true - sass: - optional: true - sass-embedded: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - tsx: - optional: true - yaml: - optional: true - bin: - vite: bin/vite.js - checksum: 10c0/d75be3fbe2f63e6a8145325970338afaf0dd4d96ba9175c13f9a286fd5f95afc489401b693e4fa6c0899a4dd0e137be91cdf9401a40a635563911ad5036e3467 - languageName: node - linkType: hard - -"vite@npm:^8.1.5": +"vite@npm:^6.0.0 || ^7.0.0 || ^8.0.0, vite@npm:^8.1.5": version: 8.1.5 resolution: "vite@npm:8.1.5" dependencies: @@ -20988,13 +20693,6 @@ __metadata: languageName: node linkType: hard -"webidl-conversions@npm:^4.0.2": - version: 4.0.2 - resolution: "webidl-conversions@npm:4.0.2" - checksum: 10c0/def5c5ac3479286dffcb604547628b2e6b46c5c5b8a8cfaa8c71dc3bafc85859bde5fbe89467ff861f571ab38987cf6ab3d6e7c80b39b999e50e803c12f3164f - languageName: node - linkType: hard - "webidl-conversions@npm:^7.0.0": version: 7.0.0 resolution: "webidl-conversions@npm:7.0.0" @@ -21061,17 +20759,6 @@ __metadata: languageName: node linkType: hard -"whatwg-url@npm:^7.0.0": - version: 7.1.0 - resolution: "whatwg-url@npm:7.1.0" - dependencies: - lodash.sortby: "npm:^4.7.0" - tr46: "npm:^1.0.1" - webidl-conversions: "npm:^4.0.2" - checksum: 10c0/2785fe4647690e5a0225a79509ba5e21fdf4a71f9de3eabdba1192483fe006fc79961198e0b99f82751557309f17fc5a07d4d83c251aa5b2f85ba71e674cbee9 - languageName: node - linkType: hard - "which-boxed-primitive@npm:^1.1.0, which-boxed-primitive@npm:^1.1.1": version: 1.1.1 resolution: "which-boxed-primitive@npm:1.1.1" From 5befd94fb81b42b5e915eb555d3dd477878b0555 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 18:23:51 -0400 Subject: [PATCH 22/34] perf: Fix streaming file outputs passthrough (#13153) * perf: Fix streaming file outputs passthrough correctly * test --- server/routes/api/documents/documents.test.ts | 50 +++++++++++++++++- server/routes/api/documents/documents.ts | 2 +- server/routes/api/revisions/revisions.test.ts | 51 ++++++++++++++++++- server/routes/api/revisions/revisions.ts | 2 +- server/test/support.ts | 30 +++++++++++ server/utils/koa.ts | 21 +++++--- shared/editor/nodes/Image.tsx | 4 +- 7 files changed, 147 insertions(+), 13 deletions(-) diff --git a/server/routes/api/documents/documents.test.ts b/server/routes/api/documents/documents.test.ts index 9872b55dbd..474b60b93e 100644 --- a/server/routes/api/documents/documents.test.ts +++ b/server/routes/api/documents/documents.test.ts @@ -39,8 +39,13 @@ import { buildGroup, buildAdmin, buildTemplate, + buildAttachment, } from "@server/test/factories"; -import { getTestServer, withAPIContext } from "@server/test/support"; +import { + getTestServer, + readZipResponse, + withAPIContext, +} from "@server/test/support"; const server = getTestServer(); @@ -604,6 +609,10 @@ describe("#documents.info", () => { }); describe("#documents.export", () => { + afterEach(() => { + vi.restoreAllMocks(); + }); + it("should return published document", async () => { const user = await buildUser(); const document = await buildDocument({ @@ -688,6 +697,45 @@ describe("#documents.export", () => { expect(body.data).toEqual(await DocumentHelper.toMarkdown(document)); }); + it("should stream a zip when the document has attachments", async () => { + const user = await buildUser(); + const attachment = await buildAttachment({ + teamId: user.teamId, + userId: user.id, + }); + const document = await buildDocument({ + title: "Export Test", + userId: user.id, + teamId: user.teamId, + text: `![image](${attachment.redirectUrl})`, + }); + vi.spyOn(FileStorage, "getFileBuffer").mockResolvedValue( + Buffer.from("image-data") + ); + + const res = await server.post("/api/documents.export", user, { + body: { + id: document.id, + }, + headers: { + accept: "text/markdown", + }, + }); + + expect(res.status).toEqual(200); + expect(res.headers.get("content-type")).toEqual("application/zip"); + expect(res.headers.get("content-disposition")).toContain( + `filename="export-test.zip"` + ); + + const location = `attachments/${attachment.id}.png`; + const entries = await readZipResponse(res); + expect(Object.keys(entries).sort()).toEqual([location, "export-test.md"]); + expect(entries[location]).toEqual("image-data"); + expect(entries["export-test.md"]).toContain(location); + expect(entries["export-test.md"]).not.toContain(attachment.redirectUrl); + }); + it("should require authorization without token", async () => { const document = await buildDocument(); const res = await server.post("/api/documents.export", { diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index 468acbb186..466080cb09 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -958,7 +958,7 @@ router.post( return; } - await streamZipResponse(ctx, `${fileName}.zip`, async (zip) => { + streamZipResponse(ctx, `${fileName}.zip`, (zip) => { for (const { attachment, buffer } of externalAttachments) { const location = path.join( "attachments", diff --git a/server/routes/api/revisions/revisions.test.ts b/server/routes/api/revisions/revisions.test.ts index b35c3cee21..407d3b3584 100644 --- a/server/routes/api/revisions/revisions.test.ts +++ b/server/routes/api/revisions/revisions.test.ts @@ -1,12 +1,14 @@ import { createContext } from "@server/context"; import { UserMembership, Revision } from "@server/models"; +import FileStorage from "@server/storage/files"; import { buildAdmin, + buildAttachment, buildCollection, buildDocument, buildUser, } from "@server/test/factories"; -import { getTestServer } from "@server/test/support"; +import { getTestServer, readZipResponse } from "@server/test/support"; const server = getTestServer(); @@ -245,6 +247,53 @@ describe("#revisions.list", () => { }); describe("#revisions.export", () => { + afterEach(() => { + vi.restoreAllMocks(); + }); + + it("should stream a zip when the revision has attachments", async () => { + const user = await buildUser(); + const attachment = await buildAttachment({ + teamId: user.teamId, + userId: user.id, + }); + const document = await buildDocument({ + title: "Export Test", + userId: user.id, + teamId: user.teamId, + text: `![image](${attachment.redirectUrl})`, + }); + const revision = await Revision.createFromDocument( + createContext({ user }), + document + ); + vi.spyOn(FileStorage, "getFileBuffer").mockResolvedValue( + Buffer.from("image-data") + ); + + const res = await server.post("/api/revisions.export", user, { + body: { + id: revision.id, + }, + headers: { + accept: "text/markdown", + }, + }); + + expect(res.status).toEqual(200); + expect(res.headers.get("content-type")).toEqual("application/zip"); + expect(res.headers.get("content-disposition")).toContain( + `filename="export-test.zip"` + ); + + const location = `attachments/${attachment.id}.png`; + const entries = await readZipResponse(res); + expect(Object.keys(entries).sort()).toEqual([location, "export-test.md"]); + expect(entries[location]).toEqual("image-data"); + expect(entries["export-test.md"]).toContain(location); + expect(entries["export-test.md"]).not.toContain(attachment.redirectUrl); + }); + it("should return revision as markdown by default", async () => { const user = await buildUser(); const document = await buildDocument({ diff --git a/server/routes/api/revisions/revisions.ts b/server/routes/api/revisions/revisions.ts index 6d8ef2dbdd..b0079d0520 100644 --- a/server/routes/api/revisions/revisions.ts +++ b/server/routes/api/revisions/revisions.ts @@ -195,7 +195,7 @@ router.post( return; } - await streamZipResponse(ctx, `${fileName}.zip`, async (zip) => { + streamZipResponse(ctx, `${fileName}.zip`, async (zip) => { for (const attachment of attachments) { const location = path.join( "attachments", diff --git a/server/test/support.ts b/server/test/support.ts index bb0e4bb814..d0d2e3e3b6 100644 --- a/server/test/support.ts +++ b/server/test/support.ts @@ -1,3 +1,7 @@ +import fs from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; +import { randomUUID } from "node:crypto"; import { faker } from "@faker-js/faker"; import type { Transaction } from "sequelize"; import { afterEach, beforeEach, vi } from "vitest"; @@ -11,6 +15,7 @@ import webService from "@server/services/web"; import { sequelize } from "@server/storage/database"; import type { APIContext } from "@server/types"; import { AuthenticationType } from "@server/types"; +import ZipHelper from "@server/utils/ZipHelper"; import TestServer from "./TestServer"; export function getTestServer() { @@ -78,6 +83,31 @@ export function withAPIContext( }); } +/** + * Read a zip archive returned from an API endpoint into memory. + * + * @param res The response to read the archive from. + * @returns a map of entry filename to the entry contents as a string. + */ +export async function readZipResponse( + res: Awaited> +): Promise> { + const filePath = path.join(os.tmpdir(), `test-${randomUUID()}.zip`); + await fs.writeFile(filePath, Buffer.from(await res.arrayBuffer())); + + try { + const entries: Record = {}; + await ZipHelper.walk(filePath, async (entry) => { + entries[entry.fileName] = ( + await entry.readBuffer(1024 * 1024) + ).toString(); + }); + return entries; + } finally { + await fs.rm(filePath, { force: true }); + } +} + /** * Helper function to convert an object to form-urlencoded string. * Useful for testing OAuth endpoints that expect application/x-www-form-urlencoded content type. diff --git a/server/utils/koa.ts b/server/utils/koa.ts index 5a0a908e19..e12b15fc1e 100644 --- a/server/utils/koa.ts +++ b/server/utils/koa.ts @@ -36,13 +36,12 @@ export const getFileFromRequest = ( * @param fileName The filename to advertise in the Content-Disposition header. * @param build Callback that adds entries to the provided ZipFile. */ -export const streamZipResponse = async ( +export const streamZipResponse = ( ctx: Context, fileName: string, build: (zip: ZipFile) => void | Promise -): Promise => { +): void => { const zip = new ZipFile(); - await build(zip); ctx.set("Content-Type", "application/zip"); ctx.set( @@ -50,10 +49,20 @@ export const streamZipResponse = async ( contentDisposition(fileName, { type: "attachment" }) ); - zip.outputStream.on("error", (err) => { + const handleError = (err: Error) => { ctx.app.emit("error", err, ctx); ctx.res.destroy(err); - }); + }; + + zip.outputStream.on("error", handleError); ctx.body = zip.outputStream; - zip.end(); + + void (async () => { + try { + await build(zip); + zip.end(); + } catch (err) { + handleError(err instanceof Error ? err : new Error(String(err))); + } + })(); }; diff --git a/shared/editor/nodes/Image.tsx b/shared/editor/nodes/Image.tsx index 96c820d4b6..70968a5bda 100644 --- a/shared/editor/nodes/Image.tsx +++ b/shared/editor/nodes/Image.tsx @@ -33,7 +33,6 @@ const imageSizeRegex = /\s=(\d+)?x(\d+)?$/; // parse so the embed type survives the API markdown round-trip. const SOURCE_TOKEN_PREFIX = "source="; - type TitleAttributes = { layoutClass?: string; title?: string; @@ -520,8 +519,7 @@ export default class Image extends SimpleImage { } if (titleParts.length > 0 || size) { - markdown += - ' "' + state.esc(titleParts.join(" "), false) + size + '"'; + markdown += ' "' + state.esc(titleParts.join(" "), false) + size + '"'; } markdown += ")"; state.write(markdown); From 9ae7517efb1522c2b9b840adacc634c43913252e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 18:32:17 -0400 Subject: [PATCH 23/34] fix: Re-check file operation permissions at download (#13148) * fix: Re-check file operation permissions at download * feedback * Address feedback and copy across to other findByPk overrides --- server/models/Collection.test.ts | 24 +++ server/models/Collection.ts | 12 +- server/models/Document.test.ts | 24 +++ server/models/Document.ts | 12 +- server/models/FileOperation.test.ts | 39 ++++ server/models/FileOperation.ts | 98 ++++++++++- server/policies/collection.ts | 28 ++- server/policies/fileOperation.ts | 29 ++- .../api/fileOperations/fileOperations.test.ts | 166 +++++++++++++++++- .../api/fileOperations/fileOperations.ts | 4 +- 10 files changed, 416 insertions(+), 20 deletions(-) create mode 100644 server/models/FileOperation.test.ts diff --git a/server/models/Collection.test.ts b/server/models/Collection.test.ts index 12f192c42e..6c4d2aadb0 100644 --- a/server/models/Collection.test.ts +++ b/server/models/Collection.test.ts @@ -487,6 +487,30 @@ describe("#findByPk", () => { expect(response!.id).toBe(collection.id); }); + it("should not allow a passed where to override the id", async () => { + const collection = await buildCollection(); + const other = await buildCollection(); + + const response = await Collection.findByPk(collection.id, { + where: { id: other.id }, + }); + expect(response!.id).toBe(collection.id); + + const byUrlId = await Collection.findByPk(collection.urlId, { + where: { urlId: other.urlId }, + }); + expect(byUrlId!.id).toBe(collection.id); + }); + + it("should throw the passed error when rejectOnEmpty is an error", async () => { + const error = new Error("does not exist"); + await expect( + Collection.findByPk("0e8280ea-7b4c-40e5-98ba-ec8a2f00f5e8", { + rejectOnEmpty: error, + }) + ).rejects.toThrow(error); + }); + it("should not return documentStructure by default", async () => { const collection = await buildCollection(); const response = await Collection.findByPk(collection.id); diff --git a/server/models/Collection.ts b/server/models/Collection.ts index f6efef5d2f..afda6b30a4 100644 --- a/server/models/Collection.ts +++ b/server/models/Collection.ts @@ -682,15 +682,17 @@ class Collection extends ParanoidModel< if (isUUID(id)) { const collection = await scope.findOne({ + ...rest, where: { id, }, - ...rest, rejectOnEmpty: false, }); if (!collection && rest.rejectOnEmpty) { - throw new EmptyResultError(`Collection doesn't exist with id: ${id}`); + throw rest.rejectOnEmpty instanceof Error + ? rest.rejectOnEmpty + : new EmptyResultError(`Collection doesn't exist with id: ${id}`); } return collection; @@ -699,15 +701,17 @@ class Collection extends ParanoidModel< const match = id.match(UrlHelper.SLUG_URL_REGEX); if (match) { const collection = await scope.findOne({ + ...rest, where: { urlId: match[1], }, - ...rest, rejectOnEmpty: false, }); if (!collection && rest.rejectOnEmpty) { - throw new EmptyResultError(`Collection doesn't exist with id: ${id}`); + throw rest.rejectOnEmpty instanceof Error + ? rest.rejectOnEmpty + : new EmptyResultError(`Collection doesn't exist with id: ${id}`); } return collection; diff --git a/server/models/Document.test.ts b/server/models/Document.test.ts index 456d5d6b56..2b89419dbf 100644 --- a/server/models/Document.test.ts +++ b/server/models/Document.test.ts @@ -300,6 +300,30 @@ describe("#findByPk", () => { ).rejects.toThrow(EmptyResultError); }); + it("should not allow a passed where to override the id", async () => { + const document = await buildDocument(); + const other = await buildDocument(); + + const response = await Document.findByPk(document.id, { + where: { id: other.id }, + }); + expect(response?.id).toBe(document.id); + + const byUrlId = await Document.findByPk(document.urlId, { + where: { urlId: other.urlId }, + }); + expect(byUrlId?.id).toBe(document.id); + }); + + it("should throw the passed error when rejectOnEmpty is an error", async () => { + const error = new Error("does not exist"); + await expect( + Document.findByPk("0e8280ea-7b4c-40e5-98ba-ec8a2f00f5e8", { + rejectOnEmpty: error, + }) + ).rejects.toThrow(error); + }); + it("should load state as a fallback when content is empty", async () => { const state = Buffer.from([1, 2, 3]); const document = await buildDocument(); diff --git a/server/models/Document.ts b/server/models/Document.ts index 5ac8d59d5c..3cb4d285c8 100644 --- a/server/models/Document.ts +++ b/server/models/Document.ts @@ -820,15 +820,17 @@ class Document extends ArchivableModel< if (isUUID(id)) { const document = await scope.findOne({ + ...rest, where: { id, }, - ...rest, rejectOnEmpty: false, }); if (!document && rest.rejectOnEmpty) { - throw new EmptyResultError(`Document doesn't exist with id: ${id}`); + throw rest.rejectOnEmpty instanceof Error + ? rest.rejectOnEmpty + : new EmptyResultError(`Document doesn't exist with id: ${id}`); } return document; @@ -837,15 +839,17 @@ class Document extends ArchivableModel< const match = id.match(UrlHelper.SLUG_URL_REGEX); if (match) { const document = await scope.findOne({ + ...rest, where: { urlId: match[1], }, - ...rest, rejectOnEmpty: false, }); if (!document && rest.rejectOnEmpty) { - throw new EmptyResultError(`Document doesn't exist with id: ${id}`); + throw rest.rejectOnEmpty instanceof Error + ? rest.rejectOnEmpty + : new EmptyResultError(`Document doesn't exist with id: ${id}`); } return document; diff --git a/server/models/FileOperation.test.ts b/server/models/FileOperation.test.ts new file mode 100644 index 0000000000..7453ddd430 --- /dev/null +++ b/server/models/FileOperation.test.ts @@ -0,0 +1,39 @@ +import { + buildFileOperation, + buildTeam, + buildUser, +} from "@server/test/factories"; +import FileOperation from "./FileOperation"; + +describe("FileOperation", () => { + describe("findByPk", () => { + it("should not allow a passed where to override the id", async () => { + const team = await buildTeam(); + const user = await buildUser({ teamId: team.id }); + const fileOperation = await buildFileOperation({ + teamId: team.id, + userId: user.id, + }); + const other = await buildFileOperation({ + teamId: team.id, + userId: user.id, + }); + + const found = await FileOperation.findByPk(fileOperation.id, { + where: { id: other.id }, + }); + + expect(found?.id).toEqual(fileOperation.id); + }); + + it("should throw the passed error when rejectOnEmpty is an error", async () => { + const error = new Error("does not exist"); + + await expect( + FileOperation.findByPk("3a1b2c3d-0000-4000-8000-000000000000", { + rejectOnEmpty: error, + }) + ).rejects.toThrow(error); + }); + }); +}); diff --git a/server/models/FileOperation.ts b/server/models/FileOperation.ts index 12cd9397dc..4fe51f25ec 100644 --- a/server/models/FileOperation.ts +++ b/server/models/FileOperation.ts @@ -1,12 +1,16 @@ import type { + FindOptions, + Identifier, InferAttributes, InferCreationAttributes, + NonNullFindOptions, WhereOptions, } from "sequelize"; -import { Op } from "sequelize"; +import { EmptyResultError, Op } from "sequelize"; import { ForeignKey, DefaultScope, + Scopes, Column, BeforeDestroy, BelongsTo, @@ -30,6 +34,11 @@ export type FileOperationOptions = { permission?: CollectionPermission | null; }; +type AdditionalFindOptions = { + userId?: string; + rejectOnEmpty?: boolean | Error; +}; + @DefaultScope(() => ({ include: [ { @@ -52,6 +61,47 @@ export type FileOperationOptions = { }, ], })) +@Scopes(() => ({ + withSource: (userId: string) => { + if (!userId) { + return {}; + } + + return { + include: [ + { + model: User, + as: "user", + paranoid: false, + }, + { + model: Collection.scope([ + "defaultScope", + { + method: ["withMembership", userId], + }, + ]), + as: "collection", + required: false, + paranoid: false, + }, + { + model: Document.scope([ + "defaultScope", + { + method: ["withMembership", userId, false], + }, + ]), + as: "document", + // Content columns are not needed to authorize or present an export. + attributes: { exclude: ["text", "content", "state"] }, + required: false, + paranoid: false, + }, + ], + }; + }, +})) @Table({ tableName: "file_operations", modelName: "file_operation" }) class FileOperation extends ParanoidModel< InferAttributes, @@ -59,6 +109,52 @@ class FileOperation extends ParanoidModel< > { static eventNamespace = "fileOperations"; + /** + * Overrides the standard findByPk behavior to allow loading the exported + * collection or document with memberships for a user passed in by `userId`. + * + * @param id uuid + * @param options FindOptions + * @returns a promise resolving to a file operation instance or null. + */ + static async findByPk( + id: Identifier, + options?: NonNullFindOptions & AdditionalFindOptions + ): Promise; + static async findByPk( + id: Identifier, + options?: FindOptions & AdditionalFindOptions + ): Promise; + static async findByPk( + id: Identifier, + options: FindOptions & AdditionalFindOptions = {} + ): Promise { + if (typeof id !== "string") { + return null; + } + + const { userId, ...rest } = options; + + // Preserve the caller's scope when no userId is passed + const scope = userId + ? this.scope({ method: ["withSource", userId] }) + : this; + + const fileOperation = await scope.findOne({ + ...rest, + where: { id }, + rejectOnEmpty: false, + }); + + if (!fileOperation && rest.rejectOnEmpty) { + throw rest.rejectOnEmpty instanceof Error + ? rest.rejectOnEmpty + : new EmptyResultError(`File operation doesn't exist with id: ${id}`); + } + + return fileOperation; + } + @Column(DataType.ENUM(...Object.values(FileOperationType))) type: FileOperationType; diff --git a/server/policies/collection.ts b/server/policies/collection.ts index 56ef2e9b8a..0719b59d9c 100644 --- a/server/policies/collection.ts +++ b/server/policies/collection.ts @@ -1,7 +1,7 @@ import invariant from "invariant"; -import { CollectionPermission } from "@shared/types"; +import { CollectionPermission, TeamPreference } from "@shared/types"; import { Collection, User, Team } from "@server/models"; -import { allow } from "./cancan"; +import { allow, can } from "./cancan"; import { and, isTeamAdmin, isTeamModel, isTeamMutable, or } from "./utils"; allow(User, "createCollection", Team, (actor, team) => @@ -46,6 +46,16 @@ allow(User, "read", Collection, (user, collection) => { return true; }); +allow(User, "download", Collection, (actor, collection) => + and( + can(actor, "read", collection), + or( + and(!actor.isGuest, !actor.isViewer), + !!actor.team.getPreference(TeamPreference.ViewersCanExport) + ) + ) +); + allow( User, ["readDocument", "star", "unstar", "subscribe", "unsubscribe"], @@ -174,7 +184,7 @@ allow( ) ); -allow(User, ["update", "export", "archive"], Collection, (user, collection) => +allow(User, ["update", "archive"], Collection, (user, collection) => and( !!collection, !!collection?.isActive, @@ -185,6 +195,18 @@ allow(User, ["update", "export", "archive"], Collection, (user, collection) => ) ); +allow(User, "export", Collection, (user, collection) => + and( + !!collection, + !!collection?.isActive, + can(user, "download", collection), + or( + isTeamAdmin(user, collection), + includesMembership(collection, [CollectionPermission.Admin]) + ) + ) +); + allow(User, "delete", Collection, (user, collection) => and( !!collection, diff --git a/server/policies/fileOperation.ts b/server/policies/fileOperation.ts index 3b33937b0b..77cd67b8b5 100644 --- a/server/policies/fileOperation.ts +++ b/server/policies/fileOperation.ts @@ -1,6 +1,6 @@ import { FileOperationState, FileOperationType } from "@shared/types"; import { User, Team, FileOperation } from "@server/models"; -import { allow } from "./cancan"; +import { allow, can } from "./cancan"; import { and, isTeamAdmin, isTeamModel, isTeamMutable, or } from "./utils"; const TerminalStates = [ @@ -9,6 +9,25 @@ const TerminalStates = [ FileOperationState.Expired, ]; +/** + * An export is a snapshot that outlives the permissions it was created under, + * so access to the source is re-checked rather than trusting the ownership of + * the file operation alone. + */ +function canAccessSource(actor: User, fileOperation: FileOperation) { + if (fileOperation.type !== FileOperationType.Export) { + return true; + } + if (fileOperation.documentId) { + return can(actor, "download", fileOperation.document); + } + if (fileOperation.collectionId) { + return can(actor, "download", fileOperation.collection); + } + // Exports without a collection or document cover the entire workspace. + return can(actor, "createExport", actor.team); +} + allow( User, ["createFileOperation", "createExport"], @@ -20,7 +39,13 @@ allow( allow(User, "read", FileOperation, (actor, fileOperation) => and( isTeamModel(actor, fileOperation), - or(isTeamAdmin(actor, fileOperation), fileOperation?.userId === actor.id) + or( + isTeamAdmin(actor, fileOperation), + and( + fileOperation?.userId === actor.id, + !!fileOperation && canAccessSource(actor, fileOperation) + ) + ) ) ); diff --git a/server/routes/api/fileOperations/fileOperations.test.ts b/server/routes/api/fileOperations/fileOperations.test.ts index a252eb50a6..ab82128bdb 100644 --- a/server/routes/api/fileOperations/fileOperations.test.ts +++ b/server/routes/api/fileOperations/fileOperations.test.ts @@ -1,8 +1,19 @@ -import { FileOperationState, FileOperationType } from "@shared/types"; -import { Collection, User, Event, FileOperation } from "@server/models"; +import { + CollectionPermission, + FileOperationState, + FileOperationType, +} from "@shared/types"; +import { + Collection, + User, + Event, + FileOperation, + UserMembership, +} from "@server/models"; import { buildAdmin, buildCollection, + buildDocument, buildFileOperation, buildTeam, buildUser, @@ -37,6 +48,47 @@ describe("#fileOperations.info", () => { }); it("should allow user to read their own export", async () => { + const team = await buildTeam(); + const user = await buildUser({ teamId: team.id }); + const collection = await buildCollection({ teamId: team.id }); + const exportData = await buildFileOperation({ + type: FileOperationType.Export, + teamId: team.id, + userId: user.id, + collectionId: collection.id, + }); + const res = await server.post("/api/fileOperations.info", user, { + body: { + id: exportData.id, + }, + }); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.id).toBe(exportData.id); + }); + + it("should not allow user to read their own export of a collection they lost access to", async () => { + const team = await buildTeam(); + const user = await buildUser({ teamId: team.id }); + const collection = await buildCollection({ + teamId: team.id, + permission: null, + }); + const exportData = await buildFileOperation({ + type: FileOperationType.Export, + teamId: team.id, + userId: user.id, + collectionId: collection.id, + }); + const res = await server.post("/api/fileOperations.info", user, { + body: { + id: exportData.id, + }, + }); + expect(res.status).toEqual(403); + }); + + it("should not allow demoted admin to read their own workspace export", async () => { const team = await buildTeam(); const user = await buildUser({ teamId: team.id }); const exportData = await buildFileOperation({ @@ -49,9 +101,7 @@ describe("#fileOperations.info", () => { id: exportData.id, }, }); - const body = await res.json(); - expect(res.status).toEqual(200); - expect(body.data.id).toBe(exportData.id); + expect(res.status).toEqual(403); }); it("should not allow user to read another user's export", async () => { @@ -307,11 +357,13 @@ describe("#fileOperations.redirect", () => { it("should allow user to redirect their own export", async () => { const team = await buildTeam(); const user = await buildUser({ teamId: team.id }); + const collection = await buildCollection({ teamId: team.id }); const exportData = await buildFileOperation({ state: FileOperationState.Complete, type: FileOperationType.Export, teamId: team.id, userId: user.id, + collectionId: collection.id, }); const res = await server.post("/api/fileOperations.redirect", user, { body: { @@ -322,6 +374,110 @@ describe("#fileOperations.redirect", () => { expect(res.status).toEqual(302); }); + it("should not allow user to redirect their own export of a collection they lost access to", async () => { + const team = await buildTeam(); + const user = await buildUser({ teamId: team.id }); + const collection = await buildCollection({ + teamId: team.id, + permission: null, + }); + const exportData = await buildFileOperation({ + state: FileOperationState.Complete, + type: FileOperationType.Export, + teamId: team.id, + userId: user.id, + collectionId: collection.id, + }); + const res = await server.post("/api/fileOperations.redirect", user, { + body: { + id: exportData.id, + }, + redirect: "manual", + }); + expect(res.status).toEqual(403); + }); + + it("should allow user to redirect their own export of a private collection they are a member of", async () => { + const team = await buildTeam(); + const user = await buildUser({ teamId: team.id }); + const collection = await buildCollection({ + teamId: team.id, + permission: null, + }); + await UserMembership.create({ + createdById: user.id, + collectionId: collection.id, + userId: user.id, + permission: CollectionPermission.Admin, + }); + const exportData = await buildFileOperation({ + state: FileOperationState.Complete, + type: FileOperationType.Export, + teamId: team.id, + userId: user.id, + collectionId: collection.id, + }); + const res = await server.post("/api/fileOperations.redirect", user, { + body: { + id: exportData.id, + }, + redirect: "manual", + }); + expect(res.status).toEqual(302); + }); + + it("should allow user to redirect their own document export", async () => { + const team = await buildTeam(); + const user = await buildUser({ teamId: team.id }); + const collection = await buildCollection({ teamId: team.id }); + const document = await buildDocument({ + teamId: team.id, + userId: user.id, + collectionId: collection.id, + }); + const exportData = await buildFileOperation({ + state: FileOperationState.Complete, + type: FileOperationType.Export, + teamId: team.id, + userId: user.id, + documentId: document.id, + }); + const res = await server.post("/api/fileOperations.redirect", user, { + body: { + id: exportData.id, + }, + redirect: "manual", + }); + expect(res.status).toEqual(302); + }); + + it("should not allow user to redirect their own document export after losing access", async () => { + const team = await buildTeam(); + const user = await buildUser({ teamId: team.id }); + const collection = await buildCollection({ + teamId: team.id, + permission: null, + }); + const document = await buildDocument({ + teamId: team.id, + collectionId: collection.id, + }); + const exportData = await buildFileOperation({ + state: FileOperationState.Complete, + type: FileOperationType.Export, + teamId: team.id, + userId: user.id, + documentId: document.id, + }); + const res = await server.post("/api/fileOperations.redirect", user, { + body: { + id: exportData.id, + }, + redirect: "manual", + }); + expect(res.status).toEqual(403); + }); + it("should not allow user to redirect another user's export", async () => { const team = await buildTeam(); const admin = await buildAdmin({ teamId: team.id }); diff --git a/server/routes/api/fileOperations/fileOperations.ts b/server/routes/api/fileOperations/fileOperations.ts index 67ebc15eb9..c49b0e945e 100644 --- a/server/routes/api/fileOperations/fileOperations.ts +++ b/server/routes/api/fileOperations/fileOperations.ts @@ -24,6 +24,7 @@ router.post( const { user } = ctx.state.auth; const fileOperation = await FileOperation.findByPk(id, { + userId: user.id, rejectOnEmpty: true, }); @@ -77,7 +78,8 @@ const handleFileOperationsRedirect = async ( const id = (ctx.input.body.id ?? ctx.input.query.id) as string; const { user } = ctx.state.auth; - const fileOperation = await FileOperation.unscoped().findByPk(id, { + const fileOperation = await FileOperation.findByPk(id, { + userId: user.id, rejectOnEmpty: true, }); authorize(user, "read", fileOperation); From 8cdd2895a320f3e20d93b90630d278591ea4010d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 18:39:20 -0400 Subject: [PATCH 24/34] chore: Refactor get+post combos to register (#13168) --- plugins/email/server/auth/email.ts | 17 +++++++---------- plugins/oidc/server/auth/oidcRouter.ts | 7 +++++-- server/routes/api/attachments/attachments.ts | 17 +++++++---------- server/routes/api/cron/cron.ts | 14 ++++++++++---- .../routes/api/fileOperations/fileOperations.ts | 17 +++++++---------- server/routes/api/index.ts | 6 +----- 6 files changed, 37 insertions(+), 41 deletions(-) diff --git a/plugins/email/server/auth/email.ts b/plugins/email/server/auth/email.ts index 9454444fe8..e3a8f5e741 100644 --- a/plugins/email/server/auth/email.ts +++ b/plugins/email/server/auth/email.ts @@ -212,17 +212,14 @@ const emailCallback = async (ctx: APIContext) => { client, }); }; -router.get( +router.register( "email.callback", - rateLimiter(RateLimiterStrategy.FivePerMinute), - validate(T.EmailCallbackSchema), - emailCallback -); -router.post( - "email.callback", - rateLimiter(RateLimiterStrategy.FivePerMinute), - validate(T.EmailCallbackSchema), - emailCallback + ["get", "post"], + [ + rateLimiter(RateLimiterStrategy.FivePerMinute), + validate(T.EmailCallbackSchema), + emailCallback, + ] ); export default router; diff --git a/plugins/oidc/server/auth/oidcRouter.ts b/plugins/oidc/server/auth/oidcRouter.ts index 047f9a73ef..a5e9e517c8 100644 --- a/plugins/oidc/server/auth/oidcRouter.ts +++ b/plugins/oidc/server/auth/oidcRouter.ts @@ -255,8 +255,11 @@ export function createOIDCRouter( ); router.get(config.id, startOAuthFlow, passport.authenticate(config.id)); - router.get(`${config.id}.callback`, passportMiddleware(config.id)); - router.post(`${config.id}.callback`, passportMiddleware(config.id)); + router.register( + `${config.id}.callback`, + ["get", "post"], + passportMiddleware(config.id) + ); // Performs a spec-compliant RP-initiated logout against the provider's end // session endpoint. Passing `id_token_hint` identifies the session being diff --git a/server/routes/api/attachments/attachments.ts b/server/routes/api/attachments/attachments.ts index c0b17738f4..316146ae50 100644 --- a/server/routes/api/attachments/attachments.ts +++ b/server/routes/api/attachments/attachments.ts @@ -337,17 +337,14 @@ const handleAttachmentsRedirect = async ( } }; -router.get( +router.register( "attachments.redirect", - auth({ optional: true }), - validate(T.AttachmentsRedirectSchema), - handleAttachmentsRedirect -); -router.post( - "attachments.redirect", - auth({ optional: true }), - validate(T.AttachmentsRedirectSchema), - handleAttachmentsRedirect + ["get", "post"], + [ + auth({ optional: true }), + validate(T.AttachmentsRedirectSchema), + handleAttachmentsRedirect, + ] ); export default router; diff --git a/server/routes/api/cron/cron.ts b/server/routes/api/cron/cron.ts index 3510510568..e7e010a941 100644 --- a/server/routes/api/cron/cron.ts +++ b/server/routes/api/cron/cron.ts @@ -93,11 +93,17 @@ const cronHandler = async (ctx: APIContext) => { success: true, }; }; -router.get("cron.:period", validate(T.CronSchema), cronHandler); -router.post("cron.:period", validate(T.CronSchema), cronHandler); +router.register( + "cron.:period", + ["get", "post"], + [validate(T.CronSchema), cronHandler] +); // For backwards compatibility -router.get("utils.gc", validate(T.CronSchema), cronHandler); -router.post("utils.gc", validate(T.CronSchema), cronHandler); +router.register( + "utils.gc", + ["get", "post"], + [validate(T.CronSchema), cronHandler] +); export default router; diff --git a/server/routes/api/fileOperations/fileOperations.ts b/server/routes/api/fileOperations/fileOperations.ts index c49b0e945e..772ba60810 100644 --- a/server/routes/api/fileOperations/fileOperations.ts +++ b/server/routes/api/fileOperations/fileOperations.ts @@ -92,17 +92,14 @@ const handleFileOperationsRedirect = async ( ctx.redirect(accessUrl); }; -router.get( +router.register( "fileOperations.redirect", - auth(), - validate(T.FileOperationsRedirectSchema), - handleFileOperationsRedirect -); -router.post( - "fileOperations.redirect", - auth(), - validate(T.FileOperationsRedirectSchema), - handleFileOperationsRedirect + ["get", "post"], + [ + auth(), + validate(T.FileOperationsRedirectSchema), + handleFileOperationsRedirect, + ] ); router.post( diff --git a/server/routes/api/index.ts b/server/routes/api/index.ts index 8e31a767e7..04c73a5fd0 100644 --- a/server/routes/api/index.ts +++ b/server/routes/api/index.ts @@ -131,11 +131,7 @@ if (env.isDevelopment) { router.use("/", developer.routes()); } -router.post("*", (ctx) => { - ctx.throw(NotFoundError("Endpoint not found")); -}); - -router.get("*", (ctx) => { +router.register("*", ["get", "post"], (ctx) => { ctx.throw(NotFoundError("Endpoint not found")); }); From 715694684c3979803b55ce5cb0ca2864a6343722 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 18:50:23 -0400 Subject: [PATCH 25/34] chore: Encyrpted.test.ts flaky test (#13169) --- server/models/decorators/Encrypted.test.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/server/models/decorators/Encrypted.test.ts b/server/models/decorators/Encrypted.test.ts index 8bd3a70433..366c7064da 100644 --- a/server/models/decorators/Encrypted.test.ts +++ b/server/models/decorators/Encrypted.test.ts @@ -1,3 +1,4 @@ +import { errToString } from "@shared/utils/error"; import env from "@server/env"; import { encrypt, decrypt } from "./Encrypted"; @@ -40,10 +41,23 @@ describe("Encrypted", () => { expect(encrypt(value).equals(encrypt(value))).toBe(false); }); - it("should fail to decrypt tampered data", () => { - const encrypted = encrypt(JSON.stringify("hello world")); + it("should not return the original value for tampered data", () => { + const value = JSON.stringify("hello world"); + const encrypted = encrypt(value); encrypted[encrypted.length - 1] ^= 0xff; - expect(() => decrypt(encrypted)).toThrow(); + + try { + expect(decrypt(encrypted)).not.toEqual(value); + } catch (err) { + expect(errToString(err)).toMatch(/bad decrypt/); + } + }); + + it("should fail to decrypt a truncated ciphertext", () => { + const encrypted = encrypt(JSON.stringify("hello world")); + expect(() => + decrypt(encrypted.subarray(0, encrypted.length - 1)) + ).toThrow(); }); it("should fail to decrypt with a different key", () => { From 7b751ab04b1dabef38b89f8923daaead4eb32a23 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 27 Jul 2026 19:13:18 -0400 Subject: [PATCH 26/34] perf: Attach output stream before adding zip entries (#13167) * perf: Attach output stream before adding zip entries * fix: Handle failure --- package.json | 2 +- server/models/helpers/HTMLHelper.ts | 42 ++++-- server/queues/tasks/ExportDocumentTreeTask.ts | 86 +++++++------ server/queues/tasks/ExportHTMLZipTask.ts | 7 - server/queues/tasks/ExportJSONTask.ts | 68 ++++------ .../tasks/ExportMarkdownZipTask.test.ts | 92 +++++++++++++ server/queues/tasks/ExportMarkdownZipTask.ts | 7 - server/queues/tasks/ExportTask.ts | 45 +++++++ server/test/factories.ts | 29 +++++ server/typings/yazl.d.ts | 5 + server/utils/ZipHelper.test.ts | 121 ++++++++++++++++++ server/utils/ZipHelper.ts | 64 +++++++-- yarn.lock | 10 +- 13 files changed, 453 insertions(+), 125 deletions(-) diff --git a/package.json b/package.json index b60b6831bc..c25f82af03 100644 --- a/package.json +++ b/package.json @@ -345,7 +345,7 @@ "@types/utf8": "^3.0.3", "@types/validator": "^13.15.10", "@types/yauzl": "^2.10.3", - "@types/yazl": "^2.4.6", + "@types/yazl": "^3.3.1", "@vitest/ui": "^4.1.8", "browserslist-to-esbuild": "^1.2.0", "concurrently": "^8.2.2", diff --git a/server/models/helpers/HTMLHelper.ts b/server/models/helpers/HTMLHelper.ts index a8fb468f03..a2ecae7578 100644 --- a/server/models/helpers/HTMLHelper.ts +++ b/server/models/helpers/HTMLHelper.ts @@ -30,24 +30,46 @@ export default class HTMLHelper { contentType: string | null | undefined, buffer: Buffer ): string | null { - if (!contentType?.startsWith("image/")) { - return null; - } - if (buffer.length === 0 || buffer.length > HTMLHelper.maxInlineImageSize) { - return null; - } - - const pattern = new RegExp(escapeRegExp(redirectUrl), "g"); - if ((html.match(pattern)?.length ?? 0) !== 1) { + if ( + !HTMLHelper.canInlineImage(html, redirectUrl, contentType, buffer.length) + ) { return null; } return html.replace( - pattern, + new RegExp(escapeRegExp(redirectUrl), "g"), `data:${contentType};base64,${buffer.toString("base64")}` ); } + /** + * Whether an image meets the criteria for inlining, determined from its + * size alone so that callers can avoid reading images into memory that + * would be written to the export as an external file regardless. + * + * @param html The HTML content referencing the image. + * @param redirectUrl The redirect URL of the image within the HTML. + * @param contentType The content type of the image, e.g. "image/png". + * @param size The size of the image in bytes. + * @returns True if the image is a candidate for inlining. + */ + public static canInlineImage( + html: string, + redirectUrl: string, + contentType: string | null | undefined, + size: number + ): boolean { + if (!contentType?.startsWith("image/")) { + return false; + } + if (size === 0 || size > HTMLHelper.maxInlineImageSize) { + return false; + } + + const pattern = new RegExp(escapeRegExp(redirectUrl), "g"); + return (html.match(pattern)?.length ?? 0) === 1; + } + /** * Move CSS styles from