@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,25 +1,18 @@
1
1
  import type { CryptoContext } from "@pagopa/io-react-native-jwt";
2
- import { CBOR } from "@pagopa/io-react-native-cbor";
3
2
  import type { Out } from "../../utils/misc";
4
- import type { GetIssuerConfig } from "./02-get-issuer-config";
3
+ import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
5
4
  import { IoWalletError } from "../../utils/errors";
6
5
  import { SdJwt4VC } from "../../sd-jwt/types";
7
6
  import { verify as verifySdJwt } from "../../sd-jwt";
8
- import { verify as verifyMdoc } from "../../mdoc";
9
7
  import { getValueFromDisclosures } from "../../sd-jwt/converters";
10
8
  import type { JWK } from "../../utils/jwk";
11
9
  import type { ObtainCredential } from "./06-obtain-credential";
12
- import {
13
- CredentialSdJwtClaims,
14
- CredentialClaim,
15
- } from "../../entity/openid-connect/issuer/types";
16
- import { extractElementValueAsDate } from "../../mdoc/converters";
10
+ import { LogLevel, Logger } from "../../utils/logging";
17
11
 
18
12
  export type VerifyAndParseCredential = (
19
- issuerConf: Out<GetIssuerConfig>["issuerConf"],
13
+ issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
20
14
  credential: Out<ObtainCredential>["credential"],
21
15
  format: Out<ObtainCredential>["format"],
22
- credentialType: string,
23
16
  context: {
24
17
  credentialCryptoContext: CryptoContext;
25
18
  /**
@@ -60,14 +53,9 @@ type DecodedSdJwtCredential = Out<typeof verifySdJwt> & {
60
53
  sdJwt: SdJwt4VC;
61
54
  };
62
55
 
63
- type DecodedMDocCredential = Out<typeof verifyMdoc> & {
64
- issuerSigned: CBOR.IssuerSigned;
65
- };
66
-
67
- //Exported for testing purposes
68
- export const parseCredentialSdJwt = (
56
+ const parseCredentialSdJwt = (
69
57
  // the list of supported credentials, as defined in the issuer configuration
70
- credentials_supported: Out<GetIssuerConfig>["issuerConf"]["credential_configurations_supported"],
58
+ credentials_supported: Out<EvaluateIssuerTrust>["issuerConf"]["openid_credential_issuer"]["credential_configurations_supported"],
71
59
  { sdJwt, disclosures }: DecodedSdJwtCredential,
72
60
  ignoreMissingAttributes: boolean = false,
73
61
  includeUndefinedAttributes: boolean = false
@@ -75,10 +63,18 @@ export const parseCredentialSdJwt = (
75
63
  const credentialSubject = credentials_supported[sdJwt.payload.vct];
76
64
 
77
65
  if (!credentialSubject) {
66
+ Logger.log(
67
+ LogLevel.ERROR,
68
+ `Credential type not supported by the issuer: ${sdJwt.payload.vct}`
69
+ );
78
70
  throw new IoWalletError("Credential type not supported by the issuer");
79
71
  }
80
72
 
81
73
  if (credentialSubject.format !== sdJwt.header.typ) {
74
+ Logger.log(
75
+ LogLevel.ERROR,
76
+ `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`
77
+ );
82
78
  throw new IoWalletError(
83
79
  `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `
84
80
  );
@@ -86,20 +82,23 @@ export const parseCredentialSdJwt = (
86
82
 
87
83
  // transfrom a record { key: value } in an iterable of pairs [key, value]
88
84
  if (!credentialSubject.claims) {
85
+ Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
89
86
  throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
90
87
  }
91
- const claims = credentialSubject.claims as CredentialSdJwtClaims;
92
- const attrDefinitions = Object.entries(claims);
88
+ const attrDefinitions = Object.entries(credentialSubject.claims);
93
89
 
94
90
  // the key of the attribute defintion must match the disclosure's name
95
91
  const attrsNotInDisclosures = attrDefinitions.filter(
96
- ([attrKey, definition]) =>
97
- !disclosures.some(([, name]) => name === attrKey) && definition.mandatory
92
+ ([attrKey]) => !disclosures.some(([, name]) => name === attrKey)
98
93
  );
99
94
  if (attrsNotInDisclosures.length > 0) {
100
95
  const missing = attrsNotInDisclosures.map((_) => _[0 /* key */]).join(", ");
