Skip to content

Feature Request: Safe/reliable crypto.KeyObject and webcrypto.CryptoKey detection in userland #38611

Closed
@mscdex

Description

@mscdex

Currently there are no public methods for checking for KeyObject and CryptoKey objects. Having reliable checks for these would be very nice to have for userland code that wants to support these types of objects in their code.

It seems there are already internal methods for achieving this, but I'm not sure why they are not currently exposed to userland. I was thinking maybe something like how Buffer handles this: KeyObject.isKeyObject() and CryptoKey.isCryptoKey(). The former is currently pretty easy to do in userland since it's just doing an instanceof check, but the latter checks "private" symbols, which is not as easy/ideal for userland (although I guess at least currently instanceof CryptoKey would work?). Either way, having these encapsulated in helper methods would help insulate changes to the checking logic, should it ever change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions