@pagopa/io-react-native-wallet 1.7.1 → 2.0.0-next.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 (438) 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/{entity/trust → trust}/chain.js +49 -55
  77. package/lib/commonjs/trust/chain.js.map +1 -0
  78. package/lib/commonjs/trust/errors.js +110 -0
  79. package/lib/commonjs/trust/errors.js.map +1 -0
  80. package/lib/commonjs/trust/index.js +282 -0
  81. package/lib/commonjs/trust/index.js.map +1 -0
  82. package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
  83. package/lib/commonjs/trust/types.js.map +1 -0
  84. package/lib/commonjs/trust/utils.js +41 -0
  85. package/lib/commonjs/trust/utils.js.map +1 -0
  86. package/lib/commonjs/utils/crypto.js +5 -112
  87. package/lib/commonjs/utils/crypto.js.map +1 -1
  88. package/lib/commonjs/utils/decoder.js +2 -0
  89. package/lib/commonjs/utils/decoder.js.map +1 -1
  90. package/lib/commonjs/utils/error-codes.js +22 -2
  91. package/lib/commonjs/utils/error-codes.js.map +1 -1
  92. package/lib/commonjs/utils/errors.js +72 -4
  93. package/lib/commonjs/utils/errors.js.map +1 -1
  94. package/lib/commonjs/utils/logging.js +68 -0
  95. package/lib/commonjs/utils/logging.js.map +1 -0
  96. package/lib/commonjs/utils/misc.js +2 -0
  97. package/lib/commonjs/utils/misc.js.map +1 -1
  98. package/lib/commonjs/utils/par.js +17 -10
  99. package/lib/commonjs/utils/par.js.map +1 -1
  100. package/lib/commonjs/utils/string.js +1 -12
  101. package/lib/commonjs/utils/string.js.map +1 -1
  102. package/lib/commonjs/wallet-instance/index.js +14 -0
  103. package/lib/commonjs/wallet-instance/index.js.map +1 -1
  104. package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
  105. package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
  106. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  107. package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
  108. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  109. package/lib/module/client/generated/wallet-provider.js +40 -15
  110. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  111. package/lib/module/credential/index.js +3 -1
  112. package/lib/module/credential/index.js.map +1 -1
  113. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
  114. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  115. package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
  116. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  117. package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
  118. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  119. package/lib/module/credential/issuance/05-authorize-access.js +17 -11
  120. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  121. package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
  122. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  123. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
  124. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  125. package/lib/module/credential/issuance/README.md +23 -20
  126. package/lib/module/credential/issuance/const.js +1 -1
  127. package/lib/module/credential/issuance/const.js.map +1 -1
  128. package/lib/module/credential/issuance/index.js +2 -2
  129. package/lib/module/credential/issuance/index.js.map +1 -1
  130. package/lib/module/credential/presentation/01-start-flow.js +14 -15
  131. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  132. package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
  133. package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  134. package/lib/module/credential/presentation/03-get-request-object.js +34 -7
  135. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
  136. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
  137. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  138. package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
  139. package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
  140. package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
  141. package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  142. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
  143. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  144. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
  145. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  146. package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
  147. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  148. package/lib/module/credential/presentation/README.md +74 -79
  149. package/lib/module/credential/presentation/errors.js +30 -17
  150. package/lib/module/credential/presentation/errors.js.map +1 -1
  151. package/lib/module/credential/presentation/index.js +6 -6
  152. package/lib/module/credential/presentation/index.js.map +1 -1
  153. package/lib/module/credential/presentation/types.js +49 -27
  154. package/lib/module/credential/presentation/types.js.map +1 -1
  155. package/lib/module/credential/status/01-start-flow.js +2 -0
  156. package/lib/module/credential/status/01-start-flow.js.map +1 -0
  157. package/lib/module/credential/status/02-status-attestation.js +66 -0
  158. package/lib/module/credential/status/02-status-attestation.js.map +1 -0
  159. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
  160. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  161. package/lib/module/credential/status/README.md +67 -0
  162. package/lib/module/credential/status/index.js +5 -0
  163. package/lib/module/credential/status/index.js.map +1 -0
  164. package/lib/module/credential/status/types.js +40 -0
  165. package/lib/module/credential/status/types.js.map +1 -0
  166. package/lib/module/credential/trustmark/README.md +62 -0
  167. package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
  168. package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
  169. package/lib/module/credential/trustmark/index.js +3 -0
  170. package/lib/module/credential/trustmark/index.js.map +1 -0
  171. package/lib/module/index.js +3 -1
  172. package/lib/module/index.js.map +1 -1
  173. package/lib/module/pid/sd-jwt/types.js +16 -1
  174. package/lib/module/pid/sd-jwt/types.js.map +1 -1
  175. package/lib/module/sd-jwt/__test__/index.test.js +22 -34
  176. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  177. package/lib/module/sd-jwt/__test__/types.test.js +11 -23
  178. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  179. package/lib/module/sd-jwt/index.js +1 -7
  180. package/lib/module/sd-jwt/index.js.map +1 -1
  181. package/lib/module/sd-jwt/types.js +4 -19
  182. package/lib/module/sd-jwt/types.js.map +1 -1
  183. package/lib/module/trust/chain.js +108 -0
  184. package/lib/module/trust/chain.js.map +1 -0
  185. package/lib/module/trust/errors.js +94 -0
  186. package/lib/module/trust/errors.js.map +1 -0
  187. package/lib/module/trust/index.js +263 -0
  188. package/lib/module/trust/index.js.map +1 -0
  189. package/lib/module/{entity/trust → trust}/types.js +25 -46
  190. package/lib/module/trust/types.js.map +1 -0
  191. package/lib/module/trust/utils.js +33 -0
  192. package/lib/module/trust/utils.js.map +1 -0
  193. package/lib/module/utils/crypto.js +4 -107
  194. package/lib/module/utils/crypto.js.map +1 -1
  195. package/lib/module/utils/decoder.js +3 -0
  196. package/lib/module/utils/decoder.js.map +1 -1
  197. package/lib/module/utils/error-codes.js +20 -1
  198. package/lib/module/utils/error-codes.js.map +1 -1
  199. package/lib/module/utils/errors.js +61 -4
  200. package/lib/module/utils/errors.js.map +1 -1
  201. package/lib/module/utils/logging.js +62 -0
  202. package/lib/module/utils/logging.js.map +1 -0
  203. package/lib/module/utils/misc.js +2 -0
  204. package/lib/module/utils/misc.js.map +1 -1
  205. package/lib/module/utils/par.js +17 -9
  206. package/lib/module/utils/par.js.map +1 -1
  207. package/lib/module/utils/string.js +0 -10
  208. package/lib/module/utils/string.js.map +1 -1
  209. package/lib/module/wallet-instance/index.js +13 -0
  210. package/lib/module/wallet-instance/index.js.map +1 -1
  211. package/lib/module/wallet-instance-attestation/README.md +8 -3
  212. package/lib/module/wallet-instance-attestation/index.js +2 -2
  213. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  214. package/lib/module/wallet-instance-attestation/issuing.js +16 -9
  215. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  216. package/lib/module/wallet-instance-attestation/types.js +14 -18
  217. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  218. package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
  219. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  220. package/lib/typescript/credential/index.d.ts +3 -1
  221. package/lib/typescript/credential/index.d.ts.map +1 -1
  222. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
  223. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
  224. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
  225. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
  226. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  227. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
  228. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  229. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
  230. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  231. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
  232. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  233. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
  234. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  235. package/lib/typescript/credential/issuance/const.d.ts +1 -1
  236. package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
  237. package/lib/typescript/credential/issuance/index.d.ts +3 -3
  238. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  239. package/lib/typescript/credential/issuance/types.d.ts +8 -3
  240. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  241. package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
  242. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
  243. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
  244. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
  245. package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
  246. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
  247. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
  248. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
  249. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
  250. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
  251. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
  252. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
  253. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
  254. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  255. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
  256. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  257. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
  258. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
  259. package/lib/typescript/credential/presentation/errors.d.ts +25 -10
  260. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
  261. package/lib/typescript/credential/presentation/index.d.ts +7 -8
  262. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  263. package/lib/typescript/credential/presentation/types.d.ts +137 -307
  264. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  265. package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
  266. package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
  267. package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
  268. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
  269. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
  270. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
  271. package/lib/typescript/credential/status/index.d.ts +7 -0
  272. package/lib/typescript/credential/status/index.d.ts.map +1 -0
  273. package/lib/typescript/credential/status/types.d.ts +305 -0
  274. package/lib/typescript/credential/status/types.d.ts.map +1 -0
  275. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
  276. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
  277. package/lib/typescript/credential/trustmark/index.d.ts +4 -0
  278. package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
  279. package/lib/typescript/index.d.ts +3 -1
  280. package/lib/typescript/index.d.ts.map +1 -1
  281. package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
  282. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
  283. package/lib/typescript/sd-jwt/index.d.ts +30 -82
  284. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  285. package/lib/typescript/sd-jwt/types.d.ts +29 -134
  286. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  287. package/lib/typescript/{entity/trust → trust}/chain.d.ts +5 -10
  288. package/lib/typescript/trust/chain.d.ts.map +1 -0
  289. package/lib/typescript/trust/errors.d.ts +80 -0
  290. package/lib/typescript/trust/errors.d.ts.map +1 -0
  291. package/lib/typescript/{entity/trust → trust}/index.d.ts +211 -186
  292. package/lib/typescript/trust/index.d.ts.map +1 -0
  293. package/lib/typescript/{entity/trust → trust}/types.d.ts +1533 -1120
  294. package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
  295. package/lib/typescript/trust/utils.d.ts +12 -0
  296. package/lib/typescript/trust/utils.d.ts.map +1 -0
  297. package/lib/typescript/utils/crypto.d.ts +0 -32
  298. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  299. package/lib/typescript/utils/decoder.d.ts.map +1 -1
  300. package/lib/typescript/utils/error-codes.d.ts +20 -0
  301. package/lib/typescript/utils/error-codes.d.ts.map +1 -1
  302. package/lib/typescript/utils/errors.d.ts +55 -10
  303. package/lib/typescript/utils/errors.d.ts.map +1 -1
  304. package/lib/typescript/utils/logging.d.ts +35 -0
  305. package/lib/typescript/utils/logging.d.ts.map +1 -0
  306. package/lib/typescript/utils/misc.d.ts.map +1 -1
  307. package/lib/typescript/utils/par.d.ts +8 -1
  308. package/lib/typescript/utils/par.d.ts.map +1 -1
  309. package/lib/typescript/utils/string.d.ts +0 -7
  310. package/lib/typescript/utils/string.d.ts.map +1 -1
  311. package/lib/typescript/wallet-instance/index.d.ts +8 -0
  312. package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
  313. package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
  314. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  315. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
  316. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  317. package/lib/typescript/wallet-instance-attestation/types.d.ts +78 -120
  318. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  319. package/package.json +8 -9
  320. package/src/client/generated/wallet-provider.ts +52 -17
  321. package/src/credential/index.ts +4 -1
  322. package/src/credential/issuance/01-start-flow.ts +1 -1
  323. package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
  324. package/src/credential/issuance/03-start-user-authorization.ts +48 -22
  325. package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
  326. package/src/credential/issuance/05-authorize-access.ts +29 -11
  327. package/src/credential/issuance/06-obtain-credential.ts +61 -36
  328. package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
  329. package/src/credential/issuance/README.md +23 -20
  330. package/src/credential/issuance/const.ts +1 -1
  331. package/src/credential/issuance/index.ts +6 -3
  332. package/src/credential/presentation/01-start-flow.ts +19 -22
  333. package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
  334. package/src/credential/presentation/03-get-request-object.ts +36 -8
  335. package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
  336. package/src/credential/presentation/05-verify-request-object.ts +115 -30
  337. package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
  338. package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
  339. package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
  340. package/src/credential/presentation/08-send-authorization-response.ts +178 -260
  341. package/src/credential/presentation/README.md +74 -79
  342. package/src/credential/presentation/errors.ts +38 -15
  343. package/src/credential/presentation/index.ts +18 -19
  344. package/src/credential/presentation/types.ts +67 -64
  345. package/src/credential/status/01-start-flow.ts +9 -0
  346. package/src/credential/status/02-status-attestation.ts +105 -0
  347. package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
  348. package/src/credential/status/README.md +67 -0
  349. package/src/credential/status/index.ts +22 -0
  350. package/src/credential/status/types.ts +43 -0
  351. package/src/credential/trustmark/README.md +62 -0
  352. package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
  353. package/src/credential/trustmark/index.ts +8 -0
  354. package/src/index.ts +4 -0
  355. package/src/pid/sd-jwt/types.ts +18 -1
  356. package/src/sd-jwt/__test__/index.test.ts +36 -55
  357. package/src/sd-jwt/__test__/types.test.ts +16 -29
  358. package/src/sd-jwt/index.ts +1 -5
  359. package/src/sd-jwt/types.ts +2 -19
  360. package/src/trust/chain.ts +151 -0
  361. package/src/trust/errors.ts +105 -0
  362. package/src/{entity/trust → trust}/index.ts +198 -23
  363. package/src/{entity/trust → trust}/types.ts +24 -37
  364. package/src/trust/utils.ts +35 -0
  365. package/src/utils/crypto.ts +4 -106
  366. package/src/utils/decoder.ts +6 -1
  367. package/src/utils/error-codes.ts +23 -0
  368. package/src/utils/errors.ts +119 -15
  369. package/src/utils/logging.ts +68 -0
  370. package/src/utils/misc.ts +5 -0
  371. package/src/utils/par.ts +19 -6
  372. package/src/utils/string.ts +0 -10
  373. package/src/wallet-instance/index.ts +30 -1
  374. package/src/wallet-instance-attestation/README.md +8 -3
  375. package/src/wallet-instance-attestation/index.ts +2 -2
  376. package/src/wallet-instance-attestation/issuing.ts +33 -12
  377. package/src/wallet-instance-attestation/types.ts +18 -22
  378. package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
  379. package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
  380. package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
  381. package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
  382. package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
  383. package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
  384. package/lib/commonjs/entity/trust/chain.js.map +0 -1
  385. package/lib/commonjs/entity/trust/index.js +0 -148
  386. package/lib/commonjs/entity/trust/index.js.map +0 -1
  387. package/lib/commonjs/entity/trust/types.js.map +0 -1
  388. package/lib/commonjs/mdoc/converters.js +0 -26
  389. package/lib/commonjs/mdoc/converters.js.map +0 -1
  390. package/lib/commonjs/mdoc/index.js +0 -68
  391. package/lib/commonjs/mdoc/index.js.map +0 -1
  392. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
  393. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  394. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
  395. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  396. package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
  397. package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
  398. package/lib/module/entity/openid-connect/issuer/index.js +0 -20
  399. package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
  400. package/lib/module/entity/openid-connect/issuer/types.js +0 -48
  401. package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
  402. package/lib/module/entity/trust/chain.js +0 -113
  403. package/lib/module/entity/trust/chain.js.map +0 -1
  404. package/lib/module/entity/trust/index.js +0 -131
  405. package/lib/module/entity/trust/index.js.map +0 -1
  406. package/lib/module/entity/trust/types.js.map +0 -1
  407. package/lib/module/mdoc/converters.js +0 -20
  408. package/lib/module/mdoc/converters.js.map +0 -1
  409. package/lib/module/mdoc/index.js +0 -60
  410. package/lib/module/mdoc/index.js.map +0 -1
  411. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
  412. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  413. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
  414. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  415. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
  416. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
  417. package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
  418. package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
  419. package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
  420. package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
  421. package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
  422. package/lib/typescript/entity/trust/index.d.ts.map +0 -1
  423. package/lib/typescript/mdoc/converters.d.ts +0 -8
  424. package/lib/typescript/mdoc/converters.d.ts.map +0 -1
  425. package/lib/typescript/mdoc/index.d.ts +0 -10
  426. package/lib/typescript/mdoc/index.d.ts.map +0 -1
  427. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
  428. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
  429. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
  430. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
  431. package/src/credential/issuance/02-get-issuer-config.ts +0 -67
  432. package/src/entity/openid-connect/issuer/index.ts +0 -27
  433. package/src/entity/openid-connect/issuer/types.ts +0 -76
  434. package/src/entity/trust/chain.ts +0 -154
  435. package/src/mdoc/converters.ts +0 -26
  436. package/src/mdoc/index.ts +0 -95
  437. package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
  438. package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -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>