101
96
  const received = disclosures.map((_) => _[1 /* name */]).join(", ");
102
97
  if (!ignoreMissingAttributes) {
98
+ Logger.log(
99
+ LogLevel.ERROR,
100
+ `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
101
+ );
103
102
  throw new IoWalletError(
104
103
  `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
105
104
  );
@@ -123,8 +122,6 @@ export const parseCredentialSdJwt = (
123
122
  },
124
123
  ] as const
125
124
  )
126
- //filter the not found elements
127
- .filter(([_, definition]) => definition.value !== undefined)
128
125
  // add a human readable attribute name, with i18n, in the form { locale: name }
129
126
  // example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
130
127
  .map(
@@ -159,136 +156,6 @@ export const parseCredentialSdJwt = (
159
156
  return definedValues;
160
157
  };
161
158
 
162
- //Exported for testing purposes
163
- export const parseCredentialMDoc = (
164
- // the list of supported credentials, as defined in the issuer configuration
165
- credentials_supported: Out<GetIssuerConfig>["issuerConf"]["credential_configurations_supported"],
166
- credential_type: string,
167
- { issuerSigned }: DecodedMDocCredential,
168
- ignoreMissingAttributes: boolean = false,
169
- includeUndefinedAttributes: boolean = false
170
- ): ParsedCredential => {
171
- const credentialSubject = credentials_supported[credential_type];
172
-
173
- if (!credentialSubject) {
174
- throw new IoWalletError("Credential type not supported by the issuer");
175
- }
176
-
177
- // transfrom a record { key: value } in an iterable of pairs [key, value]
178
- if (!credentialSubject.claims) {
179
- throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
180
- }
181
-
182
- const claims = credentialSubject.claims as Record<
183
- string,
184
- CredentialSdJwtClaims
185
- >;
186
-
187
- const attrDefinitions: [string, string, CredentialClaim][] = Object.entries(
188
- claims
189
- ).flatMap(([namespace, claimName]) =>
190
- Object.entries(claimName).map(
191
- ([claimNameKey, definition]) =>
192
- [namespace, claimNameKey, definition] as [
193
- string,
194
- string,
195
- CredentialClaim,
196
- ]
197
- )
198
- );
199
-
200
- if (!issuerSigned.nameSpaces) {
201
- throw new IoWalletError("Missing claims in the credential");
202
- }
203
-
204
- const flatNamespaces: [string, string, string][] = Object.entries(
205
- issuerSigned.nameSpaces
206
- ).flatMap(([namespace, values]) =>
207
- values.map(
208
- (v) =>
209
- [namespace, v.elementIdentifier, v.elementValue] as [
210
- string,
211
- string,
212
- string,
213
- ]
214
- )
215
- );
216
-
217
- // Check that all mandatory attributes defined in the issuer configuration are present in the disclosure set
218
- // and filter the non present ones
219
- const attrsNotInDisclosures = attrDefinitions.filter(
220
- ([attrDefNamespace, attrKey, definition]) => {
221
- const isClaimPresent = flatNamespaces.find(
222
- ([namespace, name]) =>
223
- attrDefNamespace === namespace && name === attrKey
224
- );
225
- return isClaimPresent === undefined && definition.mandatory;
226
- }
227
- );
228
- if (attrsNotInDisclosures.length > 0) {
229
- const missing = attrsNotInDisclosures
230
- .map((_) => _[1 /* claim key */])
231
- .join(", ");
232
- const received = flatNamespaces.map((_) => _[1 /*name*/]);
233
- if (!ignoreMissingAttributes) {
234
- throw new IoWalletError(
235
- `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
236
- );
237
- }
238
- }
239
-
240
- // Attributes defined in the issuer configuration and present in the disclosure set
241
- const definedValues = Object.fromEntries(
242
- attrDefinitions
243
- // Retrieve the value from the corresponding disclosure
244
- .map(
245
- ([attrDefNamespace, attrKey, definition]) =>
246
- [
247
- attrKey,
248
- {
249
- ...definition,
250
- value: flatNamespaces.find(
251
- ([namespace, name]) =>
252
- attrDefNamespace === namespace && name === attrKey
253
- )?.[2],
254
- },
255
- ] as const
256
- )
257
- //filter the not found elements
258
- .filter(([_, definition]) => definition.value !== undefined)
259
- // Add a human-readable attribute name, with i18n, in the form { locale: name }
260
- // Example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
261
- .map(
262
- ([attrKey, { display, ...definition }]) =>
263
- [
264
- attrKey,
265
- {
266
- ...definition,
267
- name: display.reduce(
268
- (names, { locale, name }) => ({ ...names, [locale]: name }),
269
- {} as Record<string, string>
270
- ),
271
- },
272
- ] as const
273
- )
274
- );
275
-
276
- if (includeUndefinedAttributes) {
277
- // Attributes that are present in the disclosure set but not defined in the issuer configuration
278
- const undefinedValues = Object.fromEntries(
279
- flatNamespaces
280
- .filter(([, key]) => !Object.keys(definedValues).includes(key))
281
- .map(([, key, value]) => [key, { value, name: key }])
282
- );
283
- return {
284
- ...definedValues,
285
- ...undefinedValues,
286
- };
287
- }
288
-
289
- return definedValues;
290
- };
291
-
292
159
  /**
293
160
  * Given a credential, verify it's in the supported format
294
161
  * and the credential is correctly signed
@@ -319,6 +186,10 @@ async function verifyCredentialSdJwt(
319
186
  const { cnf } = decodedCredential.sdJwt.payload;
320
187
 
321
188
  if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
189
+ Logger.log(
190
+ LogLevel.ERROR,
191
+ `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`
192
+ );
322
193
  throw new IoWalletError(
323
194
  `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`
324
195
  );
@@ -327,72 +198,18 @@ async function verifyCredentialSdJwt(
327
198
  return decodedCredential;
328
199
  }
329
200
 
330
- /**
331
- * Given a credential, verify it's in the supported format
332
- * and the credential is correctly signed
333
- * and it's bound to the given key
334
- *
335
- * @param rawCredential The received credential
336
- * @param issuerKeys The set of public keys of the issuer,
337
- * which will be used to verify the signature
338
- * @param holderBindingContext The access to the holder's key
339
- *
340
- * @throws If the signature verification fails
341
- * @throws If the credential is not in the SdJwt4VC format
342
- * @throws If the holder binding is not properly configured
343
- *
344
- */
345
- async function verifyCredentialMDoc(
346
- rawCredential: string,
347
- issuerKeys: JWK[],
348
- holderBindingContext: CryptoContext
349
- ): Promise<DecodedMDocCredential> {
350
- /**
351
- * For the moment, being that issues in the crypto key generation
352
- * have been found on Android, the check for the deviceKey inside
353
- * of the mDoc is skipped, so we are not interested in the holderBindingKey
354
- */
355
- const [decodedCredential, _] =
356
- // parallel for optimization
357
- await Promise.all([
358
- verifyMdoc(rawCredential, issuerKeys),
359
- holderBindingContext.getPublicKey(),
360
- ]);
361
-
362
- if (!decodedCredential) {
363
- throw new IoWalletError("No MDOC credentials found!");
364
- }
365
-
366
- /**
367
- * For the moment, being that issues in the crypto key generation
368
- * have been found on Android, the check for the deviceKey inside
369
- * of the mDoc is skipped.
370
- */
371
- //const key = decodedCredential.mDoc.issuerSigned.issuerAuth.payload.deviceKeyInfo.deviceKey;
372
- //
373
- //if (!compareKeysByThumbprint(key, holderBindingKey as PublicKey)) {
374
- // throw new IoWalletError(
375
- // `Failed to verify holder binding, holder binding key and mDoc deviceKey don't match`
376
- // );
377
- //}
378
-
379
- return decodedCredential;
380
- }
381
-
382
201
  // utility type that specialize VerifyAndParseCredential for given format
383
202
  type WithFormat<Format extends Parameters<VerifyAndParseCredential>[2]> = (
384
203
  _0: Parameters<VerifyAndParseCredential>[0],
385
204
  _1: Parameters<VerifyAndParseCredential>[1],
386
205
  _2: Format,
387
- _3: Parameters<VerifyAndParseCredential>[3],
388
- _4: Parameters<VerifyAndParseCredential>[4]
206
+ _3: Parameters<VerifyAndParseCredential>[3]
389
207
  ) => ReturnType<VerifyAndParseCredential>;
390
208
 
391
209
  const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
392
210
  issuerConf,
393
211
  credential,
394
212
  _,
395
- __,
396
213
  {
397
214
  credentialCryptoContext,
398
215
  ignoreMissingAttributes,
@@ -401,19 +218,25 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
401
218
  ) => {
402
219
  const decoded = await verifyCredentialSdJwt(
403
220
  credential,
404
- issuerConf.keys,
221
+ issuerConf.openid_credential_issuer.jwks.keys,
405
222
  credentialCryptoContext
406
223
  );
407
224
 
225
+ Logger.log(LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
226
+
408
227
  const parsedCredential = parseCredentialSdJwt(
409
- issuerConf.credential_configurations_supported,
228
+ issuerConf.openid_credential_issuer.credential_configurations_supported,
410
229
  decoded,
411
230
  ignoreMissingAttributes,
412
231
  includeUndefinedAttributes
413
232
  );
414
-
415
233
  const maybeIssuedAt = getValueFromDisclosures(decoded.disclosures, "iat");
416
234
 
235
+ Logger.log(
236
+ LogLevel.DEBUG,
237
+ `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`
238
+ );
239
+
417
240
  return {
418
241
  parsedCredential,
419
242
  expiration: new Date(decoded.sdJwt.payload.exp * 1000),
@@ -424,50 +247,9 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
424
247
  };
425
248
  };
426
249
 
427
- const verifyAndParseCredentialMDoc: WithFormat<"mso_mdoc"> = async (
428
- issuerConf,
429
- credential,
430
- _,
431
- credentialType,
432
- { credentialCryptoContext, ignoreMissingAttributes }
433
- ) => {
434
- const decoded = await verifyCredentialMDoc(
435
- credential,
436
- issuerConf.keys,
437
- credentialCryptoContext
438
- );
439
-
440
- const parsedCredential = parseCredentialMDoc(
441
- issuerConf.credential_configurations_supported,
442
- credentialType,
443
- decoded,
444
- undefined,
445
- ignoreMissingAttributes
446
- );
447
-
448
- const expirationDate = extractElementValueAsDate(
449
- parsedCredential?.expiry_date?.value as string
450
- );
451
- if (!expirationDate) {
452
- throw new IoWalletError(`expirationDate must be present!!`);
453
- }
454
- expirationDate?.setDate(expirationDate.getDate() + 1);
455
-
456
- const maybeIssuedAt = extractElementValueAsDate(
457
- parsedCredential?.issue_date?.value as string
458
- );
459
- maybeIssuedAt?.setDate(maybeIssuedAt.getDate() + 1);
460
-
461
- return {
462
- parsedCredential,
463
- expiration: expirationDate ?? new Date(),
464
- issuedAt: maybeIssuedAt ?? undefined,
465
- };
466
- };
467
-
468
250
  /**
469
251
  * Verify and parse an encoded credential.
470
- * @param issuerConf The Issuer configuration returned by {@link getIssuerConfig}
252
+ * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
471
253
  * @param credential The encoded credential returned by {@link obtainCredential}
472
254
  * @param format The format of the credentual returned by {@link obtainCredential}
473
255
  * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
@@ -482,27 +264,18 @@ export const verifyAndParseCredential: VerifyAndParseCredential = async (
482
264
  issuerConf,
483
265
  credential,
484
266
  format,
485
- credentialType,
486
267
  context
487
268
  ) => {
488
269
  if (format === "vc+sd-jwt") {
270
+ Logger.log(LogLevel.DEBUG, "Parsing credential in vc+sd-jwt format");
489
271
  return verifyAndParseCredentialSdJwt(
490
272
  issuerConf,
491
273
  credential,
492
274
  format,
493
- credentialType,
494
- context
495
- );
496
- }
497
- if (format === "mso_mdoc") {
498
- return verifyAndParseCredentialMDoc(
499
- issuerConf,
500
- credential,
501
- format,
502
- credentialType,
503
275
  context
504
276
  );
505
277
  }
506
278
 
279
+ Logger.log(LogLevel.ERROR, `Unsupported credential format: ${format}`);
507
280
  throw new IoWalletError(`Unsupported credential format: ${format}`);
508
281
  };
@@ -6,7 +6,7 @@ There's a fork in the flow which is based on the type of the credential that is
6
6
  This is due to the fact that eID credentials require a different authorization flow than other credentials, which is accomplished by a strong authentication method like SPID or CIE.
7
7
  Credentials instead require a simpler authorization flow and they require other credentials to be presented in order to be issued.
8
8
 
9
- The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `getIssuerConfig` step.
9
+ The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `evaluateIssuerTrust` step.
10
10
 
11
11
  ## Sequence Diagram
12
12
 
@@ -14,7 +14,7 @@ The supported credentials are defined in the entity configuration of the issuer
14
14
  graph TD;
15
15
  0[WalletInstanceAttestation.getAttestation]
16
16
  1[startFlow]
17
- 2[getIssuerConfig]
17
+ 2[evaluateIssuerTrust]
18
18
  3[startUserAuthorization]
19
19
  C4[getRequestedCredentialToBePresented]
20
20
  C4.1[completeUserAuthorizationWithFormPostJwtMode]
@@ -41,9 +41,12 @@ graph TD;
41
41
 
42
42
  The following errors are mapped to a `IssuerResponseError` with specific codes.
43
43
 
44
- | HTTP Status | Error Code | Description |
45
- | ----------- | -------------------------- | ----------------------------------------------------------------------------------------------------- |
46
- | `*` | `ERR_ISSUER_GENERIC_ERROR` | This is a generic error code to map unexpected errors that occurred when interacting with the Issuer. |
44
+ |HTTP Status|Error Code|Description|
45
+ |-----------|----------|-----------|
46
+ |`201 Created`|`ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS`| This response is returned by the credential issuer when the request has been queued because the credential cannot be issued synchronously. The consumer should try to obtain the credential at a later time. Although `201 Created` is not considered an error, it is mapped as an error in this context in order to handle the case where the credential issuance is not synchronous. This allows keeping the flow consistent and handle the case where the credential is not immediately available.|
47
+ |`403 Forbidden`|`ERR_CREDENTIAL_INVALID_STATUS`|This response is returned by the credential issuer when the requested credential has an invalid status. It might contain more details in the `reason` property.|
48
+ |`404 Not Found`|`ERR_CREDENTIAL_INVALID_STATUS`| This response is returned by the credential issuer when the authenticated user is not entitled to receive the requested credential. It might contain more details in the `reason` property.|
49
+ |`*`|`ERR_ISSUER_GENERIC_ERROR`|This is a generic error code to map unexpected errors that occurred when interacting with the Issuer.|
47
50
 
48
51
  ## Strong authentication for eID issuance (Query Mode)
49
52
 
@@ -105,7 +108,7 @@ const eid = {
105
108
  const eidCryptoContext = createCryptoContextFor(eid.keyTag);
106
109
 
107
110
  // Create credential crypto context
108
- const credentialKeyTag = uuid.v4().toString();
111
+ const credentialKeyTag = uuidv4().toString();
109
112
  await generate(credentialKeyTag); // Let's assume this function generates a new hardware-backed key pair
110
113
  const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
111
114
 
@@ -118,7 +121,7 @@ const startFlow: Credential.Issuance.StartFlow = () => ({
118
121
  const { issuerUrl } = startFlow();
119
122
 
120
123
  // Evaluate issuer trust
121
- const { issuerConf } = await Credential.Issuance.getIssuerConfig(issuerUrl);
124
+ const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(issuerUrl);
122
125
 
123
126
  // Start user authorization
124
127
  const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
@@ -241,23 +244,24 @@ const authorizationContext = idpHint.includes("servizicie")
241
244
  * Create credential crypto context for the PID
242
245
  * WARNING: The eID keytag must be persisted and later used when requesting a credential which requires a eID presentation
243
246
  */
244
- const credentialKeyTag = uuid.v4().toString();
247
+ const credentialKeyTag = uuidv4().toString();
245
248
  await generate(credentialKeyTag);
246
249
  const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
247
250
 
248
251
  // Start the issuance flow
249
252
  const startFlow: Credential.Issuance.StartFlow = () => ({
250
253
  issuerUrl: WALLET_EID_PROVIDER_BASE_URL,
251
- credentialType: "urn:eu.europa.ec.eudi:pid:1",
254
+ credentialType: "PersonIdentificationData",
252
255
  appFetch,
253
256
  });
254
257
 
255
258
  const { issuerUrl } = startFlow();
256
259
 
257
260
  // Evaluate issuer trust
258
- const { issuerConf } = await Credential.Issuance.getIssuerConfig(issuerUrl, {
259
- appFetch,
260
- });
261
+ const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(
262
+ issuerUrl,
263
+ { appFetch }
264
+ );
261
265
 
262
266
  // Start user authorization
263
267
  const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
@@ -311,13 +315,12 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
311
315
  );
312
316
 
313
317
  // Parse and verify the eID credential
314
- const { parsedCredential, issuedAt, expiration } =
315
- await Credential.Issuance.verifyAndParseCredential(
316
- issuerConf,
317
- credential,
318
- format,
319
- { credentialCryptoContext }
320
- );
318
+ const { parsedCredential, issuedAt, expiration } = await Credential.Issuance.verifyAndParseCredential(
319
+ issuerConf,
320
+ credential,
321
+ format,
322
+ { credentialCryptoContext }
323
+ );
321
324
 
322
325
  return {
323
326
  parsedCredential,
@@ -325,7 +328,7 @@ return {
325
328
  keyTag: credentialKeyTag,
326
329
  credentialType,
327
330
  issuedAt,
328
- expiration,
331
+ expiration
329
332
  };
330
333
  ```
331
334
 
@@ -7,5 +7,5 @@ export type SupportedCredentialFormat = z.infer<
7
7
  >;
8
8
  export const SupportedCredentialFormat = z.union([
9
9
  z.literal("vc+sd-jwt"),
10
- z.literal("mso_mdoc"),
10
+ z.literal("vc+mdoc-cbor"),
11
11
  ]);
@@ -1,5 +1,8 @@
1
1
  import { type StartFlow } from "./01-start-flow";
2
- import { getIssuerConfig, type GetIssuerConfig } from "./02-get-issuer-config";
2
+ import {
3
+ evaluateIssuerTrust,
4
+ type EvaluateIssuerTrust,
5
+ } from "./02-evaluate-issuer-trust";
3
6
  import {
4
7
  startUserAuthorization,
5
8
  type StartUserAuthorization,
@@ -27,7 +30,7 @@ import {
27
30
  import * as Errors from "./errors";
28
31
 
29
32
  export {
30
- getIssuerConfig,
33
+ evaluateIssuerTrust,
31
34
  startUserAuthorization,
32
35
  buildAuthorizationUrl,
33
36
  completeUserAuthorizationWithQueryMode,
@@ -41,7 +44,7 @@ export {
41
44
  };
42
45
  export type {
43
46
  StartFlow,
44
- GetIssuerConfig,
47
+ EvaluateIssuerTrust,
45
48
  StartUserAuthorization,
46
49
  BuildAuthorizationUrl,
47
50
  CompleteUserAuthorizationWithQueryMode,
@@ -1,45 +1,42 @@
1
1
  import * as z from "zod";
2
- import { ValidationFailed } from "../../utils/errors";
2
+ import { InvalidQRCodeError } from "./errors";
3
3
 
4
4
  const PresentationParams = z.object({
5
- clientId: z.string().nonempty(),
6
- requestUri: z.string().url(),
5
+ client_id: z.string().nonempty(),
6
+ request_uri: z.string().url(),
7
+ request_uri_method: z.enum(["get", "post"]),
8
+ state: z.string().optional(),
7
9
  });
10
+ export type PresentationParams = z.infer<typeof PresentationParams>;
8
11
 
9
12
  /**
10
13
  * The beginning of the presentation flow.
11
14
  * To be implemented accordind to the user touchpoint
12
15
  *
13
- * @param Optional parameters, depending on the starting touchoint
16
+ * @param params Presentation parameters, depending on the starting touchpoint
14
17
  * @returns The url for the Relying Party to connect with
15
18
  */
16
- export type StartFlow<T extends Array<unknown> = []> = (...args: T) => {
17
- requestUri: string;
18
- clientId: string;
19
- };
19
+ export type StartFlow = (params: {
20
+ [K in keyof PresentationParams]?: PresentationParams[K] | null;
21
+ }) => PresentationParams;
20
22
 
21
23
  /**
22
- * Start a presentation flow by decoding the parameters needed to start the presentation flow.
24
+ * Start a presentation flow by validating the required parameters.
25
+ * Parameters are extracted from a url encoded in a QR code or in a deep link.
23
26
  *
24
- * @param qrcode The encoded QR-code content
27
+ * @param params The parameters to be validated
25
28
  * @returns The url for the Relying Party to connect with
26
- * @throws If the provided qr code fails to be decoded
29
+ * @throws If the provided parameters are not valid
27
30
  */
28
- export const startFlowFromQR: StartFlow<[string, string]> = (
29
- requestUri: string,
30
- clientId: string
31
- ) => {
31
+ export const startFlowFromQR: StartFlow = (params) => {
32
32
  const result = PresentationParams.safeParse({
33
- requestUri,
34
- clientId,
33
+ ...params,
34
+ request_uri_method: params.request_uri_method ?? "get",
35
35
  });
36
36
 
37
37
  if (result.success) {
38
38
  return result.data;
39
- } else {
40
- throw new ValidationFailed({
41
- message: "Invalid parameters provided",
42
- reason: result.error.message,
43
- });
44
39
  }
40
+
41
+ throw new InvalidQRCodeError(result.error.message);
45
42
  };
@@ -1,5 +1,5 @@
1
- import { getRelyingPartyEntityConfiguration } from "../../entity/trust/index";
2
- import { RelyingPartyEntityConfiguration } from "../../entity/trust/types";
1
+ import { getRelyingPartyEntityConfiguration } from "../../trust";
2
+ import { RelyingPartyEntityConfiguration } from "../../trust/types";
3
3
  import type { StartFlow } from "../issuance/01-start-flow";
4
4
  import type { Out } from "../../utils/misc";
5
5
 
@@ -10,6 +10,7 @@ export type EvaluateRelyingPartyTrust = (
10
10
  }
11
11
  ) => Promise<{
12
12
  rpConf: RelyingPartyEntityConfiguration["payload"]["metadata"];
13
+ subject: string;
13
14
  }>;
14
15
 
15
16
  /**
@@ -25,9 +26,9 @@ export const evaluateRelyingPartyTrust: EvaluateRelyingPartyTrust = async (
25
26
  { appFetch = fetch } = {}
26
27
  ) => {
27
28
  const {
28
- payload: { metadata: rpConf },
29
+ payload: { metadata: rpConf, sub },
29
30
  } = await getRelyingPartyEntityConfiguration(rpUrl, {
30
31
  appFetch,
31
32
  });
32
- return { rpConf };
33
+ return { rpConf, subject: sub };
33
34
  };