@verii/verii-verification 1.1.0-pre.1758089377 → 1.1.0-pre.1758094000

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verii/verii-verification",
3
- "version": "1.1.0-pre.1758089377",
3
+ "version": "1.1.0-pre.1758094000",
4
4
  "description": "Verii VC and VP Verification library ",
5
5
  "repository": "https://github.com/LFDT-Verii/core",
6
6
  "main": "index.js",
@@ -17,21 +17,21 @@
17
17
  "author": "Yauheni Pozdnyakov",
18
18
  "license": "Apache-2.0",
19
19
  "dependencies": {
20
- "@verii/common-fetchers": "1.1.0-pre.1758089377",
21
- "@verii/common-functions": "1.1.0-pre.1758089377",
22
- "@verii/did-doc": "1.1.0-pre.1758089377",
23
- "@verii/http-client": "1.1.0-pre.1758089377",
24
- "@verii/jwt": "1.1.0-pre.1758089377",
25
- "@verii/metadata-registration": "1.1.0-pre.1758089377",
26
- "@verii/vc-checks": "1.1.0-pre.1758089377",
20
+ "@verii/common-fetchers": "1.1.0-pre.1758094000",
21
+ "@verii/common-functions": "1.1.0-pre.1758094000",
22
+ "@verii/did-doc": "1.1.0-pre.1758094000",
23
+ "@verii/http-client": "1.1.0-pre.1758094000",
24
+ "@verii/jwt": "1.1.0-pre.1758094000",
25
+ "@verii/metadata-registration": "1.1.0-pre.1758094000",
26
+ "@verii/vc-checks": "1.1.0-pre.1758094000",
27
27
  "http-errors": "^2.0.0",
28
28
  "lodash": "^4.17.21"
29
29
  },
30
30
  "devDependencies": {
31
- "@verii/crypto": "1.1.0-pre.1758089377",
32
- "@verii/sample-data": "1.1.0-pre.1758089377",
33
- "@verii/test-regexes": "1.1.0-pre.1758089377",
34
- "@verii/tests-helpers": "1.1.0-pre.1758089377",
31
+ "@verii/crypto": "1.1.0-pre.1758094000",
32
+ "@verii/sample-data": "1.1.0-pre.1758094000",
33
+ "@verii/test-regexes": "1.1.0-pre.1758094000",
34
+ "@verii/tests-helpers": "1.1.0-pre.1758094000",
35
35
  "date-fns": "3.6.0",
36
36
  "eslint": "8.57.1",
37
37
  "eslint-config-airbnb-base": "14.2.1",
@@ -43,7 +43,7 @@
43
43
  "eslint-plugin-prettier": "4.2.5",
44
44
  "eslint-watch": "7.0.0",
45
45
  "expect": "29.7.0",
46
- "nanoid": "5.1.0",
46
+ "nanoid": "5.1.5",
47
47
  "nock": "15.0.0-beta.6",
48
48
  "prettier": "2.8.8",
49
49
  "undici": "7.16.0"
@@ -53,5 +53,5 @@
53
53
  "lib"
54
54
  ]
55
55
  },
56
- "gitHead": "5b06e1575dc6628ef2c79ee7e7567f920caaf91b"
56
+ "gitHead": "b3c64e0a7724eb54cf40c86938011dca098fa616"
57
57
  }
@@ -23,13 +23,34 @@ const verifyVerifiablePresentationJwt = async (
23
23
  presentationJwt,
24
24
  { vnfProtocolVersion }
25
25
  ) => {
26
+ if (vnfProtocolVersion < VeriiProtocolVersions.PROTOCOL_VERSION_2) {
27
+ return wrapVerifyPresentationJwt(presentationJwt);
28
+ }
29
+
30
+ const { header } = jwtDecode(presentationJwt);
31
+ if (header.jwk != null) {
32
+ throw newError(400, 'jwt_vp must not be self signed', {
33
+ errorCode: 'presentation_malformed',
34
+ });
35
+ }
36
+
37
+ const jwk = await wrapGetJwkFromDidUri(header.kid);
38
+ return wrapVerifyPresentationJwt(presentationJwt, jwk);
39
+ };
40
+
41
+ const wrapGetJwkFromDidUri = async (kid) => {
26
42
  try {
27
- if (vnfProtocolVersion < VeriiProtocolVersions.PROTOCOL_VERSION_2) {
28
- return await verifyPresentationJwt(presentationJwt);
29
- }
43
+ const jwk = await getJwkFromDidUri(kid);
44
+ return jwk;
45
+ } catch (error) {
46
+ throw newError(400, `kid_${error.message}`, {
47
+ errorCode: 'presentation_malformed',
48
+ });
49
+ }
50
+ };
30
51
 
31
- const { header } = jwtDecode(presentationJwt);
32
- const jwk = await getJwkFromDidUri(header.kid);
52
+ const wrapVerifyPresentationJwt = async (presentationJwt, jwk) => {
53
+ try {
33
54
  return await verifyPresentationJwt(presentationJwt, jwk);
34
55
  } catch (error) {
35
56
  throw newError(400, `Malformed jwt_vp property: ${error.message}`, {