-
-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isObject helper fails in jest #178
Comments
Hi @maurolucc, I am unable to reproduce your issue. Can you provide more details? const crypto = require('crypto');
const { fromKeyLike } = require('jose/jwk/from_key_like');
const { parseJwk } = require('jose/jwk/parse');
const key = crypto.generateKeyPairSync("ec", {
namedCurve: "secp256k1",
});
(async () => {
const privateJwk = await fromKeyLike(key.privateKey);
console.log(privateJwk.constructor)
const privateKey = await parseJwk(privateJwk, "ES256K");
console.log('works');
})();
|
Excuse me, I forgot to mention I'm using Typescript v4.2.4. Let me add it in the environment information. |
I would need the actual steps and project to reproduce then, from the top of my head i don't see how TS is relevant to this issue. As is, i'm not able to reproduce. Can you create a gist with the necessary source, configuration files, and a readme to reproduce? |
@maurolucc that is of no help unfortunately. I have no clue what the package.json looks like, how you execute this, nor what the typescript configuration is. I'm looking for a reproduction, e.g. such as that i can clone the gist, run |
Alright. I've updated the gist I shared with you. Now you should be able to clone it and run:
You'll see that the test fails for this node version but not for older. Notice that to make this test pass in my project I fix it with the trick found in
|
Thank you for the reproduction steps, very helpful! Well, apparently under jest the global.Object comparison with constructor fails, eventho they both log as I'll update the isObject helper in to account for different domains when i have the time, unless you feel like opening a PR and researching a better way. Or possibly just making sure typeof is |
@panva Awesome! You fix it already. Good job. Thanks. 😄 |
Describe the bug
fromKeyLike
does not return an object (JWK). If you use the output of this function in the latest version of node you get the following error:TypeError: JWK must be an object
To Reproduce
Use Node v15.14.0.
Expected behaviour
Get proper object so as to be able to use JWK.
Environment:
jose
version: 3.11.4Additional context
If anyone faces the same issue, there are two tricks that can save you:
privateJwk
in the next function as input but{...privateJwk }
or
privateJwk
setjwk.constructor = Object;
The text was updated successfully, but these errors were encountered: