@pagopa/io-react-native-wallet 0.27.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -5,35 +5,45 @@ describe("SdJwt4VC", () => {
5
5
  // example provided at https://italia.github.io/eidas-it-wallet-docs/en/pid-data-model.html
6
6
  const token = {
7
7
  header: {
8
+ kid: "eNN-g5i6CnLKcltQBp6abbioGMbzM6muW3vuxw6uh88",
8
9
  typ: "vc+sd-jwt",
9
- alg: "RS512",
10
- kid: "dB67gL7ck3TFiIAf7N6_7SHvqk0MDYMEQcoGGlkUAAw",
10
+ alg: "RS256",
11
11
  },
12
12
  payload: {
13
+ sub: "sj1OpYiiLTVYANnBGNwSK2krMwqpWaz2iHmN1t0_Esg",
13
14
  _sd: [
14
- "0q1D5Jmav6pQaEh_J_Fcv_uNNMQIgCyhQOxqlY4l3qU",
15
- "KCJ-AVNv88d-xj6sUIAOJxFnbUh3rHXDKkIH1lFqbRs",
16
- "M9lo9YxDNIXrAq2qWeiCA40zpJ_zYfFdR_4AEALcRtU",
17
- "czgjUk0nqRCswShChCjdS6A1-v47d_qTCSFIvIHhMoI",
18
- "nGnQr7clm3tfTp8yjL_uHrDSOtzR2PVb8S7GeLdAqBQ",
19
- "xNIVwlpSsaZ8CJSf0gz5x_75VRWWc6V1mlpejdCrqUs",
15
+ "1UmtISsdd7udbFaFy-ViZ8dZFherbOGD2N3HlX4PIC8",
16
+ "Fmjs4qzc5vkeOAY5G20_ZPvU-1q-oXaV7Ax516CCMFk",
17
+ "Q3bagNzMeQh6EgwPBSHimbgQplmY_6v9SW4go2XAkgA",
18
+ "QVwkn71B4pWfCOzzlQl9HnxFSVdEHuW35zdTQQdFQGc",
19
+ "VVdR41A2KOOVzxYagZCGbVang7sSkegCeiuWf3DOtjs",
20
+ "vO2dvncmzlv37MQkmWudSDIHDE9YHd0EFB8xBTDVjz0",
20
21
  ],
21
- sub: "216f8946-9ecb-4819-9309-c076f34a7e11",
22
+ "vct#integrity":
23
+ "242302d97d38da2714a257f2a253bf2fa30aae5c109fe9581bfcda3b1d797c97",
22
24
  _sd_alg: "sha-256",
23
- vct: "PersonIdentificationData",
24
- iss: "https://pidprovider.example.com",
25
+ vct: "urn:eu.europa.ec.eudi:pid:1",
26
+ iss: "https://api.potential-wallet-it-pid-provider.it",
25
27
  cnf: {
26
28
  jwk: {
27
29
  kty: "EC",
28
30
  crv: "P-256",
29
- kid: "zEv_qGSL5r0_F67j2dwEgUJmBgbMNSEJ5K_iH1PYc7A",
30
- x: "0Pj7v_afNp9ETJx11JbYgkI7yQpd0rtiYuo5feuAN2o",
31
- y: "XB62Um02vHqedkOzSfJ5hdtjPz-zmV9jmWh4sKgdD9o",
31
+ kid: "LegnFQ8lvhA6qyPutYv48nWWpSnO5tHigavywyds5S0",
32
+ x: "czZrN9lcNuc0q69X40n27c5jKpii0A-aYX_Pbo9pqBQ",
33
+ y: "YGKGaCJNWfTiKiz3JmAG9ky7h4twPuUfzYOgy1bzLv8",
32
34
  },
33
35
  },
34
- exp: 1751107255,
36
+ exp: 1768490196,
37
+ iat: 1736954196,
38
+ verification: {
39
+ evidence: {
40
+ method: "cie",
41
+ },
42
+ trust_framework: "eidas",
43
+ assurance_level: "high",
44
+ },
35
45
  status: {
36
- status_attestation: {
46
+ status_assertion: {
37
47
  credential_hash_alg: "sha-256",
38
48
  },
39
49
  },
@@ -1,3 +1,4 @@
1
+ import { CredentialFormat } from "../entity/openid-connect/issuer/types";
1
2
  import { JWK } from "../utils/jwk";
2
3
  import { z } from "zod";
3
4
 
@@ -33,12 +34,23 @@ export type DisclosureWithEncoded = {
33
34
  encoded: string;
34
35
  };
35
36
 
37
+ export type Verification = z.infer<typeof Verification>;
38
+ export const Verification = z.object({
39
+ trust_framework: z.literal("eidas"),
40
+ assurance_level: z.string(),
41
+ evidence: z.object({
42
+ method: z.string(),
43
+ }),
44
+ });
45
+
36
46
  export type SdJwt4VC = z.infer<typeof SdJwt4VC>;
37
47
  export const SdJwt4VC = z.object({
38
48
  header: z.object({
39
- typ: z.literal("vc+sd-jwt"),
49
+ typ: CredentialFormat,
40
50
  alg: z.string(),
41
51
  kid: z.string().optional(),
52
+ x5c: z.string().optional(),
53
+ vctm: z.array(z.string()).optional(),
42
54
  }),
43
55
  payload: z.intersection(
44
56
  z.object({
@@ -48,7 +60,7 @@ export const SdJwt4VC = z.object({
48
60
  exp: UnixTime,
49
61
  _sd_alg: z.literal("sha-256"),
50
62
  status: z.object({
51
- status_attestation: z.object({
63
+ status_assertion: z.object({
52
64
  credential_hash_alg: z.literal("sha-256"),
53
65
  }),
54
66
  }),
@@ -56,6 +68,8 @@ export const SdJwt4VC = z.object({
56
68
  jwk: JWK,
57
69
  }),
58
70
  vct: z.string(),
71
+ "vct#integrity": z.string().optional(),
72
+ verification: Verification.optional(),
59
73
  }),
60
74
  ObfuscatedDisclosures
61
75
  ),
@@ -1,21 +1,9 @@
1
1
  export const IssuerResponseErrorCodes = {
2
2
  IssuerGenericError: "ERR_ISSUER_GENERIC_ERROR",
3
- /**
4
- * Error code thrown when a credential cannot be issued immediately because it follows the async flow.
5
- */
6
- CredentialIssuingNotSynchronous: "ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS",
7
3
  /**
8
4
  * Error code thrown when an error occurs while requesting a credential.
9
5
  */
10
6
  CredentialRequestFailed: "ERR_CREDENTIAL_REQUEST_FAILED",
11
- /**
12
- * Error code thrown when a credential status is invalid, either during issuance or when requesting a status attestation.
13
- */
14
- CredentialInvalidStatus: "ERR_CREDENTIAL_INVALID_STATUS",
15
- /**
16
- * Error code thrown when an error occurs while obtaining a status attestation for a credential.
17
- */
18
- StatusAttestationRequestFailed: "ERR_STATUS_ATTESTATION_REQUEST_FAILED",
19
7
  } as const;
20
8
 
21
9
  export const WalletProviderResponseErrorCodes = {
@@ -1,5 +1,4 @@
1
1
  import type { ProblemDetail } from "../client/generated/wallet-provider";
2
- import type { CredentialIssuerEntityConfiguration } from "../trust";
3
2
  import {
4
3
  IssuerResponseErrorCodes,
5
4
  WalletProviderResponseErrorCodes,
@@ -149,91 +148,6 @@ export class WalletProviderResponseError extends UnexpectedStatusCodeError {
149
148
  }
150
149
  }
151
150
 
152
- type LocalizedIssuanceError = {
153
- [locale: string]: {
154
- title: string;
155
- description: string;
156
- };
157
- };
158
-
159
- /**
160
- * Function to extract the error message from the Entity Configuration's supported error codes.
161
- * @param errorCode The error code to map to a meaningful message
162
- * @param issuerConf The entity configuration for credentials
163
- * @param credentialType The type of credential the error belongs to
164
- * @returns A localized error {@link LocalizedIssuanceError} or undefined
165
- * @throws {IoWalletError} When no credential config is found
166
- */
167
- export function extractErrorMessageFromIssuerConf(
168
- errorCode: string,
169
- {
170
- issuerConf,
171
- credentialType,
172
- }: {
173
- issuerConf: CredentialIssuerEntityConfiguration["payload"]["metadata"];
174
- credentialType: string;
175
- }
176
- ): LocalizedIssuanceError | undefined {
177
- const credentialConfiguration =
178
- issuerConf.openid_credential_issuer.credential_configurations_supported[
179
- credentialType
180
- ];
181
-
182
- if (!credentialConfiguration) {
183
- throw new IoWalletError(
184
- `No configuration found for ${credentialType} in the provided EC`
185
- );
186
- }
187
-
188
- const { issuance_errors_supported } = credentialConfiguration;
189
-
190
- if (!issuance_errors_supported?.[errorCode]) {
191
- return undefined;
192
- }
193
-
194
- const localesList = issuance_errors_supported[errorCode]!.display;
195
-
196
- return localesList.reduce(
197
- (acc, { locale, ...rest }) => ({ ...acc, [locale]: rest }),
198
- {} as LocalizedIssuanceError
199
- );
200
- }
201
-
202
- /**
203
- * Type guard for issuer errors.
204
- * @param error The error to check
205
- * @param code Optional code to narrow down the issuer error
206
- */
207
- export const isIssuerResponseError = (
208
- error: unknown,
209
- code?: IssuerResponseErrorCode
210
- ): error is IssuerResponseError =>
211
- error instanceof IssuerResponseError && error.code === (code ?? error.code);
212
-
213
- /**
214
- * Type guard for wallet provider errors.
215
- * @param error The error to check
216
- * @param code Optional code to narrow down the wallet provider error
217
- */
218
- export const isWalletProviderResponseError = (
219
- error: unknown,
220
- code?: WalletProviderResponseErrorCode
221
- ): error is WalletProviderResponseError =>
222
- error instanceof WalletProviderResponseError &&
223
- error.code === (code ?? error.code);
224
-
225
- type ErrorCodeMap<T> = T extends typeof IssuerResponseError
226
- ? IssuerResponseErrorCode
227
- : T extends typeof WalletProviderResponseError
228
- ? WalletProviderResponseErrorCode
229
- : never;
230
-
231
- type ErrorCase<T> = {
232
- code: ErrorCodeMap<T>;
233
- message: string;
234
- reason?: GenericErrorReason;
235
- };
236
-
237
151
  /**
238
152
  * Builder class used to create specialized errors from type {@link UnexpectedStatusCodeError} that handles multiple status codes.
239
153
  *
@@ -271,3 +185,15 @@ export class ResponseErrorBuilder<T extends typeof UnexpectedStatusCodeError> {
271
185
  return originalError;
272
186
  }
273
187
  }
188
+
189
+ type ErrorCodeMap<T> = T extends typeof IssuerResponseError
190
+ ? IssuerResponseErrorCode
191
+ : T extends typeof WalletProviderResponseError
192
+ ? WalletProviderResponseErrorCode
193
+ : never;
194
+
195
+ type ErrorCase<T> = {
196
+ code: ErrorCodeMap<T>;
197
+ message: string;
198
+ reason?: GenericErrorReason;
199
+ };
package/src/utils/jwk.ts CHANGED
@@ -58,3 +58,8 @@ export function fixBase64EncodingOnKey(key: JWK): JWK {
58
58
  ...(n ? { n: removePadding(n) } : {}),
59
59
  };
60
60
  }
61
+
62
+ export type JWKS = z.infer<typeof JWKS>;
63
+ export const JWKS = z.object({
64
+ keys: z.array(JWK),
65
+ });
package/src/utils/par.ts CHANGED
@@ -13,7 +13,6 @@ import { IssuerResponseError } from "./errors";
13
13
  export type AuthorizationDetail = z.infer<typeof AuthorizationDetail>;
14
14
  export const AuthorizationDetail = z.object({
15
15
  credential_configuration_id: z.string(),
16
- format: z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]),
17
16
  type: z.literal("openid_credential"),
18
17
  });
19
18
 
@@ -38,8 +37,7 @@ export const makeParRequest =
38
37
  responseMode: string,
39
38
  parEndpoint: string,
40
39
  walletInstanceAttestation: string,
41
- authorizationDetails: AuthorizationDetails,
42
- assertionType: string
40
+ authorizationDetails: AuthorizationDetails
43
41
  ): Promise<string> => {
44
42
  const wiaPublicKey = await wiaCryptoContext.getPublicKey();
45
43
 
@@ -85,8 +83,6 @@ export const makeParRequest =
85
83
  code_challenge_method: codeChallengeMethod,
86
84
  authorization_details: authorizationDetails,
87
85
  redirect_uri: redirectUri,
88
- client_assertion_type: assertionType,
89
- client_assertion: walletInstanceAttestation + "~" + signedWiaPoP,
90
86
  })
91
87
  .setIssuedAt() //iat is set to now
92
88
  .setExpirationTime("5min")
@@ -94,19 +90,16 @@ export const makeParRequest =
94
90
 
95
91
  /** The request body for the Pushed Authorization Request */
96
92
  var formBody = new URLSearchParams({
97
- response_type: "code",
98
93
  client_id: clientId,
99
- code_challenge: codeChallenge,
100
- code_challenge_method: "S256",
101
94
  request: signedJwtForPar,
102
- client_assertion_type: assertionType,
103
- client_assertion: walletInstanceAttestation + "~" + signedWiaPoP,
104
95
  });
105
96
 
106
97
  return await appFetch(parEndpoint, {
107
98
  method: "POST",
108
99
  headers: {
109
100
  "Content-Type": "application/x-www-form-urlencoded",
101
+ "OAuth-Client-Attestation": walletInstanceAttestation,
102
+ "OAuth-Client-Attestation-PoP": signedWiaPoP,
110
103
  },
111
104
  body: formBody.toString(),
112
105
  })
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.evaluateIssuerTrust = void 0;
7
- var _trust = require("../../trust");
8
- /**
9
- * WARNING: This function must be called after {@link startFlow}. The next function to be called is {@link startUserAuthorization}.
10
- * The Issuer trust evaluation phase.
11
- * Fetch the Issuer's configuration and verify trust.
12
- *
13
- * @param issuerUrl The base url of the Issuer returned by {@link startFlow}
14
- * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
15
- * @returns The Issuer's configuration
16
- */
17
- const evaluateIssuerTrust = async function (issuerUrl) {
18
- let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
- const issuerConf = await (0, _trust.getCredentialIssuerEntityConfiguration)(issuerUrl, {
20
- appFetch: context.appFetch
21
- }).then(_ => _.payload.metadata);
22
- return {
23
- issuerConf
24
- };
25
- };
26
- exports.evaluateIssuerTrust = evaluateIssuerTrust;
27
- //# sourceMappingURL=02-evaluate-issuer-trust.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_trust","require","evaluateIssuerTrust","issuerUrl","context","arguments","length","undefined","issuerConf","getCredentialIssuerEntityConfiguration","appFetch","then","_","payload","metadata","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/02-evaluate-issuer-trust.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAwC,GAAG,eAAAA,CACtDC,SAAS,EAEN;EAAA,IADHC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEZ,MAAMG,UAAU,GAAG,MAAM,IAAAC,6CAAsC,EAACN,SAAS,EAAE;IACzEO,QAAQ,EAAEN,OAAO,CAACM;EACpB,CAAC,CAAC,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,OAAO,CAACC,QAAQ,CAAC;EAClC,OAAO;IAAEN;EAAW,CAAC;AACvB,CAAC;AAACO,OAAA,CAAAb,mBAAA,GAAAA,mBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNativeUuid","_interopRequireDefault","require","_ioReactNativeJwt","_dpop","_errors","_misc","_types","obj","__esModule","default","getRequestObject","requestUri","rpConf","_ref","wiaCryptoContext","appFetch","fetch","walletInstanceAttestation","signedWalletInstanceDPoP","createDPopToken","jti","uuid","v4","htm","htu","ath","sha256ToBase64","responseEncodedJwt","method","headers","Authorization","DPoP","then","hasStatusOrThrow","res","json","responseJson","response","responseJwt","decodeJwt","pubKey","wallet_relying_party","jwks","keys","find","_ref2","kid","protectedHeader","NoSuitableKeysFoundInEntityConfiguration","verify","requestObject","RequestObject","parse","payload","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAAwC,SAAAD,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAYxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,gBAAkC,GAAG,MAAAA,CAChDC,UAAU,EACVC,MAAM,EAAAC,IAAA,KAEH;EAAA,IADH;IAAEC,gBAAgB;IAAEC,QAAQ,GAAGC,KAAK;IAAEC;EAA0B,CAAC,GAAAJ,IAAA;EAEjE,MAAMK,wBAAwB,GAAG,MAAM,IAAAC,qBAAe,EACpD;IACEC,GAAG,EAAG,GAAEC,wBAAI,CAACC,EAAE,CAAC,CAAE,EAAC;IACnBC,GAAG,EAAE,KAAK;IACVC,GAAG,EAAEb,UAAU;IACfc,GAAG,EAAE,MAAM,IAAAC,gCAAc,EAACT,yBAAyB;EACrD,CAAC,EACDH,gBACF,CAAC;EAED,MAAMa,kBAAkB,GAAG,MAAMZ,QAAQ,CAACJ,UAAU,EAAE;IACpDiB,MAAM,EAAE,KAAK;IACbC,OAAO,EAAE;MACPC,aAAa,EAAG,QAAOb,yBAA0B,EAAC;MAClDc,IAAI,EAAEb;IACR;EACF,CAAC,CAAC,CACCc,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,CAAC,CAAC,CAC3BD,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBH,IAAI,CAAEI,YAAY,IAAKA,YAAY,CAACC,QAAQ,CAAC;EAEhD,MAAMC,WAAW,GAAG,IAAAC,wBAAS,EAACZ,kBAAkB,CAAC;;EAEjD;EACA;EACA;IACE,MAAMa,MAAM,GAAG5B,MAAM,CAAC6B,oBAAoB,CAACC,IAAI,CAACC,IAAI,CAACC,IAAI,CACvDC,KAAA;MAAA,IAAC;QAAEC;MAAI,CAAC,GAAAD,KAAA;MAAA,OAAKC,GAAG,KAAKR,WAAW,CAACS,eAAe,CAACD,GAAG;IAAA,CACtD,CAAC;IACD,IAAI,CAACN,MAAM,EAAE;MACX,MAAM,IAAIQ,gDAAwC,CAChD,uCACF,CAAC;IACH;IACA,MAAM,IAAAC,wBAAM,EAACtB,kBAAkB,EAAEa,MAAM,CAAC;EAC1C;;EAEA;EACA,MAAMU,aAAa,GAAGC,oBAAa,CAACC,KAAK,CAACd,WAAW,CAACe,OAAO,CAAC;EAE9D,OAAO;IACLH;EACF,CAAC;AACH,CAAC;AAACI,OAAA,CAAA5C,gBAAA,GAAAA,gBAAA"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=01-start-flow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/status/01-start-flow.ts"],"mappings":""}
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.statusAttestation = void 0;
7
- var _misc = require("../../utils/misc");
8
- var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
9
- var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
10
- var _types = require("./types");
11
- var _errors = require("../../utils/errors");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- /**
14
- * WARNING: This function must be called after {@link startFlow}.
15
- * Verify the status of the credential attestation.
16
- * @param issuerConf - The issuer's configuration
17
- * @param credential - The credential to be verified
18
- * @param credentialCryptoContext - The credential's crypto context
19
- * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
20
- * @throws {IssuerResponseError} with a specific code for more context
21
- * @returns The credential status attestation
22
- */
23
- const statusAttestation = async function (issuerConf, credential, credentialCryptoContext) {
24
- let appFetch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : fetch;
25
- const jwk = await credentialCryptoContext.getPublicKey();
26
- const credentialHash = await (0, _misc.getCredentialHashWithouDiscloures)(credential);
27
- const statusAttUrl = issuerConf.openid_credential_issuer.status_attestation_endpoint;
28
- const credentialPop = await new _ioReactNativeJwt.SignJWT(credentialCryptoContext).setPayload({
29
- aud: statusAttUrl,
30
- jti: _reactNativeUuid.default.v4().toString(),
31
- credential_hash: credentialHash,
32
- credential_hash_alg: "S256"
33
- }).setProtectedHeader({
34
- alg: "ES256",
35
- typ: "status-attestation-request+jwt",
36
- kid: jwk.kid
37
- }).setIssuedAt().setExpirationTime("5m").sign();
38
- const body = {
39
- credential_pop: credentialPop
40
- };
41
- const result = await appFetch(statusAttUrl, {
42
- method: "POST",
43
- headers: {
44
- "Content-Type": "application/json"
45
- },
46
- body: JSON.stringify(body)
47
- }).then((0, _misc.hasStatusOrThrow)(201)).then(raw => raw.json()).then(json => _types.StatusAttestationResponse.parse(json)).catch(handleStatusAttestationError);
48
- return {
49
- statusAttestation: result.status_attestation
50
- };
51
- };
52
-
53
- /**
54
- * Handle the status attestation error by mapping it to a custom exception.
55
- * If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
56
- * @param e - The error to be handled
57
- * @throws {IssuerResponseError} with a specific code for more context
58
- */
59
- exports.statusAttestation = statusAttestation;
60
- const handleStatusAttestationError = e => {
61
- if (!(e instanceof _errors.UnexpectedStatusCodeError)) {
62
- throw e;
63
- }
64
- throw new _errors.ResponseErrorBuilder(_errors.IssuerResponseError).handle(404, {
65
- code: _errors.IssuerResponseErrorCodes.CredentialInvalidStatus,
66
- message: "Invalid status found for the given credential"
67
- }).handle("*", {
68
- code: _errors.IssuerResponseErrorCodes.StatusAttestationRequestFailed,
69
- message: `Unable to obtain the status attestation for the given credential`
70
- }).buildFrom(e);
71
- };
72
- //# sourceMappingURL=02-status-attestation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_misc","require","_ioReactNativeJwt","_reactNativeUuid","_interopRequireDefault","_types","_errors","obj","__esModule","default","statusAttestation","issuerConf","credential","credentialCryptoContext","appFetch","arguments","length","undefined","fetch","jwk","getPublicKey","credentialHash","getCredentialHashWithouDiscloures","statusAttUrl","openid_credential_issuer","status_attestation_endpoint","credentialPop","SignJWT","setPayload","aud","jti","uuid","v4","toString","credential_hash","credential_hash_alg","setProtectedHeader","alg","typ","kid","setIssuedAt","setExpirationTime","sign","body","credential_pop","result","method","headers","JSON","stringify","then","hasStatusOrThrow","raw","json","StatusAttestationResponse","parse","catch","handleStatusAttestationError","status_attestation","exports","e","UnexpectedStatusCodeError","ResponseErrorBuilder","IssuerResponseError","handle","code","IssuerResponseErrorCodes","CredentialInvalidStatus","message","StatusAttestationRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/status/02-status-attestation.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAK4B,SAAAG,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAA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,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBH,IAAI,CAAEG,IAAI,IAAKC,gCAAyB,CAACC,KAAK,CAACF,IAAI,CAAC,CAAC,CACrDG,KAAK,CAACC,4BAA4B,CAAC;EAEtC,OAAO;IAAE/C,iBAAiB,EAAEmC,MAAM,CAACa;EAAmB,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAC,OAAA,CAAAjD,iBAAA,GAAAA,iBAAA;AAMA,MAAM+C,4BAA4B,GAAIG,CAAU,IAAK;EACnD,IAAI,EAAEA,CAAC,YAAYC,iCAAyB,CAAC,EAAE;IAC7C,MAAMD,CAAC;EACT;EAEA,MAAM,IAAIE,4BAAoB,CAACC,2BAAmB,CAAC,CAChDC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACC,uBAAuB;IACtDC,OAAO,EAAE;EACX,CAAC,CAAC,CACDJ,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACG,8BAA8B;IAC7DD,OAAO,EAAG;EACZ,CAAC,CAAC,CACDE,SAAS,CAACV,CAAC,CAAC;AACjB,CAAC"}
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.verifyAndParseStatusAttestation = void 0;
7
- var _errors = require("../../utils/errors");
8
- var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
9
- var _types = require("./types");
10
- /**
11
- * Given a status attestation, verifies that:
12
- * - It's in the supported format;
13
- * - The attestation is correctly signed;
14
- * - It's bound to the given key.
15
- * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
16
- * @param statusAttestation The encoded status attestation returned by {@link statusAttestation}
17
- * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
18
- * @returns A parsed status attestation
19
- * @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
20
- * @throws {IoWalletError} If the credential is not bound to the provided user key
21
- * @throws {IoWalletError} If the credential data fail to parse
22
- */
23
- const verifyAndParseStatusAttestation = async (issuerConf, rawStatusAttestation, context) => {
24
- try {
25
- const {
26
- statusAttestation
27
- } = rawStatusAttestation;
28
- const {
29
- credentialCryptoContext
30
- } = context;
31
- await (0, _ioReactNativeJwt.verify)(statusAttestation, issuerConf.openid_credential_issuer.jwks.keys);
32
- const decodedJwt = (0, _ioReactNativeJwt.decode)(statusAttestation);
33
- const parsedStatusAttestation = _types.ParsedStatusAttestation.parse({
34
- header: decodedJwt.protectedHeader,
35
- payload: decodedJwt.payload
36
- });
37
- const holderBindingKey = await credentialCryptoContext.getPublicKey();
38
- const {
39
- cnf
40
- } = parsedStatusAttestation.payload;
41
- if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
42
- throw new _errors.IoWalletError(`Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`);
43
- }
44
- return {
45
- parsedStatusAttestation
46
- };
47
- } catch (e) {
48
- throw new _errors.IoWalletError(`Failed to verify status attestation: ${JSON.stringify(e)}`);
49
- }
50
- };
51
- exports.verifyAndParseStatusAttestation = verifyAndParseStatusAttestation;
52
- //# sourceMappingURL=03-verify-and-parse-status-attestation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_errors","require","_ioReactNativeJwt","_types","verifyAndParseStatusAttestation","issuerConf","rawStatusAttestation","context","statusAttestation","credentialCryptoContext","verify","openid_credential_issuer","jwks","keys","decodedJwt","decodeJwt","parsedStatusAttestation","ParsedStatusAttestation","parse","header","protectedHeader","payload","holderBindingKey","getPublicKey","cnf","jwk","kid","IoWalletError","e","JSON","stringify","exports"],"sourceRoot":"../../../../src","sources":["credential/status/03-verify-and-parse-status-attestation.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,MAA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ow is used to obtain a credential status attestation from its credential issuer. Each step in the flow is imported from the related file which is named with a sequential number.
4
- The credential status attestation is a JWT which contains the credential status which indicates if the credential is valid or not.
5
- The status attestation is supposed to be stored securely along with the credential. It has a limited lifetime and should be refreshed periodically according to the `exp` field in the JWT payload.
6
-
7
- ## Sequence Diagram
8
-
9
- ```mermaid
10
- graph TD;
11
- 0[startFlow]
12
- 1[statusAttestation]
13
- 2[verifyAndParseStatusAttestation]
14
-
15
- 0 --> 1
16
- 1 --> 2
17
- ```
18
-
19
-
20
- ## Mapped results
21
-
22
- The following errors are mapped to a `IssuerResponseError` with specific codes.
23
-
24
- |HTTP Status|Error Code|Description|
25
- |-----------|----------|-----------|
26
- |`404 Not Found`|`ERR_CREDENTIAL_INVALID_STATUS`|This response is returned by the credential issuer when the status attestation is invalid. It might contain more details in the `reason` property.|
27
-
28
- ## Example
29
-
30
- <details>
31
- <summary>Credential status attestation flow</summary>
32
-
33
- ```ts
34
- // Start the issuance flow
35
- const credentialIssuerUrl = "https://issuer.example.com";
36
- const startFlow: Credential.Status.StartFlow = () => ({
37
- issuerUrl: credentialIssuerUrl, // Let's assum
38
- });
39
-
40
- const { issuerUrl } = startFlow();
41
-
42
- // Evaluate issuer trust
43
- const { issuerConf } = await Credential.Status.evaluateIssuerTrust(issuerUrl);
44
-
45
- // Get the credential attestation
46
- const res = await Credential.Status.statusAttestation(
47
- issuerConf,
48
- credential,
49
- credentialCryptoContext
50
- );
51
-
52
- // Verify and parse the status attestation
53
- const { parsedStatusAttestation } =
54
- await Credential.Status.verifyAndParseStatusAttestation(
55
- issuerConf,
56
- res.statusAttestation,
57
- { credentialCryptoContext }
58
- );
59
-
60
- return {
61
- statusAttestation: res.statusAttestation,
62
- parsedStatusAttestation,
63
- credentialType,
64
- };
65
- ```
66
-
67
- </details>
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "evaluateIssuerTrust", {
7
- enumerable: true,
8
- get: function () {
9
- return _issuance.evaluateIssuerTrust;
10
- }
11
- });
12
- Object.defineProperty(exports, "statusAttestation", {
13
- enumerable: true,
14
- get: function () {
15
- return _statusAttestation.statusAttestation;
16
- }
17
- });
18
- Object.defineProperty(exports, "verifyAndParseStatusAttestation", {
19
- enumerable: true,
20
- get: function () {
21
- return _verifyAndParseStatusAttestation.verifyAndParseStatusAttestation;
22
- }
23
- });
24
- var _statusAttestation = require("./02-status-attestation");
25
- var _issuance = require("../issuance");
26
- var _verifyAndParseStatusAttestation = require("./03-verify-and-parse-status-attestation");
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_statusAttestation","require","_issuance","_verifyAndParseStatusAttestation"],"sourceRoot":"../../../../src","sources":["credential/status/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,gCAAA,GAAAF,OAAA"}
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.StatusAttestationResponse = exports.ParsedStatusAttestation = void 0;
7
- var _types = require("../../sd-jwt/types");
8
- var _jwk = require("../../utils/jwk");
9
- var z = _interopRequireWildcard(require("zod"));
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
- /**
13
- * Shape from parsing a status attestation response in case of 201.
14
- */
15
- const StatusAttestationResponse = z.object({
16
- status_attestation: z.string()
17
- });
18
-
19
- /**
20
- * Type from parsing a status attestation response in case of 201.
21
- * Inferred from {@link StatusAttestationResponse}.
22
- */
23
-
24
- /**
25
- * Type for a parsed status attestation.
26
- */
27
- exports.StatusAttestationResponse = StatusAttestationResponse;
28
- /**
29
- * Shape for parsing a status attestation in a JWT.
30
- */
31
- const ParsedStatusAttestation = z.object({
32
- header: z.object({
33
- typ: z.literal("status-attestation+jwt"),
34
- alg: z.string(),
35
- kid: z.string().optional()
36
- }),
37
- payload: z.object({
38
- credential_hash_alg: z.string(),
39
- credential_hash: z.string(),
40
- cnf: z.object({
41
- jwk: _jwk.JWK
42
- }),
43
- exp: _types.UnixTime,
44
- iat: _types.UnixTime
45
- })
46
- });
47
- exports.ParsedStatusAttestation = ParsedStatusAttestation;
48
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_types","require","_jwk","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StatusAttestationResponse","object","status_attestation","string","exports","ParsedStatusAttestation","header","typ","literal","alg","kid","optional","payload","credential_hash_alg","credential_hash","cnf","jwk","JWK","exp","UnixTime","iat"],"sourceRoot":"../../../../src","sources":["credential/status/types.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OA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