@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,14 +1,22 @@
1
+ import { sdkConfigV1_0, sdkConfigV1_3 } from "../../../utils/config";
1
2
  import type { MRTDPoPApi } from "../api/mrtd-pop";
2
3
  import { verifyAndParseChallengeInfo } from "./01-verify-and-parse-challenge-info";
3
- import { initChallenge } from "./02-init-challenge";
4
+ import { createInitChallenge } from "./02-init-challenge";
4
5
  import {
5
- validateChallenge,
6
+ createValidateChallenge,
6
7
  buildChallengeCallbackUrl,
7
8
  } from "./03-validate-challenge";
8
9
 
9
- export const MRTDPoP: MRTDPoPApi = {
10
+ export const MRTDPoPv1_0: MRTDPoPApi = {
10
11
  verifyAndParseChallengeInfo,
11
- initChallenge,
12
- validateChallenge,
12
+ initChallenge: createInitChallenge({ sdkConfig: sdkConfigV1_0 }),
13
+ validateChallenge: createValidateChallenge({ sdkConfig: sdkConfigV1_0 }),
14
+ buildChallengeCallbackUrl,
15
+ };
16
+
17
+ export const MRTDPoPv1_3: MRTDPoPApi = {
18
+ verifyAndParseChallengeInfo,
19
+ initChallenge: createInitChallenge({ sdkConfig: sdkConfigV1_3 }),
20
+ validateChallenge: createValidateChallenge({ sdkConfig: sdkConfigV1_3 }),
13
21
  buildChallengeCallbackUrl,
14
22
  };
@@ -6,7 +6,7 @@ import type { IssuanceApi } from "../api";
6
6
  import {
7
7
  selectCredentialDefinition,
8
8
  selectResponseMode,
9
- } from "../common/authorization";
9
+ } from "../common/02-start-user-authorization";
10
10
 
11
11
  export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
12
12
  async (issuerConf, credentialIds, proof, ctx) => {
@@ -17,7 +17,7 @@ import { ResponseUriResultShape } from "./types";
17
17
  import { getJwtFromFormPost } from "../../../utils/decoder";
18
18
  import { AuthorizationError, AuthorizationIdpError } from "../common/errors";
19
19
  import { LogLevel, Logger } from "../../../utils/logging";
20
- import { RequestObjectPayload } from "../../presentation/v1.0.0/types";
20
+ import { RawRequestObject } from "../../presentation/v1.0.0/types";
21
21
  import { RemotePresentation as RemotePresentationFlow } from "../../presentation/v1.0.0";
22
22
  import type { IssuanceApi } from "../api";
23
23
  import type { RemotePresentation } from "../../presentation";
@@ -105,7 +105,12 @@ export const getRequestedCredentialToBePresented: IssuanceApi["getRequestedCrede
105
105
  .then(hasStatusOrThrow(200, IssuerResponseError))
106
106
  .then((res) => res.text())
107
107
  .then((jws) => decode(jws))
108
- .then((reqObj) => RequestObjectPayload.safeParse(reqObj.payload));
108
+ .then((reqObj) =>
109
+ RawRequestObject.safeParse({
110
+ header: reqObj.protectedHeader,
111
+ payload: reqObj.payload,
112
+ })
113
+ );
109
114
 
110
115
  if (!requestObject.success) {
111
116
  Logger.log(
@@ -117,7 +122,7 @@ export const getRequestedCredentialToBePresented: IssuanceApi["getRequestedCrede
117
122
  reason: requestObject.error.message,
118
123
  });
119
124
  }
120
- return requestObject.data;
125
+ return requestObject.data.payload;
121
126
  };
122
127
 
123
128
  export const completeUserAuthorizationWithFormPostJwtMode: IssuanceApi["completeUserAuthorizationWithFormPostJwtMode"] =
@@ -10,6 +10,7 @@ import {
10
10
  IssuerResponseErrorCodes,
11
11
  ResponseErrorBuilder,
12
12
  UnexpectedStatusCodeError,
13
+ UnimplementedFeatureError,
13
14
  ValidationFailed,
14
15
  } from "../../../utils/errors";
15
16
  import { createDPopToken } from "../../../utils/dpop";
@@ -210,3 +211,8 @@ const handleObtainCredentialError = (e: unknown) => {
210
211
  })
