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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (443) hide show
  1. package/README.md +47 -1
  2. package/lib/commonjs/client/generated/wallet-provider.js +49 -20
  3. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
  4. package/lib/commonjs/credential/index.js +5 -1
  5. package/lib/commonjs/credential/index.js.map +1 -1
  6. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
  7. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  8. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
  9. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  10. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
  11. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  12. package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
  13. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  14. package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
  15. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  16. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
  17. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  18. package/lib/commonjs/credential/issuance/README.md +23 -20
  19. package/lib/commonjs/credential/issuance/const.js +1 -1
  20. package/lib/commonjs/credential/issuance/const.js.map +1 -1
  21. package/lib/commonjs/credential/issuance/index.js +3 -3
  22. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  23. package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
  24. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  25. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
  26. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  27. package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
  28. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
  29. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
  30. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  31. package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
  32. package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
  33. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
  34. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  35. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
  36. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  37. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
  38. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  39. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
  40. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
  41. package/lib/commonjs/credential/presentation/README.md +74 -79
  42. package/lib/commonjs/credential/presentation/errors.js +42 -21
  43. package/lib/commonjs/credential/presentation/errors.js.map +1 -1
  44. package/lib/commonjs/credential/presentation/index.js +13 -13
  45. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  46. package/lib/commonjs/credential/presentation/types.js +53 -29
  47. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  48. package/lib/commonjs/credential/status/01-start-flow.js +2 -0
  49. package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
  50. package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
  51. package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
  52. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
  53. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  54. package/lib/commonjs/credential/status/README.md +67 -0
  55. package/lib/commonjs/credential/status/index.js +27 -0
  56. package/lib/commonjs/credential/status/index.js.map +1 -0
  57. package/lib/commonjs/credential/status/types.js +48 -0
  58. package/lib/commonjs/credential/status/types.js.map +1 -0
  59. package/lib/commonjs/credential/trustmark/README.md +62 -0
  60. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
  61. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
  62. package/lib/commonjs/credential/trustmark/index.js +13 -0
  63. package/lib/commonjs/credential/trustmark/index.js.map +1 -0
  64. package/lib/commonjs/index.js +5 -1
  65. package/lib/commonjs/index.js.map +1 -1
  66. package/lib/commonjs/pid/sd-jwt/types.js +18 -2
  67. package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
  68. package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
  69. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  70. package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
  71. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  72. package/lib/commonjs/sd-jwt/index.js +1 -7
  73. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  74. package/lib/commonjs/sd-jwt/types.js +5 -21
  75. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  76. package/lib/commonjs/trust/README.md +147 -0
  77. package/lib/commonjs/trust/chain.js +153 -0
  78. package/lib/commonjs/trust/chain.js.map +1 -0
  79. package/lib/commonjs/trust/errors.js +133 -0
  80. package/lib/commonjs/trust/errors.js.map +1 -0
  81. package/lib/commonjs/trust/index.js +288 -0
  82. package/lib/commonjs/trust/index.js.map +1 -0
  83. package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
  84. package/lib/commonjs/trust/types.js.map +1 -0
  85. package/lib/commonjs/trust/utils.js +70 -0
  86. package/lib/commonjs/trust/utils.js.map +1 -0
  87. package/lib/commonjs/utils/crypto.js +5 -112
  88. package/lib/commonjs/utils/crypto.js.map +1 -1
  89. package/lib/commonjs/utils/decoder.js +2 -0
  90. package/lib/commonjs/utils/decoder.js.map +1 -1
  91. package/lib/commonjs/utils/error-codes.js +22 -2
  92. package/lib/commonjs/utils/error-codes.js.map +1 -1
  93. package/lib/commonjs/utils/errors.js +72 -4
  94. package/lib/commonjs/utils/errors.js.map +1 -1
  95. package/lib/commonjs/utils/logging.js +68 -0
  96. package/lib/commonjs/utils/logging.js.map +1 -0
  97. package/lib/commonjs/utils/misc.js +2 -0
  98. package/lib/commonjs/utils/misc.js.map +1 -1
  99. package/lib/commonjs/utils/par.js +17 -10
  100. package/lib/commonjs/utils/par.js.map +1 -1
  101. package/lib/commonjs/utils/string.js +1 -12
  102. package/lib/commonjs/utils/string.js.map +1 -1
  103. package/lib/commonjs/wallet-instance/index.js +14 -0
  104. package/lib/commonjs/wallet-instance/index.js.map +1 -1
  105. package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
  106. package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
  107. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  108. package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
  109. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  110. package/lib/module/client/generated/wallet-provider.js +40 -15
  111. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  112. package/lib/module/credential/index.js +3 -1
  113. package/lib/module/credential/index.js.map +1 -1
  114. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
  115. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  116. package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
  117. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  118. package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
  119. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  120. package/lib/module/credential/issuance/05-authorize-access.js +17 -11
  121. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  122. package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
  123. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  124. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
  125. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  126. package/lib/module/credential/issuance/README.md +23 -20
  127. package/lib/module/credential/issuance/const.js +1 -1
  128. package/lib/module/credential/issuance/const.js.map +1 -1
  129. package/lib/module/credential/issuance/index.js +2 -2
  130. package/lib/module/credential/issuance/index.js.map +1 -1
  131. package/lib/module/credential/presentation/01-start-flow.js +14 -15
  132. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  133. package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
  134. package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  135. package/lib/module/credential/presentation/03-get-request-object.js +34 -7
  136. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
  137. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
  138. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  139. package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
  140. package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
  141. package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
  142. package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  143. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
  144. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  145. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
  146. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  147. package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
  148. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  149. package/lib/module/credential/presentation/README.md +74 -79
  150. package/lib/module/credential/presentation/errors.js +30 -17
  151. package/lib/module/credential/presentation/errors.js.map +1 -1
  152. package/lib/module/credential/presentation/index.js +6 -6
  153. package/lib/module/credential/presentation/index.js.map +1 -1
  154. package/lib/module/credential/presentation/types.js +49 -27
  155. package/lib/module/credential/presentation/types.js.map +1 -1
  156. package/lib/module/credential/status/01-start-flow.js +2 -0
  157. package/lib/module/credential/status/01-start-flow.js.map +1 -0
  158. package/lib/module/credential/status/02-status-attestation.js +66 -0
  159. package/lib/module/credential/status/02-status-attestation.js.map +1 -0
  160. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
  161. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  162. package/lib/module/credential/status/README.md +67 -0
  163. package/lib/module/credential/status/index.js +5 -0
  164. package/lib/module/credential/status/index.js.map +1 -0
  165. package/lib/module/credential/status/types.js +40 -0
  166. package/lib/module/credential/status/types.js.map +1 -0
  167. package/lib/module/credential/trustmark/README.md +62 -0
  168. package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
  169. package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
  170. package/lib/module/credential/trustmark/index.js +3 -0
  171. package/lib/module/credential/trustmark/index.js.map +1 -0
  172. package/lib/module/index.js +3 -1
  173. package/lib/module/index.js.map +1 -1
  174. package/lib/module/pid/sd-jwt/types.js +16 -1
  175. package/lib/module/pid/sd-jwt/types.js.map +1 -1
  176. package/lib/module/sd-jwt/__test__/index.test.js +22 -34
  177. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  178. package/lib/module/sd-jwt/__test__/types.test.js +11 -23
  179. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  180. package/lib/module/sd-jwt/index.js +1 -7
  181. package/lib/module/sd-jwt/index.js.map +1 -1
  182. package/lib/module/sd-jwt/types.js +4 -19
  183. package/lib/module/sd-jwt/types.js.map +1 -1
  184. package/lib/module/trust/README.md +147 -0
  185. package/lib/module/trust/chain.js +145 -0
  186. package/lib/module/trust/chain.js.map +1 -0
  187. package/lib/module/trust/errors.js +115 -0
  188. package/lib/module/trust/errors.js.map +1 -0
  189. package/lib/module/trust/index.js +269 -0
  190. package/lib/module/trust/index.js.map +1 -0
  191. package/lib/module/{entity/trust → trust}/types.js +25 -46
  192. package/lib/module/trust/types.js.map +1 -0
  193. package/lib/module/trust/utils.js +60 -0
  194. package/lib/module/trust/utils.js.map +1 -0
  195. package/lib/module/utils/crypto.js +4 -107
  196. package/lib/module/utils/crypto.js.map +1 -1
  197. package/lib/module/utils/decoder.js +3 -0
  198. package/lib/module/utils/decoder.js.map +1 -1
  199. package/lib/module/utils/error-codes.js +20 -1
  200. package/lib/module/utils/error-codes.js.map +1 -1
  201. package/lib/module/utils/errors.js +61 -4
  202. package/lib/module/utils/errors.js.map +1 -1
  203. package/lib/module/utils/logging.js +62 -0
  204. package/lib/module/utils/logging.js.map +1 -0
  205. package/lib/module/utils/misc.js +2 -0
  206. package/lib/module/utils/misc.js.map +1 -1
  207. package/lib/module/utils/par.js +17 -9
  208. package/lib/module/utils/par.js.map +1 -1
  209. package/lib/module/utils/string.js +0 -10
  210. package/lib/module/utils/string.js.map +1 -1
  211. package/lib/module/wallet-instance/index.js +13 -0
  212. package/lib/module/wallet-instance/index.js.map +1 -1
  213. package/lib/module/wallet-instance-attestation/README.md +8 -3
  214. package/lib/module/wallet-instance-attestation/index.js +2 -2
  215. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  216. package/lib/module/wallet-instance-attestation/issuing.js +16 -9
  217. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  218. package/lib/module/wallet-instance-attestation/types.js +14 -18
  219. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  220. package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
  221. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  222. package/lib/typescript/credential/index.d.ts +3 -1
  223. package/lib/typescript/credential/index.d.ts.map +1 -1
  224. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
  225. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
  226. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
  227. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
  228. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  229. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
  230. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  231. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
  232. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  233. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
  234. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  235. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
  236. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  237. package/lib/typescript/credential/issuance/const.d.ts +1 -1
  238. package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
  239. package/lib/typescript/credential/issuance/index.d.ts +3 -3
  240. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  241. package/lib/typescript/credential/issuance/types.d.ts +8 -3
  242. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  243. package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
  244. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
  245. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
  246. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
  247. package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
  248. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
  249. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
  250. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
  251. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
  252. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
  253. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
  254. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
  255. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
  256. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  257. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
  258. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  259. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
  260. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
  261. package/lib/typescript/credential/presentation/errors.d.ts +25 -10
  262. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
  263. package/lib/typescript/credential/presentation/index.d.ts +7 -8
  264. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  265. package/lib/typescript/credential/presentation/types.d.ts +137 -307
  266. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  267. package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
  268. package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
  269. package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
  270. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
  271. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
  272. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
  273. package/lib/typescript/credential/status/index.d.ts +7 -0
  274. package/lib/typescript/credential/status/index.d.ts.map +1 -0
  275. package/lib/typescript/credential/status/types.d.ts +305 -0
  276. package/lib/typescript/credential/status/types.d.ts.map +1 -0
  277. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
  278. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
  279. package/lib/typescript/credential/trustmark/index.d.ts +4 -0
  280. package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
  281. package/lib/typescript/index.d.ts +3 -1
  282. package/lib/typescript/index.d.ts.map +1 -1
  283. package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
  284. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
  285. package/lib/typescript/sd-jwt/index.d.ts +20 -72
  286. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  287. package/lib/typescript/sd-jwt/types.d.ts +24 -129
  288. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  289. package/lib/typescript/trust/chain.d.ts +23 -0
  290. package/lib/typescript/trust/chain.d.ts.map +1 -0
  291. package/lib/typescript/trust/errors.d.ts +102 -0
  292. package/lib/typescript/trust/errors.d.ts.map +1 -0
  293. package/lib/typescript/{entity/trust → trust}/index.d.ts +308 -281
  294. package/lib/typescript/trust/index.d.ts.map +1 -0
  295. package/lib/typescript/{entity/trust → trust}/types.d.ts +1714 -1301
  296. package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
  297. package/lib/typescript/trust/utils.d.ts +22 -0
  298. package/lib/typescript/trust/utils.d.ts.map +1 -0
  299. package/lib/typescript/utils/crypto.d.ts +0 -32
  300. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  301. package/lib/typescript/utils/decoder.d.ts.map +1 -1
  302. package/lib/typescript/utils/error-codes.d.ts +20 -0
  303. package/lib/typescript/utils/error-codes.d.ts.map +1 -1
  304. package/lib/typescript/utils/errors.d.ts +55 -10
  305. package/lib/typescript/utils/errors.d.ts.map +1 -1
  306. package/lib/typescript/utils/logging.d.ts +35 -0
  307. package/lib/typescript/utils/logging.d.ts.map +1 -0
  308. package/lib/typescript/utils/misc.d.ts.map +1 -1
  309. package/lib/typescript/utils/par.d.ts +8 -1
  310. package/lib/typescript/utils/par.d.ts.map +1 -1
  311. package/lib/typescript/utils/string.d.ts +0 -7
  312. package/lib/typescript/utils/string.d.ts.map +1 -1
  313. package/lib/typescript/wallet-instance/index.d.ts +8 -0
  314. package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
  315. package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
  316. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  317. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
  318. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  319. package/lib/typescript/wallet-instance-attestation/types.d.ts +60 -102
  320. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  321. package/package.json +9 -10
  322. package/src/client/generated/wallet-provider.ts +52 -17
  323. package/src/credential/index.ts +4 -1
  324. package/src/credential/issuance/01-start-flow.ts +1 -1
  325. package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
  326. package/src/credential/issuance/03-start-user-authorization.ts +48 -22
  327. package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
  328. package/src/credential/issuance/05-authorize-access.ts +29 -11
  329. package/src/credential/issuance/06-obtain-credential.ts +61 -36
  330. package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
  331. package/src/credential/issuance/README.md +23 -20
  332. package/src/credential/issuance/const.ts +1 -1
  333. package/src/credential/issuance/index.ts +6 -3
  334. package/src/credential/presentation/01-start-flow.ts +19 -22
  335. package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
  336. package/src/credential/presentation/03-get-request-object.ts +36 -8
  337. package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
  338. package/src/credential/presentation/05-verify-request-object.ts +115 -30
  339. package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
  340. package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
  341. package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
  342. package/src/credential/presentation/08-send-authorization-response.ts +178 -260
  343. package/src/credential/presentation/README.md +74 -79
  344. package/src/credential/presentation/errors.ts +38 -15
  345. package/src/credential/presentation/index.ts +18 -19
  346. package/src/credential/presentation/types.ts +67 -64
  347. package/src/credential/status/01-start-flow.ts +9 -0
  348. package/src/credential/status/02-status-attestation.ts +105 -0
  349. package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
  350. package/src/credential/status/README.md +67 -0
  351. package/src/credential/status/index.ts +22 -0
  352. package/src/credential/status/types.ts +43 -0
  353. package/src/credential/trustmark/README.md +62 -0
  354. package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
  355. package/src/credential/trustmark/index.ts +8 -0
  356. package/src/index.ts +4 -0
  357. package/src/pid/sd-jwt/types.ts +18 -1
  358. package/src/sd-jwt/__test__/index.test.ts +36 -55
  359. package/src/sd-jwt/__test__/types.test.ts +16 -29
  360. package/src/sd-jwt/index.ts +1 -5
  361. package/src/sd-jwt/types.ts +2 -19
  362. package/src/trust/README.md +147 -0
  363. package/src/trust/chain.ts +227 -0
  364. package/src/trust/errors.ts +136 -0
  365. package/src/{entity/trust → trust}/index.ts +207 -25
  366. package/src/{entity/trust → trust}/types.ts +24 -37
  367. package/src/trust/utils.ts +70 -0
  368. package/src/utils/crypto.ts +4 -106
  369. package/src/utils/decoder.ts +6 -1
  370. package/src/utils/error-codes.ts +23 -0
  371. package/src/utils/errors.ts +119 -15
  372. package/src/utils/logging.ts +68 -0
  373. package/src/utils/misc.ts +5 -0
  374. package/src/utils/par.ts +19 -6
  375. package/src/utils/string.ts +0 -10
  376. package/src/wallet-instance/index.ts +30 -1
  377. package/src/wallet-instance-attestation/README.md +8 -3
  378. package/src/wallet-instance-attestation/index.ts +2 -2
  379. package/src/wallet-instance-attestation/issuing.ts +33 -12
  380. package/src/wallet-instance-attestation/types.ts +18 -22
  381. package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
  382. package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
  383. package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
  384. package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
  385. package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
  386. package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
  387. package/lib/commonjs/entity/trust/chain.js +0 -122
  388. package/lib/commonjs/entity/trust/chain.js.map +0 -1
  389. package/lib/commonjs/entity/trust/index.js +0 -148
  390. package/lib/commonjs/entity/trust/index.js.map +0 -1
  391. package/lib/commonjs/entity/trust/types.js.map +0 -1
  392. package/lib/commonjs/mdoc/converters.js +0 -26
  393. package/lib/commonjs/mdoc/converters.js.map +0 -1
  394. package/lib/commonjs/mdoc/index.js +0 -68
  395. package/lib/commonjs/mdoc/index.js.map +0 -1
  396. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
  397. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  398. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
  399. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  400. package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
  401. package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
  402. package/lib/module/entity/openid-connect/issuer/index.js +0 -20
  403. package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
  404. package/lib/module/entity/openid-connect/issuer/types.js +0 -48
  405. package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
  406. package/lib/module/entity/trust/chain.js +0 -113
  407. package/lib/module/entity/trust/chain.js.map +0 -1
  408. package/lib/module/entity/trust/index.js +0 -131
  409. package/lib/module/entity/trust/index.js.map +0 -1
  410. package/lib/module/entity/trust/types.js.map +0 -1
  411. package/lib/module/mdoc/converters.js +0 -20
  412. package/lib/module/mdoc/converters.js.map +0 -1
  413. package/lib/module/mdoc/index.js +0 -60
  414. package/lib/module/mdoc/index.js.map +0 -1
  415. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
  416. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  417. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
  418. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  419. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
  420. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
  421. package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
  422. package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
  423. package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
  424. package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
  425. package/lib/typescript/entity/trust/chain.d.ts +0 -26
  426. package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
  427. package/lib/typescript/entity/trust/index.d.ts.map +0 -1
  428. package/lib/typescript/mdoc/converters.d.ts +0 -8
  429. package/lib/typescript/mdoc/converters.d.ts.map +0 -1
  430. package/lib/typescript/mdoc/index.d.ts +0 -10
  431. package/lib/typescript/mdoc/index.d.ts.map +0 -1
  432. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
  433. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
  434. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
  435. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
  436. package/src/credential/issuance/02-get-issuer-config.ts +0 -67
  437. package/src/entity/openid-connect/issuer/index.ts +0 -27
  438. package/src/entity/openid-connect/issuer/types.ts +0 -76
  439. package/src/entity/trust/chain.ts +0 -154
  440. package/src/mdoc/converters.ts +0 -26
  441. package/src/mdoc/index.ts +0 -95
  442. package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
  443. package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -1,14 +1,25 @@
