Skip to content

Commit 145edb3

Browse files
workers-devprodgithub-actions[bot]
authored andcommitted
Version Packages (#8540)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent b761a22 commit 145edb3

File tree

6 files changed

+39
-136
lines changed

6 files changed

+39
-136
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/unenv-preset": minor
3+
---
4+
5+
Use the native implementation of crypto APIs

.conflict-base-0/packages/unenv-preset/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"peerDependencies": {
5656
"unenv": "2.0.0-rc.15",
57-
"workerd": "^1.20250310.0"
57+
"workerd": "^1.20250311.0"
5858
},
5959
"peerDependenciesMeta": {
6060
"workerd": {

.conflict-base-0/packages/unenv-preset/src/runtime/node/crypto.ts

Lines changed: 30 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,67 @@
22
// so extract it separately from the other exports
33
import {
44
Cipher,
5-
Cipheriv,
65
constants,
76
createCipher,
8-
createCipheriv,
97
createDecipher,
10-
createDecipheriv,
11-
createECDH,
12-
createSign,
13-
createVerify,
148
Decipher,
15-
Decipheriv,
16-
diffieHellman,
17-
ECDH,
18-
getCipherInfo,
19-
hash,
20-
privateDecrypt,
21-
privateEncrypt,
229
pseudoRandomBytes,
23-
publicDecrypt,
24-
publicEncrypt,
25-
Sign,
26-
sign,
2710
webcrypto as unenvCryptoWebcrypto,
28-
Verify,
29-
verify,
3011
} from "unenv/node/crypto";
3112
import type nodeCrypto from "node:crypto";
3213

33-
export {
34-
Cipher,
35-
Cipheriv,
36-
Decipher,
37-
Decipheriv,
38-
ECDH,
39-
Sign,
40-
Verify,
41-
constants,
42-
createCipheriv,
43-
createDecipheriv,
44-
createECDH,
45-
createSign,
46-
createVerify,
47-
diffieHellman,
48-
getCipherInfo,
49-
hash,
50-
privateDecrypt,
51-
privateEncrypt,
52-
publicDecrypt,
53-
publicEncrypt,
54-
sign,
55-
verify,
56-
} from "unenv/node/crypto";
14+
export { Cipher, constants, Decipher } from "unenv/node/crypto";
5715

5816
const workerdCrypto = process.getBuiltinModule("node:crypto");
5917

60-
// TODO: Ideally this list is not hardcoded but instead is generated when the preset is being generated in the `env()` call
61-
// This generation should use information from https://github.com/cloudflare/workerd/issues/2097
6218
export const {
6319
Certificate,
64-
DiffieHellman,
65-
DiffieHellmanGroup,
66-
Hash,
67-
Hmac,
68-
KeyObject,
69-
X509Certificate,
7020
checkPrime,
7121
checkPrimeSync,
22+
Cipheriv,
23+
createCipheriv,
24+
createDecipheriv,
7225
createDiffieHellman,
7326
createDiffieHellmanGroup,
27+
createECDH,
7428
createHash,
7529
createHmac,
7630
createPrivateKey,
7731
createPublicKey,
7832
createSecretKey,
33+
createSign,
34+
createVerify,
35+
Decipheriv,
36+
diffieHellman,
37+
DiffieHellman,
38+
DiffieHellmanGroup,
39+
ECDH,
40+
fips,
7941
generateKey,
8042
generateKeyPair,
8143
generateKeyPairSync,
8244
generateKeySync,
8345
generatePrime,
8446
generatePrimeSync,
47+
getCipherInfo,
8548
getCiphers,
8649
getCurves,
8750
getDiffieHellman,
8851
getFips,
8952
getHashes,
53+
getRandomValues,
54+
hash,
55+
Hash,
9056
hkdf,
9157
hkdfSync,
58+
Hmac,
59+
KeyObject,
9260
pbkdf2,
9361
pbkdf2Sync,
62+
privateDecrypt,
63+
privateEncrypt,
64+
publicDecrypt,
65+
publicEncrypt,
9466
randomBytes,
9567
randomFill,
9668
randomFillSync,
@@ -101,27 +73,24 @@ export const {
10173
secureHeapUsed,
10274
setEngine,
10375
setFips,
76+
sign,
77+
Sign,
10478
subtle,
10579
timingSafeEqual,
80+
verify,
81+
Verify,
82+
X509Certificate,
10683
} = workerdCrypto;
10784

108-
// Special case getRandomValues as it must be bound to the webcrypto object
109-
export const getRandomValues = workerdCrypto.getRandomValues.bind(
110-
workerdCrypto.webcrypto
111-
);
112-
85+
// See https://github.com/cloudflare/workerd/issues/3751
11386
export const webcrypto = {
114-
// @ts-expect-error unenv has unknown type
87+
// @ts-expect-error
11588
CryptoKey: unenvCryptoWebcrypto.CryptoKey,
11689
getRandomValues,
11790
randomUUID,
11891
subtle,
11992
} satisfies typeof nodeCrypto.webcrypto;
12093

121-
// Node.js exposes fips only via the default export 🤷🏼‍♂️
122-
// so extract it separately from the other exports
123-
const fips = workerdCrypto.fips;
124-
12594
export default {
12695
/**
12796
* manually unroll unenv-polyfilled-symbols to make it tree-shakeable
@@ -137,35 +106,22 @@ export default {
137106
X509Certificate,
138107
// @ts-expect-error @types/node is out of date - this is a bug in typings
139108
constants,
140-
// @ts-expect-error unenv has unknown type
141109
createCipheriv,
142-
// @ts-expect-error unenv has unknown type
143110
createDecipheriv,
144-
// @ts-expect-error unenv has unknown type
145111
createECDH,
146-
// @ts-expect-error unenv has unknown type
147112
createSign,
148-
// @ts-expect-error unenv has unknown type
149113
createVerify,
150114
// @ts-expect-error unenv has unknown type
151115
diffieHellman,
152-
// @ts-expect-error unenv has unknown type
153116
getCipherInfo,
154-
// @ts-expect-error unenv has unknown type
155117
hash,
156-
// @ts-expect-error unenv has unknown type
157118
privateDecrypt,
158-
// @ts-expect-error unenv has unknown type
159119
privateEncrypt,
160-
// @ts-expect-error unenv has unknown type
161120
publicDecrypt,
162-
// @ts-expect-error unenv has unknown type
163121
publicEncrypt,
164122
scrypt,
165123
scryptSync,
166-
// @ts-expect-error unenv has unknown type
167124
sign,
168-
// @ts-expect-error unenv has unknown type
169125
verify,
170126

171127
// default-only export from unenv

.conflict-base-0/pnpm-lock.yaml

Lines changed: 2 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.conflict-side-0/packages/unenv-preset/src/runtime/node/crypto.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const {
8484
X509Certificate,
8585
} = workerdCrypto;
8686

87+
// See https://github.com/cloudflare/workerd/issues/3751
8788
// See https://github.com/cloudflare/workerd/issues/3751
8889
// See https://github.com/cloudflare/workerd/issues/3751
8990
export const webcrypto = {

.conflict-side-1/packages/unenv-preset/src/runtime/node/crypto.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export const {
8282
X509Certificate,
8383
} = workerdCrypto;
8484

85-
// See https://github.com/cloudflare/workerd/issues/3751
8685
export const webcrypto = {
8786
// @ts-expect-error
8887
CryptoKey: unenvCryptoWebcrypto.CryptoKey,

0 commit comments

Comments
 (0)