211
212
  .buildFrom(e);
212
213
  };
214
+
215
+ export const obtainCredentialsBatch: IssuanceApi["obtainCredentialsBatch"] =
216
+ () => {
217
+ throw new UnimplementedFeatureError("obtainCredentialsBatch", "1.0.0");
218
+ };
@@ -9,9 +9,12 @@ import {
9
9
  getRequestedCredentialToBePresented,
10
10
  } from "./03-complete-user-authorization";
11
11
  import { authorizeAccess } from "./04-authorize-access";
12
- import { obtainCredential } from "./05-obtain-credential";
12
+ import {
13
+ obtainCredential,
14
+ obtainCredentialsBatch,
15
+ } from "./05-obtain-credential";
13
16
  import { verifyAndParseCredential } from "./06-verify-and-parse-credential";
14
- import { MRTDPoP } from "../mrtd-pop";
17
+ import { MRTDPoPv1_0 } from "../mrtd-pop";
15
18
 
16
19
  export const Issuance: IssuanceApi = {
17
20
  evaluateIssuerTrust,
@@ -23,6 +26,7 @@ export const Issuance: IssuanceApi = {
23
26
  completeUserAuthorizationWithFormPostJwtMode,
24
27
  authorizeAccess,
25
28
  obtainCredential,
29
+ obtainCredentialsBatch,
26
30
  verifyAndParseCredential,
27
- MRTDPoP,
31
+ MRTDPoP: MRTDPoPv1_0,
28
32
  };
@@ -17,7 +17,10 @@ export const mapToIssuerConfig = createMapper<
17
17
  credential_issuer: openid_credential_issuer.credential_issuer,
18
18
  credential_configurations_supported:
19
19
  openid_credential_issuer.credential_configurations_supported,
20
- keys: openid_credential_issuer.jwks.keys,
20
+ keys: [
21
+ ...openid_credential_issuer.jwks.keys,
22
+ ...oauth_authorization_server.jwks.keys,
23
+ ],
21
24
  pushed_authorization_request_endpoint:
22
25
  oauth_authorization_server.pushed_authorization_request_endpoint,
23
26
  token_endpoint: oauth_authorization_server.token_endpoint,
@@ -2,7 +2,6 @@ import {
2
2
  fetchMetadata,
3
3
  type MetadataResponseV1_3,
4
4
  } from "@pagopa/io-wallet-oid4vci";
5
- import { partialCallbacks } from "../../../utils/callbacks";
6
5
  import { sdkConfigV1_3 } from "../../../utils/config";
7
6
  import type { IssuanceApi } from "../api";
8
7
  import { mapToIssuerConfig } from "./mappers";
@@ -15,7 +14,6 @@ export const evaluateIssuerTrust: IssuanceApi["evaluateIssuerTrust"] = async (
15
14
  config: sdkConfigV1_3,
16
15
  credentialIssuerUrl: issuerUrl,
17
16
  callbacks: {
18
- ...partialCallbacks,
19
17
  fetch: context.appFetch,
20
18
  },
21
19
  })) as MetadataResponseV1_3;
@@ -3,16 +3,17 @@ import {
3
3
  fetchPushedAuthorizationResponse,
4
4
  createClientAttestationPopJwt,
5
5
  } from "@pagopa/io-wallet-oauth2";
6
- import type { CallbackContext } from "@pagopa/io-wallet-oauth2";
6
+ import type { JwtSignerJwk } from "@pagopa/io-wallet-oauth2";
7
+ import { v4 as uuidv4 } from "uuid";
7
8
  import { LogLevel, Logger } from "../../../utils/logging";
8
9
  import type { IssuanceApi } from "../api";
9
- import { SignJWT } from "@pagopa/io-react-native-jwt";
10
- import { partialCallbacks } from "../../../utils/callbacks";
11
- import { IoWalletError } from "../../../utils/errors";
12
10
  import {
13
- selectCredentialDefinition,
14
- selectResponseMode,
15
- } from "../common/authorization";
11
+ createSignJwtFromCryptoContext,
12
+ partialCallbacks,
13
+ } from "../../../utils/callbacks";
14
+ import { IoWalletError } from "../../../utils/errors";
15
+ import { sdkConfigV1_3 } from "../../../utils/config";
16
+ import { selectCredentialDefinition } from "../common/02-start-user-authorization";
16
17
 
