@pagopa/io-react-native-wallet 1.1.1 → 1.2.2

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.
Files changed (106) hide show
  1. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +3 -1
  2. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  3. package/lib/commonjs/credential/presentation/01-start-flow.js +7 -5
  4. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  5. package/lib/commonjs/credential/presentation/03-get-request-object.js +47 -0
  6. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -0
  7. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +82 -0
  8. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -0
  9. package/lib/commonjs/credential/presentation/05-verify-request-object.js +35 -0
  10. package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -0
  11. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +63 -0
  12. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -0
  13. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +169 -0
  14. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -0
  15. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +202 -0
  16. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -0
  17. package/lib/commonjs/credential/presentation/README.md +43 -4
  18. package/lib/commonjs/credential/presentation/errors.js +52 -1
  19. package/lib/commonjs/credential/presentation/errors.js.map +1 -1
  20. package/lib/commonjs/credential/presentation/index.js +27 -6
  21. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  22. package/lib/commonjs/credential/presentation/types.js +69 -4
  23. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  24. package/lib/commonjs/entity/trust/types.js +4 -1
  25. package/lib/commonjs/entity/trust/types.js.map +1 -1
  26. package/lib/module/credential/issuance/04-complete-user-authorization.js +3 -1
  27. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  28. package/lib/module/credential/presentation/01-start-flow.js +8 -6
  29. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  30. package/lib/module/credential/presentation/03-get-request-object.js +39 -0
  31. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -0
  32. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +75 -0
  33. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -0
  34. package/lib/module/credential/presentation/05-verify-request-object.js +28 -0
  35. package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -0
  36. package/lib/module/credential/presentation/06-fetch-presentation-definition.js +56 -0
  37. package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -0
  38. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +161 -0
  39. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -0
  40. package/lib/module/credential/presentation/08-send-authorization-response.js +188 -0
  41. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -0
  42. package/lib/module/credential/presentation/README.md +43 -4
  43. package/lib/module/credential/presentation/errors.js +48 -0
  44. package/lib/module/credential/presentation/errors.js.map +1 -1
  45. package/lib/module/credential/presentation/index.js +7 -4
  46. package/lib/module/credential/presentation/index.js.map +1 -1
  47. package/lib/module/credential/presentation/types.js +67 -3
  48. package/lib/module/credential/presentation/types.js.map +1 -1
  49. package/lib/module/entity/trust/types.js +4 -1
  50. package/lib/module/entity/trust/types.js.map +1 -1
  51. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +1 -1
  52. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  53. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
  54. package/lib/typescript/credential/presentation/{04-get-request-object.d.ts → 03-get-request-object.d.ts} +3 -5
  55. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -0
  56. package/lib/typescript/credential/presentation/{03-retrieve-jwks.d.ts → 04-retrieve-rp-jwks.d.ts} +5 -4
  57. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -0
  58. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +8 -0
  59. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -0
  60. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +26 -0
  61. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -0
  62. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +27 -0
  63. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -0
  64. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +99 -0
  65. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -0
  66. package/lib/typescript/credential/presentation/errors.d.ts +33 -0
  67. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
  68. package/lib/typescript/credential/presentation/index.d.ts +8 -5
  69. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  70. package/lib/typescript/credential/presentation/types.d.ts +612 -9
  71. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  72. package/lib/typescript/entity/trust/index.d.ts +152 -0
  73. package/lib/typescript/entity/trust/index.d.ts.map +1 -1
  74. package/lib/typescript/entity/trust/types.d.ts +2088 -0
  75. package/lib/typescript/entity/trust/types.d.ts.map +1 -1
  76. package/package.json +5 -1
  77. package/src/credential/issuance/04-complete-user-authorization.ts +2 -2
  78. package/src/credential/presentation/01-start-flow.ts +10 -6
  79. package/src/credential/presentation/{04-get-request-object.ts → 03-get-request-object.ts} +6 -51
  80. package/src/credential/presentation/{03-retrieve-jwks.ts → 04-retrieve-rp-jwks.ts} +39 -24
  81. package/src/credential/presentation/05-verify-request-object.ts +35 -0
  82. package/src/credential/presentation/06-fetch-presentation-definition.ts +78 -0
  83. package/src/credential/presentation/07-evaluate-input-descriptor.ts +204 -0
  84. package/src/credential/presentation/08-send-authorization-response.ts +251 -0
  85. package/src/credential/presentation/README.md +43 -4
  86. package/src/credential/presentation/errors.ts +48 -0
  87. package/src/credential/presentation/index.ts +27 -9
  88. package/src/credential/presentation/types.ts +59 -3
  89. package/src/entity/trust/types.ts +3 -0
  90. package/lib/commonjs/credential/presentation/03-retrieve-jwks.js +0 -68
  91. package/lib/commonjs/credential/presentation/03-retrieve-jwks.js.map +0 -1
  92. package/lib/commonjs/credential/presentation/04-get-request-object.js +0 -82
  93. package/lib/commonjs/credential/presentation/04-get-request-object.js.map +0 -1
  94. package/lib/commonjs/credential/presentation/05-send-authorization-response.js +0 -139
  95. package/lib/commonjs/credential/presentation/05-send-authorization-response.js.map +0 -1
  96. package/lib/module/credential/presentation/03-retrieve-jwks.js +0 -61
  97. package/lib/module/credential/presentation/03-retrieve-jwks.js.map +0 -1
  98. package/lib/module/credential/presentation/04-get-request-object.js +0 -74
  99. package/lib/module/credential/presentation/04-get-request-object.js.map +0 -1
  100. package/lib/module/credential/presentation/05-send-authorization-response.js +0 -128
  101. package/lib/module/credential/presentation/05-send-authorization-response.js.map +0 -1
  102. package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts.map +0 -1
  103. package/lib/typescript/credential/presentation/04-get-request-object.d.ts.map +0 -1
  104. package/lib/typescript/credential/presentation/05-send-authorization-response.d.ts +0 -34
  105. package/lib/typescript/credential/presentation/05-send-authorization-response.d.ts.map +0 -1
  106. package/src/credential/presentation/05-send-authorization-response.ts +0 -168
