

const require_Hasher = require('../../../crypto/hashes/Hasher.js');
const require_zod = require('../../../utils/zod.js');
const require_TypedArrayEncoder = require('../../../utils/TypedArrayEncoder.js');
require('../../../utils/index.js');
const require_knownJwk = require('./knownJwk.js');

//#region src/modules/kms/jwk/jwkThumbprint.ts
const zJwkThumbprintComponents = require_knownJwk.zKmsJwkPublic.transform((data) => {
	if (data.kty === "EC") return {
		crv: data.crv,
		kty: data.kty,
		x: data.x,
		y: data.y
	};
	if (data.kty === "OKP") return {
		crv: data.crv,
		kty: data.kty,
		x: data.x
	};
	if (data.kty === "RSA") return {
		e: data.e,
		kty: data.kty,
		n: data.n
	};
	if (data.kty === "oct") return {
		k: data.k,
		kty: data.kty
	};
	throw new Error("Unsupported kty");
});
function calculateJwkThumbprint(options) {
	const jwkThumbprintComponents = require_zod.zParseWithErrorHandling(zJwkThumbprintComponents, options.jwk, `Provided jwk does not match a supported jwk structure. Either the 'kty' is not supported, or required values are missing.`);
	return require_Hasher.Hasher.hash(require_TypedArrayEncoder.TypedArrayEncoder.fromString(JSON.stringify(jwkThumbprintComponents)), options.hashAlgorithm);
}

//#endregion
exports.calculateJwkThumbprint = calculateJwkThumbprint;