@pagopa/io-react-native-wallet 1.7.0 → 1.8.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 (146) hide show
  1. package/lib/commonjs/client/generated/wallet-provider.js +37 -11
  2. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
  3. package/lib/commonjs/credential/issuance/02-get-issuer-config.js +83 -3
  4. package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +5 -7
  6. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/06-obtain-credential.js +27 -10
  8. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +50 -46
  10. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/README.md +1 -1
  12. package/lib/commonjs/credential/issuance/const.js +1 -1
  13. package/lib/commonjs/credential/issuance/const.js.map +1 -1
  14. package/lib/commonjs/credential/issuance/index.js +6 -0
  15. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  16. package/lib/commonjs/credential/issuance/types.js +19 -10
  17. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  18. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +10 -3
  19. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  20. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +11 -4
  21. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  22. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +3 -3
  23. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
  24. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  25. package/lib/commonjs/entity/openid-connect/issuer/types.js +2 -2
  26. package/lib/commonjs/entity/openid-connect/issuer/types.js.map +1 -1
  27. package/lib/commonjs/entity/trust/types.js +19 -30
  28. package/lib/commonjs/entity/trust/types.js.map +1 -1
  29. package/lib/commonjs/index.js +7 -0
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/mdoc/index.js +4 -4
  32. package/lib/commonjs/mdoc/index.js.map +1 -1
  33. package/lib/commonjs/sd-jwt/index.js +2 -2
  34. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  35. package/lib/commonjs/sd-jwt/types.js +1 -1
  36. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  37. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +3 -2
  38. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +1 -1
  39. package/lib/commonjs/utils/pop.js +1 -1
  40. package/lib/commonjs/utils/pop.js.map +1 -1
  41. package/lib/commonjs/wallet-instance-attestation/issuing.js +11 -7
  42. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  43. package/lib/commonjs/wallet-instance-attestation/types.js +14 -19
  44. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  45. package/lib/module/client/generated/wallet-provider.js +29 -7
  46. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  47. package/lib/module/credential/issuance/02-get-issuer-config.js +80 -1
  48. package/lib/module/credential/issuance/02-get-issuer-config.js.map +1 -1
  49. package/lib/module/credential/issuance/03-start-user-authorization.js +5 -7
  50. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  51. package/lib/module/credential/issuance/06-obtain-credential.js +28 -11
  52. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  53. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +50 -46
  54. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  55. package/lib/module/credential/issuance/README.md +1 -1
  56. package/lib/module/credential/issuance/const.js +1 -1
  57. package/lib/module/credential/issuance/const.js.map +1 -1
  58. package/lib/module/credential/issuance/index.js +2 -2
  59. package/lib/module/credential/issuance/index.js.map +1 -1
  60. package/lib/module/credential/issuance/types.js +15 -8
  61. package/lib/module/credential/issuance/types.js.map +1 -1
  62. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +10 -3
  63. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  64. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +11 -4
  65. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  66. package/lib/module/credential/presentation/08-send-authorization-response.js +3 -3
  67. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  68. package/lib/module/credential/presentation/types.js.map +1 -1
  69. package/lib/module/entity/openid-connect/issuer/types.js +2 -2
  70. package/lib/module/entity/openid-connect/issuer/types.js.map +1 -1
  71. package/lib/module/entity/trust/types.js +19 -30
  72. package/lib/module/entity/trust/types.js.map +1 -1
  73. package/lib/module/index.js +2 -1
  74. package/lib/module/index.js.map +1 -1
  75. package/lib/module/mdoc/index.js +4 -4
  76. package/lib/module/mdoc/index.js.map +1 -1
  77. package/lib/module/sd-jwt/index.js +2 -2
  78. package/lib/module/sd-jwt/index.js.map +1 -1
  79. package/lib/module/sd-jwt/types.js +1 -1
  80. package/lib/module/sd-jwt/types.js.map +1 -1
  81. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +3 -2
  82. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +1 -1
  83. package/lib/module/utils/pop.js +1 -1
  84. package/lib/module/utils/pop.js.map +1 -1
  85. package/lib/module/wallet-instance-attestation/issuing.js +13 -9
  86. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  87. package/lib/module/wallet-instance-attestation/types.js +12 -17
  88. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  89. package/lib/typescript/client/generated/wallet-provider.d.ts +146 -17
  90. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  91. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +15 -0
  92. package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +1 -1
  93. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  94. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +7 -2
  95. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  96. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  97. package/lib/typescript/credential/issuance/const.d.ts +1 -1
  98. package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
  99. package/lib/typescript/credential/issuance/index.d.ts +2 -2
  100. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  101. package/lib/typescript/credential/issuance/types.d.ts +52 -21
  102. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  103. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  104. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  105. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +1 -1
  106. package/lib/typescript/credential/presentation/types.d.ts +4 -2
  107. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  108. package/lib/typescript/entity/openid-connect/issuer/types.d.ts +17 -17
  109. package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +1 -1
  110. package/lib/typescript/entity/trust/index.d.ts +150 -140
  111. package/lib/typescript/entity/trust/index.d.ts.map +1 -1
  112. package/lib/typescript/entity/trust/types.d.ts +540 -344
  113. package/lib/typescript/entity/trust/types.d.ts.map +1 -1
  114. package/lib/typescript/index.d.ts +2 -1
  115. package/lib/typescript/index.d.ts.map +1 -1
  116. package/lib/typescript/pid/sd-jwt/types.d.ts +2 -2
  117. package/lib/typescript/sd-jwt/index.d.ts +12 -12
  118. package/lib/typescript/sd-jwt/types.d.ts +14 -14
  119. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +1 -1
  120. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  121. package/lib/typescript/wallet-instance-attestation/types.d.ts +50 -102
  122. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  123. package/package.json +2 -2
  124. package/src/client/generated/wallet-provider.ts +39 -7
  125. package/src/credential/issuance/02-get-issuer-config.ts +117 -0
  126. package/src/credential/issuance/03-start-user-authorization.ts +7 -8
  127. package/src/credential/issuance/06-obtain-credential.ts +41 -14
  128. package/src/credential/issuance/07-verify-and-parse-credential.ts +7 -3
  129. package/src/credential/issuance/README.md +1 -1
  130. package/src/credential/issuance/const.ts +1 -0
  131. package/src/credential/issuance/index.ts +6 -1
  132. package/src/credential/issuance/types.ts +21 -8
  133. package/src/credential/presentation/07-evaluate-dcql-query.ts +15 -5
  134. package/src/credential/presentation/07-evaluate-input-descriptor.ts +21 -4
  135. package/src/credential/presentation/08-send-authorization-response.ts +3 -3
  136. package/src/credential/presentation/types.ts +3 -0
  137. package/src/entity/openid-connect/issuer/types.ts +2 -1
  138. package/src/entity/trust/types.ts +22 -20
  139. package/src/index.ts +2 -0
  140. package/src/mdoc/index.ts +4 -4
  141. package/src/sd-jwt/index.ts +2 -2
  142. package/src/sd-jwt/types.ts +1 -1
  143. package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +3 -2
  144. package/src/utils/pop.ts +1 -1
  145. package/src/wallet-instance-attestation/issuing.ts +14 -8
  146. package/src/wallet-instance-attestation/types.ts +16 -22
