Skip to content

Commit

Permalink
fix(ext/node): add Symbol.toStringTag to KeyObject instances (#24377)
Browse files Browse the repository at this point in the history
As per nodejs/node#46043, this adds
Symbol.toStringTag getter to KeyObject.
  • Loading branch information
panva committed Jul 1, 2024
1 parent 6f30ef8 commit 740c6a0
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 740c6a0

Please sign in to comment.