@pagopa/io-react-native-wallet 1.7.1 → 2.0.0-next.1

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 (443) hide show
  1. package/README.md +47 -1
  2. package/lib/commonjs/client/generated/wallet-provider.js +49 -20
  3. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
  4. package/lib/commonjs/credential/index.js +5 -1
  5. package/lib/commonjs/credential/index.js.map +1 -1
  6. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
  7. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  8. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
  9. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  10. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
  11. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  12. package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
  13. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  14. package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
  15. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  16. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
  17. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  18. package/lib/commonjs/credential/issuance/README.md +23 -20
  19. package/lib/commonjs/credential/issuance/const.js +1 -1
  20. package/lib/commonjs/credential/issuance/const.js.map +1 -1
  21. package/lib/commonjs/credential/issuance/index.js +3 -3
  22. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  23. package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
  24. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  25. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
  26. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  27. package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
  28. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
  29. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
  30. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  31. package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
  32. package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
  33. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
  34. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  35. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
  36. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  37. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
  38. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  39. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
  40. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
  41. package/lib/commonjs/credential/presentation/README.md +74 -79
  42. package/lib/commonjs/credential/presentation/errors.js +42 -21
  43. package/lib/commonjs/credential/presentation/errors.js.map +1 -1
  44. package/lib/commonjs/credential/presentation/index.js +13 -13
  45. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  46. package/lib/commonjs/credential/presentation/types.js +53 -29
  47. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  48. package/lib/commonjs/credential/status/01-start-flow.js +2 -0
  49. package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
  50. package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
  51. package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
  52. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
  53. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  54. package/lib/commonjs/credential/status/README.md +67 -0
  55. package/lib/commonjs/credential/status/index.js +27 -0
  56. package/lib/commonjs/credential/status/index.js.map +1 -0
  57. package/lib/commonjs/credential/status/types.js +48 -0
  58. package/lib/commonjs/credential/status/types.js.map +1 -0
  59. package/lib/commonjs/credential/trustmark/README.md +62 -0
  60. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
  61. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
  62. package/lib/commonjs/credential/trustmark/index.js +13 -0
  63. package/lib/commonjs/credential/trustmark/index.js.map +1 -0
  64. package/lib/commonjs/index.js +5 -1
  65. package/lib/commonjs/index.js.map +1 -1
  66. package/lib/commonjs/pid/sd-jwt/types.js +18 -2
  67. package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
  68. package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
  69. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  70. package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
  71. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  72. package/lib/commonjs/sd-jwt/index.js +1 -7
  73. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  74. package/lib/commonjs/sd-jwt/types.js +5 -21
  75. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  76. package/lib/commonjs/trust/README.md +147 -0
  77. package/lib/commonjs/trust/chain.js +153 -0
  78. package/lib/commonjs/trust/chain.js.map +1 -0
  79. package/lib/commonjs/trust/errors.js +133 -0
  80. package/lib/commonjs/trust/errors.js.map +1 -0
  81. package/lib/commonjs/trust/index.js +288 -0
  82. package/lib/commonjs/trust/index.js.map +1 -0
  83. package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
  84. package/lib/commonjs/trust/types.js.map +1 -0
  85. package/lib/commonjs/trust/utils.js +70 -0
  86. package/lib/commonjs/trust/utils.js.map +1 -0
  87. package/lib/commonjs/utils/crypto.js +5 -112
  88. package/lib/commonjs/utils/crypto.js.map +1 -1
  89. package/lib/commonjs/utils/decoder.js +2 -0
  90. package/lib/commonjs/utils/decoder.js.map +1 -1
  91. package/lib/commonjs/utils/error-codes.js +22 -2
  92. package/lib/commonjs/utils/error-codes.js.map +1 -1
  93. package/lib/commonjs/utils/errors.js +72 -4
  94. package/lib/commonjs/utils/errors.js.map +1 -1
  95. package/lib/commonjs/utils/logging.js +68 -0
  96. package/lib/commonjs/utils/logging.js.map +1 -0
  97. package/lib/commonjs/utils/misc.js +2 -0
  98. package/lib/commonjs/utils/misc.js.map +1 -1
  99. package/lib/commonjs/utils/par.js +17 -10
  100. package/lib/commonjs/utils/par.js.map +1 -1
  101. package/lib/commonjs/utils/string.js +1 -12
  102. package/lib/commonjs/utils/string.js.map +1 -1
  103. package/lib/commonjs/wallet-instance/index.js +14 -0
  104. package/lib/commonjs/wallet-instance/index.js.map +1 -1
  105. package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
  106. package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
  107. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  108. package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
  109. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  110. package/lib/module/client/generated/wallet-provider.js +40 -15
  111. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  112. package/lib/module/credential/index.js +3 -1
  113. package/lib/module/credential/index.js.map +1 -1
  114. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
  115. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  116. package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
  117. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  118. package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
  119. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  120. package/lib/module/credential/issuance/05-authorize-access.js +17 -11
  121. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  122. package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
  123. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  124. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
  125. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  126. package/lib/module/credential/issuance/README.md +23 -20
  127. package/lib/module/credential/issuance/const.js +1 -1
  128. package/lib/module/credential/issuance/const.js.map +1 -1
  129. package/lib/module/credential/issuance/index.js +2 -2
  130. package/lib/module/credential/issuance/index.js.map +1 -1
  131. package/lib/module/credential/presentation/01-start-flow.js +14 -15
  132. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  133. package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
  134. package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  135. package/lib/module/credential/presentation/03-get-request-object.js +34 -7
  136. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
  137. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
  138. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  139. package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
  140. package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
  141. package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
  142. package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  143. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
  144. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  145. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
  146. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  147. package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
  148. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  149. package/lib/module/credential/presentation/README.md +74 -79
  150. package/lib/module/credential/presentation/errors.js +30 -17
  151. package/lib/module/credential/presentation/errors.js.map +1 -1
  152. package/lib/module/credential/presentation/index.js +6 -6
  153. package/lib/module/credential/presentation/index.js.map +1 -1
  154. package/lib/module/credential/presentation/types.js +49 -27
  155. package/lib/module/credential/presentation/types.js.map +1 -1
  156. package/lib/module/credential/status/01-start-flow.js +2 -0
  157. package/lib/module/credential/status/01-start-flow.js.map +1 -0
  158. package/lib/module/credential/status/02-status-attestation.js +66 -0
  159. package/lib/module/credential/status/02-status-attestation.js.map +1 -0
  160. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
  161. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  162. package/lib/module/credential/status/README.md +67 -0
  163. package/lib/module/credential/status/index.js +5 -0
  164. package/lib/module/credential/status/index.js.map +1 -0
  165. package/lib/module/credential/status/types.js +40 -0
  166. package/lib/module/credential/status/types.js.map +1 -0
  167. package/lib/module/credential/trustmark/README.md +62 -0
  168. package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
  169. package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
  170. package/lib/module/credential/trustmark/index.js +3 -0
  171. package/lib/module/credential/trustmark/index.js.map +1 -0
  172. package/lib/module/index.js +3 -1
  173. package/lib/module/index.js.map +1 -1
  174. package/lib/module/pid/sd-jwt/types.js +16 -1
  175. package/lib/module/pid/sd-jwt/types.js.map +1 -1
  176. package/lib/module/sd-jwt/__test__/index.test.js +22 -34
  177. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  178. package/lib/module/sd-jwt/__test__/types.test.js +11 -23
  179. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  180. package/lib/module/sd-jwt/index.js +1 -7
  181. package/lib/module/sd-jwt/index.js.map +1 -1
  182. package/lib/module/sd-jwt/types.js +4 -19
  183. package/lib/module/sd-jwt/types.js.map +1 -1
  184. package/lib/module/trust/README.md +147 -0
  185. package/lib/module/trust/chain.js +145 -0
  186. package/lib/module/trust/chain.js.map +1 -0
  187. package/lib/module/trust/errors.js +115 -0
  188. package/lib/module/trust/errors.js.map +1 -0
  189. package/lib/module/trust/index.js +269 -0
  190. package/lib/module/trust/index.js.map +1 -0
  191. package/lib/module/{entity/trust → trust}/types.js +25 -46
  192. package/lib/module/trust/types.js.map +1 -0
  193. package/lib/module/trust/utils.js +60 -0
  194. package/lib/module/trust/utils.js.map +1 -0
  195. package/lib/module/utils/crypto.js +4 -107
  196. package/lib/module/utils/crypto.js.map +1 -1
  197. package/lib/module/utils/decoder.js +3 -0
  198. package/lib/module/utils/decoder.js.map +1 -1
  199. package/lib/module/utils/error-codes.js +20 -1
  200. package/lib/module/utils/error-codes.js.map +1 -1
  201. package/lib/module/utils/errors.js +61 -4
  202. package/lib/module/utils/errors.js.map +1 -1
  203. package/lib/module/utils/logging.js +62 -0
  204. package/lib/module/utils/logging.js.map +1 -0
  205. package/lib/module/utils/misc.js +2 -0
  206. package/lib/module/utils/misc.js.map +1 -1
  207. package/lib/module/utils/par.js +17 -9
  208. package/lib/module/utils/par.js.map +1 -1
  209. package/lib/module/utils/string.js +0 -10
  210. package/lib/module/utils/string.js.map +1 -1
  211. package/lib/module/wallet-instance/index.js +13 -0
  212. package/lib/module/wallet-instance/index.js.map +1 -1
  213. package/lib/module/wallet-instance-attestation/README.md +8 -3
  214. package/lib/module/wallet-instance-attestation/index.js +2 -2
  215. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  216. package/lib/module/wallet-instance-attestation/issuing.js +16 -9
  217. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  218. package/lib/module/wallet-instance-attestation/types.js +14 -18
  219. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  220. package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
  221. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  222. package/lib/typescript/credential/index.d.ts +3 -1
  223. package/lib/typescript/credential/index.d.ts.map +1 -1
  224. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
  225. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
  226. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
  227. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
  228. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  229. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
  230. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  231. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
  232. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  233. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
  234. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  235. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
  236. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  237. package/lib/typescript/credential/issuance/const.d.ts +1 -1
  238. package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
  239. package/lib/typescript/credential/issuance/index.d.ts +3 -3
  240. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  241. package/lib/typescript/credential/issuance/types.d.ts +8 -3
  242. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  243. package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
  244. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
  245. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
  246. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
  247. package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
  248. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
  249. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
  250. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
  251. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
  252. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
  253. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
  254. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
  255. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
  256. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  257. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
  258. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  259. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
  260. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
  261. package/lib/typescript/credential/presentation/errors.d.ts +25 -10
  262. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
  263. package/lib/typescript/credential/presentation/index.d.ts +7 -8
  264. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  265. package/lib/typescript/credential/presentation/types.d.ts +137 -307
  266. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  267. package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
  268. package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
  269. package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
  270. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
  271. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
  272. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
  273. package/lib/typescript/credential/status/index.d.ts +7 -0
  274. package/lib/typescript/credential/status/index.d.ts.map +1 -0
  275. package/lib/typescript/credential/status/types.d.ts +305 -0
  276. package/lib/typescript/credential/status/types.d.ts.map +1 -0
  277. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
  278. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
  279. package/lib/typescript/credential/trustmark/index.d.ts +4 -0
  280. package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
  281. package/lib/typescript/index.d.ts +3 -1
  282. package/lib/typescript/index.d.ts.map +1 -1
  283. package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
  284. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
  285. package/lib/typescript/sd-jwt/index.d.ts +20 -72
  286. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  287. package/lib/typescript/sd-jwt/types.d.ts +24 -129
  288. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  289. package/lib/typescript/trust/chain.d.ts +23 -0
  290. package/lib/typescript/trust/chain.d.ts.map +1 -0
  291. package/lib/typescript/trust/errors.d.ts +102 -0
  292. package/lib/typescript/trust/errors.d.ts.map +1 -0
  293. package/lib/typescript/{entity/trust → trust}/index.d.ts +308 -281
  294. package/lib/typescript/trust/index.d.ts.map +1 -0
  295. package/lib/typescript/{entity/trust → trust}/types.d.ts +1714 -1301
  296. package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
  297. package/lib/typescript/trust/utils.d.ts +22 -0
  298. package/lib/typescript/trust/utils.d.ts.map +1 -0
  299. package/lib/typescript/utils/crypto.d.ts +0 -32
  300. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  301. package/lib/typescript/utils/decoder.d.ts.map +1 -1
  302. package/lib/typescript/utils/error-codes.d.ts +20 -0
  303. package/lib/typescript/utils/error-codes.d.ts.map +1 -1
  304. package/lib/typescript/utils/errors.d.ts +55 -10
  305. package/lib/typescript/utils/errors.d.ts.map +1 -1
  306. package/lib/typescript/utils/logging.d.ts +35 -0
  307. package/lib/typescript/utils/logging.d.ts.map +1 -0
  308. package/lib/typescript/utils/misc.d.ts.map +1 -1
  309. package/lib/typescript/utils/par.d.ts +8 -1
  310. package/lib/typescript/utils/par.d.ts.map +1 -1
  311. package/lib/typescript/utils/string.d.ts +0 -7
  312. package/lib/typescript/utils/string.d.ts.map +1 -1
  313. package/lib/typescript/wallet-instance/index.d.ts +8 -0
  314. package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
  315. package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
  316. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  317. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
  318. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  319. package/lib/typescript/wallet-instance-attestation/types.d.ts +60 -102
  320. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  321. package/package.json +9 -10
  322. package/src/client/generated/wallet-provider.ts +52 -17
  323. package/src/credential/index.ts +4 -1
  324. package/src/credential/issuance/01-start-flow.ts +1 -1
  325. package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
  326. package/src/credential/issuance/03-start-user-authorization.ts +48 -22
  327. package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
  328. package/src/credential/issuance/05-authorize-access.ts +29 -11
  329. package/src/credential/issuance/06-obtain-credential.ts +61 -36
  330. package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
  331. package/src/credential/issuance/README.md +23 -20
  332. package/src/credential/issuance/const.ts +1 -1
  333. package/src/credential/issuance/index.ts +6 -3
  334. package/src/credential/presentation/01-start-flow.ts +19 -22
  335. package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
  336. package/src/credential/presentation/03-get-request-object.ts +36 -8
  337. package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
  338. package/src/credential/presentation/05-verify-request-object.ts +115 -30
  339. package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
  340. package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
  341. package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
  342. package/src/credential/presentation/08-send-authorization-response.ts +178 -260
  343. package/src/credential/presentation/README.md +74 -79
  344. package/src/credential/presentation/errors.ts +38 -15
  345. package/src/credential/presentation/index.ts +18 -19
  346. package/src/credential/presentation/types.ts +67 -64
  347. package/src/credential/status/01-start-flow.ts +9 -0
  348. package/src/credential/status/02-status-attestation.ts +105 -0
  349. package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
  350. package/src/credential/status/README.md +67 -0
  351. package/src/credential/status/index.ts +22 -0
  352. package/src/credential/status/types.ts +43 -0
  353. package/src/credential/trustmark/README.md +62 -0
  354. package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
  355. package/src/credential/trustmark/index.ts +8 -0
  356. package/src/index.ts +4 -0
  357. package/src/pid/sd-jwt/types.ts +18 -1
  358. package/src/sd-jwt/__test__/index.test.ts +36 -55
  359. package/src/sd-jwt/__test__/types.test.ts +16 -29
  360. package/src/sd-jwt/index.ts +1 -5
  361. package/src/sd-jwt/types.ts +2 -19
  362. package/src/trust/README.md +147 -0
  363. package/src/trust/chain.ts +227 -0
  364. package/src/trust/errors.ts +136 -0
  365. package/src/{entity/trust → trust}/index.ts +207 -25
  366. package/src/{entity/trust → trust}/types.ts +24 -37
  367. package/src/trust/utils.ts +70 -0
  368. package/src/utils/crypto.ts +4 -106
  369. package/src/utils/decoder.ts +6 -1
  370. package/src/utils/error-codes.ts +23 -0
  371. package/src/utils/errors.ts +119 -15
  372. package/src/utils/logging.ts +68 -0
  373. package/src/utils/misc.ts +5 -0
  374. package/src/utils/par.ts +19 -6
  375. package/src/utils/string.ts +0 -10
  376. package/src/wallet-instance/index.ts +30 -1
  377. package/src/wallet-instance-attestation/README.md +8 -3
  378. package/src/wallet-instance-attestation/index.ts +2 -2
  379. package/src/wallet-instance-attestation/issuing.ts +33 -12
  380. package/src/wallet-instance-attestation/types.ts +18 -22
  381. package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
  382. package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
  383. package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
  384. package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
  385. package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
  386. package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
  387. package/lib/commonjs/entity/trust/chain.js +0 -122
  388. package/lib/commonjs/entity/trust/chain.js.map +0 -1
  389. package/lib/commonjs/entity/trust/index.js +0 -148
  390. package/lib/commonjs/entity/trust/index.js.map +0 -1
  391. package/lib/commonjs/entity/trust/types.js.map +0 -1
  392. package/lib/commonjs/mdoc/converters.js +0 -26
  393. package/lib/commonjs/mdoc/converters.js.map +0 -1
  394. package/lib/commonjs/mdoc/index.js +0 -68
  395. package/lib/commonjs/mdoc/index.js.map +0 -1
  396. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
  397. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  398. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
  399. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  400. package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
  401. package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
  402. package/lib/module/entity/openid-connect/issuer/index.js +0 -20
  403. package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
  404. package/lib/module/entity/openid-connect/issuer/types.js +0 -48
  405. package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
  406. package/lib/module/entity/trust/chain.js +0 -113
  407. package/lib/module/entity/trust/chain.js.map +0 -1
  408. package/lib/module/entity/trust/index.js +0 -131
  409. package/lib/module/entity/trust/index.js.map +0 -1
  410. package/lib/module/entity/trust/types.js.map +0 -1
  411. package/lib/module/mdoc/converters.js +0 -20
  412. package/lib/module/mdoc/converters.js.map +0 -1
  413. package/lib/module/mdoc/index.js +0 -60
  414. package/lib/module/mdoc/index.js.map +0 -1
  415. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
  416. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  417. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
  418. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  419. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
  420. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
  421. package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
  422. package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
  423. package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
  424. package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
  425. package/lib/typescript/entity/trust/chain.d.ts +0 -26
  426. package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
  427. package/lib/typescript/entity/trust/index.d.ts.map +0 -1
  428. package/lib/typescript/mdoc/converters.d.ts +0 -8
  429. package/lib/typescript/mdoc/converters.d.ts.map +0 -1
  430. package/lib/typescript/mdoc/index.d.ts +0 -10
  431. package/lib/typescript/mdoc/index.d.ts.map +0 -1
  432. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
  433. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
  434. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
  435. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
  436. package/src/credential/issuance/02-get-issuer-config.ts +0 -67
  437. package/src/entity/openid-connect/issuer/index.ts +0 -27
  438. package/src/entity/openid-connect/issuer/types.ts +0 -76
  439. package/src/entity/trust/chain.ts +0 -154
  440. package/src/mdoc/converters.ts +0 -26
  441. package/src/mdoc/index.ts +0 -95
  442. package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
  443. package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -1,13 +1,10 @@
