@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,30 +1,58 @@
1
- import { hasStatusOrThrow, type Out } from "../../utils/misc";
2
- import type { StartFlow } from "./01-start-flow";
1
+ import { RelyingPartyResponseError } from "../../utils/errors";
2
+ import { hasStatusOrThrow } from "../../utils/misc";
3
+ import { RequestObjectWalletCapabilities } from "./types";
3
4
 
4
5
  export type GetRequestObject = (
5
- requestUri: Out<StartFlow>["requestUri"],
6
+ requestUri: string,
6
7
  context?: {
7
8
  appFetch?: GlobalFetch["fetch"];
9
+ walletCapabilities?: RequestObjectWalletCapabilities;
8
10
  }
9
11
  ) => Promise<{ requestObjectEncodedJwt: string }>;
10
12
 
11
13
  /**
12
- * Obtain the Request Object for RP authentication
14
+ * Obtain the Request Object for RP authentication. Both the GET and POST `request_uri_method` are supported.
13
15
  * @see https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html
14
16
  *
15
- * @param requestUri The request uri of the Relying Party
17
+ * @param requestUri The url for the Relying Party to connect with
18
+ * @param rpConf The Relying Party's configuration * @param context.walletInstanceAttestation The Wallet Instance Attestation token
19
+ * @param context.walletCapabilities (optional) An object containing the wallet technical capabilities that will be sent with a POST request
16
20
  * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
17
21
  * @returns The Request Object that describes the presentation
18
22
  */
