@pagopa/io-react-native-wallet 3.5.1 → 3.6.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 (63) hide show
  1. package/lib/commonjs/credential/issuance/api/IssuerConfig.js +1 -1
  2. package/lib/commonjs/credential/issuance/api/IssuerConfig.js.map +1 -1
  3. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.mdoc.js +8 -3
  4. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.mdoc.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js +6 -4
  6. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/v1.3.3/mappers.js +1 -1
  8. package/lib/commonjs/credential/issuance/v1.3.3/mappers.js.map +1 -1
  9. package/lib/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.js +1 -0
  10. package/lib/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.js.map +1 -1
  11. package/lib/commonjs/credentials-catalogue/v1.3.3/mappers.js +2 -2
  12. package/lib/commonjs/credentials-catalogue/v1.3.3/mappers.js.map +1 -1
  13. package/lib/commonjs/credentials-catalogue/v1.3.3/types.js +2 -1
  14. package/lib/commonjs/credentials-catalogue/v1.3.3/types.js.map +1 -1
  15. package/lib/commonjs/mdoc/const.js +3 -1
  16. package/lib/commonjs/mdoc/const.js.map +1 -1
  17. package/lib/commonjs/mdoc/utils.js +5 -5
  18. package/lib/commonjs/mdoc/utils.js.map +1 -1
  19. package/lib/module/credential/issuance/api/IssuerConfig.js +1 -1
  20. package/lib/module/credential/issuance/api/IssuerConfig.js.map +1 -1
  21. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.mdoc.js +8 -3
  22. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.mdoc.js.map +1 -1
  23. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js +6 -4
  24. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js.map +1 -1
  25. package/lib/module/credential/issuance/v1.3.3/mappers.js +1 -1
  26. package/lib/module/credential/issuance/v1.3.3/mappers.js.map +1 -1
  27. package/lib/module/credentials-catalogue/api/DigitalCredentialsCatalogue.js +1 -0
  28. package/lib/module/credentials-catalogue/api/DigitalCredentialsCatalogue.js.map +1 -1
  29. package/lib/module/credentials-catalogue/v1.3.3/mappers.js +2 -2
  30. package/lib/module/credentials-catalogue/v1.3.3/mappers.js.map +1 -1
  31. package/lib/module/credentials-catalogue/v1.3.3/types.js +2 -1
  32. package/lib/module/credentials-catalogue/v1.3.3/types.js.map +1 -1
  33. package/lib/module/mdoc/const.js +1 -0
  34. package/lib/module/mdoc/const.js.map +1 -1
  35. package/lib/module/mdoc/utils.js +6 -6
  36. package/lib/module/mdoc/utils.js.map +1 -1
  37. package/lib/typescript/credential/issuance/api/IssuerConfig.d.ts +2 -2
  38. package/lib/typescript/credential/issuance/common/06-verify-and-parse-credential.mdoc.d.ts.map +1 -1
  39. package/lib/typescript/credential/issuance/common/06-verify-and-parse-credential.sdjwt.d.ts.map +1 -1
  40. package/lib/typescript/credential/issuance/v1.0.0/mappers.d.ts +2 -2
  41. package/lib/typescript/credential/issuance/v1.3.3/mappers.d.ts +2 -2
  42. package/lib/typescript/credential/issuance/v1.3.3/mappers.d.ts.map +1 -1
  43. package/lib/typescript/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts +2 -0
  44. package/lib/typescript/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts.map +1 -1
  45. package/lib/typescript/credentials-catalogue/v1.0.0/mappers.d.ts +1 -0
  46. package/lib/typescript/credentials-catalogue/v1.0.0/mappers.d.ts.map +1 -1
  47. package/lib/typescript/credentials-catalogue/v1.3.3/mappers.d.ts +6 -4
  48. package/lib/typescript/credentials-catalogue/v1.3.3/mappers.d.ts.map +1 -1
  49. package/lib/typescript/credentials-catalogue/v1.3.3/types.d.ts +6 -4
  50. package/lib/typescript/credentials-catalogue/v1.3.3/types.d.ts.map +1 -1
  51. package/lib/typescript/mdoc/const.d.ts +1 -0
  52. package/lib/typescript/mdoc/const.d.ts.map +1 -1
  53. package/lib/typescript/mdoc/utils.d.ts.map +1 -1
  54. package/package.json +1 -1
  55. package/src/credential/issuance/api/IssuerConfig.ts +1 -1
  56. package/src/credential/issuance/common/06-verify-and-parse-credential.mdoc.ts +19 -3
  57. package/src/credential/issuance/common/06-verify-and-parse-credential.sdjwt.ts +14 -4
  58. package/src/credential/issuance/v1.3.3/mappers.ts +1 -1
  59. package/src/credentials-catalogue/api/DigitalCredentialsCatalogue.ts +1 -0
  60. package/src/credentials-catalogue/v1.3.3/mappers.ts +4 -2
  61. package/src/credentials-catalogue/v1.3.3/types.ts +4 -6
  62. package/src/mdoc/const.ts +1 -0
  63. package/src/mdoc/utils.ts +11 -8
