@pagopa/io-react-native-wallet 1.6.2 → 1.7.1

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 (81) hide show
  1. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +69 -35
  2. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  3. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +181 -0
  4. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -0
  5. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +3 -67
  6. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  7. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +98 -2
  8. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
  9. package/lib/commonjs/credential/presentation/index.js +14 -1
  10. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  11. package/lib/commonjs/credential/presentation/types.js +9 -2
  12. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  13. package/lib/commonjs/mdoc/index.js +1 -1
  14. package/lib/commonjs/mdoc/index.js.map +1 -1
  15. package/lib/commonjs/sd-jwt/__test__/index.test.js +24 -21
  16. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  17. package/lib/commonjs/sd-jwt/__test__/types.test.js +3 -0
  18. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  19. package/lib/commonjs/sd-jwt/types.js +4 -1
  20. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  21. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +469 -0
  22. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +1 -0
  23. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +90 -0
  24. package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +1 -0
  25. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +67 -35
  26. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  27. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +175 -0
  28. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -0
  29. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +3 -66
  30. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  31. package/lib/module/credential/presentation/08-send-authorization-response.js +97 -2
  32. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  33. package/lib/module/credential/presentation/index.js +4 -3
  34. package/lib/module/credential/presentation/index.js.map +1 -1
  35. package/lib/module/credential/presentation/types.js +9 -2
  36. package/lib/module/credential/presentation/types.js.map +1 -1
  37. package/lib/module/mdoc/index.js +1 -1
  38. package/lib/module/mdoc/index.js.map +1 -1
  39. package/lib/module/sd-jwt/__test__/index.test.js +24 -21
  40. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  41. package/lib/module/sd-jwt/__test__/types.test.js +3 -0
  42. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  43. package/lib/module/sd-jwt/types.js +4 -1
  44. package/lib/module/sd-jwt/types.js.map +1 -1
  45. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +462 -0
  46. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +1 -0
  47. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +83 -0
  48. package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +1 -0
  49. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +12 -0
  50. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  51. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +27 -0
  52. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -0
  53. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +2 -28
  54. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  55. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +23 -1
  56. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
  57. package/lib/typescript/credential/presentation/index.d.ts +6 -4
  58. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  59. package/lib/typescript/credential/presentation/types.d.ts +26 -7
  60. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  61. package/lib/typescript/sd-jwt/index.d.ts +12 -0
  62. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  63. package/lib/typescript/sd-jwt/types.d.ts +15 -0
  64. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  65. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +3 -0
  66. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +1 -0
  67. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +42 -0
  68. package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +1 -0
  69. package/package.json +3 -2
  70. package/src/credential/issuance/07-verify-and-parse-credential.ts +35 -3
  71. package/src/credential/presentation/07-evaluate-dcql-query.ts +228 -0
  72. package/src/credential/presentation/07-evaluate-input-descriptor.ts +6 -103
  73. package/src/credential/presentation/08-send-authorization-response.ts +137 -2
  74. package/src/credential/presentation/index.ts +12 -2
  75. package/src/credential/presentation/types.ts +33 -3
  76. package/src/mdoc/index.ts +1 -1
  77. package/src/sd-jwt/__test__/index.test.ts +45 -36
  78. package/src/sd-jwt/__test__/types.test.ts +3 -0
  79. package/src/sd-jwt/types.ts +3 -0
  80. package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +615 -0
  81. package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +171 -0