1
+ import { decode, verify } from "./utils";
1
2
  import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
2
3
  import {
3
- WalletProviderEntityConfiguration,
4
- TrustAnchorEntityConfiguration,
5
4
  CredentialIssuerEntityConfiguration,
6
- RelyingPartyEntityConfiguration,
7
5
  EntityConfiguration,
8
6
  EntityStatement,
7
+ FederationListResponse,
8
+ RelyingPartyEntityConfiguration,
9
+ TrustAnchorEntityConfiguration,
10
+ WalletProviderEntityConfiguration,
9
11
  } from "./types";
10
- import { validateTrustChain, renewTrustChain } from "./chain";
11
- import { hasStatusOrThrow } from "../../utils/misc";
12
+ import { renewTrustChain, validateTrustChain } from "./chain";
13
+ import { hasStatusOrThrow } from "../utils/misc";
14
+ import type { JWK } from "../utils/jwk";
15
+ import {
16
+ BuildTrustChainError,
17
+ FederationListParseError,
18
+ MissingFederationFetchEndpointError,
19
+ RelyingPartyNotAuthorizedError,
20
+ TrustAnchorKidMissingError,
21
+ } from "./errors";
22
+ import type { X509CertificateOptions } from "@pagopa/io-react-native-crypto";
12
23
 
