UNPKG

@credo-ts/core

Version:

<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1

47 lines (43 loc) • 1.44 kB
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.supportedEncryptionKeyAgreementAlgorithms.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.fromBase64Url(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