

const require_CredoError = require('../../../../error/CredoError.js');
require('../../../../error/index.js');
const require_PublicJwk = require('../../../kms/jwk/PublicJwk.js');
require('../../../kms/index.js');

//#region src/modules/dids/domain/verificationMethod/JsonWebKey2020.ts
const VERIFICATION_METHOD_TYPE_JSON_WEB_KEY_2020 = "JsonWebKey2020";
/**
* Get a JsonWebKey2020 verification method.
*/
function getJsonWebKey2020(options) {
	return {
		id: options.verificationMethodId ?? `${options.did}#${options.publicJwk.fingerprint}`,
		type: VERIFICATION_METHOD_TYPE_JSON_WEB_KEY_2020,
		controller: options.did,
		publicKeyJwk: options.publicJwk.toJson()
	};
}
/**
* Check whether a verification method is a JsonWebKey2020 verification method.
*/
function isJsonWebKey2020(verificationMethod) {
	return verificationMethod.type === VERIFICATION_METHOD_TYPE_JSON_WEB_KEY_2020;
}
/**
* Get a key from a JsonWebKey2020 verification method.
*/
function getPublicJwkFromJsonWebKey2020(verificationMethod) {
	if (!verificationMethod.publicKeyJwk) throw new require_CredoError.CredoError(`Missing publicKeyJwk on verification method with type ${VERIFICATION_METHOD_TYPE_JSON_WEB_KEY_2020}`);
	return require_PublicJwk.PublicJwk.fromUnknown(verificationMethod.publicKeyJwk);
}

//#endregion
exports.VERIFICATION_METHOD_TYPE_JSON_WEB_KEY_2020 = VERIFICATION_METHOD_TYPE_JSON_WEB_KEY_2020;
exports.getJsonWebKey2020 = getJsonWebKey2020;
exports.getPublicJwkFromJsonWebKey2020 = getPublicJwkFromJsonWebKey2020;
exports.isJsonWebKey2020 = isJsonWebKey2020;