Skip to content

Commit

Permalink
fix(deps): Replaced uuid dependency with crypto.randomUUID
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Oct 28, 2024
1 parent 2a1b34a commit d462b5a
Show file tree
Hide file tree
Showing 7 changed files with 1,442 additions and 1,364 deletions.
2 changes: 1 addition & 1 deletion lib/acme/acme-challenge.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { normalizeDomain } = require('../tools');
const { v4: uuid } = require('uuid');
const { randomUUID: uuid } = require('crypto');

// Unfinished challenges are deleted after this amount of time
const DEFAULT_TTL = 2 * 3600 * 1000; // milliseconds
Expand Down
6 changes: 3 additions & 3 deletions lib/api/asps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = require('wild-config');
const Joi = require('joi');
const ObjectId = require('mongodb').ObjectId;
const mobileconfig = require('mobileconfig');
const uuid = require('uuid');
const { randomUUID: uuid } = require('crypto');
const consts = require('../consts');
const certs = require('../certs').get('api.mobileconfig');
const tools = require('../tools');
Expand Down Expand Up @@ -515,7 +515,7 @@ module.exports = (db, server, userHandler) => {
PayloadType: 'Configuration',
PayloadVersion: 1,
PayloadIdentifier: profileOpts.identifier + '.' + userData._id,
PayloadUUID: uuid.v4(),
PayloadUUID: uuid(),
PayloadDisplayName: description || profileOpts.displayName,
PayloadDescription: profileOpts.displayDescription,
PayloadOrganization: profileOpts.organization || 'WildDuck Mail Server',
Expand All @@ -525,7 +525,7 @@ module.exports = (db, server, userHandler) => {
PayloadType: 'com.apple.mail.managed',
PayloadVersion: 1,
PayloadIdentifier: profileOpts.identifier + '.' + userData._id,
PayloadUUID: uuid.v4(),
PayloadUUID: uuid(),
PayloadDisplayName: 'Email Account',
PayloadDescription: 'Configures email account',
PayloadOrganization: profileOpts.organization || 'WildDuck Mail Server',
Expand Down
4 changes: 2 additions & 2 deletions lib/data-url.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const os = require('os');
const uuid = require('uuid');
const { randomUUID: uuid } = require('crypto');
const HTMLParser = require('node-html-parser');

function processDataUrl(element, useBase64) {
Expand Down Expand Up @@ -54,7 +54,7 @@ function preprocessHtml(html, hostname) {
attachment.filename = filename;
img.removeAttribute('data-filename');
}
attachment.cid = `${uuid.v4()}@${hostname ? hostname : 'inline'}`;
attachment.cid = `${uuid()}@${hostname ? hostname : 'inline'}`;
img.setAttribute('src', `cid:${attachment.cid}`);

attachments.push(attachment);
Expand Down
4 changes: 2 additions & 2 deletions lib/maildropper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const RelaxedBody = require('nodemailer/lib/dkim/relaxed-body');
const MessageSplitter = require('./message-splitter');
const seqIndex = new SeqIndex();
const GridFSBucket = require('mongodb').GridFSBucket;
const uuid = require('uuid');
const { randomUUID: uuid } = require('crypto');
const os = require('os');
const hostname = os.hostname().toLowerCase();
const addressparser = require('nodemailer/lib/addressparser');
Expand Down Expand Up @@ -441,7 +441,7 @@ class Maildropper {
// Check Message-ID: value. Add if missing
let mId = envelope.headers.getFirst('message-id');
if (!mId) {
mId = '<' + uuid.v4() + '@' + (envelope.from.substr(envelope.from.lastIndexOf('@') + 1) || hostname) + '>';
mId = '<' + uuid() + '@' + (envelope.from.substr(envelope.from.lastIndexOf('@') + 1) || hostname) + '>';

envelope.headers.remove('message-id'); // in case there's an empty value
envelope.headers.add('Message-ID', mId);
Expand Down
4 changes: 2 additions & 2 deletions lib/message-handler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const crypto = require('crypto');
const { v1: uuidV1 } = require('uuid');
const { randomUUID: uuid } = require('crypto');
const ObjectId = require('mongodb').ObjectId;
const Indexer = require('../imap-core/lib/indexer/indexer');
const ImapNotifier = require('./imap-notifier');
Expand Down Expand Up @@ -1348,7 +1348,7 @@ class MessageHandler {
hdate = idate;
}

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

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

Expand Down
Loading

0 comments on commit d462b5a

Please sign in to comment.