Skip to content

Commit

Permalink
chore: remove unused npm dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Jakob Linskeseder <[email protected]>
  • Loading branch information
jaylinski committed Feb 1, 2025
1 parent f86b092 commit ca29a87
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 47 deletions.
41 changes: 0 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.0",
"@nextcloud/cdav-library": "1.5.2",
Expand All @@ -43,14 +42,11 @@
"color-convert": "^2.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.0.5",
"vue": "^3.5.13",
"vue-material-design-icons": "^5.3.1",
"vue-router": "^4.5.0",
Expand Down
4 changes: 2 additions & 2 deletions src/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions src/utils/crypto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Nextcloud - Tasks
*
* @copyright Copyright (c) 2019 Georg Ehrke
*
* @author Georg Ehrke <[email protected]>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

/**
* 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('')
}

0 comments on commit ca29a87

Please sign in to comment.