@@ -49,12 +49,12 @@ const CredentialIssuerDisplayMetadata = z.object({
49
49
  });
50
50
 
51
51
  type ClaimsMetadata = z.infer<typeof ClaimsMetadata>;
52
- const ClaimsMetadata = z.record(
53
- z.object({
54
- value_type: z.string(),
55
- display: z.array(z.object({ name: z.string(), locale: z.string() })),
56
- })
57
- );
52
+ const ClaimsMetadata = z.object({
53
+ path: z.array(z.string()),
54
+ display: z.array(CredentialDisplayMetadata),
55
+ mandatory: z.boolean().optional(),
56
+ value_type: z.string().optional(),
57
+ });
58
58
 
59
59
  type IssuanceErrorSupported = z.infer<typeof IssuanceErrorSupported>;
60
60
  const IssuanceErrorSupported = z.object({
@@ -70,12 +70,17 @@ const IssuanceErrorSupported = z.object({
70
70
  // Metadata for a credentia which is supported by a Issuer
71
71
  type SupportedCredentialMetadata = z.infer<typeof SupportedCredentialMetadata>;
72
72
  const SupportedCredentialMetadata = z.object({
73
- format: z.union([z.literal("vc+sd-jwt"), z.literal("mso_mdoc")]),
73
+ format: z.union([
74
+ z.literal("vc+sd-jwt"),
75
+ z.literal("dc+sd-jwt"),
76
+ z.literal("mso_mdoc"),
77
+ ]),
78
+ vct: z.string().optional(),
74
79
  scope: z.string(),
75
80
  display: z.array(CredentialDisplayMetadata),
76
- claims: ClaimsMetadata.optional(), // TODO [SIW-1268]: should not be optional
81
+ claims: z.array(ClaimsMetadata),
77
82
  cryptographic_binding_methods_supported: z.array(z.string()),
78
- credential_signing_alg_values_supported: z.array(z.string()),
83
+ credential_signing_alg_values_supported: z.array(z.string()).optional(),
79
84
  authentic_source: z.string().optional(),
80
85
  issuance_errors_supported: z.record(IssuanceErrorSupported).optional(),
81
86
  });
@@ -165,40 +170,37 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(
165
170
  credential_issuer: z.string(),
166
171
  credential_endpoint: z.string(),
167
172
  revocation_endpoint: z.string(),
173
+ nonce_endpoint: z.string(),
168
174
  status_attestation_endpoint: z.string(),
169
175
  display: z.array(CredentialIssuerDisplayMetadata),
170
176
  credential_configurations_supported: z.record(
171
177
  SupportedCredentialMetadata
172
178
  ),
173
179
  jwks: z.object({ keys: z.array(JWK) }),
180
+ trust_frameworks_supported: z.array(z.string()),
181
+ evidence_supported: z.array(z.string()),
174
182
  }),
175
183
  oauth_authorization_server: z.object({
176
184
  authorization_endpoint: z.string(),
177
185
  pushed_authorization_request_endpoint: z.string(),
178
- dpop_signing_alg_values_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
179
186
  token_endpoint: z.string(),
180
- introspection_endpoint: z.string().optional(), // TODO [SIW-1268]: should not be optional
181
187
  client_registration_types_supported: z.array(z.string()),
182
188
  code_challenge_methods_supported: z.array(z.string()),
183
- authorization_details_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional,
184
189
  acr_values_supported: z.array(z.string()),
185
190
  grant_types_supported: z.array(z.string()),
186
191
  issuer: z.string(),
187
192
  jwks: z.object({ keys: z.array(JWK) }),
188
193
  scopes_supported: z.array(z.string()),
189
- request_parameter_supported: z.boolean().optional(), // TODO [SIW-1268]: should not be optional
190
- request_uri_parameter_supported: z.boolean().optional(), // TODO [SIW-1268]: should not be optional
191
- response_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
192
194
  response_modes_supported: z.array(z.string()),
193
- subject_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
194
195
  token_endpoint_auth_methods_supported: z.array(z.string()),
195
196
  token_endpoint_auth_signing_alg_values_supported: z.array(z.string()),
196
197
  request_object_signing_alg_values_supported: z.array(z.string()),
197
198
  }),
198
- /** Credential Issuers act as Relying Party
199
- when they require the presentation of other credentials.
200
- This does not apply for PID issuance, which requires CIE authz. */
201
- wallet_relying_party: RelyingPartyMetadata.optional(),
199
+ /**
200
+ * Credential Issuers act as Relying Party when they require the presentation of other credentials.
201
+ * This does not apply for PID issuance, which requires CIE authz.
202
+ */
203
+ openid_credential_verifier: RelyingPartyMetadata.optional(),
202
204
  }),
203
205
  }),
