@pagopa/io-react-native-wallet 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/lib/commonjs/credential/issuance/common/02-start-user-authorization.js +4 -3
  2. package/lib/commonjs/credential/issuance/common/02-start-user-authorization.js.map +1 -1
  3. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js +37 -8
  4. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/mrtd-pop/02-init-challenge.js +46 -38
  6. package/lib/commonjs/credential/issuance/mrtd-pop/02-init-challenge.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/mrtd-pop/03-validate-challenge.js +58 -51
  8. package/lib/commonjs/credential/issuance/mrtd-pop/03-validate-challenge.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/mrtd-pop/index.js +21 -5
  10. package/lib/commonjs/credential/issuance/mrtd-pop/index.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/v1.0.0/02-start-user-authorization.js +3 -3
  12. package/lib/commonjs/credential/issuance/v1.0.0/02-start-user-authorization.js.map +1 -1
  13. package/lib/commonjs/credential/issuance/v1.0.0/index.js +1 -1
  14. package/lib/commonjs/credential/issuance/v1.0.0/index.js.map +1 -1
  15. package/lib/commonjs/credential/issuance/v1.0.0/mappers.js +1 -1
  16. package/lib/commonjs/credential/issuance/v1.0.0/mappers.js.map +1 -1
  17. package/lib/commonjs/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js +0 -2
  18. package/lib/commonjs/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js.map +1 -1
  19. package/lib/commonjs/credential/issuance/v1.3.3/02-start-user-authorization.js +20 -16
  20. package/lib/commonjs/credential/issuance/v1.3.3/02-start-user-authorization.js.map +1 -1
  21. package/lib/commonjs/credential/issuance/v1.3.3/04-authorize-access.js +20 -19
  22. package/lib/commonjs/credential/issuance/v1.3.3/04-authorize-access.js.map +1 -1
  23. package/lib/commonjs/credential/issuance/v1.3.3/05-obtain-credential.js +4 -6
  24. package/lib/commonjs/credential/issuance/v1.3.3/05-obtain-credential.js.map +1 -1
  25. package/lib/commonjs/credential/issuance/v1.3.3/06-verify-and-parse-credential.js +4 -1
  26. package/lib/commonjs/credential/issuance/v1.3.3/06-verify-and-parse-credential.js.map +1 -1
  27. package/lib/commonjs/credential/issuance/v1.3.3/index.js +1 -1
  28. package/lib/commonjs/credential/issuance/v1.3.3/index.js.map +1 -1
  29. package/lib/commonjs/credential/issuance/v1.3.3/mappers.js +1 -1
  30. package/lib/commonjs/credential/issuance/v1.3.3/mappers.js.map +1 -1
  31. package/lib/commonjs/credential/presentation/{v1.3.3/utils.mdoc.js → common/utils/mdoc.js} +2 -2
  32. package/lib/commonjs/credential/presentation/common/utils/mdoc.js.map +1 -0
  33. package/lib/commonjs/credential/presentation/v1.3.3/06-evaluate-dcql-query.js +2 -2
  34. package/lib/commonjs/credential/presentation/v1.3.3/06-evaluate-dcql-query.js.map +1 -1
  35. package/lib/commonjs/credential/status/README.md +3 -2
  36. package/lib/commonjs/credential/status/v1.3.3/01-status-list.js +27 -5
  37. package/lib/commonjs/credential/status/v1.3.3/01-status-list.js.map +1 -1
  38. package/lib/commonjs/credential/status/v1.3.3/02-verify-and-parse-status-list.js +17 -6
  39. package/lib/commonjs/credential/status/v1.3.3/02-verify-and-parse-status-list.js.map +1 -1
  40. package/lib/commonjs/mdoc/index.js +3 -24
  41. package/lib/commonjs/mdoc/index.js.map +1 -1
  42. package/lib/commonjs/sd-jwt/__test__/types.test.js +2 -14
  43. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  44. package/lib/commonjs/sd-jwt/__test__/utils.test.js +0 -12
  45. package/lib/commonjs/sd-jwt/__test__/utils.test.js.map +1 -1
  46. package/lib/commonjs/sd-jwt/types.js +1 -14
  47. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  48. package/lib/commonjs/utils/callbacks.js +20 -1
  49. package/lib/commonjs/utils/callbacks.js.map +1 -1
  50. package/lib/commonjs/utils/x509.js +34 -0
  51. package/lib/commonjs/utils/x509.js.map +1 -0
  52. package/lib/commonjs/wallet-instance-attestation/api/types.js +0 -2
  53. package/lib/commonjs/wallet-instance-attestation/api/types.js.map +1 -1
  54. package/lib/commonjs/wallet-instance-attestation/v1.3.3/mappers.js +1 -14
  55. package/lib/commonjs/wallet-instance-attestation/v1.3.3/mappers.js.map +1 -1
  56. package/lib/commonjs/wallet-instance-attestation/v1.3.3/types.js +2 -7
  57. package/lib/commonjs/wallet-instance-attestation/v1.3.3/types.js.map +1 -1
  58. package/lib/commonjs/wallet-unit-attestation/api/types.js +0 -11
  59. package/lib/commonjs/wallet-unit-attestation/api/types.js.map +1 -1
  60. package/lib/module/credential/issuance/common/02-start-user-authorization.js +4 -3
  61. package/lib/module/credential/issuance/common/02-start-user-authorization.js.map +1 -1
  62. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js +39 -10
  63. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js.map +1 -1
  64. package/lib/module/credential/issuance/mrtd-pop/02-init-challenge.js +47 -34
  65. package/lib/module/credential/issuance/mrtd-pop/02-init-challenge.js.map +1 -1
  66. package/lib/module/credential/issuance/mrtd-pop/03-validate-challenge.js +58 -47
  67. package/lib/module/credential/issuance/mrtd-pop/03-validate-challenge.js.map +1 -1
  68. package/lib/module/credential/issuance/mrtd-pop/index.js +20 -5
  69. package/lib/module/credential/issuance/mrtd-pop/index.js.map +1 -1
  70. package/lib/module/credential/issuance/v1.0.0/02-start-user-authorization.js +1 -1
  71. package/lib/module/credential/issuance/v1.0.0/02-start-user-authorization.js.map +1 -1
  72. package/lib/module/credential/issuance/v1.0.0/index.js +2 -2
  73. package/lib/module/credential/issuance/v1.0.0/index.js.map +1 -1
  74. package/lib/module/credential/issuance/v1.0.0/mappers.js +1 -1
  75. package/lib/module/credential/issuance/v1.0.0/mappers.js.map +1 -1
  76. package/lib/module/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js +0 -2
  77. package/lib/module/credential/issuance/v1.3.3/01-evaluate-issuer-trust.js.map +1 -1
  78. package/lib/module/credential/issuance/v1.3.3/02-start-user-authorization.js +20 -16
  79. package/lib/module/credential/issuance/v1.3.3/02-start-user-authorization.js.map +1 -1
  80. package/lib/module/credential/issuance/v1.3.3/04-authorize-access.js +22 -19
  81. package/lib/module/credential/issuance/v1.3.3/04-authorize-access.js.map +1 -1
  82. package/lib/module/credential/issuance/v1.3.3/05-obtain-credential.js +5 -7
  83. package/lib/module/credential/issuance/v1.3.3/05-obtain-credential.js.map +1 -1
  84. package/lib/module/credential/issuance/v1.3.3/06-verify-and-parse-credential.js +4 -1
  85. package/lib/module/credential/issuance/v1.3.3/06-verify-and-parse-credential.js.map +1 -1
  86. package/lib/module/credential/issuance/v1.3.3/index.js +2 -2
  87. package/lib/module/credential/issuance/v1.3.3/index.js.map +1 -1
  88. package/lib/module/credential/issuance/v1.3.3/mappers.js +1 -1
  89. package/lib/module/credential/issuance/v1.3.3/mappers.js.map +1 -1
  90. package/lib/module/credential/presentation/{v1.3.3/utils.mdoc.js → common/utils/mdoc.js} +2 -2
  91. package/lib/module/credential/presentation/common/utils/mdoc.js.map +1 -0
  92. package/lib/module/credential/presentation/v1.3.3/06-evaluate-dcql-query.js +2 -3
  93. package/lib/module/credential/presentation/v1.3.3/06-evaluate-dcql-query.js.map +1 -1
  94. package/lib/module/credential/status/README.md +3 -2
  95. package/lib/module/credential/status/v1.3.3/01-status-list.js +27 -5
  96. package/lib/module/credential/status/v1.3.3/01-status-list.js.map +1 -1
  97. package/lib/module/credential/status/v1.3.3/02-verify-and-parse-status-list.js +17 -6
  98. package/lib/module/credential/status/v1.3.3/02-verify-and-parse-status-list.js.map +1 -1
  99. package/lib/module/mdoc/index.js +3 -24
  100. package/lib/module/mdoc/index.js.map +1 -1
  101. package/lib/module/sd-jwt/__test__/types.test.js +2 -14
  102. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  103. package/lib/module/sd-jwt/__test__/utils.test.js +0 -12
  104. package/lib/module/sd-jwt/__test__/utils.test.js.map +1 -1
  105. package/lib/module/sd-jwt/types.js +1 -14
  106. package/lib/module/sd-jwt/types.js.map +1 -1
  107. package/lib/module/utils/callbacks.js +19 -1
  108. package/lib/module/utils/callbacks.js.map +1 -1
  109. package/lib/module/utils/x509.js +28 -0
  110. package/lib/module/utils/x509.js.map +1 -0
  111. package/lib/module/wallet-instance-attestation/api/types.js +0 -2
  112. package/lib/module/wallet-instance-attestation/api/types.js.map +1 -1
  113. package/lib/module/wallet-instance-attestation/v1.3.3/mappers.js +1 -14
  114. package/lib/module/wallet-instance-attestation/v1.3.3/mappers.js.map +1 -1
  115. package/lib/module/wallet-instance-attestation/v1.3.3/types.js +2 -7
  116. package/lib/module/wallet-instance-attestation/v1.3.3/types.js.map +1 -1
  117. package/lib/module/wallet-unit-attestation/api/types.js +0 -11
  118. package/lib/module/wallet-unit-attestation/api/types.js.map +1 -1
  119. package/lib/typescript/credential/issuance/api/06-verify-and-parse-credential.d.ts +4 -0
  120. package/lib/typescript/credential/issuance/api/06-verify-and-parse-credential.d.ts.map +1 -1
  121. package/lib/typescript/credential/issuance/common/02-start-user-authorization.d.ts.map +1 -1
  122. package/lib/typescript/credential/issuance/common/06-verify-and-parse-credential.sdjwt.d.ts.map +1 -1
  123. package/lib/typescript/credential/issuance/mrtd-pop/02-init-challenge.d.ts +12 -1
  124. package/lib/typescript/credential/issuance/mrtd-pop/02-init-challenge.d.ts.map +1 -1
  125. package/lib/typescript/credential/issuance/mrtd-pop/03-validate-challenge.d.ts +12 -1
  126. package/lib/typescript/credential/issuance/mrtd-pop/03-validate-challenge.d.ts.map +1 -1
  127. package/lib/typescript/credential/issuance/mrtd-pop/index.d.ts +2 -1
  128. package/lib/typescript/credential/issuance/mrtd-pop/index.d.ts.map +1 -1
  129. package/lib/typescript/credential/issuance/v1.0.0/mappers.d.ts.map +1 -1
  130. package/lib/typescript/credential/issuance/v1.3.3/01-evaluate-issuer-trust.d.ts.map +1 -1
  131. package/lib/typescript/credential/issuance/v1.3.3/02-start-user-authorization.d.ts.map +1 -1
  132. package/lib/typescript/credential/issuance/v1.3.3/04-authorize-access.d.ts.map +1 -1
  133. package/lib/typescript/credential/issuance/v1.3.3/05-obtain-credential.d.ts.map +1 -1
  134. package/lib/typescript/credential/issuance/v1.3.3/06-verify-and-parse-credential.d.ts.map +1 -1
  135. package/lib/typescript/credential/issuance/v1.3.3/mappers.d.ts.map +1 -1
  136. package/lib/typescript/credential/presentation/{v1.3.3/utils.mdoc.d.ts → common/utils/mdoc.d.ts} +2 -2
  137. package/lib/typescript/credential/presentation/common/utils/mdoc.d.ts.map +1 -0
  138. package/lib/typescript/credential/presentation/v1.3.3/06-evaluate-dcql-query.d.ts.map +1 -1
  139. package/lib/typescript/credential/status/api/status-list.d.ts +8 -4
  140. package/lib/typescript/credential/status/api/status-list.d.ts.map +1 -1
  141. package/lib/typescript/credential/status/v1.3.3/01-status-list.d.ts.map +1 -1
  142. package/lib/typescript/credential/status/v1.3.3/02-verify-and-parse-status-list.d.ts.map +1 -1
  143. package/lib/typescript/mdoc/index.d.ts +1 -1
  144. package/lib/typescript/mdoc/index.d.ts.map +1 -1
  145. package/lib/typescript/mdoc/utils.d.ts +0 -24
  146. package/lib/typescript/mdoc/utils.d.ts.map +1 -1
  147. package/lib/typescript/sd-jwt/types.d.ts +0 -12
  148. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  149. package/lib/typescript/utils/callbacks.d.ts +7 -0
  150. package/lib/typescript/utils/callbacks.d.ts.map +1 -1
  151. package/lib/typescript/utils/x509.d.ts +10 -0
  152. package/lib/typescript/utils/x509.d.ts.map +1 -0
  153. package/lib/typescript/wallet-instance-attestation/api/types.d.ts +0 -2
  154. package/lib/typescript/wallet-instance-attestation/api/types.d.ts.map +1 -1
  155. package/lib/typescript/wallet-instance-attestation/v1.0.0/mappers.d.ts +0 -2
  156. package/lib/typescript/wallet-instance-attestation/v1.0.0/mappers.d.ts.map +1 -1
  157. package/lib/typescript/wallet-instance-attestation/v1.3.3/mappers.d.ts +2 -9
  158. package/lib/typescript/wallet-instance-attestation/v1.3.3/mappers.d.ts.map +1 -1
  159. package/lib/typescript/wallet-instance-attestation/v1.3.3/types.d.ts +2 -7
  160. package/lib/typescript/wallet-instance-attestation/v1.3.3/types.d.ts.map +1 -1
  161. package/lib/typescript/wallet-unit-attestation/api/types.d.ts +0 -11
  162. package/lib/typescript/wallet-unit-attestation/api/types.d.ts.map +1 -1
  163. package/lib/typescript/wallet-unit-attestation/v1.3.3/mappers.d.ts +0 -22
  164. package/lib/typescript/wallet-unit-attestation/v1.3.3/mappers.d.ts.map +1 -1
  165. package/lib/typescript/wallet-unit-attestation/v1.3.3/types.d.ts +0 -11
  166. package/lib/typescript/wallet-unit-attestation/v1.3.3/types.d.ts.map +1 -1
  167. package/package.json +6 -6
  168. package/src/credential/issuance/api/06-verify-and-parse-credential.ts +4 -0
  169. package/src/credential/issuance/common/02-start-user-authorization.ts +6 -3
  170. package/src/credential/issuance/common/06-verify-and-parse-credential.sdjwt.ts +42 -9
  171. package/src/credential/issuance/mrtd-pop/02-init-challenge.ts +69 -45
  172. package/src/credential/issuance/mrtd-pop/03-validate-challenge.ts +84 -62
  173. package/src/credential/issuance/mrtd-pop/index.ts +13 -5
  174. package/src/credential/issuance/v1.0.0/02-start-user-authorization.ts +1 -1
  175. package/src/credential/issuance/v1.0.0/index.ts +2 -2
  176. package/src/credential/issuance/v1.0.0/mappers.ts +4 -1
  177. package/src/credential/issuance/v1.3.3/01-evaluate-issuer-trust.ts +0 -2
  178. package/src/credential/issuance/v1.3.3/02-start-user-authorization.ts +24 -20
  179. package/src/credential/issuance/v1.3.3/04-authorize-access.ts +28 -23
  180. package/src/credential/issuance/v1.3.3/05-obtain-credential.ts +8 -8
  181. package/src/credential/issuance/v1.3.3/06-verify-and-parse-credential.ts +2 -1
  182. package/src/credential/issuance/v1.3.3/index.ts +2 -2
  183. package/src/credential/issuance/v1.3.3/mappers.ts +4 -1
  184. package/src/credential/presentation/{v1.3.3/utils.mdoc.ts → common/utils/mdoc.ts} +2 -2
  185. package/src/credential/presentation/v1.3.3/06-evaluate-dcql-query.ts +3 -3
  186. package/src/credential/status/README.md +3 -2
  187. package/src/credential/status/api/status-list.ts +10 -7
  188. package/src/credential/status/v1.3.3/01-status-list.ts +21 -7
  189. package/src/credential/status/v1.3.3/02-verify-and-parse-status-list.ts +19 -5
  190. package/src/mdoc/index.ts +5 -41
  191. package/src/sd-jwt/__test__/types.test.ts +1 -13
  192. package/src/sd-jwt/__test__/utils.test.ts +0 -12
  193. package/src/sd-jwt/types.ts +0 -13
  194. package/src/utils/callbacks.ts +28 -1
  195. package/src/utils/x509.ts +43 -0
  196. package/src/wallet-instance-attestation/api/types.ts +0 -2
  197. package/src/wallet-instance-attestation/v1.3.3/mappers.ts +3 -11
  198. package/src/wallet-instance-attestation/v1.3.3/types.ts +2 -7
  199. package/src/wallet-unit-attestation/api/types.ts +0 -11
  200. package/lib/commonjs/credential/issuance/common/authorization.js +0 -56
  201. package/lib/commonjs/credential/issuance/common/authorization.js.map +0 -1
  202. package/lib/commonjs/credential/presentation/v1.3.3/utils.mdoc.js.map +0 -1
  203. package/lib/module/credential/issuance/common/authorization.js +0 -48
  204. package/lib/module/credential/issuance/common/authorization.js.map +0 -1
  205. package/lib/module/credential/presentation/v1.3.3/utils.mdoc.js.map +0 -1
  206. package/lib/typescript/credential/issuance/common/authorization.d.ts +0 -21
  207. package/lib/typescript/credential/issuance/common/authorization.d.ts.map +0 -1
  208. package/lib/typescript/credential/presentation/v1.3.3/utils.mdoc.d.ts.map +0 -1
  209. package/src/credential/issuance/common/authorization.ts +0 -89
