Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Squash] nits
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
jasnell and aduh95 authored Dec 21, 2021
commit 195d391c1ff746e2d048b3d49e742abdab2998d5
13 changes: 7 additions & 6 deletions lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ const Certificate = require('internal/crypto/certificate');

let webcrypto;
function lazyWebCrypto() {
if (webcrypto === undefined) {
webcrypto = require('internal/crypto/webcrypto');
}
webcrypto ??= require('internal/crypto/webcrypto');
return webcrypto;
}

Expand Down Expand Up @@ -291,19 +289,22 @@ ObjectDefineProperties(module.exports, {
webcrypto: {
configurable: false,
enumerable: true,
get() { return lazyWebCrypto().crypto; }
get() { return lazyWebCrypto().crypto; },
set: undefined,
},

subtle: {
configurable: false,
enumerable: true,
get() { return lazyWebCrypto().crypto.subtle; }
get() { return lazyWebCrypto().crypto.subtle; },
set: undefined,
},

getRandomValues: {
configurable: false,
enumerable: true,
get() { return lazyWebCrypto().crypto.getRandomValues; }
get() { return lazyWebCrypto().crypto.getRandomValues; },
set: undefined,
},

// Aliases for randomBytes are deprecated.
Expand Down