@pagopa/io-react-native-wallet 1.0.0 → 1.1.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 (289) hide show
  1. package/lib/commonjs/credential/index.js +1 -5
  2. package/lib/commonjs/credential/index.js.map +1 -1
  3. package/lib/commonjs/credential/issuance/02-get-issuer-config.js +48 -0
  4. package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +1 -0
  5. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +16 -20
  6. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +8 -8
  8. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/05-authorize-access.js +8 -9
  10. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/06-obtain-credential.js +18 -21
  12. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  13. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +3 -3
  14. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  15. package/lib/commonjs/credential/issuance/README.md +18 -21
  16. package/lib/commonjs/credential/issuance/index.js +3 -3
  17. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  18. package/lib/commonjs/credential/issuance/types.js +1 -1
  19. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  20. package/lib/commonjs/credential/presentation/01-start-flow.js +7 -2
  21. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  22. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +2 -2
  23. package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  24. package/lib/commonjs/credential/presentation/03-retrieve-jwks.js +68 -0
  25. package/lib/commonjs/credential/presentation/03-retrieve-jwks.js.map +1 -0
  26. package/lib/commonjs/credential/presentation/{03-get-request-object.js → 04-get-request-object.js} +27 -13
  27. package/lib/commonjs/credential/presentation/04-get-request-object.js.map +1 -0
  28. package/lib/commonjs/credential/presentation/{04-send-authorization-response.js → 05-send-authorization-response.js} +1 -1
  29. package/lib/commonjs/credential/presentation/{04-send-authorization-response.js.map → 05-send-authorization-response.js.map} +1 -1
  30. package/lib/commonjs/credential/presentation/README.md +74 -2
  31. package/lib/commonjs/credential/presentation/index.js +15 -2
  32. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  33. package/lib/commonjs/credential/presentation/types.js +5 -3
  34. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  35. package/lib/commonjs/entity/openid-connect/issuer/index.js +25 -0
  36. package/lib/commonjs/entity/openid-connect/issuer/index.js.map +1 -0
  37. package/lib/commonjs/entity/openid-connect/issuer/types.js +61 -0
  38. package/lib/commonjs/entity/openid-connect/issuer/types.js.map +1 -0
  39. package/lib/commonjs/{trust → entity/trust}/chain.js +1 -1
  40. package/lib/commonjs/entity/trust/chain.js.map +1 -0
  41. package/lib/commonjs/{trust → entity/trust}/index.js +1 -1
  42. package/lib/commonjs/entity/trust/index.js.map +1 -0
  43. package/lib/commonjs/{trust → entity/trust}/types.js +2 -2
  44. package/lib/commonjs/entity/trust/types.js.map +1 -0
  45. package/lib/commonjs/index.js +1 -3
  46. package/lib/commonjs/index.js.map +1 -1
  47. package/lib/commonjs/pid/sd-jwt/types.js +2 -18
  48. package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
  49. package/lib/commonjs/sd-jwt/__test__/index.test.js +32 -23
  50. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  51. package/lib/commonjs/sd-jwt/__test__/types.test.js +20 -11
  52. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  53. package/lib/commonjs/sd-jwt/types.js +18 -5
  54. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  55. package/lib/commonjs/utils/error-codes.js +1 -13
  56. package/lib/commonjs/utils/error-codes.js.map +1 -1
  57. package/lib/commonjs/utils/errors.js +2 -53
  58. package/lib/commonjs/utils/errors.js.map +1 -1
  59. package/lib/commonjs/utils/jwk.js +5 -1
  60. package/lib/commonjs/utils/jwk.js.map +1 -1
  61. package/lib/commonjs/utils/par.js +6 -12
  62. package/lib/commonjs/utils/par.js.map +1 -1
  63. package/lib/module/credential/index.js +1 -3
  64. package/lib/module/credential/index.js.map +1 -1
  65. package/lib/module/credential/issuance/02-get-issuer-config.js +42 -0
  66. package/lib/module/credential/issuance/02-get-issuer-config.js.map +1 -0
  67. package/lib/module/credential/issuance/03-start-user-authorization.js +16 -20
  68. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  69. package/lib/module/credential/issuance/04-complete-user-authorization.js +8 -8
  70. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  71. package/lib/module/credential/issuance/05-authorize-access.js +8 -9
  72. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  73. package/lib/module/credential/issuance/06-obtain-credential.js +18 -21
  74. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  75. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +3 -3
  76. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  77. package/lib/module/credential/issuance/README.md +18 -21
  78. package/lib/module/credential/issuance/index.js +2 -2
  79. package/lib/module/credential/issuance/index.js.map +1 -1
  80. package/lib/module/credential/issuance/types.js +1 -1
  81. package/lib/module/credential/issuance/types.js.map +1 -1
  82. package/lib/module/credential/presentation/01-start-flow.js +7 -2
  83. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  84. package/lib/module/credential/presentation/02-evaluate-rp-trust.js +1 -1
  85. package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
  86. package/lib/module/credential/presentation/03-retrieve-jwks.js +61 -0
  87. package/lib/module/credential/presentation/03-retrieve-jwks.js.map +1 -0
  88. package/lib/module/credential/presentation/{03-get-request-object.js → 04-get-request-object.js} +26 -12
  89. package/lib/module/credential/presentation/04-get-request-object.js.map +1 -0
  90. package/lib/module/credential/presentation/{04-send-authorization-response.js → 05-send-authorization-response.js} +1 -1
  91. package/lib/module/credential/presentation/{04-send-authorization-response.js.map → 05-send-authorization-response.js.map} +1 -1
  92. package/lib/module/credential/presentation/README.md +74 -2
  93. package/lib/module/credential/presentation/index.js +4 -3
  94. package/lib/module/credential/presentation/index.js.map +1 -1
  95. package/lib/module/credential/presentation/types.js +5 -3
  96. package/lib/module/credential/presentation/types.js.map +1 -1
  97. package/lib/module/entity/openid-connect/issuer/index.js +20 -0
  98. package/lib/module/entity/openid-connect/issuer/index.js.map +1 -0
  99. package/lib/module/entity/openid-connect/issuer/types.js +47 -0
  100. package/lib/module/entity/openid-connect/issuer/types.js.map +1 -0
  101. package/lib/module/{trust → entity/trust}/chain.js +1 -1
  102. package/lib/module/entity/trust/chain.js.map +1 -0
  103. package/lib/module/{trust → entity/trust}/index.js +1 -1
  104. package/lib/module/entity/trust/index.js.map +1 -0
  105. package/lib/module/{trust → entity/trust}/types.js +2 -2
  106. package/lib/module/entity/trust/types.js.map +1 -0
  107. package/lib/module/index.js +1 -2
  108. package/lib/module/index.js.map +1 -1
  109. package/lib/module/pid/sd-jwt/types.js +1 -16
  110. package/lib/module/pid/sd-jwt/types.js.map +1 -1
  111. package/lib/module/sd-jwt/__test__/index.test.js +32 -23
  112. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  113. package/lib/module/sd-jwt/__test__/types.test.js +20 -11
  114. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  115. package/lib/module/sd-jwt/types.js +16 -4
  116. package/lib/module/sd-jwt/types.js.map +1 -1
  117. package/lib/module/utils/error-codes.js +1 -13
  118. package/lib/module/utils/error-codes.js.map +1 -1
  119. package/lib/module/utils/errors.js +0 -48
  120. package/lib/module/utils/errors.js.map +1 -1
  121. package/lib/module/utils/jwk.js +3 -0
  122. package/lib/module/utils/jwk.js.map +1 -1
  123. package/lib/module/utils/par.js +6 -12
  124. package/lib/module/utils/par.js.map +1 -1
  125. package/lib/typescript/credential/index.d.ts +1 -3
  126. package/lib/typescript/credential/index.d.ts.map +1 -1
  127. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
  128. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +32 -0
  129. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +1 -0
  130. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
  131. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  132. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +8 -8
  133. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  134. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
  135. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  136. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +3 -3
  137. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  138. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -3
  139. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  140. package/lib/typescript/credential/issuance/index.d.ts +3 -3
  141. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  142. package/lib/typescript/credential/issuance/types.d.ts +4 -9
  143. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  144. package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
  145. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +1 -1
  146. package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
  147. package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts +41 -0
  148. package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts.map +1 -0
  149. package/lib/typescript/credential/presentation/{03-get-request-object.d.ts → 04-get-request-object.d.ts} +4 -4
  150. package/lib/typescript/credential/presentation/04-get-request-object.d.ts.map +1 -0
  151. package/lib/typescript/credential/presentation/{04-send-authorization-response.d.ts → 05-send-authorization-response.d.ts} +2 -2
  152. package/lib/typescript/credential/presentation/{04-send-authorization-response.d.ts.map → 05-send-authorization-response.d.ts.map} +1 -1
  153. package/lib/typescript/credential/presentation/index.d.ts +5 -4
  154. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  155. package/lib/typescript/credential/presentation/types.d.ts +15 -15
  156. package/lib/typescript/entity/openid-connect/issuer/index.d.ts +12 -0
  157. package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +1 -0
  158. package/lib/typescript/entity/openid-connect/issuer/types.d.ts +641 -0
  159. package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +1 -0
  160. package/lib/typescript/entity/trust/chain.d.ts.map +1 -0
  161. package/lib/typescript/{trust → entity/trust}/index.d.ts +97 -97
  162. package/lib/typescript/entity/trust/index.d.ts.map +1 -0
  163. package/lib/typescript/{trust → entity/trust}/types.d.ts +597 -597
  164. package/lib/typescript/{trust → entity/trust}/types.d.ts.map +1 -1
  165. package/lib/typescript/index.d.ts +1 -2
  166. package/lib/typescript/index.d.ts.map +1 -1
  167. package/lib/typescript/pid/sd-jwt/types.d.ts +25 -103
  168. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
  169. package/lib/typescript/sd-jwt/index.d.ts +60 -20
  170. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  171. package/lib/typescript/sd-jwt/types.d.ts +114 -24
  172. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  173. package/lib/typescript/utils/error-codes.d.ts +0 -12
  174. package/lib/typescript/utils/error-codes.d.ts.map +1 -1
  175. package/lib/typescript/utils/errors.d.ts +6 -37
  176. package/lib/typescript/utils/errors.d.ts.map +1 -1
  177. package/lib/typescript/utils/jwk.d.ts +135 -0
  178. package/lib/typescript/utils/jwk.d.ts.map +1 -1
  179. package/lib/typescript/utils/par.d.ts +1 -8
  180. package/lib/typescript/utils/par.d.ts.map +1 -1
  181. package/lib/typescript/wallet-instance-attestation/types.d.ts +12 -12
  182. package/package.json +1 -1
  183. package/src/credential/index.ts +1 -4
  184. package/src/credential/issuance/01-start-flow.ts +1 -1
  185. package/src/credential/issuance/02-get-issuer-config.ts +67 -0
  186. package/src/credential/issuance/03-start-user-authorization.ts +22 -30
  187. package/src/credential/issuance/04-complete-user-authorization.ts +11 -13
  188. package/src/credential/issuance/05-authorize-access.ts +8 -10
  189. package/src/credential/issuance/06-obtain-credential.ts +30 -31
  190. package/src/credential/issuance/07-verify-and-parse-credential.ts +6 -6
  191. package/src/credential/issuance/README.md +18 -21
  192. package/src/credential/issuance/index.ts +3 -6
  193. package/src/credential/issuance/types.ts +1 -1
  194. package/src/credential/presentation/01-start-flow.ts +8 -2
  195. package/src/credential/presentation/02-evaluate-rp-trust.ts +2 -2
  196. package/src/credential/presentation/03-retrieve-jwks.ts +73 -0
  197. package/src/credential/presentation/{03-get-request-object.ts → 04-get-request-object.ts} +33 -15
  198. package/src/credential/presentation/{04-send-authorization-response.ts → 05-send-authorization-response.ts} +1 -1
  199. package/src/credential/presentation/README.md +74 -2
  200. package/src/credential/presentation/index.ts +10 -2
  201. package/src/credential/presentation/types.ts +3 -3
  202. package/src/entity/openid-connect/issuer/index.ts +27 -0
  203. package/src/entity/openid-connect/issuer/types.ts +68 -0
  204. package/src/{trust → entity/trust}/chain.ts +2 -2
  205. package/src/{trust → entity/trust}/index.ts +1 -1
  206. package/src/{trust → entity/trust}/types.ts +2 -2
  207. package/src/index.ts +0 -2
  208. package/src/pid/sd-jwt/types.ts +1 -18
  209. package/src/sd-jwt/__test__/index.test.ts +47 -37
  210. package/src/sd-jwt/__test__/types.test.ts +26 -16
  211. package/src/sd-jwt/types.ts +16 -2
  212. package/src/utils/error-codes.ts +0 -12
  213. package/src/utils/errors.ts +12 -86
  214. package/src/utils/jwk.ts +5 -0
  215. package/src/utils/par.ts +3 -10
  216. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +0 -27
  217. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +0 -1
  218. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +0 -1
  219. package/lib/commonjs/credential/status/01-start-flow.js +0 -2
  220. package/lib/commonjs/credential/status/01-start-flow.js.map +0 -1
  221. package/lib/commonjs/credential/status/02-status-attestation.js +0 -72
  222. package/lib/commonjs/credential/status/02-status-attestation.js.map +0 -1
  223. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +0 -52
  224. package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
  225. package/lib/commonjs/credential/status/README.md +0 -67
  226. package/lib/commonjs/credential/status/index.js +0 -27
  227. package/lib/commonjs/credential/status/index.js.map +0 -1
  228. package/lib/commonjs/credential/status/types.js +0 -48
  229. package/lib/commonjs/credential/status/types.js.map +0 -1
  230. package/lib/commonjs/credential/trustmark/README.md +0 -62
  231. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +0 -81
  232. package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +0 -1
  233. package/lib/commonjs/credential/trustmark/index.js +0 -13
  234. package/lib/commonjs/credential/trustmark/index.js.map +0 -1
  235. package/lib/commonjs/trust/chain.js.map +0 -1
  236. package/lib/commonjs/trust/index.js.map +0 -1
  237. package/lib/commonjs/trust/types.js.map +0 -1
  238. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +0 -20
  239. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +0 -1
  240. package/lib/module/credential/presentation/03-get-request-object.js.map +0 -1
  241. package/lib/module/credential/status/01-start-flow.js +0 -2
  242. package/lib/module/credential/status/01-start-flow.js.map +0 -1
  243. package/lib/module/credential/status/02-status-attestation.js +0 -64
  244. package/lib/module/credential/status/02-status-attestation.js.map +0 -1
  245. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +0 -46
  246. package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
  247. package/lib/module/credential/status/README.md +0 -67
  248. package/lib/module/credential/status/index.js +0 -5
  249. package/lib/module/credential/status/index.js.map +0 -1
  250. package/lib/module/credential/status/types.js +0 -40
  251. package/lib/module/credential/status/types.js.map +0 -1
  252. package/lib/module/credential/trustmark/README.md +0 -62
  253. package/lib/module/credential/trustmark/get-credential-trustmark.js +0 -72
  254. package/lib/module/credential/trustmark/get-credential-trustmark.js.map +0 -1
  255. package/lib/module/credential/trustmark/index.js +0 -3
  256. package/lib/module/credential/trustmark/index.js.map +0 -1
  257. package/lib/module/trust/chain.js.map +0 -1
  258. package/lib/module/trust/index.js.map +0 -1
  259. package/lib/module/trust/types.js.map +0 -1
  260. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +0 -19
  261. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +0 -1
  262. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +0 -1
  263. package/lib/typescript/credential/status/01-start-flow.d.ts +0 -10
  264. package/lib/typescript/credential/status/01-start-flow.d.ts.map +0 -1
  265. package/lib/typescript/credential/status/02-status-attestation.d.ts +0 -19
  266. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +0 -1
  267. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +0 -24
  268. package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +0 -1
  269. package/lib/typescript/credential/status/index.d.ts +0 -7
  270. package/lib/typescript/credential/status/index.d.ts.map +0 -1
  271. package/lib/typescript/credential/status/types.d.ts +0 -305
  272. package/lib/typescript/credential/status/types.d.ts.map +0 -1
  273. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +0 -52
  274. package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +0 -1
  275. package/lib/typescript/credential/trustmark/index.d.ts +0 -4
  276. package/lib/typescript/credential/trustmark/index.d.ts.map +0 -1
  277. package/lib/typescript/trust/chain.d.ts.map +0 -1
  278. package/lib/typescript/trust/index.d.ts.map +0 -1
  279. package/src/credential/issuance/02-evaluate-issuer-trust.ts +0 -32
  280. package/src/credential/status/01-start-flow.ts +0 -9
  281. package/src/credential/status/02-status-attestation.ts +0 -102
  282. package/src/credential/status/03-verify-and-parse-status-attestation.ts +0 -60
  283. package/src/credential/status/README.md +0 -67
  284. package/src/credential/status/index.ts +0 -22
  285. package/src/credential/status/types.ts +0 -43
  286. package/src/credential/trustmark/README.md +0 -62
  287. package/src/credential/trustmark/get-credential-trustmark.ts +0 -120
  288. package/src/credential/trustmark/index.ts +0 -8
  289. /package/lib/typescript/{trust → entity/trust}/chain.d.ts +0 -0