@@ -13,6 +13,12 @@ import type { IssuanceApi, IssuerConfig, ParsedCredential } from "../api";
13
13
  type CredentialConf =
14
14
  IssuerConfig["credential_configurations_supported"][string];
15
15
 
16
+ type ClaimConfig = CredentialConf["claims"][number];
17
+
18
+ type DisplayableClaim = Omit<ClaimConfig, "display"> & {
19
+ display: NonNullable<ClaimConfig["display"]>;
20
+ };
21
+
16
22
  type DecodedMDocCredential = Out<typeof verifyMdoc> & {
17
23
  issuerSigned: CBOR.IssuerSigned;
18
24
  };
@@ -75,7 +81,13 @@ const parseCredentialMDoc = (
75
81
  throw new IoWalletError("Missing claims in the credential subject");
76
82
  }
77
83
 
78
- const attrDefinitions = credentialConfig.claims.map<
84
+ // Claims without display property (such as `iat`, `exp`, `iss`, etc.)
85
+ // must be ignored as they are not meant to be displayed to the user.
86
+ const displayableClaims = credentialConfig.claims.filter(
87
+ (c) => c.display !== undefined
88
+ ) as DisplayableClaim[];
89
+
90
+ const attrDefinitions = displayableClaims.map<
79
91
  [string, string, { name: string; locale: string }[]]