204
206
  })
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ import * as WalletInstance from "./wallet-instance";
13
13
  import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
14
14
  import { createCryptoContextFor } from "./utils/crypto";
15
15
  import type { IntegrityContext } from "./utils/integrity";
16
+ import { getCredentialIssuerEntityConfiguration } from "./entity/trust";
16
17
 
17
18
  export {
18
19
  SdJwt,
@@ -25,6 +26,7 @@ export {
25
26
  AuthorizationDetail,
26
27
  AuthorizationDetails,
27
28
  fixBase64EncodingOnKey,
29
+ getCredentialIssuerEntityConfiguration,
28
30
  };
29
31
 
30
32
  export type { IntegrityContext, AuthorizationContext };
package/src/mdoc/index.ts CHANGED
@@ -14,13 +14,13 @@ export const verify = async (
14
14
  token: string,
15
15
  _: JWK | JWK[]
16
16
  ): Promise<{ issuerSigned: CBOR.IssuerSigned }> => {
17
- // get decoded data
18
- const issuerSigned = await CBOR.decodeIssuerSigned(token);
17
+ // ensure that token is base64
18
+ const issuerSigned = await CBOR.decodeIssuerSigned(b64utob64(token));
19
19
  if (!issuerSigned) {
20
20
  throw new Error("Invalid mDoc");
21
21
  }
22
22
 
23
- const cert = issuerSigned.issuerAuth.unprotectedHeader[0]?.keyId;
23
+ const cert = issuerSigned.issuerAuth.unprotectedHeader[0]?.x5chain?.[0];
24
24
  if (!cert) throw new Error("Certificate not present in credential");
25
25
 
26
26
  const pemcert = convertCertToPem(b64utob64(cert));
@@ -55,7 +55,7 @@ export const prepareVpTokenMdoc = async (
55
55
  /* verifiableCredential is a IssuerSigned structure */
56
56
  const documents = [
57
57
  {
58
- issuerSignedContent: verifiableCredential,
58
+ issuerSignedContent: b64utob64(verifiableCredential),
59
59
  alias: keyTag,
60
60
  docType,
61
61
  },
@@ -41,7 +41,7 @@ export const decode = <S extends z.ZodType<SdJwt4VC>>(
41
41
  if (token.slice(-1) === "~") {
42
42
  token = token.slice(0, -1);
43
43
  }
44
- const [rawSdJwt = "", ...rawDisclosures] = token.split("~");
44
+ const [rawSdJwt = "", ...rawDisclosures] = token.split("~").filter(Boolean);
45
45
 
46
46
  // get the sd-jwt as object
47
47
  // validate it's a valid SD-JWT for Verifiable Credentials
@@ -80,7 +80,7 @@ export const disclose = async (
80
80
  token: string,
81
81
  claims: string[]
82
82
  ): Promise<{ token: string; paths: { claim: string; path: string }[] }> => {
83
- const [rawSdJwt, ...rawDisclosures] = token.split("~");
83
+ const [rawSdJwt, ...rawDisclosures] = token.split("~").filter(Boolean);
84
84
  const { sdJwt, disclosures } = decode(token, SdJwt4VC);
85
85
 
86
86
  // for each claim, return the path on which they are located in the SD-JWT token
@@ -49,7 +49,7 @@ export const SdJwt4VC = z.object({
49
49
  typ: CredentialFormat,
50
50
  alg: z.string(),
51
51
  kid: z.string().optional(),
52
- x5c: z.string().optional(),
52
+ x5c: z.array(z.string()).optional(),
53
53
  vctm: z.array(z.string()).optional(),
54
54
  }),
55
55
  payload: z.intersection(
@@ -127,10 +127,11 @@ export function buildMockSDJWTTestScenario(
127
127
  ): Parameters<typeof parseCredentialSdJwt> {
128
128
  return [
129
129
  {
130
- "eu.europa.ec.eudi.pid.1": {
130
+ dc_sd_jwt_PersonIdentificationData: {
131
131
  cryptographic_suites_supported: [],
132
132
  cryptographic_binding_methods_supported: [],
133
133
  format: "vc+sd-jwt",
134
+ vct: "urn:eu.europa.ec.eudi:pid:1",
134
135
  display: [],
135
136
  claims,
136
137
  },
@@ -147,7 +148,7 @@ export function buildMockSDJWTTestScenario(
147
148
  credential_hash_alg: "sha-256",
148
149
  },
149
150
  },
150
- vct: "eu.europa.ec.eudi.pid.1",
151
+ vct: "urn:eu.europa.ec.eudi:pid:1",
151
152
  iss: "unused",
152
153
  sub: "unused",
153
154
  expiry_date: "unused",
package/src/utils/pop.ts CHANGED
@@ -18,7 +18,7 @@ export const createPopToken = async (
18
18
  return new SignJWT(crypto)
19
19
  .setPayload(payload)
20
20
  .setProtectedHeader({
21
- typ: "jwt-client-attestation-pop",
21
+ typ: "oauth-client-attestation-pop+jwt",
22
22
  kid,
23
23
  })
24
24
  .setIssuedAt()
@@ -7,11 +7,12 @@ import { fixBase64EncodingOnKey, JWK } from "../utils/jwk";
7
7
  import { getWalletProviderClient } from "../client";
8
8
  import type { IntegrityContext } from "..";
9
9
  import {
10
+ IoWalletError,
10
11
  ResponseErrorBuilder,
11
12
  WalletProviderResponseError,
12
13
  WalletProviderResponseErrorCodes,
13
14
  } from "../utils/errors";
14
- import { TokenResponse } from "./types";
15
+ import { WalletAttestationResponse } from "./types";
15
16
 
16
17
  /**
17
18
  * Getter for an attestation request. The attestation request is a JWT that will be sent to the Wallet Provider to request a Wallet Instance Attestation.
@@ -47,8 +48,8 @@ export async function getAttestationRequest(
47
48
  return new SignJWT(wiaCryptoContext)
48
49
  .setPayload({
49
50
  iss: keyThumbprint,
50
- sub: walletProviderBaseUrl,
51
- challenge,
51
+ aud: walletProviderBaseUrl,
52
+ nonce: challenge,
52
53
  hardware_signature: signature,
53
54
  integrity_assertion: authenticatorData,
54
55
  hardware_key_tag: hardwareKeyTag,
@@ -58,7 +59,7 @@ export async function getAttestationRequest(
58
59
  })
59
60
  .setProtectedHeader({
60
61
  kid: publicKey.kid,
61
- typ: "war+jwt",
62
+ typ: "wp-war+jwt",
62
63
  })
63
64
  .setIssuedAt()
64
65
  .setExpirationTime("1h")
@@ -103,16 +104,21 @@ export const getAttestation = async ({
103
104
 
104
105
  // 3. Request WIA
105
106
  const tokenResponse = await api
106
- .post("/token", {
107
+ .post("/wallet-attestations", {
107
108
  body: {
108
- grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
109
109
  assertion: signedAttestationRequest,
110
110
  },
111
111
  })
112
- .then((result) => TokenResponse.parse(result))
112
+ .then(WalletAttestationResponse.parse)
113
113
  .catch(handleAttestationCreationError);
114
114
 
115
- return tokenResponse.wallet_attestation;
115
+ const wallet_attestation = tokenResponse.wallet_attestations;
116
+ if (wallet_attestation && wallet_attestation[0]) {
117
+ // Return first because eudiw be return only jwt
118
+ return wallet_attestation[0].wallet_attestation;
119
+ }
120
+
121
+ throw new IoWalletError("Wallet Attestation response is empty!");
116
122
  };
117
123
 
118
124
  const handleAttestationCreationError = (e: unknown) => {
@@ -33,7 +33,7 @@ export const WalletInstanceAttestationRequestJwt = z.object({
33
33
  header: z.intersection(
34
34
  Jwt.shape.header,
35
35
  z.object({
36
- typ: z.literal("war+jwt"),
36
+ typ: z.literal("wp-war+jwt"),
37
37
  })
38
38
  ),
39
39
  payload: z.intersection(
@@ -53,35 +53,29 @@ export const WalletInstanceAttestationJwt = z.object({
53
53
  header: z.intersection(
54
54
  Jwt.shape.header,
55
55
  z.object({
56
- typ: z.literal("wallet-attestation+jwt"),
56
+ typ: z.literal("oauth-client-attestation+jwt"),
57
+ trust_chain: z.array(z.string()).optional(), // TODO: [SIW-2264] Make mandatory
57
58
  })
58
59
  ),
59
60
  payload: z.intersection(
60
61
  Jwt.shape.payload,
61
62
  z.object({
62
63
  sub: z.string(),
63
- aal: z.string(),
64
- authorization_endpoint: z.string(),
65
- response_types_supported: z.array(z.string()),
66
- vp_formats_supported: z.object({
67
- "vc+sd-jwt": z
68
- .object({
69
- "sd-jwt_alg_values": z.array(z.string()),
70
- })
71
- .optional(),
72
- "vp+sd-jwt": z
73
- .object({
74
- "sd-jwt_alg_values": z.array(z.string()),
75
- })
76
- .optional(),
77
- }),
78
- request_object_signing_alg_values_supported: z.array(z.string()),
79
- presentation_definition_uri_supported: z.boolean(),
64
+ aal: z.string().optional(),
65
+ wallet_link: z.string().optional(),
66
+ wallet_name: z.string().optional(),
80
67
  })
81
68
  ),
82
69
  });
83
70
 
84
- export type TokenResponse = z.infer<typeof TokenResponse>;
85
- export const TokenResponse = z.object({
86
- wallet_attestation: z.string(),
71
+ export type WalletAttestationResponse = z.infer<
72
+ typeof WalletAttestationResponse
73
+ >;
74
+ export const WalletAttestationResponse = z.object({
75
+ wallet_attestations: z.array(
76
+ z.object({
77
+ wallet_attestation: z.string(),
78
+ format: z.enum(["jwt", "dc+sd-jwt", "mso_mdoc"]),
79
+ })
80
+ ),
87
81
  });