1
1
  import { EncryptJwe } from "@pagopa/io-react-native-jwt";
2
2
  import uuid from "react-native-uuid";
3
- import { NoSuitableKeysFoundInEntityConfiguration, CredentialNotFoundError } from "./errors";
3
+ import { getJwksFromConfig } from "./04-retrieve-rp-jwks";
4
+ import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
4
5
  import { hasStatusOrThrow } from "../../utils/misc";
5
6
  import * as z from "zod";
6
- import { Base64 } from "js-base64";
7
- import { prepareVpTokenMdoc } from "../../mdoc";
8
- import { generateRandomAlphaNumericString } from "../../utils/misc";
9
- import { createCryptoContextFor } from "../../utils/crypto";
10
- import { prepareVpToken } from "../../sd-jwt";
7
+ import { RelyingPartyResponseError, ResponseErrorBuilder, UnexpectedStatusCodeError, RelyingPartyResponseErrorCodes } from "../../utils/errors";
11
8
  export const AuthorizationResponse = z.object({
12
9
  status: z.string().optional(),
13
10
  response_code: z.string() /**
@@ -22,24 +19,12 @@ export const AuthorizationResponse = z.object({
22
19
  * Selects a public key (with `use = enc`) from the set of JWK keys
23
20
  * offered by the Relying Party (RP) for encryption.
24
21
  *
25
- * Preference is given to EC keys (P-256 or P-384), followed by RSA keys,
26
- * based on compatibility and common usage for encryption.
27
- *
28
22
  * @param rpJwkKeys - The array of JWKs retrieved from the RP entity configuration.
29
23
  * @returns The first suitable public key found in the list.
30
24
  * @throws {NoSuitableKeysFoundInEntityConfiguration} If no suitable encryption key is found.
31
25
  */
32
26
  export const choosePublicKeyToEncrypt = rpJwkKeys => {
33
- // First try to find RSA keys which are more commonly used for encryption
34
- const encKeys = rpJwkKeys.filter(jwk => jwk.use === "enc");
35
-
36
- // Prioritize EC keys first, then fall back to RSA keys if needed
37
- // io-react-native-jwt support only EC keys with P-256 or P-384 curves
38
- const ecEncKeys = encKeys.filter(jwk => jwk.kty === "EC" && (jwk.crv === "P-256" || jwk.crv === "P-384"));
39
- const rsaEncKeys = encKeys.filter(jwk => jwk.kty === "RSA");
40
-
41
- // Select the first available key based on priority
42
- const encKey = ecEncKeys[0] || rsaEncKeys[0] || encKeys[0];
27
+ const encKey = rpJwkKeys.find(jwk => jwk.use === "enc");
43
28
  if (encKey) {
44
29
  return encKey;
45
30
  }
@@ -48,56 +33,36 @@ export const choosePublicKeyToEncrypt = rpJwkKeys => {
48
33
  throw new NoSuitableKeysFoundInEntityConfiguration("No suitable public key found for encryption.");
49
34
  };
50
35
 
51
- /**
52
- * Builds a URL-encoded form body for a direct POST response without encryption.
53
- *
54
- * @param requestObject - Contains state, nonce, and other relevant info.
55
- * @param payload - Object that contains either the VP token to encrypt and the stringified mapping of the credential disclosures or the error code
56
- * @returns A URL-encoded string suitable for an `application/x-www-form-urlencoded` POST body.
57
- */
58
- export const buildDirectPostBody = async (requestObject, payload) => {
59
- const formUrlEncodedBody = new URLSearchParams({
60
- ...(requestObject.state ? {
61
- state: requestObject.state
62
- } : {}),
63
- ...Object.fromEntries(Object.entries(payload).map(_ref => {
64
- let [key, value] = _ref;
65
- return [key, Array.isArray(value) || typeof value === "object" ? JSON.stringify(value) : value];
66
- }))
67
- });
68
- return formUrlEncodedBody.toString();
69
- };
70
-
71
36
  /**
72
37
  * Builds a URL-encoded form body for a direct POST response using JWT encryption.
73
38
  *
74
39
  * @param jwkKeys - Array of JWKs from the Relying Party for encryption.
75
40
  * @param requestObject - Contains state, nonce, and other relevant info.
76
- * @param payload - Object that contains either the VP token to encrypt and the mapping of the credential disclosures or the error code
77
- * @param generatedNonce - Optional nonce for the `apu` claim in the JWE header, it is used during ISO 18013-7.
78
- * @returns A URL-encoded string for an `application/x-www-form-urlencoded` POST body,
79
- * where `response` contains the encrypted JWE.
41
+ * @param payload - Object that contains the VP token to encrypt and the mapping of the credential disclosures
42
+ * @returns A URL-encoded string for an `application/x-www-form-urlencoded` POST body, where `response` contains the encrypted JWE.
80
43
  */
81
- export const buildDirectPostJwtBody = async (jwkKeys, requestObject, payload, generatedNonce) => {
44
+ export const buildDirectPostJwtBody = async (requestObject, rpConf, payload) => {
82
45
  // Prepare the authorization response payload to be encrypted
83
46
  const authzResponsePayload = JSON.stringify({
84
47
  state: requestObject.state,
85
48
  ...payload
86
49
  });
87
- const encPublicJwk = choosePublicKeyToEncrypt(jwkKeys);
50
+ // Choose a suitable public key for encryption
51
+ const {
52
+ keys
53
+ } = getJwksFromConfig(rpConf);
54
+ const encPublicJwk = choosePublicKeyToEncrypt(keys);
55
+
88
56
  // Encrypt the authorization payload
89
57
  const {
90
- client_metadata
91
- } = requestObject;
58
+ authorization_encrypted_response_alg,
59
+ authorization_encrypted_response_enc
60
+ } = rpConf.openid_credential_verifier;
61
+ const defaultAlg = encPublicJwk.kty === "EC" ? "ECDH-ES" : "RSA-OAEP-256";
92
62
  const encryptedResponse = await new EncryptJwe(authzResponsePayload, {
93
- alg: (client_metadata === null || client_metadata === void 0 ? void 0 : client_metadata.authorization_encrypted_response_alg) || "RSA-OAEP-256",
94
- enc: (client_metadata === null || client_metadata === void 0 ? void 0 : client_metadata.authorization_encrypted_response_enc) || "A256CBC-HS512",
95
- kid: encPublicJwk.kid,
96
- /* ISO 18013-7 */
97
- apv: Base64.encodeURI(requestObject.nonce),
98
- ...(generatedNonce ? {
99
- apu: Base64.encodeURI(generatedNonce)
100
- } : {})
63
+ alg: authorization_encrypted_response_alg || defaultAlg,
64
+ enc: authorization_encrypted_response_enc || "A256CBC-HS512",
65
+ kid: encPublicJwk.kid
101
66
  }).encrypt(encPublicJwk);
102
67
 
103
68
  // Build the x-www-form-urlencoded form body
@@ -111,13 +76,33 @@ export const buildDirectPostJwtBody = async (jwkKeys, requestObject, payload, ge
111
76
  };
112
77
 
113
78
  /**
114
- * Type definition for the function that sends the authorization response
115
- * to the Relying Party, completing the presentation flow.
79
+ * Builds a URL-encoded form body for a direct POST response without encryption.
80
+ *
81
+ * @param requestObject - Contains state, nonce, and other relevant info.
82
+ * @param payload - Object that contains either the VP token to encrypt and the stringified mapping of the credential disclosures or the error code
83
+ * @returns A URL-encoded string suitable for an `application/x-www-form-urlencoded` POST body.
116
84
  */
85
+ export const buildDirectPostBody = async (requestObject, payload) => {
86
+ const formUrlEncodedBody = new URLSearchParams({
87
+ ...(requestObject.state && {
88
+ state: requestObject.state
89
+ }),
90
+ ...Object.entries(payload).reduce((acc, _ref) => {
91
+ let [key, value] = _ref;
92
+ return {
93
+ ...acc,
94
+ [key]: Array.isArray(value) || typeof value === "object" ? JSON.stringify(value) : value
95
+ };
96
+ }, {})
97
+ });
98
+ return formUrlEncodedBody.toString();
99
+ };
117
100
 
118
101
  /**
119
102
  * Type definition for the function that sends the authorization response
120
103
  * to the Relying Party, completing the presentation flow.
104
+ * Use with `presentation_definition`.
105
+ * @deprecated Use `sendAuthorizationResponse`
121
106
  */
122
107
 
123
108
  /**
@@ -131,172 +116,124 @@ export const buildDirectPostJwtBody = async (jwkKeys, requestObject, payload, ge
131
116
  * @param context - Contains optional custom fetch implementation.
132
117
  * @returns Parsed and validated authorization response from the Relying Party.
133
118
  */
134
- export const sendAuthorizationResponse = async function (requestObject, presentationDefinitionId, jwkKeys, remotePresentation) {
135
- var _presentations$;
119
+ export const sendLegacyAuthorizationResponse = async function (requestObject, presentationDefinitionId, remotePresentations, rpConf) {
120
+ var _remotePresentations$;
136
121
  let {
137
122
  appFetch = fetch
138
123
  } = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
139
- const {
140
- generatedNonce,
141
- presentations
142
- } = remotePresentation;
143
124
  /**
144
125
  * 1. Prepare the VP token and presentation submission
145
126
  * If there is only one credential, `vpToken` is a single string.
146
127
  * If there are multiple credential, `vpToken` is an array of string.
147
128
  **/
148
- const vp_token = (presentations === null || presentations === void 0 ? void 0 : presentations.length) === 1 ? (_presentations$ = presentations[0]) === null || _presentations$ === void 0 ? void 0 : _presentations$.vpToken : presentations.map(presentation => presentation.vpToken);
149
- const descriptor_map = presentations.map((presentation, index) => ({
150
- id: presentation.credentialId,
151
- path: (presentations === null || presentations === void 0 ? void 0 : presentations.length) === 1 ? `$` : `$[${index}]`,
152
- format: presentation.format
129
+ const vp_token = (remotePresentations === null || remotePresentations === void 0 ? void 0 : remotePresentations.length) === 1 ? (_remotePresentations$ = remotePresentations[0]) === null || _remotePresentations$ === void 0 ? void 0 : _remotePresentations$.vpToken : remotePresentations.map(remotePresentation => remotePresentation.vpToken);
130
+ const descriptor_map = remotePresentations.map((remotePresentation, index) => ({
131
+ id: remotePresentation.inputDescriptor.id,
132
+ path: remotePresentations.length === 1 ? `$` : `$[${index}]`,
133
+ format: remotePresentation.format
153
134
  }));
154
135
  const presentation_submission = {
155
136
  id: uuid.v4(),
156
137
  definition_id: presentationDefinitionId,
157
138
  descriptor_map
158
139
  };
159
-
160
- // 2. Choose the appropriate request body builder based on response mode
161
- const requestBody = requestObject.response_mode === "direct_post.jwt" ? await buildDirectPostJwtBody(jwkKeys, requestObject, {
140
+ const requestBody = await buildDirectPostJwtBody(requestObject, rpConf, {
162
141
  vp_token,
163
142
  presentation_submission
164
- }, generatedNonce) : await buildDirectPostBody(requestObject, {
165
- vp_token,
166
- presentation_submission: presentation_submission
167
143
  });
168
144
 
169
145
  // 3. Send the authorization response via HTTP POST and validate the response
170
- const authResponse = await appFetch(requestObject.response_uri, {
146
+ return await appFetch(requestObject.response_uri, {
171
147
  method: "POST",
172
148
  headers: {
173
149
  "Content-Type": "application/x-www-form-urlencoded"
174
150
  },
175
151
  body: requestBody
176
- }).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.safeParse);
177
-
178
- // Some Relying Parties may return an empty body.
179
- return authResponse.success ? authResponse.data : {};
152
+ }).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
180
153
  };
181
154
 
182
155
  /**
183
156
  * Type definition for the function that sends the authorization response
184
157
  * to the Relying Party, completing the presentation flow.
158
+ * Use with DCQL queries.
185
159
  */
186
160
 
187
- /**
188
- * Sends the authorization error response to the Relying Party (RP) using the specified `response_mode`.
189
- * This function completes the presentation flow in an OpenID 4 Verifiable Presentations scenario.
190
- *
191
- * @param requestObject - The request details, including presentation requirements.
192
- * @param error - The response error value
193
- * @param jwkKeys - Array of JWKs from the Relying Party for optional encryption.
194
- * @param context - Contains optional custom fetch implementation.
195
- * @returns Parsed and validated authorization response from the Relying Party.
196
- */
197
- export const sendAuthorizationErrorResponse = async function (requestObject, error, jwkKeys) {
161
+ export const sendAuthorizationResponse = async function (requestObject, remotePresentations, rpConf) {
198
162
  let {
199
163
  appFetch = fetch
200
164
  } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
201
- // 2. Choose the appropriate request body builder based on response mode
202
- const requestBody = requestObject.response_mode === "direct_post.jwt" ? await buildDirectPostJwtBody(jwkKeys, requestObject, {
203
- error
204
- }) : await buildDirectPostBody(requestObject, {
205
- error
165
+ // 1. Prepare the VP token as a JSON object with keys corresponding to the DCQL query credential IDs
166
+ const requestBody = await buildDirectPostJwtBody(requestObject, rpConf, {
167
+ vp_token: remotePresentations.reduce((acc, presentation) => ({
168
+ ...acc,
169
+ [presentation.credentialId]: presentation.vpToken
170
+ }), {})
206
171
  });
207
- // 3. Send the authorization error response via HTTP POST and validate the response
172
+
173
+ // 2. Send the authorization response via HTTP POST and validate the response
208
174
  return await appFetch(requestObject.response_uri, {
209
175
  method: "POST",
210
176
  headers: {
211
177
  "Content-Type": "application/x-www-form-urlencoded"
212
178
  },
213
179
  body: requestBody
214
- }).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
180
+ }).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse).catch(handleAuthorizationResponseError);
215
181
  };
216
- export const sendAuthorizationResponseDcql = async function (requestObject, jwkKeys, remotePresentation) {
182
+
183
+ /**
184
+ * Type definition for the function that sends the authorization response
185
+ * to the Relying Party, completing the presentation flow.
186
+ */
187
+
188
+ /**
189
+ * Sends the authorization error response to the Relying Party (RP) using the specified `response_mode`.
190
+ * This function completes the presentation flow in an OpenID 4 Verifiable Presentations scenario.
191
+ *
192
+ * @param requestObject - The request details, including presentation requirements.
193
+ * @param error - The response error value, with description
194
+ * @param context - Contains optional custom fetch implementation.
195
+ * @returns Parsed and validated authorization response from the Relying Party.
196
+ */
197
+ export const sendAuthorizationErrorResponse = async function (requestObject, _ref2) {
198
+ let {
199
+ error,
200
+ errorDescription
201
+ } = _ref2;
217
202
  let {
218
203
  appFetch = fetch
219
- } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
220
- const {
221
- generatedNonce,
222
- presentations
223
- } = remotePresentation;
224
- // 1. Prepare the VP token as a JSON object with keys corresponding to the DCQL query credential IDs
225
- const requestBody = await buildDirectPostJwtBody(jwkKeys, requestObject, {
226
- vp_token: presentations.reduce((acc, presentation) => ({
227
- ...acc,
228
- [presentation.credentialId]: presentation.vpToken
229
- }), {})
230
- }, generatedNonce);
231
-
232
- // 2. Send the authorization response via HTTP POST and validate the response
204
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
205
+ const requestBody = await buildDirectPostBody(requestObject, {
206
+ error,
207
+ error_description: errorDescription
208
+ });
233
209
  return await appFetch(requestObject.response_uri, {
234
210
  method: "POST",
235
211
  headers: {
236
212
  "Content-Type": "application/x-www-form-urlencoded"
237
213
  },
238
214
  body: requestBody
239
- }).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
215
+ }).then(hasStatusOrThrow(200, RelyingPartyResponseError)).then(res => res.json()).then(AuthorizationResponse.parse);
240
216
  };
241
217
 
242
218
  /**
243
- * Prepares remote presentations for a set of credentials.
244
- *
245
- * For each credential, this function:
246
- * - Validates the credential format (currently supports 'mso_mdoc' and 'vc+sd-jwt').
247
- * - Generates a verifiable presentation token (vpToken) using the appropriate method.
248
- * - For ISO 18013-7, generates a special nonce with minimum entropy of 16.
249
- *
250
- * @param credentials - An array of credential items containing format, credential data, requested claims, and key information.
251
- * @param authRequestObject - The authentication request object containing nonce, clientId, and responseUri.
252
- * @returns A promise that resolves to an object containing an array of presentations and the generated nonce.
253
- * @throws {CredentialNotFoundError} When the credential format is unsupported.
219
+ * Handle the the presentation error by mapping it to a custom exception.
220
+ * If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
221
+ * @param e - The error to be handled
222
+ * @throws {RelyingPartyResponseError} with a specific code for more context
254
223
  */
255
- export const prepareRemotePresentations = async (credentials, authRequestObject) => {
256
- /* In case of ISO 18013-7 we need a nonce, it shall have a minimum entropy of 16 */
257
- const generatedNonce = generateRandomAlphaNumericString(16);
258
- const presentations = await Promise.all(credentials.map(async item => {
259
- const {
260
- credentialInputId,
261
- format
262
- } = item;
263
- if (format === "mso_mdoc") {
264
- const {
265
- vp_token
266
- } = await prepareVpTokenMdoc(authRequestObject.nonce, generatedNonce, authRequestObject.clientId, authRequestObject.responseUri, item.doctype, item.keyTag, [item.credential, item.requestedClaims, createCryptoContextFor(item.keyTag)]);
267
- return {
268
- requestedClaims: [...item.requestedClaims.map(_ref2 => {
269
- let {
270
- name
271
- } = _ref2;
272
- return name;
273
- })],
274
- credentialId: credentialInputId,
275
- vpToken: vp_token,
276
- format: "mso_mdoc"
277
- };
278
- }
279
- if (format === "vc+sd-jwt") {
280
- const {
281
- vp_token
282
- } = await prepareVpToken(authRequestObject.nonce, authRequestObject.clientId, [item.credential, item.requestedClaims, createCryptoContextFor(item.keyTag)]);
283
- return {
284
- requestedClaims: [...item.requestedClaims.map(_ref3 => {
285
- let {
286
- name
287
- } = _ref3;
288
- return name;
289
- })],
290
- credentialId: credentialInputId,
291
- vpToken: vp_token,
292
- format: "vc+sd-jwt"
293
- };
294
- }
295
- throw new CredentialNotFoundError(`${format} format is not supported.`);
296
- }));
297
- return {
298
- presentations,
299
- generatedNonce
300
- };
224
+ const handleAuthorizationResponseError = e => {
225
+ if (!(e instanceof UnexpectedStatusCodeError)) {
226
+ throw e;
227
+ }
228
+ throw new ResponseErrorBuilder(RelyingPartyResponseError).handle(400, {
229
+ code: RelyingPartyResponseErrorCodes.InvalidAuthorizationResponse,
230
+ message: "The Authorization Response contains invalid parameters or it is malformed"
231
+ }).handle(403, {
232
+ code: RelyingPartyResponseErrorCodes.InvalidAuthorizationResponse,
233
+ message: "The Authorization Response was forbidden"
234
+ }).handle("*", {
235
+ code: RelyingPartyResponseErrorCodes.RelyingPartyGenericError,
236
+ message: "Unable to successfully send the Authorization Response"
237
+ }).buildFrom(e);
301
238
  };
302
239
  //# sourceMappingURL=08-send-authorization-response.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["EncryptJwe","uuid","NoSuitableKeysFoundInEntityConfiguration","CredentialNotFoundError","hasStatusOrThrow","z","Base64","prepareVpTokenMdoc","generateRandomAlphaNumericString","createCryptoContextFor","prepareVpToken","AuthorizationResponse","object","status","string","optional","response_code","redirect_uri","choosePublicKeyToEncrypt","rpJwkKeys","encKeys","filter","jwk","use","ecEncKeys","kty","crv","rsaEncKeys","encKey","buildDirectPostBody","requestObject","payload","formUrlEncodedBody","URLSearchParams","state","Object","fromEntries","entries","map","_ref","key","value","Array","isArray","JSON","stringify","toString","buildDirectPostJwtBody","jwkKeys","generatedNonce","authzResponsePayload","encPublicJwk","client_metadata","encryptedResponse","alg","authorization_encrypted_response_alg","enc","authorization_encrypted_response_enc","kid","apv","encodeURI","nonce","apu","encrypt","formBody","response","sendAuthorizationResponse","presentationDefinitionId","remotePresentation","_presentations$","appFetch","fetch","arguments","length","undefined","presentations","vp_token","vpToken","presentation","descriptor_map","index","id","credentialId","path","format","presentation_submission","v4","definition_id","requestBody","response_mode","authResponse","response_uri","method","headers","body","then","res","json","safeParse","success","data","sendAuthorizationErrorResponse","error","parse","sendAuthorizationResponseDcql","reduce","acc","prepareRemotePresentations","credentials","authRequestObject","Promise","all","item","credentialInputId","clientId","responseUri","doctype","keyTag","credential","requestedClaims","_ref2","name","_ref3"],"sourceRoot":"../../../../src","sources":["credential/presentation/08-send-authorization-response.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,6BAA6B;AACxD,OAAOC,IAAI,MAAM,mBAAmB;AAGpC,SACEC,wCAAwC,EACxCC,uBAAuB,QAClB,UAAU;AACjB,SAASC,gBAAgB,QAAkB,kBAAkB;AAO7D,OAAO,KAAKC,CAAC,MAAM,KAAK;AAExB,SAASC,MAAM,QAAQ,WA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ACM,UAAU,EACfN,IAAI,CAACO,eAAe,EACpB9G,sBAAsB,CAACuG,IAAI,CAACK,MAAM,CAAC,CAEvC,CAAC;MAED,OAAO;QACLE,eAAe,EAAE,CAAC,GAAGP,IAAI,CAACO,eAAe,CAACjF,GAAG,CAACkF,KAAA;UAAA,IAAC;YAAEC;UAAK,CAAC,GAAAD,KAAA;UAAA,OAAKC,IAAI;QAAA,EAAC,CAAC;QAClEvC,YAAY,EAAE+B,iBAAiB;QAC/BpC,OAAO,EAAED,QAAQ;QACjBQ,MAAM,EAAE;MACV,CAAC;IACH;IAEA,IAAIA,MAAM,KAAK,WAAW,EAAE;MAC1B,MAAM;QAAER;MAAS,CAAC,GAAG,MAAMlE,cAAc,CACvCmG,iBAAiB,CAAChD,KAAK,EACvBgD,iBAAiB,CAACK,QAAQ,EAC1B,CACEF,IAAI,CAACM,UAAU,EACfN,IAAI,CAACO,eAAe,EACpB9G,sBAAsB,CAACuG,IAAI,CAACK,MAAM,CAAC,CAEvC,CAAC;MAED,OAAO;QACLE,eAAe,EAAE,CAAC,GAAGP,IAAI,CAACO,eAAe,CAACjF,GAAG,CAACoF,KAAA;UAAA,IAAC;YAAED;UAAK,CAAC,GAAAC,KAAA;UAAA,OAAKD,IAAI;QAAA,EAAC,CAAC;QAClEvC,YAAY,EAAE+B,iBAAiB;QAC/BpC,OAAO,EAAED,QAAQ;QACjBQ,MAAM,EAAE;MACV,CAAC;IACH;IAEA,MAAM,IAAIjF,uBAAuB,CAAE,GAAEiF,MAAO,2BAA0B,CAAC;EACzE,CAAC,CACH,CAAC;EAED,OAAO;IACLT,aAAa;IACb1B;EACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["EncryptJwe","uuid","getJwksFromConfig","NoSuitableKeysFoundInEntityConfiguration","hasStatusOrThrow","z","RelyingPartyResponseError","ResponseErrorBuilder","UnexpectedStatusCodeError","RelyingPartyResponseErrorCodes","AuthorizationResponse","object","status","string","optional","response_code","redirect_uri","choosePublicKeyToEncrypt","rpJwkKeys","encKey","find","jwk","use","buildDirectPostJwtBody","requestObject","rpConf","payload","authzResponsePayload","JSON","stringify","state","keys","encPublicJwk","authorization_encrypted_response_alg","authorization_encrypted_response_enc","openid_credential_verifier","defaultAlg","kty","encryptedResponse","alg","enc","kid","encrypt","formBody","URLSearchParams","response","toString","buildDirectPostBody","formUrlEncodedBody","Object","entries","reduce","acc","_ref","key","value","Array","isArray","sendLegacyAuthorizationResponse","presentationDefinitionId","remotePresentations","_remotePresentations$","appFetch","fetch","arguments","length","undefined","vp_token","vpToken","map","remotePresentation","descriptor_map","index","id","inputDescriptor","path","format","presentation_submission","v4","definition_id","requestBody","response_uri","method","headers","body","then","res","json","parse","sendAuthorizationResponse","presentation","credentialId","catch","handleAuthorizationResponseError","sendAuthorizationErrorResponse","_ref2","error","errorDescription","error_description","e","handle","code","InvalidAuthorizationResponse","message","RelyingPartyGenericError","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/presentation/08-send-authorization-response.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,6BAA6B;AACxD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,iBAAiB,QAAwB,uBAAuB;AAEzE,SAASC,wCAAwC,QAAQ,UAAU;AACnE,SAASC,gBAAgB,QAAkB,kBAAkB;AAO7D,OAAO,KAAKC,CAAC,MAAM,KAAK;AAGxB,SACEC,yBAAyB,EACzBC,oBAAoB,EACpBC,yBAAyB,EACzBC,8BAA8B,QACzB,oBAAoB;AAG3B,OAAO,MAAMC,qBAAqB,GAAGL,CAAC,CAACM,MAAM,CAAC;EAC5CC,MAAM,EAAEP,CAAC,CAACQ,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BC,aAAa,EAAEV,CAAC,CACbQ,MAAM,CAAC,CAAC,CAAC;AACd;AACA;AACA;AACA,8BAJc,CAKTC,QAAQ,CAAC,CAAC;EACbE,YAAY,EAAEX,CAAC,CAACQ,MAAM,CAAC,CAAC,CAACC,QAAQ,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AAE;IAC3DwE,KAAK;IACLE,iBAAiB,EAAED;EACrB,CAAC,CAAC;EAEF,OAAO,MAAMnC,QAAQ,CAACtC,aAAa,CAACyD,YAAY,EAAE;IAChDC,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE;IAClB,CAAC;IACDC,IAAI,EAAEJ;EACR,CAAC,CAAC,CACCK,IAAI,CAACjF,gBAAgB,CAAC,GAAG,EAAEE,yBAAyB,CAAC,CAAC,CACtD+E,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAC3E,qBAAqB,CAAC8E,KAAK,CAAC;AACtC,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,gCAAgC,GAAIM,CAAU,IAAK;EACvD,IAAI,EAAEA,CAAC,YAAY3F,yBAAyB,CAAC,EAAE;IAC7C,MAAM2F,CAAC;EACT;EAEA,MAAM,IAAI5F,oBAAoB,CAACD,yBAAyB,CAAC,CACtD8F,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE5F,8BAA8B,CAAC6F,4BAA4B;IACjEC,OAAO,EACL;EACJ,CAAC,CAAC,CACDH,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE5F,8BAA8B,CAAC6F,4BAA4B;IACjEC,OAAO,EAAE;EACX,CAAC,CAAC,CACDH,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE5F,8BAA8B,CAAC+F,wBAAwB;IAC7DD,OAAO,EAAE;EACX,CAAC,CAAC,CACDE,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
@@ -1,112 +1,107 @@
1
1
  # Credential Presentation
2
2
 
3
+ This flow is used for remote presentation, allowing a user with a valid Wallet Instance to remotely present credentials to a Relying Party (Verifier). The presentation flow adheres to the [IT Wallet 0.9.x specification](https://italia.github.io/eid-wallet-it-docs/v0.9.3/en/relying-party-solution.html).
4
+
5
+ The Relying Party provides the Wallet with a Request Object that contains the requested credentials and claims. The Wallet validates the Request Object and asks the user for consent. Then the Wallet creates an encrypted Authorization Response that contains the Verifiable Presentation with the requested data (`vp_token`) and sends it to the Relying Party.
6
+
3
7
  ## Sequence Diagram
4
8
 
5
9
  ```mermaid
6
10
  sequenceDiagram
7
- autonumber
8
- participant I as Individual using EUDI Wallet
9
- participant O as Organisational Wallet (Verifier)
10
- participant A as Organisational Wallet (Issuer)
11
-
12
- O->>+I: QR-CODE: Authorisation request (`request_uri`)
13
- I->>+O: GET: Request object, resolved from the `request_uri`
14
- O->>+I: Respond with the Request object
15
- I->>+O: GET: /.well-known/jar-issuer/jwk
16
- O->>+I: Respond with the public key
17
-
18
- I->>+O: POST: VP token response
19
- O->>+A: GET: /.well-known/jwt-vc-issuer/jwk
20
- A->>+O: Respond with the public key
21
- O->>+I: Redirect: Authorisation response
11
+ autonumber
12
+ participant I as User (Wallet Instance)
13
+ participant O as Relying Party (Verifier)
14
+
15
+ O->>+I: QR-CODE: Authorization Request (`request_uri`)
16
+ I->>+O: GET: Verifier's Entity Configuration
17
+ O->>+I: Respond with metadata (including public keys)
18
+ I->>+O: GET: Request Object, resolved from `request_uri`
19
+ O->>+I: Respond with the Request Object
20
+ I->>+I: Validate Request Object and give consent
21
+ I->>+O: POST: Authorization Response with encrypted VP token
22
+ O->>+I: Respond with optional `redirect_uri`
22
23
  ```
23
24
 
24
25
  ## Mapped results
25
26
 
27
+ | Error | Description|
28
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
29
+ | `InvalidRequestObject` | The Request Object is not valid, for instance it is malformed or its signature cannot be verified. |
30
+ | `DcqlError` | The DCQL query cannot be evaluated because it contains errors. |
31
+ | `CredentialsNotFoundError` | The presentation cannot be completed because the Wallet does not contain all requested credentials. The missing credentials can be found in `details`. |
32
+ | `RelyingPartyResponseError` | Error in the Relying Party's response. See the next table for more details. |
33
+
34
+ #### RelyingPartyResponseError
35
+ The following HTTP errors are mapped to a `RelyingPartyResponseError` with specific codes.
36
+
37
+ | HTTP Status | Error Code | Description |
38
+ | ------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
39
+ | `400`, `403` | `ERR_RP_INVALID_AUTHORIZATION_RESPONSE` | The Relying Party rejected the Authorization Response sent by the Wallet because it was deemed invalid. |
40
+ | `*` | `ERR_RP_GENERIC_ERROR` | This is a generic error code to map unexpected errors that occurred when interacting with the Relying Party. |
41
+
42
+
26
43
  ## Examples
27
44
 
28
45
  <details>
29
46
  <summary>Remote Presentation flow</summary>
30
47
 
48
+ **Note:** To successfully complete a remote presentation, the Wallet Instance must be in a valid state with a valid Wallet Instance Attestation.
49
+
31
50
  ```ts
32
- // Scan e retrive qr-code, decode it and get its parameters
33
- const {requestUri, clientId} = ...
34
-
35
- // Retrieve the integrity key tag from the store and create its context
36
- const integrityKeyTag = "example"; // Let's assume this is the key tag used to create the wallet instance
37
- const integrityContext = getIntegrityContext(integrityKeyTag);
38
-
39
- // Let's assume the key esists befor starting the presentation process
40
- const wiaCryptoContext = createCryptoContextFor(WIA_KEYTAG);
41
-
42
- const { WALLET_PROVIDER_BASE_URL, WALLET_EAA_PROVIDER_BASE_URL, REDIRECT_URI } =
43
- env; // Let's assume these are the environment variables
44
-
45
- /**
46
- * Obtains a new Wallet Instance Attestation.
47
- * WARNING: The integrity context must be the same used when creating the Wallet Instance with the same keytag.
48
- */
49
- const walletInstanceAttestation =
50
- await WalletInstanceAttestation.getAttestation({
51
- wiaCryptoContext,
52
- integrityContext,
53
- walletProviderBaseUrl: WALLET_PROVIDER_BASE_URL,
54
- appFetch,
55
- });
51
+ // Retrieve and scan the qr-code, decode it and get its parameters
52
+ const qrCodeParams = decodeQrCode(qrCode)
56
53
 
57
54
  // Start the issuance flow
58
- const { requestURI, clientId } = Credential.Presentation.startFlowFromQR(requestUri, clientId);
55
+ const {
56
+ request_uri,
57
+ client_id,
58
+ request_uri_method,
59
+ state
60
+ } = Credential.Presentation.startFlowFromQR(qrCodeParams);
59
61
 
60
- // If use trust federation: Evaluate issuer trust
61
- const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(clientId);
62
+ // Get the Relying Party's Entity Configuration and evaluate trust
63
+ const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(client_id);
62
64
 
65
+ // Get the Request Object from the RP
63
66
  const { requestObjectEncodedJwt } =
64
- await Credential.Presentation.getRequestObject(requestURI, {
65
- appFetch: appFetch
66
- });
67
-
68
- // Retrieve RP JWK
69
- // If use trust federation: Fetch Jwks from rpConf
70
- const jwks = await Credential.Presentation.fetchJwksFromConfig(rpConf);
67
+ await Credential.Presentation.getRequestObject(request_uri);
71
68
 
72
- // If not use trust: Fetch Jwks from request object
73
- const jwks = await Credential.Presentation.fetchJwksFromRequestObject(
69
+ // Validate the Request Object
70
+ const { requestObject } = await Credential.Presentation.verifyRequestObject(
74
71
  requestObjectEncodedJwt,
75
- { context: { appFetch } }
72
+ { clientId: client_id, rpConf }
76
73
  );
77
74
 
78
- // Verify signature Request Object
79
- const { requestObject } =
80
- await Credential.Presentation.verifyRequestObjectSignature(
81
- requestObjectEncodedJwt,
82
- jwks.keys
83
- );
75
+ // All the credentials that might be requested by the Relying Party
76
+ const credentialsSdJwt = [
77
+ ["credential1_keytag", "eyJraWQiOiItRl82VWdhOG4zVmVnalkyVTdZVUhLMXpMb2FELU5QVGM2M1JNSVNuTGF3IiwidHlwIjoidmMrc2Qtand0IiwiYWxnIjoiRVMyNTYifQ.eyJfc2"],
78
+ ["credential2_keytag", "eyJ0eXAiOiJ2YytzZC1qd3QiLCJhbGciOiJFUzI1NiIsImtpZCI6Ii1GXzZVZ2E4bjNWZWdqWTJVN1lVSEsxekxvYUQtTlBUYzYzUk1JU25MYXcifQ.ew0KIC"]
79
+ ];
84
80
 
85
-
86
- const { presentationDefinition } = await Credential.Presentation.fetchPresentDefinition(
87
- requestObject,
88
- {
89
- appFetch: appFetch,
90
- },
91
- rpConf // If trust federation is used
81
+ const result = Credential.Presentation.evaluateDcqlQuery(
82
+ credentialsSdJwt,
83
+ requestObject.dcql_query as DcqlQuery
92
84
  );
93
85
 
94
- // For each credential, find it and evaluate input descriptor and disclosures
95
- const { requiredDisclosures } = Credential.Presentation.evaluateInputDescriptionForSdJwt4VC(
96
- inputDescriptor,
97
- credential.payload,
98
- disclosures
99
- );
86
+ const credentialsToPresent = result.map(
87
+ ({ requiredDisclosures, ...rest }) => ({
88
+ ...rest,
89
+ requestedClaims: requiredDisclosures.map(([, claimName]) => claimName),
90
+ })
91
+ );
100
92
 
101
- // After confirm disclosures in app
102
- const authResponse = Credential.Presentation.sendAuthorizationResponse(
103
- requestObject,
104
- presentationDefinition,
105
- jwks,
106
- [credential, disclosuresRequested, { appFetch: appFetch }]
93
+ const remotePresentations =
94
+ await Credential.Presentation.prepareRemotePresentations(
95
+ credentialsToPresent,
96
+ requestObject.nonce,
97
+ requestObject.client_id
107
98
  );
108
99
 
109
-
100
+ const authResponse = await Credential.Presentation.sendAuthorizationResponse(
101
+ requestObject,
102
+ remotePresentations,
103
+ rpConf
104
+ );
110
105
  ```
111
106
 
112
- </details>
107
+ </details>