summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/crypto/_keys.ts
blob: 794582bf17b86be25a79c61931c76f244f21e60c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { kKeyObject } from "internal:deno_node/polyfills/internal/crypto/constants.ts";

export const kKeyType = Symbol("kKeyType");

export function isKeyObject(obj: unknown): boolean {
  return (
    obj != null && (obj as Record<symbol, unknown>)[kKeyType] !== undefined
  );
}

export function isCryptoKey(obj: unknown): boolean {
  return (
    obj != null && (obj as Record<symbol, unknown>)[kKeyObject] !== undefined
  );
}