diff --git a/infrastructure/eid-wallet/src/lib/utils/capitalize.ts b/infrastructure/eid-wallet/src/lib/utils/capitalize.ts index 33c77ed5..f5c2510c 100644 --- a/infrastructure/eid-wallet/src/lib/utils/capitalize.ts +++ b/infrastructure/eid-wallet/src/lib/utils/capitalize.ts @@ -1,3 +1,9 @@ +/** + * Returns a new string with the first letter of each word in uppercase and the remaining letters in lowercase. + * + * @param str - The input string to capitalize. + * @returns The capitalized string. + */ export function capitalize(str: string) { return str .toLowerCase() diff --git a/infrastructure/evault-provisioner/src/utils/hmac.ts b/infrastructure/evault-provisioner/src/utils/hmac.ts index 29790b4d..2091f7f2 100644 --- a/infrastructure/evault-provisioner/src/utils/hmac.ts +++ b/infrastructure/evault-provisioner/src/utils/hmac.ts @@ -1,11 +1,26 @@ import { createHmac } from "crypto"; +/** + * Generates an HMAC SHA-256 signature for a JSON-serializable object using the provided secret key. + * + * @param body - The object to be signed. + * @param secret - The secret key used for HMAC generation. + * @returns The hexadecimal string representation of the HMAC signature. + */ export function createHmacSignature(body: Record, secret: string) { return createHmac("sha256", secret) .update(JSON.stringify(body)) .digest("hex"); } +/** + * Verifies that a provided HMAC signature matches the expected signature for a given object and secret key. + * + * @param body - The object whose signature is to be verified. + * @param signature - The HMAC signature to compare against. + * @param secret - The secret key used to generate the expected signature. + * @returns `true` if the signature is valid; otherwise, `false`. + */ export function verifyHmacSignature( body: Record, signature: string,