@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
@@ -3,38 +3,93 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.verifyRequestObjectSignature = void 0;
7
- var _errors = require("./errors");
6
+ exports.verifyRequestObject = void 0;
8
7
  var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
8
+ var _errors = require("./errors");
9
9
  var _types = require("./types");
10
- const verifyRequestObjectSignature = async (requestObjectEncodedJwt, jwkKeys) => {
10
+ var _retrieveRpJwks = require("./04-retrieve-rp-jwks");
11
+ /**
12
+ * Function to verify the Request Object's validity, from the signature to the required properties.
13
+ * @param requestObjectEncodedJwt The Request Object in JWT format
14
+ * @param context.clientId The client ID to verify
15
+ * @param context.rpConf The Entity Configuration of the Relying Party
16
+ * @param context.state Optional state
17
+ * @returns The verified Request Object
18
+ * @throws {InvalidRequestObjectError} if the Request Object cannot be validated
19
+ */
20
+ const verifyRequestObject = async (requestObjectEncodedJwt, _ref) => {
21
+ let {
22
+ clientId,
23
+ rpConf,
24
+ rpSubject,
25
+ state
26
+ } = _ref;
11
27
  const requestObjectJwt = (0, _ioReactNativeJwt.decode)(requestObjectEncodedJwt);
12
-
13
- // verify token signature to ensure the request object is authentic
14
- const pubKey = (jwkKeys === null || jwkKeys === void 0 ? void 0 : jwkKeys.find(_ref => {
15
- let {
16
- kid
17
- } = _ref;
18
- return kid === requestObjectJwt.protectedHeader.kid;
19
- })) || (jwkKeys === null || jwkKeys === void 0 ? void 0 : jwkKeys.find(_ref2 => {
20
- let {
21
- use
22
- } = _ref2;
23
- return use === "sig";
24
- }));
25
- if (!pubKey) {
26
- throw new _errors.UnverifiedEntityError("Request Object signature verification!");
28
+ const pubKey = getSigPublicKey(rpConf, requestObjectJwt.protectedHeader.kid);
29
+ try {
30
+ // Standard claims are verified within `verify`
31
+ await (0, _ioReactNativeJwt.verify)(requestObjectEncodedJwt, pubKey, {
32
+ issuer: clientId
33
+ });
34
+ } catch (_) {
35
+ throw new _errors.InvalidRequestObjectError("The Request Object signature verification failed");
27
36
  }
28
- await (0, _ioReactNativeJwt.verify)(requestObjectEncodedJwt, pubKey);
29
- const requestObject = _types.RequestObject.parse(requestObjectJwt.payload);
30
- // Check if exp exists and is expired
31
- // exp is typically in seconds since epoch, Get current time in seconds
32
- if (requestObject.exp && requestObject.exp <= Date.now() / 1000) {
33
- throw new _errors.UnverifiedEntityError("Request Object is expired!");
37
+ const requestObject = validateRequestObjectShape(requestObjectJwt.payload);
38
+ const isClientIdMatch = clientId === requestObject.client_id && clientId === rpSubject;
39
+ if (!isClientIdMatch) {
40
+ throw new _errors.InvalidRequestObjectError("Client ID does not match Request Object or Entity Configuration");
41
+ }
42
+ const isStateMatch = state && requestObject.state ? state === requestObject.state : true;
43
+ if (!isStateMatch) {
44
+ throw new _errors.InvalidRequestObjectError("The provided state does not match the Request Object's");
34
45
  }
35
46
  return {
36
47
  requestObject
37
48
  };
38
49
  };
39
- exports.verifyRequestObjectSignature = verifyRequestObjectSignature;
50
+
51
+ /**
52
+ * Validate the shape of the Request Object to ensure all required properties are present and are of the expected type.
53
+ *
54
+ * @param payload The Request Object to validate
55
+ * @returns A valid Request Object
56
+ * @throws {InvalidRequestObjectError} when the Request Object cannot be parsed
57
+ */
58
+ exports.verifyRequestObject = verifyRequestObject;
59
+ const validateRequestObjectShape = payload => {
60
+ const requestObjectParse = _types.RequestObject.safeParse(payload);
61
+ if (requestObjectParse.success) {
62
+ return requestObjectParse.data;
63
+ }
64
+ throw new _errors.InvalidRequestObjectError("The Request Object cannot be parsed successfully", formatFlattenedZodErrors(requestObjectParse.error.flatten()));
65
+ };
66
+
67
+ /**
68
+ * Get the public key to verify the Request Object's signature from the Relying Party's EC.
69
+ *
70
+ * @param rpConf The Relying Party's EC
71
+ * @param kid The identifier of the key to find
72
+ * @returns The corresponding public key to verify the signature
73
+ * @throws {InvalidRequestObjectError} when the key cannot be found
74
+ */
75
+ const getSigPublicKey = (rpConf, kid) => {
76
+ try {
77
+ const {
78
+ keys
79
+ } = (0, _retrieveRpJwks.getJwksFromConfig)(rpConf);
80
+ const pubKey = keys.find(k => k.kid === kid);
81
+ if (!pubKey) throw new Error();
82
+ return pubKey;
83
+ } catch (_) {
84
+ throw new _errors.InvalidRequestObjectError(`The public key for signature verification (${kid}) cannot be found in the Entity Configuration`);
85
+ }
86
+ };
87
+
88
+ /**
89
+ * Utility to format flattened Zod errors into a simplified string `key1: key1_error, key2: key2_error`
90
+ */
91
+ const formatFlattenedZodErrors = errors => Object.entries(errors.fieldErrors).map(_ref2 => {
92
+ let [key, error] = _ref2;
93
+ return `${key}: ${error[0]}`;
94
+ }).join(", ");
40
95
  //# sourceMappingURL=05-verify-request-object.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","verifyRequestObjectSignature","requestObjectEncodedJwt","jwkKeys","requestObjectJwt","decodeJwt","pubKey","find","_ref","kid","protectedHeader","_ref2","use","UnverifiedEntityError","verify","requestObject","RequestObject","parse","payload","exp","Date","now","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/05-verify-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AASO,MAAMG,4BAA0D,GACrE,MAAAA,CAAOC,uBAAuB,EAAEC,OAAO,KAAK;EAC1C,MAAMC,gBAAgB,GAAG,IAAAC,wBAAS,EAACH,uBAAuB,CAAC;;EAE3D;EACA,MAAMI,MAAM,GACV,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,IAAI,CACXC,IAAA;IAAA,IAAC;MAAEC;IAAI,CAAC,GAAAD,IAAA;IAAA,OAAKC,GAAG,KAAKL,gBAAgB,CAACM,eAAe,CAACD,GAAG;EAAA,CAC3D,CAAC,MAAIN,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,IAAI,CAACI,KAAA;IAAA,IAAC;MAAEC;IAAI,CAAC,GAAAD,KAAA;IAAA,OAAKC,GAAG,KAAK,KAAK;EAAA,EAAC;EAEhD,IAAI,CAACN,MAAM,EAAE;IACX,MAAM,IAAIO,6BAAqB,CAAC,wCAAwC,CAAC;EAC3E;EACA,MAAM,IAAAC,wBAAM,EAACZ,uBAAuB,EAAEI,MAAM,CAAC;EAE7C,MAAMS,aAAa,GAAGC,oBAAa,CAACC,KAAK,CAACb,gBAAgB,CAACc,OAAO,CAAC;EACnE;EACA;EACA,IAAIH,aAAa,CAACI,GAAG,IAAIJ,aAAa,CAACI,GAAG,IAAIC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE;IAC/D,MAAM,IAAIR,6BAAqB,CAAC,4BAA4B,CAAC;EAC/D;EAEA,OAAO;IAAEE;EAAc,CAAC;AAC1B,CAAC;AAACO,OAAA,CAAArB,4BAAA,GAAAA,4BAAA"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_errors","_types","_retrieveRpJwks","verifyRequestObject","requestObjectEncodedJwt","_ref","clientId","rpConf","rpSubject","state","requestObjectJwt","decodeJwt","pubKey","getSigPublicKey","protectedHeader","kid","verify","issuer","_","InvalidRequestObjectError","requestObject","validateRequestObjectShape","payload","isClientIdMatch","client_id","isStateMatch","exports","requestObjectParse","RequestObject","safeParse","success","data","formatFlattenedZodErrors","error","flatten","keys","getJwksFromConfig","find","k","Error","errors","Object","entries","fieldErrors","map","_ref2","key","join"],"sourceRoot":"../../../../src","sources":["credential/presentation/05-verify-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,mBAAwC,GAAG,MAAAA,CACtDC,uBAAuB,EAAAC,IAAA,KAEpB;EAAA,IADH;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAM,CAAC,GAAAJ,IAAA;EAEtC,MAAMK,gBAAgB,GAAG,IAAAC,wBAAS,EAACP,uBAAuB,CAAC;EAE3D,MAAMQ,MAAM,GAAGC,eAAe,CAACN,MA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ACpB;EACH,IAAI;IACF,MAAM;MAAEoB;IAAK,CAAC,GAAG,IAAAC,iCAAiB,EAAC7B,MAAM,CAAC;IAE1C,MAAMK,MAAM,GAAGuB,IAAI,CAACE,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACvB,GAAG,KAAKA,GAAG,CAAC;IAE9C,IAAI,CAACH,MAAM,EAAE,MAAM,IAAI2B,KAAK,CAAC,CAAC;IAE9B,OAAO3B,MAAM;EACf,CAAC,CAAC,OAAOM,CAAC,EAAE;IACV,MAAM,IAAIC,iCAAyB,CAChC,8CAA6CJ,GAAI,+CACpD,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA,MAAMiB,wBAAwB,GAC5BQ,MAA+C,IAE/CC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,WAAW,CAAC,CAC/BC,GAAG,CAACC,KAAA;EAAA,IAAC,CAACC,GAAG,EAAEb,KAAK,CAAC,GAAAY,KAAA;EAAA,OAAM,GAAEC,GAAI,KAAIb,KAAK,CAAC,CAAC,CAAE,EAAC;AAAA,EAAC,CAC5Cc,IAAI,CAAC,IAAI,CAAC"}
@@ -4,31 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.fetchPresentDefinition = void 0;
7
- var _types = require("./types");
8
- var _misc = require("../../utils/misc");
9
7
  /**
10
8
  * Retrieves a PresentationDefinition based on the given parameters.
11
9
  *
12
10
  * The method attempts the following strategies in order:
13
11
  * 1. Checks if `presentation_definition` is directly available in the request object.
14
- * 2. Fetches the `presentation_definition` from the URI provided in the relying party configuration.
15
- * 3. Uses a pre-configured `presentation_definition` from the relying party configuration if the `scope` is present in the request object.
12
+ * 2. Uses a pre-configured `presentation_definition` from the relying party configuration if the `scope` is present in the request object.
16
13
  *
17
- * If none of the above conditions are met, the function throws an error indicating the definition could not be found.
14
+ * 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.
18
15
  *
19
16
  * @param {RequestObject} requestObject - The request object containing the presentation definition or references to it.
20
17
  * @param {RelyingPartyEntityConfiguration["payload"]["metadata"]} [rpConf] - Optional relying party configuration.
21
- * @param {Object} [context] - Optional context for providing a custom fetch implementation.
22
- * @param {GlobalFetch["fetch"]} [context.appFetch] - Custom fetch function, defaults to global `fetch`.
23
18
  * @returns {Promise<{ presentationDefinition: PresentationDefinition }>} - Resolves with the presentation definition.
24
19
  * @throws {Error} - Throws if the presentation definition cannot be found or fetched.
25
20
  */
26
- const fetchPresentDefinition = async function (requestObject) {
27
- var _rpConf$wallet_relyin, _rpConf$wallet_relyin2;
28
- let {
29
- appFetch = fetch
30
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
31
- let rpConf = arguments.length > 2 ? arguments[2] : undefined;
21
+ const fetchPresentDefinition = async (requestObject, rpConf) => {
22
+ var _rpConf$openid_creden;
32
23
  // Check if `presentation_definition` is directly available in the request object
33
24
  if (requestObject.presentation_definition) {
34
25
  return {
@@ -36,25 +27,10 @@ const fetchPresentDefinition = async function (requestObject) {
36
27
  };
37
28
  }
38
29
 
39
- // Check if `presentation_definition_uri` is provided in the relying party configuration
40
- if (rpConf !== null && rpConf !== void 0 && (_rpConf$wallet_relyin = rpConf.wallet_relying_party) !== null && _rpConf$wallet_relyin !== void 0 && _rpConf$wallet_relyin.presentation_definition_uri) {
41
- try {
42
- // Fetch the presentation definition from the provided URI
43
- const presentationDefinition = await appFetch(rpConf === null || rpConf === void 0 ? void 0 : rpConf.wallet_relying_party.presentation_definition_uri, {
44
- method: "GET"
45
- }).then((0, _misc.hasStatusOrThrow)(200)).then(raw => raw.json()).then(json => _types.PresentationDefinition.parse(json));
46
- return {
47
- presentationDefinition
48
- };
49
- } catch (error) {
50
- throw new Error(`Failed to fetch presentation definition: ${error}`);
51
- }
52
- }
53
-
54
30
  // Check if `scope` is present in the request object and a pre-configured presentation definition exists
55
- if (requestObject.scope && rpConf !== null && rpConf !== void 0 && (_rpConf$wallet_relyin2 = rpConf.wallet_relying_party) !== null && _rpConf$wallet_relyin2 !== void 0 && _rpConf$wallet_relyin2.presentation_definition) {
31
+ if (requestObject.scope && rpConf !== null && rpConf !== void 0 && (_rpConf$openid_creden = rpConf.openid_credential_verifier) !== null && _rpConf$openid_creden !== void 0 && _rpConf$openid_creden.presentation_definition) {
56
32
  return {
57
- presentationDefinition: rpConf.wallet_relying_party.presentation_definition
33
+ presentationDefinition: rpConf.openid_credential_verifier.presentation_definition
58
34
  };
59
35
  }
60
36
  throw new Error("Presentation definition not found");
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","_misc","fetchPresentDefinition","requestObject","_rpConf$wallet_relyin","_rpConf$wallet_relyin2","appFetch","fetch","arguments","length","undefined","rpConf","presentation_definition","presentationDefinition","wallet_relying_party","presentation_definition_uri","method","then","hasStatusOrThrow","raw","json","PresentationDefinition","parse","error","Error","scope","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/06-fetch-presentation-definition.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,sBAAmD,GAAG,eAAAA,CACjEC,aAAa,EAGV;EAAA,IAAAC,qBAAA,EAAAC,sBAAA;EAAA,IAFH;IAAEC,QAAQ,GAAGC;EAAM,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAAA,IACzBG,MAAM,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEN;EACA,IAAIP,aAAa,CAACS,uBAAuB,EAAE;IACzC,OAAO;MACLC,sBAAsB,EAAEV,aAAa,CAACS;IACxC,CAAC;EACH;;EAEA;EACA,IAAID,MAAM,aAANA,MAAM,gBAAAP,qBAAA,GAANO,MAAM,CAAEG,oBAAoB,cAAAV,qBAAA,eAA5BA,qBAAA,CAA8BW,2BAA2B,EAAE;IAC7D,IAAI;MACF;MACA,MAAMF,sBAAsB,GAAG,MAAMP,QAAQ,CAC3CK,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEG,oBAAoB,CAACC,2BAA2B,EACxD;QACEC,MAAM,EAAE;MACV,CACF,CAAC,CACEC,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,CAAC,CAAC,CAC3BD,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBH,IAAI,CAAEG,IAAI,IAAKC,6BAAsB,CAACC,KAAK,CAACF,IAAI,CAAC,CAAC;MAErD,OAAO;QACLP;MACF,CAAC;IACH,CAAC,CAAC,OAAOU,KAAK,EAAE;MACd,MAAM,IAAIC,KAAK,CAAE,4CAA2CD,KAAM,EAAC,CAAC;IACtE;EACF;;EAEA;EACA,IACEpB,aAAa,CAACsB,KAAK,IACnBd,MAAM,aAANA,MAAM,gBAAAN,sBAAA,GAANM,MAAM,CAAEG,oBAAoB,cAAAT,sBAAA,eAA5BA,sBAAA,CAA8BO,uBAAuB,EACrD;IACA,OAAO;MACLC,sBAAsB,EACpBF,MAAM,CAACG,oBAAoB,CAACF;IAChC,CAAC;EACH;EAEA,MAAM,IAAIY,KAAK,CAAC,mCAAmC,CAAC;AACtD,CAAC;AAACE,OAAA,CAAAxB,sBAAA,GAAAA,sBAAA"}
1
+ {"version":3,"names":["fetchPresentDefinition","requestObject","rpConf","_rpConf$openid_creden","presentation_definition","presentationDefinition","scope","openid_credential_verifier","Error","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/06-fetch-presentation-definition.ts"],"mappings":";;;;;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,sBAAmD,GAAG,MAAAA,CACjEC,aAAa,EACbC,MAAM,KACH;EAAA,IAAAC,qBAAA;EACH;EACA,IAAIF,aAAa,CAACG,uBAAuB,EAAE;IACzC,OAAO;MACLC,sBAAsB,EAAEJ,aAAa,CAACG;IACxC,CAAC;EACH;;EAEA;EACA,IACEH,aAAa,CAACK,KAAK,IACnBJ,MAAM,aAANA,MAAM,gBAAAC,qBAAA,GAAND,MAAM,CAAEK,0BAA0B,cAAAJ,qBAAA,eAAlCA,qBAAA,CAAoCC,uBAAuB,EAC3D;IACA,OAAO;MACLC,sBAAsB,EACpBH,MAAM,CAACK,0BAA0B,CAACH;IACtC,CAAC;EACH;EAEA,MAAM,IAAII,KAAK,CAAC,mCAAmC,CAAC;AACtD,CAAC;AAACC,OAAA,CAAAT,sBAAA,GAAAA,sBAAA"}
@@ -3,28 +3,31 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.evaluateDcqlQuery = void 0;
6
+ exports.prepareRemotePresentations = exports.evaluateDcqlQuery = void 0;
7
7
  var _dcql = require("dcql");
8
8
  var _valibot = require("valibot");
9
9
  var _sdJwt = require("../../sd-jwt");
10
- var _errors = require("../../utils/errors");
11
- var _errors2 = require("./errors");
12
- var _ioReactNativeCbor = require("@pagopa/io-react-native-cbor");
10
+ var _crypto = require("../../utils/crypto");
11
+ var _errors = require("./errors");
13
12
  /**
14
13
  * The purpose for the credential request by the RP.
15
14
  */
16
15
 
17
16
  /**
18
- * Convert a credential in SD-JWT format to an object with claims
17
+ * Convert a credential in JWT format to an object with claims
19
18
  * for correct parsing by the `dcql` library.
20
19
  */
21
- const mapCredentialSdJwtToObj = credentials => credentials.map(_ref => {
22
- let [,, jwt] = _ref;
20
+ const mapCredentialToObject = jwt => {
23
21
  const {
24
22
  sdJwt,
25
23
  disclosures
26
24
  } = (0, _sdJwt.decode)(jwt);
27
25
  const credentialFormat = sdJwt.header.typ;
26
+
27
+ // TODO [SIW-2082]: support MDOC credentials
28
+ if (credentialFormat !== "vc+sd-jwt") {
29
+ throw new Error(`Unsupported credential format: ${credentialFormat}`);
30
+ }
28
31
  return {
29
32
  vct: sdJwt.payload.vct,
30
33
  credential_format: credentialFormat,
@@ -33,63 +36,74 @@ const mapCredentialSdJwtToObj = credentials => credentials.map(_ref => {
33
36
  [disclosure.decoded[1]]: disclosure.decoded
34
37
  }), {})
35
38
  };
39
+ };
40
+
41
+ /**
42
+ * Extract only successful matches from the DCQL query result.
43
+ */
44
+ const getDcqlQueryMatches = result => Object.entries(result.credential_matches).filter(_ref => {
45
+ let [, match] = _ref;
46
+ return match.success === true;
36
47
  });
37
48
 
38
49
  /**
39
- * Convert a credential in Mdoc format to an object with claims
40
- * for correct parsing by the `dcql` library.
50
+ * Extract only failed matches from the DCQL query result.
51
+ */
52
+ const getDcqlQueryFailedMatches = result => Object.entries(result.credential_matches).filter(_ref2 => {
53
+ let [, match] = _ref2;
54
+ return match.success === false;
55
+ });
56
+
57
+ /**
58
+ * Extract missing credentials from the DCQL query result.
59
+ * Note: here we are assuming a failed match is a missing credential,
60
+ * but there might be other reasons for its failure.
41
61
  */
42
- const mapCredentialsMdocToObj = async credentialsMdoc => {
43
- return await Promise.all(credentialsMdoc === null || credentialsMdoc === void 0 ? void 0 : credentialsMdoc.map(async _ref2 => {
44
- let [type, _, credential] = _ref2;
45
- const issuerSigned = credential ? await _ioReactNativeCbor.CBOR.decodeIssuerSigned(credential) : undefined;
46
- if (!issuerSigned) {
47
- throw new _errors2.CredentialNotFoundError("mso_mdoc credential is not present.");
62
+ const extractMissingCredentials = (queryResult, originalQuery) => {
63
+ return getDcqlQueryFailedMatches(queryResult).map(_ref3 => {
64
+ var _credential$meta;
65
+ let [id] = _ref3;
66
+ const credential = originalQuery.credentials.find(c => c.id === id);
67
+ if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
68
+ throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
48
69
  }
49
- const namespaces = Object.entries(issuerSigned.nameSpaces).reduce((acc, _ref3) => {
50
- let [ns, nsClaims] = _ref3;
51
- const flattenNsClaims = Object.entries(nsClaims).reduce((ac, _ref4) => {
52
- let [, el] = _ref4;
53
- return {
54
- ...ac,
55
- [el.elementIdentifier]: el.elementValue
56
- };
57
- }, {});
58
- return {
59
- ...acc,
60
- [ns]: flattenNsClaims
61
- };
62
- }, {});
70
+
63
71
  return {
64
- credential_format: "mso_mdoc",
65
- doctype: type,
66
- namespaces
72
+ id,
73
+ vctValues: (_credential$meta = credential.meta) === null || _credential$meta === void 0 ? void 0 : _credential$meta.vct_values
67
74
  };
68
- }));
75
+ });
69
76
  };
70
-
71
- /**
72
- * Extract only successful matches from the DCQL query result.
73
- */
74
- const getDcqlQueryMatches = result => Object.entries(result.credential_matches).filter(_ref5 => {
75
- let [, match] = _ref5;
76
- return match.success === true;
77
- });
78
- const evaluateDcqlQuery = async (query, credentialsSdJwt, credentialsMdoc) => {
79
- const credentials = [];
80
- credentials.push(...mapCredentialSdJwtToObj(credentialsSdJwt));
81
- credentials.push(...(await mapCredentialsMdocToObj(credentialsMdoc)));
77
+ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
78
+ const credentials = credentialsSdJwt.map(_ref4 => {
79
+ let [, credential] = _ref4;
80
+ return mapCredentialToObject(credential);
81
+ });
82
82
  try {
83
83
  // Validate the query
84
84
  const parsedQuery = _dcql.DcqlQuery.parse(query);
85
85
  _dcql.DcqlQuery.validate(parsedQuery);
86
86
  const queryResult = _dcql.DcqlQuery.query(parsedQuery, credentials);
87
87
  if (!queryResult.canBeSatisfied) {
88
- throw new Error("No credential can satisfy the provided DCQL query");
88
+ throw new _errors.CredentialsNotFoundError(extractMissingCredentials(queryResult, parsedQuery));
89
89
  }
90
- return getDcqlQueryMatches(queryResult).map(_ref6 => {
90
+
91
+ // Build an object vct:credentialJwt to map matched credentials to their JWT
92
+ const credentialsSdJwtByVct = credentials.reduce((acc, c, i) => ({
93
+ ...acc,
94
+ [c.vct]: credentialsSdJwt[i]
95
+ }), {});
96
+ return getDcqlQueryMatches(queryResult).map(_ref5 => {
91
97
  var _queryResult$credenti;
92
- let [id, match] = _ref6;
98
+ let [id, match] = _ref5;
99
+ if (match.output.credential_format !== "vc+sd-jwt") {
100
+ throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
101
+ }
102
+
103
+ const {
104
+ vct,
105
+ claims
106
+ } = match.output;
93
107
  const purposes = (_queryResult$credenti = queryResult.credential_sets) === null || _queryResult$credenti === void 0 || (_queryResult$credenti = _queryResult$credenti.filter(set => {
94
108
  var _set$matching_options;
95
109
  return (_set$matching_options = set.matching_options) === null || _set$matching_options === void 0 ? void 0 : _set$matching_options.flat().includes(id);
@@ -100,82 +114,48 @@ const evaluateDcqlQuery = async (query, credentialsSdJwt, credentialsMdoc) => {
100
114
  required: Boolean(credentialSet.required)
101
115
  };
102
116
  });
103
- if (match.output.credential_format === "vc+sd-jwt") {
104
- const {
105
- vct,
106
- claims
107
- } = match.output;
108
- const [, keyTag, credential] = credentialsSdJwt.find(_ref7 => {
109
- let [type] = _ref7;
110
- return type === vct;
111
- });
112
- const requiredDisclosures = Object.values(claims);
113
- return {
114
- id,
115
- vct,
116
- keyTag,
117
- format: match.output.credential_format,
118
- credential,
119
- requiredDisclosures,
120
- // When it is a match but no credential_sets are found, the credential is required by default
121
- // See https://openid.net/specs/openid-4-verifiable-presentations-1_0-24.html#section-6.3.1.2-2.1
122
- purposes: purposes ?? [{
123
- required: true
124
- }]
125
- };
126
- }
127
- if (match.output.credential_format === "mso_mdoc") {
128
- const {
129
- doctype,
130
- namespaces
131
- } = match.output;
132
- const [, keyTag, credential] = credentialsMdoc.find(_ref8 => {
133
- let [type] = _ref8;
134
- return type === doctype;
135
- });
136
- const requiredDisclosures = Object.entries(namespaces).reduce((acc, _ref9) => {
137
- let [ns, nsClaims] = _ref9;
138
- return [...acc, ...Object.entries(nsClaims).map(_ref10 => {
139
- let [claimName] = _ref10;
140
- return {
141
- namespace: ns,
142
- name: claimName,
143
- value: nsClaims[claimName]
144
- };
145
- })];
146
- }, []);
147
- return {
148
- id,
149
- keyTag,
150
- format: match.output.credential_format,
151
- credential,
152
- requiredDisclosures,
153
- // When it is a match but no credential_sets are found, the credential is required by default
154
- // See https://openid.net/specs/openid-4-verifiable-presentations-1_0-24.html#section-6.3.1.2-2.1
155
- purposes: purposes ?? [{
156
- required: true
157
- }],
158
- doctype
159
- };
160
- }
161
- throw new Error(`Unsupported credential format: ${match.output.credential_format}`);
117
+ const [keyTag, credential] = credentialsSdJwtByVct[vct];
118
+ const requiredDisclosures = Object.values(claims);
119
+ return {
120
+ id,
121
+ vct,
122
+ keyTag,
123
+ credential,
124
+ requiredDisclosures,
125
+ // When it is a match but no credential_sets are found, the credential is required by default
126
+ // See https://openid.net/specs/openid-4-verifiable-presentations-1_0-24.html#section-6.3.1.2-2.1
127
+ purposes: purposes ?? [{
128
+ required: true
129
+ }]
130
+ };
162
131
  });
163
132
  } catch (error) {
164
- // Invalid DCQL query structure
133
+ // Invalid DCQL query structure. Remap to `DcqlError` for consistency.
165
134
  if ((0, _valibot.isValiError)(error)) {
166
- throw new _errors.ValidationFailed({
167
- message: "Invalid DCQL query",
168
- reason: error.issues.map(issue => issue.message).join(", ")
135
+ throw new _dcql.DcqlError({
136
+ message: "Failed to parse the provided DCQL query",
137
+ code: "PARSE_ERROR",
138
+ cause: error.issues
169
139
  });
170
140
  }
171
- if (error instanceof _dcql.DcqlError) {
172
- // TODO [SIW-2110]: handle invalid DQCL query or let the error propagate
173
- }
174
- if (error instanceof _dcql.DcqlCredentialSetError) {
175
- // TODO [SIW-2110]: handle missing credentials or let the error propagate
176
- }
141
+
142
+ // Let other errors propagate so they can be caught with `err instanceof DcqlError`
177
143
  throw error;
178
144
  }
179
145
  };
180
146
  exports.evaluateDcqlQuery = evaluateDcqlQuery;
147
+ const prepareRemotePresentations = async (credentials, nonce, clientId) => {
148
+ return Promise.all(credentials.map(async item => {
149
+ const {
150
+ vp_token
151
+ } = await (0, _sdJwt.prepareVpToken)(nonce, clientId, [item.credential, item.requestedClaims, (0, _crypto.createCryptoContextFor)(item.keyTag)]);
152
+ return {
153
+ credentialId: item.id,
154
+ requestedClaims: item.requestedClaims,
155
+ vpToken: vp_token,
156
+ format: "vc+sd-jwt"
157
+ };
158
+ }));
159
+ };
160
+ exports.prepareRemotePresentations = prepareRemotePresentations;
181
161
  //# sourceMappingURL=07-evaluate-dcql-query.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dcql","require","_valibot","_sdJwt","_errors","_errors2","_ioReactNativeCbor","mapCredentialSdJwtToObj","credentials","map","_ref","jwt","sdJwt","disclosures","decode","credentialFormat","header","typ","vct","payload","credential_format","claims","reduce","acc","disclosure","decoded","mapCredentialsMdocToObj","credentialsMdoc","Promise","all","_ref2","type","_","credential","issuerSigned","CBOR","decodeIssuerSigned","undefined","CredentialNotFoundError","namespaces","Object","entries","nameSpaces","_ref3","ns","nsClaims","flattenNsClaims","ac","_ref4","el","elementIdentifier","elementValue","doctype","getDcqlQueryMatches","result","credential_matches","filter","_ref5","match","success","evaluateDcqlQuery","query","credentialsSdJwt","push","parsedQuery","DcqlQuery","parse","validate","queryResult","canBeSatisfied","Error","_ref6","_queryResult$credenti","id","purposes","credential_sets","set","_set$matching_options","matching_options","flat","includes","credentialSet","_credentialSet$purpos","description","purpose","toString","required","Boolean","output","keyTag","find","_ref7","requiredDisclosures","values","format","_ref8","_ref9","_ref10","claimName","namespace","name","value","error","isValiError","ValidationFailed","message","reason","issues","issue","join","DcqlError","DcqlCredentialSetError","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-dcql-query.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,IAAAK,kBAAA,GAAAL,OAAA;AAEA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA,MAAMM,uBAAuB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AC,CAAC;UAC1ClC;QACF,CAAC;MACH;MAEA,MAAM,IAAIkB,KAAK,CACZ,kCAAiCZ,KAAK,CAAC8B,MAAM,CAACpE,iBAAkB,EACnE,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC,OAAOkF,KAAK,EAAE;IACd;IACA,IAAI,IAAAC,oBAAW,EAACD,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIE,wBAAgB,CAAC;QACzBC,OAAO,EAAE,oBAAoB;QAC7BC,MAAM,EAAEJ,KAAK,CAACK,MAAM,CAAClG,GAAG,CAAEmG,KAAK,IAAKA,KAAK,CAACH,OAAO,CAAC,CAACI,IAAI,CAAC,IAAI;MAC9D,CAAC,CAAC;IACJ;IAEA,IAAIP,KAAK,YAAYQ,eAAS,EAAE;MAC9B;IAAA;IAEF,IAAIR,KAAK,YAAYS,4BAAsB,EAAE;MAC3C;IAAA;IAEF,MAAMT,KAAK;EACb;AACF,CAAC;AAACU,OAAA,CAAApD,iBAAA,GAAAA,iBAAA"}
1
+ {"version":3,"names":["_dcql","require","_valibot","_sdJwt","_crypto","_errors","mapCredentialToObject","jwt","sdJwt","disclosures","decode","credentialFormat","header","typ","Error","vct","payload","credential_format","claims","reduce","acc","disclosure","decoded","getDcqlQueryMatches","result","Object","entries","credential_matches","filter","_ref","match","success","getDcqlQueryFailedMatches","_ref2","extractMissingCredentials","queryResult","originalQuery","map","_ref3","_credential$meta","id","credential","credentials","find","c","format","vctValues","meta","vct_values","evaluateDcqlQuery","credentialsSdJwt","query","_ref4","parsedQuery","DcqlQuery","parse","validate","canBeSatisfied","CredentialsNotFoundError","credentialsSdJwtByVct","i","_ref5","_queryResult$credenti","output","purposes","credential_sets","set","_set$matching_options","matching_options","flat","includes","credentialSet","_credentialSet$purpos","description","purpose","toString","required","Boolean","keyTag","requiredDisclosures","values","error","isValiError","DcqlError","message","code","cause","issues","exports","prepareRemotePresentations","nonce","clientId","Promise","all","item","vp_token","prepareVpToken","requestedClaims","createCryptoContextFor","credentialId","vpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-dcql-query.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAEA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA,MAAMK,qBAAqB,GAAIC,GAAW,IAAK;EAC7C,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAG,IAAAC,aAAM,EAACH,GAAG,CAAC;EAC1C,MAAMI,gBAAgB,GAAGH,KAAK,CAACI,MAAM,CAACC,GAAG;;EAEzC;EACA,IAAIF,gBAAgB,KAAK,WAAW,EAAE;IACpC,MAAM,IAAIG,KAAK,CAAE,kCAAiCH,gBAAiB,EAAC,CAAC;EACvE;EAEA,OAAO;IACLI,GAAG,EAAEP,KAAK,CAACQ,OAAO,CAACD,GAAG;IACtBE,iBAAiB,EAAEN,gBAAgB;IACnCO,MAAM,EAAET,WAAW,CAACU,MAAM,CACxB,CAACC,GAAG,EAAEC,UAAU,MAAM;MACpB,GAAGD,GAAG;MACN,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC,CAAC,GAAGD,UAAU,CAACC;IACtC,CAAC,CAAC,EACF,CAAC,CACH;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA,MAAMC,mBAAmB,GAAIC,MAAuB,IAClDC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,kBAAkB,CAAC,CAACC,MAAM,CAC9CC,IAAA;EAAA,IAAC,GAAGC,KAAK,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAACC,OAAO,KAAK,IAAI;AAAA,CACvC,CAAiC;;AAEnC;AACA;AACA;AACA,MAAMC,yBAAyB,GAAIR,MAAuB,IACxDC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,kBAAkB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