@pagopa/io-react-native-wallet 1.7.0 → 2.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/README.md +47 -1
  2. package/lib/commonjs/client/generated/wallet-provider.js +49 -20
  3. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
  4. package/lib/commonjs/credential/index.js +5 -1
  5. package/lib/commonjs/credential/index.js.map +1 -1
  6. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
  7. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  8. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
  9. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  10. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
  11. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  12. package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
  13. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  14. package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
  15. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  16. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
  17. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  18. package/lib/commonjs/credential/issuance/README.md +23 -20
  19. package/lib/commonjs/credential/issuance/const.js +1 -1
  20. package/lib/commonjs/credential/issuance/const.js.map +1 -1
  21. package/lib/commonjs/credential/issuance/index.js +3 -3
  22. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  23. package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
  24. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  25. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
  26. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  27. package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
  28. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
  29. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
  30. package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  31. package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
  32. package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
  33. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
  34. package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  35. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
  36. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  37. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
  38. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  39. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
  40. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
  41. package/lib/commonjs/credential/presentation/README.md +74 -79
  42. package/lib/commonjs/credential/presentation/errors.js +42 -21
  43. package/lib/commonjs/credential/presentation/errors.js.map +1 -1
  44. package/lib/commonjs/credential/presentation/index.js +13 -13
  45. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  46. package/lib/commonjs/credential/presentation/types.js +53 -29
  47. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  48. package/lib/commonjs/credential/status/01-start-flow.js +2 -0
  49. package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
  50. package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
  51. package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
  52. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
  53. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  54. package/lib/commonjs/credential/status/README.md +67 -0
  55. package/lib/commonjs/credential/status/index.js +27 -0
  56. package/lib/commonjs/credential/status/index.js.map +1 -0
  57. package/lib/commonjs/credential/status/types.js +48 -0
  58. package/lib/commonjs/credential/status/types.js.map +1 -0
  59. package/lib/commonjs/credential/trustmark/README.md +62 -0
  60. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
  61. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
  62. package/lib/commonjs/credential/trustmark/index.js +13 -0
  63. package/lib/commonjs/credential/trustmark/index.js.map +1 -0
  64. package/lib/commonjs/index.js +5 -1
  65. package/lib/commonjs/index.js.map +1 -1
  66. package/lib/commonjs/pid/sd-jwt/types.js +18 -2
  67. package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
  68. package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
  69. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  70. package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
  71. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  72. package/lib/commonjs/sd-jwt/index.js +1 -7
  73. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  74. package/lib/commonjs/sd-jwt/types.js +5 -21
  75. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  76. package/lib/commonjs/{entity/trust → trust}/chain.js +49 -55
  77. package/lib/commonjs/trust/chain.js.map +1 -0
  78. package/lib/commonjs/trust/errors.js +110 -0
  79. package/lib/commonjs/trust/errors.js.map +1 -0
  80. package/lib/commonjs/trust/index.js +282 -0
  81. package/lib/commonjs/trust/index.js.map +1 -0
  82. package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
  83. package/lib/commonjs/trust/types.js.map +1 -0
  84. package/lib/commonjs/trust/utils.js +41 -0
  85. package/lib/commonjs/trust/utils.js.map +1 -0
  86. package/lib/commonjs/utils/crypto.js +5 -112
  87. package/lib/commonjs/utils/crypto.js.map +1 -1
  88. package/lib/commonjs/utils/decoder.js +2 -0
  89. package/lib/commonjs/utils/decoder.js.map +1 -1
  90. package/lib/commonjs/utils/error-codes.js +22 -2
  91. package/lib/commonjs/utils/error-codes.js.map +1 -1
  92. package/lib/commonjs/utils/errors.js +72 -4
  93. package/lib/commonjs/utils/errors.js.map +1 -1
  94. package/lib/commonjs/utils/logging.js +68 -0
  95. package/lib/commonjs/utils/logging.js.map +1 -0
  96. package/lib/commonjs/utils/misc.js +2 -0
  97. package/lib/commonjs/utils/misc.js.map +1 -1
  98. package/lib/commonjs/utils/par.js +17 -10
  99. package/lib/commonjs/utils/par.js.map +1 -1
  100. package/lib/commonjs/utils/string.js +1 -12
  101. package/lib/commonjs/utils/string.js.map +1 -1
  102. package/lib/commonjs/wallet-instance/index.js +14 -0
  103. package/lib/commonjs/wallet-instance/index.js.map +1 -1
  104. package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
  105. package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
  106. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  107. package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
  108. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  109. package/lib/module/client/generated/wallet-provider.js +40 -15
  110. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  111. package/lib/module/credential/index.js +3 -1
  112. package/lib/module/credential/index.js.map +1 -1
  113. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
  114. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
  115. package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
  116. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  117. package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
  118. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  119. package/lib/module/credential/issuance/05-authorize-access.js +17 -11
  120. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  121. package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
  122. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  123. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
  124. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  125. package/lib/module/credential/issuance/README.md +23 -20
  126. package/lib/module/credential/issuance/const.js +1 -1
  127. package/lib/module/credential/issuance/const.js.map +1 -1
  128. package/lib/module/credential/issuance/index.js +2 -2
  129. package/lib/module/credential/issuance/index.js.map +1 -1
  130. package/lib/module/credential/presentation/01-start-flow.js +14 -15
  131. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  132. package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
  133. package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  134. package/lib/module/credential/presentation/03-get-request-object.js +34 -7
  135. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
  136. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
  137. package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
  138. package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
  139. package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
  140. package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
  141. package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
  142. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
  143. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  144. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
  145. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  146. package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
  147. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  148. package/lib/module/credential/presentation/README.md +74 -79
  149. package/lib/module/credential/presentation/errors.js +30 -17
  150. package/lib/module/credential/presentation/errors.js.map +1 -1
  151. package/lib/module/credential/presentation/index.js +6 -6
  152. package/lib/module/credential/presentation/index.js.map +1 -1
  153. package/lib/module/credential/presentation/types.js +49 -27
  154. package/lib/module/credential/presentation/types.js.map +1 -1
  155. package/lib/module/credential/status/01-start-flow.js +2 -0
  156. package/lib/module/credential/status/01-start-flow.js.map +1 -0
  157. package/lib/module/credential/status/02-status-attestation.js +66 -0
  158. package/lib/module/credential/status/02-status-attestation.js.map +1 -0
  159. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
  160. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
  161. package/lib/module/credential/status/README.md +67 -0
  162. package/lib/module/credential/status/index.js +5 -0
  163. package/lib/module/credential/status/index.js.map +1 -0
  164. package/lib/module/credential/status/types.js +40 -0
  165. package/lib/module/credential/status/types.js.map +1 -0
  166. package/lib/module/credential/trustmark/README.md +62 -0
  167. package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
  168. package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
  169. package/lib/module/credential/trustmark/index.js +3 -0
  170. package/lib/module/credential/trustmark/index.js.map +1 -0
  171. package/lib/module/index.js +3 -1
  172. package/lib/module/index.js.map +1 -1
  173. package/lib/module/pid/sd-jwt/types.js +16 -1
  174. package/lib/module/pid/sd-jwt/types.js.map +1 -1
  175. package/lib/module/sd-jwt/__test__/index.test.js +22 -34
  176. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  177. package/lib/module/sd-jwt/__test__/types.test.js +11 -23
  178. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  179. package/lib/module/sd-jwt/index.js +1 -7
  180. package/lib/module/sd-jwt/index.js.map +1 -1
  181. package/lib/module/sd-jwt/types.js +4 -19
  182. package/lib/module/sd-jwt/types.js.map +1 -1
  183. package/lib/module/trust/chain.js +108 -0
  184. package/lib/module/trust/chain.js.map +1 -0
  185. package/lib/module/trust/errors.js +94 -0
  186. package/lib/module/trust/errors.js.map +1 -0
  187. package/lib/module/trust/index.js +263 -0
  188. package/lib/module/trust/index.js.map +1 -0
  189. package/lib/module/{entity/trust → trust}/types.js +25 -46
  190. package/lib/module/trust/types.js.map +1 -0
  191. package/lib/module/trust/utils.js +33 -0
  192. package/lib/module/trust/utils.js.map +1 -0
  193. package/lib/module/utils/crypto.js +4 -107
  194. package/lib/module/utils/crypto.js.map +1 -1
  195. package/lib/module/utils/decoder.js +3 -0
  196. package/lib/module/utils/decoder.js.map +1 -1
  197. package/lib/module/utils/error-codes.js +20 -1
  198. package/lib/module/utils/error-codes.js.map +1 -1
  199. package/lib/module/utils/errors.js +61 -4
  200. package/lib/module/utils/errors.js.map +1 -1
  201. package/lib/module/utils/logging.js +62 -0
  202. package/lib/module/utils/logging.js.map +1 -0
  203. package/lib/module/utils/misc.js +2 -0
  204. package/lib/module/utils/misc.js.map +1 -1
  205. package/lib/module/utils/par.js +17 -9
  206. package/lib/module/utils/par.js.map +1 -1
  207. package/lib/module/utils/string.js +0 -10
  208. package/lib/module/utils/string.js.map +1 -1
  209. package/lib/module/wallet-instance/index.js +13 -0
  210. package/lib/module/wallet-instance/index.js.map +1 -1
  211. package/lib/module/wallet-instance-attestation/README.md +8 -3
  212. package/lib/module/wallet-instance-attestation/index.js +2 -2
  213. package/lib/module/wallet-instance-attestation/index.js.map +1 -1
  214. package/lib/module/wallet-instance-attestation/issuing.js +16 -9
  215. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  216. package/lib/module/wallet-instance-attestation/types.js +14 -18
  217. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  218. package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
  219. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  220. package/lib/typescript/credential/index.d.ts +3 -1
  221. package/lib/typescript/credential/index.d.ts.map +1 -1
  222. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
  223. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
  224. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
  225. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
  226. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  227. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
  228. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  229. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
  230. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  231. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
  232. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  233. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
  234. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  235. package/lib/typescript/credential/issuance/const.d.ts +1 -1
  236. package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
  237. package/lib/typescript/credential/issuance/index.d.ts +3 -3
  238. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  239. package/lib/typescript/credential/issuance/types.d.ts +8 -3
  240. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  241. package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
  242. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
  243. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
  244. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
  245. package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
  246. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
  247. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
  248. package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
  249. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
  250. package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
  251. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
  252. package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
  253. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
  254. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  255. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
  256. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  257. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
  258. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
  259. package/lib/typescript/credential/presentation/errors.d.ts +25 -10
  260. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
  261. package/lib/typescript/credential/presentation/index.d.ts +7 -8
  262. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  263. package/lib/typescript/credential/presentation/types.d.ts +137 -307
  264. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  265. package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
  266. package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
  267. package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
  268. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
  269. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
  270. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
  271. package/lib/typescript/credential/status/index.d.ts +7 -0
  272. package/lib/typescript/credential/status/index.d.ts.map +1 -0
  273. package/lib/typescript/credential/status/types.d.ts +305 -0
  274. package/lib/typescript/credential/status/types.d.ts.map +1 -0
  275. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
  276. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
  277. package/lib/typescript/credential/trustmark/index.d.ts +4 -0
  278. package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
  279. package/lib/typescript/index.d.ts +3 -1
  280. package/lib/typescript/index.d.ts.map +1 -1
  281. package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
  282. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
  283. package/lib/typescript/sd-jwt/index.d.ts +30 -82
  284. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  285. package/lib/typescript/sd-jwt/types.d.ts +29 -134
  286. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  287. package/lib/typescript/{entity/trust → trust}/chain.d.ts +5 -10
  288. package/lib/typescript/trust/chain.d.ts.map +1 -0
  289. package/lib/typescript/trust/errors.d.ts +80 -0
  290. package/lib/typescript/trust/errors.d.ts.map +1 -0
  291. package/lib/typescript/{entity/trust → trust}/index.d.ts +211 -186
  292. package/lib/typescript/trust/index.d.ts.map +1 -0
  293. package/lib/typescript/{entity/trust → trust}/types.d.ts +1533 -1120
  294. package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
  295. package/lib/typescript/trust/utils.d.ts +12 -0
  296. package/lib/typescript/trust/utils.d.ts.map +1 -0
  297. package/lib/typescript/utils/crypto.d.ts +0 -32
  298. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  299. package/lib/typescript/utils/decoder.d.ts.map +1 -1
  300. package/lib/typescript/utils/error-codes.d.ts +20 -0
  301. package/lib/typescript/utils/error-codes.d.ts.map +1 -1
  302. package/lib/typescript/utils/errors.d.ts +55 -10
  303. package/lib/typescript/utils/errors.d.ts.map +1 -1
  304. package/lib/typescript/utils/logging.d.ts +35 -0
  305. package/lib/typescript/utils/logging.d.ts.map +1 -0
  306. package/lib/typescript/utils/misc.d.ts.map +1 -1
  307. package/lib/typescript/utils/par.d.ts +8 -1
  308. package/lib/typescript/utils/par.d.ts.map +1 -1
  309. package/lib/typescript/utils/string.d.ts +0 -7
  310. package/lib/typescript/utils/string.d.ts.map +1 -1
  311. package/lib/typescript/wallet-instance/index.d.ts +8 -0
  312. package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
  313. package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
  314. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
  315. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
  316. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  317. package/lib/typescript/wallet-instance-attestation/types.d.ts +78 -120
  318. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  319. package/package.json +8 -9
  320. package/src/client/generated/wallet-provider.ts +52 -17
  321. package/src/credential/index.ts +4 -1
  322. package/src/credential/issuance/01-start-flow.ts +1 -1
  323. package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
  324. package/src/credential/issuance/03-start-user-authorization.ts +48 -22
  325. package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
  326. package/src/credential/issuance/05-authorize-access.ts +29 -11
  327. package/src/credential/issuance/06-obtain-credential.ts +61 -36
  328. package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
  329. package/src/credential/issuance/README.md +23 -20
  330. package/src/credential/issuance/const.ts +1 -1
  331. package/src/credential/issuance/index.ts +6 -3
  332. package/src/credential/presentation/01-start-flow.ts +19 -22
  333. package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
  334. package/src/credential/presentation/03-get-request-object.ts +36 -8
  335. package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
  336. package/src/credential/presentation/05-verify-request-object.ts +115 -30
  337. package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
  338. package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
  339. package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
  340. package/src/credential/presentation/08-send-authorization-response.ts +178 -260
  341. package/src/credential/presentation/README.md +74 -79
  342. package/src/credential/presentation/errors.ts +38 -15
  343. package/src/credential/presentation/index.ts +18 -19
  344. package/src/credential/presentation/types.ts +67 -64
  345. package/src/credential/status/01-start-flow.ts +9 -0
  346. package/src/credential/status/02-status-attestation.ts +105 -0
  347. package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
  348. package/src/credential/status/README.md +67 -0
  349. package/src/credential/status/index.ts +22 -0
  350. package/src/credential/status/types.ts +43 -0
  351. package/src/credential/trustmark/README.md +62 -0
  352. package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
  353. package/src/credential/trustmark/index.ts +8 -0
  354. package/src/index.ts +4 -0
  355. package/src/pid/sd-jwt/types.ts +18 -1
  356. package/src/sd-jwt/__test__/index.test.ts +36 -55
  357. package/src/sd-jwt/__test__/types.test.ts +16 -29
  358. package/src/sd-jwt/index.ts +1 -5
  359. package/src/sd-jwt/types.ts +2 -19
  360. package/src/trust/chain.ts +151 -0
  361. package/src/trust/errors.ts +105 -0
  362. package/src/{entity/trust → trust}/index.ts +198 -23
  363. package/src/{entity/trust → trust}/types.ts +24 -37
  364. package/src/trust/utils.ts +35 -0
  365. package/src/utils/crypto.ts +4 -106
  366. package/src/utils/decoder.ts +6 -1
  367. package/src/utils/error-codes.ts +23 -0
  368. package/src/utils/errors.ts +119 -15
  369. package/src/utils/logging.ts +68 -0
  370. package/src/utils/misc.ts +5 -0
  371. package/src/utils/par.ts +19 -6
  372. package/src/utils/string.ts +0 -10
  373. package/src/wallet-instance/index.ts +30 -1
  374. package/src/wallet-instance-attestation/README.md +8 -3
  375. package/src/wallet-instance-attestation/index.ts +2 -2
  376. package/src/wallet-instance-attestation/issuing.ts +33 -12
  377. package/src/wallet-instance-attestation/types.ts +18 -22
  378. package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
  379. package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
  380. package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
  381. package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
  382. package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
  383. package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
  384. package/lib/commonjs/entity/trust/chain.js.map +0 -1
  385. package/lib/commonjs/entity/trust/index.js +0 -148
  386. package/lib/commonjs/entity/trust/index.js.map +0 -1
  387. package/lib/commonjs/entity/trust/types.js.map +0 -1
  388. package/lib/commonjs/mdoc/converters.js +0 -26
  389. package/lib/commonjs/mdoc/converters.js.map +0 -1
  390. package/lib/commonjs/mdoc/index.js +0 -68
  391. package/lib/commonjs/mdoc/index.js.map +0 -1
  392. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
  393. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  394. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
  395. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  396. package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
  397. package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
  398. package/lib/module/entity/openid-connect/issuer/index.js +0 -20
  399. package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
  400. package/lib/module/entity/openid-connect/issuer/types.js +0 -48
  401. package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
  402. package/lib/module/entity/trust/chain.js +0 -113
  403. package/lib/module/entity/trust/chain.js.map +0 -1
  404. package/lib/module/entity/trust/index.js +0 -131
  405. package/lib/module/entity/trust/index.js.map +0 -1
  406. package/lib/module/entity/trust/types.js.map +0 -1
  407. package/lib/module/mdoc/converters.js +0 -20
  408. package/lib/module/mdoc/converters.js.map +0 -1
  409. package/lib/module/mdoc/index.js +0 -60
  410. package/lib/module/mdoc/index.js.map +0 -1
  411. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
  412. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
  413. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
  414. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
  415. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
  416. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
  417. package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
  418. package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
  419. package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
  420. package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
  421. package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
  422. package/lib/typescript/entity/trust/index.d.ts.map +0 -1
  423. package/lib/typescript/mdoc/converters.d.ts +0 -8
  424. package/lib/typescript/mdoc/converters.d.ts.map +0 -1
  425. package/lib/typescript/mdoc/index.d.ts +0 -10
  426. package/lib/typescript/mdoc/index.d.ts.map +0 -1
  427. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
  428. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
  429. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
  430. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
  431. package/src/credential/issuance/02-get-issuer-config.ts +0 -67
  432. package/src/entity/openid-connect/issuer/index.ts +0 -27
  433. package/src/entity/openid-connect/issuer/types.ts +0 -76
  434. package/src/entity/trust/chain.ts +0 -154
  435. package/src/mdoc/converters.ts +0 -26
  436. package/src/mdoc/index.ts +0 -95
  437. package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
  438. package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -1,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,35 @@
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
+
8
+ export type ParsedToken = {
9
+ header: JWTDecodeResult["protectedHeader"];
10
+ payload: JWTDecodeResult["payload"];
11
+ };
12
+
13
+ // Verify a token signature
14
+ // The kid is extracted from the token header
15
+ export const verify = async (
16
+ token: string,
17
+ kid: string,
18
+ jwks: JWK[]
19
+ ): Promise<ParsedToken> => {
20
+ const jwk = jwks.find((k) => k.kid === kid);
21
+ if (!jwk) {
22
+ throw new Error(`Invalid kid: ${kid}, token: ${token}`);
23
+ }
24
+ const { protectedHeader: header, payload } = await verifyJwt(token, jwk);
25
+ return { header, payload };
26
+ };
27
+
28
+ /**
29
+ * Return type for this function is necessary to avoid an issue during the bob build process.
30
+ * It seems like typescript can't correctly infer the return type of the function.
31
+ */
32
+ export const decode = (token: string): ParsedToken => {
33
+ const { protectedHeader: header, payload } = decodeJwt(token);
34
+ return { header, payload };
35
+ };
@@ -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
  });
