awslabs / aws-jwt-verify

JS library for verifying JWTs signed by Amazon Cognito, and any OIDC-compatible IDP that signs JWTs with RS256, RS384, and RS512
Apache License 2.0
606 stars 42 forks source link

Attempted import error: 'createPublicKey' is not exported from 'crypto' #32

Closed jnbooth closed 2 years ago

jnbooth commented 2 years ago

What are the steps to reproduce this issue?

1. yarn add aws-jwt-verify

2. import verify from 'aws-jwt-verify';

What happens?

Failed to compile.

./node_modules/aws-jwt-verify/dist/esm/jwt-rsa.js

Attempted import error: 'createPublicKey' is not exported from 'crypto' (imported as 'createPublicKey').

What versions of software are you using?

"node": 14

"aws-jwt-verify": 1.0.3, and also tried version 1.0.0

ottokruse commented 2 years ago

Can't explain the issue so far, since crypto.createPublicKey has been around since Node 11.6.0.

It should work on Node14 and in fact we run our unit and integration tests on Node14 and all okay.

You're also using TypeScript? Which version? Should be at least 4. Also use a sufficiently high version of @types/node otherwise TypeScript might not know about crypto.createPublicKey yet. (Not sure this matter, might matter if you TSC with skipLibCheck: false)

BTW I notice you're using a default import, which this library doesn't offer, so I would have expected this message:

import verify from 'aws-jwt-verify';
       ^^^^^^
SyntaxError: The requested module 'aws-jwt-verify' does not provide an export named 'default'

Maybe that's just your example, otherwise try this: import { JwtRsaVerifier, CognitoJwtVerifier } from 'aws-jwt-verify';

ottokruse commented 2 years ago

Hi @jnbooth, any update from your side?

leelalagudu commented 2 years ago

@jnbooth , following up on the above inquiry, could you update when you can please?

ottokruse commented 2 years ago

Closing because of inactivity, feel free to open a new issue