|
9 | 9 | CredentialFormat, |
10 | 10 | ItwCredentialStatus, |
11 | 11 | StoredCredential, |
12 | | - Verification |
| 12 | + StoredVerification |
13 | 13 | } from "./itwTypesUtils"; |
14 | 14 |
|
15 | 15 | // Credentials that can be actively requested and obtained by the user |
@@ -129,25 +129,34 @@ export const validCredentialStatuses: Array<ItwCredentialStatus> = [ |
129 | 129 |
|
130 | 130 | /** |
131 | 131 | * Extracts the verification object from a stored credential based on its format. |
| 132 | + * Only persists `trust_framework` and `assurance_level`, excluding `evidence` |
| 133 | + * which is being dropped in spec v1.3.3. |
132 | 134 | * @param credential - The stored credential fields needed to extract verification |
133 | | - * @returns The verification object or undefined if extraction fails |
| 135 | + * @returns The slim verification object or undefined if extraction fails |
134 | 136 | */ |
135 | 137 | export const extractVerification = ({ |
136 | 138 | format, |
137 | 139 | credential, |
138 | 140 | parsedCredential |
139 | 141 | }: Pick<StoredCredential, "format" | "credential" | "parsedCredential">): |
140 | | - | Verification |
| 142 | + | StoredVerification |
141 | 143 | | undefined => { |
142 | 144 | try { |
143 | | - switch (format) { |
144 | | - case CredentialFormat.SD_JWT: |
145 | | - return SdJwt.getVerification(credential); |
146 | | - case CredentialFormat.MDOC: |
147 | | - return Mdoc.getVerificationFromParsedCredential(parsedCredential); |
148 | | - default: |
149 | | - return undefined; |
| 145 | + const verification = (() => { |
| 146 | + switch (format) { |
| 147 | + case CredentialFormat.SD_JWT: |
| 148 | + return SdJwt.getVerification(credential); |
| 149 | + case CredentialFormat.MDOC: |
| 150 | + return Mdoc.getVerificationFromParsedCredential(parsedCredential); |
| 151 | + default: |
| 152 | + return undefined; |
| 153 | + } |
| 154 | + })(); |
| 155 | + if (!verification) { |
| 156 | + return undefined; |
150 | 157 | } |
| 158 | + const { trust_framework, assurance_level } = verification; |
| 159 | + return { trust_framework, assurance_level }; |
151 | 160 | } catch { |
152 | 161 | return undefined; |
153 | 162 | } |
|
0 commit comments