diff --git a/plugins/linear/server/tasks/UploadLinearWorkspaceLogoTask.ts b/plugins/linear/server/tasks/UploadLinearWorkspaceLogoTask.ts index 30529300c3..a0a815ef2d 100644 --- a/plugins/linear/server/tasks/UploadLinearWorkspaceLogoTask.ts +++ b/plugins/linear/server/tasks/UploadLinearWorkspaceLogoTask.ts @@ -1,4 +1,3 @@ -import { v4 as uuidv4 } from "uuid"; import { IntegrationService, IntegrationType } from "@shared/types"; import { Integration } from "@server/models"; import { Buckets } from "@server/models/helpers/AttachmentHelper"; @@ -27,7 +26,7 @@ export default class UploadLinearWorkspaceLogoTask extends BaseTask { const res = await FileStorage.storeFromUrl( props.logoUrl, - `${Buckets.avatars}/${integration.teamId}/${uuidv4()}`, + `${Buckets.avatars}/${integration.teamId}/${crypto.randomUUID()}`, "public-read", { headers: { diff --git a/plugins/storage/server/api/files.test.ts b/plugins/storage/server/api/files.test.ts index 16bf3503db..118d2eff98 100644 --- a/plugins/storage/server/api/files.test.ts +++ b/plugins/storage/server/api/files.test.ts @@ -3,7 +3,6 @@ import { readFile } from "fs/promises"; import path from "path"; import FormData from "form-data"; import { ensureDirSync } from "fs-extra"; -import { v4 as uuidV4 } from "uuid"; import { FileOperationState, FileOperationType } from "@shared/types"; import env from "@server/env"; import { Buckets } from "@server/models/helpers/AttachmentHelper"; @@ -135,7 +134,7 @@ describe("#files.get", () => { it("should fail with status 404 if existing file is requested with key", async () => { const user = await buildUser(); const fileName = "images.docx"; - const key = path.join("uploads", user.id, uuidV4(), fileName); + const key = path.join("uploads", user.id, crypto.randomUUID(), fileName); ensureDirSync( path.dirname(path.join(env.FILE_STORAGE_LOCAL_ROOT_DIR, key)) @@ -153,7 +152,7 @@ describe("#files.get", () => { it("should fail with status 404 if non-existing file is requested with key", async () => { const user = await buildUser(); const fileName = "images.docx"; - const key = path.join("uploads", user.id, uuidV4(), fileName); + const key = path.join("uploads", user.id, crypto.randomUUID(), fileName); const res = await server.get(`/api/files.get?key=${key}`); expect(res.status).toEqual(404); }); @@ -279,7 +278,7 @@ describe("#files.get", () => { it("should succeed with status 200 ok when avatar is requested using key", async () => { const user = await buildUser(); - const key = path.join("avatars", user.id, uuidV4()); + const key = path.join("avatars", user.id, crypto.randomUUID()); const attachment = await buildAttachment({ key, teamId: user.teamId, @@ -308,7 +307,7 @@ describe("#files.get", () => { it("should succeed with status 200 ok when avatar is requested using key", async () => { const user = await buildUser(); - const key = path.join("avatars", user.id, uuidV4()); + const key = path.join("avatars", user.id, crypto.randomUUID()); await buildAttachment({ key, teamId: user.teamId, @@ -335,7 +334,7 @@ describe("#files.get", () => { it("should succeed with status 200 ok when exported file is requested using signature", async () => { const user = await buildUser(); const fileName = "export-markdown.zip"; - const key = `${Buckets.uploads}/${user.teamId}/${uuidV4()}/${fileName}`; + const key = `${Buckets.uploads}/${user.teamId}/${crypto.randomUUID()}/${fileName}`; await buildFileOperation({ userId: user.id, diff --git a/plugins/webhooks/server/tasks/DeliverWebhookTask.test.ts b/plugins/webhooks/server/tasks/DeliverWebhookTask.test.ts index 0aa80c4bb3..7bc0683dd9 100644 --- a/plugins/webhooks/server/tasks/DeliverWebhookTask.test.ts +++ b/plugins/webhooks/server/tasks/DeliverWebhookTask.test.ts @@ -1,5 +1,4 @@ import fetchMock from "jest-fetch-mock"; -import { v4 as uuidv4 } from "uuid"; import { WebhookDelivery } from "@server/models"; import { buildUser, @@ -99,7 +98,7 @@ describe("DeliverWebhookTask", () => { url: "http://example.com", events: ["*"], }); - const deletedUserId = uuidv4(); + const deletedUserId = crypto.randomUUID(); const signedInUser = await buildUser({ teamId: subscription.teamId }); const task = new DeliverWebhookTask(); diff --git a/shared/editor/commands/insertFiles.ts b/shared/editor/commands/insertFiles.ts index 4f751720a7..1b981f0914 100644 --- a/shared/editor/commands/insertFiles.ts +++ b/shared/editor/commands/insertFiles.ts @@ -1,7 +1,6 @@ import * as Sentry from "@sentry/react"; import { EditorView } from "prosemirror-view"; import { toast } from "sonner"; -import { v4 as uuidv4 } from "uuid"; import type { Dictionary } from "~/hooks/useDictionary"; import FileHelper from "../lib/FileHelper"; import uploadPlaceholderPlugin, { @@ -72,7 +71,7 @@ const insertFiles = async function ( : undefined; return { - id: `upload-${uuidv4()}`, + id: `upload-${crypto.randomUUID()}`, dimensions: await getDimensions?.(file), isImage, isVideo, diff --git a/shared/editor/extensions/Mermaid.ts b/shared/editor/extensions/Mermaid.ts index 7d0716581d..c774b5b102 100644 --- a/shared/editor/extensions/Mermaid.ts +++ b/shared/editor/extensions/Mermaid.ts @@ -10,7 +10,6 @@ import { Transaction, } from "prosemirror-state"; import { Decoration, DecorationSet } from "prosemirror-view"; -import { v4 as uuidv4 } from "uuid"; import { isCode } from "../lib/isCode"; import { isRemoteTransaction } from "../lib/multiplayer"; import { findBlockNodes } from "../queries/findChildren"; @@ -54,7 +53,7 @@ class MermaidRenderer { readonly editor: Editor; constructor(editor: Editor) { - this.diagramId = uuidv4(); + this.diagramId = crypto.randomUUID(); this.elementId = `mermaid-diagram-wrapper-${this.diagramId}`; this.element = document.getElementById(this.elementId) || document.createElement("div"); diff --git a/shared/editor/marks/Comment.ts b/shared/editor/marks/Comment.ts index 8b28778807..8b578efc0c 100644 --- a/shared/editor/marks/Comment.ts +++ b/shared/editor/marks/Comment.ts @@ -1,7 +1,6 @@ import { toggleMark } from "prosemirror-commands"; import { MarkSpec, MarkType, Schema, Mark as PMMark } from "prosemirror-model"; import { Command, Plugin } from "prosemirror-state"; -import { v4 as uuidv4 } from "uuid"; import { addMark } from "../commands/addMark"; import { collapseSelection } from "../commands/collapseSelection"; import { chainTransactions } from "../lib/chainTransactions"; @@ -82,7 +81,7 @@ export default class Comment extends Mark { chainTransactions( toggleMark(type, { - id: uuidv4(), + id: crypto.randomUUID(), userId: this.options.userId, draft: true, }), @@ -112,7 +111,7 @@ export default class Comment extends Mark { chainTransactions( addMark(type, { - id: uuidv4(), + id: crypto.randomUUID(), userId: this.options.userId, draft: true, }), diff --git a/shared/editor/nodes/Mention.tsx b/shared/editor/nodes/Mention.tsx index ae69768fc8..bc75d66884 100644 --- a/shared/editor/nodes/Mention.tsx +++ b/shared/editor/nodes/Mention.tsx @@ -12,9 +12,7 @@ import { Plugin, TextSelection, } from "prosemirror-state"; -import * as React from "react"; import { Primitive } from "utility-types"; -import { v4 as uuidv4 } from "uuid"; import env from "../../env"; import { MentionType, UnfurlResourceType, UnfurlResponse } from "../../types"; import { @@ -172,7 +170,7 @@ export default class Mention extends Node { node.type.name === this.name && (!nodeId || existingIds.has(nodeId)) ) { - nodeId = uuidv4(); + nodeId = crypto.randomUUID(); modified = true; tr.setNodeAttribute(pos, "id", nodeId); }