Skip to content

Commit 5755158

Browse files
committed
drop evidence from verification
1 parent bdd98ea commit 5755158

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

ts/features/itwallet/common/utils/itwCredentialUtils.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
CredentialFormat,
1010
ItwCredentialStatus,
1111
StoredCredential,
12-
Verification
12+
StoredVerification
1313
} from "./itwTypesUtils";
1414

1515
// Credentials that can be actively requested and obtained by the user
@@ -129,25 +129,34 @@ export const validCredentialStatuses: Array<ItwCredentialStatus> = [
129129

130130
/**
131131
* 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.
132134
* @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
134136
*/
135137
export const extractVerification = ({
136138
format,
137139
credential,
138140
parsedCredential
139141
}: Pick<StoredCredential, "format" | "credential" | "parsedCredential">):
140-
| Verification
142+
| StoredVerification
141143
| undefined => {
142144
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;
150157
}
158+
const { trust_framework, assurance_level } = verification;
159+
return { trust_framework, assurance_level };
151160
} catch {
152161
return undefined;
153162
}

ts/features/itwallet/common/utils/itwTypesUtils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ export type Verification = NonNullable<
9292
ReturnType<typeof SdJwt.getVerification>
9393
>;
9494

95+
/**
96+
* Slim version of Verification for storage.
97+
* Only persists the fields actually used by the app.
98+
* The `evidence` field is excluded as it's being dropped in spec v1.3.3.
99+
*/
100+
export type StoredVerification = Pick<
101+
Verification,
102+
"trust_framework" | "assurance_level"
103+
>;
104+
95105
export type StoredStatusAssertion =
96106
| {
97107
credentialStatus: "valid";
@@ -126,7 +136,7 @@ export type StoredCredential = {
126136
issuedAt?: string;
127137
};
128138
spec_version: string;
129-
verification?: Verification;
139+
verification?: StoredVerification;
130140
};
131141

132142
// Digital credential status

0 commit comments

Comments
 (0)