@@ -1,4 +1,5 @@
1
1
  import { IoWalletError, serializeAttrs } from "../../utils/errors";
2
+ export { DcqlError } from "dcql";
2
3
 
3
4
  /**
4
5
  * An error subclass thrown when auth request decode fail
@@ -41,18 +42,33 @@ export class NoSuitableKeysFoundInEntityConfiguration extends IoWalletError {
41
42
  }
42
43
 
43
44
  /**
44
- * When the entity is unverified because the Relying Party is not trusted.
45
+ * When a QR code is not valid.
45
46
  *
46
47
  */
47
- export class UnverifiedEntityError extends IoWalletError {
48
- code = "ERR_UNVERIFIED_RP_ENTITY";
48
+ export class InvalidQRCodeError extends IoWalletError {
49
+ code = "ERR_INVALID_QR_CODE";
50
+
51
+ /** Detailed reason for the QR code validation failure. */
52
+ reason: string;
49
53
 
50
- /**
51
- * @param reason A description of why the entity cannot be verified.
52
- */
53
54
  constructor(reason: string) {
54
- const message = `Unverified entity: ${reason}.`;
55
+ super("Invalid QR code");
56
+ this.reason = reason;
57
+ }
58
+ }
59
+
60
+ /**
61
+ * When the Request Object sent by the Relying Party is not valid
62
+ */
63
+ export class InvalidRequestObjectError extends IoWalletError {
64
+ code = "ERR_INVALID_REQUEST_OBJECT";
65
+
66
+ /** Detailed reason for the Request Object validation failure. */
67
+ reason: string;
68
+
69
+ constructor(message: string, reason = "unspecified") {
55
70
  super(message);
71
+ this.reason = reason;
56
72
  }
57
73
  }
58
74
 
@@ -72,18 +88,25 @@ export class MissingDataError extends IoWalletError {
72
88
  }
73
89
  }
