Skip to content

Commit

Permalink
Use crypto.randomUUID()
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 8, 2022
1 parent 9171b14 commit d5d0c54
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/history/merge/id.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { v4 as uuidv4, validate as isUuid } from 'uuid'
import { randomUUID } from 'crypto'

import { validate as isUuid } from 'uuid'

// Validate `merge` property
export const validateMerge = function (value) {
Expand Down Expand Up @@ -28,7 +30,7 @@ export const normalizeId = function (newResult, history) {
const LAST_ID = 'last'

export const getDefaultId = function () {
return uuidv4()
return randomUUID()
}

// We only keep the first characters of the `result.id` in the filename.
Expand All @@ -48,7 +50,7 @@ const ID_LENGTH = 12
// history results filenames are unique even when their `id` and `timestamp`
// are the same (which is fairly unlikely).
export const createSubId = function () {
return getUuidFirstChars(uuidv4(), SUBID_LENGTH)
return getUuidFirstChars(randomUUID(), SUBID_LENGTH)
}

// This must be low enough to keep filenames short, but high enough to prevent
Expand Down

0 comments on commit d5d0c54

Please sign in to comment.