@@ -27,7 +27,9 @@ export const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerCo
27
27
  const params = new URLSearchParams({
28
28
  client_id: clientId,
29
29
  request_uri: issuerRequestUri,
30
- idphint: idpHint
30
+ ...(idpHint && {
31
+ idphint: idpHint
32
+ })
31
33
  });
32
34
  const authUrl = `${authzRequestEndpoint}?${params}`;
33
35
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","requestObject","toString","method","then","res","text","jws","reqObj","safeParse","payload","success","message","reason","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","JSON","stringify","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAEnB,kBAAkB;AACzB,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SACEC,MAAM,EACNC,YAAY,EACZC,OAAO,QAEF,6BAA6B;AACpC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,UAAU;;AAEpE;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAA4C,GAAG,MAAAA,CA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IAAInC,qBAAqB,CAC7BoF,OAAO,CAAC9C,IAAI,CAACD,KAAK,EAClB+C,OAAO,CAAC9C,IAAI,CAAC+C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC7C,IAAI;AAC3B,CAAC"}
1
+ {"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","requestObject","toString","method","then","res","text","jws","reqObj","safeParse","payload","success","message","reason","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","JSON","stringify","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAEnB,kBAAkB;AACzB,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SACEC,MAAM,EACNC,YAAY,EACZC,OAAO,QAEF,6BAA6B;AACpC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,OAAOC,IAAI,MAAM,mBAAmB;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;EACjE,IAAI,CAACC,aAAa,CAACjD,OAAO,EAAE;IAC1B,MAAMkD,OAAO,GAAGlG,uBAAuB,CAAC8C,SAAS,CAACkD,OAAO,CAAC;IAC1D,IAAI,CAACE,OAAO,CAAClD,OAAO,EAAE;MACpB,MAAM,IAAInC,kBAAkB,CAACoF,aAAa,CAAC9C,KAAK,CAACF,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACA,MAAM,IAAInC,qBAAqB,CAC7BoF,OAAO,CAAC9C,IAAI,CAACD,KAAK,EAClB+C,OAAO,CAAC9C,IAAI,CAAC+C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC7C,IAAI;AAC3B,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import * as z from "zod";
2
- import { decodeBase64 } from "@pagopa/io-react-native-jwt";
3
- import { AuthRequestDecodeError } from "./errors";
2
+ import { InvalidQRCodeError } from "./errors";
4
3
  const QRCodePayload = z.object({
5
4
  protocol: z.string(),
6
5
  resource: z.string(),
@@ -27,10 +26,13 @@ const QRCodePayload = z.object({
27
26
  export const startFlowFromQR = qrcode => {
28
27
  let decodedUrl;
29
28
  try {
30
- const decoded = decodeBase64(qrcode);
31
- decodedUrl = new URL(decoded);
29
+ var _originalQrCode$;
30
+ // splitting qrcode to identify which is link format
31
+ const originalQrCode = qrcode.split("://");
32
+ const replacedQrcode = (_originalQrCode$ = originalQrCode[1]) !== null && _originalQrCode$ !== void 0 && _originalQrCode$.startsWith("?") ? qrcode.replace(`${originalQrCode[0]}://`, "https://wallet.example/") : qrcode;
33
+ decodedUrl = new URL(replacedQrcode);
32
34
  } catch (error) {
33
- throw new AuthRequestDecodeError("Failed to decode QR code: ", qrcode);
35
+ throw new InvalidQRCodeError(`Failed to decode QR code: ${qrcode}`);
34
36
  }
35
37
  const protocol = decodedUrl.protocol;
36
38
  const resource = decodedUrl.hostname;
@@ -45,7 +47,7 @@ export const startFlowFromQR = qrcode => {
45
47
  if (result.success) {
46
48
  return result.data;
47
49
  } else {
48
- throw new AuthRequestDecodeError(result.error.message, `${decodedUrl}`);
50
+ throw new InvalidQRCodeError(`${result.error.message}, ${decodedUrl}`);
49
51
  }
50
52
  };
51
53
  //# sourceMappingURL=01-start-flow.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["z","decodeBase64","AuthRequestDecodeError","QRCodePayload","object","protocol","string","resource","clientId","requestURI","startFlowFromQR","qrcode","decodedUrl","decoded","URL","error","hostname","searchParams","get","result","safeParse","success","data","message"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,sBAAsB,QAAQ,UAAU;AAEjD,MAAMC,aAAa,GAAGH,CAAC,CAACI,MAAM,CAAC;EAC7BC,QAAQ,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EACpBC,QAAQ,EAAEP,CAAC,CAACM,MAAM,CAAC,CAAC;EAAE;EACtBE,QAAQ,EAAER,CAAC,CAACM,MAAM,CAAC,CAAC;EACpBG,UAAU,EAAET,CAAC,CAACM,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,eAAoC,GAAIC,MAAM,IAAK;EAC9D,IAAIC,UAAe;EACnB,IAAI;IACF,MAAMC,OAAO,GAAGZ,YAAY,CAACU,MAAM,CAAC;IACpCC,UAAU,GAAG,IAAIE,GAAG,CAACD,OAAO,CAAC;EAC/B,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd,MAAM,IAAIb,sBAAsB,CAAC,4BAA4B,EAAES,MAAM,CAAC;EACxE;EAEA,MAAMN,QAAQ,GAAGO,UAAU,CAACP,QAAQ;EACpC,MAAME,QAAQ,GAAGK,UAAU,CAACI,QAAQ;EACpC,MAAMP,UAAU,GAAGG,UAAU,CAACK,YAAY,CAACC,GAAG,CAAC,aAAa,CAAC;EAC7D,MAAMV,QAAQ,GAAGI,UAAU,CAACK,YAAY,CAACC,GAAG,CAAC,WAAW,CAAC;EAEzD,MAAMC,MAAM,GAAGhB,aAAa,CAACiB,SAAS,CAAC;IACrCf,QAAQ;IACRE,QAAQ;IACRE,UAAU;IACVD;EACF,CAAC,CAAC;EAEF,IAAIW,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB,CAAC,MAAM;IACL,MAAM,IAAIpB,sBAAsB,CAACiB,MAAM,CAACJ,KAAK,CAACQ,OAAO,EAAG,GAAEX,UAAW,EAAC,CAAC;EACzE;AACF,CAAC"}
1
+ {"version":3,"names":["z","InvalidQRCodeError","QRCodePayload","object","protocol","string","resource","clientId","requestURI","startFlowFromQR","qrcode","decodedUrl","_originalQrCode$","originalQrCode","split","replacedQrcode","startsWith","replace","URL","error","hostname","searchParams","get","result","safeParse","success","data","message"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,SAASC,kBAAkB,QAAQ,UAAU;AAE7C,MAAMC,aAAa,GAAGF,CAAC,CAACG,MAAM,CAAC;EAC7BC,QAAQ,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC;EACpBC,QAAQ,EAAEN,CAAC,CAACK,MAAM,CAAC,CAAC;EAAE;EACtBE,QAAQ,EAAEP,CAAC,CAACK,MAAM,CAAC,CAAC;EACpBG,UAAU,EAAER,CAAC,CAACK,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,eAAoC,GAAIC,MAAM,IAAK;EAC9D,IAAIC,UAAe;EACnB,IAAI;IAAA,IAAAC,gBAAA;IACF;IACA,MAAMC,cAAc,GAAGH,MAAM,CAACI,KAAK,CAAC,KAAK,CAAC;IAC1C,MAAMC,cAAc,GAAG,CAAAH,gBAAA,GAAAC,cAAc,CAAC,CAAC,CAAC,cAAAD,gBAAA,eAAjBA,gBAAA,CAAmBI,UAAU,CAAC,GAAG,CAAC,GACrDN,MAAM,CAACO,OAAO,CAAE,GAAEJ,cAAc,CAAC,CAAC,CAAE,KAAI,EAAE,yBAAyB,CAAC,GACpEH,MAAM;IAEVC,UAAU,GAAG,IAAIO,GAAG,CAACH,cAAc,CAAC;EACtC,CAAC,CAAC,OAAOI,KAAK,EAAE;IACd,MAAM,IAAIlB,kBAAkB,CAAE,8BAA6BS,MAAO,EAAC,CAAC;EACtE;EAEA,MAAMN,QAAQ,GAAGO,UAAU,CAACP,QAAQ;EACpC,MAAME,QAAQ,GAAGK,UAAU,CAACS,QAAQ;EACpC,MAAMZ,UAAU,GAAGG,UAAU,CAACU,YAAY,CAACC,GAAG,CAAC,aAAa,CAAC;EAC7D,MAAMf,QAAQ,GAAGI,UAAU,CAACU,YAAY,CAACC,GAAG,CAAC,WAAW,CAAC;EAEzD,MAAMC,MAAM,GAAGrB,aAAa,CAACsB,SAAS,CAAC;IACrCpB,QAAQ;IACRE,QAAQ;IACRE,UAAU;IACVD;EACF,CAAC,CAAC;EAEF,IAAIgB,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB,CAAC,MAAM;IACL,MAAM,IAAIzB,kBAAkB,CAAE,GAAEsB,MAAM,CAACJ,KAAK,CAACQ,OAAQ,KAAIhB,UAAW,EAAC,CAAC;EACxE;AACF,CAAC"}
@@ -0,0 +1,39 @@
1
+ import uuid from "react-native-uuid";
2
+ import { sha256ToBase64 } from "@pagopa/io-react-native-jwt";
3
+ import { createDPopToken } from "../../utils/dpop";
4
+ import { hasStatusOrThrow } from "../../utils/misc";
5
+ /**
6
+ * Obtain the Request Object for RP authentication
7
+ * @see https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html
8
+ *
9
+ * @param requestUri The url for the Relying Party to connect with
10
+ * @param rpConf The Relying Party's configuration
11
+ * @param context.wiaCryptoContext The context to access the key associated with the Wallet Instance Attestation
12
+ * @param context.walletInstanceAttestation The Wallet Instance Attestation token
13
+ * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
14
+ * @returns The Request Object that describes the presentation
15
+ */
16
+ export const getRequestObject = async (requestUri, _ref) => {
17
+ let {
18
+ wiaCryptoContext,
19
+ appFetch = fetch,
20
+ walletInstanceAttestation
21
+ } = _ref;
22
+ const signedWalletInstanceDPoP = await createDPopToken({
23
+ jti: `${uuid.v4()}`,
24
+ htm: "GET",
25
+ htu: requestUri,
26
+ ath: await sha256ToBase64(walletInstanceAttestation)
27
+ }, wiaCryptoContext);
28
+ const requestObjectEncodedJwt = await appFetch(requestUri, {
29
+ method: "GET",
30
+ headers: {
31
+ Authorization: `DPoP ${walletInstanceAttestation}`,
32
+ DPoP: signedWalletInstanceDPoP
33
+ }
34
+ }).then(hasStatusOrThrow(200)).then(res => res.text());
35
+ return {
36
+ requestObjectEncodedJwt
37
+ };
38
+ };
39
+ //# sourceMappingURL=03-get-request-object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["uuid","sha256ToBase64","createDPopToken","hasStatusOrThrow","getRequestObject","requestUri","_ref","wiaCryptoContext","appFetch","fetch","walletInstanceAttestation","signedWalletInstanceDPoP","jti","v4","htm","htu","ath","requestObjectEncodedJwt","method","headers","Authorization","DPoP","then","res","text"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":"AAAA,OAAOA,IAAI,MAAM,mBAAmB;AACpC,SACEC,cAAc,QAET,6BAA6B;AAEpC,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,gBAAgB,QAAkB,kBAAkB;AAY7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAkC,GAAG,MAAAA,CAChDC,UAAU,EAAAC,IAAA,KAEP;EAAA,IADH;IAAEC,gBAAgB;IAAEC,QAAQ,GAAGC,KAAK;IAAEC;EAA0B,CAAC,GAAAJ,IAAA;EAEjE,MAAMK,wBAAwB,GAAG,MAAMT,eAAe,CACpD;IACEU,GAAG,EAAG,GAAEZ,IAAI,CAACa,EAAE,CAAC,CAAE,EAAC;IACnBC,GAAG,EAAE,KAAK;IACVC,GAAG,EAAEV,UAAU;IACfW,GAAG,EAAE,MAAMf,cAAc,CAACS,yBAAyB;EACrD,CAAC,EACDH,gBACF,CAAC;EAED,MAAMU,uBAAuB,GAAG,MAAMT,QAAQ,CAACH,UAAU,EAAE;IACzDa,MAAM,EAAE,KAAK;IACbC,OAAO,EAAE;MACPC,aAAa,EAAG,QAAOV,yBAA0B,EAAC;MAClDW,IAAI,EAAEV;IACR;EACF,CAAC,CAAC,CACCW,IAAI,CAACnB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAC3BmB,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;EAE5B,OAAO;IACLP;EACF,CAAC;AACH,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { JWKS, JWK } from "../../utils/jwk";
2
+ import { hasStatusOrThrow } from "../../utils/misc";
3
+ import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
4
+ import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
5
+
6
+ /**
7
+ * Defines the signature for a function that retrieves JSON Web Key Sets (JWKS) from a client.
8
+ *
9
+ * @template T - The tuple type representing the function arguments.
10
+ * @param args - The arguments passed to the function.
11
+ * @returns A promise resolving to an object containing an array of JWKs.
12
+ */
13
+
14
+ /**
15
+ * Retrieves the JSON Web Key Set (JWKS) from the specified client's well-known endpoint.
16
+ * It is formed using `{issUrl.base}/.well-known/jar-issuer${issUrl.pah}` as explained in SD-JWT VC issuer metadata section
17
+ *
18
+ * @param requestObjectEncodedJwt - Request Object in JWT format.
19
+ * @param options - Optional context containing a custom fetch implementation.
20
+ * @param options.context - Optional context object.
21
+ * @param options.context.appFetch - Optional custom fetch function to use instead of the global `fetch`.
22
+ * @returns A promise resolving to an object containing an array of JWKs.
23
+ * @throws Will throw an error if the JWKS retrieval fails.
24
+ */
25
+ export const fetchJwksFromRequestObject = async function (requestObjectEncodedJwt) {
26
+ var _requestObjectJwt$pro, _requestObjectJwt$pay;
27
+ let {
28
+ context = {}
29
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30
+ const {
31
+ appFetch = fetch
32
+ } = context;
33
+ const requestObjectJwt = decodeJwt(requestObjectEncodedJwt);
34
+
35
+ // 1. check if request object jwt contains the 'jwk' attribute
36
+ if ((_requestObjectJwt$pro = requestObjectJwt.protectedHeader) !== null && _requestObjectJwt$pro !== void 0 && _requestObjectJwt$pro.jwk) {
37
+ return {
38
+ keys: [JWK.parse(requestObjectJwt.protectedHeader.jwk)]
39
+ };
40
+ }
41
+
42
+ // 2. According to Potential profile, retrieve from RP endpoint using iss claim
43
+ const issClaimValue = (_requestObjectJwt$pay = requestObjectJwt.payload) === null || _requestObjectJwt$pay === void 0 ? void 0 : _requestObjectJwt$pay.iss;
44
+ if (issClaimValue) {
45
+ const issUrl = new URL(issClaimValue);
46
+ const wellKnownUrl = new URL(`/.well-known/jar-issuer${issUrl.pathname}`, `${issUrl.protocol}//${issUrl.host}`).toString();
47
+
48
+ // Fetches the JWKS from a specific endpoint of the entity's well-known configuration
49
+ const jwks = await appFetch(wellKnownUrl, {
50
+ method: "GET"
51
+ }).then(hasStatusOrThrow(200)).then(raw => raw.json()).then(json => JWKS.parse(json.jwks));
52
+ return {
53
+ keys: jwks.keys
54
+ };
55
+ }
56
+ throw new NoSuitableKeysFoundInEntityConfiguration("Request Object signature verification");
57
+ };
58
+
59
+ /**
60
+ * Retrieves the JSON Web Key Set (JWKS) from a Relying Party's entity configuration.
61
+ *
62
+ * @param rpConfig - The configuration object of the Relying Party entity.
63
+ * @returns An object containing an array of JWKs.
64
+ * @throws Will throw an error if the configuration is invalid or if JWKS is not found.
65
+ */
66
+ export const fetchJwksFromConfig = async rpConfig => {
67
+ const jwks = rpConfig.wallet_relying_party.jwks;
68
+ if (!jwks || !Array.isArray(jwks.keys)) {
69
+ throw new Error("JWKS not found in Relying Party configuration.");
70
+ }
71
+ return {
72
+ keys: jwks.keys
73
+ };
74
+ };
75
+ //# sourceMappingURL=04-retrieve-rp-jwks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JWKS","JWK","hasStatusOrThrow","decode","decodeJwt","NoSuitableKeysFoundInEntityConfiguration","fetchJwksFromRequestObject","requestObjectEncodedJwt","_requestObjectJwt$pro","_requestObjectJwt$pay","context","arguments","length","undefined","appFetch","fetch","requestObjectJwt","protectedHeader","jwk","keys","parse","issClaimValue","payload","iss","issUrl","URL","wellKnownUrl","pathname","protocol","host","toString","jwks","method","then","raw","json","fetchJwksFromConfig","rpConfig","wallet_relying_party","Array","isArray","Error"],"sourceRoot":"../../../../src","sources":["credential/presentation/04-retrieve-rp-jwks.ts"],"mappings":"AAAA,SAASA,IAAI,EAAEC,GAAG,QAAQ,iBAAiB;AAC3C,SAASC,gBAAgB,QAAQ,kBAAkB;AAEnD,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,wCAAwC,QAAQ,UAAU;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAEZ,GAAG,eAAAA,CAAOC,uBAAuB,EAA4B;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EAAA,IAA1B;IAAEC,OAAO,GAAG,CAAC;EAAE,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACvD,MAAM;IAAEG,QAAQ,GAAGC;EAAM,CAAC,GAAGL,OAAO;EACpC,MAAMM,gBAAgB,GAAGZ,SAAS,CAACG,uBAAuB,CAAC;;EAE3D;EACA,KAAAC,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CAACZ,IAAI,CAAC,EAAE;IACtC,MAAM,IAAIsB,KAAK,CAAC,gDAAgD,CAAC;EACnE;EAEA,OAAO;IACLtB,IAAI,EAAEY,IAAI,CAACZ;EACb,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { UnverifiedEntityError } from "./errors";
2
+ import { decode as decodeJwt, verify } from "@pagopa/io-react-native-jwt";
3
+ import { RequestObject } from "./types";
4
+ export const verifyRequestObjectSignature = async (requestObjectEncodedJwt, jwkKeys) => {
5
+ const requestObjectJwt = decodeJwt(requestObjectEncodedJwt);
6
+
7
+ // verify token signature to ensure the request object is authentic
8
+ const pubKey = jwkKeys === null || jwkKeys === void 0 ? void 0 : jwkKeys.find(_ref => {
9
+ let {
10
+ kid
11
+ } = _ref;
12
+ return kid === requestObjectJwt.protectedHeader.kid;
13
+ });
14
+ if (!pubKey) {
15
+ throw new UnverifiedEntityError("Request Object signature verification!");
16
+ }
17
+ await verify(requestObjectEncodedJwt, pubKey);
18
+ const requestObject = RequestObject.parse(requestObjectJwt.payload);
19
+ // Check if exp exists and is expired
20
+ // exp is typically in seconds since epoch, Get current time in seconds
21
+ if (requestObject.exp && requestObject.exp <= Date.now() / 1000) {
22
+ throw new UnverifiedEntityError("Request Object is expired!");
23
+ }
24
+ return {
25
+ requestObject
26
+ };
27
+ };
28
+ //# sourceMappingURL=05-verify-request-object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnverifiedEntityError","decode","decodeJwt","verify","RequestObject","verifyRequestObjectSignature","requestObjectEncodedJwt","jwkKeys","requestObjectJwt","pubKey","find","_ref","kid","protectedHeader","requestObject","parse","payload","exp","Date","now"],"sourceRoot":"../../../../src","sources":["credential/presentation/05-verify-request-object.ts"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,UAAU;AAEhD,SAASC,MAAM,IAAIC,SAAS,EAAEC,MAAM,QAAQ,6BAA6B;AACzE,SAASC,aAAa,QAAQ,SAAS;AASvC,OAAO,MAAMC,4BAA0D,GACrE,MAAAA,CAAOC,uBAAuB,EAAEC,OAAO,KAAK;EAC1C,MAAMC,gBAAgB,GAAGN,SAAS,CAACI,uBAAuB,CAAC;;EAE3D;EACA,MAAMG,MAAM,GAAGF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,IAAI,CAC1BC,IAAA;IAAA,IAAC;MAAEC;IAAI,CAAC,GAAAD,IAAA;IAAA,OAAKC,GAAG,KAAKJ,gBAAgB,CAACK,eAAe,CAACD,GAAG;EAAA,CAC3D,CAAC;EAED,IAAI,CAACH,MAAM,EAAE;IACX,MAAM,IAAIT,qBAAqB,CAAC,wCAAwC,CAAC;EAC3E;EACA,MAAMG,MAAM,CAACG,uBAAuB,EAAEG,MAAM,CAAC;EAE7C,MAAMK,aAAa,GAAGV,aAAa,CAACW,KAAK,CAACP,gBAAgB,CAACQ,OAAO,CAAC;EACnE;EACA;EACA,IAAIF,aAAa,CAACG,GAAG,IAAIH,aAAa,CAACG,GAAG,IAAIC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE;IAC/D,MAAM,IAAInB,qBAAqB,CAAC,4BAA4B,CAAC;EAC/D;EAEA,OAAO;IAAEc;EAAc,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { PresentationDefinition } from "./types";
2
+ import { hasStatusOrThrow } from "../../utils/misc";
3
+ /**
4
+ * Retrieves a PresentationDefinition based on the given parameters.
5
+ *
6
+ * The method attempts the following strategies in order:
7
+ * 1. Checks if `presentation_definition` is directly available in the request object.
8
+ * 2. Fetches the `presentation_definition` from the URI provided in the relying party configuration.
9
+ * 3. Uses a pre-configured `presentation_definition` from the relying party configuration if the `scope` is present in the request object.
10
+ *
11
+ * If none of the above conditions are met, the function throws an error indicating the definition could not be found.
12
+ *
13
+ * @param {RequestObject} requestObject - The request object containing the presentation definition or references to it.
14
+ * @param {RelyingPartyEntityConfiguration["payload"]["metadata"]} [rpConf] - Optional relying party configuration.
15
+ * @param {Object} [context] - Optional context for providing a custom fetch implementation.
16
+ * @param {GlobalFetch["fetch"]} [context.appFetch] - Custom fetch function, defaults to global `fetch`.
17
+ * @returns {Promise<{ presentationDefinition: PresentationDefinition }>} - Resolves with the presentation definition.
18
+ * @throws {Error} - Throws if the presentation definition cannot be found or fetched.
19
+ */
20
+ export const fetchPresentDefinition = async function (requestObject) {
21
+ var _rpConf$wallet_relyin, _rpConf$wallet_relyin2;
22
+ let {
23
+ appFetch = fetch
24
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25
+ let rpConf = arguments.length > 2 ? arguments[2] : undefined;
26
+ // Check if `presentation_definition` is directly available in the request object
27
+ if (requestObject.presentation_definition) {
28
+ return {
29
+ presentationDefinition: requestObject.presentation_definition
30
+ };
31
+ }
32
+
33
+ // Check if `presentation_definition_uri` is provided in the relying party configuration
34
+ if (rpConf !== null && rpConf !== void 0 && (_rpConf$wallet_relyin = rpConf.wallet_relying_party) !== null && _rpConf$wallet_relyin !== void 0 && _rpConf$wallet_relyin.presentation_definition_uri) {
35
+ try {
36
+ // Fetch the presentation definition from the provided URI
37
+ const presentationDefinition = await appFetch(rpConf === null || rpConf === void 0 ? void 0 : rpConf.wallet_relying_party.presentation_definition_uri, {
38
+ method: "GET"
39
+ }).then(hasStatusOrThrow(200)).then(raw => raw.json()).then(json => PresentationDefinition.parse(json));
40
+ return {
41
+ presentationDefinition
42
+ };
43
+ } catch (error) {
44
+ throw new Error(`Failed to fetch presentation definition: ${error}`);
45
+ }
46
+ }
47
+
48
+ // Check if `scope` is present in the request object and a pre-configured presentation definition exists
49
+ if (requestObject.scope && rpConf !== null && rpConf !== void 0 && (_rpConf$wallet_relyin2 = rpConf.wallet_relying_party) !== null && _rpConf$wallet_relyin2 !== void 0 && _rpConf$wallet_relyin2.presentation_definition) {
50
+ return {
51
+ presentationDefinition: rpConf.wallet_relying_party.presentation_definition
52
+ };
53
+ }
54
+ throw new Error("Presentation definition not found");
55
+ };
56
+ //# sourceMappingURL=06-fetch-presentation-definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PresentationDefinition","hasStatusOrThrow","fetchPresentDefinition","requestObject","_rpConf$wallet_relyin","_rpConf$wallet_relyin2","appFetch","fetch","arguments","length","undefined","rpConf","presentation_definition","presentationDefinition","wallet_relying_party","presentation_definition_uri","method","then","raw","json","parse","error","Error","scope"],"sourceRoot":"../../../../src","sources":["credential/presentation/06-fetch-presentation-definition.ts"],"mappings":"AAAA,SAASA,sBAAsB,QAAuB,SAAS;AAE/D,SAASC,gBAAgB,QAAQ,kBAAkB;AAYnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAmD,GAAG,eAAAA,CACjEC,aAAa,EAGV;EAAA,IAAAC,qBAAA,EAAAC,sBAAA;EAAA,IAFH;IAAEC,QAAQ,GAAGC;EAAM,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAAA,IACzBG,MAAM,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEN;EACA,IAAIP,aAAa,CAACS,uBAAuB,EAAE;IACzC,OAAO;MACLC,sBAAsB,EAAEV,aAAa,CAACS;IACxC,CAAC;EACH;;EAEA;EACA,IAAID,MAAM,aAANA,MAAM,gBAAAP,qBAAA,GAANO,MAAM,CAAEG,oBAAoB,cAAAV,qBAAA,eAA5BA,qBAAA,CAA8BW,2BAA2B,EAAE;IAC7D,IAAI;MACF;MACA,MAAMF,sBAAsB,GAAG,MAAMP,QAAQ,CAC3CK,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEG,oBAAoB,CAACC,2BAA2B,EACxD;QACEC,MAAM,EAAE;MACV,CACF,CAAC,CACEC,IAAI,CAAChB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAC3BgB,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEE,IAAI,IAAKnB,sBAAsB,CAACoB,KAAK,CAACD,IAAI,CAAC,CAAC;MAErD,OAAO;QACLN;MACF,CAAC;IACH,CAAC,CAAC,OAAOQ,KAAK,EAAE;MACd,MAAM,IAAIC,KAAK,CAAE,4CAA2CD,KAAM,EAAC,CAAC;IACtE;EACF;;EAEA;EACA,IACElB,aAAa,CAACoB,KAAK,IACnBZ,MAAM,aAANA,MAAM,gBAAAN,sBAAA,GAANM,MAAM,CAAEG,oBAAoB,cAAAT,sBAAA,eAA5BA,sBAAA,CAA8BO,uBAAuB,EACrD;IACA,OAAO;MACLC,sBAAsB,EACpBF,MAAM,CAACG,oBAAoB,CAACF;IAChC,CAAC;EACH;EAEA,MAAM,IAAIU,KAAK,CAAC,mCAAmC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,161 @@
1
+ import { JSONPath } from "jsonpath-plus";
2
+ import { MissingDataError } from "./errors";
3
+ import Ajv from "ajv";
4
+ const ajv = new Ajv({
5
+ allErrors: true
6
+ });
7
+ const INDEX_CLAIM_NAME = 1;
8
+ /**
9
+ * Transforms an array of DisclosureWithEncoded objects into a key-value map.
10
+ * @param disclosures - An array of DisclosureWithEncoded, each containing a decoded property with [?, claimName, claimValue].
11
+ * @returns An object mapping claim names to their corresponding values.
12
+ */
13
+ const mapDisclosuresToObject = disclosures => {
14
+ return disclosures.reduce((obj, _ref) => {
15
+ let {
16
+ decoded
17
+ } = _ref;
18
+ const [, claimName, claimValue] = decoded;
19
+ obj[claimName] = claimValue;
20
+ return obj;
21
+ }, {});
22
+ };
23
+
24
+ /**
25
+ * Finds a claim within the payload based on provided JSONPath expressions.
26
+ * @param paths - An array of JSONPath expressions to search for in the payload.
27
+ * @param payload - The object to search within using JSONPath.
28
+ * @returns A tuple with the first matched JSONPath and its corresponding value, or [undefined, undefined] if not found.
29
+ */
30
+ const findMatchedClaim = (paths, payload) => {
31
+ let matchedPath;
32
+ let matchedValue;
33
+ paths.some(singlePath => {
34
+ try {
35
+ const result = JSONPath({
36
+ path: singlePath,
37
+ json: payload
38
+ });
39
+ if (result.length > 0) {
40
+ matchedPath = singlePath;
41
+ matchedValue = result[0];
42
+ return true;
43
+ }
44
+ } catch (error) {
45
+ throw new MissingDataError(`JSONPath for "${singlePath}" does not match the provided payload.`);
46
+ }
47
+ return false;
48
+ });
49
+ return [matchedPath, matchedValue];
50
+ };
51
+
52
+ /**
53
+ * Extracts the claim name from a path that can be in one of the following formats:
54
+ * 1. $.propertyName
55
+ * 2. $["propertyName"] or $['propertyName']
56
+ *
57
+ * @param path - The path string containing the claim reference.
58
+ * @returns The extracted claim name if matched; otherwise, throws an exception.
59
+ */
60
+ const extractClaimName = path => {
61
+ // Define a regular expression that matches both formats:
62
+ // 1. $.propertyName
63
+ // 2. $["propertyName"] or $['propertyName']
64
+ const regex = /^\$\.(\w+)$|^\$\[(?:'|")(\w+)(?:'|")\]$/;
65
+ const match = path.match(regex);
66
+ if (match) {
67
+ // match[1] corresponds to the first capture group (\w+) after $.
68
+ // match[2] corresponds to the second capture group (\w+) inside [""] or ['']
69
+ return match[1] || match[2];
70
+ }
71
+
72
+ // If the input doesn't match any of the expected formats, return null
73
+
74
+ throw new Error(`Invalid input format: "${path}". Expected formats are "$.propertyName", "$['propertyName']", or '$["propertyName"]'.`);
75
+ };
76
+
77
+ /**
78
+ * Evaluates an InputDescriptor for an SD-JWT-based verifiable credential.
79
+ *
80
+ * - Checks each field in the InputDescriptor against the provided `payloadCredential`
81
+ * and `disclosures` (selectively disclosed claims).
82
+ * - Validates whether required fields are present (unless marked optional)
83
+ * and match any specified JSONPath.
84
+ * - If a field includes a JSON Schema filter, validates the claim value against that schema.
85
+ * - Enforces `limit_disclosure` rules by returning only disclosures matching the specified fields
86
+ * if set to "required". Otherwise return the array of all disclosures.
87
+ * - Throws an error if a required field is invalid or missing.
88
+ *
89
+ * @param inputDescriptor - Describes constraints (fields, filters, etc.) that must be satisfied.
90
+ * @param payloadCredential - The credential payload to check against.
91
+ * @param disclosures - An array of DisclosureWithEncoded objects representing selective disclosures.
92
+ * @returns A filtered list of disclosures satisfying the descriptor constraints, or throws an error if not.
93
+ * @throws Will throw an error if any required constraint fails or if JSONPath lookups are invalid.
94
+ */
95
+ export const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential, disclosures) => {
96
+ var _inputDescriptor$cons;
97
+ if (!(inputDescriptor !== null && inputDescriptor !== void 0 && (_inputDescriptor$cons = inputDescriptor.constraints) !== null && _inputDescriptor$cons !== void 0 && _inputDescriptor$cons.fields)) {
98
+ // No validation, all field are optional
99
+ return {
100
+ requiredDisclosures: [],
101
+ optionalDisclosures: disclosures
102
+ };
103
+ }
104
+ const requiredClaimNames = [];
105
+ const optionalClaimNames = [];
106
+
107
+ // Transform disclosures to find claim using JSONPath
108
+ const disclosuresAsPayload = mapDisclosuresToObject(disclosures);
109
+
110
+ // For each field, we need at least one matching path
111
+ // If we succeed, we push the matched disclosure in matchedDisclosures and stop checking further paths
112
+ const allFieldsValid = inputDescriptor.constraints.fields.every(field => {
113
+ // For Potential profile, selectively disclosed claims will always be built as an individual object property, by using a name-value pair.
114
+ // Hence that selective claim for array element and recursive disclosures are not supported by Potential for the first iteration of Piloting.
115
+ // We need to check inside disclosures or inside credential payload. Example path: "$.given_name"
116
+ let [matchedPath, matchedValue] = findMatchedClaim(field.path, disclosuresAsPayload);
117
+ if (!matchedPath) {
118
+ [matchedPath, matchedValue] = findMatchedClaim(field.path, payloadCredential);
119
+ if (!matchedPath) {
120
+ // Path could be optional, in this case no need to validate! continue to next field
121
+ return field === null || field === void 0 ? void 0 : field.optional;
122
+ }
123
+ } else {
124
+ // if match a disclouse we save which is required or optional
125
+ const claimName = extractClaimName(matchedPath);
126
+ if (claimName) {
127
+ (field !== null && field !== void 0 && field.optional ? optionalClaimNames : requiredClaimNames).push(claimName);
128
+ }
129
+ }
130
+
131
+ // FILTER validation
132
+ // If this field has a "filter" (JSON Schema), validate the claimValue
133
+ if (field.filter) {
134
+ try {
135
+ const validateSchema = ajv.compile(field.filter);
136
+ if (!validateSchema(matchedValue)) {
137
+ throw new MissingDataError(`Claim value "${matchedValue}" for path "${matchedPath}" does not match the provided JSON Schema.`);
138
+ }
139
+ } catch (error) {
140
+ return false;
141
+ }
142
+ }
143
+ // Submission Requirements validation
144
+ // TODO: [EUDIW-216] Read rule value if “all” o “pick” and validate
145
+
146
+ return true;
147
+ });
148
+ if (!allFieldsValid) {
149
+ throw new MissingDataError("Credential validation failed: Required fields are missing or do not match the input descriptor.");
150
+ }
151
+
152
+ // Categorizes disclosures into required and optional based on claim names and disclosure constraints.
153
+ const isNotLimitDisclosure = !(inputDescriptor.constraints.limit_disclosure === "required");
154
+ const requiredDisclosures = disclosures.filter(disclosure => requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]));
155
+ const optionalDisclosures = disclosures.filter(disclosure => optionalClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]) || isNotLimitDisclosure && !requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]));
156
+ return {
157
+ requiredDisclosures,
158
+ optionalDisclosures
159
+ };
160
+ };
161
+ //# sourceMappingURL=07-evaluate-input-descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JSONPath","MissingDataError","Ajv","ajv","allErrors","INDEX_CLAIM_NAME","mapDisclosuresToObject","disclosures","reduce","obj","_ref","decoded","claimName","claimValue","findMatchedClaim","paths","payload","matchedPath","matchedValue","some","singlePath","result","path","json","length","error","extractClaimName","regex","match","Error","evaluateInputDescriptorForSdJwt4VC","inputDescriptor","payloadCredential","_inputDescriptor$cons","constraints","fields","requiredDisclosures","optionalDisclosures","requiredClaimNames","optionalClaimNames","disclosuresAsPayload","allFieldsValid","every","field","optional","push","filter","validateSchema","compile","isNotLimitDisclosure","limit_disclosure","disclosure","includes"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-input-descriptor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