@pagopa/io-react-native-wallet 3.1.2 → 3.3.0

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 (360) hide show
  1. package/lib/commonjs/credential/issuance/README.md +44 -17
  2. package/lib/commonjs/credential/issuance/common/02-start-user-authorization.js +4 -3
  3. package/lib/commonjs/credential/issuance/common/02-start-user-authorization.js.map +1 -1
  4. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js +37 -8
  5. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js.map +1 -1
  6. package/lib/commonjs/credential/issuance/mrtd-pop/02-init-challenge.js +46 -38
  7. package/lib/commonjs/credential/issuance/mrtd-pop/02-init-challenge.js.map +1 -1
  8. package/lib/commonjs/credential/issuance/mrtd-pop/03-validate-challenge.js +58 -51
  9. package/lib/commonjs/credential/issuance/mrtd-pop/03-validate-challenge.js.map +1 -1
  10. package/lib/commonjs/credential/issuance/mrtd-pop/index.js +21 -5
  11. package/lib/commonjs/credential/issuance/mrtd-pop/index.js.map +1 -1
  12. package/lib/commonjs/credential/issuance/v1.0.0/02-start-user-authorization.js +3 -3
  13. package/lib/commonjs/credential/issuance/v1.0.0/02-start-user-authorization.js.map +1 -1
  14. package/lib/commonjs/credential/issuance/v1.0.0/03-complete-user-authorization.js +5 -2
  15. package/lib/commonjs/credential/issuance/v1.0.0/03-complete-user-authorization.js.map +1 -1
  16. package/lib/commonjs/credential/issuance/v1.0.0/05-obtain-credential.js +5 -1
  17. package/lib/commonjs/credential/issuance/v1.0.0/05-obtain-credential.js.map +1 -1
  18. package/lib/commonjs/credential/issuance/v1.0.0/index.js +2 -1
  19. package/lib/commonjs/credential/issuance/v1.0.0/index.js.map +1 -1
  20. package/lib/commonjs/credential/issuance/v1.0.0/mappers.js +1 -1
  21. package/lib/commonjs/credential/issuance/v1.0.0/mappers.js.map +1 -1
  22. package/lib/commonjs/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js +0 -2
  23. package/lib/commonjs/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js.map +1 -1
  24. package/lib/commonjs/credential/issuance/v1.3.3/02-start-user-authorization.js +20 -16
  25. package/lib/commonjs/credential/issuance/v1.3.3/02-start-user-authorization.js.map +1 -1
  26. package/lib/commonjs/credential/issuance/v1.3.3/03-complete-user-authorization.js +1 -1
  27. package/lib/commonjs/credential/issuance/v1.3.3/03-complete-user-authorization.js.map +1 -1
  28. package/lib/commonjs/credential/issuance/v1.3.3/04-authorize-access.js +20 -19
  29. package/lib/commonjs/credential/issuance/v1.3.3/04-authorize-access.js.map +1 -1
  30. package/lib/commonjs/credential/issuance/v1.3.3/05-obtain-credential.js +150 -57
  31. package/lib/commonjs/credential/issuance/v1.3.3/05-obtain-credential.js.map +1 -1
  32. package/lib/commonjs/credential/issuance/v1.3.3/06-verify-and-parse-credential.js +4 -1
  33. package/lib/commonjs/credential/issuance/v1.3.3/06-verify-and-parse-credential.js.map +1 -1
  34. package/lib/commonjs/credential/issuance/v1.3.3/index.js +2 -1
  35. package/lib/commonjs/credential/issuance/v1.3.3/index.js.map +1 -1
  36. package/lib/commonjs/credential/issuance/v1.3.3/mappers.js +1 -1
  37. package/lib/commonjs/credential/issuance/v1.3.3/mappers.js.map +1 -1
  38. package/lib/commonjs/credential/presentation/api/types.js.map +1 -1
  39. package/lib/commonjs/credential/presentation/{v1.3.3/utils.mdoc.js → common/utils/mdoc.js} +2 -2
  40. package/lib/commonjs/credential/presentation/common/utils/mdoc.js.map +1 -0
  41. package/lib/commonjs/credential/presentation/v1.0.0/05-verify-request-object.js +18 -12
  42. package/lib/commonjs/credential/presentation/v1.0.0/05-verify-request-object.js.map +1 -1
  43. package/lib/commonjs/credential/presentation/v1.0.0/07-send-authorization-response.js +3 -0
  44. package/lib/commonjs/credential/presentation/v1.0.0/07-send-authorization-response.js.map +1 -1
  45. package/lib/commonjs/credential/presentation/v1.0.0/index.js +0 -2
  46. package/lib/commonjs/credential/presentation/v1.0.0/index.js.map +1 -1
  47. package/lib/commonjs/credential/presentation/v1.0.0/mappers.js +23 -13
  48. package/lib/commonjs/credential/presentation/v1.0.0/mappers.js.map +1 -1
  49. package/lib/commonjs/credential/presentation/v1.0.0/types.js +25 -17
  50. package/lib/commonjs/credential/presentation/v1.0.0/types.js.map +1 -1
  51. package/lib/commonjs/credential/presentation/v1.3.3/05-verify-request-object.js +29 -6
  52. package/lib/commonjs/credential/presentation/v1.3.3/05-verify-request-object.js.map +1 -1
  53. package/lib/commonjs/credential/presentation/v1.3.3/06-evaluate-dcql-query.js +2 -2
  54. package/lib/commonjs/credential/presentation/v1.3.3/06-evaluate-dcql-query.js.map +1 -1
  55. package/lib/commonjs/credential/presentation/v1.3.3/07-send-authorization-response.js +9 -6
  56. package/lib/commonjs/credential/presentation/v1.3.3/07-send-authorization-response.js.map +1 -1
  57. package/lib/commonjs/credential/presentation/v1.3.3/mappers.js +25 -13
  58. package/lib/commonjs/credential/presentation/v1.3.3/mappers.js.map +1 -1
  59. package/lib/commonjs/credential/presentation/v1.3.3/types.js +6 -3
  60. package/lib/commonjs/credential/presentation/v1.3.3/types.js.map +1 -1
  61. package/lib/commonjs/credential/status/README.md +3 -2
  62. package/lib/commonjs/credential/status/v1.3.3/01-status-list.js +27 -5
  63. package/lib/commonjs/credential/status/v1.3.3/01-status-list.js.map +1 -1
  64. package/lib/commonjs/credential/status/v1.3.3/02-verify-and-parse-status-list.js +17 -6
  65. package/lib/commonjs/credential/status/v1.3.3/02-verify-and-parse-status-list.js.map +1 -1
  66. package/lib/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.js +26 -1
  67. package/lib/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.js.map +1 -1
  68. package/lib/commonjs/credentials-catalogue/v1.3.3/fetch-and-parse-catalogue.js +4 -0
  69. package/lib/commonjs/credentials-catalogue/v1.3.3/fetch-and-parse-catalogue.js.map +1 -1
  70. package/lib/commonjs/credentials-catalogue/v1.3.3/fetch-translations.js +5 -3
  71. package/lib/commonjs/credentials-catalogue/v1.3.3/fetch-translations.js.map +1 -1
  72. package/lib/commonjs/credentials-catalogue/v1.3.3/mappers.js +9 -1
  73. package/lib/commonjs/credentials-catalogue/v1.3.3/mappers.js.map +1 -1
  74. package/lib/commonjs/credentials-catalogue/v1.3.3/types.js +49 -1
  75. package/lib/commonjs/credentials-catalogue/v1.3.3/types.js.map +1 -1
  76. package/lib/commonjs/mdoc/index.js +3 -24
  77. package/lib/commonjs/mdoc/index.js.map +1 -1
  78. package/lib/commonjs/sd-jwt/__test__/types.test.js +2 -14
  79. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  80. package/lib/commonjs/sd-jwt/__test__/utils.test.js +0 -12
  81. package/lib/commonjs/sd-jwt/__test__/utils.test.js.map +1 -1
  82. package/lib/commonjs/sd-jwt/types.js +1 -14
  83. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  84. package/lib/commonjs/utils/callbacks.js +45 -7
  85. package/lib/commonjs/utils/callbacks.js.map +1 -1
  86. package/lib/commonjs/utils/crypto.js +58 -5
  87. package/lib/commonjs/utils/crypto.js.map +1 -1
  88. package/lib/commonjs/utils/x509.js +34 -0
  89. package/lib/commonjs/utils/x509.js.map +1 -0
  90. package/lib/commonjs/wallet-instance-attestation/api/types.js +0 -2
  91. package/lib/commonjs/wallet-instance-attestation/api/types.js.map +1 -1
  92. package/lib/commonjs/wallet-instance-attestation/v1.3.3/mappers.js +1 -14
  93. package/lib/commonjs/wallet-instance-attestation/v1.3.3/mappers.js.map +1 -1
  94. package/lib/commonjs/wallet-instance-attestation/v1.3.3/types.js +2 -7
  95. package/lib/commonjs/wallet-instance-attestation/v1.3.3/types.js.map +1 -1
  96. package/lib/commonjs/wallet-unit-attestation/api/types.js +0 -11
  97. package/lib/commonjs/wallet-unit-attestation/api/types.js.map +1 -1
  98. package/lib/module/credential/issuance/README.md +44 -17
  99. package/lib/module/credential/issuance/common/02-start-user-authorization.js +4 -3
  100. package/lib/module/credential/issuance/common/02-start-user-authorization.js.map +1 -1
  101. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js +39 -10
  102. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js.map +1 -1
  103. package/lib/module/credential/issuance/mrtd-pop/02-init-challenge.js +47 -34
  104. package/lib/module/credential/issuance/mrtd-pop/02-init-challenge.js.map +1 -1
  105. package/lib/module/credential/issuance/mrtd-pop/03-validate-challenge.js +58 -47
  106. package/lib/module/credential/issuance/mrtd-pop/03-validate-challenge.js.map +1 -1
  107. package/lib/module/credential/issuance/mrtd-pop/index.js +20 -5
  108. package/lib/module/credential/issuance/mrtd-pop/index.js.map +1 -1
  109. package/lib/module/credential/issuance/v1.0.0/02-start-user-authorization.js +1 -1
  110. package/lib/module/credential/issuance/v1.0.0/02-start-user-authorization.js.map +1 -1
  111. package/lib/module/credential/issuance/v1.0.0/03-complete-user-authorization.js +6 -3
  112. package/lib/module/credential/issuance/v1.0.0/03-complete-user-authorization.js.map +1 -1
  113. package/lib/module/credential/issuance/v1.0.0/05-obtain-credential.js +4 -1
  114. package/lib/module/credential/issuance/v1.0.0/05-obtain-credential.js.map +1 -1
  115. package/lib/module/credential/issuance/v1.0.0/index.js +4 -3
  116. package/lib/module/credential/issuance/v1.0.0/index.js.map +1 -1
  117. package/lib/module/credential/issuance/v1.0.0/mappers.js +1 -1
  118. package/lib/module/credential/issuance/v1.0.0/mappers.js.map +1 -1
  119. package/lib/module/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js +0 -2
  120. package/lib/module/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js.map +1 -1
  121. package/lib/module/credential/issuance/v1.3.3/02-start-user-authorization.js +20 -16
  122. package/lib/module/credential/issuance/v1.3.3/02-start-user-authorization.js.map +1 -1
  123. package/lib/module/credential/issuance/v1.3.3/03-complete-user-authorization.js +1 -1
  124. package/lib/module/credential/issuance/v1.3.3/03-complete-user-authorization.js.map +1 -1
  125. package/lib/module/credential/issuance/v1.3.3/04-authorize-access.js +22 -19
  126. package/lib/module/credential/issuance/v1.3.3/04-authorize-access.js.map +1 -1
  127. package/lib/module/credential/issuance/v1.3.3/05-obtain-credential.js +147 -55
  128. package/lib/module/credential/issuance/v1.3.3/05-obtain-credential.js.map +1 -1
  129. package/lib/module/credential/issuance/v1.3.3/06-verify-and-parse-credential.js +4 -1
  130. package/lib/module/credential/issuance/v1.3.3/06-verify-and-parse-credential.js.map +1 -1
  131. package/lib/module/credential/issuance/v1.3.3/index.js +4 -3
  132. package/lib/module/credential/issuance/v1.3.3/index.js.map +1 -1
  133. package/lib/module/credential/issuance/v1.3.3/mappers.js +1 -1
  134. package/lib/module/credential/issuance/v1.3.3/mappers.js.map +1 -1
  135. package/lib/module/credential/presentation/api/types.js.map +1 -1
  136. package/lib/module/credential/presentation/{v1.3.3/utils.mdoc.js → common/utils/mdoc.js} +2 -2
  137. package/lib/module/credential/presentation/common/utils/mdoc.js.map +1 -0
  138. package/lib/module/credential/presentation/v1.0.0/05-verify-request-object.js +13 -7
  139. package/lib/module/credential/presentation/v1.0.0/05-verify-request-object.js.map +1 -1
  140. package/lib/module/credential/presentation/v1.0.0/07-send-authorization-response.js +4 -1
  141. package/lib/module/credential/presentation/v1.0.0/07-send-authorization-response.js.map +1 -1
  142. package/lib/module/credential/presentation/v1.0.0/index.js +0 -2
  143. package/lib/module/credential/presentation/v1.0.0/index.js.map +1 -1
  144. package/lib/module/credential/presentation/v1.0.0/mappers.js +23 -13
  145. package/lib/module/credential/presentation/v1.0.0/mappers.js.map +1 -1
  146. package/lib/module/credential/presentation/v1.0.0/types.js +23 -15
  147. package/lib/module/credential/presentation/v1.0.0/types.js.map +1 -1
  148. package/lib/module/credential/presentation/v1.3.3/05-verify-request-object.js +28 -6
  149. package/lib/module/credential/presentation/v1.3.3/05-verify-request-object.js.map +1 -1
  150. package/lib/module/credential/presentation/v1.3.3/06-evaluate-dcql-query.js +2 -3
  151. package/lib/module/credential/presentation/v1.3.3/06-evaluate-dcql-query.js.map +1 -1
  152. package/lib/module/credential/presentation/v1.3.3/07-send-authorization-response.js +9 -6
  153. package/lib/module/credential/presentation/v1.3.3/07-send-authorization-response.js.map +1 -1
  154. package/lib/module/credential/presentation/v1.3.3/mappers.js +25 -13
  155. package/lib/module/credential/presentation/v1.3.3/mappers.js.map +1 -1
  156. package/lib/module/credential/presentation/v1.3.3/types.js +5 -2
  157. package/lib/module/credential/presentation/v1.3.3/types.js.map +1 -1
  158. package/lib/module/credential/status/README.md +3 -2
  159. package/lib/module/credential/status/v1.3.3/01-status-list.js +27 -5
  160. package/lib/module/credential/status/v1.3.3/01-status-list.js.map +1 -1
  161. package/lib/module/credential/status/v1.3.3/02-verify-and-parse-status-list.js +17 -6
  162. package/lib/module/credential/status/v1.3.3/02-verify-and-parse-status-list.js.map +1 -1
  163. package/lib/module/credentials-catalogue/api/DigitalCredentialsCatalogue.js +24 -0
  164. package/lib/module/credentials-catalogue/api/DigitalCredentialsCatalogue.js.map +1 -1
  165. package/lib/module/credentials-catalogue/v1.3.3/fetch-and-parse-catalogue.js +5 -1
  166. package/lib/module/credentials-catalogue/v1.3.3/fetch-and-parse-catalogue.js.map +1 -1
  167. package/lib/module/credentials-catalogue/v1.3.3/fetch-translations.js +5 -3
  168. package/lib/module/credentials-catalogue/v1.3.3/fetch-translations.js.map +1 -1
  169. package/lib/module/credentials-catalogue/v1.3.3/mappers.js +9 -1
  170. package/lib/module/credentials-catalogue/v1.3.3/mappers.js.map +1 -1
  171. package/lib/module/credentials-catalogue/v1.3.3/types.js +47 -0
  172. package/lib/module/credentials-catalogue/v1.3.3/types.js.map +1 -1
  173. package/lib/module/mdoc/index.js +3 -24
  174. package/lib/module/mdoc/index.js.map +1 -1
  175. package/lib/module/sd-jwt/__test__/types.test.js +2 -14
  176. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  177. package/lib/module/sd-jwt/__test__/utils.test.js +0 -12
  178. package/lib/module/sd-jwt/__test__/utils.test.js.map +1 -1
  179. package/lib/module/sd-jwt/types.js +1 -14
  180. package/lib/module/sd-jwt/types.js.map +1 -1
  181. package/lib/module/utils/callbacks.js +45 -8
  182. package/lib/module/utils/callbacks.js.map +1 -1
  183. package/lib/module/utils/crypto.js +57 -6
  184. package/lib/module/utils/crypto.js.map +1 -1
  185. package/lib/module/utils/x509.js +28 -0
  186. package/lib/module/utils/x509.js.map +1 -0
  187. package/lib/module/wallet-instance-attestation/api/types.js +0 -2
  188. package/lib/module/wallet-instance-attestation/api/types.js.map +1 -1
  189. package/lib/module/wallet-instance-attestation/v1.3.3/mappers.js +1 -14
  190. package/lib/module/wallet-instance-attestation/v1.3.3/mappers.js.map +1 -1
  191. package/lib/module/wallet-instance-attestation/v1.3.3/types.js +2 -7
  192. package/lib/module/wallet-instance-attestation/v1.3.3/types.js.map +1 -1
  193. package/lib/module/wallet-unit-attestation/api/types.js +0 -11
  194. package/lib/module/wallet-unit-attestation/api/types.js.map +1 -1
  195. package/lib/typescript/credential/issuance/api/05-obtain-credential.d.ts +20 -0
  196. package/lib/typescript/credential/issuance/api/05-obtain-credential.d.ts.map +1 -1
  197. package/lib/typescript/credential/issuance/api/06-verify-and-parse-credential.d.ts +4 -0
  198. package/lib/typescript/credential/issuance/api/06-verify-and-parse-credential.d.ts.map +1 -1
  199. package/lib/typescript/credential/issuance/common/02-start-user-authorization.d.ts.map +1 -1
  200. package/lib/typescript/credential/issuance/common/06-verify-and-parse-credential.sdjwt.d.ts.map +1 -1
  201. package/lib/typescript/credential/issuance/mrtd-pop/02-init-challenge.d.ts +12 -1
  202. package/lib/typescript/credential/issuance/mrtd-pop/02-init-challenge.d.ts.map +1 -1
  203. package/lib/typescript/credential/issuance/mrtd-pop/03-validate-challenge.d.ts +12 -1
  204. package/lib/typescript/credential/issuance/mrtd-pop/03-validate-challenge.d.ts.map +1 -1
  205. package/lib/typescript/credential/issuance/mrtd-pop/index.d.ts +2 -1
  206. package/lib/typescript/credential/issuance/mrtd-pop/index.d.ts.map +1 -1
  207. package/lib/typescript/credential/issuance/v1.0.0/03-complete-user-authorization.d.ts.map +1 -1
  208. package/lib/typescript/credential/issuance/v1.0.0/05-obtain-credential.d.ts +1 -0
  209. package/lib/typescript/credential/issuance/v1.0.0/05-obtain-credential.d.ts.map +1 -1
  210. package/lib/typescript/credential/issuance/v1.0.0/index.d.ts.map +1 -1
  211. package/lib/typescript/credential/issuance/v1.0.0/mappers.d.ts.map +1 -1
  212. package/lib/typescript/credential/issuance/v1.3.3/01-evaluate-issuer-trust.d.ts.map +1 -1
  213. package/lib/typescript/credential/issuance/v1.3.3/02-start-user-authorization.d.ts.map +1 -1
  214. package/lib/typescript/credential/issuance/v1.3.3/04-authorize-access.d.ts.map +1 -1
  215. package/lib/typescript/credential/issuance/v1.3.3/05-obtain-credential.d.ts +23 -2
  216. package/lib/typescript/credential/issuance/v1.3.3/05-obtain-credential.d.ts.map +1 -1
  217. package/lib/typescript/credential/issuance/v1.3.3/06-verify-and-parse-credential.d.ts.map +1 -1
  218. package/lib/typescript/credential/issuance/v1.3.3/index.d.ts.map +1 -1
  219. package/lib/typescript/credential/issuance/v1.3.3/mappers.d.ts.map +1 -1
  220. package/lib/typescript/credential/presentation/api/04-verify-certificate-chain.d.ts +9 -2
  221. package/lib/typescript/credential/presentation/api/04-verify-certificate-chain.d.ts.map +1 -1
  222. package/lib/typescript/credential/presentation/api/05-verify-request-object.d.ts +2 -2
  223. package/lib/typescript/credential/presentation/api/05-verify-request-object.d.ts.map +1 -1
  224. package/lib/typescript/credential/presentation/api/07-send-authorization-response.d.ts +2 -2
  225. package/lib/typescript/credential/presentation/api/07-send-authorization-response.d.ts.map +1 -1
  226. package/lib/typescript/credential/presentation/api/types.d.ts +18 -0
  227. package/lib/typescript/credential/presentation/api/types.d.ts.map +1 -1
  228. package/lib/typescript/credential/presentation/{v1.3.3/utils.mdoc.d.ts → common/utils/mdoc.d.ts} +2 -2
  229. package/lib/typescript/credential/presentation/common/utils/mdoc.d.ts.map +1 -0
  230. package/lib/typescript/credential/presentation/v1.0.0/05-verify-request-object.d.ts.map +1 -1
  231. package/lib/typescript/credential/presentation/v1.0.0/07-send-authorization-response.d.ts.map +1 -1
  232. package/lib/typescript/credential/presentation/v1.0.0/index.d.ts.map +1 -1
  233. package/lib/typescript/credential/presentation/v1.0.0/mappers.d.ts +21 -13
  234. package/lib/typescript/credential/presentation/v1.0.0/mappers.d.ts.map +1 -1
  235. package/lib/typescript/credential/presentation/v1.0.0/types.d.ts +23 -15
  236. package/lib/typescript/credential/presentation/v1.0.0/types.d.ts.map +1 -1
  237. package/lib/typescript/credential/presentation/v1.3.3/05-verify-request-object.d.ts.map +1 -1
  238. package/lib/typescript/credential/presentation/v1.3.3/06-evaluate-dcql-query.d.ts.map +1 -1
  239. package/lib/typescript/credential/presentation/v1.3.3/07-send-authorization-response.d.ts.map +1 -1
  240. package/lib/typescript/credential/presentation/v1.3.3/mappers.d.ts +89 -79
  241. package/lib/typescript/credential/presentation/v1.3.3/mappers.d.ts.map +1 -1
  242. package/lib/typescript/credential/presentation/v1.3.3/types.d.ts +87 -79
  243. package/lib/typescript/credential/presentation/v1.3.3/types.d.ts.map +1 -1
  244. package/lib/typescript/credential/status/api/status-list.d.ts +8 -4
  245. package/lib/typescript/credential/status/api/status-list.d.ts.map +1 -1
  246. package/lib/typescript/credential/status/v1.3.3/01-status-list.d.ts.map +1 -1
  247. package/lib/typescript/credential/status/v1.3.3/02-verify-and-parse-status-list.d.ts.map +1 -1
  248. package/lib/typescript/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts +73 -0
  249. package/lib/typescript/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts.map +1 -1
  250. package/lib/typescript/credentials-catalogue/api/index.d.ts +6 -5
  251. package/lib/typescript/credentials-catalogue/api/index.d.ts.map +1 -1
  252. package/lib/typescript/credentials-catalogue/v1.0.0/mappers.d.ts +25 -0
  253. package/lib/typescript/credentials-catalogue/v1.0.0/mappers.d.ts.map +1 -1
  254. package/lib/typescript/credentials-catalogue/v1.3.3/fetch-and-parse-catalogue.d.ts.map +1 -1
  255. package/lib/typescript/credentials-catalogue/v1.3.3/fetch-translations.d.ts.map +1 -1
  256. package/lib/typescript/credentials-catalogue/v1.3.3/mappers.d.ts +51 -0
  257. package/lib/typescript/credentials-catalogue/v1.3.3/mappers.d.ts.map +1 -1
  258. package/lib/typescript/credentials-catalogue/v1.3.3/types.d.ts +33 -0
  259. package/lib/typescript/credentials-catalogue/v1.3.3/types.d.ts.map +1 -1
  260. package/lib/typescript/mdoc/index.d.ts +1 -1
  261. package/lib/typescript/mdoc/index.d.ts.map +1 -1
  262. package/lib/typescript/mdoc/utils.d.ts +0 -24
  263. package/lib/typescript/mdoc/utils.d.ts.map +1 -1
  264. package/lib/typescript/sd-jwt/types.d.ts +0 -12
  265. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  266. package/lib/typescript/utils/callbacks.d.ts +7 -0
  267. package/lib/typescript/utils/callbacks.d.ts.map +1 -1
  268. package/lib/typescript/utils/crypto.d.ts +32 -15
  269. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  270. package/lib/typescript/utils/x509.d.ts +10 -0
  271. package/lib/typescript/utils/x509.d.ts.map +1 -0
  272. package/lib/typescript/wallet-instance-attestation/api/types.d.ts +0 -2
  273. package/lib/typescript/wallet-instance-attestation/api/types.d.ts.map +1 -1
  274. package/lib/typescript/wallet-instance-attestation/v1.0.0/mappers.d.ts +0 -2
  275. package/lib/typescript/wallet-instance-attestation/v1.0.0/mappers.d.ts.map +1 -1
  276. package/lib/typescript/wallet-instance-attestation/v1.3.3/mappers.d.ts +2 -9
  277. package/lib/typescript/wallet-instance-attestation/v1.3.3/mappers.d.ts.map +1 -1
  278. package/lib/typescript/wallet-instance-attestation/v1.3.3/types.d.ts +2 -7
  279. package/lib/typescript/wallet-instance-attestation/v1.3.3/types.d.ts.map +1 -1
  280. package/lib/typescript/wallet-unit-attestation/api/types.d.ts +0 -11
  281. package/lib/typescript/wallet-unit-attestation/api/types.d.ts.map +1 -1
  282. package/lib/typescript/wallet-unit-attestation/v1.3.3/mappers.d.ts +0 -22
  283. package/lib/typescript/wallet-unit-attestation/v1.3.3/mappers.d.ts.map +1 -1
  284. package/lib/typescript/wallet-unit-attestation/v1.3.3/types.d.ts +0 -11
  285. package/lib/typescript/wallet-unit-attestation/v1.3.3/types.d.ts.map +1 -1
  286. package/package.json +6 -6
  287. package/src/credential/issuance/README.md +44 -17
  288. package/src/credential/issuance/api/05-obtain-credential.ts +24 -0
  289. package/src/credential/issuance/api/06-verify-and-parse-credential.ts +4 -0
  290. package/src/credential/issuance/common/02-start-user-authorization.ts +6 -3
  291. package/src/credential/issuance/common/06-verify-and-parse-credential.sdjwt.ts +42 -9
  292. package/src/credential/issuance/mrtd-pop/02-init-challenge.ts +69 -45
  293. package/src/credential/issuance/mrtd-pop/03-validate-challenge.ts +84 -62
  294. package/src/credential/issuance/mrtd-pop/index.ts +13 -5
  295. package/src/credential/issuance/v1.0.0/02-start-user-authorization.ts +1 -1
  296. package/src/credential/issuance/v1.0.0/03-complete-user-authorization.ts +8 -3
  297. package/src/credential/issuance/v1.0.0/05-obtain-credential.ts +6 -0
  298. package/src/credential/issuance/v1.0.0/index.ts +7 -3
  299. package/src/credential/issuance/v1.0.0/mappers.ts +4 -1
  300. package/src/credential/issuance/v1.3.3/01-evaluate-issuer-trust.ts +0 -2
  301. package/src/credential/issuance/v1.3.3/02-start-user-authorization.ts +24 -20
  302. package/src/credential/issuance/v1.3.3/03-complete-user-authorization.ts +1 -1
  303. package/src/credential/issuance/v1.3.3/04-authorize-access.ts +28 -23
  304. package/src/credential/issuance/v1.3.3/05-obtain-credential.ts +182 -87
  305. package/src/credential/issuance/v1.3.3/06-verify-and-parse-credential.ts +2 -1
  306. package/src/credential/issuance/v1.3.3/index.ts +7 -3
  307. package/src/credential/issuance/v1.3.3/mappers.ts +4 -1
  308. package/src/credential/presentation/api/04-verify-certificate-chain.ts +9 -2
  309. package/src/credential/presentation/api/05-verify-request-object.ts +2 -2
  310. package/src/credential/presentation/api/07-send-authorization-response.ts +2 -2
  311. package/src/credential/presentation/api/types.ts +16 -0
  312. package/src/credential/presentation/{v1.3.3/utils.mdoc.ts → common/utils/mdoc.ts} +2 -2
  313. package/src/credential/presentation/v1.0.0/05-verify-request-object.ts +21 -10
  314. package/src/credential/presentation/v1.0.0/07-send-authorization-response.ts +7 -0
  315. package/src/credential/presentation/v1.0.0/index.ts +0 -2
  316. package/src/credential/presentation/v1.0.0/mappers.ts +17 -17
  317. package/src/credential/presentation/v1.0.0/types.ts +23 -15
  318. package/src/credential/presentation/v1.3.3/05-verify-request-object.ts +63 -10
  319. package/src/credential/presentation/v1.3.3/06-evaluate-dcql-query.ts +3 -3
  320. package/src/credential/presentation/v1.3.3/07-send-authorization-response.ts +13 -4
  321. package/src/credential/presentation/v1.3.3/mappers.ts +19 -17
  322. package/src/credential/presentation/v1.3.3/types.ts +9 -3
  323. package/src/credential/status/README.md +3 -2
  324. package/src/credential/status/api/status-list.ts +10 -7
  325. package/src/credential/status/v1.3.3/01-status-list.ts +21 -7
  326. package/src/credential/status/v1.3.3/02-verify-and-parse-status-list.ts +19 -5
  327. package/src/credentials-catalogue/api/DigitalCredentialsCatalogue.ts +32 -0
  328. package/src/credentials-catalogue/api/index.ts +6 -3
  329. package/src/credentials-catalogue/v1.3.3/fetch-and-parse-catalogue.ts +6 -0
  330. package/src/credentials-catalogue/v1.3.3/fetch-translations.ts +6 -3
  331. package/src/credentials-catalogue/v1.3.3/mappers.ts +17 -1
  332. package/src/credentials-catalogue/v1.3.3/types.ts +51 -0
  333. package/src/mdoc/index.ts +5 -41
  334. package/src/sd-jwt/__test__/types.test.ts +1 -13
  335. package/src/sd-jwt/__test__/utils.test.ts +0 -12
  336. package/src/sd-jwt/types.ts +0 -13
  337. package/src/utils/callbacks.ts +57 -9
  338. package/src/utils/crypto.ts +86 -15
  339. package/src/utils/x509.ts +43 -0
  340. package/src/wallet-instance-attestation/api/types.ts +0 -2
  341. package/src/wallet-instance-attestation/v1.3.3/mappers.ts +3 -11
  342. package/src/wallet-instance-attestation/v1.3.3/types.ts +2 -7
  343. package/src/wallet-unit-attestation/api/types.ts +0 -11
  344. package/lib/commonjs/credential/issuance/common/authorization.js +0 -56
  345. package/lib/commonjs/credential/issuance/common/authorization.js.map +0 -1
  346. package/lib/commonjs/credential/presentation/v1.0.0/04-verify-certificate-chain.js +0 -12
  347. package/lib/commonjs/credential/presentation/v1.0.0/04-verify-certificate-chain.js.map +0 -1
  348. package/lib/commonjs/credential/presentation/v1.3.3/utils.mdoc.js.map +0 -1
  349. package/lib/module/credential/issuance/common/authorization.js +0 -48
  350. package/lib/module/credential/issuance/common/authorization.js.map +0 -1
  351. package/lib/module/credential/presentation/v1.0.0/04-verify-certificate-chain.js +0 -5
  352. package/lib/module/credential/presentation/v1.0.0/04-verify-certificate-chain.js.map +0 -1
  353. package/lib/module/credential/presentation/v1.3.3/utils.mdoc.js.map +0 -1
  354. package/lib/typescript/credential/issuance/common/authorization.d.ts +0 -21
  355. package/lib/typescript/credential/issuance/common/authorization.d.ts.map +0 -1
  356. package/lib/typescript/credential/presentation/v1.0.0/04-verify-certificate-chain.d.ts +0 -3
  357. package/lib/typescript/credential/presentation/v1.0.0/04-verify-certificate-chain.d.ts.map +0 -1
  358. package/lib/typescript/credential/presentation/v1.3.3/utils.mdoc.d.ts.map +0 -1
  359. package/src/credential/issuance/common/authorization.ts +0 -89
  360. package/src/credential/presentation/v1.0.0/04-verify-certificate-chain.ts +0 -10
