

import { CredoError } from "../../../../error/CredoError.mjs";
import "../../../../error/index.mjs";
import { getJsonWebKey2020 } from "../../domain/verificationMethod/JsonWebKey2020.mjs";
import { DidDocumentBuilder } from "../../domain/DidDocumentBuilder.mjs";
import "../../domain/index.mjs";
import { SECURITY_JWS_CONTEXT_URL } from "../../../vc/constants.mjs";

//#region src/modules/dids/methods/jwk/didJwkDidDocument.ts
function getDidJwkDocument(didJwk) {
	if (!didJwk.allowsEncrypting && !didJwk.allowsSigning) throw new CredoError("At least one of allowsSigning or allowsEncrypting must be enabled");
	const verificationMethod = getJsonWebKey2020({
		did: didJwk.did,
		publicJwk: didJwk.publicJwk,
		verificationMethodId: didJwk.verificationMethodId
	});
	const didDocumentBuilder = new DidDocumentBuilder(didJwk.did).addContext(SECURITY_JWS_CONTEXT_URL).addVerificationMethod(verificationMethod);
	if (didJwk.allowsSigning) didDocumentBuilder.addAuthentication(verificationMethod.id).addAssertionMethod(verificationMethod.id).addCapabilityDelegation(verificationMethod.id).addCapabilityInvocation(verificationMethod.id);
	if (didJwk.allowsEncrypting) didDocumentBuilder.addKeyAgreement(verificationMethod.id);
	return didDocumentBuilder.build();
}

//#endregion
export { getDidJwkDocument };
//# sourceMappingURL=didJwkDidDocument.mjs.map