@@ -1,5 +1,5 @@
1
- import { getRelyingPartyEntityConfiguration } from "../../trust";
2
- import { RelyingPartyEntityConfiguration } from "../../trust/types";
1
+ import { getRelyingPartyEntityConfiguration } from "../../entity/trust/index";
2
+ import { RelyingPartyEntityConfiguration } from "../../entity/trust/types";
3
3
  import type { StartFlow } from "../issuance/01-start-flow";
4
4
  import type { Out } from "../../utils/misc";
5
5
 
@@ -0,0 +1,73 @@
1
+ import { JWKS, JWK } from "../../utils/jwk";
2
+ import { hasStatusOrThrow } from "../../utils/misc";
3
+ import { RelyingPartyEntityConfiguration } from "../../entity/trust/types";
4
+
5
+ /**
6
+ * Defines the signature for a function that retrieves JSON Web Key Sets (JWKS) from a client.
7
+ *
8
+ * @template T - The tuple type representing the function arguments.
9
+ * @param args - The arguments passed to the function.
10
+ * @returns A promise resolving to an object containing an array of JWKs.
11
+ */
12
+ export type FetchJwks<T extends Array<unknown> = []> = (...args: T) => Promise<{
13
+ keys: JWK[];
14
+ }>;
15
+
16
+ /**
17
+ * Retrieves the JSON Web Key Set (JWKS) from the specified client's well-known endpoint.
18
+ *
19
+ * @param clientUrl - The base URL of the client entity from which to retrieve the JWKS.
20
+ * @param options - Optional context containing a custom fetch implementation.
21
+ * @param options.context - Optional context object.
22
+ * @param options.context.appFetch - Optional custom fetch function to use instead of the global `fetch`.
23
+ * @returns A promise resolving to an object containing an array of JWKs.
24
+ * @throws Will throw an error if the JWKS retrieval fails.
25
+ */
26
+ export const fetchJwksFromUri: FetchJwks<
27
+ [string, { context?: { appFetch?: GlobalFetch["fetch"] } }]
28
+ > = async (clientUrl, { context = {} } = {}) => {
29
+ const { appFetch = fetch } = context;
30
+
31
+ const wellKnownUrl = new URL(
32
+ "/.well-known/jar-issuer/jwk",
33
+ clientUrl
34
+ ).toString();
35
+
36
+ // Fetches the JWKS from a specific endpoint of the entity's well-known configuration
37
+ const jwks = await appFetch(wellKnownUrl, {
38
+ method: "GET",
39
+ })
40
+ .then(hasStatusOrThrow(200))
41
+ .then((raw) => raw.json())
42
+ .then((json) => JWKS.parse(json));
43
+
44
+ return {
45
+ keys: jwks.keys,
46
+ };
47
+ };
48
+
49
+ /**
50
+ * Retrieves the JSON Web Key Set (JWKS) from a Relying Party's entity configuration.
51
+ *
52
+ * @param rpConfig - The configuration object of the Relying Party entity.
53
+ * @returns An object containing an array of JWKs.
54
+ * @throws Will throw an error if the configuration is invalid or if JWKS is not found.
55
+ */
56
+ export const fetchJwksFromConfig: FetchJwks<
57
+ [RelyingPartyEntityConfiguration]
58
+ > = async (rpConfig) => {
59
+ const parsedConfig = RelyingPartyEntityConfiguration.safeParse(rpConfig);
60
+ if (!parsedConfig.success) {
61
+ throw new Error("Invalid Relying Party configuration.");
62
+ }
63
+
64
+ const jwks = parsedConfig.data.payload.metadata.wallet_relying_party.jwks;
65
+
66
+ if (!jwks || !Array.isArray(jwks.keys)) {
67
+ throw new Error("JWKS not found in Relying Party configuration.");
68
+ }
69
+
70
+ return {
71
+ keys: jwks.keys,
72
+ };
73
+ };
@@ -8,19 +8,19 @@ import {
8
8
 
9
9
  import { createDPopToken } from "../../utils/dpop";
10
10
  import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
11
- import type { EvaluateRelyingPartyTrust } from "./02-evaluate-rp-trust";
11
+ import type { FetchJwks } from "./03-retrieve-jwks";
12
12
  import { hasStatusOrThrow, type Out } from "../../utils/misc";
13
13
  import type { StartFlow } from "./01-start-flow";
14
14
  import { RequestObject } from "./types";
15
15
 
16
16
  export type GetRequestObject = (
17
17
  requestUri: Out<StartFlow>["requestURI"],
18
- rpConf: Out<EvaluateRelyingPartyTrust>["rpConf"],
19
18
  context: {
20
19
  wiaCryptoContext: CryptoContext;
21
20
  appFetch?: GlobalFetch["fetch"];
22
21
  walletInstanceAttestation: string;
23
- }
22
+ },
23
+ jwkKeys?: Out<FetchJwks>["keys"]
24
24
  ) => Promise<{ requestObject: RequestObject }>;
