@pagopa/io-react-native-wallet 2.0.0-next.9 → 2.0.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 (54) hide show
  1. package/README.md +3 -3
  2. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +7 -1
  3. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  4. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +3 -2
  5. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  6. package/lib/commonjs/credential/status/02-status-assertion.js.map +1 -1
  7. package/lib/commonjs/credential/status/03-verify-and-parse-status-assertion.js.map +1 -1
  8. package/lib/commonjs/sd-jwt/types.js +11 -4
  9. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  10. package/lib/commonjs/trust/types.js +6 -0
  11. package/lib/commonjs/trust/types.js.map +1 -1
  12. package/lib/commonjs/utils/credentials.js +2 -1
  13. package/lib/commonjs/utils/credentials.js.map +1 -1
  14. package/lib/commonjs/utils/misc.js +3 -1
  15. package/lib/commonjs/utils/misc.js.map +1 -1
  16. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +7 -1
  17. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  18. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +3 -2
  19. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  20. package/lib/module/credential/status/02-status-assertion.js.map +1 -1
  21. package/lib/module/credential/status/03-verify-and-parse-status-assertion.js.map +1 -1
  22. package/lib/module/sd-jwt/types.js +9 -2
  23. package/lib/module/sd-jwt/types.js.map +1 -1
  24. package/lib/module/trust/types.js +6 -0
  25. package/lib/module/trust/types.js.map +1 -1
  26. package/lib/module/utils/credentials.js +2 -1
  27. package/lib/module/utils/credentials.js.map +1 -1
  28. package/lib/module/utils/misc.js +1 -0
  29. package/lib/module/utils/misc.js.map +1 -1
  30. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +1 -1
  31. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  32. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +2 -2
  33. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  34. package/lib/typescript/credential/status/02-status-assertion.d.ts +2 -1
  35. package/lib/typescript/credential/status/02-status-assertion.d.ts.map +1 -1
  36. package/lib/typescript/credential/status/03-verify-and-parse-status-assertion.d.ts +2 -1
  37. package/lib/typescript/credential/status/03-verify-and-parse-status-assertion.d.ts.map +1 -1
  38. package/lib/typescript/sd-jwt/types.d.ts +7 -1
  39. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  40. package/lib/typescript/trust/types.d.ts +4 -0
  41. package/lib/typescript/trust/types.d.ts.map +1 -1
  42. package/lib/typescript/utils/credentials.d.ts +2 -1
  43. package/lib/typescript/utils/credentials.d.ts.map +1 -1
  44. package/lib/typescript/utils/misc.d.ts +1 -0
  45. package/lib/typescript/utils/misc.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/src/credential/issuance/07-verify-and-parse-credential.ts +9 -8
  48. package/src/credential/presentation/07-evaluate-dcql-query.ts +4 -4
  49. package/src/credential/status/02-status-assertion.ts +2 -1
  50. package/src/credential/status/03-verify-and-parse-status-assertion.ts +2 -1
  51. package/src/sd-jwt/types.ts +9 -2
  52. package/src/trust/types.ts +4 -0
  53. package/src/utils/credentials.ts +6 -2
  54. package/src/utils/misc.ts +3 -0
@@ -17,12 +17,13 @@ import { Logger, LogLevel } from "../../utils/logging";
17
17
  import type { ObtainCredential } from "../issuance";
18
18
  import { extractJwkFromCredential } from "../../utils/credentials";
19
19
  import { isSameThumbprint } from "../../utils/jwk";
20
+ import type { SupportedSdJwtLegacyFormat } from "../../sd-jwt/types";
20
21
 
21
22
  export type VerifyAndParseStatusAssertion = (
22
23
  issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
23
24
  statusAssertion: Out<StatusAssertion>,
24
25
  credential: Out<ObtainCredential>["credential"],
25
- format: Out<ObtainCredential>["format"]
26
+ format: Out<ObtainCredential>["format"] | SupportedSdJwtLegacyFormat
26
27
  ) => Promise<{ parsedStatusAssertion: ParsedStatusAssertion }>;
