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/src/mechs/hmac/key.ts

24 lines
685 B
TypeScript

import { JsonProp } from "@peculiar/json-schema";
import { JsonBase64UrlConverter } from "../../converters";
import { CryptoKey } from "../../keys";
export class HmacCryptoKey extends CryptoKey {
@JsonProp({ name: "k", converter: JsonBase64UrlConverter })
public override data!: Buffer;
public override algorithm!: HmacKeyAlgorithm;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
protected get alg() {
const hash = this.algorithm.hash.name.toUpperCase();
return `HS${hash.replace("SHA-", "")}`;
}
protected override set alg(value: string) {
// nothing, cause set is needed for json-schema, but is not used by module
}
}