19
23
  export const getRequestObject: GetRequestObject = async (
20
24
  requestUri,
21
- context = {}
25
+ { appFetch = fetch, walletCapabilities } = {}
22
26
  ) => {
23
- const { appFetch = fetch } = context;
27
+ if (walletCapabilities) {
28
+ // Validate external input
29
+ const { wallet_metadata, wallet_nonce } =
30
+ RequestObjectWalletCapabilities.parse(walletCapabilities);
31
+
32
+ const formUrlEncodedBody = new URLSearchParams({
33
+ wallet_metadata: JSON.stringify(wallet_metadata),
34
+ ...(wallet_nonce && { wallet_nonce }),
35
+ });
36
+
37
+ const requestObjectEncodedJwt = await appFetch(requestUri, {
38
+ method: "POST",
39
+ headers: {
40
+ "Content-Type": "application/x-www-form-urlencoded",
41
+ },
42
+ body: formUrlEncodedBody.toString(),
43
+ })
44
+ .then(hasStatusOrThrow(200, RelyingPartyResponseError))
45
+ .then((res) => res.text());
46
+
47
+ return {
48
+ requestObjectEncodedJwt,
49
+ };
50
+ }
51
+
24
52
  const requestObjectEncodedJwt = await appFetch(requestUri, {
25
53
  method: "GET",
26
54
  })
27
- .then(hasStatusOrThrow(200))
55
+ .then(hasStatusOrThrow(200, RelyingPartyResponseError))
28
56
  .then((res) => res.text());
29
57
 
30
58
  return {
@@ -1,14 +1,5 @@
1
- import { JWKS, JWK } from "../../utils/jwk";
2
- import { hasStatusOrThrow } from "../../utils/misc";
3
- import { RelyingPartyEntityConfiguration } from "../../entity/trust/types";
4
- import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
5
- import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
6
- import { RequestObject } from "./types";
7
- import {
8
- convertCertToPem,
9
- parsePublicKey,
10
- getSigningJwk,
11
- } from "../../utils/crypto";
1
+ import { JWK } from "../../utils/jwk";
2
+ import { RelyingPartyEntityConfiguration } from "../../trust/types";
12
3
 
13
4
  /**
14
5
  * Defines the signature for a function that retrieves JSON Web Key Sets (JWKS) from a client.
@@ -17,141 +8,8 @@ import {
17
8
  * @param args - The arguments passed to the function.
18
9
  * @returns A promise resolving to an object containing an array of JWKs.
19
10
  */
20
- export type FetchJwks<T extends Array<unknown> = []> = (...args: T) => Promise<{
11
+ export type FetchJwks<T extends Array<unknown> = []> = (...args: T) => {
21
12
  keys: JWK[];
22
- }>;
23
-
24
- /**
25
- * Fetches and parses JWKS from a given URI.
26
- *
27
- * @param jwksUri - The JWKS URI.
28
- * @param fetchFn - The fetch function to use.
29
- * @returns An array of JWKs.
30
- */
31
- const fetchJwksFromUri = async (
32
- jwksUri: string,
33
- appFetch: GlobalFetch["fetch"]
34
- ): Promise<JWK[]> => {
35
- const jwks = await appFetch(jwksUri, {
36
- method: "GET",
37
- })
38
- .then(hasStatusOrThrow(200))
39
- .then((raw) => raw.json())
40
- .then((json) => (json.jwks ? JWKS.parse(json.jwks) : JWKS.parse(json)));
41
- return jwks.keys;
42
- };
43
-
44
- /**
45
- * Retrieves JWKS when the client ID scheme includes x509 SAN DNS.
46
- *
47
- * @param decodedJwt - The decoded JWT.
48
- * @param fetchFn - The fetch function to use.
49
- * @returns An array of JWKs.
50
- * @throws Will throw an error if no suitable keys are found.
51
- */
52
- const getJwksFromX509Cert = async (certChain: string[]): Promise<JWK[]> => {
53
- if (!Array.isArray(certChain) || certChain.length === 0 || !certChain[0]) {
54
- throw new NoSuitableKeysFoundInEntityConfiguration(
55
- "No RP encrypt key found!"
56
- );
57
- }
58
-
59
- const pemCert = convertCertToPem(certChain[0]);
60
- const publicKey = parsePublicKey(pemCert);
61
- if (!publicKey) {
62
- throw new NoSuitableKeysFoundInEntityConfiguration(
63
- "Unsupported public key type."
64
- );
65
- }
66
- const signingJwk = getSigningJwk(publicKey);
67
-
68
- return [signingJwk];
69
- };
70
-
71
- /**
72
- * Constructs the well-known JWKS URL based on the issuer claim.
73
- *
74
- * @param issuer - The issuer URL.
75
- * @returns The well-known JWKS URL.
76
- */
77
- const constructWellKnownJwksUrl = (issuer: string): string => {
78
- const issuerUrl = new URL(issuer);
79
- return new URL(
80
- `/.well-known/jar-issuer${issuerUrl.pathname}`,
81
- `${issuerUrl.protocol}//${issuerUrl.host}`
82
- ).toString();
83
- };
84
-
85
- /**
86
- * Fetches the JSON Web Key Set (JWKS) based on the provided Request Object encoded as a JWT.
87
- * The retrieval process follows these steps in order:
88
- *
89
- * 1. **Direct JWK Retrieval**: If the JWT's protected header contains a `jwk` attribute, it uses this key directly.
90
- * 2. **X.509 Certificate Retrieval**: If the protected header includes an `x5c` attribute, it extracts the JWKs from the provided X.509 certificate chain.
91
- * 3. **Issuer's Well-Known Endpoint**: If neither `jwk` nor `x5c` are present, it constructs the JWKS URL using the issuer (`iss`) claim and fetches the keys from the issuer's well-known JWKS endpoint.
92
- *
93
- * The JWKS URL is constructed in the format `{issUrl.base}/.well-known/jar-issuer${issUrl.path}`,
94
- * as detailed in the SD-JWT VC issuer metadata specification.
95
- *
96
- * @param requestObjectEncodedJwt - The Request Object encoded as a JWT.
97
- * @param options - Optional parameters for fetching the JWKS.
98
- * @param options.context - Optional context providing a custom fetch implementation.
99
- * @param options.context.appFetch - A custom fetch function to replace the global `fetch` if provided.
100
- * @returns A promise that resolves to an object containing an array of JSON Web Keys (JWKs).
101
- * @throws {NoSuitableKeysFoundInEntityConfiguration} Throws an error if JWKS retrieval or key extraction fails.
102
- */
103
- export const fetchJwksFromRequestObject: FetchJwks<
104
- [string, { context?: { appFetch?: GlobalFetch["fetch"] } }?]
105
- > = async (requestObjectEncodedJwt, { context = {} } = {}) => {
106
- const { appFetch = fetch } = context;
107
- const requestObjectJwt = decodeJwt(requestObjectEncodedJwt);
108
- const jwks: JWK[] = [];
109
-
110
- // 1. check if request object jwt contains the 'jwk' attribute
111
- if (requestObjectJwt.protectedHeader?.jwk) {
112
- const keys = [JWK.parse(requestObjectJwt.protectedHeader.jwk)];
113
- jwks.push(...keys);
114
- }
115
-
116
- // 2. check if request object jwt contains the 'x5c' attribute
117
- if (requestObjectJwt.protectedHeader.x5c) {
118
- const keys = await getJwksFromX509Cert(
119
- requestObjectJwt.protectedHeader.x5c
120
- );
121
- jwks.push(...keys);
122
- }
123
-
124
- // 3. check if client_metadata contains the 'jwks' or 'jwks_uri' attribute
125
- const requestObject = RequestObject.parse(requestObjectJwt.payload);
126
- const { client_metadata } = requestObject;
127
-
128
- if (client_metadata?.jwks_uri) {
129
- const fetchedJwks = await fetchJwksFromUri(
130
- new URL(client_metadata.jwks_uri).toString(),
131
- appFetch
132
- );
133
- jwks.push(...fetchedJwks);
134
- }
135
-
136
- if (client_metadata?.jwks) {
137
- jwks.push(...client_metadata.jwks.keys);
138
- }
139
-
140
- // 3. According to Potential profile, retrieve from RP endpoint using iss claim
141
- const issuer = requestObjectJwt.payload?.iss;
142
- if (jwks.length === 0 && typeof issuer === "string") {
143
- const wellKnownJwksUrl = constructWellKnownJwksUrl(issuer);
144
- const jwksKeys = await fetchJwksFromUri(wellKnownJwksUrl, appFetch);
145
- jwks.push(...jwksKeys);
146
- }
147
-
148
- if (jwks.length === 0) {
149
- throw new NoSuitableKeysFoundInEntityConfiguration(
150
- "Request Object signature verification"
151
- );
152
- }
153
-
154
- return { keys: jwks };
155
13
  };
156
14
 
157
15
  /**
@@ -161,10 +19,10 @@ export const fetchJwksFromRequestObject: FetchJwks<
161
19
  * @returns An object containing an array of JWKs.
162
20
  * @throws Will throw an error if the configuration is invalid or if JWKS is not found.
163
21
  */
164
- export const fetchJwksFromConfig: FetchJwks<
22
+ export const getJwksFromConfig: FetchJwks<
165
23
  [RelyingPartyEntityConfiguration["payload"]["metadata"]]
166
- > = async (rpConfig) => {
167
- const jwks = rpConfig.wallet_relying_party.jwks;
24
+ > = (rpConfig) => {
25
+ const jwks = rpConfig.openid_credential_verifier.jwks;
168
26
 
169
27
  if (!jwks || !Array.isArray(jwks.keys)) {
170
28
  throw new Error("JWKS not found in Relying Party configuration.");
@@ -1,36 +1,121 @@
1
- import { UnverifiedEntityError } from "./errors";
2
-
3
1
  import { decode as decodeJwt, verify } from "@pagopa/io-react-native-jwt";
2
+ import type { RelyingPartyEntityConfiguration } from "../../trust";
3
+ import { InvalidRequestObjectError } from "./errors";
4
4
  import { RequestObject } from "./types";
5
- import type { FetchJwks } from "./04-retrieve-rp-jwks";
6
- import { type Out } from "../../utils/misc";
5
+ import { getJwksFromConfig } from "./04-retrieve-rp-jwks";
7
6
 
8
- export type VerifyRequestObjectSignature = (
7
+ export type VerifyRequestObject = (
9
8
  requestObjectEncodedJwt: string,
10
- jwkKeys?: Out<FetchJwks>["keys"]
9
+ context: {
10
+ clientId: string;
11
+ rpConf: RelyingPartyEntityConfiguration["payload"]["metadata"];
12
+ rpSubject: string;
13
+ state?: string;
14
+ }
11
15
  ) => Promise<{ requestObject: RequestObject }>;
12
16
 
13
- export const verifyRequestObjectSignature: VerifyRequestObjectSignature =
14
- async (requestObjectEncodedJwt, jwkKeys) => {
15
- const requestObjectJwt = decodeJwt(requestObjectEncodedJwt);
16
-
17
- // verify token signature to ensure the request object is authentic
18
- const pubKey =
19
- jwkKeys?.find(
20
- ({ kid }) => kid === requestObjectJwt.protectedHeader.kid
21
- ) || jwkKeys?.find(({ use }) => use === "sig");
22
-
23
- if (!pubKey) {
24
- throw new UnverifiedEntityError("Request Object signature verification!");
25
- }
26
- await verify(requestObjectEncodedJwt, pubKey);
27
-
28
- const requestObject = RequestObject.parse(requestObjectJwt.payload);
29
- // Check if exp exists and is expired
30
- // exp is typically in seconds since epoch, Get current time in seconds
31
- if (requestObject.exp && requestObject.exp <= Date.now() / 1000) {
32
- throw new UnverifiedEntityError("Request Object is expired!");
33
- }
34
-
35
- return { requestObject };
36
- };
17
+ /**
18
+ * Function to verify the Request Object's validity, from the signature to the required properties.
19
+ * @param requestObjectEncodedJwt The Request Object in JWT format
20
+ * @param context.clientId The client ID to verify
21
+ * @param context.rpConf The Entity Configuration of the Relying Party
22
+ * @param context.state Optional state
23
+ * @returns The verified Request Object
24
+ * @throws {InvalidRequestObjectError} if the Request Object cannot be validated
25
+ */
26
+ export const verifyRequestObject: VerifyRequestObject = async (
27
+ requestObjectEncodedJwt,
28
+ { clientId, rpConf, rpSubject, state }
29
+ ) => {
30
+ const requestObjectJwt = decodeJwt(requestObjectEncodedJwt);
31
+
32
+ const pubKey = getSigPublicKey(rpConf, requestObjectJwt.protectedHeader.kid);
33
+
34
+ try {
35
+ // Standard claims are verified within `verify`
36
+ await verify(requestObjectEncodedJwt, pubKey, { issuer: clientId });
37
+ } catch (_) {
38
+ throw new InvalidRequestObjectError(
39
+ "The Request Object signature verification failed"
40
+ );
41
+ }
42
+
43
+ const requestObject = validateRequestObjectShape(requestObjectJwt.payload);
44
+
45
+ const isClientIdMatch =
46
+ clientId === requestObject.client_id && clientId === rpSubject;
47
+
48
+ if (!isClientIdMatch) {
49
+ throw new InvalidRequestObjectError(
50
+ "Client ID does not match Request Object or Entity Configuration"
51
+ );
52
+ }
53
+
54
+ const isStateMatch =
55
+ state && requestObject.state ? state === requestObject.state : true;
56
+
57
+ if (!isStateMatch) {
58
+ throw new InvalidRequestObjectError(
59
+ "The provided state does not match the Request Object's"
60
+ );
61
+ }
62
+
63
+ return { requestObject };
64
+ };
65
+
66
+ /**
67
+ * Validate the shape of the Request Object to ensure all required properties are present and are of the expected type.
68
+ *
69
+ * @param payload The Request Object to validate
70
+ * @returns A valid Request Object
71
+ * @throws {InvalidRequestObjectError} when the Request Object cannot be parsed
72
+ */
73
+ const validateRequestObjectShape = (payload: unknown): RequestObject => {
74
+ const requestObjectParse = RequestObject.safeParse(payload);
75
+
76
+ if (requestObjectParse.success) {
77
+ return requestObjectParse.data;
78
+ }
79
+
80
+ throw new InvalidRequestObjectError(
81
+ "The Request Object cannot be parsed successfully",
82
+ formatFlattenedZodErrors(requestObjectParse.error.flatten())
83
+ );
84
+ };
85
+
86
+ /**
87
+ * Get the public key to verify the Request Object's signature from the Relying Party's EC.
88
+ *
89
+ * @param rpConf The Relying Party's EC
90
+ * @param kid The identifier of the key to find
91
+ * @returns The corresponding public key to verify the signature
92
+ * @throws {InvalidRequestObjectError} when the key cannot be found
93
+ */
94
+ const getSigPublicKey = (
95
+ rpConf: RelyingPartyEntityConfiguration["payload"]["metadata"],
96
+ kid: string | undefined
97
+ ) => {
98
+ try {
99
+ const { keys } = getJwksFromConfig(rpConf);
100
+
101
+ const pubKey = keys.find((k) => k.kid === kid);
102
+
103
+ if (!pubKey) throw new Error();
104
+
105
+ return pubKey;
106
+ } catch (_) {
107
+ throw new InvalidRequestObjectError(
108
+ `The public key for signature verification (${kid}) cannot be found in the Entity Configuration`
109
+ );
110
+ }
111
+ };
112
+
113
+ /**
114
+ * Utility to format flattened Zod errors into a simplified string `key1: key1_error, key2: key2_error`
115
+ */
116
+ const formatFlattenedZodErrors = (
117
+ errors: Zod.typeToFlattenedError<RequestObject>
118
+ ): string =>
119
+ Object.entries(errors.fieldErrors)
120
+ .map(([key, error]) => `${key}: ${error[0]}`)
121
+ .join(", ");
@@ -1,12 +1,8 @@
1
1
  import { PresentationDefinition, RequestObject } from "./types";
2
- import { RelyingPartyEntityConfiguration } from "../../entity/trust/types";
3
- import { hasStatusOrThrow } from "../../utils/misc";
2
+ import { RelyingPartyEntityConfiguration } from "../../trust/types";
4
3
 
5
4
  export type FetchPresentationDefinition = (
6
5
  requestObject: RequestObject,
7
- context?: {
8
- appFetch?: GlobalFetch["fetch"];
9
- },
10
6
  rpConf?: RelyingPartyEntityConfiguration["payload"]["metadata"]
11
7
  ) => Promise<{
12
8
  presentationDefinition: PresentationDefinition;
@@ -17,21 +13,17 @@ export type FetchPresentationDefinition = (
17
13
  *
18
14
  * The method attempts the following strategies in order:
19
15
  * 1. Checks if `presentation_definition` is directly available in the request object.
20
- * 2. Fetches the `presentation_definition` from the URI provided in the relying party configuration.
21
- * 3. Uses a pre-configured `presentation_definition` from the relying party configuration if the `scope` is present in the request object.
16
+ * 2. Uses a pre-configured `presentation_definition` from the relying party configuration if the `scope` is present in the request object.
22
17
  *
23
- * If none of the above conditions are met, the function throws an error indicating the definition could not be found.
18
+ * If none of the above conditions are met, the function throws an error indicating the definition could not be found. Note that `presentation_definition_uri` is not supported in 0.9.x.
24
19
  *
25
20
  * @param {RequestObject} requestObject - The request object containing the presentation definition or references to it.
26
21
  * @param {RelyingPartyEntityConfiguration["payload"]["metadata"]} [rpConf] - Optional relying party configuration.
27
- * @param {Object} [context] - Optional context for providing a custom fetch implementation.
28
- * @param {GlobalFetch["fetch"]} [context.appFetch] - Custom fetch function, defaults to global `fetch`.
29
22
  * @returns {Promise<{ presentationDefinition: PresentationDefinition }>} - Resolves with the presentation definition.
30
23
  * @throws {Error} - Throws if the presentation definition cannot be found or fetched.
31
24
  */
32
25
  export const fetchPresentDefinition: FetchPresentationDefinition = async (
33
26
  requestObject,
34
- { appFetch = fetch } = {},
35
27
  rpConf
36
28
  ) => {
37
29
  // Check if `presentation_definition` is directly available in the request object
@@ -41,36 +33,14 @@ export const fetchPresentDefinition: FetchPresentationDefinition = async (
41
33
  };
42
34
  }
43
35
 
44
- // Check if `presentation_definition_uri` is provided in the relying party configuration
45
- if (rpConf?.wallet_relying_party?.presentation_definition_uri) {
46
- try {
47
- // Fetch the presentation definition from the provided URI
48
- const presentationDefinition = await appFetch(
49
- rpConf?.wallet_relying_party.presentation_definition_uri,
50
- {
51
- method: "GET",
52
- }
53
- )
54
- .then(hasStatusOrThrow(200))
55
- .then((raw) => raw.json())
56
- .then((json) => PresentationDefinition.parse(json));
57
-
58
- return {
59
- presentationDefinition,
60
- };
61
- } catch (error) {
62
- throw new Error(`Failed to fetch presentation definition: ${error}`);
63
- }
64
- }
65
-
66
36
  // Check if `scope` is present in the request object and a pre-configured presentation definition exists
67
37
  if (
68
38
  requestObject.scope &&
69
- rpConf?.wallet_relying_party?.presentation_definition
39
+ rpConf?.openid_credential_verifier?.presentation_definition
70
40
  ) {
71
41
  return {
72
42
  presentationDefinition:
73
- rpConf.wallet_relying_party.presentation_definition,
43
+ rpConf.openid_credential_verifier.presentation_definition,
74
44
  };
75
45
  }
76
46