From 73cd728c552444a2fe52b84df236e55c3ee6c76d Mon Sep 17 00:00:00 2001 From: Bibek Raj Ghimire <54546340+ghimirebibek@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:39:28 +0545 Subject: [PATCH 1/4] refactor: use native uuid generator. --- apps/api/src/__tests__/e2e_full_withAuth/index.test.ts | 3 +-- apps/api/src/controllers/__tests__/crawl.test.ts | 3 +-- apps/api/src/controllers/v0/crawl.ts | 7 +++---- apps/api/src/controllers/v0/crawlPreview.ts | 5 ++--- apps/api/src/controllers/v0/scrape.ts | 3 +-- apps/api/src/controllers/v0/search.ts | 5 ++--- apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP | 3 +-- apps/api/src/controllers/v1/batch-scrape.ts | 5 ++--- apps/api/src/controllers/v1/crawl-status-ws.ts | 3 +-- apps/api/src/controllers/v1/crawl.ts | 5 ++--- apps/api/src/controllers/v1/map.ts | 3 +-- apps/api/src/controllers/v1/scrape.ts | 3 +-- apps/api/src/index.ts | 3 +-- apps/api/src/run-req.ts | 3 +-- apps/api/src/services/queue-jobs.ts | 3 +-- apps/api/src/services/queue-worker.ts | 5 ++--- .../firecrawl/src/__tests__/e2e_withAuth/index.test.ts | 3 +-- .../firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts | 3 +-- 18 files changed, 25 insertions(+), 43 deletions(-) diff --git a/apps/api/src/__tests__/e2e_full_withAuth/index.test.ts b/apps/api/src/__tests__/e2e_full_withAuth/index.test.ts index b1708abc2..a617bc7ff 100644 --- a/apps/api/src/__tests__/e2e_full_withAuth/index.test.ts +++ b/apps/api/src/__tests__/e2e_full_withAuth/index.test.ts @@ -1,6 +1,5 @@ import request from "supertest"; import dotenv from "dotenv"; -import { v4 as uuidv4 } from "uuid"; dotenv.config(); @@ -396,7 +395,7 @@ describe("E2E Tests for API Routes", () => { ); }); it.concurrent('should prevent duplicate requests using the same idempotency key', async () => { - const uniqueIdempotencyKey = uuidv4(); + const uniqueIdempotencyKey = crypto.randomUUID(); // First request with the idempotency key const firstResponse = await request(TEST_URL) diff --git a/apps/api/src/controllers/__tests__/crawl.test.ts b/apps/api/src/controllers/__tests__/crawl.test.ts index e65523cb1..8ba72de3d 100644 --- a/apps/api/src/controllers/__tests__/crawl.test.ts +++ b/apps/api/src/controllers/__tests__/crawl.test.ts @@ -3,7 +3,6 @@ import { Request, Response } from 'express'; import { authenticateUser } from '../auth'; // Ensure this import is correct import { createIdempotencyKey } from '../../services/idempotency/create'; import { validateIdempotencyKey } from '../../services/idempotency/validate'; -import { v4 as uuidv4 } from 'uuid'; jest.mock('../auth', () => ({ authenticateUser: jest.fn().mockResolvedValue({ @@ -20,7 +19,7 @@ describe('crawlController', () => { it('should prevent duplicate requests using the same idempotency key', async () => { const req = { headers: { - 'x-idempotency-key': await uuidv4(), + 'x-idempotency-key': await crypto.randomUUID(), 'Authorization': `Bearer ${process.env.TEST_API_KEY}` }, body: { diff --git a/apps/api/src/controllers/v0/crawl.ts b/apps/api/src/controllers/v0/crawl.ts index 3ebee9768..70990cfdf 100644 --- a/apps/api/src/controllers/v0/crawl.ts +++ b/apps/api/src/controllers/v0/crawl.ts @@ -8,7 +8,6 @@ import { logCrawl } from "../../../src/services/logging/crawl_log"; import { validateIdempotencyKey } from "../../../src/services/idempotency/validate"; import { createIdempotencyKey } from "../../../src/services/idempotency/create"; import { defaultCrawlPageOptions, defaultCrawlerOptions, defaultOrigin } from "../../../src/lib/default-values"; -import { v4 as uuidv4 } from "uuid"; import { Logger } from "../../../src/lib/logger"; import { addCrawlJob, addCrawlJobs, crawlToCrawler, lockURL, lockURLs, saveCrawl, StoredCrawl } from "../../../src/lib/crawl-redis"; import { getScrapeQueue } from "../../../src/services/queue-service"; @@ -103,7 +102,7 @@ export async function crawlController(req: Request, res: Response) { // try { // const a = new WebScraperDataProvider(); // await a.setOptions({ - // jobId: uuidv4(), + // jobId: crypto.randomUUID(), // mode: "single_urls", // urls: [url], // crawlerOptions: { ...crawlerOptions, returnOnlyUrls: true }, @@ -128,7 +127,7 @@ export async function crawlController(req: Request, res: Response) { // } // } - const id = uuidv4(); + const id = crypto.randomUUID(); await logCrawl(id, team_id); @@ -164,7 +163,7 @@ export async function crawlController(req: Request, res: Response) { } const jobs = sitemap.map((x) => { const url = x.url; - const uuid = uuidv4(); + const uuid = crypto.randomUUID(); return { name: uuid, data: { diff --git a/apps/api/src/controllers/v0/crawlPreview.ts b/apps/api/src/controllers/v0/crawlPreview.ts index bceb1df94..cbb9d422e 100644 --- a/apps/api/src/controllers/v0/crawlPreview.ts +++ b/apps/api/src/controllers/v0/crawlPreview.ts @@ -2,7 +2,6 @@ import { Request, Response } from "express"; import { authenticateUser } from "../auth"; import { RateLimiterMode } from "../../../src/types"; import { isUrlBlocked } from "../../../src/scraper/WebScraper/utils/blocklist"; -import { v4 as uuidv4 } from "uuid"; import { Logger } from "../../../src/lib/logger"; import { addCrawlJob, crawlToCrawler, lockURL, saveCrawl, StoredCrawl } from "../../../src/lib/crawl-redis"; import { addScrapeJob } from "../../../src/services/queue-jobs"; @@ -51,7 +50,7 @@ export async function crawlPreviewController(req: Request, res: Response) { // try { // const a = new WebScraperDataProvider(); // await a.setOptions({ - // jobId: uuidv4(), + // jobId: crypto.randomUUID(), // mode: "single_urls", // urls: [url], // crawlerOptions: { ...crawlerOptions, returnOnlyUrls: true }, @@ -76,7 +75,7 @@ export async function crawlPreviewController(req: Request, res: Response) { // } // } - const id = uuidv4(); + const id = crypto.randomUUID(); let robots; diff --git a/apps/api/src/controllers/v0/scrape.ts b/apps/api/src/controllers/v0/scrape.ts index f5dbc3d11..e211e41cb 100644 --- a/apps/api/src/controllers/v0/scrape.ts +++ b/apps/api/src/controllers/v0/scrape.ts @@ -18,7 +18,6 @@ import { } from "../../lib/default-values"; import { addScrapeJob, waitForJob } from "../../services/queue-jobs"; import { getScrapeQueue } from "../../services/queue-service"; -import { v4 as uuidv4 } from "uuid"; import { Logger } from "../../lib/logger"; import * as Sentry from "@sentry/node"; import { getJobPriority } from "../../lib/job-priority"; @@ -208,7 +207,7 @@ export async function scrapeController(req: Request, res: Response) { }); } - const jobId = uuidv4(); + const jobId = crypto.randomUUID(); const startTime = new Date().getTime(); const result = await scrapeHelper( diff --git a/apps/api/src/controllers/v0/search.ts b/apps/api/src/controllers/v0/search.ts index 3635a4c48..a85692eff 100644 --- a/apps/api/src/controllers/v0/search.ts +++ b/apps/api/src/controllers/v0/search.ts @@ -7,7 +7,6 @@ import { logJob } from "../../services/logging/log_job"; import { PageOptions, SearchOptions } from "../../lib/entities"; import { search } from "../../search"; import { isUrlBlocked } from "../../scraper/WebScraper/utils/blocklist"; -import { v4 as uuidv4 } from "uuid"; import { Logger } from "../../lib/logger"; import { getScrapeQueue } from "../../services/queue-service"; import { addScrapeJob, waitForJob } from "../../services/queue-jobs"; @@ -82,7 +81,7 @@ export async function searchHelper( const jobDatas = res.map(x => { const url = x.url; - const uuid = uuidv4(); + const uuid = crypto.randomUUID(); return { name: uuid, data: { @@ -157,7 +156,7 @@ export async function searchController(req: Request, res: Response) { const searchOptions = req.body.searchOptions ?? { limit: 5 }; - const jobId = uuidv4(); + const jobId = crypto.randomUUID(); try { const { success: creditsCheckSuccess, message: creditsCheckMessage } = diff --git a/apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP b/apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP index 621c74361..6a5a7ad02 100644 --- a/apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP +++ b/apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP @@ -3,7 +3,6 @@ import { Request, Response } from 'express'; import { authenticateUser } from '../auth'; // Ensure this import is correct import { createIdempotencyKey } from '../../services/idempotency/create'; import { validateIdempotencyKey } from '../../services/idempotency/validate'; -import { v4 as uuidv4 } from 'uuid'; jest.mock('../auth', () => ({ authenticateUser: jest.fn().mockResolvedValue({ @@ -20,7 +19,7 @@ describe('crawlController', () => { it('should prevent duplicate requests using the same idempotency key', async () => { const req = { headers: { - 'x-idempotency-key': await uuidv4(), + 'x-idempotency-key': await crypto.randomUUID(), 'Authorization': `Bearer ${process.env.TEST_API_KEY}` }, body: { diff --git a/apps/api/src/controllers/v1/batch-scrape.ts b/apps/api/src/controllers/v1/batch-scrape.ts index cde4bd767..e79d83b0d 100644 --- a/apps/api/src/controllers/v1/batch-scrape.ts +++ b/apps/api/src/controllers/v1/batch-scrape.ts @@ -1,5 +1,4 @@ import { Response } from "express"; -import { v4 as uuidv4 } from "uuid"; import { BatchScrapeRequest, batchScrapeRequestSchema, @@ -24,7 +23,7 @@ export async function batchScrapeController( ) { req.body = batchScrapeRequestSchema.parse(req.body); - const id = uuidv4(); + const id = crypto.randomUUID(); await logCrawl(id, req.auth.team_id); @@ -58,7 +57,7 @@ export async function batchScrapeController( } const jobs = req.body.urls.map((x) => { - const uuid = uuidv4(); + const uuid = crypto.randomUUID(); return { name: uuid, data: { diff --git a/apps/api/src/controllers/v1/crawl-status-ws.ts b/apps/api/src/controllers/v1/crawl-status-ws.ts index 3738e3a21..f47607388 100644 --- a/apps/api/src/controllers/v1/crawl-status-ws.ts +++ b/apps/api/src/controllers/v1/crawl-status-ws.ts @@ -3,7 +3,6 @@ import { RateLimiterMode } from "../../types"; import { authenticateUser } from "../auth"; import { CrawlStatusParams, CrawlStatusResponse, Document, ErrorResponse, legacyDocumentConverter, RequestWithAuth } from "./types"; import { WebSocket } from "ws"; -import { v4 as uuidv4 } from "uuid"; import { Logger } from "../../lib/logger"; import { getCrawl, getCrawlExpiry, getCrawlJobs, getDoneJobsOrdered, getDoneJobsOrderedLength, getThrottledJobs, isCrawlFinished, isCrawlFinishedLocked } from "../../lib/crawl-redis"; import { getScrapeQueue } from "../../services/queue-service"; @@ -158,7 +157,7 @@ export async function crawlStatusWSController(ws: WebSocket, req: RequestWithAut } catch (err) { Sentry.captureException(err); - const id = uuidv4(); + const id = crypto.randomUUID(); let verbose = JSON.stringify(err); if (verbose === "{}") { if (err instanceof Error) { diff --git a/apps/api/src/controllers/v1/crawl.ts b/apps/api/src/controllers/v1/crawl.ts index 0000b6fea..2f77d2838 100644 --- a/apps/api/src/controllers/v1/crawl.ts +++ b/apps/api/src/controllers/v1/crawl.ts @@ -1,5 +1,4 @@ import { Response } from "express"; -import { v4 as uuidv4 } from "uuid"; import { CrawlRequest, crawlRequestSchema, @@ -30,7 +29,7 @@ export async function crawlController( ) { req.body = crawlRequestSchema.parse(req.body); - const id = uuidv4(); + const id = crypto.randomUUID(); await logCrawl(id, req.auth.team_id); @@ -103,7 +102,7 @@ export async function crawlController( } const jobs = sitemap.map((x) => { const url = x.url; - const uuid = uuidv4(); + const uuid = crypto.randomUUID(); return { name: uuid, data: { diff --git a/apps/api/src/controllers/v1/map.ts b/apps/api/src/controllers/v1/map.ts index 5ed3dd51c..f93be2b5a 100644 --- a/apps/api/src/controllers/v1/map.ts +++ b/apps/api/src/controllers/v1/map.ts @@ -1,5 +1,4 @@ import { Response } from "express"; -import { v4 as uuidv4 } from "uuid"; import { legacyCrawlerOptions, mapRequestSchema, @@ -39,7 +38,7 @@ export async function mapController( const limit: number = req.body.limit ?? MAX_MAP_LIMIT; - const id = uuidv4(); + const id = crypto.randomUUID(); let links: string[] = [req.body.url]; const sc: StoredCrawl = { diff --git a/apps/api/src/controllers/v1/scrape.ts b/apps/api/src/controllers/v1/scrape.ts index d0d4c5fc6..6d98f0658 100644 --- a/apps/api/src/controllers/v1/scrape.ts +++ b/apps/api/src/controllers/v1/scrape.ts @@ -11,7 +11,6 @@ import { ScrapeResponse, } from "./types"; import { billTeam } from "../../services/billing/credit_billing"; -import { v4 as uuidv4 } from "uuid"; import { numTokensFromString } from "../../lib/LLM-extraction/helpers"; import { addScrapeJob, waitForJob } from "../../services/queue-jobs"; import { logJob } from "../../services/logging/log_job"; @@ -29,7 +28,7 @@ export async function scrapeController( const timeout = req.body.timeout; const pageOptions = legacyScrapeOptions(req.body); const extractorOptions = req.body.extract ? legacyExtractorOptions(req.body.extract) : undefined; - const jobId = uuidv4(); + const jobId = crypto.randomUUID(); const startTime = new Date().getTime(); const jobPriority = await getJobPriority({ diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 5ccbb9cc5..e058eec54 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -19,7 +19,6 @@ import expressWs from "express-ws"; import { crawlStatusWSController } from "./controllers/v1/crawl-status-ws"; import { ErrorResponse, ResponseWithSentry } from "./controllers/v1/types"; import { ZodError } from "zod"; -import { v4 as uuidv4 } from "uuid"; import dns from 'node:dns'; const { createBullBoard } = require("@bull-board/api"); @@ -194,7 +193,7 @@ app.use((err: unknown, req: Request<{}, ErrorResponse, undefined>, res: Response return res.status(400).json({ success: false, error: 'Bad request, malformed JSON' }); } - const id = res.sentry ?? uuidv4(); + const id = res.sentry ?? crypto.randomUUID(); let verbose = JSON.stringify(err); if (verbose === "{}") { if (err instanceof Error) { diff --git a/apps/api/src/run-req.ts b/apps/api/src/run-req.ts index 6d29916d4..9e75368ac 100644 --- a/apps/api/src/run-req.ts +++ b/apps/api/src/run-req.ts @@ -1,6 +1,5 @@ import axios from "axios"; import { promises as fs } from "fs"; -import { v4 as uuidV4 } from "uuid"; interface Result { start_url: string; @@ -10,7 +9,7 @@ interface Result { } async function sendCrawl(result: Result): Promise { - const idempotencyKey = uuidV4(); + const idempotencyKey = crypto.randomUUID(); const url = result.start_url; try { const response = await axios.post( diff --git a/apps/api/src/services/queue-jobs.ts b/apps/api/src/services/queue-jobs.ts index 315700a1e..84ff3abbb 100644 --- a/apps/api/src/services/queue-jobs.ts +++ b/apps/api/src/services/queue-jobs.ts @@ -1,6 +1,5 @@ import { Job, Queue } from "bullmq"; import { getScrapeQueue } from "./queue-service"; -import { v4 as uuidv4 } from "uuid"; import { WebScraperOptions } from "../types"; import * as Sentry from "@sentry/node"; @@ -20,7 +19,7 @@ async function addScrapeJobRaw( export async function addScrapeJob( webScraperOptions: WebScraperOptions, options: any = {}, - jobId: string = uuidv4(), + jobId: string = crypto.randomUUID(), jobPriority: number = 10 ): Promise { diff --git a/apps/api/src/services/queue-worker.ts b/apps/api/src/services/queue-worker.ts index f15aca4eb..c43a6dc11 100644 --- a/apps/api/src/services/queue-worker.ts +++ b/apps/api/src/services/queue-worker.ts @@ -16,7 +16,6 @@ import { Job, Queue } from "bullmq"; import { Logger } from "../lib/logger"; import { Worker } from "bullmq"; import systemMonitor from "./system-monitor"; -import { v4 as uuidv4 } from "uuid"; import { addCrawlJob, addCrawlJobDone, @@ -125,7 +124,7 @@ const workerFun = async ( console.log("No longer accepting new jobs. SIGINT"); break; } - const token = uuidv4(); + const token = crypto.randomUUID(); const canAcceptConnection = await monitor.acceptConnection(); if (!canAcceptConnection) { console.log("Cant accept connection"); @@ -384,7 +383,7 @@ async function processJob(job: Job, token: string) { team_id: sc.team_id, basePriority: job.data.crawl_id ? 20 : 10, }); - const jobId = uuidv4(); + const jobId = crypto.randomUUID(); // console.log("plan: ", sc.plan); // console.log("team_id: ", sc.team_id) diff --git a/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts b/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts index 7d107afe6..3889fe0aa 100644 --- a/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts +++ b/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts @@ -6,7 +6,6 @@ import FirecrawlApp, { ScrapeResponseV0, SearchResponseV0, } from "../../index"; -import { v4 as uuidv4 } from "uuid"; import dotenv from "dotenv"; import { describe, test, expect } from "@jest/globals"; @@ -200,7 +199,7 @@ describe('FirecrawlApp<"v0"> E2E Tests', () => { apiUrl: API_URL, version: "v0", }); - const uniqueIdempotencyKey = uuidv4(); + const uniqueIdempotencyKey = crypto.randomUUID(); const response = (await app.crawlUrl( "https://roastmywebsite.ai", { crawlerOptions: { excludes: ["blog/*"] } }, diff --git a/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts b/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts index dea558462..bcd8ac085 100644 --- a/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts +++ b/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts @@ -1,5 +1,4 @@ import FirecrawlApp, { type CrawlParams, type CrawlResponse, type CrawlStatusResponse, type MapResponse, type ScrapeResponse } from '../../../index'; -import { v4 as uuidv4 } from 'uuid'; import dotenv from 'dotenv'; import { describe, test, expect } from '@jest/globals'; @@ -256,7 +255,7 @@ describe('FirecrawlApp E2E Tests', () => { test.concurrent('should handle idempotency key for crawl', async () => { const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL }); - const uniqueIdempotencyKey = uuidv4(); + const uniqueIdempotencyKey = crypto.randomUUID(); const response = await app.asyncCrawlUrl('https://roastmywebsite.ai', {}, uniqueIdempotencyKey) as CrawlResponse; expect(response).not.toBeNull(); expect(response.id).toBeDefined(); From b43deb0b6e7e07d69edcc1bd0b4219e958346e3a Mon Sep 17 00:00:00 2001 From: Bibek Raj Ghimire <54546340+ghimirebibek@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:42:01 +0545 Subject: [PATCH 2/4] Update crawl.test.ts --- apps/api/src/controllers/__tests__/crawl.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/src/controllers/__tests__/crawl.test.ts b/apps/api/src/controllers/__tests__/crawl.test.ts index 8ba72de3d..600f310f5 100644 --- a/apps/api/src/controllers/__tests__/crawl.test.ts +++ b/apps/api/src/controllers/__tests__/crawl.test.ts @@ -19,7 +19,7 @@ describe('crawlController', () => { it('should prevent duplicate requests using the same idempotency key', async () => { const req = { headers: { - 'x-idempotency-key': await crypto.randomUUID(), + 'x-idempotency-key': crypto.randomUUID(), 'Authorization': `Bearer ${process.env.TEST_API_KEY}` }, body: { @@ -43,4 +43,4 @@ describe('crawlController', () => { expect(res.status).toHaveBeenCalledWith(409); expect(res.json).toHaveBeenCalledWith({ error: 'Idempotency key already used' }); }); -}); \ No newline at end of file +}); From 5fe809ae410bbfa5bea1c157e12317dcca549611 Mon Sep 17 00:00:00 2001 From: Bibek Raj Ghimire <54546340+ghimirebibek@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:42:31 +0545 Subject: [PATCH 3/4] Update crawl.test.ts.WIP --- apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP b/apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP index 6a5a7ad02..1bec52cac 100644 --- a/apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP +++ b/apps/api/src/controllers/v1/__tests__/crawl.test.ts.WIP @@ -19,7 +19,7 @@ describe('crawlController', () => { it('should prevent duplicate requests using the same idempotency key', async () => { const req = { headers: { - 'x-idempotency-key': await crypto.randomUUID(), + 'x-idempotency-key': crypto.randomUUID(), 'Authorization': `Bearer ${process.env.TEST_API_KEY}` }, body: { @@ -43,4 +43,4 @@ describe('crawlController', () => { expect(res.status).toHaveBeenCalledWith(409); expect(res.json).toHaveBeenCalledWith({ error: 'Idempotency key already used' }); }); -}); \ No newline at end of file +}); From 775e44a866d879d92709c044fec376f725554f45 Mon Sep 17 00:00:00 2001 From: Bibek Raj Ghimire <54546340+ghimirebibek@users.noreply.github.com> Date: Tue, 29 Oct 2024 20:07:34 +0545 Subject: [PATCH 4/4] refactor: added regex uuid validation --- apps/api/package.json | 1 - apps/api/src/controllers/auth.ts | 4 +++- apps/js-sdk/firecrawl/package.json | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api/package.json b/apps/api/package.json index a0f9cf8e5..2dc5fb041 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -113,7 +113,6 @@ "turndown-plugin-gfm": "^1.0.2", "typesense": "^1.5.4", "unstructured-client": "^0.11.3", - "uuid": "^10.0.0", "wordpos": "^2.1.0", "ws": "^8.18.0", "xml2js": "^0.6.2", diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts index 93327e66e..972dc3d4c 100644 --- a/apps/api/src/controllers/auth.ts +++ b/apps/api/src/controllers/auth.ts @@ -32,9 +32,11 @@ import { AuthCreditUsageChunk } from "./v1/types"; // .eq('key', normalizedApi) // .limit(1) // .single(); +const UUID_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i; + function normalizedApiIsUuid(potentialUuid: string): boolean { // Check if the string is a valid UUID - return validate(potentialUuid); + return typeof potentialUuid === 'string' && UUID_REGEX.test(potentialUuid); } export async function setCachedACUC( diff --git a/apps/js-sdk/firecrawl/package.json b/apps/js-sdk/firecrawl/package.json index b8738e5eb..db703509a 100644 --- a/apps/js-sdk/firecrawl/package.json +++ b/apps/js-sdk/firecrawl/package.json @@ -36,7 +36,6 @@ }, "homepage": "https://github.com/mendableai/firecrawl#readme", "devDependencies": { - "uuid": "^9.0.1", "dotenv": "^16.4.5", "@jest/globals": "^29.7.0", "@types/axios": "^0.14.0",