summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-08-11 06:28:54 -0700
committerGitHub <noreply@github.com>2024-08-11 18:58:54 +0530
commitb61fd622a5facc0ec29a8c3b04289ff5354ae03f (patch)
treeba6e5bf4c9e4fbb592f5dac719b22f2859ac5cbf /ext/node/polyfills/internal
parentd6f662ac8280511fb4ef0f81777a0a6c5c08c0fa (diff)
fix(ext/node): rewrite X509Certificate resource and add `publicKey()` (#24988)
**Changes**: - Remove unsafe usage, rewrite Rust representation with `yoke`. - Implement `X509Certificate.prototype.publicKey()` Fixes https://github.com/denoland/deno/issues/23307
Diffstat (limited to 'ext/node/polyfills/internal')
-rw-r--r--ext/node/polyfills/internal/crypto/x509.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/ext/node/polyfills/internal/crypto/x509.ts b/ext/node/polyfills/internal/crypto/x509.ts
index 50a7ab48d..699e45a51 100644
--- a/ext/node/polyfills/internal/crypto/x509.ts
+++ b/ext/node/polyfills/internal/crypto/x509.ts
@@ -17,9 +17,13 @@ import {
op_node_x509_get_valid_to,
op_node_x509_key_usage,
op_node_x509_parse,
+ op_node_x509_public_key,
} from "ext:core/ops";
-import { KeyObject } from "ext:deno_node/internal/crypto/keys.ts";
+import {
+ KeyObject,
+ PublicKeyObject,
+} from "ext:deno_node/internal/crypto/keys.ts";
import { Buffer } from "node:buffer";
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts";
@@ -144,10 +148,9 @@ export class X509Certificate {
return result;
}
- get publicKey(): KeyObject {
- notImplemented("crypto.X509Certificate.prototype.publicKey");
-
- return {} as KeyObject;
+ get publicKey(): PublicKeyObject {
+ const handle = op_node_x509_public_key(this.#handle);
+ return new PublicKeyObject(handle);
}
get raw(): Buffer {