diff --git a/package.json b/package.json index 028ffa883..0d554d23e 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "bugs": "https://github.com/nextcloud/tasks/issues", "contributors": [], "dependencies": { - "@nextcloud/auth": "^2.4.0", "@nextcloud/axios": "^2.5.1", "@nextcloud/calendar-js": "8.1.1", "@nextcloud/cdav-library": "1.5.3", @@ -43,14 +42,11 @@ "color-convert": "^3.0.1", "debounce": "^2.2.0", "ical.js": "^2.1.0", - "linkify-it": "^5.0.0", "markdown-it": "^14.1.0", "markdown-it-emoji": "^3.0.0", "markdown-it-link-attributes": "^4.0.1", "markdown-it-task-lists": "^2.1.1", - "p-limit": "^6.2.0", "sortablejs-vue3": "^1.2.11", - "uuid": "^11.1.0", "vue": "^3.5.13", "vue-material-design-icons": "^5.3.1", "vue-router": "^4.5.0", diff --git a/src/models/task.js b/src/models/task.js index 5bdd1821d..dedbc0667 100644 --- a/src/models/task.js +++ b/src/models/task.js @@ -26,8 +26,8 @@ import moment from '@nextcloud/moment' -import { v4 as uuid } from 'uuid' import ICAL from 'ical.js' +import { randomUUID } from '../utils/crypto.js' export default class Task { @@ -83,7 +83,7 @@ export default class Task { if (!this.vtodo.hasProperty('uid')) { console.debug('This task did not have a proper uid. Setting a new one for ', this) - this.vtodo.addPropertyWithValue('uid', uuid()) + this.vtodo.addPropertyWithValue('uid', randomUUID()) } // Define components diff --git a/src/utils/crypto.js b/src/utils/crypto.js new file mode 100644 index 000000000..f5e72737e --- /dev/null +++ b/src/utils/crypto.js @@ -0,0 +1,58 @@ +/** + * Nextcloud - Tasks + * + * @copyright Copyright (c) 2019 Georg Ehrke + * + * @author Georg Ehrke + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +/** + * Generates a random UUID v4. + * + * @return {string} + */ +export function randomUUID() { + if (crypto?.randomUUID) { + // Only available in secure contexts + return crypto.randomUUID() + } + + return insecureUuidV4() +} + +/** + * Generates a random UUID v4 from a weak, non-cryptographic random number generator. + * Please use randomUUID() instead. + * + * Adapted from https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d + * Copyright 2018 Spencer Wood + * + * @return {string} + */ +function insecureUuidV4() { + const uuid = new Array(36) + for (let i = 0; i < 36; i++) { + uuid[i] = Math.floor(Math.random() * 16) + } + uuid[14] = 4 // set bits 12-15 of time-high-and-version to 0100 + uuid[19] = uuid[19] &= ~(1 << 2) // set bit 6 of clock-seq-and-reserved to zero + uuid[19] = uuid[19] |= (1 << 3) // set bit 7 of clock-seq-and-reserved to one + uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-' + return uuid.map((x) => x.toString(16)).join('') +}