diff --git a/package-lock.json b/package-lock.json index a382175a09..0b309295a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23711,15 +23711,6 @@ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.1.tgz", "integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==" }, - "node_modules/node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=", - "deprecated": "Use uuid module instead", - "bin": { - "uuid": "bin/uuid" - } - }, "node_modules/nodemailer": { "version": "6.7.2", "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.7.2.tgz", @@ -33546,7 +33537,6 @@ "glob": "^7.1.6", "lodash.once": "^4.1.1", "node-fetch": "^2.6.7", - "node-uuid": "~1.4.8", "range-parser": "^1.2.1", "stream-buffers": "~0.2.6", "tiny-async-pool": "^1.1.0" @@ -34237,8 +34227,7 @@ "overleaf-editor-core": "*", "redis": "~0.10.1", "request": "^2.88.2", - "requestretry": "^1.12.2", - "uuid": "^9.0.0" + "requestretry": "^1.12.2" }, "devDependencies": { "chai": "^4.3.6", @@ -34689,14 +34678,6 @@ "node": ">=0.6" } }, - "services/project-history/node_modules/uuid": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", - "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "services/real-time": { "name": "@overleaf/real-time", "dependencies": { @@ -34776,8 +34757,7 @@ "ioredis": "^4.16.1", "lodash": "^4.17.19", "request": "^2.88.2", - "underscore": "^1.10.2", - "uuid": "^7.0.3" + "underscore": "^1.10.2" }, "devDependencies": { "bson": "^1.1.5", @@ -34788,14 +34768,6 @@ "sinon": "^9.2.4" } }, - "services/references/node_modules/uuid": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", - "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "services/spelling": { "name": "@overleaf/spelling", "version": "0.1.4", @@ -35088,8 +35060,7 @@ "mongodb": "^4.11.0", "node-fetch": "^2.6.7", "p-limit": "^2.3.0", - "request": "^2.88.2", - "uuid": "^8.3.2" + "request": "^2.88.2" }, "devDependencies": { "chai": "^4.3.6", @@ -35225,14 +35196,6 @@ "node": ">=8" } }, - "services/third-party-datastore/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "services/third-party-datastore/node_modules/yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", @@ -44447,7 +44410,6 @@ "mocha": "^10.2.0", "mongodb": "^3.5.9", "node-fetch": "^2.6.7", - "node-uuid": "~1.4.8", "range-parser": "^1.2.1", "sandboxed-module": "2.0.4", "sinon": "9.0.2", @@ -44966,8 +44928,7 @@ "requestretry": "^1.12.2", "sinon": "~9.0.1", "sinon-chai": "^3.7.0", - "timekeeper": "2.2.0", - "uuid": "^9.0.0" + "timekeeper": "2.2.0" }, "dependencies": { "@hapi/address": { @@ -45322,11 +45283,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" - }, - "uuid": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", - "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==" } } }, @@ -45431,15 +45387,7 @@ "request": "^2.88.2", "sandboxed-module": "^2.0.4", "sinon": "^9.2.4", - "underscore": "^1.10.2", - "uuid": "^7.0.3" - }, - "dependencies": { - "uuid": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", - "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==" - } + "underscore": "^1.10.2" } }, "@overleaf/settings": { @@ -45707,8 +45655,7 @@ "sandboxed-module": "^2.0.4", "sinon": "9.0.1", "sinon-chai": "^3.7.0", - "sinon-stub-promise": "^4.0.0", - "uuid": "^8.3.2" + "sinon-stub-promise": "^4.0.0" }, "dependencies": { "bson": { @@ -45793,11 +45740,6 @@ "has-flag": "^4.0.0" } }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" - }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", @@ -61450,11 +61392,6 @@ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.1.tgz", "integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==" }, - "node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=" - }, "nodemailer": { "version": "6.7.2", "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.7.2.tgz", diff --git a/services/filestore/app/js/LocalFileWriter.js b/services/filestore/app/js/LocalFileWriter.js index 860c54c052..c5b8ea41f1 100644 --- a/services/filestore/app/js/LocalFileWriter.js +++ b/services/filestore/app/js/LocalFileWriter.js @@ -1,5 +1,5 @@ const fs = require('fs') -const uuid = require('node-uuid') +const crypto = require('crypto') const path = require('path') const Stream = require('stream') const { callbackify, promisify } = require('util') @@ -49,7 +49,7 @@ async function deleteFile(fsPath) { function _getPath(key) { if (key == null) { - key = uuid.v1() + key = crypto.randomUUID() } key = key.replace(/\//g, '-') return path.join(Settings.path.uploadFolder, key) diff --git a/services/filestore/package.json b/services/filestore/package.json index 9ec5da32f6..ec2b9e4b43 100644 --- a/services/filestore/package.json +++ b/services/filestore/package.json @@ -29,7 +29,6 @@ "glob": "^7.1.6", "lodash.once": "^4.1.1", "node-fetch": "^2.6.7", - "node-uuid": "~1.4.8", "range-parser": "^1.2.1", "stream-buffers": "~0.2.6", "tiny-async-pool": "^1.1.0" diff --git a/services/project-history/app/js/LargeFileManager.js b/services/project-history/app/js/LargeFileManager.js index 239057c640..b8a44f6d4d 100644 --- a/services/project-history/app/js/LargeFileManager.js +++ b/services/project-history/app/js/LargeFileManager.js @@ -10,7 +10,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import fs from 'fs' -import { v1 as uuid } from 'uuid' +import { randomUUID } from 'crypto' import Path from 'path' import logger from '@overleaf/logger' import OError from '@overleaf/o-error' @@ -27,7 +27,7 @@ export function createStub(fsPath, fileId, fileSize, fileHash, callback) { callback = _.once(callback) const newFsPath = Path.join( Settings.path.uploadFolder, - uuid() + `-${fileId}-stub` + randomUUID() + `-${fileId}-stub` ) const writeStream = fs.createWriteStream(newFsPath) writeStream.on('error', function (error) { diff --git a/services/project-history/app/js/LocalFileWriter.js b/services/project-history/app/js/LocalFileWriter.js index 9b82ef278a..a37c0905b0 100644 --- a/services/project-history/app/js/LocalFileWriter.js +++ b/services/project-history/app/js/LocalFileWriter.js @@ -10,7 +10,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import fs from 'fs' -import { v1 as uuid } from 'uuid' +import { randomUUID } from 'crypto' import path from 'path' import Url from 'url' import _ from 'lodash' @@ -42,7 +42,10 @@ export function bufferOnDisk(inStream, fileId, consumeOutStream, callback) { // capture the stream url for logging const url = inStream.uri && Url.format(inStream.uri) - const fsPath = path.join(Settings.path.uploadFolder, uuid() + `-${fileId}`) + const fsPath = path.join( + Settings.path.uploadFolder, + randomUUID() + `-${fileId}` + ) let cleaningUp = false const cleanup = _.once((streamError, res) => { diff --git a/services/project-history/package.json b/services/project-history/package.json index 1f73197784..baff71a8a2 100644 --- a/services/project-history/package.json +++ b/services/project-history/package.json @@ -42,8 +42,7 @@ "overleaf-editor-core": "*", "redis": "~0.10.1", "request": "^2.88.2", - "requestretry": "^1.12.2", - "uuid": "^9.0.0" + "requestretry": "^1.12.2" }, "devDependencies": { "chai": "^4.3.6", diff --git a/services/web/app/src/Features/Analytics/AnalyticsManager.js b/services/web/app/src/Features/Analytics/AnalyticsManager.js index 55c9340289..a09b40fe25 100644 --- a/services/web/app/src/Features/Analytics/AnalyticsManager.js +++ b/services/web/app/src/Features/Analytics/AnalyticsManager.js @@ -3,7 +3,7 @@ const UserAnalyticsIdCache = require('./UserAnalyticsIdCache') const Settings = require('@overleaf/settings') const Metrics = require('../../infrastructure/Metrics') const Queues = require('../../infrastructure/Queues') -const uuid = require('uuid') +const crypto = require('crypto') const _ = require('lodash') const { expressify } = require('../../util/promises') const { logger } = require('@overleaf/logger') @@ -288,7 +288,7 @@ async function analyticsIdMiddleware(req, res, next) { session.analyticsId = getAnalyticsIdFromMongoUser(sessionUser) } else if (!session.analyticsId) { // generate an `analyticsId` if needed - session.analyticsId = uuid.v4() + session.analyticsId = crypto.randomUUID() } next() diff --git a/services/web/app/src/Features/Templates/TemplatesManager.js b/services/web/app/src/Features/Templates/TemplatesManager.js index 42fd9ead6a..b3361e438a 100644 --- a/services/web/app/src/Features/Templates/TemplatesManager.js +++ b/services/web/app/src/Features/Templates/TemplatesManager.js @@ -24,7 +24,7 @@ const logger = require('@overleaf/logger') const request = require('request') const fetch = require('node-fetch') const settings = require('@overleaf/settings') -const uuid = require('uuid') +const crypto = require('crypto') const Errors = require('../Errors/Errors') const _ = require('underscore') @@ -59,7 +59,7 @@ const TemplatesManager = { } const projectName = ProjectDetailsHandler.fixProjectName(templateName) - const dumpPath = `${settings.path.dumpFolder}/${uuid.v4()}` + const dumpPath = `${settings.path.dumpFolder}/${crypto.randomUUID()}` const writeStream = fs.createWriteStream(dumpPath) const attributes = { fromV1TemplateId: templateId, diff --git a/services/web/app/src/infrastructure/FileWriter.js b/services/web/app/src/infrastructure/FileWriter.js index 0f4b6f88e5..285ac9b0cd 100644 --- a/services/web/app/src/infrastructure/FileWriter.js +++ b/services/web/app/src/infrastructure/FileWriter.js @@ -13,7 +13,7 @@ const fs = require('fs') const OError = require('@overleaf/o-error') const logger = require('@overleaf/logger') -const uuid = require('uuid') +const crypto = require('crypto') const _ = require('underscore') const Settings = require('@overleaf/settings') const request = require('request') @@ -82,7 +82,9 @@ const FileWriter = { callback = function () {} } callback = _.once(callback) - const fsPath = `${Settings.path.dumpFolder}/${identifier}_${uuid.v4()}` + const fsPath = `${ + Settings.path.dumpFolder + }/${identifier}_${crypto.randomUUID()}` return FileWriter.ensureDumpFolderExists(function (error) { if (error != null) { return callback(error) @@ -106,7 +108,9 @@ const FileWriter = { } options = options || {} - const fsPath = `${Settings.path.dumpFolder}/${identifier}_${uuid.v4()}` + const fsPath = `${ + Settings.path.dumpFolder + }/${identifier}_${crypto.randomUUID()}` stream.pause() diff --git a/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js b/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js index 2cb9de8562..f15806e50a 100644 --- a/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js +++ b/services/web/test/unit/src/Analytics/AnalyticsManagerTests.js @@ -279,8 +279,8 @@ describe('AnalyticsManager', function () { }, }, './UserAnalyticsIdCache': {}, - uuid: { - v4: () => this.analyticsId, + crypto: { + randomUUID: () => this.analyticsId, }, }, }) diff --git a/services/web/test/unit/src/Templates/TemplatesManagerTests.js b/services/web/test/unit/src/Templates/TemplatesManagerTests.js index a35dd2232d..2823b3cfe1 100644 --- a/services/web/test/unit/src/Templates/TemplatesManagerTests.js +++ b/services/web/test/unit/src/Templates/TemplatesManagerTests.js @@ -88,8 +88,8 @@ describe('TemplatesManager', function () { host: this.v1Url, }, }, - uuid: { - v4: () => this.uuid, + crypto: { + randomUUID: () => this.uuid, }, request: this.request, fs: this.fs,