@pagopa/io-react-native-wallet 0.1.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 (114) hide show
  1. package/README.md +91 -0
  2. package/lib/commonjs/index.js +17 -0
  3. package/lib/commonjs/index.js.map +1 -0
  4. package/lib/commonjs/pid/index.js +11 -0
  5. package/lib/commonjs/pid/index.js.map +1 -0
  6. package/lib/commonjs/pid/sd-jwt/converters.js +29 -0
  7. package/lib/commonjs/pid/sd-jwt/converters.js.map +1 -0
  8. package/lib/commonjs/pid/sd-jwt/index.js +76 -0
  9. package/lib/commonjs/pid/sd-jwt/index.js.map +1 -0
  10. package/lib/commonjs/pid/sd-jwt/types.js +50 -0
  11. package/lib/commonjs/pid/sd-jwt/types.js.map +1 -0
  12. package/lib/commonjs/sd-jwt/__test__/converters.test.js +25 -0
  13. package/lib/commonjs/sd-jwt/__test__/converters.test.js.map +1 -0
  14. package/lib/commonjs/sd-jwt/__test__/types.test.js +70 -0
  15. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -0
  16. package/lib/commonjs/sd-jwt/converters.js +30 -0
  17. package/lib/commonjs/sd-jwt/converters.js.map +1 -0
  18. package/lib/commonjs/sd-jwt/index.js +77 -0
  19. package/lib/commonjs/sd-jwt/index.js.map +1 -0
  20. package/lib/commonjs/sd-jwt/types.js +53 -0
  21. package/lib/commonjs/sd-jwt/types.js.map +1 -0
  22. package/lib/commonjs/sd-jwt/verifier.js +18 -0
  23. package/lib/commonjs/sd-jwt/verifier.js.map +1 -0
  24. package/lib/commonjs/utils/errors.js +82 -0
  25. package/lib/commonjs/utils/errors.js.map +1 -0
  26. package/lib/commonjs/utils/jwk.js +45 -0
  27. package/lib/commonjs/utils/jwk.js.map +1 -0
  28. package/lib/commonjs/wallet-instance-attestation/index.js +63 -0
  29. package/lib/commonjs/wallet-instance-attestation/index.js.map +1 -0
  30. package/lib/commonjs/wallet-instance-attestation/issuing.js +96 -0
  31. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -0
  32. package/lib/commonjs/wallet-instance-attestation/types.js +65 -0
  33. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -0
  34. package/lib/module/index.js +7 -0
  35. package/lib/module/index.js.map +1 -0
  36. package/lib/module/pid/index.js +3 -0
  37. package/lib/module/pid/index.js.map +1 -0
  38. package/lib/module/pid/sd-jwt/converters.js +23 -0
  39. package/lib/module/pid/sd-jwt/converters.js.map +1 -0
  40. package/lib/module/pid/sd-jwt/index.js +66 -0
  41. package/lib/module/pid/sd-jwt/index.js.map +1 -0
  42. package/lib/module/pid/sd-jwt/types.js +43 -0
  43. package/lib/module/pid/sd-jwt/types.js.map +1 -0
  44. package/lib/module/sd-jwt/__test__/converters.test.js +23 -0
  45. package/lib/module/sd-jwt/__test__/converters.test.js.map +1 -0
  46. package/lib/module/sd-jwt/__test__/types.test.js +68 -0
  47. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -0
  48. package/lib/module/sd-jwt/converters.js +24 -0
  49. package/lib/module/sd-jwt/converters.js.map +1 -0
  50. package/lib/module/sd-jwt/index.js +71 -0
  51. package/lib/module/sd-jwt/index.js.map +1 -0
  52. package/lib/module/sd-jwt/types.js +44 -0
  53. package/lib/module/sd-jwt/types.js.map +1 -0
  54. package/lib/module/sd-jwt/verifier.js +11 -0
  55. package/lib/module/sd-jwt/verifier.js.map +1 -0
  56. package/lib/module/utils/errors.js +73 -0
  57. package/lib/module/utils/errors.js.map +1 -0
  58. package/lib/module/utils/jwk.js +38 -0
  59. package/lib/module/utils/jwk.js.map +1 -0
  60. package/lib/module/wallet-instance-attestation/index.js +52 -0
  61. package/lib/module/wallet-instance-attestation/index.js.map +1 -0
  62. package/lib/module/wallet-instance-attestation/issuing.js +90 -0
  63. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -0
  64. package/lib/module/wallet-instance-attestation/types.js +55 -0
  65. package/lib/module/wallet-instance-attestation/types.js.map +1 -0
  66. package/lib/typescript/index.d.ts +5 -0
  67. package/lib/typescript/index.d.ts.map +1 -0
  68. package/lib/typescript/pid/index.d.ts +3 -0
  69. package/lib/typescript/pid/index.d.ts.map +1 -0
  70. package/lib/typescript/pid/sd-jwt/converters.d.ts +4 -0
  71. package/lib/typescript/pid/sd-jwt/converters.d.ts.map +1 -0
  72. package/lib/typescript/pid/sd-jwt/index.d.ts +50 -0
  73. package/lib/typescript/pid/sd-jwt/index.d.ts.map +1 -0
  74. package/lib/typescript/pid/sd-jwt/types.d.ts +196 -0
  75. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -0
  76. package/lib/typescript/sd-jwt/__test__/converters.test.d.ts +2 -0
  77. package/lib/typescript/sd-jwt/__test__/converters.test.d.ts.map +1 -0
  78. package/lib/typescript/sd-jwt/__test__/types.test.d.ts +2 -0
  79. package/lib/typescript/sd-jwt/__test__/types.test.d.ts.map +1 -0
  80. package/lib/typescript/sd-jwt/converters.d.ts +3 -0
  81. package/lib/typescript/sd-jwt/converters.d.ts.map +1 -0
  82. package/lib/typescript/sd-jwt/index.d.ts +42 -0
  83. package/lib/typescript/sd-jwt/index.d.ts.map +1 -0
  84. package/lib/typescript/sd-jwt/types.d.ts +416 -0
  85. package/lib/typescript/sd-jwt/types.d.ts.map +1 -0
  86. package/lib/typescript/sd-jwt/verifier.d.ts +3 -0
  87. package/lib/typescript/sd-jwt/verifier.d.ts.map +1 -0
  88. package/lib/typescript/utils/errors.d.ts +45 -0
  89. package/lib/typescript/utils/errors.d.ts.map +1 -0
  90. package/lib/typescript/utils/jwk.d.ts +85 -0
  91. package/lib/typescript/utils/jwk.d.ts.map +1 -0
  92. package/lib/typescript/wallet-instance-attestation/index.d.ts +36 -0
  93. package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -0
  94. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +32 -0
  95. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -0
  96. package/lib/typescript/wallet-instance-attestation/types.d.ts +733 -0
  97. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -0
  98. package/package.json +108 -0
  99. package/src/index.ts +8 -0
  100. package/src/pid/index.ts +2 -0
  101. package/src/pid/sd-jwt/converters.ts +26 -0
  102. package/src/pid/sd-jwt/index.ts +71 -0
  103. package/src/pid/sd-jwt/types.ts +44 -0
  104. package/src/sd-jwt/__test__/converters.test.ts +27 -0
  105. package/src/sd-jwt/__test__/types.test.ts +85 -0
  106. package/src/sd-jwt/converters.ts +24 -0
  107. package/src/sd-jwt/index.ts +92 -0
  108. package/src/sd-jwt/types.ts +54 -0
  109. package/src/sd-jwt/verifier.ts +20 -0
  110. package/src/utils/errors.ts +74 -0
  111. package/src/utils/jwk.ts +39 -0
  112. package/src/wallet-instance-attestation/index.ts +56 -0
  113. package/src/wallet-instance-attestation/issuing.ts +107 -0
  114. package/src/wallet-instance-attestation/types.ts +77 -0
