diff --git a/benchmarks/keys/generate-keys.js b/benchmarks/keys/generate-keys.js index 927f811..f3c244c 100755 --- a/benchmarks/keys/generate-keys.js +++ b/benchmarks/keys/generate-keys.js @@ -1,8 +1,8 @@ #!/usr/bin/env node -const { generateKeyPair } = require('crypto') -const { writeFileSync } = require('fs') -const { resolve } = require('path') +const { generateKeyPair } = require('node:crypto') +const { writeFileSync } = require('node:fs') +const { resolve } = require('node:path') const passProtectedKeyPassphrase = 'secret' const configurations = { diff --git a/benchmarks/keys/generate-tokens.js b/benchmarks/keys/generate-tokens.js index 726b180..3ea3e0e 100644 --- a/benchmarks/keys/generate-tokens.js +++ b/benchmarks/keys/generate-tokens.js @@ -1,7 +1,7 @@ 'use strict' -const { readFileSync } = require('fs') -const { resolve } = require('path') +const { readFileSync } = require('node:fs') +const { resolve } = require('node:path') const { createSigner } = require('../../src') diff --git a/src/crypto.js b/src/crypto.js index e45bf68..a9fd4ae 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -14,8 +14,8 @@ const { RSA_PSS_SALTLEN_MAX_SIGN, RSA_PSS_SALTLEN_AUTO } -} = require('crypto') -let { sign: directSign, verify: directVerify } = require('crypto') +} = require('node:crypto') +let { sign: directSign, verify: directVerify } = require('node:crypto') const { joseToDer, derToJose } = require('ecdsa-sig-formatter') const Cache = require('mnemonist/lru-cache') const { TokenError } = require('./error') diff --git a/src/signer.js b/src/signer.js index 96964ae..8151a36 100644 --- a/src/signer.js +++ b/src/signer.js @@ -13,7 +13,7 @@ const { } = require('./crypto') const { TokenError } = require('./error') const { getAsyncKey, ensurePromiseCallback } = require('./utils') -const { createPrivateKey, createSecretKey } = require('crypto') +const { createPrivateKey, createSecretKey } = require('node:crypto') const { parse: parseMs } = require('@lukeed/ms') const supportedAlgorithms = new Set([...hsAlgorithms, ...esAlgorithms, ...rsaAlgorithms, ...edAlgorithms, 'none']) diff --git a/src/utils.js b/src/utils.js index 9e87830..4f0ec42 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,6 +1,6 @@ 'use strict' -const { createHash } = require('crypto') +const { createHash } = require('node:crypto') const algorithmMatcher = /"alg"\s*:\s*"[HERP]S(256|384)"/m const edAlgorithmMatcher = /"alg"\s*:\s*"EdDSA"/m const ed448CurveMatcher = /"crv"\s*:\s*"Ed448"/m diff --git a/src/verifier.js b/src/verifier.js index 2f801b1..339615c 100644 --- a/src/verifier.js +++ b/src/verifier.js @@ -1,6 +1,6 @@ 'use strict' -const { createPublicKey, createSecretKey } = require('crypto') +const { createPublicKey, createSecretKey } = require('node:crypto') const Cache = require('mnemonist/lru-cache') const { useNewCrypto, hsAlgorithms, verifySignature, detectPublicKeyAlgorithms } = require('./crypto') diff --git a/test/compatibility.spec.js b/test/compatibility.spec.js index d42bb53..9c588ba 100644 --- a/test/compatibility.spec.js +++ b/test/compatibility.spec.js @@ -1,12 +1,12 @@ 'use strict' -const { readFileSync } = require('fs') +const { readFileSync } = require('node:fs') const { sign: jsonwebtokenSign, verify: jsonwebtokenVerify } = require('jsonwebtoken') const { JWT: { sign: joseSign, verify: joseVerify }, JWK: { asKey } } = require('jose') -const { resolve } = require('path') +const { resolve } = require('node:path') const { test } = require('tap') const { createSigner, createVerifier } = require('../src') diff --git a/test/crypto.spec.js b/test/crypto.spec.js index b34bb9b..3bdb7b0 100644 --- a/test/crypto.spec.js +++ b/test/crypto.spec.js @@ -1,8 +1,8 @@ 'use strict' const { test } = require('tap') -const { readFileSync } = require('fs') -const { resolve } = require('path') +const { readFileSync } = require('node:fs') +const { resolve } = require('node:path') const { createVerifier, createSigner } = require('../src') const { diff --git a/test/signer.spec.js b/test/signer.spec.js index 3978501..cc5e662 100644 --- a/test/signer.spec.js +++ b/test/signer.spec.js @@ -1,7 +1,7 @@ 'use strict' -const { readFileSync } = require('fs') -const { resolve } = require('path') +const { readFileSync } = require('node:fs') +const { resolve } = require('node:path') const { test } = require('tap') const { createSigner, createVerifier, TokenError, createDecoder } = require('../src') diff --git a/test/verifier.spec.js b/test/verifier.spec.js index 8bd8c65..fb47795 100644 --- a/test/verifier.spec.js +++ b/test/verifier.spec.js @@ -1,8 +1,8 @@ 'use strict' -const { createHash } = require('crypto') -const { readFileSync } = require('fs') -const { resolve } = require('path') +const { createHash } = require('node:crypto') +const { readFileSync } = require('node:fs') +const { resolve } = require('node:path') const { test } = require('tap') const { install: fakeTime } = require('@sinonjs/fake-timers')