@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
66 lines (65 loc) • 2.12 kB
JavaScript
import { CredoError } from "../../../error/CredoError.mjs";
import "../../../error/index.mjs";
import { Jwt } from "../../../crypto/jose/jwt/Jwt.mjs";
import "../models/ClaimFormat.mjs";
import { getPresentationFromJwtPayload } from "./presentationTransformer.mjs";
//#region src/modules/vc/jwt-vc/W3cJwtVerifiablePresentation.ts
var W3cJwtVerifiablePresentation = class W3cJwtVerifiablePresentation {
constructor(options) {
this.jwt = options.jwt;
this._presentation = getPresentationFromJwtPayload(this.jwt.payload);
}
static fromSerializedJwt(serializedJwt) {
const jwt = Jwt.fromSerializedJwt(serializedJwt);
if (!jwt.payload.additionalClaims.nonce) throw new CredoError(`JWT payload does not contain required claim 'nonce'`);
return new W3cJwtVerifiablePresentation({ jwt });
}
/**
* Get the W3cPresentation from the JWT payload. This does not include the JWT wrapper,
* and thus is not suitable for sharing. If you need a JWT, use the `serializedJwt` property.
*
* All properties and getters from the `W3cPresentation` interface are implemented as getters
* on the `W3cJwtVerifiablePresentation` class itself, so you can also use this directly
* instead of accessing the inner `presentation` property.
*/
get presentation() {
return this._presentation;
}
get serializedJwt() {
return this.jwt.serializedJwt;
}
get context() {
return this.presentation.context;
}
get id() {
return this.presentation.id;
}
get type() {
return this.presentation.type;
}
get holder() {
return this.presentation.holder;
}
get verifiableCredential() {
return this.presentation.verifiableCredential;
}
get holderId() {
return this.presentation.holderId;
}
/**
* The {@link ClaimFormat} of the presentation. For JWT presentations this is always `jwt_vp`.
*/
get claimFormat() {
return "jwt_vp";
}
/**
* Get the encoded variant of the W3C Verifiable Presentation. For JWT presentations this is
* a JWT string.
*/
get encoded() {
return this.serializedJwt;
}
};
//#endregion
export { W3cJwtVerifiablePresentation };
//# sourceMappingURL=W3cJwtVerifiablePresentation.mjs.map