We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 876b853 commit 901cd90Copy full SHA for 901cd90
src/lib/is_key_like.ts
@@ -6,9 +6,15 @@ export function assertCryptoKey(key: unknown): asserts key is types.CryptoKey {
6
}
7
8
9
-export const isCryptoKey = (key: unknown): key is types.CryptoKey =>
+export const isCryptoKey = (key: unknown): key is types.CryptoKey => {
10
// @ts-ignore
11
- key?.[Symbol.toStringTag] === 'CryptoKey'
+ if (key?.[Symbol.toStringTag] === 'CryptoKey') return true
12
+ try {
13
+ return key instanceof CryptoKey
14
+ } catch {
15
+ return false
16
+ }
17
+}
18
19
export const isKeyObject = <T extends types.KeyObject = types.KeyObject>(key: unknown): key is T =>
20
0 commit comments