Skip to content

Commit

Permalink
fix(ext/node): add Symbol.toStringTag to KeyObject instances (denolan…
Browse files Browse the repository at this point in the history
…d#24377)

As per nodejs/node#46043, this adds
Symbol.toStringTag getter to KeyObject.
  • Loading branch information
panva authored and sbmsr committed Jul 2, 2024
1 parent 77cd1f3 commit dfab1f7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ext/node/polyfills/internal/crypto/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials

import { primordials } from "ext:core/mod.js";

const {
ObjectDefineProperties,
SymbolToStringTag,
} = primordials;

import {
op_node_create_private_key,
op_node_create_public_key,
Expand Down Expand Up @@ -209,6 +216,14 @@ export class KeyObject {
}
}

ObjectDefineProperties(KeyObject.prototype, {
[SymbolToStringTag]: {
__proto__: null,
configurable: true,
value: "KeyObject",
},
});

export interface JsonWebKeyInput {
key: JsonWebKey;
format: "jwk";
Expand Down

0 comments on commit dfab1f7

Please sign in to comment.