

const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.js');
const require_Hasher = require('../../../crypto/hashes/Hasher.js');
const require_TypedArrayEncoder = require('../../../utils/TypedArrayEncoder.js');
require('../../../utils/index.js');
require('../../kms/index.js');
const require_keyAlgorithmConversion = require('../../../crypto/webcrypto/utils/keyAlgorithmConversion.js');
require('../../../crypto/webcrypto/utils/index.js');
let __peculiar_x509 = require("@peculiar/x509");
__peculiar_x509 = require_rolldown_runtime.__toESM(__peculiar_x509);

//#region src/modules/x509/utils/extensions.ts
const createSubjectKeyIdentifierExtension = (options, additionalOptions) => {
	if (!options || !options.include) return;
	const spki = require_keyAlgorithmConversion.publicJwkToSpki(additionalOptions.publicJwk);
	const hash = require_Hasher.Hasher.hash(new Uint8Array(spki.subjectPublicKey), "SHA-1");
	return new __peculiar_x509.SubjectKeyIdentifierExtension(require_TypedArrayEncoder.TypedArrayEncoder.toHex(hash));
};
const createKeyUsagesExtension = (options) => {
	if (!options) return;
	return new __peculiar_x509.KeyUsagesExtension(options.usages.reduce((prev, curr) => prev | curr, 0), options.markAsCritical);
};
const createExtendedKeyUsagesExtension = (options) => {
	if (!options) return;
	return new __peculiar_x509.ExtendedKeyUsageExtension(options.usages, options.markAsCritical);
};
const createAuthorityKeyIdentifierExtension = (options, additionalOptions) => {
	if (!options) return;
	const spki = require_keyAlgorithmConversion.publicJwkToSpki(additionalOptions.publicJwk);
	const hash = require_Hasher.Hasher.hash(new Uint8Array(spki.subjectPublicKey), "SHA-1");
	return new __peculiar_x509.AuthorityKeyIdentifierExtension(require_TypedArrayEncoder.TypedArrayEncoder.toHex(hash), options.markAsCritical);
};
const createIssuerAlternativeNameExtension = (options) => {
	if (!options) return;
	return new __peculiar_x509.IssuerAlternativeNameExtension(options.name, options.markAsCritical);
};
const createSubjectAlternativeNameExtension = (options) => {
	if (!options) return;
	return new __peculiar_x509.SubjectAlternativeNameExtension(options.name, options.markAsCritical);
};
const createBasicConstraintsExtension = (options) => {
	if (!options) return;
	return new __peculiar_x509.BasicConstraintsExtension(options.ca, options.pathLenConstraint, options.markAsCritical);
};
const createCrlDistributionPointsExtension = (options) => {
	if (!options) return;
	return new __peculiar_x509.CRLDistributionPointsExtension(options.urls, options.markAsCritical);
};

//#endregion
exports.createAuthorityKeyIdentifierExtension = createAuthorityKeyIdentifierExtension;
exports.createBasicConstraintsExtension = createBasicConstraintsExtension;
exports.createCrlDistributionPointsExtension = createCrlDistributionPointsExtension;
exports.createExtendedKeyUsagesExtension = createExtendedKeyUsagesExtension;
exports.createIssuerAlternativeNameExtension = createIssuerAlternativeNameExtension;
exports.createKeyUsagesExtension = createKeyUsagesExtension;
exports.createSubjectAlternativeNameExtension = createSubjectAlternativeNameExtension;
exports.createSubjectKeyIdentifierExtension = createSubjectKeyIdentifierExtension;