Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tired-cycles-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@agentcommercekit/vc": patch
---

Define explicit W3CCredential type to resolve TS compiler issues with inferred return types
30 changes: 25 additions & 5 deletions packages/vc/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import type {
JwtCredentialPayload,
Verifiable,
W3CCredential
} from "did-jwt-vc"
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { JwtCredentialPayload, Verifiable } from "did-jwt-vc"

type Extensible<T> = T & Record<string, any>

export interface CredentialStatus {
id: string
type: string
}

type W3CCredential = {
"@context": string[]
id?: string
type: string[]
issuer: Extensible<{ id: string }>
issuanceDate: string
expirationDate?: string
credentialSubject: Extensible<{
id?: string
}>
credentialStatus?: CredentialStatus

evidence?: any
termsOfUse?: any
}

export type CredentialSubject = W3CCredential["credentialSubject"]
export type { JwtCredentialPayload, Verifiable, W3CCredential }
1 change: 1 addition & 0 deletions packages/vc/src/verification/verify-parsed-credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function isVerifiable(
): credential is Verifiable<W3CCredential> {
return (
"proof" in credential &&
credential.proof !== null &&
typeof credential.proof === "object" &&
"type" in credential.proof
)
Expand Down