27
28
 
28
29
  /**
@@ -20,6 +20,13 @@ export const Disclosure = z.tuple([
20
20
  /* claim value */ z.unknown(),
21
21
  ]);
22
22
 
23
+ /**
24
+ * For backward compatibility reasons it is still necessary to support the legacy SD-JWT
25
+ * in a few flows (for instance status assertion and presentation of the old eID).
26
+ */
27
+ export type SupportedSdJwtLegacyFormat = typeof LEGACY_SD_JWT;
28
+ export const LEGACY_SD_JWT = "vc+sd-jwt";
29
+
23
30
  /**
24
31
  * Encoding depends on the serialization algorithm used when generating the disclosure tokens.
25
32
  * The SD-JWT reference itself take no decision about how to handle whitespaces in serialized objects.
@@ -44,7 +51,7 @@ const StatusAssertion = z.object({
44
51
  export type SdJwt4VC = z.infer<typeof SdJwt4VC>;
45
52
  export const SdJwt4VC = z.object({
46
53
  header: z.object({
47
- typ: z.enum(["vc+sd-jwt", "dc+sd-jwt"]),
54
+ typ: z.enum(["dc+sd-jwt", LEGACY_SD_JWT]),
48
55
  alg: z.string(),
49
56
  kid: z.string(),
50
57
  trust_chain: z.array(z.string()).optional(),
@@ -62,7 +69,7 @@ export const SdJwt4VC = z.object({
62
69
  .union([
63
70
  // Credentials v1.0
64
71
  z.object({ status_assertion: StatusAssertion }),
65
- // Credentials v0.7.1
72
+ // Legacy credentials v0.7.1
66
73
  z.object({ status_attestation: StatusAssertion }),
67
74
  ])
68
75
  .optional(),
@@ -71,6 +71,10 @@ const SupportedCredentialMetadata = z.intersection(
71
71
  })
72
72
  );
73
73
 
74
+ /**
75
+ * Supported formats for credentials issued by the Issuer API 1.0,
76
+ * compliant with IT-Wallet technical specifications 1.0.
77
+ */
74
78
  export type SupportedCredentialFormat = z.infer<
75
79
  typeof SupportedCredentialMetadata
76
80
  >["format"];
@@ -4,8 +4,12 @@ import type { Out } from "./misc";
4
4
  import type { ObtainCredential } from "../credential/issuance";
5
5
  import type { JWK } from "./jwk";
6
6
  import { IoWalletError } from "./errors";
7
+ import {
8
+ LEGACY_SD_JWT,
9
+ type SupportedSdJwtLegacyFormat,
10
+ } from "../sd-jwt/types";
7
11
 
8
- const SD_JWT = ["vc+sd-jwt", "dc+sd-jwt"];
12
+ const SD_JWT = ["dc+sd-jwt", LEGACY_SD_JWT];
9
13
 
10
14
  /**
11
15
  * Extracts a JWK from a credential.
@@ -15,7 +19,7 @@ const SD_JWT = ["vc+sd-jwt", "dc+sd-jwt"];
15
19
  */
16
20
  export const extractJwkFromCredential = async (
17
21
  credential: Out<ObtainCredential>["credential"],
18
- format: Out<ObtainCredential>["format"]
22
+ format: Out<ObtainCredential>["format"] | SupportedSdJwtLegacyFormat
19
23
  ): Promise<JWK> => {
20
24
  if (SD_JWT.includes(format)) {
21
25
  // 1. SD-JWT case
package/src/utils/misc.ts CHANGED
@@ -78,3 +78,6 @@ export const safeJsonParse = <T>(text: string, withDefault?: T): T | null => {
78
78
  return withDefault ?? null;
79
79
  }
80
80
  };
81
+
82
+ export const isObject = (value: unknown): value is Record<string, unknown> =>
83
+ typeof value === "object" && value !== null && !Array.isArray(value);