{"version":3,"file":"W3cJwtVerifiableCredential.mjs","names":[],"sources":["../../../../src/modules/vc/jwt-vc/W3cJwtVerifiableCredential.ts"],"sourcesContent":["import { Jwt } from '../../../crypto/jose/jwt/Jwt'\nimport { JsonTransformer } from '../../../utils'\nimport { ClaimFormat } from '../models/ClaimFormat'\nimport type { W3cCredential } from '../models/credential/W3cCredential'\nimport type { W3cJsonCredential } from '../models/credential/W3cJsonCredential'\n\nimport { getCredentialFromJwtPayload } from './credentialTransformer'\n\nexport interface W3cJwtVerifiableCredentialOptions {\n  jwt: Jwt\n}\n\nexport class W3cJwtVerifiableCredential {\n  public readonly jwt: Jwt\n  private _credential: W3cCredential\n\n  public constructor(options: W3cJwtVerifiableCredentialOptions) {\n    this.jwt = options.jwt\n\n    this._credential = getCredentialFromJwtPayload(this.jwt.payload)\n  }\n\n  public static fromSerializedJwt(serializedJwt: string) {\n    const jwt = Jwt.fromSerializedJwt(serializedJwt)\n\n    return new W3cJwtVerifiableCredential({\n      jwt,\n    })\n  }\n\n  /**\n   * Get the W3cCredential from the JWT payload. This does not include the JWT wrapper,\n   * and thus is not suitable for sharing. If you need a JWT, use the `serializedJwt` property.\n   *\n   * All properties and getters from the `W3cCredential` interface are implemented as getters\n   * on the `W3cJwtVerifiableCredential` class itself, so you can also use this directly\n   * instead of accessing the inner `credential` property.\n   */\n  public get credential(): W3cCredential {\n    return this._credential\n  }\n\n  public get serializedJwt(): string {\n    return this.jwt.serializedJwt\n  }\n\n  //\n  // Below all properties from the `W3cCredential` interface are implemented as getters\n  // this is to make the interface compatible with the W3cJsonLdVerifiableCredential interface\n  // which makes using the different classes interchangeably from a user point of view.\n  // This is 'easier' than extending the W3cCredential class as it means we have to create the\n  // instance based on JSON, but also add custom properties.\n  //\n\n  public get context() {\n    return this.credential.context\n  }\n\n  public get id() {\n    return this.credential.id\n  }\n\n  public get type() {\n    return this.credential.type\n  }\n\n  public get issuer() {\n    return this.credential.issuer\n  }\n\n  public get issuanceDate() {\n    return this.credential.issuanceDate\n  }\n\n  public get expirationDate() {\n    return this.credential.expirationDate\n  }\n\n  public get credentialSubject() {\n    return this.credential.credentialSubject\n  }\n\n  public get credentialSchema() {\n    return this.credential.credentialSchema\n  }\n\n  public get credentialStatus() {\n    return this.credential.credentialStatus\n  }\n\n  public get issuerId() {\n    return this.credential.issuerId\n  }\n\n  public get credentialSchemaIds() {\n    return this.credential.credentialSchemaIds\n  }\n\n  public get credentialSubjectIds() {\n    return this.credential.credentialSubjectIds\n  }\n\n  public get contexts() {\n    return this.credential.contexts\n  }\n\n  /**\n   * The {@link ClaimFormat} of the credential. For JWT credentials this is always `jwt_vc`.\n   */\n  public get claimFormat(): ClaimFormat.JwtVc {\n    return ClaimFormat.JwtVc\n  }\n\n  /**\n   * Get the encoded variant of the W3C Verifiable Credential. For JWT credentials this is\n   * a JWT string.\n   */\n  public get encoded() {\n    return this.serializedJwt\n  }\n\n  public get jsonCredential(): W3cJsonCredential {\n    return JsonTransformer.toJSON(this.credential) as W3cJsonCredential\n  }\n}\n"],"mappings":";;;;;;;;;AAYA,IAAa,6BAAb,MAAa,2BAA2B;CAItC,AAAO,YAAY,SAA4C;AAC7D,OAAK,MAAM,QAAQ;AAEnB,OAAK,cAAc,4BAA4B,KAAK,IAAI,QAAQ;;CAGlE,OAAc,kBAAkB,eAAuB;AAGrD,SAAO,IAAI,2BAA2B,EACpC,KAHU,IAAI,kBAAkB,cAAc,EAI/C,CAAC;;;;;;;;;;CAWJ,IAAW,aAA4B;AACrC,SAAO,KAAK;;CAGd,IAAW,gBAAwB;AACjC,SAAO,KAAK,IAAI;;CAWlB,IAAW,UAAU;AACnB,SAAO,KAAK,WAAW;;CAGzB,IAAW,KAAK;AACd,SAAO,KAAK,WAAW;;CAGzB,IAAW,OAAO;AAChB,SAAO,KAAK,WAAW;;CAGzB,IAAW,SAAS;AAClB,SAAO,KAAK,WAAW;;CAGzB,IAAW,eAAe;AACxB,SAAO,KAAK,WAAW;;CAGzB,IAAW,iBAAiB;AAC1B,SAAO,KAAK,WAAW;;CAGzB,IAAW,oBAAoB;AAC7B,SAAO,KAAK,WAAW;;CAGzB,IAAW,mBAAmB;AAC5B,SAAO,KAAK,WAAW;;CAGzB,IAAW,mBAAmB;AAC5B,SAAO,KAAK,WAAW;;CAGzB,IAAW,WAAW;AACpB,SAAO,KAAK,WAAW;;CAGzB,IAAW,sBAAsB;AAC/B,SAAO,KAAK,WAAW;;CAGzB,IAAW,uBAAuB;AAChC,SAAO,KAAK,WAAW;;CAGzB,IAAW,WAAW;AACpB,SAAO,KAAK,WAAW;;;;;CAMzB,IAAW,cAAiC;AAC1C,SAAO,YAAY;;;;;;CAOrB,IAAW,UAAU;AACnB,SAAO,KAAK;;CAGd,IAAW,iBAAoC;AAC7C,SAAO,gBAAgB,OAAO,KAAK,WAAW"}