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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (443) hide show
  1. package/README.md +47 -1
  2. package/lib/commonjs/client/generated/wallet-provider.js +49 -20
  3. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
  4. package/lib/commonjs/credential/index.js +5 -1
  5. package/lib/commonjs/credential/index.js.map +1 -1
  6. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
  7. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  8. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
  9. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  10. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
  11. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  12. package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
  13. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  14. package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
  15. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  16. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
  17. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  18. package/lib/commonjs/credential/issuance/README.md +23 -20
  19. package/lib/commonjs/credential/issuance/const.js +1 -1
  20. package/lib/commonjs/credential/issuance/const.js.map +1 -1
  21. package/lib/commonjs/credential/issuance/index.js +3 -3
  22. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  23. package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
  24. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  25. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
  26. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  27. package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
  28. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
  29. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
  30. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  31. package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
  32. package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
  33. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
  34. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  35. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
  36. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  37. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
  38. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  39. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
  40. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
  41. package/lib/commonjs/credential/presentation/README.md +74 -79
  42. package/lib/commonjs/credential/presentation/errors.js +42 -21
  43. package/lib/commonjs/credential/presentation/errors.js.map +1 -1
  44. package/lib/commonjs/credential/presentation/index.js +13 -13
  45. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  46. package/lib/commonjs/credential/presentation/types.js +53 -29
  47. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  48. package/lib/commonjs/credential/status/01-start-flow.js +2 -0
  49. package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
  50. package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
  51. package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
  52. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
  53. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  54. package/lib/commonjs/credential/status/README.md +67 -0
  55. package/lib/commonjs/credential/status/index.js +27 -0
  56. package/lib/commonjs/credential/status/index.js.map +1 -0
  57. package/lib/commonjs/credential/status/types.js +48 -0
  58. package/lib/commonjs/credential/status/types.js.map +1 -0
  59. package/lib/commonjs/credential/trustmark/README.md +62 -0
  60. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
  61. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
  62. package/lib/commonjs/credential/trustmark/index.js +13 -0
  63. package/lib/commonjs/credential/trustmark/index.js.map +1 -0
  64. package/lib/commonjs/index.js +5 -1
  65. package/lib/commonjs/index.js.map +1 -1
  66. package/lib/commonjs/pid/sd-jwt/types.js +18 -2
  67. package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
  68. package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
  69. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  70. package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
  71. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  72. package/lib/commonjs/sd-jwt/index.js +1 -7
  73. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  74. package/lib/commonjs/sd-jwt/types.js +5 -21
  75. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  76. package/lib/commonjs/trust/README.md +147 -0
  77. package/lib/commonjs/trust/chain.js +153 -0
  78. package/lib/commonjs/trust/chain.js.map +1 -0
  79. package/lib/commonjs/trust/errors.js +133 -0
  80. package/lib/commonjs/trust/errors.js.map +1 -0
  81. package/lib/commonjs/trust/index.js +288 -0
  82. package/lib/commonjs/trust/index.js.map +1 -0
  83. package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
  84. package/lib/commonjs/trust/types.js.map +1 -0
  85. package/lib/commonjs/trust/utils.js +70 -0
  86. package/lib/commonjs/trust/utils.js.map +1 -0
  87. package/lib/commonjs/utils/crypto.js +5 -112
  88. package/lib/commonjs/utils/crypto.js.map +1 -1
  89. package/lib/commonjs/utils/decoder.js +2 -0
  90. package/lib/commonjs/utils/decoder.js.map +1 -1
  91. package/lib/commonjs/utils/error-codes.js +22 -2
  92. package/lib/commonjs/utils/error-codes.js.map +1 -1
  93. package/lib/commonjs/utils/errors.js +72 -4
  94. package/lib/commonjs/utils/errors.js.map +1 -1
  95. package/lib/commonjs/utils/logging.js +68 -0
  96. package/lib/commonjs/utils/logging.js.map +1 -0
  97. package/lib/commonjs/utils/misc.js +2 -0
  98. package/lib/commonjs/utils/misc.js.map +1 -1
  99. package/lib/commonjs/utils/par.js +17 -10
  100. package/lib/commonjs/utils/par.js.map +1 -1
  101. package/lib/commonjs/utils/string.js +1 -12
  102. package/lib/commonjs/utils/string.js.map +1 -1
  103. package/lib/commonjs/wallet-instance/index.js +14 -0
  104. package/lib/commonjs/wallet-instance/index.js.map +1 -1
  105. package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
  106. package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
  107. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  108. package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
  109. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  110. package/lib/module/client/generated/wallet-provider.js +40 -15
  111. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  112. package/lib/module/credential/index.js +3 -1
  113. package/lib/module/credential/index.js.map +1 -1
  114. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
  115. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  116. package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
  117. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  118. package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
  119. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  120. package/lib/module/credential/issuance/05-authorize-access.js +17 -11
  121. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  122. package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
  123. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  124. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
  125. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  126. package/lib/module/credential/issuance/README.md +23 -20
  127. package/lib/module/credential/issuance/const.js +1 -1
  128. package/lib/module/credential/issuance/const.js.map +1 -1
  129. package/lib/module/credential/issuance/index.js +2 -2
  130. package/lib/module/credential/issuance/index.js.map +1 -1
  131. package/lib/module/credential/presentation/01-start-flow.js +14 -15
  132. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  133. package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
  134. package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  135. package/lib/module/credential/presentation/03-get-request-object.js +34 -7
  136. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
  137. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
  138. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  139. package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
  140. package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
  141. package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
  142. package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  143. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
  144. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  145. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
  146. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  147. package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
  148. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  149. package/lib/module/credential/presentation/README.md +74 -79
  150. package/lib/module/credential/presentation/errors.js +30 -17
  151. package/lib/module/credential/presentation/errors.js.map +1 -1
  152. package/lib/module/credential/presentation/index.js +6 -6
  153. package/lib/module/credential/presentation/index.js.map +1 -1
  154. package/lib/module/credential/presentation/types.js +49 -27
  155. package/lib/module/credential/presentation/types.js.map +1 -1
  156. package/lib/module/credential/status/01-start-flow.js +2 -0
  157. package/lib/module/credential/status/01-start-flow.js.map +1 -0
  158. package/lib/module/credential/status/02-status-attestation.js +66 -0
  159. package/lib/module/credential/status/02-status-attestation.js.map +1 -0
  160. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
  161. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  162. package/lib/module/credential/status/README.md +67 -0
  163. package/lib/module/credential/status/index.js +5 -0
  164. package/lib/module/credential/status/index.js.map +1 -0
  165. package/lib/module/credential/status/types.js +40 -0
  166. package/lib/module/credential/status/types.js.map +1 -0
  167. package/lib/module/credential/trustmark/README.md +62 -0
  168. package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
  169. package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
  170. package/lib/module/credential/trustmark/index.js +3 -0
  171. package/lib/module/credential/trustmark/index.js.map +1 -0
  172. package/lib/module/index.js +3 -1
  173. package/lib/module/index.js.map +1 -1
  174. package/lib/module/pid/sd-jwt/types.js +16 -1
  175. package/lib/module/pid/sd-jwt/types.js.map +1 -1
  176. package/lib/module/sd-jwt/__test__/index.test.js +22 -34
  177. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  178. package/lib/module/sd-jwt/__test__/types.test.js +11 -23
  179. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  180. package/lib/module/sd-jwt/index.js +1 -7
  181. package/lib/module/sd-jwt/index.js.map +1 -1
  182. package/lib/module/sd-jwt/types.js +4 -19
  183. package/lib/module/sd-jwt/types.js.map +1 -1
  184. package/lib/module/trust/README.md +147 -0
  185. package/lib/module/trust/chain.js +145 -0
  186. package/lib/module/trust/chain.js.map +1 -0
  187. package/lib/module/trust/errors.js +115 -0
  188. package/lib/module/trust/errors.js.map +1 -0
  189. package/lib/module/trust/index.js +269 -0
  190. package/lib/module/trust/index.js.map +1 -0
  191. package/lib/module/{entity/trust → trust}/types.js +25 -46
  192. package/lib/module/trust/types.js.map +1 -0
  193. package/lib/module/trust/utils.js +60 -0
  194. package/lib/module/trust/utils.js.map +1 -0
  195. package/lib/module/utils/crypto.js +4 -107
  196. package/lib/module/utils/crypto.js.map +1 -1
  197. package/lib/module/utils/decoder.js +3 -0
  198. package/lib/module/utils/decoder.js.map +1 -1
  199. package/lib/module/utils/error-codes.js +20 -1
  200. package/lib/module/utils/error-codes.js.map +1 -1
  201. package/lib/module/utils/errors.js +61 -4
  202. package/lib/module/utils/errors.js.map +1 -1
  203. package/lib/module/utils/logging.js +62 -0
  204. package/lib/module/utils/logging.js.map +1 -0
  205. package/lib/module/utils/misc.js +2 -0
  206. package/lib/module/utils/misc.js.map +1 -1
  207. package/lib/module/utils/par.js +17 -9
  208. package/lib/module/utils/par.js.map +1 -1
  209. package/lib/module/utils/string.js +0 -10
  210. package/lib/module/utils/string.js.map +1 -1
  211. package/lib/module/wallet-instance/index.js +13 -0
  212. package/lib/module/wallet-instance/index.js.map +1 -1
  213. package/lib/module/wallet-instance-attestation/README.md +8 -3
  214. package/lib/module/wallet-instance-attestation/index.js +2 -2
  215. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  216. package/lib/module/wallet-instance-attestation/issuing.js +16 -9
  217. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  218. package/lib/module/wallet-instance-attestation/types.js +14 -18
  219. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  220. package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
  221. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  222. package/lib/typescript/credential/index.d.ts +3 -1
  223. package/lib/typescript/credential/index.d.ts.map +1 -1
  224. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
  225. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
  226. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
  227. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
  228. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  229. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
  230. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  231. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
  232. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  233. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
  234. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  235. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
  236. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  237. package/lib/typescript/credential/issuance/const.d.ts +1 -1
  238. package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
  239. package/lib/typescript/credential/issuance/index.d.ts +3 -3
  240. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  241. package/lib/typescript/credential/issuance/types.d.ts +8 -3
  242. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  243. package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
  244. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
  245. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
  246. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
  247. package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
  248. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
  249. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
  250. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
  251. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
  252. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
  253. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
  254. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
  255. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
  256. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  257. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
  258. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  259. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
  260. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
  261. package/lib/typescript/credential/presentation/errors.d.ts +25 -10
  262. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
  263. package/lib/typescript/credential/presentation/index.d.ts +7 -8
  264. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  265. package/lib/typescript/credential/presentation/types.d.ts +137 -307
  266. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  267. package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
  268. package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
  269. package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
  270. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
  271. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
  272. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
  273. package/lib/typescript/credential/status/index.d.ts +7 -0
  274. package/lib/typescript/credential/status/index.d.ts.map +1 -0
  275. package/lib/typescript/credential/status/types.d.ts +305 -0
  276. package/lib/typescript/credential/status/types.d.ts.map +1 -0
  277. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
  278. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
  279. package/lib/typescript/credential/trustmark/index.d.ts +4 -0
  280. package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
  281. package/lib/typescript/index.d.ts +3 -1
  282. package/lib/typescript/index.d.ts.map +1 -1
  283. package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
  284. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
  285. package/lib/typescript/sd-jwt/index.d.ts +20 -72
  286. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  287. package/lib/typescript/sd-jwt/types.d.ts +24 -129
  288. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  289. package/lib/typescript/trust/chain.d.ts +23 -0
  290. package/lib/typescript/trust/chain.d.ts.map +1 -0
  291. package/lib/typescript/trust/errors.d.ts +102 -0
  292. package/lib/typescript/trust/errors.d.ts.map +1 -0
  293. package/lib/typescript/{entity/trust → trust}/index.d.ts +308 -281
  294. package/lib/typescript/trust/index.d.ts.map +1 -0
  295. package/lib/typescript/{entity/trust → trust}/types.d.ts +1714 -1301
  296. package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
  297. package/lib/typescript/trust/utils.d.ts +22 -0
  298. package/lib/typescript/trust/utils.d.ts.map +1 -0
  299. package/lib/typescript/utils/crypto.d.ts +0 -32
  300. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  301. package/lib/typescript/utils/decoder.d.ts.map +1 -1
  302. package/lib/typescript/utils/error-codes.d.ts +20 -0
  303. package/lib/typescript/utils/error-codes.d.ts.map +1 -1
  304. package/lib/typescript/utils/errors.d.ts +55 -10
  305. package/lib/typescript/utils/errors.d.ts.map +1 -1
  306. package/lib/typescript/utils/logging.d.ts +35 -0
  307. package/lib/typescript/utils/logging.d.ts.map +1 -0
  308. package/lib/typescript/utils/misc.d.ts.map +1 -1
  309. package/lib/typescript/utils/par.d.ts +8 -1
  310. package/lib/typescript/utils/par.d.ts.map +1 -1
  311. package/lib/typescript/utils/string.d.ts +0 -7
  312. package/lib/typescript/utils/string.d.ts.map +1 -1
  313. package/lib/typescript/wallet-instance/index.d.ts +8 -0
  314. package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
  315. package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
  316. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  317. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
  318. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  319. package/lib/typescript/wallet-instance-attestation/types.d.ts +60 -102
  320. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  321. package/package.json +9 -10
  322. package/src/client/generated/wallet-provider.ts +52 -17
  323. package/src/credential/index.ts +4 -1
  324. package/src/credential/issuance/01-start-flow.ts +1 -1
  325. package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
  326. package/src/credential/issuance/03-start-user-authorization.ts +48 -22
  327. package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
  328. package/src/credential/issuance/05-authorize-access.ts +29 -11
  329. package/src/credential/issuance/06-obtain-credential.ts +61 -36
  330. package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
  331. package/src/credential/issuance/README.md +23 -20
  332. package/src/credential/issuance/const.ts +1 -1
  333. package/src/credential/issuance/index.ts +6 -3
  334. package/src/credential/presentation/01-start-flow.ts +19 -22
  335. package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
  336. package/src/credential/presentation/03-get-request-object.ts +36 -8
  337. package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
  338. package/src/credential/presentation/05-verify-request-object.ts +115 -30
  339. package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
  340. package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
  341. package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
  342. package/src/credential/presentation/08-send-authorization-response.ts +178 -260
  343. package/src/credential/presentation/README.md +74 -79
  344. package/src/credential/presentation/errors.ts +38 -15
  345. package/src/credential/presentation/index.ts +18 -19
  346. package/src/credential/presentation/types.ts +67 -64
  347. package/src/credential/status/01-start-flow.ts +9 -0
  348. package/src/credential/status/02-status-attestation.ts +105 -0
  349. package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
  350. package/src/credential/status/README.md +67 -0
  351. package/src/credential/status/index.ts +22 -0
  352. package/src/credential/status/types.ts +43 -0
  353. package/src/credential/trustmark/README.md +62 -0
  354. package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
  355. package/src/credential/trustmark/index.ts +8 -0
  356. package/src/index.ts +4 -0
  357. package/src/pid/sd-jwt/types.ts +18 -1
  358. package/src/sd-jwt/__test__/index.test.ts +36 -55
  359. package/src/sd-jwt/__test__/types.test.ts +16 -29
  360. package/src/sd-jwt/index.ts +1 -5
  361. package/src/sd-jwt/types.ts +2 -19
  362. package/src/trust/README.md +147 -0
  363. package/src/trust/chain.ts +227 -0
  364. package/src/trust/errors.ts +136 -0
  365. package/src/{entity/trust → trust}/index.ts +207 -25
  366. package/src/{entity/trust → trust}/types.ts +24 -37
  367. package/src/trust/utils.ts +70 -0
  368. package/src/utils/crypto.ts +4 -106
  369. package/src/utils/decoder.ts +6 -1
  370. package/src/utils/error-codes.ts +23 -0
  371. package/src/utils/errors.ts +119 -15
  372. package/src/utils/logging.ts +68 -0
  373. package/src/utils/misc.ts +5 -0
  374. package/src/utils/par.ts +19 -6
  375. package/src/utils/string.ts +0 -10
  376. package/src/wallet-instance/index.ts +30 -1
  377. package/src/wallet-instance-attestation/README.md +8 -3
  378. package/src/wallet-instance-attestation/index.ts +2 -2
  379. package/src/wallet-instance-attestation/issuing.ts +33 -12
  380. package/src/wallet-instance-attestation/types.ts +18 -22
  381. package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
  382. package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
  383. package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
  384. package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
  385. package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
  386. package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
  387. package/lib/commonjs/entity/trust/chain.js +0 -122
  388. package/lib/commonjs/entity/trust/chain.js.map +0 -1
  389. package/lib/commonjs/entity/trust/index.js +0 -148
  390. package/lib/commonjs/entity/trust/index.js.map +0 -1
  391. package/lib/commonjs/entity/trust/types.js.map +0 -1
  392. package/lib/commonjs/mdoc/converters.js +0 -26
  393. package/lib/commonjs/mdoc/converters.js.map +0 -1
  394. package/lib/commonjs/mdoc/index.js +0 -68
  395. package/lib/commonjs/mdoc/index.js.map +0 -1
  396. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
  397. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  398. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
  399. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  400. package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
  401. package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
  402. package/lib/module/entity/openid-connect/issuer/index.js +0 -20
  403. package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
  404. package/lib/module/entity/openid-connect/issuer/types.js +0 -48
  405. package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
  406. package/lib/module/entity/trust/chain.js +0 -113
  407. package/lib/module/entity/trust/chain.js.map +0 -1
  408. package/lib/module/entity/trust/index.js +0 -131
  409. package/lib/module/entity/trust/index.js.map +0 -1
  410. package/lib/module/entity/trust/types.js.map +0 -1
  411. package/lib/module/mdoc/converters.js +0 -20
  412. package/lib/module/mdoc/converters.js.map +0 -1
  413. package/lib/module/mdoc/index.js +0 -60
  414. package/lib/module/mdoc/index.js.map +0 -1
  415. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
  416. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  417. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
  418. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  419. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
  420. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
  421. package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
  422. package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
  423. package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
  424. package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
  425. package/lib/typescript/entity/trust/chain.d.ts +0 -26
  426. package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
  427. package/lib/typescript/entity/trust/index.d.ts.map +0 -1
  428. package/lib/typescript/mdoc/converters.d.ts +0 -8
  429. package/lib/typescript/mdoc/converters.d.ts.map +0 -1
  430. package/lib/typescript/mdoc/index.d.ts +0 -10
  431. package/lib/typescript/mdoc/index.d.ts.map +0 -1
  432. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
  433. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
  434. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
  435. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
  436. package/src/credential/issuance/02-get-issuer-config.ts +0 -67
  437. package/src/entity/openid-connect/issuer/index.ts +0 -27
  438. package/src/entity/openid-connect/issuer/types.ts +0 -76
  439. package/src/entity/trust/chain.ts +0 -154
  440. package/src/mdoc/converters.ts +0 -26
  441. package/src/mdoc/index.ts +0 -95
  442. package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
  443. package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -7,7 +7,7 @@ import { hasStatusOrThrow, type Out } from "../../utils/misc";
