@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
91 lines (87 loc) • 2.54 kB
JavaScript
import { JsonTransformer } from "../../../utils/JsonTransformer.mjs";
import "../../../utils/index.mjs";
import { Jwt } from "../../../crypto/jose/jwt/Jwt.mjs";
import { ClaimFormat } from "../models/ClaimFormat.mjs";
import { getCredentialFromJwtPayload } from "./credentialTransformer.mjs";
//#region src/modules/vc/jwt-vc/W3cJwtVerifiableCredential.ts
var W3cJwtVerifiableCredential = class W3cJwtVerifiableCredential {
constructor(options) {
this.jwt = options.jwt;
this._credential = getCredentialFromJwtPayload(this.jwt.payload);
}
static fromSerializedJwt(serializedJwt) {
return new W3cJwtVerifiableCredential({ jwt: Jwt.fromSerializedJwt(serializedJwt) });
}
/**
* Get the W3cCredential 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 `W3cCredential` interface are implemented as getters
* on the `W3cJwtVerifiableCredential` class itself, so you can also use this directly
* instead of accessing the inner `credential` property.
*/
get credential() {
return this._credential;
}
get serializedJwt() {
return this.jwt.serializedJwt;
}
get context() {
return this.credential.context;
}
get id() {
return this.credential.id;
}
get type() {
return this.credential.type;
}
get issuer() {
return this.credential.issuer;
}
get issuanceDate() {
return this.credential.issuanceDate;
}
get expirationDate() {
return this.credential.expirationDate;
}
get credentialSubject() {
return this.credential.credentialSubject;
}
get credentialSchema() {
return this.credential.credentialSchema;
}
get credentialStatus() {
return this.credential.credentialStatus;
}
get issuerId() {
return this.credential.issuerId;
}
get credentialSchemaIds() {
return this.credential.credentialSchemaIds;
}
get credentialSubjectIds() {
return this.credential.credentialSubjectIds;
}
get contexts() {
return this.credential.contexts;
}
/**
* The {@link ClaimFormat} of the credential. For JWT credentials this is always `jwt_vc`.
*/
get claimFormat() {
return ClaimFormat.JwtVc;
}
/**
* Get the encoded variant of the W3C Verifiable Credential. For JWT credentials this is
* a JWT string.
*/
get encoded() {
return this.serializedJwt;
}
get jsonCredential() {
return JsonTransformer.toJSON(this.credential);
}
};
//#endregion
export { W3cJwtVerifiableCredential };
//# sourceMappingURL=W3cJwtVerifiableCredential.mjs.map