@@ -3,16 +3,17 @@ import {
3
3
  fetchPushedAuthorizationResponse,
4
4
  createClientAttestationPopJwt,
5
5
  } from "@pagopa/io-wallet-oauth2";
6
- import type { CallbackContext } from "@pagopa/io-wallet-oauth2";
6
+ import type { JwtSignerJwk } from "@pagopa/io-wallet-oauth2";
7
+ import { v4 as uuidv4 } from "uuid";
7
8
  import { LogLevel, Logger } from "../../../utils/logging";
8
9
  import type { IssuanceApi } from "../api";
9
- import { SignJWT } from "@pagopa/io-react-native-jwt";
10
- import { partialCallbacks } from "../../../utils/callbacks";
11
- import { IoWalletError } from "../../../utils/errors";
12
10
  import {
13
- selectCredentialDefinition,
14
- selectResponseMode,
15
- } from "../common/authorization";
11
+ createSignJwtFromCryptoContext,
12
+ partialCallbacks,
13
+ } from "../../../utils/callbacks";
14
+ import { IoWalletError } from "../../../utils/errors";
15
+ import { sdkConfigV1_3 } from "../../../utils/config";
16
+ import { selectCredentialDefinition } from "../common/02-start-user-authorization";
16
17
 
17
18
  export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
