

import { JsonEncoder } from "../../../../utils/JsonEncoder.mjs";
import "../../../../utils/index.mjs";
import { PublicJwk } from "../../../kms/jwk/PublicJwk.mjs";
import "../../../kms/index.mjs";
import { parseDid } from "../../domain/parse.mjs";
import { getDidJwkDocument } from "./didJwkDidDocument.mjs";

//#region src/modules/dids/methods/jwk/DidJwk.ts
var DidJwk = class DidJwk {
	constructor(did, publicJwk) {
		this.did = did;
		this.publicJwk = publicJwk;
	}
	get allowsEncrypting() {
		return this.publicJwk.toJson().use === "enc" || this.publicJwk.supportdEncryptionKeyAgreementAlgorithms.length > 0;
	}
	get allowsSigning() {
		return this.publicJwk.toJson().use === "sig" || this.publicJwk.supportedSignatureAlgorithms.length > 0;
	}
	static fromDid(did) {
		const parsed = parseDid(did);
		const jwkJson = JsonEncoder.fromBase64(parsed.id);
		return new DidJwk(did, PublicJwk.fromUnknown(jwkJson));
	}
	/**
	* A did:jwk DID can only have one verification method, and the verification method
	* id will always be `<did>#0`.
	*/
	get verificationMethodId() {
		return `${this.did}#0`;
	}
	static fromPublicJwk(publicJwk) {
		return new DidJwk(`did:jwk:${JsonEncoder.toBase64URL(publicJwk.toJson({ includeKid: false }))}`, publicJwk);
	}
	get jwkJson() {
		return this.publicJwk.toJson();
	}
	get didDocument() {
		return getDidJwkDocument(this);
	}
};

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