7
7
  import type { StartUserAuthorization } from "./03-start-user-authorization";
8
8
  import parseUrl from "parse-url";
9
9
  import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
10
- import type { GetIssuerConfig } from "./02-get-issuer-config";
10
+ import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
11
11
  import {
12
12
  decode,
13
13
  encodeBase64,
@@ -15,13 +15,14 @@ import {
15
15
  type CryptoContext,
16
16
  } from "@pagopa/io-react-native-jwt";
17
17
  import { RequestObject } from "../presentation/types";
18
- import uuid from "react-native-uuid";
18
+ import { v4 as uuidv4 } from "uuid";
19
19
  import { ResponseUriResultShape } from "./types";
20
20
  import { getJwtFromFormPost } from "../../utils/decoder";
21
21
  import { AuthorizationError, AuthorizationIdpError } from "./errors";
22
+ import { LogLevel, Logger } from "../../utils/logging";
22
23
 
23
24
  /**
24
- * The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a urn:eu.europa.ec.eudi:pid:1.
25
+ * The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
25
26
  */
26
27
  export type CompleteUserAuthorizationWithQueryMode = (
27
28
  authRedirectUrl: string
@@ -41,14 +42,14 @@ export type CompleteUserAuthorizationWithFormPostJwtMode = (
41
42
  export type GetRequestedCredentialToBePresented = (
42
43
  issuerRequestUri: Out<StartUserAuthorization>["issuerRequestUri"],
43
44
  clientId: Out<StartUserAuthorization>["clientId"],
44
- issuerConf: Out<GetIssuerConfig>["issuerConf"],
45
+ issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
45
46
  appFetch?: GlobalFetch["fetch"]
46
47
  ) => Promise<RequestObject>;
47
48
 
48
49
  export type BuildAuthorizationUrl = (
49
50
  issuerRequestUri: Out<StartUserAuthorization>["issuerRequestUri"],
50
51
  clientId: Out<StartUserAuthorization>["clientId"],
51
- issuerConf: Out<GetIssuerConfig>["issuerConf"],
52
+ issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
52
53
  idpHint?: string
53
54
  ) => Promise<{
54
55
  authUrl: string;
@@ -59,8 +60,8 @@ export type BuildAuthorizationUrl = (
59
60
  * Builds the authorization URL to which the end user should be redirected to continue the authentication flow.
60
61
  * @param issuerRequestUri the URI of the issuer where the request is sent
61
62
  * @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
62
- * @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
63
- * @param idpHint Unique identifier of the IDP selected by the user
63
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
64
+ * @param idpHint Unique identifier of the IDP selected by the user (optional)
64
65
  * @returns An object containing the authorization URL
65
66
  */
66
67
  export const buildAuthorizationUrl: BuildAuthorizationUrl = async (
@@ -69,14 +70,18 @@ export const buildAuthorizationUrl: BuildAuthorizationUrl = async (
69
70
  issuerConf,
70
71
  idpHint
71
72
  ) => {
72
- const authzRequestEndpoint = issuerConf.authorization_endpoint;
73
+ const authzRequestEndpoint =
74
+ issuerConf.oauth_authorization_server.authorization_endpoint;
73
75
 
74
76
  const params = new URLSearchParams({
75
77
  client_id: clientId,
76
78
  request_uri: issuerRequestUri,
77
- ...(idpHint && { idphint: idpHint }),
78
79
  });
79
80
 
81
+ if (idpHint) {
82
+ params.append("idphint", idpHint);
83
+ }
84
+
80
85
  const authUrl = `${authzRequestEndpoint}?${params}`;
81
86
 
82
87
  return { authUrl };
@@ -84,13 +89,17 @@ export const buildAuthorizationUrl: BuildAuthorizationUrl = async (
84
89
 
85
90
  /**
86
91
  * WARNING: This function must be called after obtaining the authorization redirect URL from the webviews (SPID and CIE L3) or browser for CIEID.
87
- * Complete User authorization via strong identification when the response mode is "query" and the request credential is a urn:eu.europa.ec.eudi:pid:1.
92
+ * Complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
88
93
  * This function parses the authorization redirect URL to extract the authorization response.
89
94
  * @param authRedirectUrl The URL to which the end user should be redirected to start the authentication flow
90
95
  * @returns the authorization response which contains code, state and iss
91
96
  */
92
97
  export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWithQueryMode =
93
98
  async (authRedirectUrl) => {
99
+ Logger.log(
100
+ LogLevel.DEBUG,
101
+ `The requeste credential is a PersonIdentificationData, completing the user authorization with query mode`
102
+ );
94
103
  const query = parseUrl(authRedirectUrl).query;
95
104
 
96
105
  return parseAuthorizationResponse(query);
@@ -103,19 +112,29 @@ export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWi
103
112
  * The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
104
113
  * @param issuerRequestUri the URI of the issuer where the request is sent
105
114
  * @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
106
- * @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
115
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
107
116
  * @param appFetch (optional) fetch api implementation. Default: built-in fetch
108
117
  * @throws {ValidationFailed} if an error while validating the response
109
118
  * @returns the request object which contains the credential to be presented in order to obtain the requested credential
110
119
  */
111
120
  export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePresented =
112
121
  async (issuerRequestUri, clientId, issuerConf, appFetch = fetch) => {
113
- const authzRequestEndpoint = issuerConf.authorization_endpoint;
122
+ Logger.log(
123
+ LogLevel.DEBUG,
124
+ `The requeste credential is not a PersonIdentificationData, requesting the credential to be presented`
125
+ );
126
+ const authzRequestEndpoint =
127
+ issuerConf.oauth_authorization_server.authorization_endpoint;
114
128
  const params = new URLSearchParams({
115
129
  client_id: clientId,
116
130
  request_uri: issuerRequestUri,
117
131
  });
118
132
 
133
+ Logger.log(
134
+ LogLevel.DEBUG,
135
+ `Requesting the request object to ${authzRequestEndpoint}?${params.toString()}`
136
+ );
137
+
119
138
  const requestObject = await appFetch(
120
139
  `${authzRequestEndpoint}?${params.toString()}`,
121
140
  { method: "GET" }
@@ -126,6 +145,10 @@ export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePres
126
145
  .then((reqObj) => RequestObject.safeParse(reqObj.payload));
127
146
 
128
147
  if (!requestObject.success) {
148
+ Logger.log(
149
+ LogLevel.ERROR,
150
+ `Error while validating the response object: ${requestObject.error.message}`
151
+ );
129
152
  throw new ValidationFailed({
130
153
  message: "Request Object validation failed",
131
154
  reason: requestObject.error.message,
@@ -141,7 +164,7 @@ export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePres
141
164
  * The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
142
165
  * @param issuerRequestUri the URI of the issuer where the request is sent
143
166
  * @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
144
- * @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
167
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
145
168
  * @param context.walletInstanceAccestation the Wallet Instance's attestation to be presented
146
169
  * @param context.pid the PID to be presented
147
170
  * @param context.wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
@@ -152,6 +175,11 @@ export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePres
152
175
  */
153
176
  export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthorizationWithFormPostJwtMode =
154
177
  async (requestObject, ctx) => {
178
+ Logger.log(
179
+ LogLevel.DEBUG,
180
+ `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`
181
+ );
182
+
155
183
  const {
156
184
  wiaCryptoContext,
157
185
  pidCryptoContext,
@@ -167,7 +195,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
167
195
  })
168
196
  .setPayload({
169
197
  vp: walletInstanceAttestation,
170
- jti: uuid.v4().toString(),
198
+ jti: uuidv4().toString(),
171
199
  nonce: requestObject.nonce,
172
200
  })
173
201
  .setIssuedAt()
@@ -182,7 +210,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
182
210
  })
183
211
  .setPayload({
184
212
  vp: pid,
185
- jti: uuid.v4().toString(),
213
+ jti: uuidv4().toString(),
186
214
  nonce: requestObject.nonce,
187
215
  })
188
216
  .setIssuedAt()
@@ -190,15 +218,20 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
190
218
  .setAudience(requestObject.response_uri)
191
219
  .sign();
192
220
 
221
+ Logger.log(
222
+ LogLevel.DEBUG,
223
+ `Wallet instance attestation JWT token: ${wiaWpToken}`
224
+ );
225
+
193
226
  /* The path parameter refers to the vp_token variable of the authzResponsePayload and must point to the plain credential which
194
227
  * is cointaned in the `vp` property of the signed jwt token payload
195
228
  */
196
229
  const presentationSubmission = {
197
- definition_id: `${uuid.v4()}`,
198
- id: `${uuid.v4()}`,
230
+ definition_id: `${uuidv4()}`,
231
+ id: `${uuidv4()}`,
199
232
  descriptor_map: [
200
233
  {
201
- id: "urn:eu.europa.ec.eudi:pid:1",
234
+ id: "PersonIdentificationData",
202
235
  path: "$.vp_token[0].vp",
203
236
  format: "vc+sd-jwt",
204
237
  },
@@ -210,6 +243,11 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
210
243
  ],
211
244
  };
212
245
 
246
+ Logger.log(
247
+ LogLevel.DEBUG,
248
+ `Presentation submission: ${JSON.stringify(presentationSubmission)}`
249
+ );
250
+
213
251
  const authzResponsePayload = encodeBase64(
214
252
  JSON.stringify({
215
253
  state: requestObject.state,
@@ -218,6 +256,11 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
218
256
  })
219
257
  );
220
258
 
259
+ Logger.log(
260
+ LogLevel.DEBUG,
261
+ `Authz response payload: ${authzResponsePayload}`
262
+ );
263
+
221
264
  // Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
222
265
  // https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-response
223
266
  // const rsaPublicJwk = chooseRSAPublicKeyToEncrypt(rpConf);
@@ -230,6 +273,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
230
273
  const body = new URLSearchParams({
231
274
  response: authzResponsePayload,
232
275
  }).toString();
276
+
233
277
  const resUriRes = await appFetch(requestObject.response_uri, {
234
278
  method: "POST",
235
279
  headers: {
@@ -242,6 +286,10 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
242
286
 
243
287
  const responseUri = ResponseUriResultShape.safeParse(resUriRes);
244
288
  if (!responseUri.success) {
289
+ Logger.log(
290
+ LogLevel.ERROR,
291
+ `Error while validating the response uri: ${responseUri.error.message}`
292
+ );
245
293
  throw new ValidationFailed({
246
294
  message: "Response Uri validation failed",
247
295
  reason: responseUri.error.message,
@@ -269,8 +317,16 @@ export const parseAuthorizationResponse = (
269
317
  if (!authResParsed.success) {
270
318
  const authErr = AuthorizationErrorShape.safeParse(authRes);
271
319
  if (!authErr.success) {
320
+ Logger.log(
321
+ LogLevel.ERROR,
322
+ `Error while parsing the authorization response: ${authResParsed.error.message}`
323
+ );
272
324
  throw new AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
273
325
  }
326
+ Logger.log(
327
+ LogLevel.ERROR,
328
+ `Error while authorizating with the idp: ${JSON.stringify(authErr)}`
329
+ );
274
330
  throw new AuthorizationIdpError(
275
331
  authErr.data.error,
276
332
  authErr.data.error_description
@@ -1,17 +1,19 @@
1
1
  import { hasStatusOrThrow, type Out } from "../../utils/misc";
2
- import type { GetIssuerConfig } from "./02-get-issuer-config";
2
+ import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
3
3
  import type { StartUserAuthorization } from "./03-start-user-authorization";
4
4
  import { createDPopToken } from "../../utils/dpop";
5
- import uuid from "react-native-uuid";
5
+ import { v4 as uuidv4 } from "uuid";
6
6
  import { createPopToken } from "../../utils/pop";
7
7
  import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
8
8
  import type { CryptoContext } from "@pagopa/io-react-native-jwt";
9
+ import { ASSERTION_TYPE } from "./const";
9
10
  import { TokenResponse } from "./types";
10
11
  import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
11
12
  import type { CompleteUserAuthorizationWithQueryMode } from "./04-complete-user-authorization";
13
+ import { LogLevel, Logger } from "../../utils/logging";
12
14
 
13
15
  export type AuthorizeAccess = (
14
- issuerConf: Out<GetIssuerConfig>["issuerConf"],
16
+ issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
15
17
  code: Out<CompleteUserAuthorizationWithQueryMode>["code"],
16
18
  redirectUri: string,
17
19
  clientId: Out<StartUserAuthorization>["clientId"],
@@ -29,7 +31,7 @@ export type AuthorizeAccess = (
29
31
  * for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
30
32
  * This enables the Wallet Instance to request a digital credential.
31
33
  * The DPoP Proof JWT is generated according to the section 4.3 of the DPoP RFC 9449 specification.
32
- * @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
34
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
33
35
  * @param code The authorization code returned by {@link completeUserAuthorizationWithQueryMode} or {@link completeUserAuthorizationWithFormPost}
34
36
  * @param redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
35
37
  * @param clientId The client id returned by {@link startUserAuthorization}
@@ -57,48 +59,59 @@ export const authorizeAccess: AuthorizeAccess = async (
57
59
  dPopCryptoContext,
58
60
  } = context;
59
61
 
60
- const parEndpoint = issuerConf.pushed_authorization_request_endpoint;
62
+ const parEndpoint =
63
+ issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
61
64
  const parUrl = new URL(parEndpoint);
62
65
  const aud = `${parUrl.protocol}//${parUrl.hostname}`;
63
66
  const iss = WalletInstanceAttestation.decode(walletInstanceAttestation)
64
67
  .payload.cnf.jwk.kid;
65
68
 
66
- const tokenUrl = issuerConf.token_endpoint;
69
+ const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
67
70
 
68
71
  const tokenRequestSignedDPop = await createDPopToken(
69
72
  {
70
73
  htm: "POST",
71
74
  htu: tokenUrl,
72
- jti: `${uuid.v4()}`,
75
+ jti: `${uuidv4()}`,
73
76
  },
74
77
  dPopCryptoContext
75
78
  );
76
79
 
80
+ Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
81
+
77
82
  const signedWiaPoP = await createPopToken(
78
83
  {
79
- jti: `${uuid.v4()}`,
84
+ jti: `${uuidv4()}`,
80
85
  aud,
81
86
  iss,
82
87
  },
83
88
  wiaCryptoContext
84
89
  );
85
90
 
91
+ Logger.log(LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
92
+
86
93
  const requestBody = {
87
- client_id: clientId,
88
94
  grant_type: "authorization_code",
95
+ client_id: clientId,
89
96
  code,
90
97
  redirect_uri: redirectUri,
91
98
  code_verifier: codeVerifier,
99
+ client_assertion_type: ASSERTION_TYPE,
100
+ client_assertion: walletInstanceAttestation + "~" + signedWiaPoP,
92
101
  };
93
102
 
94
103
  const authorizationRequestFormBody = new URLSearchParams(requestBody);
104
+
105
+ Logger.log(
106
+ LogLevel.DEBUG,
107
+ `Auth form request body: ${authorizationRequestFormBody}`
108
+ );
109
+
95
110
  const tokenRes = await appFetch(tokenUrl, {
96
111
  method: "POST",
97
112
  headers: {
98
113
  "Content-Type": "application/x-www-form-urlencoded",
99
114
  DPoP: tokenRequestSignedDPop,
100
- "OAuth-Client-Attestation": walletInstanceAttestation,
101
- "OAuth-Client-Attestation-PoP": signedWiaPoP,
102
115
  },
103
116
  body: authorizationRequestFormBody.toString(),
104
117
  })
@@ -107,6 +120,11 @@ export const authorizeAccess: AuthorizeAccess = async (
107
120
  .then((body) => TokenResponse.safeParse(body));
108
121
 
109
122
  if (!tokenRes.success) {
123
+ Logger.log(
124
+ LogLevel.ERROR,
125
+ `Token Response validation failed: ${tokenRes.error.message}`
126
+ );
127
+
110
128
  throw new ValidationFailed({
111
129
  message: "Token Response validation failed",
112
130
  reason: tokenRes.error.message,
@@ -4,7 +4,7 @@ import {
4
4
  SignJWT,
5
5
  } from "@pagopa/io-react-native-jwt";
6
6
  import type { AuthorizeAccess } from "./05-authorize-access";
7
- import type { GetIssuerConfig } from "./02-get-issuer-config";
7
+ import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
8
8
  import { hasStatusOrThrow, type Out } from "../../utils/misc";
9
9
  import type { StartUserAuthorization } from "./03-start-user-authorization";
10
10
  import {
@@ -16,10 +16,11 @@ import {
16
16
  } from "../../utils/errors";
17
17
  import { CredentialResponse } from "./types";
18
18
  import { createDPopToken } from "../../utils/dpop";
19
- import uuid from "react-native-uuid";
19
+ import { v4 as uuidv4 } from "uuid";
20
+ import { LogLevel, Logger } from "../../utils/logging";
20
21
 
21
22
  export type ObtainCredential = (
22
- issuerConf: Out<GetIssuerConfig>["issuerConf"],
23
+ issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
23
24
  accessToken: Out<AuthorizeAccess>["accessToken"],
24
25
  clientId: Out<StartUserAuthorization>["clientId"],
25
26
  credentialDefinition: Out<StartUserAuthorization>["credentialDefinition"],
@@ -27,7 +28,8 @@ export type ObtainCredential = (
27
28
  dPopCryptoContext: CryptoContext;
28
29
  credentialCryptoContext: CryptoContext;
29
30
  appFetch?: GlobalFetch["fetch"];
30
- }
31
+ },
32
+ operationType?: "reissuing"
31
33
  ) => Promise<CredentialResponse>;
32
34
 
33
35
  export const createNonceProof = async (
@@ -58,7 +60,7 @@ export const createNonceProof = async (
58
60
  * of the Credential Issuer to request the issuance of a credential linked to the public key contained in the JWT proof.
59
61
  * The Openid4vci proof JWT incapsulates the nonce extracted from the token response from the {@link authorizeAccess} step.
60
62
  * The credential request is sent to the Credential Endpoint of the Credential Issuer via HTTP POST with the type of the credential, its format, the access token and the JWT proof.
61
- * @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
63
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
62
64
  * @param accessToken The access token response returned by {@link authorizeAccess}
63
65
  * @param clientId The client id returned by {@link startUserAuthorization}
64
66
  * @param credentialDefinition The credential definition of the credential to be obtained returned by {@link startUserAuthorization}
@@ -73,7 +75,8 @@ export const obtainCredential: ObtainCredential = async (
73
75
  accessToken,
74
76
  clientId,
75
77
  credentialDefinition,
76
- context
78
+ context,
79
+ operationType
77
80
  ) => {
78
81
  const {
79
82
  credentialCryptoContext,
@@ -81,7 +84,7 @@ export const obtainCredential: ObtainCredential = async (
81
84
  dPopCryptoContext,
82
85
  } = context;
83
86
 
84
- const credentialUrl = issuerConf.credential_endpoint;
87
+ const credentialUrl = issuerConf.openid_credential_issuer.credential_endpoint;
85
88
 
86
89
  /**
87
90
  * JWT proof token to bind the request nonce to the key that will bind the holder User with the Credential
@@ -95,67 +98,64 @@ export const obtainCredential: ObtainCredential = async (
95
98
  credentialCryptoContext
96
99
  );
97
100
 
101
+ Logger.log(LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
102
+
103
+ // Validation of accessTokenResponse.authorization_details if contain credentialDefinition
98
104
  const containsCredentialDefinition = accessToken.authorization_details.some(
99
- (detail) =>
100
- detail.credential_configuration_id ===
105
+ (c) =>
106
+ c.credential_configuration_id ===
101
107
  credentialDefinition.credential_configuration_id &&
102
- detail.type === credentialDefinition.type
108
+ c.format === credentialDefinition.format &&
109
+ c.type === credentialDefinition.type
103
110
  );
104
111
 
105
112
  if (!containsCredentialDefinition) {
113
+ Logger.log(
114
+ LogLevel.ERROR,
115
+ `Credential definition not found in the access token response ${accessToken.authorization_details}`
116
+ );
106
117
  throw new ValidationFailed({
107
118
  message:
108
119
  "The access token response does not contain the requested credential",
109
120
  });
110
121
  }
111
122
 
112
- const credential =
113
- issuerConf.credential_configurations_supported[
114
- credentialDefinition.credential_configuration_id
115
- ];
116
-
117
- if (!credential) {
118
- throw new ValidationFailed({
119
- message: "The credential configuration is not supported by the issuer",
120
- });
121
- }
122
-
123
- const format = credential.format;
124
-
125
- if (!format) {
126
- throw new ValidationFailed({
127
- message:
128
- "The credential doesn't contain the format required by the issuer",
129
- });
130
- }
131
-
132
123
  /** The credential request body */
133
124
  const credentialRequestFormBody = {
134
- ...(format === "mso_mdoc"
135
- ? { doctype: credentialDefinition.credential_configuration_id }
136
- : { vct: credentialDefinition.credential_configuration_id }),
137
- format,
125
+ credential_definition: {
126
+ type: [credentialDefinition.credential_configuration_id],
127
+ },
128
+ format: credentialDefinition.format,
138
129
  proof: {
139
130
  jwt: signedNonceProof,
140
131
  proof_type: "jwt",
141
132
  },
142
133
  };
143
134
 
135
+ Logger.log(
136
+ LogLevel.DEBUG,
137
+ `Credential request body: ${JSON.stringify(credentialRequestFormBody)}`
138
+ );
139
+
144
140
  const tokenRequestSignedDPop = await createDPopToken(
145
141
  {
146
142
  htm: "POST",
147
143
  htu: credentialUrl,
148
- jti: `${uuid.v4()}`,
144
+ jti: `${uuidv4()}`,
149
145
  ath: await sha256ToBase64(accessToken.access_token),
150
146
  },
151
147
  dPopCryptoContext
152
148
  );
149
+
150
+ Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
151
+
153
152
  const credentialRes = await appFetch(credentialUrl, {
154
153
  method: "POST",
155
154
  headers: {
156
155
  "Content-Type": "application/json",
157
156
  DPoP: tokenRequestSignedDPop,
158
157
  Authorization: `${accessToken.token_type} ${accessToken.access_token}`,
158
+ ...(operationType === "reissuing" && { operationType }),
159
159
  },
160
160
  body: JSON.stringify(credentialRequestFormBody),
161
161
  })
@@ -165,13 +165,21 @@ export const obtainCredential: ObtainCredential = async (
165
165
  .catch(handleObtainCredentialError);
166
166
 
167
167
  if (!credentialRes.success) {
168
+ Logger.log(
169
+ LogLevel.ERROR,
170
+ `Credential Response validation failed: ${credentialRes.error.message}`
171
+ );
168
172
  throw new ValidationFailed({
169
173
  message: "Credential Response validation failed",
170
174
  reason: credentialRes.error.message,
171
175
  });
172
176
  }
173
177
 
174
- /* temporary base64 parsing for the "mso_mdoc" format until the credential submission with this format is fixed. */
178
+ Logger.log(
179
+ LogLevel.DEBUG,
180
+ `Credential Response: ${JSON.stringify(credentialRes.data)}`
181
+ );
182
+
175
183
  return credentialRes.data;
176
184
  };
177
185
 
@@ -182,11 +190,28 @@ export const obtainCredential: ObtainCredential = async (
182
190
  * @throws {IssuerResponseError} with a specific code for more context
183
191
  */
184
192
  const handleObtainCredentialError = (e: unknown) => {
193
+ Logger.log(LogLevel.ERROR, `Error occurred while obtaining credential: ${e}`);
194
+
185
195
  if (!(e instanceof UnexpectedStatusCodeError)) {
186
196
  throw e;
187
197
  }
188
198
 
189
199
  throw new ResponseErrorBuilder(IssuerResponseError)
200
+ .handle(201, {
201
+ // Although it is technically not an error, we handle it as such to avoid
202
+ // changing the return type of `obtainCredential` and introduce a breaking change.
203
+ code: IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
204
+ message:
205
+ "This credential cannot be issued synchronously. It will be available at a later time.",
206
+ })
207
+ .handle(403, {
208
+ code: IssuerResponseErrorCodes.CredentialInvalidStatus,
209
+ message: "Invalid status found for the given credential",
210
+ })
211
+ .handle(404, {
212
+ code: IssuerResponseErrorCodes.CredentialInvalidStatus,
213
+ message: "Invalid status found for the given credential",
214
+ })
190
215
  .handle("*", {
191
216
  code: IssuerResponseErrorCodes.CredentialRequestFailed,
192
217
  message: "Unable to obtain the requested credential",