18
19
  async (issuerConf, credentialIds, proof, ctx) => {
@@ -33,8 +34,6 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
33
34
  throw new IoWalletError("No public key found");
34
35
  }
35
36
 
36
- const responseMode = selectResponseMode(issuerConf, credentialIds);
37
-
38
37
  const credentialDefinition = credentialIds.map((c) =>
39
38
  selectCredentialDefinition(issuerConf, c)
40
39
  );
@@ -54,13 +53,16 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
54
53
  });
55
54
  }
56
55
 
57
- const signerJwk = await wiaCryptoContext.getPublicKey();
58
- const signJwt: CallbackContext["signJwt"] = async (_, payload) => ({
59
- jwt: await new SignJWT(wiaCryptoContext).setPayload(payload).sign(),
60
- signerJwk,
61
- });
56
+ const wiaSigner: JwtSignerJwk = {
57
+ method: "jwk",
58
+ alg: "ES256",
59
+ publicJwk: await wiaCryptoContext.getPublicKey(),
60
+ };
61
+
62
+ const signJwt = createSignJwtFromCryptoContext(wiaCryptoContext);
62
63
 
63
64
  const parRequest = await createPushedAuthorizationRequest({
65
+ config: sdkConfigV1_3,
64
66
  callbacks: {
65
67
  ...partialCallbacks,
66
68
  signJwt,
@@ -68,25 +70,27 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
68
70
  authorizationServerMetadata: {
69
71
  require_signed_request_object: true,
70
72
  },
73
+ jti: uuidv4(),
71
74
  clientId,
72
75
  audience: issuerConf.credential_issuer,
73
76
  authorization_details: credentialDefinition,
74
77
  codeChallengeMethodsSupported: ["S256"],
75
- responseMode,
76
78
  redirectUri,
79
+ dpop: {
80
+ signer: wiaSigner,
81
+ },
77
82
  });
78
83
 
79
84
  const clientAttestationPoP = await createClientAttestationPopJwt({
85
+ config: sdkConfigV1_3,
80
86
  callbacks: {
87
+ generateRandom: partialCallbacks.generateRandom,
81
88
  signJwt,
82
89
  },
83
90
  clientAttestation: walletInstanceAttestation,
84
91
  authorizationServer: issuerConf.authorization_endpoint,
85
- signer: {
86
- method: "jwk",
87
- alg: "ES256",
88
- publicJwk: signerJwk,
89
- },
92
+ signer: wiaSigner,
93
+ jti: uuidv4(),
90
94
  });
91
95
 
92
96
  const { request_uri } = await fetchPushedAuthorizationResponse({
@@ -1,10 +1,15 @@
1
- import { SignJWT } from "@pagopa/io-react-native-jwt";
2
- import { createTokenDPoP, fetchTokenResponse } from "@pagopa/io-wallet-oauth2";
1
+ import {
2
+ createClientAttestationPopJwt,
3
+ createTokenDPoP,
4
+ fetchTokenResponse,
5
+ } from "@pagopa/io-wallet-oauth2";
3
6
  import { v4 as uuidv4 } from "uuid";
4
- import { createPopToken } from "../../../utils/pop";
5
- import * as WalletInstanceAttestation from "../../../wallet-instance-attestation/v1.0.0/utils";
6
- import { partialCallbacks } from "../../../utils/callbacks";
7
+ import {
8
+ createSignJwtFromCryptoContext,
9
+ partialCallbacks,
10
+ } from "../../../utils/callbacks";
7
11
  import { IoWalletError } from "../../../utils/errors";
12
+ import { sdkConfigV1_3 } from "../../../utils/config";
8
13
  import type { IssuanceApi, TokenResponse } from "../api";
9
14
 
10
15
  export const authorizeAccess: IssuanceApi["authorizeAccess"] = async (
@@ -21,37 +26,37 @@ export const authorizeAccess: IssuanceApi["authorizeAccess"] = async (
21
26
  dPopCryptoContext,
22
27
  } = context;
23
28
 
24
- const dPopSignerJwk = await dPopCryptoContext.getPublicKey();
25
29
  const tokenDPoP = await createTokenDPoP({
26
30
  callbacks: {
27
31
  ...partialCallbacks,
28
- signJwt: async (_, payload) => ({
29
- jwt: await new SignJWT(wiaCryptoContext).setPayload(payload).sign(),
30
- signerJwk: dPopSignerJwk,
31
- }),
32
+ signJwt: createSignJwtFromCryptoContext(dPopCryptoContext),
32
33
  },
33
34
  signer: {
34
- alg: "ES256",
35
35
  method: "jwk",
36
- publicJwk: dPopSignerJwk,
36
+ alg: "ES256",
37
+ publicJwk: await dPopCryptoContext.getPublicKey(),
37
38
  },
39
+ jti: uuidv4(),
38
40
  tokenRequest: {
39
41
  method: "POST",
40
42
  url: issuerConf.token_endpoint,
41
43
  },
42
44
  });
43
45
 
44
- const iss = WalletInstanceAttestation.decode(walletInstanceAttestation)
45
- .payload.cnf.jwk.kid;
46
-
47
- const signedWiaPoP = await createPopToken(
48
- {
49
- jti: uuidv4(),
50
- aud: issuerConf.credential_issuer,
51
- iss,
46
+ const clientAttestationDPoP = await createClientAttestationPopJwt({
47
+ config: sdkConfigV1_3,
48
+ callbacks: {
49
+ generateRandom: partialCallbacks.generateRandom,
50
+ signJwt: createSignJwtFromCryptoContext(wiaCryptoContext),
52
51
  },
53
- wiaCryptoContext
54
- );
52
+ clientAttestation: walletInstanceAttestation,
53
+ authorizationServer: issuerConf.credential_issuer,
54
+ signer: {
55
+ method: "jwk",
56
+ alg: "ES256",
57
+ publicJwk: await wiaCryptoContext.getPublicKey(),
58
+ },
59
+ });
55
60
 
56
61
  const tokenResponse = await fetchTokenResponse({
57
62
  accessTokenEndpoint: issuerConf.token_endpoint,
@@ -61,7 +66,7 @@ export const authorizeAccess: IssuanceApi["authorizeAccess"] = async (
61
66
  },
62
67
  walletAttestation: walletInstanceAttestation,
63
68
  dPoP: tokenDPoP.jwt,
64
- clientAttestationDPoP: signedWiaPoP,
69
+ clientAttestationDPoP,
65
70
  accessTokenRequest: {
66
71
  code,
67
72
  grant_type: "authorization_code",
@@ -9,6 +9,7 @@ import {
9
9
  createCredentialRequest,
10
10
  } from "@pagopa/io-wallet-oid4vci";
11
11
  import { UnexpectedStatusCodeError as SdkUnexpectedStatusCodeError } from "@pagopa/io-wallet-utils";
12
+ import { v4 as uuidv4 } from "uuid";
12
13
  import { hasStatusOrThrow, type Out } from "../../../utils/misc";
13
14
  import {
14
15
  IoWalletError,
@@ -19,7 +20,10 @@ import {
19
20
  } from "../../../utils/errors";
20
21
  import { LogLevel, Logger } from "../../../utils/logging";
21
22
  import { sdkConfigV1_3 } from "../../../utils/config";
22
- import { partialCallbacks } from "../../../utils/callbacks";
23
+ import {
24
+ createSignJwtFromCryptoContext,
25
+ partialCallbacks,
26
+ } from "../../../utils/callbacks";
23
27
  import type { IssuanceApi, IssuerConfig } from "../api";
24
28
  import { NonceResponse } from "./types";
25
29
  import type { AuthorizeAccessApi } from "../api/04-authorize-access";
@@ -115,21 +119,17 @@ export const requestCredentials = async ({
115
119
  signers,
116
120
  });
117
121
 
118
- const dPopSignerJwk = await dPopCryptoContext.getPublicKey();
119
-
120
122
  const credentialDPoP = await createTokenDPoP({
121
123
  callbacks: {
122
124
  ...partialCallbacks,
123
- signJwt: async (_, payload) => ({
124
- jwt: await new SignJWT(dPopCryptoContext).setPayload(payload).sign(),
125
- signerJwk: dPopSignerJwk,
126
- }),
125
+ signJwt: createSignJwtFromCryptoContext(dPopCryptoContext),
127
126
  },
128
127
  signer: {
129
128
  method: "jwk",
130
129
  alg: "ES256",
131
- publicJwk: dPopSignerJwk,
130
+ publicJwk: await dPopCryptoContext.getPublicKey(),
132
131
  },
132
+ jti: uuidv4(),
133
133
  tokenRequest: {
134
134
  method: "POST",
135
135
  url: issuerConf.credential_endpoint,
@@ -23,7 +23,8 @@ export const verifyAndParseCredential: IssuanceApi["verifyAndParseCredential"] =
23
23
  issuerConf,
24
24
  credential,
25
25
  credentialConfigurationId,
26
- context
26
+ { validateCertificateChain: true, ...context },
27
+ x509CertRoot
27
28
  );
28
29
  }
29
30
  case "mso_mdoc": {
@@ -14,7 +14,7 @@ import {
14
14
  obtainCredentialsBatch,
15
15
  } from "./05-obtain-credential";
16
16
  import { verifyAndParseCredential } from "./06-verify-and-parse-credential";
17
- import { MRTDPoP } from "../mrtd-pop";
17
+ import { MRTDPoPv1_3 } from "../mrtd-pop";
18
18
 
19
19
  export const Issuance: IssuanceApi = {
20
20
  evaluateIssuerTrust,
@@ -28,5 +28,5 @@ export const Issuance: IssuanceApi = {
28
28
  obtainCredential,
29
29
  obtainCredentialsBatch,
30
30
  verifyAndParseCredential,
31
- MRTDPoP,
31
+ MRTDPoP: MRTDPoPv1_3,
32
32
  };
@@ -60,7 +60,10 @@ export const mapToIssuerConfig = createMapper<
60
60
  credential_configurations_supported: mapCredentialConfigurationsSupported(
61
61
  openid_credential_issuer
62
62
  ),
63
- keys: openid_credential_issuer.jwks.keys as JWK[],
63
+ keys: [
64
+ ...openid_credential_issuer.jwks.keys,
65
+ ...oauth_authorization_server.jwks.keys,
66
+ ] as JWK[],
64
67
  pushed_authorization_request_endpoint:
65
68
  oauth_authorization_server.pushed_authorization_request_endpoint,
66
69
  token_endpoint: oauth_authorization_server.token_endpoint,
@@ -5,8 +5,8 @@ import type {
5
5
  Credential4Dcql,
6
6
  EvaluatedDisclosure,
7
7
  PresentationFrame,
8
- } from "../api";
9
- import { getValidDcqlClaims } from "../common/utils/dcql";
8
+ } from "../../api";
9
+ import { getValidDcqlClaims } from "./dcql";
10
10
 
11
11
  type CustomDcqlMdocCredential = DcqlMdocCredential & {
12
12
  original_credential: Credential4Dcql;
@@ -2,13 +2,13 @@ import { DcqlQuery, DcqlError } from "dcql";
2
2
  import { isValiError } from "valibot";
3
3
  import { CredentialsNotFoundError } from "../common/errors";
4
4
  import type { CredentialPurpose } from "../api/06-evaluate-dcql-query";
5
- import * as mdocUtils from "./utils.mdoc";
6
- import type { Credential4Dcql, RemotePresentationApi } from "../api";
7
5
  import * as sdJwtUtils from "../common/utils/sd-jwt";
8
- import { getClaimsFromDcqlMatch } from "./utils.mdoc";
6
+ import * as mdocUtils from "../common/utils/mdoc";
7
+ import type { Credential4Dcql, RemotePresentationApi } from "../api";
9
8
  import {
10
9
  extractFailedCredentialsDetails,
11
10
  getDcqlQueryMatches,
11
+ getClaimsFromDcqlMatch,
12
12
  getPresentationFrameFromDcqlMatch,
13
13
  } from "../common/utils/dcql";
14
14
 
@@ -111,15 +111,16 @@ const res = await wallet.CredentialStatus.statusList.get(
111
111
  );
112
112
 
113
113
  // Verify and parse the status list response to get the credential status
114
- const { status } =
114
+ const { status, statusBit } =
115
115
  await wallet.CredentialStatus.statusList.verifyAndParse(
116
- issuerConf,
116
+ issuerConf.keys,
117
117
  res
118
118
  );
119
119
 
120
120
  return {
121
121
  statusList: res.statusList,
122
122
  status,
123
+ statusBit,
123
124
  };
124
125
  ```
125
126
 
@@ -1,8 +1,6 @@
1
1
  import type { Out } from "../../../utils/misc";
2
- import type {
3
- CredentialFormat,
4
- IssuerConfig,
5
- } from "../../../credential/issuance/api";
2
+ import type { CredentialFormat } from "../../../credential/issuance/api";
3
+ import type { JWK } from "../../../utils/jwk";
6
4
 
7
5
  export interface StatusListApi {
8
6
  isSupported: true;
@@ -22,6 +20,7 @@ export interface StatusListApi {
22
20
  * @since 1.3.3
23
21
  * @param credential The credential to get the status list for
24
22
  * @param format The credential format
23
+ * @param context.appFetch Optional fetch function to use for the network request
25
24
  * @returns The raw status list, the index of the credential and other metadata
26
25
  */
27
26
  get(
@@ -40,11 +39,15 @@ export interface StatusListApi {
40
39
  /**
41
40
  * Verifies the signature of a status list and extract the status at the specified index.
42
41
  * @since 1.3.3
43
- * @param issuerConf The Credential Issuer common configuration
42
+ * @param keys The JSON Web Key Set to verify the status list signature
44
43
  * @param statusListParams The raw status list, the index to read and other metadata
44
+ * @return The status of the credential and the raw status bit in hexadecimal format (e.g. "0x01")
45
45
  */
46
46
  verifyAndParse(
47
- issuerConf: IssuerConfig,
47
+ keys: JWK[],
48
48
  statusListParams: Out<StatusListApi["get"]>
49
- ): Promise<{ status: number }>;
49
+ ): Promise<{
50
+ statusBit: string;
51
+ status: string;
52
+ }>;
50
53
  }
@@ -1,4 +1,5 @@
1
1
  import { CBOR } from "@pagopa/io-react-native-iso18013";
2
+ import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
2
3
  import {
3
4
  getStatusListFromJWT,
4
5
  type StatusListEntry,
@@ -38,13 +39,26 @@ export const getStatusList: StatusListApi["get"] = async (
38
39
  ) => {
39
40
  const { uri, idx } = await getStatusListEntry(credential, format);
40
41
 
41
- const statusList = await appFetch(uri, {
42
- headers: {
43
- Accept: "application/statuslist+jwt",
44
- },
45
- })
46
- .then(hasStatusOrThrow(200))
47
- .then((response) => response.text());
42
+ const fetchStatusList = (options: { cacheDisabled?: boolean } = {}) =>
43
+ appFetch(uri, {
44
+ headers: {
45
+ Accept: "application/statuslist+jwt",
46
+ ...(options.cacheDisabled && { "Cache-Control": "no-cache" }),
47
+ },
48
+ })
49
+ .then(hasStatusOrThrow(200))
50
+ .then((response) => response.text());
48
51
 
52
+ // When the HTTP response includes cache headers, fetch will return a cached response and the JWT might be expired
53
+ let statusList = await fetchStatusList();
54
+ const decoded = decodeJwt(statusList);
55
+
56
+ const { exp } = decoded.payload;
57
+
58
+ // If the status list JWT is expired, try to fetch it again bypassing the HTTP cache.
59
+ // If it is still expired after the refetch, `verifyAndParseStatusList` will throw.
60
+ if (exp && exp < Math.floor(Date.now() / 1000)) {
61
+ statusList = await fetchStatusList({ cacheDisabled: true });
62
+ }
49
63
  return { statusList, uri, idx, format: "jwt" };
50
64
  };
@@ -2,18 +2,32 @@ import { verify } from "@pagopa/io-react-native-jwt";
2
2
  import { getListFromStatusListJWT } from "@sd-jwt/jwt-status-list";
3
3
  import type { StatusListApi } from "../api/status-list";
4
4
 
5
+ /**
6
+ * Mapping of status bits to their corresponding meaning as defined in the specification.
7
+ * @see https://italia.github.io/eid-wallet-it-docs/releases/1.3.3/en/credential-revocation.html#token-status-lists
8
+ */
9
+ const CredentialStatusMap = {
10
+ 0x00: "VALID",
11
+ 0x01: "INVALID",
12
+ 0x02: "SUSPENDED",
13
+ 0x03: "UPDATE",
14
+ 0x0b: "ATTRIBUTE_UPDATE",
15
+ } as const;
16
+
17
+ type CredentialStatusBit = keyof typeof CredentialStatusMap;
18
+
5
19
  export const verifyAndParseStatusList: StatusListApi["verifyAndParse"] = async (
6
- issuerConf,
20
+ keys,
7
21
  { statusList: rawStatusList, idx }
8
22
  ) => {
9
- await verify(rawStatusList, issuerConf.keys);
23
+ await verify(rawStatusList, keys);
10
24
 
11
25
  const statusList = getListFromStatusListJWT(rawStatusList);
26
+ const statusBit = statusList.getStatus(idx) as CredentialStatusBit;
27
+ const status = CredentialStatusMap[statusBit];
12
28
 
13
- const status = statusList.getStatus(idx);
14
-
15
- // TODO: [SIW-3992] Improve the return object with additional data, throw CredentialInvalidStatus when invalid
16
29
  return {
17
30
  status,
31
+ statusBit: `0x${statusBit.toString(16).padStart(2, "0").toUpperCase()}`,
18
32
  };
19
33
  };
package/src/mdoc/index.ts CHANGED
@@ -1,19 +1,12 @@
1
1
  import { CBOR, COSE, ISO18013_7 } from "@pagopa/io-react-native-iso18013";
2
2
  import { b64utob64 } from "jsrsasign";
3
- import {
4
- verifyCertificateChain,
5
- type CertificateValidationResult,
6
- type PublicKey,
7
- type X509CertificateOptions,
8
- } from "@pagopa/io-react-native-crypto";
9
- import {
10
- MissingX509CertsError,
11
- X509ValidationError,
12
- } from "../trust/common/errors";
3
+ import { type PublicKey } from "@pagopa/io-react-native-crypto";
4
+ import { MissingX509CertsError } from "../trust/common/errors";
13
5
  import { IoWalletError } from "../utils/errors";
14
6
  import { convertBase64DerToPem, getSigninJwkFromCert } from "../utils/crypto";
15
- import type { Presentation } from "src/credential/presentation";
7
+ import type { Presentation } from "../credential/presentation";
16
8
  import { removePadding } from "@pagopa/io-react-native-jwt";
9
+ import { verifyX509Chain } from "../utils/x509";
17
10
  export * from "./utils";
18
11
 
19
12
  export const verify = async (
@@ -37,7 +30,7 @@ export const verify = async (
37
30
  const x5chain =
38
31
  issuerSigned.issuerAuth.unprotectedHeader.x5chain.map(b64utob64);
39
32
  // Verify the x5chain
40
- await verifyX5chain(x5chain, x509CertRoot);
33
+ await verifyX509Chain(x5chain, x509CertRoot);
41
34
 
42
35
  const coseSign1 = issuerSigned.issuerAuth.rawValue;
43
36
 
@@ -50,35 +43,6 @@ export const verify = async (
50
43
  return { issuerSigned };
51
44
  };
52
45
 
53
- /**
54
- * This function checks whether the x509 certificate chain is valid against a specified Certificate Authority (CA)
55
- *
56
- * @param x5chain The mdoc's x509 certificate chain
57
- * @param x509CertRoot The Trust Anchor CA
58
- * @param options Options for certificate validation
59
- */
60
- const verifyX5chain = async (
61
- x5chain: string[],
62
- x509CertRoot: string,
63
- options: X509CertificateOptions = {
64
- connectTimeout: 10000,
65
- readTimeout: 10000,
66
- requireCrl: true,
67
- }
68
- ) => {
69
- const x509ValidationResult: CertificateValidationResult =
70
- await verifyCertificateChain(x5chain, x509CertRoot, options);
71
-
72
- if (!x509ValidationResult.isValid) {
73
- throw new X509ValidationError(
74
- `X.509 certificate chain validation failed. Status: ${x509ValidationResult.validationStatus}. Error: ${x509ValidationResult.errorMessage}`,
75
- {
76
- x509ValidationStatus: x509ValidationResult.validationStatus,
77
- x509ErrorMessage: x509ValidationResult.errorMessage,
78
- }
79
- );
80
- }
81
- };
82
46
  /**
83
47
  * This function verifies that the signature is valid for the given certificate.
84
48
  * If not, it throws an error
@@ -28,20 +28,8 @@ describe("Verification.time", () => {
28
28
 
29
29
  it("rejects invalid type", () => {
30
30
  const value = {
31
- trust_framework: "eidas",
31
+ trust_framework: ["eidas"],
32
32
  assurance_level: "high",
33
- evidence: [
34
- {
35
- type: "vouch",
36
- time: null,
37
- attestation: {
38
- type: "digital_attestation",
39
- reference_number: "abc",
40
- date_of_issuance: "2025-09-02",
41
- voucher: { organization: "IPZS" },
42
- },
43
- },
44
- ],
45
33
  };
46
34
 
47
35
  expect(Verification.safeParse(value).success).toBe(false);
@@ -4,18 +4,6 @@ import { getVerification } from "..";
4
4
  describe("SD-JWT getVerification", () => {
5
5
  it("extracts the verification claims correctly", () => {
6
6
  expect(getVerification(pid)).toEqual({
7
- evidence: [
8
- {
9
- attestation: {
10
- date_of_issuance: "2025-06-23",
11
- voucher: { organization: "Ministero dell'Interno" },
12
- type: "digital_attestation",
13
- reference_number: "123456789",
14
- },
15
- time: "2025-06-23T13:14:25Z",
16
- type: "vouch",
17
- },
18
- ],
19
7
  trust_framework: "it_cie",
20
8
  assurance_level: "high",
21
9
  });
@@ -64,19 +64,6 @@ export type Verification = z.infer<typeof Verification>;
64
64
  export const Verification = z.object({
65
65
  trust_framework: z.string(),
66
66
  assurance_level: z.string(),
67
- evidence: z.array(
68
- z.object({
69
- type: z.literal("vouch"),
70
- // Support both string and UNIX timestamp for backward compatibility
71
- time: z.union([z.string(), z.number()]),
72
- attestation: z.object({
73
- type: z.literal("digital_attestation"),
74
- reference_number: z.string(),
75
- date_of_issuance: z.string(),
76
- voucher: z.object({ organization: z.string() }),
77
- }),
78
- })
79
- ),
80
67
  });
81
68
 
82
69
  /**
@@ -1,4 +1,9 @@
1
- import { EncryptJwe, getJwkFromHeader } from "@pagopa/io-react-native-jwt";
1
+ import {
2
+ EncryptJwe,
3
+ getJwkFromHeader,
4
+ SignJWT,
5
+ type CryptoContext,
6
+ } from "@pagopa/io-react-native-jwt";
2
7
  import { verify } from "@pagopa/io-react-native-jwt";
3
8
  import { type CallbackContext, type JwtSigner } from "@pagopa/io-wallet-oauth2";
4
9
  import { digest } from "@sd-jwt/crypto-nodejs";
@@ -109,3 +114,25 @@ export const createVerifyJwtFromJwks = (
109
114
  }
110
115
  };
111
116
  };
117
+
118
+ /**
119
+ * Create a signJwt implementation that signs a JWT using the provided CryptoContext.
120
+ * @param cryptoContext The CryptoContext to use for signing the JWT
121
+ * @returns Function that implements `signJwt` callback
122
+ */
123
+ export const createSignJwtFromCryptoContext = (
124
+ cryptoContext: CryptoContext
125
+ ): CallbackContext["signJwt"] => {
126
+ return async function signJwt(jwtSigner, { header, payload }) {
127
+ return {
128
+ jwt: await new SignJWT(cryptoContext)
129
+ .setProtectedHeader(header)
130
+ .setPayload(payload)
131
+ .sign(),
132
+ signerJwk:
133
+ jwtSigner.method === "jwk"
134
+ ? jwtSigner.publicJwk
135
+ : await cryptoContext.getPublicKey(),
136
+ };
137
+ };
138
+ };
@@ -0,0 +1,43 @@
1
+ import {
2
+ verifyCertificateChain,
3
+ type CertificateValidationResult,
4
+ type X509CertificateOptions,
5
+ } from "@pagopa/io-react-native-crypto";
6
+ import { X509ValidationError } from "../trust/common/errors";
7
+
8
+ /**
9
+ * This function checks whether the x509 certificate chain is valid against a specified Certificate Authority (CA)
10
+ *
11
+ * @param x5chain The mdoc's x509 certificate chain
12
+ * @param x509CertRoot The Trust Anchor CA
13
+ * @param options Options for certificate validation
14
+ */
15
+ export const verifyX509Chain = async (
16
+ x5chain: string[],
17
+ x509CertRoot: string,
18
+ options: X509CertificateOptions = {
19
+ connectTimeout: 10000,
20
+ readTimeout: 10000,
21
+ requireCrl: true,
22
+ }
23
+ ) => {
24
+ // Strip the trust anchor from the chain if the issuer included it,
25
+ // since verifyCertificateChain expects it passed separately.
26
+ const certChain =
27
+ x5chain.length > 1 && x5chain.at(-1) === x509CertRoot
28
+ ? x5chain.slice(0, -1)
29
+ : x5chain;
30
+
31
+ const x509ValidationResult: CertificateValidationResult =
32
+ await verifyCertificateChain(certChain, x509CertRoot, options);
33
+
34
+ if (!x509ValidationResult.isValid) {
35
+ throw new X509ValidationError(
36
+ `X.509 certificate chain validation failed. Status: ${x509ValidationResult.validationStatus}. Error: ${x509ValidationResult.errorMessage}`,
37
+ {
38
+ x509ValidationStatus: x509ValidationResult.validationStatus,
39
+ x509ErrorMessage: x509ValidationResult.errorMessage,
40
+ }
41
+ );
42
+ }
43
+ };
@@ -15,8 +15,6 @@ export const DecodedWalletInstanceAttestation = z.object({
15
15
  exp: UnixTime,
16
16
  cnf: z.object({ jwk: JWK }),
17
17
  sub: z.string(),
18
- wallet_provider_name: z.string().optional(),
19
- wallet_solution_id: z.string().optional(),
20
18
  /** @deprecated */
21
19
  wallet_link: z.string().optional(),
22
20
  /** @deprecated */
@@ -5,14 +5,6 @@ import { WalletInstanceAttestationJwt } from "./types";
5
5
  export const mapToDecodedWalletInstanceAttestation = createMapper<
6
6
  WalletInstanceAttestationJwt,
7
7
  DecodedWalletInstanceAttestation
8
- >(
9
- ({ payload }) => {
10
- const { eudi_wallet_info, ...rest } = payload;
11
- return {
12
- ...rest,
13
- wallet_provider_name: eudi_wallet_info.general_info.wallet_provider_name,
14
- wallet_solution_id: eudi_wallet_info.general_info.wallet_solution_id,
15
- };
16
- },
17
- { outputSchema: DecodedWalletInstanceAttestation }
18
- );
8
+ >((x) => x.payload, {
9
+ outputSchema: DecodedWalletInstanceAttestation,
10
+ });