Skip to content

Commit

Permalink
chore(uuid): deprecate uuid package in favor of node:crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
gratcliff committed Jul 26, 2024
1 parent 472d391 commit f320d93
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
11 changes: 2 additions & 9 deletions package-lock.json

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

4 changes: 1 addition & 3 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"oas": "^20.10.2",
"ssri": "^10.0.1",
"timeout-signal": "^1.1.0",
"type-is": "^1.6.18",
"uuid": "^9.0.0"
"type-is": "^1.6.18"
},
"devDependencies": {
"@readme/eslint-config": "^14.0.0",
Expand All @@ -52,7 +51,6 @@
"@types/ssri": "^7.1.1",
"@types/supertest": "^2.0.12",
"@types/type-is": "^1.6.3",
"@types/uuid": "^9.0.2",
"@vitest/coverage-v8": "^0.34.2",
"caseless": "^0.12.0",
"eslint": "^8.34.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/lib/construct-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { UUID } from 'node:crypto';
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { TLSSocket } from 'tls';

import { randomUUID } from 'node:crypto';
import os from 'os';
import { URL } from 'url';

import ssri from 'ssri';
import { v4 as uuidv4 } from 'uuid';

import { version } from '../../package.json';

Expand Down Expand Up @@ -142,7 +142,7 @@ export function constructPayload(
const serverTime = payloadData.responseEndDateTime.getTime() - payloadData.startedDateTime.getTime();

return {
_id: payloadData.logId || (uuidv4() as UUID),
_id: payloadData.logId || randomUUID(),
_version: 3,
group: {
id: mask(payloadData.apiKey),
Expand Down
5 changes: 2 additions & 3 deletions packages/node/src/lib/log.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { LogOptions } from './construct-payload';
import type { GroupingObject, OutgoingLogBody } from './metrics-log';
import type { UUID } from 'node:crypto';
import type { IncomingMessage, ServerResponse } from 'node:http';

import { randomUUID } from 'node:crypto';
import * as url from 'url';

import clamp from 'lodash/clamp';
import { v4 as uuidv4 } from 'uuid';

import config from '../config';

Expand Down Expand Up @@ -108,7 +107,7 @@ export function log(
const bufferLength = clamp(options.bufferLength || config.bufferLength, 1, 30);

const startedDateTime = new Date();
const logId = uuidv4() as UUID;
const logId = randomUUID();

// baseLogUrl can be provided, but if it isn't then we
// attempt to fetch it from the ReadMe API
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/lib/metrics-log.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Options } from './log';
import type { UUID } from 'crypto';
import type { Har } from 'har-format';
import type { Response } from 'node-fetch';
import type { UUID } from 'node:crypto';

import fetch from 'node-fetch';
import timeoutSignal from 'timeout-signal';
Expand Down

0 comments on commit f320d93

Please sign in to comment.