Skip to content

Commit 901cd90

Browse files
committed
refactor: fallback to checking instanceof for CryptoKey
Closes #765 Closes #803 Closes #821 Closes #827 Closes #828
1 parent 876b853 commit 901cd90

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lib/is_key_like.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ export function assertCryptoKey(key: unknown): asserts key is types.CryptoKey {
66
}
77
}
88

9-
export const isCryptoKey = (key: unknown): key is types.CryptoKey =>
9+
export const isCryptoKey = (key: unknown): key is types.CryptoKey => {
1010
// @ts-ignore
11-
key?.[Symbol.toStringTag] === 'CryptoKey'
11+
if (key?.[Symbol.toStringTag] === 'CryptoKey') return true
12+
try {
13+
return key instanceof CryptoKey
14+
} catch {
15+
return false
16+
}
17+
}
1218

1319
export const isKeyObject = <T extends types.KeyObject = types.KeyObject>(key: unknown): key is T =>
1420
// @ts-ignore

0 commit comments

Comments
 (0)