@@ -0,0 +1,50 @@
1
+ import { PID } from "./types";
2
+ import { Disclosure, SdJwt4VC } from "../../sd-jwt/types";
3
+ /**
4
+ * Decode a given SD-JWT with Disclosures to get the parsed PID object they define.
5
+ * It ensures provided data is in a valid shape.
6
+ *
7
+ * It DOES NOT verify token signature nor check disclosures are correctly referenced by the SD-JWT.
8
+ * Use {@link verify} instead
9
+ *
10
+ * @function
11
+ * @param token The encoded token that represents a valid sd-jwt for verifiable credentials
12
+ *
13
+ * @returns The validated PID object along with the parsed SD-JWT token and the parsed disclosures
14
+ * @throws A decoding error if the token doesn't resolve in a valid SD-JWT
15
+ * @throws A validation error if the provided data doesn't result in a valid PID
16
+ *
17
+ */
18
+ export declare function decode(token: string): PidWithToken;
19
+ /**
20
+ * Verify a given SD-JWT with Disclosures to get the parsed PID object they define.
21
+ * Same as {@link decode} plus:
22
+ * - token signature verification
23
+ * - ensure disclosures are well-defined inside the SD-JWT
24
+ *
25
+ * @async @function
26
+ *
27
+ * @todo implement signature validation
28
+ * @todo check disclosures in sd-jwt
29
+ *
30
+ * @param token The encoded token that represents a valid sd-jwt for verifiable credentials
31
+ *
32
+ * @returns {VerifyResult} The validated PID object along with the parsed SD-JWT token and the parsed disclosures
33
+ * @throws A decoding error if the token doesn't resolve in a valid SD-JWT
34
+ * @throws A validation error if the provided data doesn't result in a valid PID
35
+ * @throws A validation error if the provided disclosures are not defined in the SD-JWT
36
+ * @throws Invalid signature error if the token signature is not valid
37
+ *
38
+ */
39
+ export declare function verify(token: string): Promise<VerifyResult>;
40
+ type PidWithToken = {
41
+ pid: PID;
42
+ sdJwt: SdJwt4VC;
43
+ disclosures: Disclosure[];
44
+ };
45
+ /**
46
+ * Result object for {@link verify}
47
+ */
48
+ export type VerifyResult = PidWithToken;
49
+ export { PID } from "./types";
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/pid/sd-jwt/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAKlD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAMjE;AAED,KAAK,YAAY,GAAG;IAElB,GAAG,EAAE,GAAG,CAAC;IAET,KAAK,EAAE,QAAQ,CAAC;IAEhB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,196 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Data structure for the PID.
4
+ * It contains PID claims in plain text as well as verification data with the issuer's information
5
+ *
6
+ * @see https://italia.github.io/eidas-it-wallet-docs/en/pid-data-model.html
7
+ */
8
+ export type PID = z.infer<typeof PID>;
9
+ export declare const PID: z.ZodObject<{
10
+ issuer: z.ZodString;
11
+ issuedAt: z.ZodDate;
12
+ expiration: z.ZodDate;
13
+ verification: z.ZodObject<{
14
+ trustFramework: z.ZodLiteral<"eidas">;
15
+ assuranceLevel: z.ZodString;
16
+ evidence: z.ZodArray<z.ZodObject<{
17
+ type: z.ZodString;
18
+ record: z.ZodObject<{
19
+ type: z.ZodString;
20
+ source: z.ZodObject<{
21
+ organization_name: z.ZodString;
22
+ organization_id: z.ZodString;
23
+ country_code: z.ZodString;
24
+ }, "strip", z.ZodTypeAny, {
25
+ organization_name: string;
26
+ organization_id: string;
27
+ country_code: string;
28
+ }, {
29
+ organization_name: string;
30
+ organization_id: string;
31
+ country_code: string;
32
+ }>;
33
+ }, "strip", z.ZodTypeAny, {
34
+ type: string;
35
+ source: {
36
+ organization_name: string;
37
+ organization_id: string;
38
+ country_code: string;
39
+ };
40
+ }, {
41
+ type: string;
42
+ source: {
43
+ organization_name: string;
44
+ organization_id: string;
45
+ country_code: string;
46
+ };
47
+ }>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ type: string;
50
+ record: {
51
+ type: string;
52
+ source: {
53
+ organization_name: string;
54
+ organization_id: string;
55
+ country_code: string;
56
+ };
57
+ };
58
+ }, {
59
+ type: string;
60
+ record: {
61
+ type: string;
62
+ source: {
63
+ organization_name: string;
64
+ organization_id: string;
65
+ country_code: string;
66
+ };
67
+ };
68
+ }>, "many">;
69
+ }, "strip", z.ZodTypeAny, {
70
+ trustFramework: "eidas";
71
+ assuranceLevel: string;
72
+ evidence: {
73
+ type: string;
74
+ record: {
75
+ type: string;
76
+ source: {
77
+ organization_name: string;
78
+ organization_id: string;
79
+ country_code: string;
80
+ };
81
+ };
82
+ }[];
83
+ }, {
84
+ trustFramework: "eidas";
85
+ assuranceLevel: string;
86
+ evidence: {
87
+ type: string;
88
+ record: {
89
+ type: string;
90
+ source: {
91
+ organization_name: string;
92
+ organization_id: string;
93
+ country_code: string;
94
+ };
95
+ };
96
+ }[];
97
+ }>;
98
+ claims: z.ZodObject<{
99
+ uniqueId: z.ZodString;
100
+ givenName: z.ZodString;
101
+ familyName: z.ZodString;
102
+ birthdate: z.ZodString;
103
+ placeOfBirth: z.ZodObject<{
104
+ country: z.ZodString;
105
+ locality: z.ZodString;
106
+ }, "strip", z.ZodTypeAny, {
107
+ country: string;
108
+ locality: string;
109
+ }, {
110
+ country: string;
111
+ locality: string;
112
+ }>;
113
+ taxIdCode: z.ZodString;
114
+ }, "strip", z.ZodTypeAny, {
115
+ uniqueId: string;
116
+ givenName: string;
117
+ familyName: string;
118
+ birthdate: string;
119
+ placeOfBirth: {
120
+ country: string;
121
+ locality: string;
122
+ };
123
+ taxIdCode: string;
124
+ }, {
125
+ uniqueId: string;
126
+ givenName: string;
127
+ familyName: string;
128
+ birthdate: string;
129
+ placeOfBirth: {
130
+ country: string;
131
+ locality: string;
132
+ };
133
+ taxIdCode: string;
134
+ }>;
135
+ }, "strip", z.ZodTypeAny, {
136
+ verification: {
137
+ trustFramework: "eidas";
138
+ assuranceLevel: string;
139
+ evidence: {
140
+ type: string;
141
+ record: {
142
+ type: string;
143
+ source: {
144
+ organization_name: string;
145
+ organization_id: string;
146
+ country_code: string;
147
+ };
148
+ };
149
+ }[];
150
+ };
151
+ claims: {
152
+ uniqueId: string;
153
+ givenName: string;
154
+ familyName: string;
155
+ birthdate: string;
156
+ placeOfBirth: {
157
+ country: string;
158
+ locality: string;
159
+ };
160
+ taxIdCode: string;
161
+ };
162
+ issuer: string;
163
+ issuedAt: Date;
164
+ expiration: Date;
165
+ }, {
166
+ verification: {
167
+ trustFramework: "eidas";
168
+ assuranceLevel: string;
169
+ evidence: {
170
+ type: string;
171
+ record: {
172
+ type: string;
173
+ source: {
174
+ organization_name: string;
175
+ organization_id: string;
176
+ country_code: string;
177
+ };
178
+ };
179
+ }[];
180
+ };
181
+ claims: {
182
+ uniqueId: string;
183
+ givenName: string;
184
+ familyName: string;
185
+ birthdate: string;
186
+ placeOfBirth: {
187
+ country: string;
188
+ locality: string;
189
+ };
190
+ taxIdCode: string;
191
+ };
192
+ issuer: string;
193
+ issuedAt: Date;
194
+ expiration: Date;
195
+ }>;
196
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/pid/sd-jwt/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB;;;;;GAKG;AACH,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;AACtC,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=converters.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.test.d.ts","sourceRoot":"","sources":["../../../../src/sd-jwt/__test__/converters.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.test.d.ts","sourceRoot":"","sources":["../../../../src/sd-jwt/__test__/types.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { Disclosure } from "./types";
2
+ export declare function getValueFromDisclosures(disclosures: Disclosure[], claimName: string): any;
3
+ //# sourceMappingURL=converters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/sd-jwt/converters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,UAAU,EAAE,EACzB,SAAS,EAAE,MAAM,OAmBlB"}
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { Disclosure } from "./types";
3
+ import type { JWK } from "src/utils/jwk";
4
+ /**
5
+ * Decode a given SD-JWT with Disclosures to get the parsed SD-JWT object they define.
6
+ * It ensures provided data is in a valid shape.
7
+ *
8
+ * It DOES NOT verify token signature nor check disclosures are correctly referenced by the SD-JWT.
9
+ * Use {@link verify} instead
10
+ *
11
+ * @function
12
+ * @param token The encoded token that represents a valid sd-jwt for verifiable credentials
13
+ * @param schema Schema to use to parse the SD-JWT
14
+ *
15
+ * @returns The parsed SD-JWT token and the parsed disclosures
16
+ *
17
+ */
18
+ export declare const decode: <S extends z.AnyZodObject>(token: string, schema: S) => {
19
+ sdJwt: z.TypeOf<S>;
20
+ disclosures: Disclosure[];
21
+ };
22
+ /**
23
+ * Verify a given SD-JWT with Disclosures
24
+ * Same as {@link decode} plus:
25
+ * - token signature verification
26
+ * - ensure disclosures are well-defined inside the SD-JWT
27
+ *
28
+ * @async @function
29
+ *
30
+ *
31
+ * @param token The encoded token that represents a valid sd-jwt for verifiable credentials
32
+ * @param publicKey The public key to validate the signature
33
+ * @param schema Schema to use to parse the SD-JWT
34
+ *
35
+ * @returns The parsed SD-JWT token and the parsed disclosures
36
+ *
37
+ */
38
+ export declare const verify: <S extends z.AnyZodObject>(token: string, publicKey: JWK, schema: S) => Promise<{
39
+ sdJwt: z.TypeOf<S>;
40
+ disclosures: Disclosure[];
41
+ }>;
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sd-jwt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM,oCACV,MAAM;;iBAEsB,UAAU,EAAE;CAqBhD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,oCACV,MAAM,aACF,GAAG;;iBAE6B,UAAU,EAAE;EAqBxD,CAAC"}