Skip to content

CryptoKey string tag imprecise for detection #45987

Closed
@brettz9

Description

@brettz9

Version

v18.12.1

Platform

Darwin MacBook-Air-2.local 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:04:44 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8103 arm64

Subsystem

No response

What steps will reproduce the bug?

import {webcrypto as crypto} from 'node:crypto';
const key = await crypto.subtle.generateKey(
  {
    name: 'HMAC',
    hash: {name: 'SHA-512'}
  },
  true, // Extractable
  ['sign', 'verify']
);
const stringTag = Object.prototype.toString.call(key).slice(8, -1);
console.log(stringTag);

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

On the browser, this logs CryptoKey and allows for detection of object type and we expect it here.

What do you see instead?

Object

Additional information

This can be readily remedied by adding Symbol.toStringTag to the CryptoKey class returning the value, "CryptoKey".

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.webcrypto

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions