@sphereon/ssi-sdk.credential-validation 0.32.0 → 0.32.1-feature.MWALL.715.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/CredentialValidation.d.ts.map +1 -1
- package/dist/agent/CredentialValidation.js +14 -14
- package/dist/agent/CredentialValidation.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +7 -7
- package/plugin.schema.json +26 -62
- package/src/agent/CredentialValidation.ts +30 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialValidation.d.ts","sourceRoot":"","sources":["../../src/agent/CredentialValidation.ts"],"names":[],"mappings":"AAUA,OAAO,
|
|
1
|
+
{"version":3,"file":"CredentialValidation.d.ts","sourceRoot":"","sources":["../../src/agent/CredentialValidation.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAmF,MAAM,cAAc,CAAA;AAI5H,OAAO,EAEL,qBAAqB,EAUtB,MAAM,UAAU,CAAA;AAMjB,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,MAAM,CAMrD,CAAA;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,QAAQ,CAAC,MAAM,MAA+B;IAC9C,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAMtC;IAED,OAAO,CAAC,aAAa;YAkBP,kBAAkB;YA0BlB,cAAc;YAad,cAAc;YA8Bd,WAAW;YAQX,6BAA6B;YA0B7B,YAAY;YAyBZ,qBAAqB;YA6CrB,uBAAuB;CAqBtC"}
|
|
@@ -27,7 +27,7 @@ exports.credentialValidationMethods = [
|
|
|
27
27
|
'cvVerifySchema',
|
|
28
28
|
'cvVerifyMdoc',
|
|
29
29
|
'cvVerifySDJWTCredential',
|
|
30
|
-
'cvVerifyW3CCredential'
|
|
30
|
+
'cvVerifyW3CCredential',
|
|
31
31
|
];
|
|
32
32
|
/**
|
|
33
33
|
* {@inheritDoc ICredentialValidation}
|
|
@@ -40,7 +40,7 @@ class CredentialValidation {
|
|
|
40
40
|
cvVerifySchema: this.cvVerifySchema.bind(this),
|
|
41
41
|
cvVerifyMdoc: this.cvVerifyMdoc.bind(this),
|
|
42
42
|
cvVerifySDJWTCredential: this.cvVerifySDJWTCredential.bind(this),
|
|
43
|
-
cvVerifyW3CCredential: this.cvVerifyW3CCredential.bind(this)
|
|
43
|
+
cvVerifyW3CCredential: this.cvVerifyW3CCredential.bind(this),
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
detectSchemas(wrappedVC) {
|
|
@@ -66,7 +66,7 @@ class CredentialValidation {
|
|
|
66
66
|
const schemaResult = yield this.cvVerifySchema({
|
|
67
67
|
credential,
|
|
68
68
|
validationPolicy: (_a = policies === null || policies === void 0 ? void 0 : policies.schemaValidation) !== null && _a !== void 0 ? _a : index_1.SchemaValidation.WHEN_PRESENT,
|
|
69
|
-
hasher
|
|
69
|
+
hasher,
|
|
70
70
|
});
|
|
71
71
|
if (!schemaResult.result) {
|
|
72
72
|
return schemaResult;
|
|
@@ -90,7 +90,7 @@ class CredentialValidation {
|
|
|
90
90
|
return {
|
|
91
91
|
result: true,
|
|
92
92
|
source: wrappedCredential,
|
|
93
|
-
subResults: []
|
|
93
|
+
subResults: [],
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
return this.validateSchema(wrappedCredential, validationPolicy);
|
|
@@ -105,14 +105,14 @@ class CredentialValidation {
|
|
|
105
105
|
return {
|
|
106
106
|
result: false,
|
|
107
107
|
source: wrappedVC,
|
|
108
|
-
subResults: []
|
|
108
|
+
subResults: [],
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
112
|
return {
|
|
113
113
|
result: true,
|
|
114
114
|
source: wrappedVC,
|
|
115
|
-
subResults: []
|
|
115
|
+
subResults: [],
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -120,7 +120,7 @@ class CredentialValidation {
|
|
|
120
120
|
return {
|
|
121
121
|
result: subResults.every((subResult) => subResult.result),
|
|
122
122
|
source: wrappedVC,
|
|
123
|
-
subResults
|
|
123
|
+
subResults,
|
|
124
124
|
};
|
|
125
125
|
});
|
|
126
126
|
}
|
|
@@ -144,7 +144,7 @@ class CredentialValidation {
|
|
|
144
144
|
console.error(error);
|
|
145
145
|
return {
|
|
146
146
|
result: false,
|
|
147
|
-
error: error
|
|
147
|
+
error: error,
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
const ajv = new _2020_1.default({ loadSchema: this.fetchSchema });
|
|
@@ -155,7 +155,7 @@ class CredentialValidation {
|
|
|
155
155
|
console.error(`Schema validation failed for `, wrappedVC.credential);
|
|
156
156
|
}
|
|
157
157
|
return {
|
|
158
|
-
result: valid
|
|
158
|
+
result: valid,
|
|
159
159
|
};
|
|
160
160
|
});
|
|
161
161
|
}
|
|
@@ -171,11 +171,11 @@ class CredentialValidation {
|
|
|
171
171
|
name: 'mdoc',
|
|
172
172
|
critical: true,
|
|
173
173
|
error: true,
|
|
174
|
-
message: (_a = error.message) !== null && _a !== void 0 ? _a : 'Mdoc Issuer Signed VC could not be verified'
|
|
174
|
+
message: (_a = error.message) !== null && _a !== void 0 ? _a : 'Mdoc Issuer Signed VC could not be verified',
|
|
175
175
|
};
|
|
176
176
|
});
|
|
177
177
|
return Object.assign({ source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(credential), result: !verification.error, subResults: [] }, (verification.error && {
|
|
178
|
-
error: (_a = verification.message) !== null && _a !== void 0 ? _a : `Could not verify mdoc from issuer
|
|
178
|
+
error: (_a = verification.message) !== null && _a !== void 0 ? _a : `Could not verify mdoc from issuer`,
|
|
179
179
|
}));
|
|
180
180
|
});
|
|
181
181
|
}
|
|
@@ -190,7 +190,7 @@ class CredentialValidation {
|
|
|
190
190
|
// FIXME the source is never used, need to start using this as the source of truth
|
|
191
191
|
source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(args.credential), result }, (!result && {
|
|
192
192
|
error: 'Invalid JWT VC',
|
|
193
|
-
errorDetails: `JWT VC was not valid with policies: ${JSON.stringify(policies)}
|
|
193
|
+
errorDetails: `JWT VC was not valid with policies: ${JSON.stringify(policies)}`,
|
|
194
194
|
})), { subResults: [] });
|
|
195
195
|
}
|
|
196
196
|
else {
|
|
@@ -215,7 +215,7 @@ class CredentialValidation {
|
|
|
215
215
|
result: result.verified,
|
|
216
216
|
subResults,
|
|
217
217
|
error,
|
|
218
|
-
errorDetails
|
|
218
|
+
errorDetails,
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
});
|
|
@@ -230,7 +230,7 @@ class CredentialValidation {
|
|
|
230
230
|
console.error(error);
|
|
231
231
|
return {
|
|
232
232
|
error: 'Invalid SD-JWT VC',
|
|
233
|
-
errorDetails: (_a = error.message) !== null && _a !== void 0 ? _a : 'SD-JWT VC could not be verified'
|
|
233
|
+
errorDetails: (_a = error.message) !== null && _a !== void 0 ? _a : 'SD-JWT VC could not be verified',
|
|
234
234
|
};
|
|
235
235
|
});
|
|
236
236
|
const result = 'header' in verification && 'payload' in verification;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialValidation.js","sourceRoot":"","sources":["../../src/agent/CredentialValidation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAA6C;AAE7C,mDAO4B;
|
|
1
|
+
{"version":3,"file":"CredentialValidation.js","sourceRoot":"","sources":["../../src/agent/CredentialValidation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAA6C;AAE7C,mDAO4B;AAE5B,8DAAoC;AACpC,0DAAmC;AACnC,8DAA+B;AAC/B,oCAYiB;AAEjB,IAAO,UAAU,GAAG,mBAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAA;AAC/C,IAAO,gBAAgB,GAAG,mBAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAA;AAExE,wDAAw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
|
+
"version": "0.32.1-feature.MWALL.715.47+99c3f8e7",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
19
|
-
"@sphereon/ssi-sdk.agent-config": "0.32.
|
|
20
|
-
"@sphereon/ssi-sdk.core": "0.32.
|
|
21
|
-
"@sphereon/ssi-sdk.mdl-mdoc": "0.32.
|
|
22
|
-
"@sphereon/ssi-sdk.sd-jwt": "0.32.
|
|
23
|
-
"@sphereon/ssi-types": "0.32.
|
|
19
|
+
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.MWALL.715.47+99c3f8e7",
|
|
20
|
+
"@sphereon/ssi-sdk.core": "0.32.1-feature.MWALL.715.47+99c3f8e7",
|
|
21
|
+
"@sphereon/ssi-sdk.mdl-mdoc": "0.32.1-feature.MWALL.715.47+99c3f8e7",
|
|
22
|
+
"@sphereon/ssi-sdk.sd-jwt": "0.32.1-feature.MWALL.715.47+99c3f8e7",
|
|
23
|
+
"@sphereon/ssi-types": "0.32.1-feature.MWALL.715.47+99c3f8e7",
|
|
24
24
|
"@veramo/core": "4.2.0",
|
|
25
25
|
"@veramo/utils": "4.2.0",
|
|
26
26
|
"ajv": "^8.17.1",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"Credential",
|
|
55
55
|
"VerifiableCredential"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "99c3f8e784f7b47c48aa7b0d4f1f270f37c37315"
|
|
58
58
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -895,19 +895,11 @@
|
|
|
895
895
|
"description": "In case of JWT credential it will be the decoded version. In other cases it will be the same as original one"
|
|
896
896
|
},
|
|
897
897
|
"type": {
|
|
898
|
-
"
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
{
|
|
904
|
-
"type": "string",
|
|
905
|
-
"const": "jwt-encoded"
|
|
906
|
-
},
|
|
907
|
-
{
|
|
908
|
-
"type": "string",
|
|
909
|
-
"const": "jwt-decoded"
|
|
910
|
-
}
|
|
898
|
+
"type": "string",
|
|
899
|
+
"enum": [
|
|
900
|
+
"json-ld",
|
|
901
|
+
"jwt-encoded",
|
|
902
|
+
"jwt-decoded"
|
|
911
903
|
],
|
|
912
904
|
"description": "Type of this credential. Supported types are json-ld, jwt (decoded/encoded)"
|
|
913
905
|
},
|
|
@@ -953,15 +945,10 @@
|
|
|
953
945
|
"description": "Decoded version of the SD-JWT payload. This is the decoded payload, rather than the whole SD-JWT as the `decoded` property is used in e.g. PEX to check for path filters from fields. The full decoded credential can be found in the `credential` field."
|
|
954
946
|
},
|
|
955
947
|
"type": {
|
|
956
|
-
"
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
},
|
|
961
|
-
{
|
|
962
|
-
"type": "string",
|
|
963
|
-
"const": "sd-jwt-vc-encoded"
|
|
964
|
-
}
|
|
948
|
+
"type": "string",
|
|
949
|
+
"enum": [
|
|
950
|
+
"sd-jwt-vc-decoded",
|
|
951
|
+
"sd-jwt-vc-encoded"
|
|
965
952
|
],
|
|
966
953
|
"description": "Type of this credential."
|
|
967
954
|
},
|
|
@@ -1006,15 +993,10 @@
|
|
|
1006
993
|
"description": "Record where keys are the namespaces and the values are objects again with the namespace values"
|
|
1007
994
|
},
|
|
1008
995
|
"type": {
|
|
1009
|
-
"
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
},
|
|
1014
|
-
{
|
|
1015
|
-
"type": "string",
|
|
1016
|
-
"const": "mso_mdoc-encoded"
|
|
1017
|
-
}
|
|
996
|
+
"type": "string",
|
|
997
|
+
"enum": [
|
|
998
|
+
"mso_mdoc-decoded",
|
|
999
|
+
"mso_mdoc-encoded"
|
|
1018
1000
|
],
|
|
1019
1001
|
"description": "Type of this credential."
|
|
1020
1002
|
},
|
|
@@ -1089,19 +1071,11 @@
|
|
|
1089
1071
|
"description": "In case of JWT VP it will be the decoded version. In other cases it will be the same as original one"
|
|
1090
1072
|
},
|
|
1091
1073
|
"type": {
|
|
1092
|
-
"
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
{
|
|
1098
|
-
"type": "string",
|
|
1099
|
-
"const": "jwt-encoded"
|
|
1100
|
-
},
|
|
1101
|
-
{
|
|
1102
|
-
"type": "string",
|
|
1103
|
-
"const": "jwt-decoded"
|
|
1104
|
-
}
|
|
1074
|
+
"type": "string",
|
|
1075
|
+
"enum": [
|
|
1076
|
+
"json-ld",
|
|
1077
|
+
"jwt-encoded",
|
|
1078
|
+
"jwt-decoded"
|
|
1105
1079
|
],
|
|
1106
1080
|
"description": "Type of this Presentation. Supported types are json-ld and jwt (decoded/encoded) and sd-jwt-vc (decoded/encoded)"
|
|
1107
1081
|
},
|
|
@@ -1369,15 +1343,10 @@
|
|
|
1369
1343
|
"description": "Decoded version of the SD-JWT payload. This is the decoded payload, rather than the whole SD-JWT."
|
|
1370
1344
|
},
|
|
1371
1345
|
"type": {
|
|
1372
|
-
"
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
},
|
|
1377
|
-
{
|
|
1378
|
-
"type": "string",
|
|
1379
|
-
"const": "sd-jwt-vc-encoded"
|
|
1380
|
-
}
|
|
1346
|
+
"type": "string",
|
|
1347
|
+
"enum": [
|
|
1348
|
+
"sd-jwt-vc-decoded",
|
|
1349
|
+
"sd-jwt-vc-encoded"
|
|
1381
1350
|
],
|
|
1382
1351
|
"description": "Type of this Presentation."
|
|
1383
1352
|
},
|
|
@@ -1428,15 +1397,10 @@
|
|
|
1428
1397
|
"description": "Decoded version of the SD-JWT payload. This is the decoded payload, rather than the whole SD-JWT."
|
|
1429
1398
|
},
|
|
1430
1399
|
"type": {
|
|
1431
|
-
"
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
},
|
|
1436
|
-
{
|
|
1437
|
-
"type": "string",
|
|
1438
|
-
"const": "mso_mdoc-decoded"
|
|
1439
|
-
}
|
|
1400
|
+
"type": "string",
|
|
1401
|
+
"enum": [
|
|
1402
|
+
"mso_mdoc-encoded",
|
|
1403
|
+
"mso_mdoc-decoded"
|
|
1440
1404
|
],
|
|
1441
1405
|
"description": "Type of this Presentation."
|
|
1442
1406
|
},
|
|
@@ -6,13 +6,9 @@ import {
|
|
|
6
6
|
ICredentialSchemaType,
|
|
7
7
|
IVerifyResult,
|
|
8
8
|
OriginalVerifiableCredential,
|
|
9
|
-
WrappedVerifiableCredential
|
|
9
|
+
WrappedVerifiableCredential,
|
|
10
10
|
} from '@sphereon/ssi-types'
|
|
11
|
-
import {
|
|
12
|
-
IAgentPlugin,
|
|
13
|
-
IVerifyCredentialArgs,
|
|
14
|
-
W3CVerifiableCredential as VeramoW3CVerifiableCredential
|
|
15
|
-
} from '@veramo/core'
|
|
11
|
+
import { IAgentPlugin, IVerifyCredentialArgs, W3CVerifiableCredential as VeramoW3CVerifiableCredential } from '@veramo/core'
|
|
16
12
|
import addFormats from 'ajv-formats'
|
|
17
13
|
import Ajv2020 from 'ajv/dist/2020'
|
|
18
14
|
import fetch from 'cross-fetch'
|
|
@@ -27,7 +23,7 @@ import {
|
|
|
27
23
|
VerificationSubResult,
|
|
28
24
|
VerifyCredentialArgs,
|
|
29
25
|
VerifyMdocCredentialArgs,
|
|
30
|
-
VerifySDJWTCredentialArgs
|
|
26
|
+
VerifySDJWTCredentialArgs,
|
|
31
27
|
} from '../index'
|
|
32
28
|
import IVerifySignatureResult = com.sphereon.crypto.generic.IVerifySignatureResult
|
|
33
29
|
import decodeFrom = com.sphereon.kmp.decodeFrom
|
|
@@ -39,7 +35,7 @@ export const credentialValidationMethods: Array<string> = [
|
|
|
39
35
|
'cvVerifySchema',
|
|
40
36
|
'cvVerifyMdoc',
|
|
41
37
|
'cvVerifySDJWTCredential',
|
|
42
|
-
'cvVerifyW3CCredential'
|
|
38
|
+
'cvVerifyW3CCredential',
|
|
43
39
|
]
|
|
44
40
|
|
|
45
41
|
/**
|
|
@@ -52,7 +48,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
52
48
|
cvVerifySchema: this.cvVerifySchema.bind(this),
|
|
53
49
|
cvVerifyMdoc: this.cvVerifyMdoc.bind(this),
|
|
54
50
|
cvVerifySDJWTCredential: this.cvVerifySDJWTCredential.bind(this),
|
|
55
|
-
cvVerifyW3CCredential: this.cvVerifyW3CCredential.bind(this)
|
|
51
|
+
cvVerifyW3CCredential: this.cvVerifyW3CCredential.bind(this),
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
private detectSchemas(wrappedVC: WrappedVerifiableCredential): ICredentialSchemaType[] | undefined {
|
|
@@ -79,7 +75,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
79
75
|
const schemaResult = await this.cvVerifySchema({
|
|
80
76
|
credential,
|
|
81
77
|
validationPolicy: policies?.schemaValidation ?? SchemaValidation.WHEN_PRESENT,
|
|
82
|
-
hasher
|
|
78
|
+
hasher,
|
|
83
79
|
})
|
|
84
80
|
if (!schemaResult.result) {
|
|
85
81
|
return schemaResult
|
|
@@ -89,10 +85,13 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
89
85
|
} else if (CredentialMapper.isSdJwtEncoded(credential)) {
|
|
90
86
|
return await this.cvVerifySDJWTCredential({ credential, hasher }, context)
|
|
91
87
|
} else {
|
|
92
|
-
return await this.cvVerifyW3CCredential(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
return await this.cvVerifyW3CCredential(
|
|
89
|
+
{
|
|
90
|
+
...args,
|
|
91
|
+
credential: credential as VeramoW3CVerifiableCredential,
|
|
92
|
+
},
|
|
93
|
+
context,
|
|
94
|
+
)
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
|
|
@@ -103,7 +102,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
103
102
|
return {
|
|
104
103
|
result: true,
|
|
105
104
|
source: wrappedCredential,
|
|
106
|
-
subResults: []
|
|
105
|
+
subResults: [],
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
return this.validateSchema(wrappedCredential, validationPolicy)
|
|
@@ -113,17 +112,19 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
113
112
|
const schemas: ICredentialSchemaType[] | undefined = this.detectSchemas(wrappedVC)
|
|
114
113
|
if (!schemas) {
|
|
115
114
|
if (validationPolicy === SchemaValidation.ALWAYS) {
|
|
116
|
-
console.error(
|
|
115
|
+
console.error(
|
|
116
|
+
`No schema found for credential, but validation policy is set to ALWAYS. Returning false. Credential: ${JSON.stringify(wrappedVC.credential, null, 2)}`,
|
|
117
|
+
)
|
|
117
118
|
return {
|
|
118
119
|
result: false,
|
|
119
120
|
source: wrappedVC,
|
|
120
|
-
subResults: []
|
|
121
|
+
subResults: [],
|
|
121
122
|
}
|
|
122
123
|
} else {
|
|
123
124
|
return {
|
|
124
125
|
result: true,
|
|
125
126
|
source: wrappedVC,
|
|
126
|
-
subResults: []
|
|
127
|
+
subResults: [],
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
}
|
|
@@ -133,7 +134,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
133
134
|
return {
|
|
134
135
|
result: subResults.every((subResult) => subResult.result),
|
|
135
136
|
source: wrappedVC,
|
|
136
|
-
subResults
|
|
137
|
+
subResults,
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -154,7 +155,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
154
155
|
console.error(error)
|
|
155
156
|
return {
|
|
156
157
|
result: false,
|
|
157
|
-
error: error
|
|
158
|
+
error: error,
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
|
|
@@ -167,7 +168,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
167
168
|
console.error(`Schema validation failed for `, wrappedVC.credential)
|
|
168
169
|
}
|
|
169
170
|
return {
|
|
170
|
-
result: valid
|
|
171
|
+
result: valid,
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
|
|
@@ -182,7 +183,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
182
183
|
name: 'mdoc',
|
|
183
184
|
critical: true,
|
|
184
185
|
error: true,
|
|
185
|
-
message: error.message ?? 'Mdoc Issuer Signed VC could not be verified'
|
|
186
|
+
message: error.message ?? 'Mdoc Issuer Signed VC could not be verified',
|
|
186
187
|
} satisfies IVerifySignatureResult<ICoseKeyJson>
|
|
187
188
|
})
|
|
188
189
|
|
|
@@ -191,8 +192,8 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
191
192
|
result: !verification.error,
|
|
192
193
|
subResults: [],
|
|
193
194
|
...(verification.error && {
|
|
194
|
-
error: verification.message ?? `Could not verify mdoc from issuer
|
|
195
|
-
})
|
|
195
|
+
error: verification.message ?? `Could not verify mdoc from issuer`,
|
|
196
|
+
}),
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
|
|
@@ -209,9 +210,9 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
209
210
|
result,
|
|
210
211
|
...(!result && {
|
|
211
212
|
error: 'Invalid JWT VC',
|
|
212
|
-
errorDetails: `JWT VC was not valid with policies: ${JSON.stringify(policies)}
|
|
213
|
+
errorDetails: `JWT VC was not valid with policies: ${JSON.stringify(policies)}`,
|
|
213
214
|
}),
|
|
214
|
-
subResults: []
|
|
215
|
+
subResults: [],
|
|
215
216
|
}
|
|
216
217
|
} else {
|
|
217
218
|
// TODO look at what this is doing and make it simple and readable
|
|
@@ -236,7 +237,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
236
237
|
result: result.verified,
|
|
237
238
|
subResults,
|
|
238
239
|
error,
|
|
239
|
-
errorDetails
|
|
240
|
+
errorDetails,
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
}
|
|
@@ -250,7 +251,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
250
251
|
console.error(error)
|
|
251
252
|
return {
|
|
252
253
|
error: 'Invalid SD-JWT VC',
|
|
253
|
-
errorDetails: error.message ?? 'SD-JWT VC could not be verified'
|
|
254
|
+
errorDetails: error.message ?? 'SD-JWT VC could not be verified',
|
|
254
255
|
}
|
|
255
256
|
})
|
|
256
257
|
|
|
@@ -259,7 +260,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
259
260
|
source: CredentialMapper.toWrappedVerifiableCredential(credential as OriginalVerifiableCredential, { hasher }),
|
|
260
261
|
result,
|
|
261
262
|
subResults: [],
|
|
262
|
-
...(!result && { ...verification })
|
|
263
|
+
...(!result && { ...verification }),
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
}
|