

const require_CredoError = require('../../../../error/CredoError.js');
require('../../../../error/index.js');
const require_constants = require('../../../vc/constants.js');
const require_JsonWebKey2020 = require('../../domain/verificationMethod/JsonWebKey2020.js');
const require_DidDocumentBuilder = require('../../domain/DidDocumentBuilder.js');
require('../../domain/index.js');

//#region src/modules/dids/methods/jwk/didJwkDidDocument.ts
function getDidJwkDocument(didJwk) {
	if (!didJwk.allowsEncrypting && !didJwk.allowsSigning) throw new require_CredoError.CredoError("At least one of allowsSigning or allowsEncrypting must be enabled");
	const verificationMethod = require_JsonWebKey2020.getJsonWebKey2020({
		did: didJwk.did,
		publicJwk: didJwk.publicJwk,
		verificationMethodId: didJwk.verificationMethodId
	});
	const didDocumentBuilder = new require_DidDocumentBuilder.DidDocumentBuilder(didJwk.did).addContext(require_constants.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
exports.getDidJwkDocument = getDidJwkDocument;