Closed rebyatyonok closed 3 months ago
Hello! I run the following code with node/bun
#!/usr/bin/node /* eslint no-console: off */ import { existsSync } from 'node:fs' import { exportPEMKey, generateKeyPair } from '@cross/jwt' const paths = { private: process.env.PRIVATE_KEY_PATH, public: process.env.PUBLIC_KEY_PATH } ;(async () => { const isPrivateExists = existsSync(paths.private) const isPublicExists = existsSync(paths.public) if (isPrivateExists && isPublicExists) { console.log('Keys already exist. Skipping') } else { const { privateKey, publicKey } = await generateKeyPair('PS512') exportPEMKey(privateKey, paths.private).then(() => { console.log('Private key generated') }) exportPEMKey(publicKey, paths.public).then(() => { console.log('Public key generated') }) } })()
and receive an error which is kinda makes sense
ReferenceError: window is not defined at exportPEMKey (file:///<skipped>/node_modules/@cross/jwt/src/cryptokeys.js:102:23) at file:///<skipped>/scripts/generate-keys.js:21:3
Node version: v22.2.0 Bun version: 1.1.13
Will you accept a PR to fix that?
Yes, will gladly look at and accept a PR. :)
@rebyatyonok version 0.4.9 got a fix using the global crypto object.
@Pinta365 Sorry, didn't have time to submit a PR. Thanks a lot!
Hello! I run the following code with node/bun
and receive an error which is kinda makes sense
Node version: v22.2.0 Bun version: 1.1.13
Will you accept a PR to fix that?