80
92
  >(({ path: [namespace, attribute], display }) => [
81
93
  namespace as string,
@@ -183,7 +195,11 @@ export const verifyAndParseCredentialMDoc: IssuanceApi["verifyAndParseCredential
183
195
  issuerConf,
184
196
  credential,
185
197
  credentialConfigurationId,
186
- { credentialCryptoContext, ignoreMissingAttributes },
198
+ {
199
+ credentialCryptoContext,
200
+ ignoreMissingAttributes,
201
+ includeUndefinedAttributes,
202
+ },
187
203
  x509CertRoot
188
204
  ) => {
189
205
  if (!x509CertRoot) {
@@ -204,7 +220,7 @@ export const verifyAndParseCredentialMDoc: IssuanceApi["verifyAndParseCredential
204
220
  credentialConfig,
205
221
  decoded,
206
222
  ignoreMissingAttributes,
207
- ignoreMissingAttributes
223
+ includeUndefinedAttributes
208
224
  );
209
225
 
210
226
  const { signed, validUntil } =
@@ -18,6 +18,12 @@ import type { IssuanceApi, IssuerConfig, ParsedCredential } from "../api";
18
18
  type CredentialConf =
19
19
  IssuerConfig["credential_configurations_supported"][string];
20
20
 
21
+ type ClaimConfig = CredentialConf["claims"][number];
22
+
23
+ type DisplayableClaim = Omit<ClaimConfig, "display"> & {
24
+ display: NonNullable<ClaimConfig["display"]>;
25
+ };
26
+
21
27
  /**
22
28
  * Parse a Sd-Jwt credential according to the issuer configuration
23
29
  * @param credentialConfig - the list of supported credentials, as defined in the issuer configuration with their claims metadata
@@ -32,13 +38,17 @@ const parseCredentialSdJwt = (
32
38
  ignoreMissingAttributes: boolean = false,
33
39
  includeUndefinedAttributes: boolean = false
34
40
  ): ParsedCredential => {
35
- const claimsMetadata = credentialConfig.claims || [];
41
+ // Claims without display property (such as `iat`, `exp`, `iss`, etc.)
42
+ // must be ignored as they are not meant to be displayed to the user.
43
+ const displayableClaims = (credentialConfig.claims || []).filter(
44
+ (c) => c.display !== undefined
45
+ ) as DisplayableClaim[];
36
46
 
37
47
  // Check that all mandatory attributes defined in the issuer configuration are present in the credential
38
48
  if (!ignoreMissingAttributes) {
39
49
  const missingPaths: string[] = [];
40
50
  const rootKeysToVerify = new Set(
41
- claimsMetadata
51
+ displayableClaims
42
52
  .map((c) => c.path[0])
43
53
  .filter((p): p is string => typeof p === "string")
44
54
  );
@@ -64,7 +74,7 @@ const parseCredentialSdJwt = (
64
74
  const getDisplayNames = (
65
75
  path: (string | number | null)[]
66
76
  ): Record<string, string> | undefined => {
67
- const match = claimsMetadata.find((c) => isPathEqual(c.path, path));
77
+ const match = displayableClaims.find((c) => isPathEqual(c.path, path));
68
78
  if (!match) return undefined;
69
79
 
70
80
  const nameMap: Record<string, string> = {};
@@ -99,7 +109,7 @@ const parseCredentialSdJwt = (
99
109
 
100
110
  // Identify unique keys in config at this level
101
111
  const configKeysAtThisLevel: (string | number)[] = [];
102
- for (const claim of claimsMetadata) {
112
+ for (const claim of displayableClaims) {
103
113
  // Check if the claim path starts with the current path
104
114
  if (isPrefixOf(currentPath, claim.path)) {
105
115
  const nextPart = claim.path[currentPath.length];
@@ -25,7 +25,7 @@ const mapCredentialConfigurationsSupported = (
25
25
  claims:
26
26
  config.credential_metadata.claims?.map((claim) => ({
27
27
  path: claim.path,
28
- display: claim.display ?? [],
28
+ display: claim.display,
29
29
  })) ?? [],
30
30
  };
31
31
  return acc;
@@ -115,6 +115,7 @@ export const DigitalCredential = z.object({
115
115
  purposes: z.array(z.union([z.string(), CredentialPurpose])),
116
116
  issuers: z.array(CredentialIssuer),
117
117
  authentic_sources: z.array(AuthenticSource),
118
+ parent_credentials: z.array(z.string()).optional(),
118
119
  formats: z.array(CredentialFormat).optional(),
119
120
  // claims: z.array(Claim), // TODO: [SIW-3978] Should we keep claims?
120
121
  });
@@ -65,7 +65,7 @@ export const mapToCredentialsCatalogue = createMapper<
65
65
  `Schemas for ${credentialType} must be present in the Schema Registry`
66
66
  );
67
67
  return schemas.map((schema) => ({
68
- configuration_id: schema.id, // TODO: [SIW-3978] Does schema ID corresponds to configuration_id?
68
+ configuration_id: schema.id, // TODO: [SIW-3978] Fix this, the schema ID does not correspond to configuration_id
69
69
  ...schema,
70
70
  }));
71
71
  };
@@ -87,7 +87,9 @@ export const mapToCredentialsCatalogue = createMapper<
87
87
  ({ authentic_sources, credential_name_l10n_id, ...credential }) => ({
88
88
  name_l10n_id: credential_name_l10n_id,
89
89
  formats: resolveFormats(credential.credential_type),
90
- authentic_sources: authentic_sources.map(resolveAuthSource),
90
+ authentic_sources: authentic_sources
91
+ ? authentic_sources.map(resolveAuthSource)
92
+ : [],
91
93
  ...credential,
92
94
  })
93
95
  ),
@@ -132,12 +132,10 @@ export const DigitalCredential = z.object({
132
132
  classes: z.array(z.string()).optional(),
133
133
  purposes: z.array(z.string()),
134
134
  issuers: z.array(CredentialIssuer),
135
- authentic_sources: z.array(
136
- z.object({
137
- id: z.string(),
138
- dataset_id: z.string(),
139
- })
140
- ),
135
+ authentic_sources: z
136
+ .array(z.object({ id: z.string(), dataset_id: z.string() }))
137
+ .optional(),
138
+ parent_credentials: z.array(z.string()).optional(),
141
139
  });
142
140
 
143
141
  const JwtHeader = z.object({
package/src/mdoc/const.ts CHANGED
@@ -1 +1,2 @@
1
1
  export const MDOC_DEFAULT_NAMESPACE = "org.iso.18013.5.1";
2
+ export const MDOC_VERIFICATION_IDENTIFIER = "verification";
package/src/mdoc/utils.ts CHANGED
@@ -2,7 +2,7 @@ import { CBOR } from "@pagopa/io-react-native-iso18013";
2
2
  import { Verification } from "../sd-jwt/types";
3
3
  import type { IssuanceApi } from "../credential/issuance";
4
4
  import type { Out } from "../utils/misc";
5
- import { MDOC_DEFAULT_NAMESPACE } from "./const";
5
+ import { MDOC_VERIFICATION_IDENTIFIER } from "./const";
6
6
 
7
7
  /**
8
8
  * @param namespace The mdoc credential `namespace`
@@ -25,11 +25,12 @@ export const getVerificationFromParsedCredential = (
25
25
  IssuanceApi["verifyAndParseCredential"]
26
26
  >["parsedCredential"]
27
27
  ) => {
28
- const verificationKey = getParsedCredentialClaimKey(
29
- `${MDOC_DEFAULT_NAMESPACE}.IT`,
30
- "verification"
28
+ const verificationKey = Object.keys(parsedCredential).find((key) =>
29
+ key.endsWith(MDOC_VERIFICATION_IDENTIFIER)
31
30
  );
32
- const verification = parsedCredential[verificationKey]?.value;
31
+ const verification = verificationKey
32
+ ? parsedCredential[verificationKey]?.value
33
+ : undefined;
33
34
  return verification ? Verification.parse(verification) : undefined;
34
35
  };
35
36
 
@@ -43,9 +44,11 @@ export const getVerificationFromParsedCredential = (
43
44
  */
44
45
  export const getVerification = async (token: string) => {
45
46
  const issuerSigned = await CBOR.decodeIssuerSigned(token);
46
- const namespace = issuerSigned.nameSpaces[`${MDOC_DEFAULT_NAMESPACE}.IT`];
47
- const verification = namespace?.find(
48
- (x) => x.elementIdentifier === "verification"
47
+
48
+ const flattenedClaims = Object.values(issuerSigned.nameSpaces).flat();
49
+
50
+ const verification = flattenedClaims?.find(
51
+ (x) => x.elementIdentifier === MDOC_VERIFICATION_IDENTIFIER
49
52
  )?.elementValue;
50
53
 
51
54
  return verification ? Verification.parse(verification) : undefined;