@@ -1,4 +1,5 @@
1
1
  import { CBOR } from "@pagopa/io-react-native-iso18013";
2
+ import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
2
3
  import {
3
4
  getStatusListFromJWT,
4
5
  type StatusListEntry,
@@ -38,13 +39,26 @@ export const getStatusList: StatusListApi["get"] = async (
38
39
  ) => {
39
40
  const { uri, idx } = await getStatusListEntry(credential, format);
40
41
 
41
- const statusList = await appFetch(uri, {
42
- headers: {
43
- Accept: "application/statuslist+jwt",
44
- },
45
- })
46
- .then(hasStatusOrThrow(200))
47
- .then((response) => response.text());
42
+ const fetchStatusList = (options: { cacheDisabled?: boolean } = {}) =>
43
+ appFetch(uri, {
44
+ headers: {
45
+ Accept: "application/statuslist+jwt",
46
+ ...(options.cacheDisabled && { "Cache-Control": "no-cache" }),
47
+ },
48
+ })
49
+ .then(hasStatusOrThrow(200))
50
+ .then((response) => response.text());
48
51
 
52
+ // When the HTTP response includes cache headers, fetch will return a cached response and the JWT might be expired
53
+ let statusList = await fetchStatusList();
54
+ const decoded = decodeJwt(statusList);
55
+
56
+ const { exp } = decoded.payload;
57
+
58
+ // If the status list JWT is expired, try to fetch it again bypassing the HTTP cache.
59
+ // If it is still expired after the refetch, `verifyAndParseStatusList` will throw.
60
+ if (exp && exp < Math.floor(Date.now() / 1000)) {
61
+ statusList = await fetchStatusList({ cacheDisabled: true });
62
+ }
49
63
  return { statusList, uri, idx, format: "jwt" };
50
64
  };
@@ -2,18 +2,32 @@ import { verify } from "@pagopa/io-react-native-jwt";
2
2
  import { getListFromStatusListJWT } from "@sd-jwt/jwt-status-list";
3
3
  import type { StatusListApi } from "../api/status-list";
4
4
 
5
+ /**
6
+ * Mapping of status bits to their corresponding meaning as defined in the specification.
7
+ * @see https://italia.github.io/eid-wallet-it-docs/releases/1.3.3/en/credential-revocation.html#token-status-lists
8
+ */
9
+ const CredentialStatusMap = {
10
+ 0x00: "VALID",
11
+ 0x01: "INVALID",
12
+ 0x02: "SUSPENDED",
13
+ 0x03: "UPDATE",
14
+ 0x0b: "ATTRIBUTE_UPDATE",
15
+ } as const;
16
+
17
+ type CredentialStatusBit = keyof typeof CredentialStatusMap;
18
+
5
19
  export const verifyAndParseStatusList: StatusListApi["verifyAndParse"] = async (
6
- issuerConf,
20
+ keys,
7
21
  { statusList: rawStatusList, idx }
8
22
  ) => {
9
- await verify(rawStatusList, issuerConf.keys);
23
+ await verify(rawStatusList, keys);
10
24
 
11
25
  const statusList = getListFromStatusListJWT(rawStatusList);
26
+ const statusBit = statusList.getStatus(idx) as CredentialStatusBit;
27
+ const status = CredentialStatusMap[statusBit];
12
28
 
13
- const status = statusList.getStatus(idx);
14
-
15
- // TODO: [SIW-3992] Improve the return object with additional data, throw CredentialInvalidStatus when invalid
16
29
  return {
17
30
  status,
31
+ statusBit: `0x${statusBit.toString(16).padStart(2, "0").toUpperCase()}`,
18
32
  };
19
33
  };
@@ -117,8 +117,40 @@ export const DigitalCredential = z.object({
117
117
  // claims: z.array(Claim), // TODO: [SIW-3978] Should we keep claims?
118
118
  });
119
119
 
120
+ const TaxonomyPurpose = z.object({
121
+ id: z.string(),
122
+ name_l10n_id: z.string(),
123
+ });
124
+ export type TaxonomyPurpose = z.infer<typeof TaxonomyPurpose>;
125
+
126
+ const TaxonomyClass = z.object({
127
+ id: z.string(),
128
+ name_l10n_id: z.string(),
129
+ supported_purposes: z.array(z.string()),
130
+ });
131
+ export type TaxonomyClass = z.infer<typeof TaxonomyClass>;
132
+
133
+ const TaxonomyDomain = z.object({
134
+ id: z.string(),
135
+ name_l10n_id: z.string(),
136
+ description_l10n_id: z.string(),
137
+ classes: z.array(TaxonomyClass),
138
+ });
139
+ export type TaxonomyDomain = z.infer<typeof TaxonomyDomain>;
140
+
141
+ export const Taxonomy = z.object({
142
+ id: z.string(),
143
+ name_l10n_id: z.string(),
144
+ description_l10n_id: z.string(),
145
+ domains: z.array(TaxonomyDomain),
146
+ purposes: z.array(TaxonomyPurpose),
147
+ localization: LocalizationInfo.optional(),
148
+ });
149
+ export type Taxonomy = z.infer<typeof Taxonomy>;
150
+
120
151
  export const DigitalCredentialsCatalogue = z.object({
121
152
  taxonomy_uri: z.string().url(),
153
+ taxonomy: Taxonomy.optional(),
122
154
  credentials: z.array(DigitalCredential),
123
155
  iat: UnixTime,
124
156
  exp: UnixTime,
@@ -2,6 +2,7 @@ import {
2
2
  type CatalogueTranslations,
3
3
  type DigitalCredentialsCatalogue,
4
4
  type LocalizationInfo,
5
+ type Taxonomy,
5
6
  } from "./DigitalCredentialsCatalogue";
6
7
 
7
8
  type FetchContext = { appFetch?: GlobalFetch["fetch"] };
@@ -9,6 +10,7 @@ type FetchContext = { appFetch?: GlobalFetch["fetch"] };
9
10
  type FetchTranslationsLocalizations = {
10
11
  catalogue?: LocalizationInfo;
11
12
  authenticSources?: LocalizationInfo;
13
+ taxonomy?: LocalizationInfo;
12
14
  };
13
15
 
14
16
  export interface CredentialsCatalogueApi {
@@ -27,11 +29,11 @@ export interface CredentialsCatalogueApi {
27
29
  ): Promise<DigitalCredentialsCatalogue>;
28
30
 
29
31
  /**
30
- * Fetch locale bundle files for the credential catalogue and authentic sources.
31
- * For each requested locale, fetches translations from both registries (if the locale
32
+ * Fetch locale bundle files for the credential catalogue, authentic sources, and taxonomy.
33
+ * For each requested locale, fetches translations from all registries (if the locale
32
34
  * is listed in their respective `available_locales`) and merges the keys.
33
35
  * Locales not present in a registry's `available_locales` are silently skipped for that source.
34
- * On key conflicts, authentic-sources translations take precedence.
36
+ * On key conflicts, later sources (authenticSources, taxonomy) take precedence.
35
37
  *
36
38
  * Optional: not supported by all versions. Check for existence before calling.
37
39
  *
@@ -52,4 +54,5 @@ export {
52
54
  type CatalogueTranslations,
53
55
  type DigitalCredentialsCatalogue,
54
56
  type LocalizationInfo,
57
+ type Taxonomy,
55
58
  };
@@ -5,6 +5,7 @@ import {
5
5
  DigitalCredentialsCatalogueJwt,
6
6
  RegistryDiscoveryJwt,
7
7
  SchemaRegistry,
8
+ TaxonomyRegistry,
8
9
  } from "./types";
9
10
  import { mapToCredentialsCatalogue } from "./mappers";
10
11
  import { fetchRegistry } from "./utils";
@@ -46,6 +47,11 @@ export const fetchAndParseCatalogue: Api["fetchAndParseCatalogue"] = async (
46
47
  asJson: true,
47
48
  appFetch,
48
49
  }),
50
+ fetchRegistry(endpoints.taxonomy, {
51
+ schema: TaxonomyRegistry,
52
+ asJson: true,
53
+ appFetch,
54
+ }),
49
55
  ]);
50
56
 
51
57
  return mapToCredentialsCatalogue([discovery, ...registries]);
@@ -2,7 +2,7 @@ import type { CredentialsCatalogueApi as Api } from "../api";
2
2
  import { fetchLocaleBundle } from "./utils";
3
3
 
4
4
  export const fetchTranslations: NonNullable<Api["fetchTranslations"]> = async (
5
- { catalogue, authenticSources },
5
+ { catalogue, authenticSources, taxonomy },
6
6
  locales,
7
7
  { appFetch = fetch } = {}
8
8
  ) => {
@@ -10,16 +10,19 @@ export const fetchTranslations: NonNullable<Api["fetchTranslations"]> = async (
10
10
 
11
11
  await Promise.all(
12
12
  locales.map(async (locale) => {
13
- const [catalogueBundle, asBundle] = await Promise.all([
13
+ const [catalogueBundle, asBundle, taxonomyBundle] = await Promise.all([
14
14
  catalogue?.available_locales.includes(locale)
15
15
  ? fetchLocaleBundle(catalogue.base_uri, locale, appFetch)
16
16
  : Promise.resolve({}),
17
17
  authenticSources?.available_locales.includes(locale)
18
18
  ? fetchLocaleBundle(authenticSources.base_uri, locale, appFetch)
19
19
  : Promise.resolve({}),
20
+ taxonomy?.available_locales.includes(locale)
21
+ ? fetchLocaleBundle(taxonomy.base_uri, locale, appFetch)
22
+ : Promise.resolve({}),
20
23
  ]);
21
24
 
22
- const merged = { ...catalogueBundle, ...asBundle };
25
+ const merged = { ...catalogueBundle, ...asBundle, ...taxonomyBundle };
23
26
 
24
27
  // Only include the locale in the result if at least one source provided translations
25
28
  if (Object.keys(merged).length > 0) {
@@ -11,6 +11,7 @@ import {
11
11
  DigitalCredentialsCatalogueJwt,
12
12
  RegistryDiscoveryJwt,
13
13
  SchemaRegistry,
14
+ TaxonomyRegistry,
14
15
  } from "./types";
15
16
 
16
17
  export const mapToCredentialsCatalogue = createMapper<
@@ -19,10 +20,17 @@ export const mapToCredentialsCatalogue = createMapper<
19
20
  DigitalCredentialsCatalogueJwt,
20
21
  AuthenticSourceRegistry,
21
22
  SchemaRegistry,
23
+ TaxonomyRegistry,
22
24
  ],
23
25
  DigitalCredentialsCatalogue
24
26
  >(
25
- ([discoveryJwt, catalogueJwt, authSourceRegistry, schemaRegistry]) => {
27
+ ([
28
+ discoveryJwt,
29
+ catalogueJwt,
30
+ authSourceRegistry,
31
+ schemaRegistry,
32
+ taxonomyRegistry,
33
+ ]) => {
26
34
  const authSourcesById = keyBy(
27
35
  authSourceRegistry.authentic_sources,
28
36
  "entity_id"
@@ -65,6 +73,14 @@ export const mapToCredentialsCatalogue = createMapper<
65
73
  return {
66
74
  ...catalogueJwt.payload,
67
75
  taxonomy_uri: discoveryJwt.payload.endpoints.taxonomy,
76
+ taxonomy: {
77
+ id: taxonomyRegistry.id,
78
+ name_l10n_id: taxonomyRegistry.name_l10n_id,
79
+ description_l10n_id: taxonomyRegistry.description_l10n_id,
80
+ domains: taxonomyRegistry.domains,
81
+ purposes: taxonomyRegistry.purposes,
82
+ localization: taxonomyRegistry.localization,
83
+ },
68
84
  localization: catalogueJwt.payload.localization,
69
85
  as_localization: authSourceRegistry.localization,
70
86
  credentials: catalogueJwt.payload.credentials.map(
@@ -233,3 +233,54 @@ export const RegistryDiscoveryJwt = z.object({
233
233
  }),
234
234
  });
235
235
  export type RegistryDiscoveryJwt = z.infer<typeof RegistryDiscoveryJwt>;
236
+
237
+ /**
238
+ * Taxonomy purpose (top-level flat list).
239
+ */
240
+ const TaxonomyPurpose = z.object({
241
+ id: z.string(),
242
+ name_l10n_id: z.string(),
243
+ });
244
+
245
+ /**
246
+ * Taxonomy class within a domain.
247
+ */
248
+ const TaxonomyClass = z.object({
249
+ id: z.string(),
250
+ name_l10n_id: z.string(),
251
+ supported_purposes: z.array(z.string()),
252
+ });
253
+
254
+ /**
255
+ * Taxonomy domain containing classes.
256
+ */
257
+ const TaxonomyDomain = z.object({
258
+ id: z.string(),
259
+ name_l10n_id: z.string(),
260
+ description_l10n_id: z.string(),
261
+ classes: z.array(TaxonomyClass),
262
+ });
263
+
264
+ /**
265
+ * Taxonomy registry, available at a dedicated endpoint.
266
+ * Provides a hierarchical classification of domains, classes, and purposes.
267
+ * @see https://italia.github.io/eid-wallet-it-docs/releases/1.3.3/en/registry.html#taxonomy
268
+ */
269
+ export const TaxonomyRegistry = z.object({
270
+ version: z.string(),
271
+ last_modified: z.string(),
272
+ id: z.string(),
273
+ localization: z
274
+ .object({
275
+ available_locales: z.array(z.string()),
276
+ base_uri: z.string(),
277
+ default_locale: z.string(),
278
+ version: z.string(),
279
+ })
280
+ .optional(),
281
+ name_l10n_id: z.string(),
282
+ description_l10n_id: z.string(),
283
+ domains: z.array(TaxonomyDomain),
284
+ purposes: z.array(TaxonomyPurpose),
285
+ });
286
+ export type TaxonomyRegistry = z.infer<typeof TaxonomyRegistry>;
package/src/mdoc/index.ts CHANGED
@@ -1,19 +1,12 @@
1
1
  import { CBOR, COSE, ISO18013_7 } from "@pagopa/io-react-native-iso18013";
2
2
  import { b64utob64 } from "jsrsasign";
3
- import {
4
- verifyCertificateChain,
5
- type CertificateValidationResult,
6
- type PublicKey,
7
- type X509CertificateOptions,
8
- } from "@pagopa/io-react-native-crypto";
9
- import {
10
- MissingX509CertsError,
11
- X509ValidationError,
12
- } from "../trust/common/errors";
3
+ import { type PublicKey } from "@pagopa/io-react-native-crypto";
4
+ import { MissingX509CertsError } from "../trust/common/errors";
13
5
  import { IoWalletError } from "../utils/errors";
14
6
  import { convertBase64DerToPem, getSigninJwkFromCert } from "../utils/crypto";
15
- import type { Presentation } from "src/credential/presentation";
7
+ import type { Presentation } from "../credential/presentation";
16
8
  import { removePadding } from "@pagopa/io-react-native-jwt";
9
+ import { verifyX509Chain } from "../utils/x509";
17
10
  export * from "./utils";
18
11
 
19
12
  export const verify = async (
@@ -37,7 +30,7 @@ export const verify = async (
37
30
  const x5chain =
38
31
  issuerSigned.issuerAuth.unprotectedHeader.x5chain.map(b64utob64);
39
32
  // Verify the x5chain
40
- await verifyX5chain(x5chain, x509CertRoot);
33
+ await verifyX509Chain(x5chain, x509CertRoot);
41
34
 
42
35
  const coseSign1 = issuerSigned.issuerAuth.rawValue;
43
36
 
@@ -50,35 +43,6 @@ export const verify = async (
50
43
  return { issuerSigned };
51
44
  };
52
45
 
53
- /**
54
- * This function checks whether the x509 certificate chain is valid against a specified Certificate Authority (CA)
55
- *
56
- * @param x5chain The mdoc's x509 certificate chain
57
- * @param x509CertRoot The Trust Anchor CA
58
- * @param options Options for certificate validation
59
- */
60
- const verifyX5chain = async (
61
- x5chain: string[],
62
- x509CertRoot: string,
63
- options: X509CertificateOptions = {
64
- connectTimeout: 10000,
65
- readTimeout: 10000,
66
- requireCrl: true,
67
- }
68
- ) => {
69
- const x509ValidationResult: CertificateValidationResult =
70
- await verifyCertificateChain(x5chain, x509CertRoot, options);
71
-
72
- if (!x509ValidationResult.isValid) {
73
- throw new X509ValidationError(
74
- `X.509 certificate chain validation failed. Status: ${x509ValidationResult.validationStatus}. Error: ${x509ValidationResult.errorMessage}`,
75
- {
76
- x509ValidationStatus: x509ValidationResult.validationStatus,
77
- x509ErrorMessage: x509ValidationResult.errorMessage,
78
- }
79
- );
80
- }
81
- };
82
46
  /**
83
47
  * This function verifies that the signature is valid for the given certificate.
84
48
  * If not, it throws an error
@@ -28,20 +28,8 @@ describe("Verification.time", () => {
28
28
 
29
29
  it("rejects invalid type", () => {
30
30
  const value = {
31
- trust_framework: "eidas",
31
+ trust_framework: ["eidas"],
32
32
  assurance_level: "high",
33
- evidence: [
34
- {
35
- type: "vouch",
36
- time: null,
37
- attestation: {
38
- type: "digital_attestation",
39
- reference_number: "abc",
40
- date_of_issuance: "2025-09-02",
41
- voucher: { organization: "IPZS" },
42
- },
43
- },
44
- ],
45
33
  };
46
34
 
47
35
  expect(Verification.safeParse(value).success).toBe(false);
@@ -4,18 +4,6 @@ import { getVerification } from "..";
4
4
  describe("SD-JWT getVerification", () => {
5
5
  it("extracts the verification claims correctly", () => {
6
6
  expect(getVerification(pid)).toEqual({
7
- evidence: [
8
- {
9
- attestation: {
10
- date_of_issuance: "2025-06-23",
11
- voucher: { organization: "Ministero dell'Interno" },
12
- type: "digital_attestation",
13
- reference_number: "123456789",
14
- },
15
- time: "2025-06-23T13:14:25Z",
16
- type: "vouch",
17
- },
18
- ],
19
7
  trust_framework: "it_cie",
20
8
  assurance_level: "high",
21
9
  });
@@ -64,19 +64,6 @@ export type Verification = z.infer<typeof Verification>;
64
64
  export const Verification = z.object({
65
65
  trust_framework: z.string(),
66
66
  assurance_level: z.string(),
67
- evidence: z.array(
68
- z.object({
69
- type: z.literal("vouch"),
70
- // Support both string and UNIX timestamp for backward compatibility
71
- time: z.union([z.string(), z.number()]),
72
- attestation: z.object({
73
- type: z.literal("digital_attestation"),
74
- reference_number: z.string(),
75
- date_of_issuance: z.string(),
76
- voucher: z.object({ organization: z.string() }),
77
- }),
78
- })
79
- ),
80
67
  });
81
68
 
82
69
  /**
@@ -1,11 +1,17 @@
1
- import { EncryptJwe, getJwkFromHeader } from "@pagopa/io-react-native-jwt";
1
+ import {
2
+ EncryptJwe,
3
+ getJwkFromHeader,
4
+ SignJWT,
5
+ type CryptoContext,
6
+ } from "@pagopa/io-react-native-jwt";
2
7
  import { verify } from "@pagopa/io-react-native-jwt";
3
- import { type CallbackContext } from "@pagopa/io-wallet-oauth2";
8
+ import { type CallbackContext, type JwtSigner } from "@pagopa/io-wallet-oauth2";
4
9
  import { digest } from "@sd-jwt/crypto-nodejs";
5
10
  import { X509 } from "jsrsasign";
6
11
  import { IoWalletError } from "./errors";
7
- import { generateRandomBytes } from "./misc";
12
+ import { assert, generateRandomBytes } from "./misc";
8
13
  import type { JWK } from "./jwk";
14
+ import { getJwkFromCertificateChain, getJwkFromTrustChain } from "./crypto";
9
15
 
10
16
  type PartialCallbackContext = Omit<
11
17
  CallbackContext,
@@ -18,6 +24,29 @@ type DigestFixed = (
18
24
  algorithm?: string
19
25
  ) => Uint8Array;
20
26
 
27
+ /**
28
+ * Extract the signing JWK from one of the supported signer methods.
29
+ * @param signer - The JWT signer.
30
+ * @returns The JWK for signature verification.
31
+ */
32
+ const getJwkFromSigner = async (signer: JwtSigner): Promise<JWK> => {
33
+ switch (signer.method) {
34
+ case "x5c":
35
+ return getJwkFromCertificateChain(signer.x5c);
36
+ case "federation": {
37
+ assert(
38
+ signer.trustChain && signer.trustChain.length > 0,
39
+ "Trust chain is required for federation signer"
40
+ );
41
+ return getJwkFromTrustChain(signer.trustChain, signer.kid);
42
+ }
43
+ case "jwk":
44
+ return signer.publicJwk as JWK;
45
+ default:
46
+ throw new IoWalletError(`Unsupported signer method: ${signer.method}`);
47
+ }
48
+ };
49
+
21
50
  /**
22
51
  * Shared callbacks with React Native implementations for use
23
52
  * in IO Wallet SDK. Callbacks not found here must be provided by the caller,
@@ -32,13 +61,10 @@ export const partialCallbacks: PartialCallbackContext = {
32
61
  encryptionJwk: publicJwk,
33
62
  }),
34
63
  verifyJwt: async (jwtSigner, jwt) => {
35
- // TODO: support other signing methods if needed
36
- if (jwtSigner.method !== "jwk") {
37
- throw new IoWalletError(`Unsupported signer method: ${jwtSigner.method}`);
38
- }
39
64
  try {
40
- await verify(jwt.compact, jwtSigner.publicJwk);
41
- return { verified: true, signerJwk: jwtSigner.publicJwk };
65
+ const signerJwk = await getJwkFromSigner(jwtSigner);
66
+ await verify(jwt.compact, signerJwk);
67
+ return { verified: true, signerJwk };
42
68
  } catch {
43
69
  return { verified: false };
44
70
  }
@@ -88,3 +114,25 @@ export const createVerifyJwtFromJwks = (
88
114
  }
89
115
  };
90
116
  };
117
+
118
+ /**
119
+ * Create a signJwt implementation that signs a JWT using the provided CryptoContext.
120
+ * @param cryptoContext The CryptoContext to use for signing the JWT
121
+ * @returns Function that implements `signJwt` callback
122
+ */
123
+ export const createSignJwtFromCryptoContext = (
124
+ cryptoContext: CryptoContext
125
+ ): CallbackContext["signJwt"] => {
126
+ return async function signJwt(jwtSigner, { header, payload }) {
127
+ return {
128
+ jwt: await new SignJWT(cryptoContext)
129
+ .setProtectedHeader(header)
130
+ .setPayload(payload)
131
+ .sign(),
132
+ signerJwk:
133
+ jwtSigner.method === "jwk"
134
+ ? jwtSigner.publicJwk
135
+ : await cryptoContext.getPublicKey(),
136
+ };
137
+ };
138
+ };
@@ -5,11 +5,34 @@ import {
5
5
  sign,
6
6
  } from "@pagopa/io-react-native-crypto";
7
7
  import { v4 as uuidv4 } from "uuid";
8
- import { thumbprint, type CryptoContext } from "@pagopa/io-react-native-jwt";
9
- import { JWK } from "./jwk";
8
+ import {
9
+ decode,
10
+ thumbprint,
11
+ type CryptoContext,
12
+ } from "@pagopa/io-react-native-jwt";
13
+ import type { BaseEntityConfiguration } from "../trust/common/types";
14
+ import { JWK, JWKS } from "./jwk";
10
15
  import { KEYUTIL, KJUR, RSAKey, X509 } from "jsrsasign";
11
16
  import { IoWalletError } from "./errors";
12
17
 
18
+ /**
19
+ * Extension of the {@link CryptoContext} that adds key generation with optional key attestation.
20
+ *
21
+ * This context requires the consumer to provide an additional method for **key generation**;
22
+ * on Android this method should also generate a key attestation as a certificate chain
23
+ * to ensure the key pair is hardware-backed.
24
+ */
25
+ export type KeyAttestationCryptoContext = CryptoContext & {
26
+ /**
27
+ * Generate a key pair with an **optional key attestation** (Android).
28
+ * @param challenge The challenge for the key attestation.
29
+ * @returns An object with a success flag and a key attestation, if it was generated.
30
+ */
31
+ generateKeyWithAttestation(
32
+ challenge: string
33
+ ): Promise<{ success: boolean; attestation?: string }>;
34
+ };
35
+
13
36
  /**
14
37
  * Create a CryptoContext bound to a key pair.
15
38
  * Key pair is supposed to exist already in the device's keychain.
@@ -92,19 +115,67 @@ export const getSigninJwkFromCert = (pemCert: string): JWK => {
92
115
  };
93
116
 
94
117
  /**
95
- * Extension of the {@link CryptoContext} that adds key generation with optional key attestation.
118
+ * Retrieves the signing JWK from a x509 certificate chain.
96
119
  *
97
- * This context requires the consumer to provide an additional method for **key generation**;
98
- * on Android this method should also generate a key attestation as a certificate chain
99
- * to ensure the key pair is hardware-backed.
120
+ * @param certChain - The x509 certificate chain.
121
+ * @returns The signing JWK.
122
+ * @throws Will throw an error if no suitable keys are found.
100
123
  */
101
- export type KeyAttestationCryptoContext = CryptoContext & {
102
- /**
103
- * Generate a key pair with an **optional key attestation** (Android).
104
- * @param challenge The challenge for the key attestation.
105
- * @returns An object with a success flag and a key attestation, if it was generated.
106
- */
107
- generateKeyWithAttestation(
108
- challenge: string
109
- ): Promise<{ success: boolean; attestation?: string }>;
124
+ export const getJwkFromCertificateChain = async (
125
+ certChain: string[]
126
+ ): Promise<JWK> => {
127
+ const [leafCert] = certChain;
128
+ if (!leafCert) {
129
+ throw new IoWalletError(
130
+ "The provided certificate chain is invalid or malformed"
131
+ );
132
+ }
133
+ const pemCert = convertBase64DerToPem(leafCert);
134
+ return getSigninJwkFromCert(pemCert);
135
+ };
136
+
137
+ /**
138
+ * Retrieves the signing JWK from a trust chain of entity configuration JWTs, matching the provided signer KID.
139
+ *
140
+ * @param trustChain - The trust chain of entity configuration JWTs.
141
+ * @param signerKid - The KID of the signer to look for in the trust chain.
142
+ * @returns The signing JWK.
143
+ * @throws Will throw an error if no suitable keys are found.
144
+ */
145
+ export const getJwkFromTrustChain = (
146
+ trustChain: string[],
147
+ signerKid: string
148
+ ): JWK => {
149
+ const [entityConfigurationJwt] = trustChain;
150
+ if (!entityConfigurationJwt) {
151
+ throw new IoWalletError("The provided trust chain is invalid or malformed");
152
+ }
153
+
154
+ const keys: JWK[] = [];
155
+ const decodedEntityConfigJwt = decode(entityConfigurationJwt);
156
+ const baseEntityConfig =
157
+ decodedEntityConfigJwt.payload as BaseEntityConfiguration["payload"];
158
+
159
+ // Get top-level JWKS
160
+ if (baseEntityConfig.jwks) {
161
+ keys.push(...JWKS.parse(baseEntityConfig.jwks).keys);
162
+ }
163
+
164
+ // Check metadata entries for additional JWKS like openid_credential_verifier
165
+ if (baseEntityConfig.metadata) {
166
+ for (const metadata of Object.values(
167
+ baseEntityConfig.metadata as Record<string, { jwks?: JWKS }>
168
+ )) {
169
+ if (metadata.jwks) {
170
+ keys.push(...JWKS.parse(metadata.jwks).keys);
171
+ }
172
+ }
173
+ }
174
+
175
+ const federationJwk = keys.find((key) => key.kid === signerKid);
176
+ if (!federationJwk)
177
+ throw new IoWalletError(
178
+ "No suitable key was found in the provided trust chain"
179
+ );
180
+ return federationJwk;
110
181
  };