@sphereon/ssi-sdk.credential-validation 0.32.1-feature.new.develop.280 → 0.32.1-feature.new.develop.283
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 +8 -7
- package/dist/agent/CredentialValidation.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +8 -8
- package/plugin.schema.json +26 -11
- package/src/agent/CredentialValidation.ts +8 -7
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAOjB,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"}
|
|
@@ -21,6 +21,7 @@ const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
|
21
21
|
const index_1 = require("../index");
|
|
22
22
|
var decodeFrom = kmp_mdoc_core_1.com.sphereon.kmp.decodeFrom;
|
|
23
23
|
var IssuerSignedCbor = kmp_mdoc_core_1.com.sphereon.mdoc.data.device.IssuerSignedCbor;
|
|
24
|
+
const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
|
|
24
25
|
// Exposing the methods here for any REST implementation
|
|
25
26
|
exports.credentialValidationMethods = [
|
|
26
27
|
'cvVerifyCredential',
|
|
@@ -61,7 +62,7 @@ class CredentialValidation {
|
|
|
61
62
|
cvVerifyCredential(args, context) {
|
|
62
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
64
|
var _a;
|
|
64
|
-
const { credential, hasher, policies } = args;
|
|
65
|
+
const { credential, hasher = ssi_sdk_core_1.defaultHasher, policies } = args;
|
|
65
66
|
// defaulting the schema validation to when_present
|
|
66
67
|
const schemaResult = yield this.cvVerifySchema({
|
|
67
68
|
credential,
|
|
@@ -84,7 +85,7 @@ class CredentialValidation {
|
|
|
84
85
|
}
|
|
85
86
|
cvVerifySchema(args) {
|
|
86
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
const { credential, hasher, validationPolicy } = args;
|
|
88
|
+
const { credential, hasher = ssi_sdk_core_1.defaultHasher, validationPolicy } = args;
|
|
88
89
|
const wrappedCredential = ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(credential, { hasher });
|
|
89
90
|
if (validationPolicy === index_1.SchemaValidation.NEVER) {
|
|
90
91
|
return {
|
|
@@ -174,7 +175,7 @@ class CredentialValidation {
|
|
|
174
175
|
message: (_a = error.message) !== null && _a !== void 0 ? _a : 'Mdoc Issuer Signed VC could not be verified',
|
|
175
176
|
};
|
|
176
177
|
});
|
|
177
|
-
return Object.assign({ source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(credential), result: !verification.error, subResults: [] }, (verification.error && {
|
|
178
|
+
return Object.assign({ source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(credential, { hasher: ssi_sdk_core_1.defaultHasher }), result: !verification.error, subResults: [] }, (verification.error && {
|
|
178
179
|
error: (_a = verification.message) !== null && _a !== void 0 ? _a : `Could not verify mdoc from issuer`,
|
|
179
180
|
}));
|
|
180
181
|
});
|
|
@@ -188,7 +189,7 @@ class CredentialValidation {
|
|
|
188
189
|
if (typeof result === 'boolean') {
|
|
189
190
|
return Object.assign(Object.assign({
|
|
190
191
|
// FIXME the source is never used, need to start using this as the source of truth
|
|
191
|
-
source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(args.credential), result }, (!result && {
|
|
192
|
+
source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(args.credential, { hasher: ssi_sdk_core_1.defaultHasher }), result }, (!result && {
|
|
192
193
|
error: 'Invalid JWT VC',
|
|
193
194
|
errorDetails: `JWT VC was not valid with policies: ${JSON.stringify(policies)}`,
|
|
194
195
|
})), { subResults: [] });
|
|
@@ -211,7 +212,7 @@ class CredentialValidation {
|
|
|
211
212
|
console.error(error);
|
|
212
213
|
}
|
|
213
214
|
return {
|
|
214
|
-
source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(credential),
|
|
215
|
+
source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(credential, { hasher: ssi_sdk_core_1.defaultHasher }),
|
|
215
216
|
result: result.verified,
|
|
216
217
|
subResults,
|
|
217
218
|
error,
|
|
@@ -222,7 +223,7 @@ class CredentialValidation {
|
|
|
222
223
|
}
|
|
223
224
|
cvVerifySDJWTCredential(args, context) {
|
|
224
225
|
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
-
const { credential, hasher } = args;
|
|
226
|
+
const { credential, hasher = ssi_sdk_core_1.defaultHasher } = args;
|
|
226
227
|
const verification = yield context.agent
|
|
227
228
|
.verifySdJwtVc({ credential })
|
|
228
229
|
.catch((error) => {
|
|
@@ -234,7 +235,7 @@ class CredentialValidation {
|
|
|
234
235
|
};
|
|
235
236
|
});
|
|
236
237
|
const result = 'header' in verification && 'payload' in verification;
|
|
237
|
-
return Object.assign({ source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(credential, { hasher }), result, subResults: [] }, (!result && Object.assign({}, verification)));
|
|
238
|
+
return Object.assign({ source: ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(credential, { hasher: hasher !== null && hasher !== void 0 ? hasher : ssi_sdk_core_1.defaultHasher }), result, subResults: [] }, (!result && Object.assign({}, verification)));
|
|
238
239
|
});
|
|
239
240
|
}
|
|
240
241
|
}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AACxE,yDAAsD;AAEtD,wDAAwD;AAC3C,QAAA,2BAA2B,GAAkB;IACxD,oBAAoB;IACpB,gBAAgB;IAChB,cAAc;IACd,yBAAyB;IACzB,uBAAuB;CACxB,CAAA;AAED;;GAEG;AACH,MAAa,oBAAoB;IAAjC;QACW,WAAM,GAAG,cAAM,CAAC,qBAAqB,CAAA;QACrC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ature.new.develop.
|
|
3
|
+
"version": "0.32.1-feature.new.develop.283+070040e1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,18 +16,18 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
19
|
-
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.new.develop.
|
|
20
|
-
"@sphereon/ssi-sdk.core": "0.32.1-feature.new.develop.
|
|
21
|
-
"@sphereon/ssi-sdk.mdl-mdoc": "0.32.1-feature.new.develop.
|
|
22
|
-
"@sphereon/ssi-sdk.sd-jwt": "0.32.1-feature.new.develop.
|
|
23
|
-
"@sphereon/ssi-types": "0.32.1-feature.new.develop.
|
|
19
|
+
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.new.develop.283+070040e1",
|
|
20
|
+
"@sphereon/ssi-sdk.core": "0.32.1-feature.new.develop.283+070040e1",
|
|
21
|
+
"@sphereon/ssi-sdk.mdl-mdoc": "0.32.1-feature.new.develop.283+070040e1",
|
|
22
|
+
"@sphereon/ssi-sdk.sd-jwt": "0.32.1-feature.new.develop.283+070040e1",
|
|
23
|
+
"@sphereon/ssi-types": "0.32.1-feature.new.develop.283+070040e1",
|
|
24
24
|
"@veramo/core": "4.2.0",
|
|
25
25
|
"@veramo/utils": "4.2.0",
|
|
26
26
|
"ajv": "^8.17.1",
|
|
27
27
|
"ajv-formats": "^3.0.1",
|
|
28
28
|
"cross-fetch": "^3.1.8",
|
|
29
29
|
"debug": "^4.3.5",
|
|
30
|
-
"typeorm": "^0.3.
|
|
30
|
+
"typeorm": "^0.3.21"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@veramo/remote-client": "4.2.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"Credential",
|
|
55
55
|
"VerifiableCredential"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "070040e12d871bfe48e884b88e26a2ebc5b41ce5"
|
|
58
58
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -536,7 +536,7 @@
|
|
|
536
536
|
"additionalProperties": {
|
|
537
537
|
"anyOf": [
|
|
538
538
|
{
|
|
539
|
-
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
539
|
+
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006"
|
|
540
540
|
},
|
|
541
541
|
{
|
|
542
542
|
"not": {}
|
|
@@ -547,7 +547,7 @@
|
|
|
547
547
|
{
|
|
548
548
|
"type": "array",
|
|
549
549
|
"items": {
|
|
550
|
-
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
550
|
+
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006"
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
553
|
]
|
|
@@ -578,7 +578,7 @@
|
|
|
578
578
|
"additionalProperties": {
|
|
579
579
|
"anyOf": [
|
|
580
580
|
{
|
|
581
|
-
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
581
|
+
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006"
|
|
582
582
|
},
|
|
583
583
|
{
|
|
584
584
|
"not": {}
|
|
@@ -589,7 +589,7 @@
|
|
|
589
589
|
{
|
|
590
590
|
"type": "array",
|
|
591
591
|
"items": {
|
|
592
|
-
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
592
|
+
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006"
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
]
|
|
@@ -599,7 +599,7 @@
|
|
|
599
599
|
}
|
|
600
600
|
]
|
|
601
601
|
},
|
|
602
|
-
"alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
602
|
+
"alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006": {
|
|
603
603
|
"anyOf": [
|
|
604
604
|
{
|
|
605
605
|
"type": "string"
|
|
@@ -615,7 +615,7 @@
|
|
|
615
615
|
"additionalProperties": {
|
|
616
616
|
"anyOf": [
|
|
617
617
|
{
|
|
618
|
-
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
618
|
+
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006"
|
|
619
619
|
},
|
|
620
620
|
{
|
|
621
621
|
"not": {}
|
|
@@ -626,7 +626,7 @@
|
|
|
626
626
|
{
|
|
627
627
|
"type": "array",
|
|
628
628
|
"items": {
|
|
629
|
-
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
629
|
+
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006"
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
632
|
]
|
|
@@ -698,7 +698,7 @@
|
|
|
698
698
|
"additionalProperties": {
|
|
699
699
|
"anyOf": [
|
|
700
700
|
{
|
|
701
|
-
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
701
|
+
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006"
|
|
702
702
|
},
|
|
703
703
|
{
|
|
704
704
|
"not": {}
|
|
@@ -709,7 +709,7 @@
|
|
|
709
709
|
{
|
|
710
710
|
"type": "array",
|
|
711
711
|
"items": {
|
|
712
|
-
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-
|
|
712
|
+
"$ref": "#/components/schemas/alias-d-jwt-vc.d.ts-197-306-d-jwt-vc.d.ts-0-8006"
|
|
713
713
|
}
|
|
714
714
|
},
|
|
715
715
|
{
|
|
@@ -771,14 +771,29 @@
|
|
|
771
771
|
"properties": {}
|
|
772
772
|
},
|
|
773
773
|
"HasherSync": {
|
|
774
|
-
"$comment": "(data: string, alg: string) => Uint8Array",
|
|
774
|
+
"$comment": "(data: string | ArrayBuffer, alg: string) => Uint8Array",
|
|
775
775
|
"type": "object",
|
|
776
776
|
"properties": {
|
|
777
777
|
"namedArgs": {
|
|
778
778
|
"type": "object",
|
|
779
779
|
"properties": {
|
|
780
780
|
"data": {
|
|
781
|
-
"
|
|
781
|
+
"anyOf": [
|
|
782
|
+
{
|
|
783
|
+
"type": "string"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
"type": "object",
|
|
787
|
+
"properties": {
|
|
788
|
+
"byteLength": {
|
|
789
|
+
"type": "number"
|
|
790
|
+
}
|
|
791
|
+
},
|
|
792
|
+
"required": [
|
|
793
|
+
"byteLength"
|
|
794
|
+
]
|
|
795
|
+
}
|
|
796
|
+
]
|
|
782
797
|
},
|
|
783
798
|
"alg": {
|
|
784
799
|
"type": "string"
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
import IVerifySignatureResult = com.sphereon.crypto.generic.IVerifySignatureResult
|
|
29
29
|
import decodeFrom = com.sphereon.kmp.decodeFrom
|
|
30
30
|
import IssuerSignedCbor = com.sphereon.mdoc.data.device.IssuerSignedCbor
|
|
31
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
31
32
|
|
|
32
33
|
// Exposing the methods here for any REST implementation
|
|
33
34
|
export const credentialValidationMethods: Array<string> = [
|
|
@@ -70,7 +71,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
private async cvVerifyCredential(args: VerifyCredentialArgs, context: RequiredContext): Promise<VerificationResult> {
|
|
73
|
-
const { credential, hasher, policies } = args
|
|
74
|
+
const { credential, hasher = defaultHasher, policies } = args
|
|
74
75
|
// defaulting the schema validation to when_present
|
|
75
76
|
const schemaResult = await this.cvVerifySchema({
|
|
76
77
|
credential,
|
|
@@ -96,7 +97,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
private async cvVerifySchema(args: ValidateSchemaArgs): Promise<VerificationResult> {
|
|
99
|
-
const { credential, hasher, validationPolicy } = args
|
|
100
|
+
const { credential, hasher = defaultHasher, validationPolicy } = args
|
|
100
101
|
const wrappedCredential: WrappedVerifiableCredential = CredentialMapper.toWrappedVerifiableCredential(credential, { hasher })
|
|
101
102
|
if (validationPolicy === SchemaValidation.NEVER) {
|
|
102
103
|
return {
|
|
@@ -188,7 +189,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
188
189
|
})
|
|
189
190
|
|
|
190
191
|
return {
|
|
191
|
-
source: CredentialMapper.toWrappedVerifiableCredential(credential as OriginalVerifiableCredential),
|
|
192
|
+
source: CredentialMapper.toWrappedVerifiableCredential(credential as OriginalVerifiableCredential, { hasher: defaultHasher }),
|
|
192
193
|
result: !verification.error,
|
|
193
194
|
subResults: [],
|
|
194
195
|
...(verification.error && {
|
|
@@ -206,7 +207,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
206
207
|
if (typeof result === 'boolean') {
|
|
207
208
|
return {
|
|
208
209
|
// FIXME the source is never used, need to start using this as the source of truth
|
|
209
|
-
source: CredentialMapper.toWrappedVerifiableCredential(args.credential as OriginalVerifiableCredential),
|
|
210
|
+
source: CredentialMapper.toWrappedVerifiableCredential(args.credential as OriginalVerifiableCredential, { hasher: defaultHasher }),
|
|
210
211
|
result,
|
|
211
212
|
...(!result && {
|
|
212
213
|
error: 'Invalid JWT VC',
|
|
@@ -233,7 +234,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
return {
|
|
236
|
-
source: CredentialMapper.toWrappedVerifiableCredential(credential as OriginalVerifiableCredential),
|
|
237
|
+
source: CredentialMapper.toWrappedVerifiableCredential(credential as OriginalVerifiableCredential, { hasher: defaultHasher }),
|
|
237
238
|
result: result.verified,
|
|
238
239
|
subResults,
|
|
239
240
|
error,
|
|
@@ -243,7 +244,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
private async cvVerifySDJWTCredential(args: VerifySDJWTCredentialArgs, context: RequiredContext): Promise<VerificationResult> {
|
|
246
|
-
const { credential, hasher } = args
|
|
247
|
+
const { credential, hasher = defaultHasher } = args
|
|
247
248
|
|
|
248
249
|
const verification: IVerifySdJwtVcResult | CredentialVerificationError = await context.agent
|
|
249
250
|
.verifySdJwtVc({ credential })
|
|
@@ -257,7 +258,7 @@ export class CredentialValidation implements IAgentPlugin {
|
|
|
257
258
|
|
|
258
259
|
const result = 'header' in verification && 'payload' in verification
|
|
259
260
|
return {
|
|
260
|
-
source: CredentialMapper.toWrappedVerifiableCredential(credential as OriginalVerifiableCredential, { hasher }),
|
|
261
|
+
source: CredentialMapper.toWrappedVerifiableCredential(credential as OriginalVerifiableCredential, { hasher: hasher ?? defaultHasher }),
|
|
261
262
|
result,
|
|
262
263
|
subResults: [],
|
|
263
264
|
...(!result && { ...verification }),
|