@@ -1,9 +1,21 @@
1
1
  export const IssuerResponseErrorCodes = {
2
2
  IssuerGenericError: "ERR_ISSUER_GENERIC_ERROR",
3
+ /**
4
+ * Error code thrown when a credential cannot be issued immediately because it follows the async flow.
5
+ */
6
+ CredentialIssuingNotSynchronous: "ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS",
3
7
  /**
4
8
  * Error code thrown when an error occurs while requesting a credential.
5
9
  */
6
10
  CredentialRequestFailed: "ERR_CREDENTIAL_REQUEST_FAILED",
11
+ /**
12
+ * Error code thrown when a credential status is invalid, either during issuance or when requesting a status attestation.
13
+ */
14
+ CredentialInvalidStatus: "ERR_CREDENTIAL_INVALID_STATUS",
15
+ /**
16
+ * Error code thrown when an error occurs while obtaining a status attestation for a credential.
17
+ */
18
+ StatusAttestationRequestFailed: "ERR_STATUS_ATTESTATION_REQUEST_FAILED",
7
19
  } as const;
8
20
 
9
21
  export const WalletProviderResponseErrorCodes = {
@@ -31,8 +43,19 @@ export const WalletProviderResponseErrorCodes = {
31
43
  WalletInstanceNotFound: "ERR_IO_WALLET_INSTANCE_NOT_FOUND",
32
44
  } as const;
33
45
 
46
+ export const RelyingPartyResponseErrorCodes = {
47
+ RelyingPartyGenericError: "ERR_RP_GENERIC_ERROR",
48
+ /**
49
+ * An error code thrown then the Relying Party rejects the Wallet's Authorization Response.
50
+ */
51
+ InvalidAuthorizationResponse: "ERR_RP_INVALID_AUTHORIZATION_RESPONSE",
52
+ } as const;
53
+
34
54
  export type IssuerResponseErrorCode =
35
55
  (typeof IssuerResponseErrorCodes)[keyof typeof IssuerResponseErrorCodes];
36
56
 
37
57
  export type WalletProviderResponseErrorCode =
38
58
  (typeof WalletProviderResponseErrorCodes)[keyof typeof WalletProviderResponseErrorCodes];
59
+
60
+ export type RelyingPartyResponseErrorCode =
61
+ (typeof RelyingPartyResponseErrorCodes)[keyof typeof RelyingPartyResponseErrorCodes];
@@ -1,12 +1,19 @@
1
1
  import type { ProblemDetail } from "../client/generated/wallet-provider";
2
+ import type { CredentialIssuerEntityConfiguration } from "../trust";
2
3
  import {
3
4
  IssuerResponseErrorCodes,
4
5
  WalletProviderResponseErrorCodes,
6
+ RelyingPartyResponseErrorCodes,
5
7
  type IssuerResponseErrorCode,
6
8
  type WalletProviderResponseErrorCode,
9
+ type RelyingPartyResponseErrorCode,
7
10
  } from "./error-codes";
8
11
 
9
- export { IssuerResponseErrorCodes, WalletProviderResponseErrorCodes };
12
+ export {
13
+ IssuerResponseErrorCodes,
14
+ WalletProviderResponseErrorCodes,
15
+ RelyingPartyResponseErrorCodes,
16
+ };
10
17
 
11
18
  // An error reason that supports both a string and a generic JSON object
12
19
  type GenericErrorReason = string | Record<string, unknown>;
@@ -109,8 +116,6 @@ export class UnexpectedStatusCodeError extends IoWalletError {
109
116
  /**
110
117
  * An error subclass thrown when an Issuer HTTP request fails.
111
118
  * The specific error can be found in the `code` property.
112
- *
113
- * The class is generic over the error code to narrow down the reason.
114
119
  */
115
120
  export class IssuerResponseError extends UnexpectedStatusCodeError {
116
121
  code: IssuerResponseErrorCode;
@@ -148,6 +153,117 @@ export class WalletProviderResponseError extends UnexpectedStatusCodeError {
148
153
  }
149
154
  }
150
155
 
156
+ /**
157
+ * An error subclass thrown when a Relying Party HTTP request fails.
158
+ * The specific error can be found in the `code` property.
159
+ */
160
+ export class RelyingPartyResponseError extends UnexpectedStatusCodeError {
161
+ code: RelyingPartyResponseErrorCode;
162
+
163
+ constructor(params: {
164
+ code?: RelyingPartyResponseErrorCode;
165
+ message: string;
166
+ reason: GenericErrorReason;
167
+ statusCode: number;
168
+ }) {
169
+ super(params);
170
+ this.code =
171
+ params.code ?? RelyingPartyResponseErrorCodes.RelyingPartyGenericError;
172
+ }
173
+ }
174
+
175
+ type LocalizedIssuanceError = {
176
+ [locale: string]: {
177
+ title: string;
178
+ description: string;
179
+ };
180
+ };
181
+
182
+ /**
183
+ * Function to extract the error message from the Entity Configuration's supported error codes.
184
+ * @param errorCode The error code to map to a meaningful message
185
+ * @param issuerConf The entity configuration for credentials
186
+ * @param credentialType The type of credential the error belongs to
187
+ * @returns A localized error {@link LocalizedIssuanceError} or undefined
188
+ * @throws {IoWalletError} When no credential config is found
189
+ */
190
+ export function extractErrorMessageFromIssuerConf(
191
+ errorCode: string,
192
+ {
193
+ issuerConf,
194
+ credentialType,
195
+ }: {
196
+ issuerConf: CredentialIssuerEntityConfiguration["payload"]["metadata"];
197
+ credentialType: string;
198
+ }
199
+ ): LocalizedIssuanceError | undefined {
200
+ const credentialConfiguration =
201
+ issuerConf.openid_credential_issuer.credential_configurations_supported[
202
+ credentialType
203
+ ];
204
+
205
+ if (!credentialConfiguration) {
206
+ throw new IoWalletError(
207
+ `No configuration found for ${credentialType} in the provided EC`
208
+ );
209
+ }
210
+
211
+ const { issuance_errors_supported } = credentialConfiguration;
212
+
213
+ if (!issuance_errors_supported?.[errorCode]) {
214
+ return undefined;
215
+ }
216
+
217
+ const localesList = issuance_errors_supported[errorCode]!.display;
218
+
219
+ return localesList.reduce(
220
+ (acc, { locale, ...rest }) => ({ ...acc, [locale]: rest }),
221
+ {} as LocalizedIssuanceError
222
+ );
223
+ }
224
+
225
+ /**
226
+ * Factory function to create a type guard for specific error classes.
227
+ *
228
+ * @param errorClass The error class to create the type guard for
229
+ * @returns A type guard that checks if the error is an instance of the given class and has the expected code
230
+ */
231
+ const makeErrorTypeGuard =
232
+ <T extends typeof UnexpectedStatusCodeError>(ErrorClass: T) =>
233
+ (error: unknown, code?: ExtractErrorCode<T>): error is InstanceType<T> =>
234
+ error instanceof ErrorClass && error.code === (code ?? error.code);
235
+
236
+ export const isIssuerResponseError = makeErrorTypeGuard(IssuerResponseError);
237
+ export const isWalletProviderResponseError = makeErrorTypeGuard(
238
+ WalletProviderResponseError
239
+ );
240
+ export const isRelyingPartyResponseError = makeErrorTypeGuard(
241
+ RelyingPartyResponseError
242
+ );
243
+
244
+ // Mapping type between error classes and their allowed codes
245
+ type ErrorCodeMap =
246
+ | {
247
+ type: typeof IssuerResponseError;
248
+ code: IssuerResponseErrorCode;
249
+ }
250
+ | {
251
+ type: typeof WalletProviderResponseError;
252
+ code: WalletProviderResponseErrorCode;
253
+ }
254
+ | {
255
+ type: typeof RelyingPartyResponseError;
256
+ code: RelyingPartyResponseErrorCode;
257
+ };
258
+
259
+ type ExtractErrorCode<T> = Extract<ErrorCodeMap, { type: T }>["code"];
260
+
261
+ type ErrorCase<T> = {
262
+ code: ExtractErrorCode<T>;
263
+ message: string;
264
+ reason?: GenericErrorReason;
265
+ };
266
+
151
267
  /**
152
268
  * Builder class used to create specialized errors from type {@link UnexpectedStatusCodeError} that handles multiple status codes.
153
269
  *
@@ -185,15 +301,3 @@ export class ResponseErrorBuilder<T extends typeof UnexpectedStatusCodeError> {
185
301
  return originalError;
186
302
  }
187
303
  }
188
-
189
- type ErrorCodeMap<T> = T extends typeof IssuerResponseError
190
- ? IssuerResponseErrorCode
191
- : T extends typeof WalletProviderResponseError
192
- ? WalletProviderResponseErrorCode
193
- : never;
194
-
195
- type ErrorCase<T> = {
196
- code: ErrorCodeMap<T>;
197
- message: string;
198
- reason?: GenericErrorReason;
199
- };
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Logger interface which can be provided to the Logger class as a custom implementation.
3
+ */
4
+ export interface LoggingContext {
5
+ logDebug: (msg: string) => void;
6
+ logInfo: (msg: string) => void;
7
+ logWarn: (msg: string) => void;
8
+ logError: (msg: string) => void;
9
+ }
10
+
11
+ /**
12
+ * Supported debug levels.
13
+ */
14
+ export enum LogLevel {
15
+ DEBUG,
16
+ INFO,
17
+ WARN,
18
+ ERROR,
19
+ }
20
+
21
+ /**
22
+ * Logger singleton class which provides a simple logging interface with an init function to set the logging context and
23
+ * a static log function to log messages based on the debug level.
24
+ * This can be used as follows:
25
+ * const logger = Logger.getInstance();
26
+ * logger.initLogging(yourLoggingContext);
27
+ * logger.log(LogLevel.DEBUG, "Debug message");
28
+ */
29
+ export class Logger {
30
+ private static instance: Logger | null = null;
31
+ private static loggingContext?: LoggingContext;
32
+
33
+ // Private constructor to prevent direct instantiation
34
+ private constructor() {}
35
+
36
+ // Public static method to get the Logger instance
37
+ public static getInstance(): Logger {
38
+ if (Logger.instance === null) {
39
+ Logger.instance = new Logger();
40
+ }
41
+ return Logger.instance;
42
+ }
43
+
44
+ // Method to initialize the logging context
45
+ public initLogging(loggingCtx: LoggingContext): void {
46
+ Logger.loggingContext = loggingCtx;
47
+ }
48
+
49
+ // Method to log based on the level which wraps the null check for the logging context
50
+ public static log(level: LogLevel, msg: string): void {
51
+ if (Logger.loggingContext) {
52
+ switch (level) {
53
+ case LogLevel.DEBUG:
54
+ Logger.loggingContext.logDebug(msg);
55
+ break;
56
+ case LogLevel.INFO:
57
+ Logger.loggingContext.logInfo(msg);
58
+ break;
59
+ case LogLevel.WARN:
60
+ Logger.loggingContext.logWarn(msg);
61
+ break;
62
+ case LogLevel.ERROR:
63
+ Logger.loggingContext.logError(msg);
64
+ break;
65
+ }
66
+ }
67
+ }
68
+ }
package/src/utils/misc.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IoWalletError, UnexpectedStatusCodeError } from "./errors";
2
2
  import { sha256 } from "js-sha256";
3
+ import { LogLevel, Logger } from "./logging";
3
4
 
4
5
  /**
5
6
  * Check if a response is in the expected status, otherwise throw an error
@@ -13,6 +14,10 @@ export const hasStatusOrThrow =
13
14
  async (res: Response): Promise<Response> => {
14
15
  if (res.status !== status) {
15
16
  const ErrorClass = customError ?? UnexpectedStatusCodeError;
17
+ Logger.log(
18
+ LogLevel.ERROR,
19
+ `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`
20
+ );
16
21
  throw new ErrorClass({
17
22
  message: `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`,
18
23
  statusCode: res.status,