74
90
 
91
+ export type NotFoundDetail = {
92
+ id: string;
93
+ reason?: string;
94
+ vctValues?: string[];
95
+ };
96
+
75
97
  /**
76
- * When a credential is not found in the wallet.
77
- *
98
+ * Error thrown when one or more credentials cannot be found in the wallet
99
+ * and the presentation request cannot be satisfied.
78
100
  */
79
- export class CredentialNotFoundError extends IoWalletError {
80
- code = "ERR_CREDENTIAL_NOT_FOUND";
101
+ export class CredentialsNotFoundError extends IoWalletError {
102
+ code = "ERR_CREDENTIALS_NOT_FOUND";
103
+ details: NotFoundDetail[];
81
104
 
82
105
  /**
83
- * @param credentialId The ID of the credential that was not found.
106
+ * @param details The details of the credentials that could not be found.
84
107
  */
85
- constructor(credentialId: string) {
86
- const message = `Credential not found: ${credentialId}.`;
87
- super(message);
108
+ constructor(details: NotFoundDetail[]) {
109
+ super("One or more credentials cannot be found in the wallet");
110
+ this.details = details;
88
111
  }
89
112
  }
@@ -7,14 +7,10 @@ import {
7
7
  getRequestObject,
8
8
  type GetRequestObject,
9
9
  } from "./03-get-request-object";
10
+ import { getJwksFromConfig, type FetchJwks } from "./04-retrieve-rp-jwks";
10
11
  import {
11
- fetchJwksFromRequestObject,
12
- fetchJwksFromConfig,
13
- type FetchJwks,
14
- } from "./04-retrieve-rp-jwks";
15
- import {
16
- verifyRequestObjectSignature,
17
- type VerifyRequestObjectSignature,
12
+ verifyRequestObject,
13
+ type VerifyRequestObject,
18
14
  } from "./05-verify-request-object";
19
15
  import {
20
16
  fetchPresentDefinition,
@@ -22,38 +18,40 @@ import {
22
18
  } from "./06-fetch-presentation-definition";
23
19
  import {
24
20
  evaluateInputDescriptors,
21
+ prepareLegacyRemotePresentations,
25
22
  type EvaluateInputDescriptors,
23
+ type PrepareLegacyRemotePresentations,
26
24
  } from "./07-evaluate-input-descriptor";
27
25
  import {
28
26
  evaluateDcqlQuery,
27
+ prepareRemotePresentations,
29
28
  type EvaluateDcqlQuery,
29
+ type PrepareRemotePresentations,
30
30
  } from "./07-evaluate-dcql-query";
31
31
  import {
32
- prepareRemotePresentations,
33
32
  sendAuthorizationResponse,
34
33
  type SendAuthorizationResponse,
34
+ sendLegacyAuthorizationResponse,
35
+ type SendLegacyAuthorizationResponse,
35
36
  sendAuthorizationErrorResponse,
36
37
  type SendAuthorizationErrorResponse,
37
- sendAuthorizationResponseDcql,
38
- type SendAuthorizationResponseDcql,
39
38
  } from "./08-send-authorization-response";
40
39
  import * as Errors from "./errors";
41
- import type { PrepareRemotePresentations } from "./types";
42
40
 
43
41
  export {
44
42
  startFlowFromQR,
45
43
  evaluateRelyingPartyTrust,
46
44
  getRequestObject,
47
- fetchJwksFromRequestObject,
48
- fetchJwksFromConfig,
49
- verifyRequestObjectSignature,
45
+ getJwksFromConfig,
46
+ verifyRequestObject,
50
47
  fetchPresentDefinition,
51
48
  evaluateInputDescriptors,
52
49
  evaluateDcqlQuery,
50
+ prepareLegacyRemotePresentations,
51
+ prepareRemotePresentations,
53
52
  sendAuthorizationResponse,
53
+ sendLegacyAuthorizationResponse,
54
54
  sendAuthorizationErrorResponse,
55
- sendAuthorizationResponseDcql,
56
- prepareRemotePresentations,
57
55
  Errors,
58
56
  };
59
57
  export type {
@@ -61,12 +59,13 @@ export type {
61
59
  EvaluateRelyingPartyTrust,
62
60
  GetRequestObject,
63
61
  FetchJwks,
64
- VerifyRequestObjectSignature,
62
+ VerifyRequestObject,
65
63
  FetchPresentationDefinition,
66
64
  EvaluateInputDescriptors,
65
+ EvaluateDcqlQuery,
66
+ PrepareLegacyRemotePresentations,
67
67
  PrepareRemotePresentations,
68
68
  SendAuthorizationResponse,
69
- SendAuthorizationResponseDcql,
69
+ SendLegacyAuthorizationResponse,
70
70
  SendAuthorizationErrorResponse,
71
- EvaluateDcqlQuery,
72
71
  };
@@ -1,58 +1,38 @@
1
1
  import type { CryptoContext } from "@pagopa/io-react-native-jwt";
2
2
  import { UnixTime } from "../../sd-jwt/types";
3
3
  import * as z from "zod";
4
- import { JWKS } from "../../utils/jwk";
5
-
6
- export type EvaluatedDisclosure = {
7
- namespace?: string;
8
- name: string;
9
- value: unknown;
10
- };
11
-
12
- export type CredentialFormat =
13
- | {
14
- format: "vc+sd-jwt";
15
- }
16
- | {
17
- format: "mso_mdoc";
18
- doctype: string;
19
- };
20
4
 
21
5
  /**
22
6
  * A pair that associate a tokenized Verified Credential with the claims presented or requested to present.
23
7
  */
24
8
  export type Presentation = [
25
9
  /* verified credential token */ string,
26
- /* claims */ EvaluatedDisclosure[],
10
+ /* claims */ string[],
27
11
  /* the context for the key associated to the credential */ CryptoContext,
28
12
  ];
29
13
 
30
14
  /**
31
15
  * A object that associate the information needed to multiple remote presentation
16
+ * Used with `presentation_definition`
17
+ * @deprecated Use `RemotePresentation`
32
18
  */
33
- export type RemotePresentation = {
34
- presentations: {
35
- requestedClaims: string[];
36
- credentialId: string;
37
- format: string;
38
- vpToken: string;
39
- }[];
40
- generatedNonce?: string /* nonce generated by app, used in mdoc presentation */;
19
+ export type LegacyRemotePresentation = {
20
+ requestedClaims: string[];
21
+ inputDescriptor: InputDescriptor;
22
+ format: string;
23
+ vpToken: string;
41
24
  };
42
25
 
43
- export type PrepareRemotePresentations = (
44
- credentials: ({
45
- requestedClaims: EvaluatedDisclosure[];
46
- credentialInputId: string; // The credential ID descriptor in the presentation definition or DCQL query
47
- credential: string;
48
- keyTag: string;
49
- } & CredentialFormat)[],
50
- authRequestObject: {
51
- nonce: string;
52
- clientId: string;
53
- responseUri: string;
54
- }
55
- ) => Promise<RemotePresentation>;
26
+ /**
27
+ * A object that associate the information needed to multiple remote presentation
28
+ * Used with DCQL queries
29
+ */
30
+ export type RemotePresentation = {
31
+ requestedClaims: string[];
32
+ credentialId: string;
33
+ format: string;
34
+ vpToken: string;
35
+ };
56
36
 
57
37
  const Fields = z.object({
58
38
  path: z.array(z.string().min(1)), // Array of JSONPath string expressions
@@ -111,57 +91,80 @@ export const PresentationDefinition = z.object({
111
91
 
112
92
  export type RequestObject = z.infer<typeof RequestObject>;
113
93
  export const RequestObject = z.object({
114
- iss: z.string().optional(), //optional by RFC 7519, mandatory for Potential
115
- iat: UnixTime.optional(),
116
- exp: UnixTime.optional(),
94
+ iss: z.string(),
95
+ iat: UnixTime,
96
+ exp: UnixTime,
117
97
  state: z.string().optional(),
118
98
  nonce: z.string(),
119
99
  response_uri: z.string(),
100
+ response_uri_method: z.string().optional(),
120
101
  response_type: z.literal("vp_token"),
121
- response_mode: z.enum(["direct_post.jwt", "direct_post"]),
102
+ response_mode: z.literal("direct_post.jwt"),
122
103
  client_id: z.string(),
123
- client_id_scheme: z.string().optional(), // previous z.literal("entity_id"),
124
- client_metadata: z
125
- .object({
126
- authorization_encrypted_response_alg: z.string().optional(),
127
- authorization_encrypted_response_enc: z.string().optional(),
128
- jwks_uri: z.string().optional(),
129
- jwks: JWKS.optional(),
130
- })
131
- .optional(), // previous z.literal("entity_id"),
132
104
  dcql_query: z.record(z.string(), z.any()).optional(), // Validation happens within the `dcql` library, no need to duplicate it here
133
105
  scope: z.string().optional(),
134
106
  presentation_definition: PresentationDefinition.optional(),
135
107
  });
136
108
 
109
+ export type WalletMetadata = z.infer<typeof WalletMetadata>;
110
+ export const WalletMetadata = z.object({
111
+ presentation_definition_uri_supported: z.boolean().optional(),
112
+ client_id_schemes_supported: z.array(z.string()).optional(),
113
+ request_object_signing_alg_values_supported: z.array(z.string()).optional(),
114
+ vp_formats_supported: z.record(
115
+ z.string(), // TODO [SIW-2110]: use explicit credential format?
116
+ z.object({
117
+ "sd-jwt_alg_values": z.array(z.string()).optional(), // alg_values_supported?
118
+ })
119
+ ),
120
+ // TODO [SIW-2110]: include other metadata?
121
+ });
122
+
123
+ /**
124
+ * Wallet capabilities that must be submitted to get the Request Object
125
+ * via POST request when the `request_uri_method` is `post`.
126
+ */
127
+ export type RequestObjectWalletCapabilities = z.infer<
128
+ typeof RequestObjectWalletCapabilities
129
+ >;
130
+ export const RequestObjectWalletCapabilities = z.object({
131
+ wallet_metadata: WalletMetadata,
132
+ wallet_nonce: z.string().optional(),
133
+ });
134
+
137
135
  /**
138
136
  * This type models the possible error responses the OpenID4VP protocol allows for a presentation of a credential.
139
- * See https://openid.github.io/OpenID4VP/openid-4-verifiable-presentations-wg-draft.html#name-error-response for more information.
137
+ * When the Wallet encounters one of these errors, it will notify the Relying Party through the `response_uri` endpoint.
138
+ * See https://italia.github.io/eid-wallet-it-docs/versione-corrente/en/pid-eaa-presentation.html#authorization-response-errors for more information.
140
139
  */
141
140
  export type ErrorResponse = z.infer<typeof ErrorResponse>;
142
141
  export const ErrorResponse = z.enum([
143
- "invalid_scope",
142
+ "invalid_request_object",
143
+ "invalid_request_uri",
144
+ "vp_formats_not_supported",
144
145
  "invalid_request",
145
- "invalid_client",
146
146
  "access_denied",
147
+ "invalid_client",
147
148
  ]);
148
149
 
149
150
  /**
150
- * Type that defines the possible payload formats accepted by {@link buildDirectPostJwtBody} and {@link buildDirectPostBody}
151
+ * @deprecated Use `DirectAuthorizationBodyPayload`
152
+ */
153
+ const LegacyDirectAuthorizationBodyPayload = z.object({
154
+ vp_token: z.union([z.string(), z.array(z.string())]).optional(),
155
+ presentation_submission: z.record(z.string(), z.unknown()),
156
+ });
157
+
158
+ /**
159
+ * Authorization Response payload sent to the Relying Party.
151
160
  */
152
161
  export type DirectAuthorizationBodyPayload = z.infer<
153
162
  typeof DirectAuthorizationBodyPayload
154
163
  >;
155
164
  export const DirectAuthorizationBodyPayload = z.union([
156
165
  z.object({
157
- vp_token: z
158
- .union([
159
- z.string(), // Presentation Definition with one credential
160
- z.array(z.string()), // Presentation Definition with more credential
161
- z.record(z.string(), z.string()), // DCQL query
162
- ])
163
- .optional(),
164
- presentation_submission: z.record(z.string(), z.unknown()).optional(),
166
+ vp_token: z.record(z.string(), z.string()),
165
167
  }),
166
- z.object({ error: ErrorResponse }),
168
+ z.object({ error: ErrorResponse, error_description: z.string() }),
169
+ LegacyDirectAuthorizationBodyPayload,
167
170
  ]);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * WARNING: This is the first function to be called in the status attestation flow. The next function to be called is {@link statusAttestation}.
3
+ * The beginning of the status attestation flow.
4
+ *
5
+ * @returns The url of the credential issuer to be used in the next function.
6
+ */
7
+ export type StartFlow = () => {
8
+ issuerUrl: string;
9
+ };
@@ -0,0 +1,105 @@
1
+ import {
2
+ getCredentialHashWithouDiscloures,
3
+ hasStatusOrThrow,
4
+ type Out,
5
+ } from "../../utils/misc";
6
+ import type { EvaluateIssuerTrust, ObtainCredential } from "../issuance";
7
+ import { type CryptoContext, SignJWT } from "@pagopa/io-react-native-jwt";
8
+ import { v4 as uuidv4 } from "uuid";
9
+ import { StatusAttestationResponse } from "./types";
10
+ import {
11
+ IssuerResponseError,
12
+ IssuerResponseErrorCodes,
13
+ ResponseErrorBuilder,
14
+ UnexpectedStatusCodeError,
15
+ } from "../../utils/errors";
16
+ import { LogLevel, Logger } from "../../utils/logging";
17
+
18
+ export type StatusAttestation = (
19
+ issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
20
+ credential: Out<ObtainCredential>["credential"],
21
+ credentialCryptoContext: CryptoContext,
22
+ appFetch?: GlobalFetch["fetch"]
23
+ ) => Promise<{
24
+ statusAttestation: StatusAttestationResponse["status_attestation"];
25
+ }>;
26
+
27
+ /**
28
+ * WARNING: This function must be called after {@link startFlow}.
29
+ * Verify the status of the credential attestation.
30
+ * @param issuerConf - The issuer's configuration
31
+ * @param credential - The credential to be verified
32
+ * @param credentialCryptoContext - The credential's crypto context
33
+ * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
34
+ * @throws {IssuerResponseError} with a specific code for more context
35
+ * @returns The credential status attestation
36
+ */
37
+ export const statusAttestation: StatusAttestation = async (
38
+ issuerConf,
39
+ credential,
40
+ credentialCryptoContext,
41
+ appFetch: GlobalFetch["fetch"] = fetch
42
+ ) => {
43
+ const jwk = await credentialCryptoContext.getPublicKey();
44
+ const credentialHash = await getCredentialHashWithouDiscloures(credential);
45
+ const statusAttUrl =
46
+ issuerConf.openid_credential_issuer.status_attestation_endpoint;
47
+ const credentialPop = await new SignJWT(credentialCryptoContext)
48
+ .setPayload({
49
+ aud: statusAttUrl,
50
+ jti: uuidv4().toString(),
51
+ credential_hash: credentialHash,
52
+ credential_hash_alg: "S256",
53
+ })
54
+ .setProtectedHeader({
55
+ alg: "ES256",
56
+ typ: "status-attestation-request+jwt",
57
+ kid: jwk.kid,
58
+ })
59
+ .setIssuedAt()
60
+ .setExpirationTime("5m")
61
+ .sign();
62
+
63
+ const body = {
64
+ credential_pop: credentialPop,
65
+ };
66
+
67
+ Logger.log(LogLevel.DEBUG, `Credential pop: ${credentialPop}`);
68
+
69
+ const result = await appFetch(statusAttUrl, {
70
+ method: "POST",
71
+ headers: {
72
+ "Content-Type": "application/json",
73
+ },
74
+ body: JSON.stringify(body),
75
+ })
76
+ .then(hasStatusOrThrow(201))
77
+ .then((raw) => raw.json())
78
+ .then((json) => StatusAttestationResponse.parse(json))
79
+ .catch(handleStatusAttestationError);
80
+
81
+ return { statusAttestation: result.status_attestation };
82
+ };
83
+
84
+ /**
85
+ * Handle the status attestation error by mapping it to a custom exception.
86
+ * If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
87
+ * @param e - The error to be handled
88
+ * @throws {IssuerResponseError} with a specific code for more context
89
+ */
90
+ const handleStatusAttestationError = (e: unknown) => {
91
+ if (!(e instanceof UnexpectedStatusCodeError)) {
92
+ throw e;
93
+ }
94
+
95
+ throw new ResponseErrorBuilder(IssuerResponseError)
96
+ .handle(404, {
97
+ code: IssuerResponseErrorCodes.CredentialInvalidStatus,
98
+ message: "Invalid status found for the given credential",
99
+ })
100
+ .handle("*", {
101
+ code: IssuerResponseErrorCodes.StatusAttestationRequestFailed,
102
+ message: `Unable to obtain the status attestation for the given credential`,
103
+ })
104
+ .buildFrom(e);
105
+ };