13
24
  export type {
14
25
  WalletProviderEntityConfiguration,
@@ -24,26 +35,32 @@ export type {
24
35
  * It can handle fast chain renewal, which means we try to fetch a fresh version of each statement.
25
36
  *
26
37
  * @param trustAnchorEntity The entity configuration of the known trust anchor
27
- * @param chain The chain of statements to be validate
28
- * @param options.renewOnFail Whether to renew the provided chain if the validation fails at first. Default: true
29
- * @param options.appFetch Fetch api implementation. Default: the built-in implementation
38
+ * @param chain The chain of statements to be validated
39
+ * @param x509Options Options for the verification process
40
+ * @param appFetch (optional) fetch api implementation
41
+ * @param renewOnFail Whether to attempt to renew the trust chain if the initial validation fails
30
42
  * @returns The result of the chain validation
31
- * @throws {IoWalletError} When either validation or renewal fail
43
+ * @throws {FederationError} If the chain is not valid
32
44
  */
33
45
  export async function verifyTrustChain(
34
46
  trustAnchorEntity: TrustAnchorEntityConfiguration,
35
47
  chain: string[],
48
+ x509Options: X509CertificateOptions = {
49
+ connectTimeout: 10000,
50
+ readTimeout: 10000,
51
+ requireCrl: true,
52
+ },
36
53
  {
37
54
  appFetch = fetch,
38
55
  renewOnFail = true,
39
56
  }: { appFetch?: GlobalFetch["fetch"]; renewOnFail?: boolean } = {}
40
57
  ): Promise<ReturnType<typeof validateTrustChain>> {
41
58
  try {
42
- return validateTrustChain(trustAnchorEntity, chain);
59
+ return validateTrustChain(trustAnchorEntity, chain, x509Options);
43
60
  } catch (error) {
44
61
  if (renewOnFail) {
45
62
  const renewedChain = await renewTrustChain(chain, appFetch);
46
- return validateTrustChain(trustAnchorEntity, renewedChain);
63
+ return validateTrustChain(trustAnchorEntity, renewedChain, x509Options);
47
64
  } else {
48
65
  throw error;
49
66
  }
@@ -54,7 +71,7 @@ export async function verifyTrustChain(
54
71
  * Fetch the signed entity configuration token for an entity
55
72
  *
56
73
  * @param entityBaseUrl The url of the entity to fetch
57
- * @param param.appFetch (optional) fetch api implemention
74
+ * @param appFetch (optional) fetch api implementation
58
75
  * @returns The signed Entity Configuration token
59
76
  */
60
77
  export async function getSignedEntityConfiguration(
@@ -86,6 +103,7 @@ export async function getSignedEntityConfiguration(
86
103
  *
87
104
  * @param entityBaseUrl The base url of the entity.
88
105
  * @param schema The expected schema of the entity configuration, according to the kind of entity we are fetching from.
106
+ * @param options An optional object with additional options.
89
107
  * @param options.appFetch An optional instance of the http client to be used.
90
108
  * @returns The parsed entity configuration object
91
109
  * @throws {IoWalletError} If the http request fails
@@ -200,12 +218,11 @@ export const getEntityConfiguration = (
200
218
  /**
201
219
  * Fetch and parse the entity statement document for a given federation entity.
202
220
  *
203
- * @param accreditationBodyBaseUrl The base url of the accreditaion body which holds and signs the required entity statement
221
+ * @param accreditationBodyBaseUrl The base url of the accreditation body which holds and signs the required entity statement
204
222
  * @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
205
- * @param options.appFetch An optional instance of the http client to be used.
223
+ * @param appFetch An optional instance of the http client to be used.
206
224
  * @returns The parsed entity configuration object
207
225
  * @throws {IoWalletError} If the http request fails
208
- * @throws Parse error if the document is not in the expected shape.
209
226
  */
210
227
  export async function getEntityStatement(
211
228
  accreditationBodyBaseUrl: string,
@@ -234,14 +251,14 @@ export async function getEntityStatement(
234
251
  /**
235
252
  * Fetch the entity statement document for a given federation entity.
236
253
  *
237
- * @param accreditationBodyBaseUrl The base url of the accreditaion body which holds and signs the required entity statement
238
- * @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
239
- * @param options.appFetch An optional instance of the http client to be used.
240
- * @returns The signed entity statement token
241
- * @throws {IoWalletError} If the http request fails
254
+ * @param federationFetchEndpoint The exact endpoint provided by the parent EC's metadata.
255
+ * @param subordinatedEntityBaseUrl The url that identifies the subordinate entity.
256
+ * @param appFetch An optional instance of the http client to be used.
257
+ * @returns The signed entity statement token.
258
+ * @throws {IoWalletError} If the http request fails.
242
259
  */
243
260
  export async function getSignedEntityStatement(
244
- accreditationBodyBaseUrl: string,
261
+ federationFetchEndpoint: string,
245
262
  subordinatedEntityBaseUrl: string,
246
263
  {
247
264
  appFetch = fetch,
@@ -249,13 +266,178 @@ export async function getSignedEntityStatement(
249
266
  appFetch?: GlobalFetch["fetch"];
250
267
  } = {}
251
268
  ) {
252
- const url = `${accreditationBodyBaseUrl}/fetch?${new URLSearchParams({
253
- sub: subordinatedEntityBaseUrl,
254
- })}`;
269
+ const url = new URL(federationFetchEndpoint);
270
+ url.searchParams.set("sub", subordinatedEntityBaseUrl);
255
271
 
256
- return await appFetch(url, {
272
+ return await appFetch(url.toString(), {
257
273
  method: "GET",
258
274
  })
259
275
  .then(hasStatusOrThrow(200))
260
276
  .then((res) => res.text());
261
277
  }
278
+
279
+ /**
280
+ * Fetch the federation list document from a given endpoint.
281
+ *
282
+ * @param federationListEndpoint The URL of the federation list endpoint.
283
+ * @param appFetch An optional instance of the http client to be used.
284
+ * @returns The federation list as an array of strings.
285
+ * @throws {IoWalletError} If the HTTP request fails.
286
+ * @throws {FederationError} If the result is not in the expected format.
287
+ */
288
+ export async function getFederationList(
289
+ federationListEndpoint: string,
290
+ {
291
+ appFetch = fetch,
292
+ }: {
293
+ appFetch?: GlobalFetch["fetch"];
294
+ } = {}
295
+ ): Promise<string[]> {
296
+ return await appFetch(federationListEndpoint, {
297
+ method: "GET",
298
+ })
299
+ .then(hasStatusOrThrow(200))
300
+ .then((res) => res.json())
301
+ .then((json) => {
302
+ const result = FederationListResponse.safeParse(json);
303
+ if (!result.success) {
304
+ throw new FederationListParseError(
305
+ `Invalid federation list format received from ${federationListEndpoint}. Error: ${result.error.message}`,
306
+ { url: federationListEndpoint, parseError: result.error.toString() }
307
+ );
308
+ }
309
+ return result.data;
310
+ });
311
+ }
312
+
313
+ /**
314
+ * Build a not-verified trust chain for a given Relying Party (RP) entity.
315
+ *
316
+ * @param relyingPartyEntityBaseUrl The base URL of the RP entity
317
+ * @param trustAnchorKey The public key of the Trust Anchor (TA) entity
318
+ * @param appFetch An optional instance of the http client to be used.
319
+ * @returns A list of signed tokens that represent the trust chain, in the order of the chain (from the RP to the Trust Anchor)
320
+ * @throws {FederationError} When an element of the chain fails to parse or other build steps fail.
321
+ */
322
+ export async function buildTrustChain(
323
+ relyingPartyEntityBaseUrl: string,
324
+ trustAnchorKey: JWK,
325
+ appFetch: GlobalFetch["fetch"] = fetch
326
+ ): Promise<string[]> {
327
+ // 1: Recursively gather the trust chain from the RP up to the Trust Anchor
328
+ const trustChain = await gatherTrustChain(
329
+ relyingPartyEntityBaseUrl,
330
+ appFetch
331
+ );
332
+
333
+ // 2: Trust Anchor signature verification
334
+ const trustAnchorJwt = trustChain[trustChain.length - 1];
335
+ if (!trustAnchorJwt) {
336
+ throw new BuildTrustChainError(
337
+ "Cannot verify trust anchor: missing entity configuration in gathered chain.",
338
+ { relyingPartyUrl: relyingPartyEntityBaseUrl }
339
+ );
340
+ }
341
+
342
+ if (!trustAnchorKey.kid) {
343
+ throw new TrustAnchorKidMissingError();
344
+ }
345
+
346
+ await verify(trustAnchorJwt, trustAnchorKey.kid, [trustAnchorKey]);
347
+
348
+ // 3: Check the federation list
349
+ const trustAnchorConfig = EntityConfiguration.parse(decode(trustAnchorJwt));
350
+ const federationListEndpoint =
351
+ trustAnchorConfig.payload.metadata.federation_entity
352
+ .federation_list_endpoint;
353
+
354
+ if (federationListEndpoint) {
355
+ const federationList = await getFederationList(federationListEndpoint, {
356
+ appFetch,
357
+ });
358
+
359
+ if (!federationList.includes(relyingPartyEntityBaseUrl)) {
360
+ throw new RelyingPartyNotAuthorizedError(
361
+ "Relying Party entity base URL is not authorized by the Trust Anchor's federation list.",
362
+ { relyingPartyUrl: relyingPartyEntityBaseUrl, federationListEndpoint }
363
+ );
364
+ }
365
+ }
366
+
367
+ return trustChain;
368
+ }
369
+
370
+ /**
371
+ * Recursively gather the trust chain for an entity and all its superiors.
372
+ * @param entityBaseUrl The base URL of the entity for which to gather the chain.
373
+ * @param appFetch An optional instance of the http client to be used.
374
+ * @param isLeaf Whether the current entity is the leaf of the chain.
375
+ * @returns A full ordered list of JWTs (ECs and ESs) forming the trust chain.
376
+ * @throws {FederationError} If any of the fetched documents fail to parse or other errors occur during the gathering process.
377
+ */
378
+ async function gatherTrustChain(
379
+ entityBaseUrl: string,
380
+ appFetch: GlobalFetch["fetch"],
381
+ isLeaf: boolean = true
382
+ ): Promise<string[]> {
383
+ const chain: string[] = [];
384
+
385
+ // Fetch self-signed EC (only needed for the leaf)
386
+ const entityECJwt = await getSignedEntityConfiguration(entityBaseUrl, {
387
+ appFetch,
388
+ });
389
+ const entityEC = EntityConfiguration.parse(decode(entityECJwt));
390
+
391
+ if (isLeaf) {
392
+ // Only push EC for the leaf
393
+ chain.push(entityECJwt);
394
+ }
395
+
396
+ // Find authority_hints (parent, if any)
397
+ const authorityHints = entityEC.payload.authority_hints ?? [];
398
+ if (authorityHints.length === 0) {
399
+ // This is the Trust Anchor (no parent)
400
+ if (!isLeaf) {
401
+ chain.push(entityECJwt);
402
+ }
403
+ return chain;
404
+ }
405
+
406
+ const parentEntityBaseUrl = authorityHints[0]!;
407
+
408
+ // Fetch parent EC
409
+ const parentECJwt = await getSignedEntityConfiguration(parentEntityBaseUrl, {
410
+ appFetch,
411
+ });
412
+ const parentEC = EntityConfiguration.parse(decode(parentECJwt));
413
+
414
+ // Fetch ES
415
+ const federationFetchEndpoint =
416
+ parentEC.payload.metadata.federation_entity.federation_fetch_endpoint;
417
+ if (!federationFetchEndpoint) {
418
+ throw new MissingFederationFetchEndpointError(
419
+ `Missing federation_fetch_endpoint in parent's (${parentEntityBaseUrl}) configuration when gathering chain for ${entityBaseUrl}.`,
420
+ { entityBaseUrl, missingInEntityUrl: parentEntityBaseUrl }
421
+ );
422
+ }
423
+
424
+ const entityStatementJwt = await getSignedEntityStatement(
425
+ federationFetchEndpoint,
426
+ entityBaseUrl,
427
+ { appFetch }
428
+ );
429
+ // Validate the ES
430
+ EntityStatement.parse(decode(entityStatementJwt));
431
+
432
+ // Push this ES into the chain
433
+ chain.push(entityStatementJwt);
434
+
435
+ // Recurse into the parent
436
+ const parentChain = await gatherTrustChain(
437
+ parentEntityBaseUrl,
438
+ appFetch,
439
+ false
440
+ );
441
+
442
+ return chain.concat(parentChain);
443
+ }
@@ -1,7 +1,7 @@
1
- import { UnixTime } from "../../sd-jwt/types";
2
- import { JWK } from "../../utils/jwk";
1
+ import { UnixTime } from "../sd-jwt/types";
2
+ import { JWK } from "../utils/jwk";
3
3
  import * as z from "zod";
4
- import { PresentationDefinition } from "../../credential/presentation/types";
4
+ import { PresentationDefinition } from "../credential/presentation/types";
5
5
 
6
6
  export const TrustMark = z.object({ id: z.string(), trust_mark: z.string() });
7
7
  export type TrustMark = z.infer<typeof TrustMark>;
@@ -13,9 +13,11 @@ const RelyingPartyMetadata = z.object({
13
13
  jwks: z.object({ keys: z.array(JWK) }),
14
14
  contacts: z.array(z.string()).optional(),
15
15
  presentation_definition: PresentationDefinition.optional(),
16
- presentation_definition_uri: z.string().optional(),
16
+ request_uris: z.array(z.string()).optional(),
17
+ authorization_signed_response_alg: z.string().optional(),
18
+ authorization_encrypted_response_alg: z.string().optional(),
19
+ authorization_encrypted_response_enc: z.string().optional(),
17
20
  });
18
- //.passthrough();
19
21
 
20
22
  // Display metadata for a credential, used by the issuer to
21
23
  // instruct the Wallet Solution on how to render the credential correctly
@@ -23,14 +25,6 @@ type CredentialDisplayMetadata = z.infer<typeof CredentialDisplayMetadata>;
23
25
  const CredentialDisplayMetadata = z.object({
24
26
  name: z.string(),
25
27
  locale: z.string(),
26
- logo: z
27
- .object({
28
- url: z.string(),
29
- alt_text: z.string(),
30
- })
31
- .optional(), // TODO [SIW-1268]: should not be optional
32
- background_color: z.string().optional(), // TODO [SIW-1268]: should not be optional
33
- text_color: z.string().optional(), // TODO [SIW-1268]: should not be optional
34
28
  });
35
29
 
36
30
  // Metadata for displaying issuer information
@@ -40,12 +34,6 @@ type CredentialIssuerDisplayMetadata = z.infer<
40
34
  const CredentialIssuerDisplayMetadata = z.object({
41
35
  name: z.string(),
42
36
  locale: z.string(),
43
- logo: z
44
- .object({
45
- url: z.string(),
46
- alt_text: z.string(),
47
- })
48
- .optional(), // TODO [SIW-1268]: should not be optional
49
37
  });
50
38
 
51
39
  type ClaimsMetadata = z.infer<typeof ClaimsMetadata>;
@@ -67,13 +55,13 @@ const IssuanceErrorSupported = z.object({
67
55
  ),
68
56
  });
69
57
 
70
- // Metadata for a credentia which is supported by a Issuer
58
+ // Metadata for a credential which is supported by an Issuer
71
59
  type SupportedCredentialMetadata = z.infer<typeof SupportedCredentialMetadata>;
72
60
  const SupportedCredentialMetadata = z.object({
73
- format: z.union([z.literal("vc+sd-jwt"), z.literal("mso_mdoc")]),
61
+ format: z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]),
74
62
  scope: z.string(),
75
63
  display: z.array(CredentialDisplayMetadata),
76
- claims: ClaimsMetadata.optional(), // TODO [SIW-1268]: should not be optional
64
+ claims: ClaimsMetadata,
77
65
  cryptographic_binding_methods_supported: z.array(z.string()),
78
66
  credential_signing_alg_values_supported: z.array(z.string()),
79
67
  authentic_source: z.string().optional(),
@@ -91,7 +79,7 @@ export const EntityStatement = z.object({
91
79
  iss: z.string(),
92
80
  sub: z.string(),
93
81
  jwks: z.object({ keys: z.array(JWK) }),
94
- trust_marks: z.array(TrustMark),
82
+ trust_marks: z.array(TrustMark).optional(),
95
83
  iat: z.number(),
96
84
  exp: z.number(),
97
85
  }),
@@ -107,7 +95,7 @@ export const EntityConfigurationHeader = z.object({
107
95
  });
108
96
 
109
97
  /**
110
- * @see https://openid.net/specs/openid-connect-federation-1_0-29.html#name-federation-entity
98
+ * @see https://openid.net/specs/openid-federation-1_0-41.html
111
99
  */
112
100
  const FederationEntityMetadata = z
113
101
  .object({
@@ -116,6 +104,9 @@ const FederationEntityMetadata = z
116
104
  federation_resolve_endpoint: z.string().optional(),
117
105
  federation_trust_mark_status_endpoint: z.string().optional(),
118
106
  federation_trust_mark_list_endpoint: z.string().optional(),
107
+ federation_trust_mark_endpoint: z.string().optional(),
108
+ federation_historical_keys_endpoint: z.string().optional(),
109
+ endpoint_auth_signing_alg_values_supported: z.string().optional(),
119
110
  organization_name: z.string().optional(),
120
111
  homepage_uri: z.string().optional(),
121
112
  policy_uri: z.string().optional(),
@@ -124,7 +115,7 @@ const FederationEntityMetadata = z
124
115
  })
125
116
  .passthrough();
126
117
 
127
- // Structuire common to every Entity Configuration document
118
+ // Structure common to every Entity Configuration document
128
119
  const BaseEntityConfiguration = z.object({
129
120
  header: EntityConfigurationHeader,
130
121
  payload: z
@@ -175,30 +166,24 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(
175
166
  oauth_authorization_server: z.object({
176
167
  authorization_endpoint: z.string(),
177
168
  pushed_authorization_request_endpoint: z.string(),
178
- dpop_signing_alg_values_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
179
169
  token_endpoint: z.string(),
180
- introspection_endpoint: z.string().optional(), // TODO [SIW-1268]: should not be optional
181
170
  client_registration_types_supported: z.array(z.string()),
182
171
  code_challenge_methods_supported: z.array(z.string()),
183
- authorization_details_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional,
184
172
  acr_values_supported: z.array(z.string()),
185
173
  grant_types_supported: z.array(z.string()),
186
174
  issuer: z.string(),
187
175
  jwks: z.object({ keys: z.array(JWK) }),
188
176
  scopes_supported: z.array(z.string()),
189
- request_parameter_supported: z.boolean().optional(), // TODO [SIW-1268]: should not be optional
190
- request_uri_parameter_supported: z.boolean().optional(), // TODO [SIW-1268]: should not be optional
191
- response_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
192
177
  response_modes_supported: z.array(z.string()),
193
- subject_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
194
178
  token_endpoint_auth_methods_supported: z.array(z.string()),
195
179
  token_endpoint_auth_signing_alg_values_supported: z.array(z.string()),
196
180
  request_object_signing_alg_values_supported: z.array(z.string()),
197
181
  }),
198
- /** Credential Issuers act as Relying Party
199
- when they require the presentation of other credentials.
200
- This does not apply for PID issuance, which requires CIE authz. */
201
- wallet_relying_party: RelyingPartyMetadata.optional(),
182
+ /**
183
+ * Credential Issuers act as Relying Party when they require the presentation of other credentials.
184
+ * This does not apply for PID issuance, which requires CIE authz.
185
+ */
186
+ openid_credential_verifier: RelyingPartyMetadata.optional(),
202
187
  }),
203
188
  }),
204
189
  })
@@ -212,7 +197,7 @@ export const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(
212
197
  z.object({
213
198
  payload: z.object({
214
199
  metadata: z.object({
215
- wallet_relying_party: RelyingPartyMetadata,
200
+ openid_credential_verifier: RelyingPartyMetadata,
216
201
  }),
217
202
  }),
218
203
  })
@@ -256,3 +241,5 @@ export const EntityConfiguration = z.union(
256
241
  description: "Any kind of Entity Configuration allowed in the ecosystem",
257
242
  }
258
243
  );
244
+
245
+ export const FederationListResponse = z.array(z.string());
@@ -0,0 +1,70 @@
1
+ import {
2
+ decode as decodeJwt,
3
+ verify as verifyJwt,
4
+ } from "@pagopa/io-react-native-jwt";
5
+
6
+ import type { JWK, JWTDecodeResult } from "../utils/jwk";
7
+ import { FederationError } from "./errors";
8
+ import type { TrustAnchorEntityConfiguration } from "./types";
9
+
10
+ export type ParsedToken = {
11
+ header: JWTDecodeResult["protectedHeader"];
12
+ payload: JWTDecodeResult["payload"];
13
+ };
14
+
15
+ // Verify a token signature
16
+ // The kid is extracted from the token header
17
+ export const verify = async (
18
+ token: string,
19
+ kid: string,
20
+ jwks: JWK[]
21
+ ): Promise<ParsedToken> => {
22
+ const jwk = jwks.find((k) => k.kid === kid);
23
+ if (!jwk) {
24
+ throw new Error(`Invalid kid: ${kid}, token: ${token}`);
25
+ }
26
+ const { protectedHeader: header, payload } = await verifyJwt(token, jwk);
27
+ return { header, payload };
28
+ };
29
+
30
+ /**
31
+ * Return type for this function is necessary to avoid an issue during the bob build process.
32
+ * It seems like typescript can't correctly infer the return type of the function.
33
+ */
34
+ export const decode = (token: string): ParsedToken => {
35
+ const { protectedHeader: header, payload } = decodeJwt(token);
36
+ return { header, payload };
37
+ };
38
+
39
+ /**
40
+ * Extracts the X.509 Trust Anchor certificate (Base64 encoded) from the
41
+ * Trust Anchor's Entity Configuration.
42
+ *
43
+ * @param trustAnchorEntity The entity configuration of the known trust anchor.
44
+ * @returns The Base64 encoded X.509 certificate string.
45
+ * @throws {FederationError} If the certificate cannot be derived.
46
+ */
47
+ export function getTrustAnchorX509Certificate(
48
+ trustAnchorEntity: TrustAnchorEntityConfiguration
49
+ ): string {
50
+ const taHeaderKid = trustAnchorEntity.header.kid;
51
+ const taSigningJwk = trustAnchorEntity.payload.jwks.keys.find(
52
+ (key) => key.kid === taHeaderKid
53
+ );
54
+
55
+ if (!taSigningJwk) {
56
+ throw new FederationError(
57
+ `Cannot derive X.509 Trust Anchor certificate: JWK with kid '${taHeaderKid}' not found in Trust Anchor's JWKS.`,
58
+ { trustAnchorKid: taHeaderKid, reason: "JWK not found for header kid" }
59
+ );
60
+ }
61
+
62
+ if (taSigningJwk.x5c && taSigningJwk.x5c.length > 0 && taSigningJwk.x5c[0]) {
63
+ return taSigningJwk.x5c[0];
64
+ }
65
+
66
+ throw new FederationError(
67
+ `Cannot derive X.509 Trust Anchor certificate: JWK with kid '${taHeaderKid}' does not contain a valid 'x5c' certificate array.`,
68
+ { trustAnchorKid: taHeaderKid, reason: "Missing or empty x5c in JWK" }
69
+ );
70
+ }
@@ -3,14 +3,10 @@ import {
3
3
  sign,
4
4
  generate,
5
5
  deleteKey,
6
- type PublicKey,
7
6
  } from "@pagopa/io-react-native-crypto";
8
- import uuid from "react-native-uuid";
7
+ import { v4 as uuidv4 } from "uuid";
9
8
  import { thumbprint, type CryptoContext } from "@pagopa/io-react-native-jwt";
10
- import { X509, KEYUTIL, RSAKey, KJUR } from "jsrsasign";
11
- import { JWK } from "./jwk";
12
- import { removePadding } from "@pagopa/io-react-native-jwt";
13
- import { Buffer } from "buffer";
9
+ import { fixBase64EncodingOnKey } from "./jwk";
14
10
 
15
11
  /**
16
12
  * Create a CryptoContext bound to a key pair.
@@ -28,7 +24,7 @@ export const createCryptoContextFor = (keytag: string): CryptoContext => {
28
24
  */
29
25
  async getPublicKey() {
30
26
  return getPublicKey(keytag)
31
- .then(fixBase64WithLeadingZero)
27
+ .then(fixBase64EncodingOnKey)
32
28
  .then(async (jwk) => ({
33
29
  ...jwk,
34
30
  // Keys in the TEE are not stored with their KID, which is supposed to be assigned when they are included in JWK sets.
@@ -50,45 +46,6 @@ export const createCryptoContextFor = (keytag: string): CryptoContext => {
50
46
  };
51
47
  };
52
48
 
53
- /**
54
- * This function takes a JSON Web Key (JWK) and returns a new JWK with its base64-url properties (x, y, e, n) processed.
55
- * Each property is passed through the `removeLeadingZeroAndParseb64u` function if it exists, which fixes any unwanted leading zeros.
56
- *
57
- * @param key - The input JSON Web Key that may contain properties with potential leading zero issues.
58
- * @returns A new JSON Web Key with the processed properties.
59
- */
60
- const fixBase64WithLeadingZero = (key: JWK): JWK => {
61
- const { x, y, e, n, ...pk } = key;
62
-
63
- return {
64
- ...pk,
65
- ...(x ? { x: removeLeadingZeroAndParseb64u(x) } : {}),
66
- ...(y ? { y: removeLeadingZeroAndParseb64u(y) } : {}),
67
- ...(e ? { e: removeLeadingZeroAndParseb64u(e) } : {}),
68
- ...(n ? { n: removeLeadingZeroAndParseb64u(n) } : {}),
69
- };
70
- };
71
-
72
- /**
73
- * This function processes a base64-encoded string to remove any unwanted leading zeros.
74
- * It converts the input base64 string into a buffer, then to a hex string, checks for a leading "00",
75
- * and removes it if present. The result is then converted back to a base64-url.
76
- *
77
- * @param input - The base64 encoded string to process.
78
- * @returns A new base64-url encoded string with any leading zero removed.
79
- */
80
- const removeLeadingZeroAndParseb64u = (input: string): string => {
81
- // Decode base64 input into a Buffer
82
- const buffer = Buffer.from(input, "base64");
83
- const hex = buffer.toString("hex");
84
- // If the hex string starts with "00", remove the first two characters
85
- const fixedHex = hex.startsWith("00") ? hex.slice(2) : hex;
86
- const newBuffer = Buffer.from(fixedHex, "hex");
87
-
88
- // removePadding convert base64 string to base64-url
89
- return removePadding(newBuffer.toString("base64"));
90
- };
91
-
92
49
  /**
93
50
  * Executes the input function injecting an ephemeral crypto context.
94
51
  * An ephemeral crypto context is a context which is bound to a key
@@ -101,67 +58,8 @@ export const withEphemeralKey = async <R>(
101
58
  fn: (ephemeralContext: CryptoContext) => Promise<R>
102
59
  ): Promise<R> => {
103
60
  // Use an ephemeral key to be destroyed after use
104
- const keytag = `ephemeral-${uuid.v4()}`;
61
+ const keytag = `ephemeral-${uuidv4()}`;
105
62
  await generate(keytag);
106
63
  const ephemeralContext = createCryptoContextFor(keytag);
107
64
  return fn(ephemeralContext).finally(() => deleteKey(keytag));
108
65
  };
109
-
110
- /**
111
- * Converts a certificate string to PEM format.
112
- *
113
- * @param certificate - The certificate string.
114
- * @returns The PEM-formatted certificate.
115
- */
116
- export const convertCertToPem = (certificate: string): string =>
117
- `-----BEGIN CERTIFICATE-----\n${certificate}\n-----END CERTIFICATE-----`;
118
-
119
- /**
120
- * Parses the public key from a PEM-formatted certificate.
121
- *
122
- * @param pemCert - The PEM-formatted certificate.
123
- * @returns The public key object.
124
- * @throws Will throw an error if the public key is unsupported.
125
- */
126
- export const parsePublicKey = (
127
- pemCert: string
128
- ): RSAKey | KJUR.crypto.ECDSA | undefined => {
129
- const x509 = new X509();
130
- x509.readCertPEM(pemCert);
131
- const publicKey = x509.getPublicKey();
132
-
133
- if (publicKey instanceof RSAKey || publicKey instanceof KJUR.crypto.ECDSA) {
134
- return publicKey;
135
- }
136
-
137
- return undefined;
138
- };
139
-
140
- /**
141
- * Retrieves the signing JWK from the public key.
142
- *
143
- * @param publicKey - The public key object.
144
- * @returns The signing JWK.
145
- */
146
- export const getSigningJwk = (publicKey: RSAKey | KJUR.crypto.ECDSA): JWK => ({
147
- ...JWK.parse(KEYUTIL.getJWKFromKey(publicKey)),
148
- use: "sig",
149
- });
150
-
151
- /**
152
- * This function takes two {@link PublicKey} and evaluates and compares their thumbprints
153
- * @param key1 The first key
154
- * @param key2 The second key
155
- * @returns true if the keys' thumbprints are equal, false otherwise
156
- */
157
- export const compareKeysByThumbprint = async (
158
- key1: PublicKey,
159
- key2: PublicKey
160
- ) => {
161
- //Parallel for optimization
162
- const [thumbprint1, thumbprint2] = await Promise.all([
163
- thumbprint(key1),
164
- thumbprint(key2),
165
- ]);
166
- return thumbprint1 === thumbprint2;
167
- };
@@ -1,6 +1,7 @@
1
1
  import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
2
- import { ValidationFailed } from "./errors";
3
2
  import type { JWTDecodeResult } from "./jwk";
3
+ import { ValidationFailed } from "./errors";
4
+ import { LogLevel, Logger } from "./logging";
4
5
 
5
6
  /*
6
7
  * Decode a form_post.jwt and return the final JWT.
@@ -47,6 +48,10 @@ export const getJwtFromFormPost = async (
47
48
  }
48
49
  }
49
50
 
51
+ Logger.log(
52
+ LogLevel.ERROR,
53
+ `Unable to obtain JWT from form_post.jwt. Form data: ${formData}`
54
+ );
50
55
  throw new ValidationFailed({
51
56
  message: `Unable to obtain JWT from form_post.jwt. Form data: ${formData}`,
52
57
  });