@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
@@ -0,0 +1,94 @@
1
+ import { IoWalletError, serializeAttrs } from "../utils/errors"; // Ensure this path is correct
2
+
3
+ /**
4
+ * Base class for all federation-specific errors.
5
+ */
6
+ export class FederationError extends IoWalletError {
7
+ constructor(message, details) {
8
+ super(details ? serializeAttrs({
9
+ message,
10
+ ...details
11
+ }) : message);
12
+ this.name = this.constructor.name;
13
+ }
14
+ }
15
+
16
+ /**
17
+ * Error thrown when a trust chain is unexpectedly empty.
18
+ */
19
+ export class TrustChainEmptyError extends FederationError {
20
+ code = "ERR_FED_TRUST_CHAIN_EMPTY";
21
+ constructor() {
22
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Trust chain cannot be empty.";
23
+ super(message, undefined);
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Error thrown when a token is unexpectedly missing from a trust chain during processing.
29
+ */
30
+ export class TrustChainTokenMissingError extends FederationError {
31
+ code = "ERR_FED_TRUST_CHAIN_TOKEN_MISSING";
32
+ constructor(message, details) {
33
+ super(message, details);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Error thrown when renewing a trust chain fails.
39
+ * This class itself might be used or could be considered a more general renewal error.
40
+ */
41
+ export class TrustChainRenewalError extends FederationError {
42
+ code = "ERR_FED_TRUST_CHAIN_RENEWAL_FAILED";
43
+ constructor(message, details) {
44
+ super(message, details);
45
+ }
46
+ }
47
+ export class FederationListParseError extends FederationError {
48
+ code = "ERR_FED_FEDERATION_LIST_PARSE_FAILED";
49
+ constructor(message, details) {
50
+ super(message, details);
51
+ }
52
+ }
53
+
54
+ /**
55
+ * General error thrown during the trust chain building process.
56
+ */
57
+ export class BuildTrustChainError extends FederationError {
58
+ code = "ERR_FED_BUILD_TRUST_CHAIN_FAILED";
59
+ constructor(message, details) {
60
+ super(message, details);
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Error thrown when the Trust Anchor's key is missing a 'kid'.
66
+ */
67
+ export class TrustAnchorKidMissingError extends FederationError {
68
+ code = "ERR_FED_TRUST_ANCHOR_KID_MISSING";
69
+ constructor() {
70
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Missing 'kid' in provided Trust Anchor key.";
71
+ super(message, undefined);
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Error thrown if the Relying Party is not found in the Trust Anchor's federation list.
77
+ */
78
+ export class RelyingPartyNotAuthorizedError extends FederationError {
79
+ code = "ERR_FED_RELYING_PARTY_NOT_AUTHORIZED";
80
+ constructor(message, details) {
81
+ super(message, details);
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Error thrown when a 'federation_fetch_endpoint' is missing in an entity's configuration.
87
+ */
88
+ export class MissingFederationFetchEndpointError extends FederationError {
89
+ code = "ERR_FED_MISSING_FEDERATION_FETCH_ENDPOINT";
90
+ constructor(message, details) {
91
+ super(message, details);
92
+ }
93
+ }
94
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IoWalletError","serializeAttrs","FederationError","constructor","message","details","name","TrustChainEmptyError","code","arguments","length","undefined","TrustChainTokenMissingError","TrustChainRenewalError","FederationListParseError","BuildTrustChainError","TrustAnchorKidMissingError","RelyingPartyNotAuthorizedError","MissingFederationFetchEndpointError"],"sourceRoot":"../../../src","sources":["trust/errors.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,cAAc,QAAQ,iBAAiB,CAAC,CAAC;;AAEjE;AACA;AACA;AACA,OAAO,MAAMC,eAAe,SAASF,aAAa,CAAC;EACjDG,WAAWA,CAACC,OAAe,EAAEC,OAAiC,EAAE;IAC9D,KAAK,CAACA,OAAO,GAAGJ,cAAc,CAAC;MAAEG,OAAO;MAAE,GAAGC;IAAQ,CAAC,CAAC,GAAGD,OAAO,CAAC;IAClE,IAAI,CAACE,IAAI,GAAG,IAAI,CAACH,WAAW,CAACG,IAAI;EACnC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,SAASL,eAAe,CAAC;EACxDM,IAAI,GAAG,2BAA2B;EAClCL,WAAWA,CAAA,EAA2C;IAAA,IAA1CC,OAAO,GAAAK,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,8BAA8B;IAClD,KAAK,CAACL,OAAO,EAAEO,SAAS,CAAC;EAC3B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,SAASV,eAAe,CAAC;EAC/DM,IAAI,GAAG,mCAAmC;EA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TC,OAAe,EACfC,OAA8D,EAC9D;IACA,KAAK,CAACD,OAAO,EAAEC,OAAO,CAAC;EACzB;AACF"}
@@ -0,0 +1,263 @@
1
+ import { decode, verify } from "./utils";
2
+ import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
3
+ import { CredentialIssuerEntityConfiguration, EntityConfiguration, EntityStatement, FederationListResponse, RelyingPartyEntityConfiguration, TrustAnchorEntityConfiguration, WalletProviderEntityConfiguration } from "./types";
4
+ import { renewTrustChain, validateTrustChain } from "./chain";
5
+ import { hasStatusOrThrow } from "../utils/misc";
6
+ import { BuildTrustChainError, FederationListParseError, MissingFederationFetchEndpointError, RelyingPartyNotAuthorizedError, TrustAnchorKidMissingError } from "./errors";
7
+ /**
8
+ * Verify a given trust chain is actually valid.
9
+ * It can handle fast chain renewal, which means we try to fetch a fresh version of each statement.
10
+ *
11
+ * @param trustAnchorEntity The entity configuration of the known trust anchor
12
+ * @param chain The chain of statements to be validated
13
+ * @param renewOnFail Whether to renew the provided chain if the validation fails at first. Default: true
14
+ * @param appFetch Fetch api implementation. Default: the built-in implementation
15
+ * @returns The result of the chain validation
16
+ * @throws {FederationError} If the chain is not valid
17
+ */
18
+ export async function verifyTrustChain(trustAnchorEntity, chain) {
19
+ let {
20
+ appFetch = fetch,
21
+ renewOnFail = true
22
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
23
+ try {
24
+ return validateTrustChain(trustAnchorEntity, chain);
25
+ } catch (error) {
26
+ if (renewOnFail) {
27
+ const renewedChain = await renewTrustChain(chain, appFetch);
28
+ return validateTrustChain(trustAnchorEntity, renewedChain);
29
+ } else {
30
+ throw error;
31
+ }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Fetch the signed entity configuration token for an entity
37
+ *
38
+ * @param entityBaseUrl The url of the entity to fetch
39
+ * @param appFetch (optional) fetch api implementation
40
+ * @returns The signed Entity Configuration token
41
+ */
42
+ export async function getSignedEntityConfiguration(entityBaseUrl) {
43
+ let {
44
+ appFetch = fetch
45
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
46
+ const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-federation`;
47
+ return await appFetch(wellKnownUrl, {
48
+ method: "GET"
49
+ }).then(hasStatusOrThrow(200)).then(res => res.text());
50
+ }
51
+
52
+ /**
53
+ * Fetch and parse the entity configuration document for a given federation entity.
54
+ * This is an inner method to serve public interfaces.
55
+ *
56
+ * To add another entity configuration type (example: Foo entity type):
57
+ * - create its zod schema and type by inherit from the base type (example: FooEntityConfiguration = BaseEntityConfiguration.and(...))
58
+ * - add such type to EntityConfiguration union
59
+ * - add an overload to this function
60
+ * - create a public function which use such type (example: getFooEntityConfiguration = (url, options) => Promise<FooEntityConfiguration>)
61
+ *
62
+ * @param entityBaseUrl The base url of the entity.
63
+ * @param schema The expected schema of the entity configuration, according to the kind of entity we are fetching from.
64
+ * @param options An optional object with additional options.
65
+ * @param options.appFetch An optional instance of the http client to be used.
66
+ * @returns The parsed entity configuration object
67
+ * @throws {IoWalletError} If the http request fails
68
+ * @throws Parse error if the document is not in the expected shape.
69
+ */
70
+
71
+ async function fetchAndParseEntityConfiguration(entityBaseUrl, schema) {
72
+ let {
73
+ appFetch = fetch
74
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
75
+ const responseText = await getSignedEntityConfiguration(entityBaseUrl, {
76
+ appFetch
77
+ });
78
+ const responseJwt = decodeJwt(responseText);
79
+ return schema.parse({
80
+ header: responseJwt.protectedHeader,
81
+ payload: responseJwt.payload
82
+ });
83
+ }
84
+ export const getWalletProviderEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, WalletProviderEntityConfiguration, options);
85
+ export const getCredentialIssuerEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, CredentialIssuerEntityConfiguration, options);
86
+ export const getTrustAnchorEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, TrustAnchorEntityConfiguration, options);
87
+ export const getRelyingPartyEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, RelyingPartyEntityConfiguration, options);
88
+ export const getEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, EntityConfiguration, options);
89
+
90
+ /**
91
+ * Fetch and parse the entity statement document for a given federation entity.
92
+ *
93
+ * @param accreditationBodyBaseUrl The base url of the accreditation body which holds and signs the required entity statement
94
+ * @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
95
+ * @param appFetch An optional instance of the http client to be used.
96
+ * @returns The parsed entity configuration object
97
+ * @throws {IoWalletError} If the http request fails
98
+ */
99
+ export async function getEntityStatement(accreditationBodyBaseUrl, subordinatedEntityBaseUrl) {
100
+ let {
101
+ appFetch = fetch
102
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
103
+ const responseText = await getSignedEntityStatement(accreditationBodyBaseUrl, subordinatedEntityBaseUrl, {
104
+ appFetch
105
+ });
106
+ const responseJwt = decodeJwt(responseText);
107
+ return EntityStatement.parse({
108
+ header: responseJwt.protectedHeader,
109
+ payload: responseJwt.payload
110
+ });
111
+ }
112
+
113
+ /**
114
+ * Fetch the entity statement document for a given federation entity.
115
+ *
116
+ * @param federationFetchEndpoint The exact endpoint provided by the parent EC's metadata.
117
+ * @param subordinatedEntityBaseUrl The url that identifies the subordinate entity.
118
+ * @param appFetch An optional instance of the http client to be used.
119
+ * @returns The signed entity statement token.
120
+ * @throws {IoWalletError} If the http request fails.
121
+ */
122
+ export async function getSignedEntityStatement(federationFetchEndpoint, subordinatedEntityBaseUrl) {
123
+ let {
124
+ appFetch = fetch
125
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
126
+ const url = new URL(federationFetchEndpoint);
127
+ url.searchParams.set("sub", subordinatedEntityBaseUrl);
128
+ return await appFetch(url.toString(), {
129
+ method: "GET"
130
+ }).then(hasStatusOrThrow(200)).then(res => res.text());
131
+ }
132
+
133
+ /**
134
+ * Fetch the federation list document from a given endpoint.
135
+ *
136
+ * @param federationListEndpoint The URL of the federation list endpoint.
137
+ * @param appFetch An optional instance of the http client to be used.
138
+ * @returns The federation list as an array of strings.
139
+ * @throws {IoWalletError} If the HTTP request fails.
140
+ * @throws {FederationError} If the result is not in the expected format.
141
+ */
142
+ export async function getFederationList(federationListEndpoint) {
143
+ let {
144
+ appFetch = fetch
145
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
146
+ return await appFetch(federationListEndpoint, {
147
+ method: "GET"
148
+ }).then(hasStatusOrThrow(200)).then(res => res.json()).then(json => {
149
+ const result = FederationListResponse.safeParse(json);
150
+ if (!result.success) {
151
+ throw new FederationListParseError(`Invalid federation list format received from ${federationListEndpoint}. Error: ${result.error.message}`, {
152
+ url: federationListEndpoint,
153
+ parseError: result.error.toString()
154
+ });
155
+ }
156
+ return result.data;
157
+ });
158
+ }
159
+
160
+ /**
161
+ * Build a not-verified trust chain for a given Relying Party (RP) entity.
162
+ *
163
+ * @param relyingPartyEntityBaseUrl The base URL of the RP entity
164
+ * @param trustAnchorKey The public key of the Trust Anchor (TA) entity
165
+ * @param appFetch An optional instance of the http client to be used.
166
+ * @returns A list of signed tokens that represent the trust chain, in the order of the chain (from the RP to the Trust Anchor)
167
+ * @throws {FederationError} When an element of the chain fails to parse or other build steps fail.
168
+ */
169
+ export async function buildTrustChain(relyingPartyEntityBaseUrl, trustAnchorKey) {
170
+ let appFetch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : fetch;
171
+ // 1: Recursively gather the trust chain from the RP up to the Trust Anchor
172
+ const trustChain = await gatherTrustChain(relyingPartyEntityBaseUrl, appFetch);
173
+
174
+ // 2: Trust Anchor signature verification
175
+ const trustAnchorJwt = trustChain[trustChain.length - 1];
176
+ if (!trustAnchorJwt) {
177
+ throw new BuildTrustChainError("Cannot verify trust anchor: missing entity configuration in gathered chain.", {
178
+ relyingPartyUrl: relyingPartyEntityBaseUrl
179
+ });
180
+ }
181
+ if (!trustAnchorKey.kid) {
182
+ throw new TrustAnchorKidMissingError();
183
+ }
184
+ await verify(trustAnchorJwt, trustAnchorKey.kid, [trustAnchorKey]);
185
+
186
+ // 3: Check the federation list
187
+ const trustAnchorConfig = EntityConfiguration.parse(decode(trustAnchorJwt));
188
+ const federationListEndpoint = trustAnchorConfig.payload.metadata.federation_entity.federation_list_endpoint;
189
+ if (federationListEndpoint) {
190
+ const federationList = await getFederationList(federationListEndpoint, {
191
+ appFetch
192
+ });
193
+ if (!federationList.includes(relyingPartyEntityBaseUrl)) {
194
+ throw new RelyingPartyNotAuthorizedError("Relying Party entity base URL is not authorized by the Trust Anchor's federation list.", {
195
+ relyingPartyUrl: relyingPartyEntityBaseUrl,
196
+ federationListEndpoint
197
+ });
198
+ }
199
+ }
200
+ return trustChain;
201
+ }
202
+
203
+ /**
204
+ * Recursively gather the trust chain for an entity and all its superiors.
205
+ * @param entityBaseUrl The base URL of the entity for which to gather the chain.
206
+ * @param appFetch An optional instance of the http client to be used.
207
+ * @param isLeaf Whether the current entity is the leaf of the chain.
208
+ * @returns A full ordered list of JWTs (ECs and ESs) forming the trust chain.
209
+ * @throws {FederationError} If any of the fetched documents fail to parse or other errors occur during the gathering process.
210
+ */
211
+ async function gatherTrustChain(entityBaseUrl, appFetch) {
212
+ let isLeaf = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
213
+ const chain = [];
214
+
215
+ // Fetch self-signed EC (only needed for the leaf)
216
+ const entityECJwt = await getSignedEntityConfiguration(entityBaseUrl, {
217
+ appFetch
218
+ });
219
+ const entityEC = EntityConfiguration.parse(decode(entityECJwt));
220
+ if (isLeaf) {
221
+ // Only push EC for the leaf
222
+ chain.push(entityECJwt);
223
+ }
224
+
225
+ // Find authority_hints (parent, if any)
226
+ const authorityHints = entityEC.payload.authority_hints ?? [];
227
+ if (authorityHints.length === 0) {
228
+ // This is the Trust Anchor (no parent)
229
+ if (!isLeaf) {
230
+ chain.push(entityECJwt);
231
+ }
232
+ return chain;
233
+ }
234
+ const parentEntityBaseUrl = authorityHints[0];
235
+
236
+ // Fetch parent EC
237
+ const parentECJwt = await getSignedEntityConfiguration(parentEntityBaseUrl, {
238
+ appFetch
239
+ });
240
+ const parentEC = EntityConfiguration.parse(decode(parentECJwt));
241
+
242
+ // Fetch ES
243
+ const federationFetchEndpoint = parentEC.payload.metadata.federation_entity.federation_fetch_endpoint;
244
+ if (!federationFetchEndpoint) {
245
+ throw new MissingFederationFetchEndpointError(`Missing federation_fetch_endpoint in parent's (${parentEntityBaseUrl}) configuration when gathering chain for ${entityBaseUrl}.`, {
246
+ entityBaseUrl,
247
+ missingInEntityUrl: parentEntityBaseUrl
248
+ });
249
+ }
250
+ const entityStatementJwt = await getSignedEntityStatement(federationFetchEndpoint, entityBaseUrl, {
251
+ appFetch
252
+ });
253
+ // Validate the ES
254
+ EntityStatement.parse(decode(entityStatementJwt));
255
+
256
+ // Push this ES into the chain
257
+ chain.push(entityStatementJwt);
258
+
259
+ // Recurse into the parent
260
+ const parentChain = await gatherTrustChain(parentEntityBaseUrl, appFetch, false);
261
+ return chain.concat(parentChain);
262
+ }
263
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["decode","verify","decodeJwt","CredentialIssuerEntityConfiguration","EntityConfiguration","EntityStatement","FederationListResponse","RelyingPartyEntityConfiguration","TrustAnchorEntityConfiguration","WalletProviderEntityConfiguration","renewTrustChain","validateTrustChain","hasStatusOrThrow","BuildTrustChainError","FederationListParseError","MissingFederationFetchEndpointError","RelyingPartyNotAuthorizedError","TrustAnchorKidMissingError","verifyTrustChain","trustAnchorEntity","chain","appFetch","fetch","renewOnFail","arguments","length","undefined","error","renewedChain","getSignedEntityConfiguration","entityBaseUrl","wellKnownUrl","method","then","res","text","fetchAndParseEntityConfiguration","schema","responseText","responseJwt","parse","header","protectedHeader","payload","getWalletProviderEntityConfiguration","options","getCredentialIssuerEntityConfiguration","getTrustAnchorEntityConfiguration","getRelyingPartyEntityConfiguration","getEntityConfiguration","getEntityStatement","accreditationBodyBaseUrl","subordinatedEntityBaseUrl","getSignedEntityStatement","federationFetchEndpoint","url","URL","searchParams","set","toString","getFederationList","federationListEndpoint","json","result","safeParse","success","message","parseError","data","buildTrustChain","relyingPartyEntityBaseUrl","trustAnchorKey","trustChain","gatherTrustChain","trustAnchorJwt","relyingPartyUrl","kid","trustAnchorConfig","metadata","federation_entity","federation_list_endpoint","federationList","includes","isLeaf","entityECJwt","entityEC","push","authorityHints","authority_hints","parentEntityBaseUrl","parentECJwt","parentEC","federation_fetch_endpoint","missingInEntityUrl","entityStatementJwt","parentChain","concat"],"sourceRoot":"../../../src","sources":["trust/index.ts"],"mappings":"AAAA,SAASA,MAAM,EAAEC,MAAM,QAAQ,SAAS;AACxC,SAASD,MAAM,IAAIE,SAAS,QAAQ,6BAA6B;AACjE,SACEC,mCAAmC,EACnCC,mBAAmB,EACnBC,eAAe,EACfC,sBAAsB,EACtBC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,iCAAiC,QAC5B,SAAS;AAChB,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,SAAS;AAC7D,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,mCAAmC,EACnCC,8BAA8B,EAC9BC,0BAA0B,QACrB,UAAU;AAWjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,gBAAgBA,CACpCC,iBAAiD,EACjDC,KAAe,EAKiC;EAAA,IAJhD;IACEC,QAAQ,GAAGC,KAAK;IAChBC,WAAW,GAAG;EAC4C,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAElE,IAAI;IACF,OAAOb,kBAAkB,CAACQ,iBAAiB,EAAEC,KAAK,CAAC;EACrD,CAAC,CAAC,OAAO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ACC,iBAAiB,CAACa,yBAAyB;EACvE,IAAI,CAACtC,uBAAuB,EAAE;IAC5B,MAAM,IAAIvC,mCAAmC,CAC1C,kDAAiD0E,mBAAoB,4CAA2C3D,aAAc,GAAE,EACjI;MAAEA,aAAa;MAAE+D,kBAAkB,EAAEJ;IAAoB,CAC3D,CAAC;EACH;EAEA,MAAMK,kBAAkB,GAAG,MAAMzC,wBAAwB,CACvDC,uBAAuB,EACvBxB,aAAa,EACb;IAAET;EAAS,CACb,CAAC;EACD;EACAhB,eAAe,CAACmC,KAAK,CAACxC,MAAM,CAAC8F,kBAAkB,CAAC,CAAC;;EAEjD;EACA1E,KAAK,CAACkE,IAAI,CAACQ,kBAAkB,CAAC;;EAE9B;EACA,MAAMC,WAAW,GAAG,MAAMtB,gBAAgB,CACxCgB,mBAAmB,EACnBpE,QAAQ,EACR,KACF,CAAC;EAED,OAAOD,KAAK,CAAC4E,MAAM,CAACD,WAAW,CAAC;AAClC"}
@@ -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
  export const TrustMark = z.object({
6
6
  id: z.string(),
7
7
  trust_mark: z.string()
@@ -15,36 +15,25 @@ const RelyingPartyMetadata = z.object({
15
15
  }),
16
16
  contacts: z.array(z.string()).optional(),
17
17
  presentation_definition: PresentationDefinition.optional(),
18
- presentation_definition_uri: z.string().optional()
18
+ request_uris: z.array(z.string()).optional(),
19
+ authorization_signed_response_alg: z.string().optional(),
20
+ authorization_encrypted_response_alg: z.string().optional(),
21
+ authorization_encrypted_response_enc: z.string().optional()
19
22
  });
20
- //.passthrough();
21
23
 
22
24
  // Display metadata for a credential, used by the issuer to
23
25
  // instruct the Wallet Solution on how to render the credential correctly
24
26
  const CredentialDisplayMetadata = z.object({
25
27
  name: z.string(),
26
- locale: z.string(),
27
- logo: z.object({
28
- url: z.string(),
29
- alt_text: z.string()
30
- }).optional(),
31
- // TODO [SIW-1268]: should not be optional
32
- background_color: z.string().optional(),
33
- // TODO [SIW-1268]: should not be optional
34
- text_color: z.string().optional() // TODO [SIW-1268]: should not be optional
28
+ locale: z.string()
35
29
  });
36
30
 
37
31
  // Metadata for displaying issuer information
38
32
 
39
33
  const CredentialIssuerDisplayMetadata = z.object({
40
34
  name: z.string(),
41
- locale: z.string(),
42
- logo: z.object({
43
- url: z.string(),
44
- alt_text: z.string()
45
- }).optional() // TODO [SIW-1268]: should not be optional
35
+ locale: z.string()
46
36
  });
47
-
48
37
  const ClaimsMetadata = z.record(z.object({
49
38
  value_type: z.string(),
50
39
  display: z.array(z.object({
@@ -60,14 +49,13 @@ const IssuanceErrorSupported = z.object({
60
49
  }))
61
50
  });
62
51
 
63
- // Metadata for a credentia which is supported by a Issuer
52
+ // Metadata for a credential which is supported by an Issuer
64
53
 
65
54
  const SupportedCredentialMetadata = z.object({
66
- format: z.union([z.literal("vc+sd-jwt"), z.literal("mso_mdoc")]),
55
+ format: z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]),
67
56
  scope: z.string(),
68
57
  display: z.array(CredentialDisplayMetadata),
69
- claims: ClaimsMetadata.optional(),
70
- // TODO [SIW-1268]: should not be optional
58
+ claims: ClaimsMetadata,
71
59
  cryptographic_binding_methods_supported: z.array(z.string()),
72
60
  credential_signing_alg_values_supported: z.array(z.string()),
73
61
  authentic_source: z.string().optional(),
@@ -85,7 +73,7 @@ export const EntityStatement = z.object({
85
73
  jwks: z.object({
86
74
  keys: z.array(JWK)
87
75
  }),
88
- trust_marks: z.array(TrustMark),
76
+ trust_marks: z.array(TrustMark).optional(),
89
77
  iat: z.number(),
90
78
  exp: z.number()
91
79
  })
@@ -97,7 +85,7 @@ export const EntityConfigurationHeader = z.object({
97
85
  });
98
86
 
99
87
  /**
100
- * @see https://openid.net/specs/openid-connect-federation-1_0-29.html#name-federation-entity
88
+ * @see https://openid.net/specs/openid-federation-1_0-41.html
101
89
  */
102
90
  const FederationEntityMetadata = z.object({
103
91
  federation_fetch_endpoint: z.string().optional(),
@@ -105,6 +93,9 @@ const FederationEntityMetadata = z.object({
105
93
  federation_resolve_endpoint: z.string().optional(),
106
94
  federation_trust_mark_status_endpoint: z.string().optional(),
107
95
  federation_trust_mark_list_endpoint: z.string().optional(),
96
+ federation_trust_mark_endpoint: z.string().optional(),
97
+ federation_historical_keys_endpoint: z.string().optional(),
98
+ endpoint_auth_signing_alg_values_supported: z.string().optional(),
108
99
  organization_name: z.string().optional(),
109
100
  homepage_uri: z.string().optional(),
110
101
  policy_uri: z.string().optional(),
@@ -112,7 +103,7 @@ const FederationEntityMetadata = z.object({
112
103
  contacts: z.array(z.string()).optional()
113
104
  }).passthrough();
114
105
 
115
- // Structuire common to every Entity Configuration document
106
+ // Structure common to every Entity Configuration document
116
107
  const BaseEntityConfiguration = z.object({
117
108
  header: EntityConfigurationHeader,
118
109
  payload: z.object({
@@ -156,15 +147,9 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z
156
147
  oauth_authorization_server: z.object({
157
148
  authorization_endpoint: z.string(),
158
149
  pushed_authorization_request_endpoint: z.string(),
159
- dpop_signing_alg_values_supported: z.array(z.string()).optional(),
160
- // TODO [SIW-1268]: should not be optional
161
150
  token_endpoint: z.string(),
162
- introspection_endpoint: z.string().optional(),
163
- // TODO [SIW-1268]: should not be optional
164
151
  client_registration_types_supported: z.array(z.string()),
165
152
  code_challenge_methods_supported: z.array(z.string()),
166
- authorization_details_types_supported: z.array(z.string()).optional(),
167
- // TODO [SIW-1268]: should not be optional,
168
153
  acr_values_supported: z.array(z.string()),
169
154
  grant_types_supported: z.array(z.string()),
170
155
  issuer: z.string(),
@@ -172,23 +157,16 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z
172
157
  keys: z.array(JWK)
173
158
  }),
174
159
  scopes_supported: z.array(z.string()),
175
- request_parameter_supported: z.boolean().optional(),
176
- // TODO [SIW-1268]: should not be optional
177
- request_uri_parameter_supported: z.boolean().optional(),
178
- // TODO [SIW-1268]: should not be optional
179
- response_types_supported: z.array(z.string()).optional(),
180
- // TODO [SIW-1268]: should not be optional
181
160
  response_modes_supported: z.array(z.string()),
182
- subject_types_supported: z.array(z.string()).optional(),
183
- // TODO [SIW-1268]: should not be optional
184
161
  token_endpoint_auth_methods_supported: z.array(z.string()),
185
162
  token_endpoint_auth_signing_alg_values_supported: z.array(z.string()),
186
163
  request_object_signing_alg_values_supported: z.array(z.string())
187
164
  }),
188
- /** Credential Issuers act as Relying Party
189
- when they require the presentation of other credentials.
190
- This does not apply for PID issuance, which requires CIE authz. */
191
- wallet_relying_party: RelyingPartyMetadata.optional()
165
+ /**
166
+ * Credential Issuers act as Relying Party when they require the presentation of other credentials.
167
+ * This does not apply for PID issuance, which requires CIE authz.
168
+ */
169
+ openid_credential_verifier: RelyingPartyMetadata.optional()
192
170
  })
193
171
  })
194
172
  }));
@@ -198,7 +176,7 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z
198
176
  export const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(z.object({
199
177
  payload: z.object({
200
178
  metadata: z.object({
201
- wallet_relying_party: RelyingPartyMetadata
179
+ openid_credential_verifier: RelyingPartyMetadata
202
180
  })
203
181
  })
204
182
  }));
@@ -227,4 +205,5 @@ export const WalletProviderEntityConfiguration = BaseEntityConfiguration.and(z.o
227
205
  export const EntityConfiguration = z.union([WalletProviderEntityConfiguration, CredentialIssuerEntityConfiguration, TrustAnchorEntityConfiguration, RelyingPartyEntityConfiguration], {
228
206
  description: "Any kind of Entity Configuration allowed in the ecosystem"
229
207
  });
208
+ export const FederationListResponse = z.array(z.string());
230
209
  //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnixTime","JWK","z","PresentationDefinition","TrustMark","object","id","string","trust_mark","RelyingPartyMetadata","application_type","optional","client_id","client_name","jwks","keys","array","contacts","presentation_definition","request_uris","authorization_signed_response_alg","authorization_encrypted_response_alg","authorization_encrypted_response_enc","CredentialDisplayMetadata","name","locale","CredentialIssuerDisplayMetadata","ClaimsMetadata","record","value_type","display","IssuanceErrorSupported","title","description","SupportedCredentialMetadata","format","union","literal","scope","claims","cryptographic_binding_methods_supported","credential_signing_alg_values_supported","authentic_source","issuance_errors_supported","EntityStatement","header","typ","alg","kid","payload","iss","sub","trust_marks","iat","number","exp","EntityConfigurationHeader","FederationEntityMetadata","federation_fetch_endpoint","federation_list_endpoint","federation_resolve_endpoint","federation_trust_mark_status_endpoint","federation_trust_mark_list_endpoint","federation_trust_mark_endpoint","federation_historical_keys_endpoint","endpoint_auth_signing_alg_values_supported","organization_name","homepage_uri","policy_uri","logo_uri","passthrough","BaseEntityConfiguration","authority_hints","metadata","federation_entity","TrustAnchorEntityConfiguration","CredentialIssuerEntityConfiguration","and","openid_credential_issuer","credential_issuer","credential_endpoint","revocation_endpoint","status_attestation_endpoint","credential_configurations_supported","oauth_authorization_server","authorization_endpoint","pushed_authorization_request_endpoint","token_endpoint","client_registration_types_supported","code_challenge_methods_supported","acr_values_supported","grant_types_supported","issuer","scopes_supported","response_modes_supported","token_endpoint_auth_methods_supported","token_endpoint_auth_signing_alg_values_supported","request_object_signing_alg_values_supported","openid_credential_verifier","RelyingPartyEntityConfiguration","WalletProviderEntityConfiguration","wallet_provider","aal_values_supported","EntityConfiguration","FederationListResponse"],"sourceRoot":"../../../src","sources":["trust/types.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,cAAc;AAClC,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,sBAAsB,QAAQ,kCAAkC;AAEzE,OAAO,MAAMC,SAAS,GAAGF,CAAC,CAACG,MAAM,CAAC;EAAEC,EAAE,EAAEJ,CAAC,CAACK,MAA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9F,CAAC,CAACc,KAAK,CACvDd,CAAC,CAACK,MAAM,CAAC,CACX,CAAC;QACDO,IAAI,EAAEZ,CAAC,CAACG,MAAM,CAAC;UAAEU,IAAI,EAAEb,CAAC,CAACc,KAAK,CAACf,GAAG;QAAE,CAAC;MACvC,CAAC,CAAC,CACDqE,WAAW,CAAC;IACjB,CAAC;EACH,CAAC;AACH,CAAC,CACH,CAAC;;AAED;;AAEA,OAAO,MAAMiC,mBAAmB,GAAGrG,CAAC,CAACkC,KAAK,CACxC,CACEgE,iCAAiC,EACjCxB,mCAAmC,EACnCD,8BAA8B,EAC9BwB,+BAA+B,CAChC,EACD;EACElE,WAAW,EAAE;AACf,CACF,CAAC;AAED,OAAO,MAAMuE,sBAAsB,GAAGtG,CAAC,CAACc,KAAK,CAACd,CAAC,CAACK,MAAM,CAAC,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { decode as decodeJwt, verify as verifyJwt } from "@pagopa/io-react-native-jwt";
2
+ // Verify a token signature
3
+ // The kid is extracted from the token header
4
+ export const verify = async (token, kid, jwks) => {
5
+ const jwk = jwks.find(k => k.kid === kid);
6
+ if (!jwk) {
7
+ throw new Error(`Invalid kid: ${kid}, token: ${token}`);
8
+ }
9
+ const {
10
+ protectedHeader: header,
11
+ payload
12
+ } = await verifyJwt(token, jwk);
13
+ return {
14
+ header,
15
+ payload
16
+ };
17
+ };
18
+
19
+ /**
20
+ * Return type for this function is necessary to avoid an issue during the bob build process.
21
+ * It seems like typescript can't correctly infer the return type of the function.
22
+ */
23
+ export const decode = token => {
24
+ const {
25
+ protectedHeader: header,
26
+ payload
27
+ } = decodeJwt(token);
28
+ return {
29
+ header,
30
+ payload
31
+ };
32
+ };
33
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["decode","decodeJwt","verify","verifyJwt","token","kid","jwks","jwk","find","k","Error","protectedHeader","header","payload"],"sourceRoot":"../../../src","sources":["trust/utils.ts"],"mappings":"AAAA,SACEA,MAAM,IAAIC,SAAS,EACnBC,MAAM,IAAIC,SAAS,QACd,6BAA6B;AASpC;AACA;AACA,OAAO,MAAMD,MAAM,GAAG,MAAAA,CACpBE,KAAa,EACbC,GAAW,EACXC,IAAW,KACc;EACzB,MAAMC,GAAG,GAAGD,IAAI,CAACE,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACJ,GAAG,KAAKA,GAAG,CAAC;EAC3C,IAAI,CAACE,GAAG,EAAE;IACR,MAAM,IAAIG,KAAK,CAAE,gBAAeL,GAAI,YAAWD,KAAM,EAAC,CAAC;EACzD;EACA,MAAM;IAAEO,eAAe,EAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAG,MAAMV,SAAS,CAACC,KAAK,EAAEG,GAAG,CAAC;EACxE,OAAO;IAAEK,MAAM;IAAEC;EAAQ,CAAC;AAC5B,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMb,MAAM,GAAII,KAAa,IAAkB;EACpD,MAAM;IAAEO,eAAe,EAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGZ,SAAS,CAACG,KAAK,CAAC;EAC7D,OAAO;IAAEQ,MAAM;IAAEC;EAAQ,CAAC;AAC5B,CAAC"}