@@ -0,0 +1,171 @@
1
+ import type {
2
+ parseCredentialMDoc,
3
+ parseCredentialSdJwt,
4
+ } from "src/credential/issuance/07-verify-and-parse-credential";
5
+
6
+ export type TestScenario<
7
+ T extends object,
8
+ R extends object,
9
+ E extends Error,
10
+ > = {
11
+ name: string;
12
+ input: T;
13
+ expected?: R;
14
+ throws?: E;
15
+ };
16
+
17
+ export type ParseCredentialArg =
18
+ | {
19
+ format: "vc+sd-jwt";
20
+ parameters: Parameters<typeof parseCredentialSdJwt>;
21
+ }
22
+ | {
23
+ format: "mso_mdoc";
24
+ parameters: Parameters<typeof parseCredentialMDoc>;
25
+ };
26
+
27
+ export type ClaimsSdJwt =
28
+ | Record<
29
+ string,
30
+ {
31
+ display: {
32
+ name: string;
33
+ locale: string;
34
+ }[];
35
+ mandatory: boolean;
36
+ }
37
+ >
38
+ | Record<
39
+ string,
40
+ Record<
41
+ string,
42
+ {
43
+ display: {
44
+ name: string;
45
+ locale: string;
46
+ }[];
47
+ mandatory: boolean;
48
+ }
49
+ >
50
+ >;
51
+
52
+ export type ClaimsMDOC = Record<
53
+ string,
54
+ {
55
+ display: {
56
+ name: string;
57
+ locale: string;
58
+ }[];
59
+ mandatory: boolean;
60
+ }
61
+ >;
62
+
63
+ export type ParseCredentialReturn = Record<
64
+ string,
65
+ {
66
+ name?: string | Record<string, string>;
67
+ value: unknown;
68
+ mandatory?: boolean;
69
+ }
70
+ >;
71
+
72
+ export function buildMockMDOCTestScenario(
73
+ claims: ClaimsMDOC,
74
+ nameSpaces: [string, any][]
75
+ ): Parameters<typeof parseCredentialMDoc> {
76
+ return [
77
+ {
78
+ "org.iso.18013.5.1.mDL": {
79
+ cryptographic_suites_supported: [],
80
+ cryptographic_binding_methods_supported: [],
81
+ format: "mso_mdoc",
82
+ display: [],
83
+ claims: {
84
+ "org.iso.18013.5.1": claims,
85
+ },
86
+ },
87
+ },
88
+ "org.iso.18013.5.1.mDL",
89
+ {
90
+ issuerSigned: {
91
+ nameSpaces: {
92
+ "org.iso.18013.5.1": nameSpaces.map((namespace) => ({
93
+ elementIdentifier: namespace[0],
94
+ elementValue: namespace[1],
95
+ })),
96
+ },
97
+ issuerAuth: {
98
+ unprotectedHeader: [],
99
+ protectedHeader: "unused",
100
+ payload: {
101
+ validityInfo: {
102
+ signed: new Date(2000, 2, 1),
103
+ validFrom: new Date(2000, 2, 1),
104
+ validUntil: new Date(2000, 2, 1),
105
+ },
106
+ deviceKeyInfo: {
107
+ deviceKey: {
108
+ kty: "EC",
109
+ crv: "P-256",
110
+ x: "unused",
111
+ y: "unused",
112
+ },
113
+ },
114
+ valueDigests: {},
115
+ },
116
+ },
117
+ },
118
+ },
119
+ false,
120
+ true,
121
+ ];
122
+ }
123
+
124
+ export function buildMockSDJWTTestScenario(
125
+ claims: ClaimsSdJwt,
126
+ disclosures: [string, string, unknown][]
127
+ ): Parameters<typeof parseCredentialSdJwt> {
128
+ return [
129
+ {
130
+ "eu.europa.ec.eudi.pid.1": {
131
+ cryptographic_suites_supported: [],
132
+ cryptographic_binding_methods_supported: [],
133
+ format: "vc+sd-jwt",
134
+ display: [],
135
+ claims,
136
+ },
137
+ },
138
+ {
139
+ sdJwt: {
140
+ header: {
141
+ typ: "vc+sd-jwt",
142
+ alg: "unused",
143
+ },
144
+ payload: {
145
+ status: {
146
+ status_assertion: {
147
+ credential_hash_alg: "sha-256",
148
+ },
149
+ },
150
+ vct: "eu.europa.ec.eudi.pid.1",
151
+ iss: "unused",
152
+ sub: "unused",
153
+ expiry_date: "unused",
154
+ issuing_authority: "unused",
155
+ issuing_country: "unused",
156
+ exp: 0,
157
+ _sd_alg: "sha-256",
158
+ cnf: {
159
+ jwk: {
160
+ kty: "RSA",
161
+ },
162
+ },
163
+ _sd: [],
164
+ },
165
+ },
166
+ disclosures,
167
+ },
168
+ false,
169
+ true,
170
+ ];
171
+ }