Skip to content

fix(crypto): Treat undefined JWK members as absent, not "undefined" - #333

Merged
andreiltd merged 4 commits into
bytecodealliance:mainfrom
VirtualTim:jwk-undefined-members
Oct 22, 2026
Merged

andreiltd merged 4 commits into
bytecodealliance:mainfrom
VirtualTim:jwk-undefined-members

Conversation

@VirtualTim

@VirtualTim VirtualTim commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

See: https://webidl.spec.whatwg.org/#js-dictionary
The spec says:

Let jsMemberValue be ? Get(jsDict, key).

Which will return undefined for a absent key.
Following this, the spec mentions "if jsMemberValue is undefined but member has a default value [...]", then "Otherwise, if jsMemberValue is undefined and member is required [...]".

So for non-default, non-required keys, undefined members should be abscent.

There are 10 tests in okp_importKey_failures_Ed25519.https.any.js that test this.

I did not add a unit test for this, as this should be caught by okp_importKey_failures_Ed25519.https.any.js.

+10 passing test cases:

  • +2 "Import from a non-extractable"
  • +2 "Invalid 'use' field"
  • +2 "Invalid 'crv' field"
  • +4 "Invalid 'alg' field"

@VirtualTim VirtualTim changed the title fix(crypt): Treat undefined JWK members as absent, not "undefined" fix(crypto): Treat undefined JWK members as absent, not "undefined" Oct 20, 2026

@andreiltd andreiltd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@andreiltd
andreiltd merged commit 7dc6aa9 into bytecodealliance:main Oct 22, 2026
7 checks passed
@VirtualTim
VirtualTim deleted the jwk-undefined-members branch October 22, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants