Skip to content

Commit d462b5a

Browse files
committed
fix(deps): Replaced uuid dependency with crypto.randomUUID
1 parent 2a1b34a commit d462b5a

7 files changed

+1442
-1364
lines changed

lib/acme/acme-challenge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const { normalizeDomain } = require('../tools');
4-
const { v4: uuid } = require('uuid');
4+
const { randomUUID: uuid } = require('crypto');
55

66
// Unfinished challenges are deleted after this amount of time
77
const DEFAULT_TTL = 2 * 3600 * 1000; // milliseconds

lib/api/asps.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const config = require('wild-config');
44
const Joi = require('joi');
55
const ObjectId = require('mongodb').ObjectId;
66
const mobileconfig = require('mobileconfig');
7-
const uuid = require('uuid');
7+
const { randomUUID: uuid } = require('crypto');
88
const consts = require('../consts');
99
const certs = require('../certs').get('api.mobileconfig');
1010
const tools = require('../tools');
@@ -515,7 +515,7 @@ module.exports = (db, server, userHandler) => {
515515
PayloadType: 'Configuration',
516516
PayloadVersion: 1,
517517
PayloadIdentifier: profileOpts.identifier + '.' + userData._id,
518-
PayloadUUID: uuid.v4(),
518+
PayloadUUID: uuid(),
519519
PayloadDisplayName: description || profileOpts.displayName,
520520
PayloadDescription: profileOpts.displayDescription,
521521
PayloadOrganization: profileOpts.organization || 'WildDuck Mail Server',
@@ -525,7 +525,7 @@ module.exports = (db, server, userHandler) => {
525525
PayloadType: 'com.apple.mail.managed',
526526
PayloadVersion: 1,
527527
PayloadIdentifier: profileOpts.identifier + '.' + userData._id,
528-
PayloadUUID: uuid.v4(),
528+
PayloadUUID: uuid(),
529529
PayloadDisplayName: 'Email Account',
530530
PayloadDescription: 'Configures email account',
531531
PayloadOrganization: profileOpts.organization || 'WildDuck Mail Server',

lib/data-url.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const os = require('os');
4-
const uuid = require('uuid');
4+
const { randomUUID: uuid } = require('crypto');
55
const HTMLParser = require('node-html-parser');
66

77
function processDataUrl(element, useBase64) {
@@ -54,7 +54,7 @@ function preprocessHtml(html, hostname) {
5454
attachment.filename = filename;
5555
img.removeAttribute('data-filename');
5656
}
57-
attachment.cid = `${uuid.v4()}@${hostname ? hostname : 'inline'}`;
57+
attachment.cid = `${uuid()}@${hostname ? hostname : 'inline'}`;
5858
img.setAttribute('src', `cid:${attachment.cid}`);
5959

6060
attachments.push(attachment);

lib/maildropper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const RelaxedBody = require('nodemailer/lib/dkim/relaxed-body');
55
const MessageSplitter = require('./message-splitter');
66
const seqIndex = new SeqIndex();
77
const GridFSBucket = require('mongodb').GridFSBucket;
8-
const uuid = require('uuid');
8+
const { randomUUID: uuid } = require('crypto');
99
const os = require('os');
1010
const hostname = os.hostname().toLowerCase();
1111
const addressparser = require('nodemailer/lib/addressparser');
@@ -441,7 +441,7 @@ class Maildropper {
441441
// Check Message-ID: value. Add if missing
442442
let mId = envelope.headers.getFirst('message-id');
443443
if (!mId) {
444-
mId = '<' + uuid.v4() + '@' + (envelope.from.substr(envelope.from.lastIndexOf('@') + 1) || hostname) + '>';
444+
mId = '<' + uuid() + '@' + (envelope.from.substr(envelope.from.lastIndexOf('@') + 1) || hostname) + '>';
445445

446446
envelope.headers.remove('message-id'); // in case there's an empty value
447447
envelope.headers.add('Message-ID', mId);

lib/message-handler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const crypto = require('crypto');
4-
const { v1: uuidV1 } = require('uuid');
4+
const { randomUUID: uuid } = require('crypto');
55
const ObjectId = require('mongodb').ObjectId;
66
const Indexer = require('../imap-core/lib/indexer/indexer');
77
const ImapNotifier = require('./imap-notifier');
@@ -1348,7 +1348,7 @@ class MessageHandler {
13481348
hdate = idate;
13491349
}
13501350

1351-
let msgid = envelope[9] || '<' + uuidV1() + '@wildduck.email>';
1351+
let msgid = envelope[9] || '<' + uuid() + '@wildduck.email>';
13521352

13531353
let headers = this.generateIndexedHeaders(mimeTree.header);
13541354

0 commit comments

Comments
 (0)