17
18
  export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
18
19
  async (issuerConf, credentialIds, proof, ctx) => {
@@ -33,8 +34,6 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
33
34
  throw new IoWalletError("No public key found");
34
35
  }
35
36
 
36
- const responseMode = selectResponseMode(issuerConf, credentialIds);
37
-
38
37
  const credentialDefinition = credentialIds.map((c) =>
39
38
  selectCredentialDefinition(issuerConf, c)
40
39
  );
@@ -54,13 +53,16 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
54
53
  });
55
54
  }
56
55
 
57
- const signerJwk = await wiaCryptoContext.getPublicKey();
58
- const signJwt: CallbackContext["signJwt"] = async (_, payload) => ({
59
- jwt: await new SignJWT(wiaCryptoContext).setPayload(payload).sign(),
60
- signerJwk,
61
- });
56
+ const wiaSigner: JwtSignerJwk = {
57
+ method: "jwk",
58
+ alg: "ES256",
59
+ publicJwk: await wiaCryptoContext.getPublicKey(),
60
+ };
61
+
62
+ const signJwt = createSignJwtFromCryptoContext(wiaCryptoContext);
62
63
 
63
64
  const parRequest = await createPushedAuthorizationRequest({
65
+ config: sdkConfigV1_3,
64
66
  callbacks: {
65
67
  ...partialCallbacks,
66
68
  signJwt,
@@ -68,25 +70,27 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
68
70
  authorizationServerMetadata: {
69
71
  require_signed_request_object: true,
70
72
  },
73
+ jti: uuidv4(),
71
74
  clientId,
72
75
  audience: issuerConf.credential_issuer,
73
76
  authorization_details: credentialDefinition,
74
77
  codeChallengeMethodsSupported: ["S256"],
75
- responseMode,
76
78
  redirectUri,
79
+ dpop: {
80
+ signer: wiaSigner,
81
+ },
77
82
  });
78
83
 
79
84
  const clientAttestationPoP = await createClientAttestationPopJwt({
85
+ config: sdkConfigV1_3,
80
86
  callbacks: {
87
+ generateRandom: partialCallbacks.generateRandom,
81
88
  signJwt,
82
89
  },
83
90
  clientAttestation: walletInstanceAttestation,
84
91
  authorizationServer: issuerConf.authorization_endpoint,
85
- signer: {
86
- method: "jwk",
87
- alg: "ES256",
88
- publicJwk: signerJwk,
89
- },
92
+ signer: wiaSigner,
93
+ jti: uuidv4(),
90
94
  });
91
95
 
92
96
  const { request_uri } = await fetchPushedAuthorizationResponse({
@@ -16,11 +16,11 @@ import { AuthorizationError, AuthorizationIdpError } from "../common/errors";
16
16
  import { LogLevel, Logger } from "../../../utils/logging";
17
17
  import { RemotePresentation as RemotePresentationFlow } from "../../presentation/v1.3.3";
18
18
  import { partialCallbacks } from "../../../utils/callbacks";
19
+ import { sdkConfigV1_3 } from "../../../utils/config";
19
20
  import {
20
21
  IoWalletError,
21
22
  sdkUnexpectedStatusCodeToIssuerError,
22
23
  } from "../../../utils/errors";
23
- import { sdkConfigV1_3 } from "../../../utils/config";
24
24
  import type { IssuanceApi } from "../api";
25
25
  import { mapToRequestObject } from "./mappers";
26
26
  import type { RemotePresentation } from "../../presentation";
@@ -1,10 +1,15 @@
1
- import { SignJWT } from "@pagopa/io-react-native-jwt";
2
- import { createTokenDPoP, fetchTokenResponse } from "@pagopa/io-wallet-oauth2";
1
+ import {
2
+ createClientAttestationPopJwt,
3
+ createTokenDPoP,
4
+ fetchTokenResponse,
5
+ } from "@pagopa/io-wallet-oauth2";
3
6
  import { v4 as uuidv4 } from "uuid";
4
- import { createPopToken } from "../../../utils/pop";
5
- import * as WalletInstanceAttestation from "../../../wallet-instance-attestation/v1.0.0/utils";
6
- import { partialCallbacks } from "../../../utils/callbacks";
7
+ import {
8
+ createSignJwtFromCryptoContext,
9
+ partialCallbacks,
10
+ } from "../../../utils/callbacks";
7
11
  import { IoWalletError } from "../../../utils/errors";
12
+ import { sdkConfigV1_3 } from "../../../utils/config";
8
13
  import type { IssuanceApi, TokenResponse } from "../api";
9
14
 
10
15
  export const authorizeAccess: IssuanceApi["authorizeAccess"] = async (
@@ -21,37 +26,37 @@ export const authorizeAccess: IssuanceApi["authorizeAccess"] = async (
21
26
  dPopCryptoContext,
22
27
  } = context;
23
28
 
24
- const dPopSignerJwk = await dPopCryptoContext.getPublicKey();
25
29
  const tokenDPoP = await createTokenDPoP({
26
30
  callbacks: {
27
31
  ...partialCallbacks,
28
- signJwt: async (_, payload) => ({
29
- jwt: await new SignJWT(wiaCryptoContext).setPayload(payload).sign(),
30
- signerJwk: dPopSignerJwk,
31
- }),
32
+ signJwt: createSignJwtFromCryptoContext(dPopCryptoContext),
32
33
  },
33
34
  signer: {
34
- alg: "ES256",
35
35
  method: "jwk",
36
- publicJwk: dPopSignerJwk,
36
+ alg: "ES256",
37
+ publicJwk: await dPopCryptoContext.getPublicKey(),
37
38
  },
39
+ jti: uuidv4(),
38
40
  tokenRequest: {
39
41
  method: "POST",
40
42
  url: issuerConf.token_endpoint,
41
43
  },
42
44
  });
43
45
 
44
- const iss = WalletInstanceAttestation.decode(walletInstanceAttestation)
45
- .payload.cnf.jwk.kid;
46
-
47
- const signedWiaPoP = await createPopToken(
48
- {
49
- jti: uuidv4(),
50
- aud: issuerConf.credential_issuer,
51
- iss,
46
+ const clientAttestationDPoP = await createClientAttestationPopJwt({
47
+ config: sdkConfigV1_3,
48
+ callbacks: {
49
+ generateRandom: partialCallbacks.generateRandom,
50
+ signJwt: createSignJwtFromCryptoContext(wiaCryptoContext),
52
51
  },
53
- wiaCryptoContext
54
- );
52
+ clientAttestation: walletInstanceAttestation,
53
+ authorizationServer: issuerConf.credential_issuer,
54
+ signer: {
55
+ method: "jwk",
56
+ alg: "ES256",
57
+ publicJwk: await wiaCryptoContext.getPublicKey(),
58
+ },
59
+ });
55
60
 
56
61
  const tokenResponse = await fetchTokenResponse({
57
62
  accessTokenEndpoint: issuerConf.token_endpoint,
@@ -61,7 +66,7 @@ export const authorizeAccess: IssuanceApi["authorizeAccess"] = async (
61
66
  },
62
67
  walletAttestation: walletInstanceAttestation,
63
68
  dPoP: tokenDPoP.jwt,
64
- clientAttestationDPoP: signedWiaPoP,
69
+ clientAttestationDPoP,
65
70
  accessTokenRequest: {
66
71
  code,
67
72
  grant_type: "authorization_code",
@@ -1,11 +1,16 @@
1
1
  import { type CryptoContext, SignJWT } from "@pagopa/io-react-native-jwt";
2
- import { createTokenDPoP } from "@pagopa/io-wallet-oauth2";
2
+ import {
3
+ createTokenDPoP,
4
+ type CallbackContext,
5
+ type JwtSignerJwk,
6
+ } from "@pagopa/io-wallet-oauth2";
3
7
  import {
4
8
  fetchCredentialResponse,
5
9
  createCredentialRequest,
6
10
  } from "@pagopa/io-wallet-oid4vci";
7
11
  import { UnexpectedStatusCodeError as SdkUnexpectedStatusCodeError } from "@pagopa/io-wallet-utils";
8
- import { hasStatusOrThrow } from "../../../utils/misc";
12
+ import { v4 as uuidv4 } from "uuid";
13
+ import { hasStatusOrThrow, type Out } from "../../../utils/misc";
9
14
  import {
10
15
  IoWalletError,
11
16
  IssuerResponseError,
@@ -15,126 +20,116 @@ import {
15
20
  } from "../../../utils/errors";
16
21
  import { LogLevel, Logger } from "../../../utils/logging";
17
22
  import { sdkConfigV1_3 } from "../../../utils/config";
18
- import { partialCallbacks } from "../../../utils/callbacks";
19
- import type { IssuanceApi } from "../api";
23
+ import {
24
+ createSignJwtFromCryptoContext,
25
+ partialCallbacks,
26
+ } from "../../../utils/callbacks";
27
+ import type { IssuanceApi, IssuerConfig } from "../api";
20
28
  import { NonceResponse } from "./types";
29
+ import type { AuthorizeAccessApi } from "../api/04-authorize-access";
21
30
 
22
- export const createNonceProof = async (
23
- nonce: string,
24
- issuer: string,
25
- audience: string,
26
- ctx: CryptoContext
27
- ): Promise<string> => {
28
- const jwk = await ctx.getPublicKey();
29
- return new SignJWT(ctx)
30
- .setPayload({
31
- nonce,
32
- })
33
- .setProtectedHeader({
34
- typ: "openid4vci-proof+jwt",
35
- jwk,
36
- })
37
- .setAudience(audience)
38
- .setIssuer(issuer)
39
- .setIssuedAt()
40
- .setExpirationTime("5min")
41
- .sign();
31
+ type CreateRequestParams = {
32
+ clientId: string;
33
+ credentialIdentifier: string;
34
+ accessToken: Out<AuthorizeAccessApi["authorizeAccess"]>["accessToken"];
35
+ issuerConf: IssuerConfig;
36
+ dPopCryptoContext: CryptoContext;
37
+ credentialCryptoContexts: CryptoContext[];
38
+ keyAttestationJwt: string;
39
+ appFetch?: GlobalFetch["fetch"];
42
40
  };
43
41
 
44
- export const obtainCredential: IssuanceApi["obtainCredential"] = async (
42
+ /**
43
+ * Helper to create a credential request and fetch it from the issuer.
44
+ *
45
+ * When multiple keys are provided as {@link CryptoContext}, a batch is requested.
46
+ *
47
+ * @returns The raw credential response
48
+ */
49
+ export const requestCredentials = async ({
45
50
  issuerConf,
46
51
  accessToken,
52
+ credentialIdentifier,
47
53
  clientId,
48
- credentialDefinition,
49
- context
50
- ) => {
51
- const {
52
- credentialCryptoContext,
53
- dPopCryptoContext,
54
- walletUnitAttestation,
55
- appFetch = fetch,
56
- } = context;
57
- if (!walletUnitAttestation) {
58
- throw new ValidationFailed({
59
- message:
60
- "The Wallet Unit Attestation is required to obtain the credential",
61
- });
62
- }
63
-
64
- const { credential_configuration_id, credential_identifier } =
65
- credentialDefinition;
66
-
67
- // Fetch the nonce from the Credential Issuer
54
+ keyAttestationJwt,
55
+ credentialCryptoContexts,
56
+ dPopCryptoContext,
57
+ appFetch = fetch,
58
+ }: CreateRequestParams) => {
68
59
  const { c_nonce } = await appFetch(issuerConf.nonce_endpoint, {
69
60
  method: "POST",
70
61
  headers: { "Content-Type": "application/json" },
71
62
  })
72
63
  .then(hasStatusOrThrow(200))
73
64
  .then((res) => res.json())
74
- .then((body) => NonceResponse.parse(body));
65
+ .then(NonceResponse.parse);
75
66
 
76
- // Validation of accessTokenResponse.authorization_details if contain credentialDefinition
77
- const containsCredentialDefinition = accessToken.authorization_details.some(
78
- (c) =>
79
- c.credential_configuration_id === credential_configuration_id &&
80
- (credential_identifier
81
- ? c.credential_identifiers.includes(credential_identifier)
82
- : true)
67
+ const keys = await Promise.all(
68
+ credentialCryptoContexts.map(async (ctx) => {
69
+ const publicJwk = await ctx.getPublicKey();
70
+ return { publicJwk, cryptoContext: ctx };
71
+ })
83
72
  );
84
73
 
85
- if (!containsCredentialDefinition) {
86
- Logger.log(
87
- LogLevel.ERROR,
88
- `Credential definition not found in the access token response ${accessToken.authorization_details}`
89
- );
90
- throw new ValidationFailed({
91
- message:
92
- "The access token response does not contain the requested credential",
93
- });
94
- }
74
+ const signJwt: CallbackContext["signJwt"] = async (
75
+ jwtSigner,
76
+ { header, payload }
77
+ ) => {
78
+ if (jwtSigner.method !== "jwk") {
79
+ throw new IoWalletError(`Unsupported signer method: ${jwtSigner.method}`);
80
+ }
95
81
 
96
- const signerJwk = await credentialCryptoContext.getPublicKey();
82
+ const { cryptoContext } =
83
+ keys.find(({ publicJwk }) => publicJwk.kid === jwtSigner.publicJwk.kid) ??
84
+ {};
85
+
86
+ if (!cryptoContext) {
87
+ throw new IoWalletError(
88
+ `Could not find CryptoContext for key ${jwtSigner.publicJwk.kid}`
89
+ );
90
+ }
91
+
92
+ return {
93
+ jwt: await new SignJWT(cryptoContext)
94
+ .setProtectedHeader(header)
95
+ .setPayload(payload)
96
+ .sign(),
97
+ signerJwk: jwtSigner.publicJwk,
98
+ };
99
+ };
100
+
101
+ const signers = keys.map<JwtSignerJwk>(({ publicJwk }) => ({
102
+ alg: "ES256",
103
+ method: "jwk",
104
+ publicJwk,
105
+ }));
97
106
 
98
107
  const credentialRequest = await createCredentialRequest({
99
108
  config: sdkConfigV1_3,
100
109
  callbacks: {
101
110
  hash: partialCallbacks.hash,
102
- signJwt: async (_, payload) => ({
103
- jwt: await new SignJWT(credentialCryptoContext)
104
- .setPayload(payload)
105
- .sign(),
106
- signerJwk,
107
- }),
111
+ signJwt,
108
112
  },
109
113
  clientId,
110
- credential_identifier: credentialDefinition.credential_identifier!,
114
+ credential_identifier: credentialIdentifier,
111
115
  issuerIdentifier: issuerConf.credential_issuer,
116
+ maxBatchSize: issuerConf.credential_issuance_batch_size,
112
117
  nonce: c_nonce,
113
- keyAttestation: walletUnitAttestation,
114
- signers: [
115
- {
116
- alg: "ES256",
117
- method: "jwk",
118
- publicJwk: signerJwk,
119
- },
120
- ],
118
+ keyAttestation: keyAttestationJwt,
119
+ signers,
121
120
  });
122
121
 
123
- const dPopSignerJwk = await dPopCryptoContext.getPublicKey();
124
-
125
122
  const credentialDPoP = await createTokenDPoP({
126
123
  callbacks: {
127
124
  ...partialCallbacks,
128
- signJwt: async (_, payload) => ({
129
- jwt: await new SignJWT(dPopCryptoContext).setPayload(payload).sign(),
130
- signerJwk,
131
- }),
125
+ signJwt: createSignJwtFromCryptoContext(dPopCryptoContext),
132
126
  },
133
127
  signer: {
134
128
  method: "jwk",
135
129
  alg: "ES256",
136
- publicJwk: dPopSignerJwk,
130
+ publicJwk: await dPopCryptoContext.getPublicKey(),
137
131
  },
132
+ jti: uuidv4(),
138
133
  tokenRequest: {
139
134
  method: "POST",
140
135
  url: issuerConf.credential_endpoint,
@@ -142,7 +137,7 @@ export const obtainCredential: IssuanceApi["obtainCredential"] = async (
142
137
  accessToken: accessToken.access_token,
143
138
  });
144
139
 
145
- const credentialRes = await fetchCredentialResponse({
140
+ return await fetchCredentialResponse({
146
141
  callbacks: {
147
142
  fetch: appFetch,
148
143
  },
@@ -151,6 +146,61 @@ export const obtainCredential: IssuanceApi["obtainCredential"] = async (
151
146
  accessToken: accessToken.access_token,
152
147
  dPoP: credentialDPoP.jwt,
153
148
  }).catch(handleObtainCredentialError);
149
+ };
150
+
151
+ export const obtainCredential: IssuanceApi["obtainCredential"] = async (
152
+ issuerConf,
153
+ accessToken,
154
+ clientId,
155
+ credentialDefinition,
156
+ context
157
+ ) => {
158
+ const {
159
+ credentialCryptoContext,
160
+ dPopCryptoContext,
161
+ walletUnitAttestation,
162
+ appFetch = fetch,
163
+ } = context;
164
+ if (!walletUnitAttestation) {
165
+ throw new ValidationFailed({
166
+ message:
167
+ "The Wallet Unit Attestation is required to obtain the credential",
168
+ });
169
+ }
170
+
171
+ const { credential_configuration_id, credential_identifier } =
172
+ credentialDefinition;
173
+
174
+ // Validation of accessTokenResponse.authorization_details if contain credentialDefinition
175
+ const containsCredentialDefinition = accessToken.authorization_details.some(
176
+ (c) =>
177
+ c.credential_configuration_id === credential_configuration_id &&
178
+ (credential_identifier
179
+ ? c.credential_identifiers.includes(credential_identifier)
180
+ : true)
181
+ );
182
+
183
+ if (!containsCredentialDefinition) {
184
+ Logger.log(
185
+ LogLevel.ERROR,
186
+ `Credential definition not found in the access token response ${accessToken.authorization_details}`
187
+ );
188
+ throw new ValidationFailed({
189
+ message:
190
+ "The access token response does not contain the requested credential",
191
+ });
192
+ }
193
+
194
+ const credentialRes = await requestCredentials({
195
+ issuerConf,
196
+ accessToken,
197
+ clientId,
198
+ credentialCryptoContexts: [credentialCryptoContext],
199
+ credentialIdentifier: credential_identifier!,
200
+ dPopCryptoContext,
201
+ keyAttestationJwt: walletUnitAttestation,
202
+ appFetch,
203
+ });
154
204
 
155
205
  Logger.log(
156
206
  LogLevel.DEBUG,
@@ -172,6 +222,51 @@ export const obtainCredential: IssuanceApi["obtainCredential"] = async (
172
222
  };
173
223
  };
174
224
 
225
+ export const obtainCredentialsBatch: IssuanceApi["obtainCredentialsBatch"] =
226
+ async (issuerConf, accessToken, clientId, credentialDefinition, context) => {
227
+ const {
228
+ credentialCryptoContexts,
229
+ dPopCryptoContext,
230
+ walletUnitAttestation,
231
+ appFetch = fetch,
232
+ } = context;
233
+ if (!walletUnitAttestation) {
234
+ throw new ValidationFailed({
235
+ message:
236
+ "The Wallet Unit Attestation is required to obtain the credential",
237
+ });
238
+ }
239
+
240
+ const { credential_configuration_id, credential_identifier } =
241
+ credentialDefinition;
242
+
243
+ const credentialRes = await requestCredentials({
244
+ issuerConf,
245
+ accessToken,
246
+ clientId,
247
+ credentialCryptoContexts,
248
+ credentialIdentifier: credential_identifier,
249
+ dPopCryptoContext,
250
+ keyAttestationJwt: walletUnitAttestation,
251
+ appFetch,
252
+ });
253
+
254
+ // Extract the format corresponding to the credential_configuration_id used
255
+ const issuerCredentialConfig =
256
+ issuerConf.credential_configurations_supported[
257
+ credential_configuration_id
258
+ ];
259
+
260
+ if ("transaction_id" in credentialRes) {
261
+ throw new IoWalletError("Deferred issuance is not currently supported");
262
+ }
263
+
264
+ return credentialRes.credentials.map(({ credential }) => ({
265
+ credential,
266
+ format: issuerCredentialConfig!.format,
267
+ }));
268
+ };
269
+
175
270
  /**
176
271
  * Handle the credential error by mapping it to a custom exception.
177
272
  * If the error is not an instance of {@link SdkUnexpectedStatusCodeError}, it is thrown as is.