25
25
 
26
26
  /**
@@ -36,8 +36,8 @@ export type GetRequestObject = (
36
36
  */
37
37
  export const getRequestObject: GetRequestObject = async (
38
38
  requestUri,
39
- rpConf,
40
- { wiaCryptoContext, appFetch = fetch, walletInstanceAttestation }
39
+ { wiaCryptoContext, appFetch = fetch, walletInstanceAttestation },
40
+ jwkKeys
41
41
  ) => {
42
42
  const signedWalletInstanceDPoP = await createDPopToken(
43
43
  {
@@ -62,10 +62,24 @@ export const getRequestObject: GetRequestObject = async (
62
62
 
63
63
  const responseJwt = decodeJwt(responseEncodedJwt);
64
64
 
65
- // verify token signature according to RP's entity configuration
66
- // to ensure the request object is authentic
67
- {
68
- const pubKey = rpConf.wallet_relying_party.jwks.keys.find(
65
+ await verifyTokenSignature(jwkKeys, responseJwt);
66
+
67
+ // Ensure that the request object conforms to the expected specification.
68
+ const requestObject = RequestObject.parse(responseJwt.payload);
69
+
70
+ return {
71
+ requestObject,
72
+ };
73
+ };
74
+
75
+ const verifyTokenSignature = async (
76
+ jwkKeys?: Out<FetchJwks>["keys"],
77
+ responseJwt?: any
78
+ ): Promise<void> => {
79
+ // verify token signature to ensure the request object is authentic
80
+ // 1. according to entity configuration if present
81
+ if (jwkKeys) {
82
+ const pubKey = jwkKeys.find(
69
83
  ({ kid }) => kid === responseJwt.protectedHeader.kid
70
84
  );
71
85
  if (!pubKey) {
@@ -73,13 +87,17 @@ export const getRequestObject: GetRequestObject = async (
73
87
  "Request Object signature verification"
74
88
  );
75
89
  }
76
- await verify(responseEncodedJwt, pubKey);
90
+ await verify(responseJwt, pubKey);
91
+ return;
77
92
  }
78
93
 
79
- // Ensure that the request object conforms to the expected specification.
80
- const requestObject = RequestObject.parse(responseJwt.payload);
94
+ // 2. If jwk is not retrieved from entity config, check if the token contains the 'jwk' attribute
95
+ if (responseJwt.protectedHeader?.jwk) {
96
+ const pubKey = responseJwt.protectedHeader.jwk;
97
+ await verify(responseJwt, pubKey);
98
+ return;
99
+ }
81
100
 
82
- return {
83
- requestObject,
84
- };
101
+ // No verification condition matched: skipping signature verification for now.
102
+ // TODO: [EUDIW-215] Remove skipping signature verification
85
103
  };
@@ -4,7 +4,7 @@ import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
4
4
  import type { JWK } from "@pagopa/io-react-native-jwt/lib/typescript/types";
5
5
  import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
6
6
  import { hasStatusOrThrow, type Out } from "../../utils/misc";
7
- import type { GetRequestObject } from "./03-get-request-object";
7
+ import type { GetRequestObject } from "./04-get-request-object";
8
8
  import { disclose } from "../../sd-jwt";
9
9
  import type { EvaluateRelyingPartyTrust } from "./02-evaluate-rp-trust";
10
10
  import { type Presentation } from "./types";
@@ -1,3 +1,75 @@
1
- # Credential presentation
1
+ # Credential Presentation
2
2
 
3
- Currently this flow is outdated.
3
+ ## Sequence Diagram
4
+
5
+ ```mermaid
6
+ sequenceDiagram
7
+ autonumber
8
+ participant I as Individual using EUDI Wallet
9
+ participant O as Organisational Wallet (Verifier)
10
+ participant A as Organisational Wallet (Issuer)
11
+
12
+ O->>+I: QR-CODE: Authorisation request (`request_uri`)
13
+ I->>+O: GET: Request object, resolved from the `request_uri`
14
+ O->>+I: Respond with the Request object
15
+ I->>+O: GET: /.well-known/jar-issuer/jwk
16
+ O->>+I: Respond with the public key
17
+
18
+ I->>+O: POST: VP token response
19
+ O->>+A: GET: /.well-known/jwt-vc-issuer/jwk
20
+ A->>+O: Respond with the public key
21
+ O->>+I: Redirect: Authorisation response
22
+ ```
23
+
24
+ ## Mapped results
25
+
26
+ ## Examples
27
+
28
+ <details>
29
+ <summary>Remote Presentation flow</summary>
30
+
31
+ ```ts
32
+ // Scan e retrive qr-code
33
+ const qrcode = ...
34
+
35
+ // Retrieve the integrity key tag from the store and create its context
36
+ const integrityKeyTag = "example"; // Let's assume this is the key tag used to create the wallet instance
37
+ const integrityContext = getIntegrityContext(integrityKeyTag);
38
+
39
+ // Let's assume the key esists befor starting the presentation process
40
+ const wiaCryptoContext = createCryptoContextFor(WIA_KEYTAG);
41
+
42
+ const { WALLET_PROVIDER_BASE_URL, WALLET_EAA_PROVIDER_BASE_URL, REDIRECT_URI } =
43
+ env; // Let's assume these are the environment variables
44
+
45
+ /**
46
+ * Obtains a new Wallet Instance Attestation.
47
+ * WARNING: The integrity context must be the same used when creating the Wallet Instance with the same keytag.
48
+ */
49
+ const walletInstanceAttestation =
50
+ await WalletInstanceAttestation.getAttestation({
51
+ wiaCryptoContext,
52
+ integrityContext,
53
+ walletProviderBaseUrl: WALLET_PROVIDER_BASE_URL,
54
+ appFetch,
55
+ });
56
+
57
+ // Start the issuance flow
58
+ const { requestURI, clientId } = Credential.Presentation.startFlowFromQR(qrcode);
59
+
60
+ // If use trust federation: Evaluate issuer trust
61
+ const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(clientId);
62
+
63
+ // If use trust federation: Fetch Jwks from rpConf
64
+ const jwks = await Credential.Presentation.fetchJwksFromConfig(rpConf);
65
+
66
+ // If not use trust: Fetch Jwks from well-know
67
+ const jwks = await Credential.Presentation.fetchJwksFromUri(
68
+ requestURI,
69
+ appFetch,
70
+ );
71
+
72
+
73
+ ```
74
+
75
+ </details>
@@ -3,19 +3,26 @@ import {
3
3
  evaluateRelyingPartyTrust,
4
4
  type EvaluateRelyingPartyTrust,
5
5
  } from "./02-evaluate-rp-trust";
6
+ import {
7
+ fetchJwksFromUri,
8
+ fetchJwksFromConfig,
9
+ type FetchJwks,
10
+ } from "./03-retrieve-jwks";
6
11
  import {
7
12
  getRequestObject,
8
13
  type GetRequestObject,
9
- } from "./03-get-request-object";
14
+ } from "./04-get-request-object";
10
15
  import {
11
16
  sendAuthorizationResponse,
12
17
  type SendAuthorizationResponse,
13
- } from "./04-send-authorization-response";
18
+ } from "./05-send-authorization-response";
14
19
  import * as Errors from "./errors";
15
20
 
16
21
  export {
17
22
  startFlowFromQR,
18
23
  evaluateRelyingPartyTrust,
24
+ fetchJwksFromUri,
25
+ fetchJwksFromConfig,
19
26
  getRequestObject,
20
27
  sendAuthorizationResponse,
21
28
  Errors,
@@ -23,6 +30,7 @@ export {
23
30
  export type {
24
31
  StartFlow,
25
32
  EvaluateRelyingPartyTrust,
33
+ FetchJwks,
26
34
  GetRequestObject,
27
35
  SendAuthorizationResponse,
28
36
  };
@@ -13,15 +13,15 @@ export type Presentation = [
13
13
 
14
14
  export type RequestObject = z.infer<typeof RequestObject>;
15
15
  export const RequestObject = z.object({
16
- iss: z.string(),
16
+ iss: z.string().optional(), //optional by RFC 7519, mandatory for Potential
17
17
  iat: UnixTime,
18
- exp: UnixTime,
18
+ exp: UnixTime.optional(),
19
19
  state: z.string(),
20
20
  nonce: z.string(),
21
21
  response_uri: z.string(),
22
22
  response_type: z.literal("vp_token"),
23
23
  response_mode: z.literal("direct_post.jwt"),
24
24
  client_id: z.string(),
25
- client_id_scheme: z.literal("entity_id"),
25
+ client_id_scheme: z.string(), // previous z.literal("entity_id"),
26
26
  scope: z.string(),
27
27
  });
@@ -0,0 +1,27 @@
1
+ import { hasStatusOrThrow } from "../../../utils/misc";
2
+ import { CredentialIssuerConfiguration } from "./types";
3
+
4
+ /**
5
+ * Fetch the signed entity configuration token for an entity
6
+ *
7
+ * @param entityBaseUrl The url of the entity to fetch
8
+ * @param param.appFetch (optional) fetch api implemention
9
+ * @returns The signed Entity Configuration token
10
+ */
11
+ export async function getCredentialIssuerMetadata(
12
+ entityBaseUrl: string,
13
+ {
14
+ appFetch = fetch,
15
+ }: {
16
+ appFetch?: GlobalFetch["fetch"];
17
+ } = {}
18
+ ): Promise<CredentialIssuerConfiguration> {
19
+ const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-credential-issuer`;
20
+
21
+ return await appFetch(wellKnownUrl, {
22
+ method: "GET",
23
+ })
24
+ .then(hasStatusOrThrow(200))
25
+ .then((res) => res.json())
26
+ .then(CredentialIssuerConfiguration.parse);
27
+ }
@@ -0,0 +1,68 @@
1
+ import { JWK } from "../../../utils/jwk";
2
+ import * as z from "zod";
3
+
4
+ // Display metadata for a credential, used by the issuer to
5
+ // instruct the Wallet Solution on how to render the credential correctly
6
+ export type CredentialDisplay = z.infer<typeof CredentialDisplay>;
7
+ export const CredentialDisplay = z.object({
8
+ name: z.string(),
9
+ locale: z.string(),
10
+ logo: z
11
+ .object({
12
+ url: z.string(),
13
+ alt_text: z.string(),
14
+ })
15
+ .optional(),
16
+ background_color: z.string().optional(),
17
+ text_color: z.string().optional(),
18
+ });
19
+
20
+ export const CredentialClaimDisplay = z.object({
21
+ name: z.string(),
22
+ locale: z.string(),
23
+ });
24
+
25
+ export const CredentialFormat = z.union([
26
+ z.literal("vc+sd-jwt"),
27
+ z.literal("example+sd-jwt"),
28
+ ]);
29
+ const CredentialSdJwtClaims = z.record(
30
+ z.object({
31
+ mandatory: z.boolean(),
32
+ display: z.array(CredentialClaimDisplay),
33
+ })
34
+ );
35
+
36
+ export type CredentialConfigurationSupported = z.infer<
37
+ typeof CredentialConfigurationSupported
38
+ >;
39
+ export const CredentialConfigurationSupported = z.record(
40
+ z.object({
41
+ cryptographic_suites_supported: z.array(z.string()),
42
+ vct: z.string(),
43
+ scope: z.string(),
44
+ cryptographic_binding_methods_supported: z.array(z.string()),
45
+ display: z.array(CredentialDisplay),
46
+ format: CredentialFormat,
47
+ claims: CredentialSdJwtClaims,
48
+ })
49
+ );
50
+
51
+ export type CredentialIssuerKeys = z.infer<typeof CredentialIssuerKeys>;
52
+ export const CredentialIssuerKeys = z.object({
53
+ keys: z.array(JWK),
54
+ });
55
+
56
+ export type CredentialIssuerConfiguration = z.infer<
57
+ typeof CredentialIssuerConfiguration
58
+ >;
59
+ export const CredentialIssuerConfiguration = z.object({
60
+ credential_configurations_supported: CredentialConfigurationSupported,
61
+ pushed_authorization_request_endpoint: z.string(),
62
+ dpop_signing_alg_values_supported: z.array(z.string()),
63
+ jwks: CredentialIssuerKeys,
64
+ credential_issuer: z.string(),
65
+ authorization_endpoint: z.string(),
66
+ token_endpoint: z.string(),
67
+ credential_endpoint: z.string(),
68
+ });
@@ -7,8 +7,8 @@ import {
7
7
  EntityStatement,
8
8
  TrustAnchorEntityConfiguration,
9
9
  } from "./types";
10
- import { JWK } from "../utils/jwk";
11
- import { IoWalletError } from "../utils/errors";
10
+ import { JWK } from "../../utils/jwk";
11
+ import { IoWalletError } from "../../utils/errors";
12
12
  import * as z from "zod";
13
13
  import type { JWTDecodeResult } from "@pagopa/io-react-native-jwt/lib/typescript/types";
14
14
  import { getSignedEntityConfiguration, getSignedEntityStatement } from ".";
@@ -8,7 +8,7 @@ import {
8
8
  EntityStatement,
9
9
  } from "./types";
10
10
  import { validateTrustChain, renewTrustChain } from "./chain";
11
- import { hasStatusOrThrow } from "../utils/misc";
11
+ import { hasStatusOrThrow } from "../../utils/misc";
12
12
 
13
13
  export type {
14
14
  WalletProviderEntityConfiguration,
@@ -1,5 +1,5 @@
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
4
 
5
5
  export const TrustMark = z.object({ id: z.string(), trust_mark: z.string() });
package/src/index.ts CHANGED
@@ -9,7 +9,6 @@ import * as PID from "./pid";
9
9
  import * as SdJwt from "./sd-jwt";
10
10
  import * as Errors from "./utils/errors";
11
11
  import * as WalletInstanceAttestation from "./wallet-instance-attestation";
12
- import * as Trust from "./trust";
13
12
  import * as WalletInstance from "./wallet-instance";
14
13
  import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
15
14
  import { createCryptoContextFor } from "./utils/crypto";
@@ -22,7 +21,6 @@ export {
22
21
  WalletInstanceAttestation,
23
22
  WalletInstance,
24
23
  Errors,
25
- Trust,
26
24
  createCryptoContextFor,
27
25
  AuthorizationDetail,
28
26
  AuthorizationDetails,
@@ -1,22 +1,5 @@
1
1
  import { z } from "zod";
2
-
3
- const VerificationEvidence = z.object({
4
- type: z.string(),
5
- record: z.object({
6
- type: z.string(),
7
- source: z.object({
8
- organization_name: z.string(),
9
- organization_id: z.string(),
10
- country_code: z.string(),
11
- }),
12
- }),
13
- });
14
- type Verification = z.infer<typeof Verification>;
15
- const Verification = z.object({
16
- trustFramework: z.literal("eidas"),
17
- assuranceLevel: z.string(),
18
- evidence: z.array(VerificationEvidence),
19
- });
2
+ import { Verification } from "../../sd-jwt/types";
20
3
 
21
4
  /**
22
5
  * Data structure for the PID.
@@ -13,56 +13,66 @@ import { SdJwt4VC } from "../types";
13
13
  // - "address" is used as verification._sd
14
14
  // - all others disclosures are in claims._sd
15
15
  const token =
16
- "eyJraWQiOiItRl82VWdhOG4zVmVnalkyVTdZVUhLMXpMb2FELU5QVGM2M1JNSVNuTGF3IiwidHlwIjoidmMrc2Qtand0IiwiYWxnIjoiRVMyNTYifQ.eyJfc2QiOlsiMHExRDVKbWF2NnBRYUVoX0pfRmN2X3VOTk1RSWdDeWhRT3hxbFk0bDNxVSIsIktDSi1BVk52ODhkLXhqNnNVSUFPSnhGbmJVaDNySFhES2tJSDFsRnFiUnMiLCJNOWxvOVl4RE5JWHJBcTJxV2VpQ0E0MHpwSl96WWZGZFJfNEFFQUxjUnRVIiwiY3pnalVrMG5xUkNzd1NoQ2hDamRTNkExLXY0N2RfcVRDU0ZJdklIaE1vSSIsIm5HblFyN2NsbTN0ZlRwOHlqTF91SHJEU090elIyUFZiOFM3R2VMZEFxQlEiLCJ4TklWd2xwU3NhWjhDSlNmMGd6NXhfNzVWUldXYzZWMW1scGV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RpS2l6M0ptQUc5a3k3aDR0d1B1VWZ6WU9neTFiekx2OCJ9fSwiZXhwIjoxNzY4NDkwMTk2LCJpYXQiOjE3MzY5NTQxOTYsInZlcmlmaWNhdGlvbiI6eyJldmlkZW5jZSI6eyJtZXRob2QiOiJjaWUifSwidHJ1c3RfZnJhbWV3b3JrIjoiZWlkYXMiLCJhc3N1cmFuY2VfbGV2ZWwiOiJoaWdoIn0sInN0YXR1cyI6eyJzdGF0dXNfYXNzZXJ0aW9uIjp7ImNyZWRlbnRpYWxfaGFzaF9hbGciOiJzaGEtMjU2In19fQ";
20
20
 
21
21
  const signature =
22
- "qXHA2oqr8trX4fGxpxpUft2GX380TM3pzfo1MYAsDjUC8HsODA-4rdRWAvDe2zYP57x4tJU7eiABkd1Kmln9yQ";
22
+ "bDBz9xa_u1g27TEuGRjNdFCMXuVibXHeI-rpnSZ_NE7k2h4_Kcshk1Van-ttmJiDq3XFBGckl3nka_QVsMjaRMnURQP62URci3CCaFZUVu3zI4BsXp1oRhucPqq6BHl6sjZbDXALp2jViEQ862-frdFnCCEuQC0xMh-zYycpL60bHXHTaGYDzHafGQAwcwr3fyYwFZvfmLFEBoKmEawDrFC0Enfw7pE9EHP9jITxWRTIxn9NcVdnzki1FO-ERsjrDS2y-u2RK6uy6-_0kIx-1mDJ7krCkaxeol0zOLb7zJX8ooxC1QupSp1z457JKi7cPPoL1GWeTRoHFy_kZL_Jew";
23
23
 
24
24
  const signed = `${unsigned}.${signature}`;
25
25
 
26
26
  const tokenizedDisclosures = [
27
- "WyJrSkRFUDhFYU5URU1CRE9aelp6VDR3IiwidW5pcXVlX2lkIiwiVElOSVQtTFZMREFBODVUNTBHNzAyQiJd",
28
- "WyJ6SUF5VUZ2UGZJcEUxekJxeEk1aGFRIiwiYmlydGhfZGF0ZSIsIjE5ODUtMTItMTAiXQ",
29
- "WyJHcjNSM3MyOTBPa1FVbS1ORlR1OTZBIiwidGF4X2lkX2NvZGUiLCJUSU5JVC1MVkxEQUE4NVQ1MEc3MDJCIl0",
30
- "WyJHeE9SYWxNQWVsZlowZWRGSmpqWVV3IiwiZ2l2ZW5fbmFtZSIsIkFkYSJd",
31
- "WyJfdlY1UklrbDBJT0VYS290czlrdDF3IiwiZmFtaWx5X25hbWUiLCJMb3ZlbGFjZSJd",
32
- "WyJDajV0Y2NSNzJKd3J6ZTJUVzRhLXdnIiwiaWF0IiwxNzIwMDEwNTc1XQ",
27
+ "WyJacnBvZllXMWs2NEpuUE05WjdEWS1RIiwiZ2l2ZW5fbmFtZSIsIk1hcmlvIl0",
28
+ "WyJ4d0o1UWM2OTB1eEgyZ0VKMHFDV2dRIiwiZmFtaWx5X25hbWUiLCJSb3NzaSJd",
29
+ "WyJlV3ZwQXAtVkFHM0tBdkVGTEgxRGZ3IiwidW5pcXVlX2lkIiwiaWRBTlBSIl0",
30
+ "WyJHcXZJTzV5SVN3bjg4eDkzbE1aalpRIiwiYmlydGhkYXRlIiwiMTk4MC0xMC0wMSJd",
31
+ "WyJvUmprWWxPc1JvSGZ4eEh2WmZueDN3IiwidGF4X2lkX2NvZGUiLCJUSU5JVC1SU1NNUkE4MEExMEg1MDFBIl0",
32
+ "WyJzOXBvSENQcW83cVdsb3BkQXRZc0V3IiwiaWF0IiwxNzM2OTU0MTk2XQ",
33
33
  ];
34
34
 
35
35
  const sdJwt = {
36
36
  header: {
37
- kid: "-F_6Uga8n3VegjY2U7YUHK1zLoaD-NPTc63RMISnLaw",
37
+ kid: "eNN-g5i6CnLKcltQBp6abbioGMbzM6muW3vuxw6uh88",
38
38
  typ: "vc+sd-jwt",
39
- alg: "ES256",
39
+ alg: "RS256",
40
40
  },
41
41
  payload: {
42
+ sub: "sj1OpYiiLTVYANnBGNwSK2krMwqpWaz2iHmN1t0_Esg",
42
43
  _sd: [
43
- "0q1D5Jmav6pQaEh_J_Fcv_uNNMQIgCyhQOxqlY4l3qU",
44
- "KCJ-AVNv88d-xj6sUIAOJxFnbUh3rHXDKkIH1lFqbRs",
45
- "M9lo9YxDNIXrAq2qWeiCA40zpJ_zYfFdR_4AEALcRtU",
46
- "czgjUk0nqRCswShChCjdS6A1-v47d_qTCSFIvIHhMoI",
47
- "nGnQr7clm3tfTp8yjL_uHrDSOtzR2PVb8S7GeLdAqBQ",
48
- "xNIVwlpSsaZ8CJSf0gz5x_75VRWWc6V1mlpejdCrqUs",
44
+ "1UmtISsdd7udbFaFy-ViZ8dZFherbOGD2N3HlX4PIC8",
45
+ "Fmjs4qzc5vkeOAY5G20_ZPvU-1q-oXaV7Ax516CCMFk",
46
+ "Q3bagNzMeQh6EgwPBSHimbgQplmY_6v9SW4go2XAkgA",
47
+ "QVwkn71B4pWfCOzzlQl9HnxFSVdEHuW35zdTQQdFQGc",
48
+ "VVdR41A2KOOVzxYagZCGbVang7sSkegCeiuWf3DOtjs",
49
+ "vO2dvncmzlv37MQkmWudSDIHDE9YHd0EFB8xBTDVjz0",
49
50
  ],
50
- sub: "216f8946-9ecb-4819-9309-c076f34a7e11",
51
+ "vct#integrity":
52
+ "242302d97d38da2714a257f2a253bf2fa30aae5c109fe9581bfcda3b1d797c97",
51
53
  _sd_alg: "sha-256",
52
- vct: "PersonIdentificationData",
53
- iss: "https://pre.eid.wallet.ipzs.it",
54
+ vct: "urn:eu.europa.ec.eudi:pid:1",
55
+ iss: "https://api.potential-wallet-it-pid-provider.it",
54
56
  cnf: {
55
57
  jwk: {
56
58
  kty: "EC",
57
59
  crv: "P-256",
58
- kid: "Rv3W-EiKpvBTyk5yZxvrev-7MDB6SlzUCBo_CQjjddU",
59
- x: "0Wox7QtyPqByg35MH_XyCcnd5Le-Jm0AXHlUgDBA03Y",
60
- y: "eEhVvg1JPqNd3DTSa4mGDGBlwY6NP-EZbLbNFXSXwIg",
60
+ kid: "LegnFQ8lvhA6qyPutYv48nWWpSnO5tHigavywyds5S0",
61
+ x: "czZrN9lcNuc0q69X40n27c5jKpii0A-aYX_Pbo9pqBQ",
62
+ y: "YGKGaCJNWfTiKiz3JmAG9ky7h4twPuUfzYOgy1bzLv8",
61
63
  },
62
64
  },
63
- exp: 1751546576,
65
+ exp: 1768490196,
66
+ iat: 1736954196,
67
+ verification: {
68
+ evidence: {
69
+ method: "cie",
70
+ },
71
+ trust_framework: "eidas",
72
+ assurance_level: "high",
73
+ },
64
74
  status: {
65
- status_attestation: {
75
+ status_assertion: {
66
76
  credential_hash_alg: "sha-256",
67
77
  },
68
78
  },
@@ -71,12 +81,12 @@ const sdJwt = {
71
81
 
72
82
  // In the very same order than tokenizedDisclosures
73
83
  const disclosures = [
74
- ["kJDEP8EaNTEMBDOZzZzT4w", "unique_id", "TINIT-LVLDAA85T50G702B"],
75
- ["zIAyUFvPfIpE1zBqxI5haQ", "birth_date", "1985-12-10"],
76
- ["Gr3R3s290OkQUm-NFTu96A", "tax_id_code", "TINIT-LVLDAA85T50G702B"],
77
- ["GxORalMAelfZ0edFJjjYUw", "given_name", "Ada"],
78
- ["_vV5RIkl0IOEXKots9kt1w", "family_name", "Lovelace"],
79
- ["Cj5tccR72Jwrze2TW4a-wg", "iat", 1720010575],
84
+ ["ZrpofYW1k64JnPM9Z7DY-Q", "given_name", "Mario"],
85
+ ["xwJ5Qc690uxH2gEJ0qCWgQ", "family_name", "Rossi"],
86
+ ["eWvpAp-VAG3KAvEFLH1Dfw", "unique_id", "idANPR"],
87
+ ["GqvIO5yISwn88x93lMZjZQ", "birthdate", "1980-10-01"],
88
+ ["oRjkYlOsRoHfxxHvZfnx3w", "tax_id_code", "TINIT-RSSMRA80A10H501A"],
89
+ ["s9poHCPqo7qWlopdAtYsEw", "iat", 1736954196],
80
90
  ];
81
91
  it("Ensures example data correctness", () => {
82
92
  expect(
@@ -130,10 +140,10 @@ describe("decode", () => {
130
140
 
131
141
  describe("disclose", () => {
132
142
  it("should encode a valid sdjwt (one claim)", async () => {
133
- const result = await disclose(token, ["given_name"]);
143
+ const result = await disclose(token, ["unique_id"]);
134
144
  const expected = {
135
- token: `${signed}~WyJHeE9SYWxNQWVsZlowZWRGSmpqWVV3IiwiZ2l2ZW5fbmFtZSIsIkFkYSJd`,
136
- paths: [{ claim: "given_name", path: "verified_claims.claims._sd[3]" }],
145
+ token: `${signed}~WyJlV3ZwQXAtVkFHM0tBdkVGTEgxRGZ3IiwidW5pcXVlX2lkIiwiaWRBTlBSIl0`,
146
+ paths: [{ claim: "unique_id", path: "verified_claims.claims._sd[5]" }],
137
147
  };
138
148
 
139
149
  expect(result).toEqual(expected);
@@ -149,15 +159,15 @@ describe("disclose", () => {
149
159
  it("should encode a valid sdjwt (multiple claims)", async () => {
150
160
  const result = await disclose(token, ["iat", "family_name"]);
151
161
  const expected = {
152
- token: `${signed}~WyJfdlY1UklrbDBJT0VYS290czlrdDF3IiwiZmFtaWx5X25hbWUiLCJMb3ZlbGFjZSJd~WyJDajV0Y2NSNzJKd3J6ZTJUVzRhLXdnIiwiaWF0IiwxNzIwMDEwNTc1XQ`,
162
+ token: `${signed}~WyJ4d0o1UWM2OTB1eEgyZ0VKMHFDV2dRIiwiZmFtaWx5X25hbWUiLCJSb3NzaSJd~WyJzOXBvSENQcW83cVdsb3BkQXRZc0V3IiwiaWF0IiwxNzM2OTU0MTk2XQ`,
153
163
  paths: [
154
164
  {
155
165
  claim: "iat",
156
- path: "verified_claims.claims._sd[4]",
166
+ path: "verified_claims.claims._sd[1]",
157
167
  },
158
168
  {
159
169
  claim: "family_name",
160
- path: "verified_claims.claims._sd[0]",
170
+ path: "verified_claims.claims._sd[3]",
161
171
  },
162
172
  ],
163
173
  };