This repository has been archived on 2023-04-04. You can view files and clone it, but cannot push or open issues or pull requests.
webcrypto/packages/core/src/utils/is_jwk.ts

12 lines
369 B
TypeScript

import * as types from "@peculiar/webcrypto-types";
export function isJWK(data: unknown): data is types.JsonWebKey {
return !!(data && typeof data === "object" && "kty" in data);
}
export function assertJWK(data: unknown, paramName: string): asserts data is types.JsonWebKey {
if (!isJWK(data)) {
throw new TypeError(`${paramName}: is not JsonWebKey`);
}
}