@pagopa/io-react-native-wallet 1.3.0 → 1.4.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.
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +8 -2
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +147 -3
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/const.js +1 -1
- package/lib/commonjs/credential/issuance/const.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +1 -1
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +7 -25
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +52 -12
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +1 -3
- package/lib/commonjs/credential/presentation/index.js +6 -0
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +19 -1
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/entity/openid-connect/issuer/types.js +10 -7
- package/lib/commonjs/entity/openid-connect/issuer/types.js.map +1 -1
- package/lib/commonjs/entity/trust/types.js +1 -1
- package/lib/commonjs/entity/trust/types.js.map +1 -1
- package/lib/commonjs/mdoc/converters.js +26 -0
- package/lib/commonjs/mdoc/converters.js.map +1 -0
- package/lib/commonjs/mdoc/index.js +28 -0
- package/lib/commonjs/mdoc/index.js.map +1 -0
- package/lib/commonjs/utils/string.js +13 -1
- package/lib/commonjs/utils/string.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +8 -2
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +147 -3
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/const.js +1 -1
- package/lib/module/credential/issuance/const.js.map +1 -1
- package/lib/module/credential/issuance/types.js +1 -1
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +7 -24
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +51 -11
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +1 -3
- package/lib/module/credential/presentation/index.js +2 -2
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +18 -0
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/entity/openid-connect/issuer/types.js +7 -6
- package/lib/module/entity/openid-connect/issuer/types.js.map +1 -1
- package/lib/module/entity/trust/types.js +1 -1
- package/lib/module/entity/trust/types.js.map +1 -1
- package/lib/module/mdoc/converters.js +20 -0
- package/lib/module/mdoc/converters.js.map +1 -0
- package/lib/module/mdoc/index.js +21 -0
- package/lib/module/mdoc/index.js.map +1 -0
- package/lib/module/utils/string.js +12 -0
- package/lib/module/utils/string.js.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +1 -1
- package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +7 -7
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +2 -8
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +23 -7
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +3 -3
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +26 -0
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts +177 -41
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +1 -1
- package/lib/typescript/entity/trust/index.d.ts +2 -2
- package/lib/typescript/entity/trust/types.d.ts +22 -22
- package/lib/typescript/mdoc/converters.d.ts +8 -0
- package/lib/typescript/mdoc/converters.d.ts.map +1 -0
- package/lib/typescript/mdoc/index.d.ts +6 -0
- package/lib/typescript/mdoc/index.d.ts.map +1 -0
- package/lib/typescript/sd-jwt/index.d.ts +4 -4
- package/lib/typescript/sd-jwt/types.d.ts +5 -5
- package/lib/typescript/utils/string.d.ts +7 -0
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/credential/issuance/06-obtain-credential.ts +14 -5
- package/src/credential/issuance/07-verify-and-parse-credential.ts +201 -1
- package/src/credential/issuance/const.ts +1 -1
- package/src/credential/issuance/types.ts +1 -1
- package/src/credential/presentation/03-get-request-object.ts +4 -29
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +2 -5
- package/src/credential/presentation/08-send-authorization-response.ts +70 -22
- package/src/credential/presentation/README.md +1 -3
- package/src/credential/presentation/index.ts +4 -0
- package/src/credential/presentation/types.ts +26 -0
- package/src/entity/openid-connect/issuer/types.ts +18 -10
- package/src/entity/trust/types.ts +1 -1
- package/src/mdoc/converters.ts +26 -0
- package/src/mdoc/index.ts +28 -0
- package/src/utils/string.ts +12 -0
@@ -2164,7 +2164,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
2164
2164
|
} | undefined;
|
2165
2165
|
}>, "many">;
|
2166
2166
|
credential_configurations_supported: z.ZodRecord<z.ZodString, z.ZodObject<{
|
2167
|
-
format: z.ZodUnion<[z.ZodLiteral<"vc+sd-jwt">, z.ZodLiteral<"
|
2167
|
+
format: z.ZodUnion<[z.ZodLiteral<"vc+sd-jwt">, z.ZodLiteral<"mso_mdoc">]>;
|
2168
2168
|
scope: z.ZodString;
|
2169
2169
|
display: z.ZodArray<z.ZodObject<{
|
2170
2170
|
name: z.ZodString;
|
@@ -2268,7 +2268,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
2268
2268
|
}[];
|
2269
2269
|
scope: string;
|
2270
2270
|
cryptographic_binding_methods_supported: string[];
|
2271
|
-
format: "vc+sd-jwt" | "
|
2271
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
2272
2272
|
credential_signing_alg_values_supported: string[];
|
2273
2273
|
claims?: Record<string, {
|
2274
2274
|
display: {
|
@@ -2298,7 +2298,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
2298
2298
|
}[];
|
2299
2299
|
scope: string;
|
2300
2300
|
cryptographic_binding_methods_supported: string[];
|
2301
|
-
format: "vc+sd-jwt" | "
|
2301
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
2302
2302
|
credential_signing_alg_values_supported: string[];
|
2303
2303
|
claims?: Record<string, {
|
2304
2304
|
display: {
|
@@ -2460,7 +2460,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
2460
2460
|
}[];
|
2461
2461
|
scope: string;
|
2462
2462
|
cryptographic_binding_methods_supported: string[];
|
2463
|
-
format: "vc+sd-jwt" | "
|
2463
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
2464
2464
|
credential_signing_alg_values_supported: string[];
|
2465
2465
|
claims?: Record<string, {
|
2466
2466
|
display: {
|
@@ -2530,7 +2530,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
2530
2530
|
}[];
|
2531
2531
|
scope: string;
|
2532
2532
|
cryptographic_binding_methods_supported: string[];
|
2533
|
-
format: "vc+sd-jwt" | "
|
2533
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
2534
2534
|
credential_signing_alg_values_supported: string[];
|
2535
2535
|
claims?: Record<string, {
|
2536
2536
|
display: {
|
@@ -3327,7 +3327,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
3327
3327
|
}[];
|
3328
3328
|
scope: string;
|
3329
3329
|
cryptographic_binding_methods_supported: string[];
|
3330
|
-
format: "vc+sd-jwt" | "
|
3330
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
3331
3331
|
credential_signing_alg_values_supported: string[];
|
3332
3332
|
claims?: Record<string, {
|
3333
3333
|
display: {
|
@@ -3517,7 +3517,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
3517
3517
|
}[];
|
3518
3518
|
scope: string;
|
3519
3519
|
cryptographic_binding_methods_supported: string[];
|
3520
|
-
format: "vc+sd-jwt" | "
|
3520
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
3521
3521
|
credential_signing_alg_values_supported: string[];
|
3522
3522
|
claims?: Record<string, {
|
3523
3523
|
display: {
|
@@ -3735,7 +3735,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
3735
3735
|
}[];
|
3736
3736
|
scope: string;
|
3737
3737
|
cryptographic_binding_methods_supported: string[];
|
3738
|
-
format: "vc+sd-jwt" | "
|
3738
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
3739
3739
|
credential_signing_alg_values_supported: string[];
|
3740
3740
|
claims?: Record<string, {
|
3741
3741
|
display: {
|
@@ -3953,7 +3953,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
3953
3953
|
}[];
|
3954
3954
|
scope: string;
|
3955
3955
|
cryptographic_binding_methods_supported: string[];
|
3956
|
-
format: "vc+sd-jwt" | "
|
3956
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
3957
3957
|
credential_signing_alg_values_supported: string[];
|
3958
3958
|
claims?: Record<string, {
|
3959
3959
|
display: {
|
@@ -4173,7 +4173,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
4173
4173
|
}[];
|
4174
4174
|
scope: string;
|
4175
4175
|
cryptographic_binding_methods_supported: string[];
|
4176
|
-
format: "vc+sd-jwt" | "
|
4176
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
4177
4177
|
credential_signing_alg_values_supported: string[];
|
4178
4178
|
claims?: Record<string, {
|
4179
4179
|
display: {
|
@@ -4393,7 +4393,7 @@ export declare const CredentialIssuerEntityConfiguration: z.ZodIntersection<z.Zo
|
|
4393
4393
|
}[];
|
4394
4394
|
scope: string;
|
4395
4395
|
cryptographic_binding_methods_supported: string[];
|
4396
|
-
format: "vc+sd-jwt" | "
|
4396
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
4397
4397
|
credential_signing_alg_values_supported: string[];
|
4398
4398
|
claims?: Record<string, {
|
4399
4399
|
display: {
|
@@ -10230,7 +10230,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
10230
10230
|
} | undefined;
|
10231
10231
|
}>, "many">;
|
10232
10232
|
credential_configurations_supported: z.ZodRecord<z.ZodString, z.ZodObject<{
|
10233
|
-
format: z.ZodUnion<[z.ZodLiteral<"vc+sd-jwt">, z.ZodLiteral<"
|
10233
|
+
format: z.ZodUnion<[z.ZodLiteral<"vc+sd-jwt">, z.ZodLiteral<"mso_mdoc">]>;
|
10234
10234
|
scope: z.ZodString;
|
10235
10235
|
display: z.ZodArray<z.ZodObject<{
|
10236
10236
|
name: z.ZodString;
|
@@ -10334,7 +10334,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
10334
10334
|
}[];
|
10335
10335
|
scope: string;
|
10336
10336
|
cryptographic_binding_methods_supported: string[];
|
10337
|
-
format: "vc+sd-jwt" | "
|
10337
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
10338
10338
|
credential_signing_alg_values_supported: string[];
|
10339
10339
|
claims?: Record<string, {
|
10340
10340
|
display: {
|
@@ -10364,7 +10364,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
10364
10364
|
}[];
|
10365
10365
|
scope: string;
|
10366
10366
|
cryptographic_binding_methods_supported: string[];
|
10367
|
-
format: "vc+sd-jwt" | "
|
10367
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
10368
10368
|
credential_signing_alg_values_supported: string[];
|
10369
10369
|
claims?: Record<string, {
|
10370
10370
|
display: {
|
@@ -10526,7 +10526,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
10526
10526
|
}[];
|
10527
10527
|
scope: string;
|
10528
10528
|
cryptographic_binding_methods_supported: string[];
|
10529
|
-
format: "vc+sd-jwt" | "
|
10529
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
10530
10530
|
credential_signing_alg_values_supported: string[];
|
10531
10531
|
claims?: Record<string, {
|
10532
10532
|
display: {
|
@@ -10596,7 +10596,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
10596
10596
|
}[];
|
10597
10597
|
scope: string;
|
10598
10598
|
cryptographic_binding_methods_supported: string[];
|
10599
|
-
format: "vc+sd-jwt" | "
|
10599
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
10600
10600
|
credential_signing_alg_values_supported: string[];
|
10601
10601
|
claims?: Record<string, {
|
10602
10602
|
display: {
|
@@ -11393,7 +11393,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
11393
11393
|
}[];
|
11394
11394
|
scope: string;
|
11395
11395
|
cryptographic_binding_methods_supported: string[];
|
11396
|
-
format: "vc+sd-jwt" | "
|
11396
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
11397
11397
|
credential_signing_alg_values_supported: string[];
|
11398
11398
|
claims?: Record<string, {
|
11399
11399
|
display: {
|
@@ -11583,7 +11583,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
11583
11583
|
}[];
|
11584
11584
|
scope: string;
|
11585
11585
|
cryptographic_binding_methods_supported: string[];
|
11586
|
-
format: "vc+sd-jwt" | "
|
11586
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
11587
11587
|
credential_signing_alg_values_supported: string[];
|
11588
11588
|
claims?: Record<string, {
|
11589
11589
|
display: {
|
@@ -11801,7 +11801,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
11801
11801
|
}[];
|
11802
11802
|
scope: string;
|
11803
11803
|
cryptographic_binding_methods_supported: string[];
|
11804
|
-
format: "vc+sd-jwt" | "
|
11804
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
11805
11805
|
credential_signing_alg_values_supported: string[];
|
11806
11806
|
claims?: Record<string, {
|
11807
11807
|
display: {
|
@@ -12019,7 +12019,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
12019
12019
|
}[];
|
12020
12020
|
scope: string;
|
12021
12021
|
cryptographic_binding_methods_supported: string[];
|
12022
|
-
format: "vc+sd-jwt" | "
|
12022
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
12023
12023
|
credential_signing_alg_values_supported: string[];
|
12024
12024
|
claims?: Record<string, {
|
12025
12025
|
display: {
|
@@ -12239,7 +12239,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
12239
12239
|
}[];
|
12240
12240
|
scope: string;
|
12241
12241
|
cryptographic_binding_methods_supported: string[];
|
12242
|
-
format: "vc+sd-jwt" | "
|
12242
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
12243
12243
|
credential_signing_alg_values_supported: string[];
|
12244
12244
|
claims?: Record<string, {
|
12245
12245
|
display: {
|
@@ -12459,7 +12459,7 @@ export declare const EntityConfiguration: z.ZodUnion<[z.ZodIntersection<z.ZodObj
|
|
12459
12459
|
}[];
|
12460
12460
|
scope: string;
|
12461
12461
|
cryptographic_binding_methods_supported: string[];
|
12462
|
-
format: "vc+sd-jwt" | "
|
12462
|
+
format: "vc+sd-jwt" | "mso_mdoc";
|
12463
12463
|
credential_signing_alg_values_supported: string[];
|
12464
12464
|
claims?: Record<string, {
|
12465
12465
|
display: {
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* Extracts the date value of a given elementIdentifier from an MDOC object.
|
3
|
+
* Searches through the issuerSigned namespaces and attempts to parse the value as a Date.
|
4
|
+
* The expected date format is "DD-MM-YYYY".
|
5
|
+
* Returns the Date object if found, otherwise returns null.
|
6
|
+
*/
|
7
|
+
export declare function extractElementValueAsDate(elementValue: string): Date | null;
|
8
|
+
//# sourceMappingURL=converters.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/mdoc/converters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAmB3E"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mdoc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,MAAM,UACV,MAAM,aACF,GAAG,GAAG,GAAG,EAAE;UACL,KAAK,IAAI;EAqB3B,CAAC"}
|
@@ -19,7 +19,7 @@ import * as Errors from "./errors";
|
|
19
19
|
export declare const decode: <S extends z.ZodType<{
|
20
20
|
header: {
|
21
21
|
alg: string;
|
22
|
-
typ: "vc+sd-jwt" | "
|
22
|
+
typ: "vc+sd-jwt" | "mso_mdoc";
|
23
23
|
kid?: string | undefined;
|
24
24
|
x5c?: string | undefined;
|
25
25
|
vctm?: string[] | undefined;
|
@@ -76,7 +76,7 @@ export declare const decode: <S extends z.ZodType<{
|
|
76
76
|
}, z.ZodTypeDef, {
|
77
77
|
header: {
|
78
78
|
alg: string;
|
79
|
-
typ: "vc+sd-jwt" | "
|
79
|
+
typ: "vc+sd-jwt" | "mso_mdoc";
|
80
80
|
kid?: string | undefined;
|
81
81
|
x5c?: string | undefined;
|
82
82
|
vctm?: string[] | undefined;
|
@@ -173,7 +173,7 @@ export declare const disclose: (token: string, claims: string[]) => Promise<{
|
|
173
173
|
export declare const verify: <S extends z.ZodType<{
|
174
174
|
header: {
|
175
175
|
alg: string;
|
176
|
-
typ: "vc+sd-jwt" | "
|
176
|
+
typ: "vc+sd-jwt" | "mso_mdoc";
|
177
177
|
kid?: string | undefined;
|
178
178
|
x5c?: string | undefined;
|
179
179
|
vctm?: string[] | undefined;
|
@@ -230,7 +230,7 @@ export declare const verify: <S extends z.ZodType<{
|
|
230
230
|
}, z.ZodTypeDef, {
|
231
231
|
header: {
|
232
232
|
alg: string;
|
233
|
-
typ: "vc+sd-jwt" | "
|
233
|
+
typ: "vc+sd-jwt" | "mso_mdoc";
|
234
234
|
kid?: string | undefined;
|
235
235
|
x5c?: string | undefined;
|
236
236
|
vctm?: string[] | undefined;
|
@@ -56,20 +56,20 @@ export declare const Verification: z.ZodObject<{
|
|
56
56
|
export type SdJwt4VC = z.infer<typeof SdJwt4VC>;
|
57
57
|
export declare const SdJwt4VC: z.ZodObject<{
|
58
58
|
header: z.ZodObject<{
|
59
|
-
typ: z.ZodUnion<[z.ZodLiteral<"vc+sd-jwt">, z.ZodLiteral<"
|
59
|
+
typ: z.ZodUnion<[z.ZodLiteral<"vc+sd-jwt">, z.ZodLiteral<"mso_mdoc">]>;
|
60
60
|
alg: z.ZodString;
|
61
61
|
kid: z.ZodOptional<z.ZodString>;
|
62
62
|
x5c: z.ZodOptional<z.ZodString>;
|
63
63
|
vctm: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
64
64
|
}, "strip", z.ZodTypeAny, {
|
65
65
|
alg: string;
|
66
|
-
typ: "vc+sd-jwt" | "
|
66
|
+
typ: "vc+sd-jwt" | "mso_mdoc";
|
67
67
|
kid?: string | undefined;
|
68
68
|
x5c?: string | undefined;
|
69
69
|
vctm?: string[] | undefined;
|
70
70
|
}, {
|
71
71
|
alg: string;
|
72
|
-
typ: "vc+sd-jwt" | "
|
72
|
+
typ: "vc+sd-jwt" | "mso_mdoc";
|
73
73
|
kid?: string | undefined;
|
74
74
|
x5c?: string | undefined;
|
75
75
|
vctm?: string[] | undefined;
|
@@ -346,7 +346,7 @@ export declare const SdJwt4VC: z.ZodObject<{
|
|
346
346
|
}, "strip", z.ZodTypeAny, {
|
347
347
|
header: {
|
348
348
|
alg: string;
|
349
|
-
typ: "vc+sd-jwt" | "
|
349
|
+
typ: "vc+sd-jwt" | "mso_mdoc";
|
350
350
|
kid?: string | undefined;
|
351
351
|
x5c?: string | undefined;
|
352
352
|
vctm?: string[] | undefined;
|
@@ -403,7 +403,7 @@ export declare const SdJwt4VC: z.ZodObject<{
|
|
403
403
|
}, {
|
404
404
|
header: {
|
405
405
|
alg: string;
|
406
|
-
typ: "vc+sd-jwt" | "
|
406
|
+
typ: "vc+sd-jwt" | "mso_mdoc";
|
407
407
|
kid?: string | undefined;
|
408
408
|
x5c?: string | undefined;
|
409
409
|
vctm?: string[] | undefined;
|
@@ -14,4 +14,11 @@
|
|
14
14
|
* @returns The obfuscated string with random characters replaced
|
15
15
|
*/
|
16
16
|
export declare const obfuscateString: (value: string, percentage?: number, obfuscatedChar?: string) => string;
|
17
|
+
/**
|
18
|
+
* Converts a hexadecimal byte string to a Base64 URL-encoded string.
|
19
|
+
*
|
20
|
+
* @param byteString - The input string in hexadecimal format.
|
21
|
+
* @returns The Base64 URL-encoded string.
|
22
|
+
*/
|
23
|
+
export declare const byteStringToBase64Url: (byteString: string) => string;
|
17
24
|
//# sourceMappingURL=string.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,UACnB,MAAM,eACD,MAAM,mBACF,MAAM,KACrB,MAyBF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,eAAgB,MAAM,KAAG,MAE1D,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pagopa/io-react-native-wallet",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.4.0",
|
4
4
|
"description": "Provide data structures, helpers and API for IO Wallet",
|
5
5
|
"main": "lib/commonjs/index",
|
6
6
|
"module": "lib/module/index",
|
@@ -56,6 +56,7 @@
|
|
56
56
|
"@pagopa/eslint-config": "^3.0.0",
|
57
57
|
"@pagopa/io-react-native-crypto": "^0.2.3",
|
58
58
|
"@pagopa/io-react-native-jwt": "^2.0.0",
|
59
|
+
"@pagopa/io-react-native-cbor": "^1.0.0",
|
59
60
|
"@react-native/eslint-config": "^0.72.2",
|
60
61
|
"@rushstack/eslint-patch": "^1.3.2",
|
61
62
|
"@types/jest": "^28.1.2",
|
@@ -79,6 +80,7 @@
|
|
79
80
|
"peerDependencies": {
|
80
81
|
"@pagopa/io-react-native-crypto": "*",
|
81
82
|
"@pagopa/io-react-native-jwt": "*",
|
83
|
+
"@pagopa/io-react-native-cbor": "*",
|
82
84
|
"react": "*",
|
83
85
|
"react-native": "*"
|
84
86
|
},
|
@@ -17,6 +17,7 @@ import {
|
|
17
17
|
import { CredentialResponse } from "./types";
|
18
18
|
import { createDPopToken } from "../../utils/dpop";
|
19
19
|
import uuid from "react-native-uuid";
|
20
|
+
import { byteStringToBase64Url } from "../../utils/string";
|
20
21
|
|
21
22
|
export type ObtainCredential = (
|
22
23
|
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
@@ -95,10 +96,12 @@ export const obtainCredential: ObtainCredential = async (
|
|
95
96
|
credentialCryptoContext
|
96
97
|
);
|
97
98
|
|
98
|
-
const containsCredentialDefinition =
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
const containsCredentialDefinition = accessToken.authorization_details.some(
|
100
|
+
(detail) =>
|
101
|
+
detail.credential_configuration_id ===
|
102
|
+
credentialDefinition.credential_configuration_id &&
|
103
|
+
detail.type === credentialDefinition.type
|
104
|
+
);
|
102
105
|
|
103
106
|
if (!containsCredentialDefinition) {
|
104
107
|
throw new ValidationFailed({
|
@@ -167,7 +170,13 @@ export const obtainCredential: ObtainCredential = async (
|
|
167
170
|
});
|
168
171
|
}
|
169
172
|
|
170
|
-
|
173
|
+
/* temporary base64 parsing for the "mso_mdoc" format until the credential submission with this format is fixed. */
|
174
|
+
return format === "mso_mdoc"
|
175
|
+
? {
|
176
|
+
...credentialRes.data,
|
177
|
+
credential: byteStringToBase64Url(credentialRes.data.credential),
|
178
|
+
}
|
179
|
+
: credentialRes.data;
|
171
180
|
};
|
172
181
|
|
173
182
|
/**
|
@@ -1,12 +1,19 @@
|
|
1
1
|
import type { CryptoContext } from "@pagopa/io-react-native-jwt";
|
2
|
+
import { CBOR } from "@pagopa/io-react-native-cbor";
|
2
3
|
import type { Out } from "../../utils/misc";
|
3
4
|
import type { GetIssuerConfig } from "./02-get-issuer-config";
|
4
5
|
import { IoWalletError } from "../../utils/errors";
|
5
6
|
import { SdJwt4VC } from "../../sd-jwt/types";
|
6
7
|
import { verify as verifySdJwt } from "../../sd-jwt";
|
8
|
+
import { verify as verifyMdoc } from "../../mdoc";
|
7
9
|
import { getValueFromDisclosures } from "../../sd-jwt/converters";
|
8
10
|
import type { JWK } from "../../utils/jwk";
|
9
11
|
import type { ObtainCredential } from "./06-obtain-credential";
|
12
|
+
import {
|
13
|
+
CredentialSdJwtClaims,
|
14
|
+
CredentialClaim,
|
15
|
+
} from "../../entity/openid-connect/issuer/types";
|
16
|
+
import { extractElementValueAsDate } from "../../mdoc/converters";
|
10
17
|
|
11
18
|
export type VerifyAndParseCredential = (
|
12
19
|
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
@@ -52,6 +59,10 @@ type DecodedSdJwtCredential = Out<typeof verifySdJwt> & {
|
|
52
59
|
sdJwt: SdJwt4VC;
|
53
60
|
};
|
54
61
|
|
62
|
+
type DecodedMDocCredential = Out<typeof verifyMdoc> & {
|
63
|
+
mDoc: CBOR.MDOC;
|
64
|
+
};
|
65
|
+
|
55
66
|
const parseCredentialSdJwt = (
|
56
67
|
// the list of supported credentials, as defined in the issuer configuration
|
57
68
|
credentials_supported: Out<GetIssuerConfig>["issuerConf"]["credential_configurations_supported"],
|
@@ -75,7 +86,8 @@ const parseCredentialSdJwt = (
|
|
75
86
|
if (!credentialSubject.claims) {
|
76
87
|
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
77
88
|
}
|
78
|
-
const
|
89
|
+
const claims = credentialSubject.claims as CredentialSdJwtClaims;
|
90
|
+
const attrDefinitions = Object.entries(claims);
|
79
91
|
|
80
92
|
// the key of the attribute defintion must match the disclosure's name
|
81
93
|
const attrsNotInDisclosures = attrDefinitions.filter(
|
@@ -142,6 +154,108 @@ const parseCredentialSdJwt = (
|
|
142
154
|
return definedValues;
|
143
155
|
};
|
144
156
|
|
157
|
+
const parseCredentialMDoc = (
|
158
|
+
// the list of supported credentials, as defined in the issuer configuration
|
159
|
+
credentials_supported: Out<GetIssuerConfig>["issuerConf"]["credential_configurations_supported"],
|
160
|
+
{ mDoc }: DecodedMDocCredential,
|
161
|
+
includeUndefinedAttributes: boolean = false
|
162
|
+
): ParsedCredential => {
|
163
|
+
const credentialSubject = credentials_supported[mDoc.docType];
|
164
|
+
|
165
|
+
if (!credentialSubject) {
|
166
|
+
throw new IoWalletError("Credential type not supported by the issuer");
|
167
|
+
}
|
168
|
+
|
169
|
+
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
170
|
+
if (!credentialSubject.claims) {
|
171
|
+
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
172
|
+
}
|
173
|
+
|
174
|
+
const claims = credentialSubject.claims as Record<
|
175
|
+
string,
|
176
|
+
CredentialSdJwtClaims
|
177
|
+
>;
|
178
|
+
|
179
|
+
const attrDefinitions: [string, string, CredentialClaim][] = Object.entries(
|
180
|
+
claims
|
181
|
+
).flatMap(([namespace, claimName]) =>
|
182
|
+
Object.entries(claimName).map(
|
183
|
+
([claimNameKey, definition]) =>
|
184
|
+
[namespace, claimNameKey, definition] as [
|
185
|
+
string,
|
186
|
+
string,
|
187
|
+
CredentialClaim
|
188
|
+
]
|
189
|
+
)
|
190
|
+
);
|
191
|
+
|
192
|
+
if (!mDoc.issuerSigned.nameSpaces) {
|
193
|
+
throw new IoWalletError("Missing claims in the credential");
|
194
|
+
}
|
195
|
+
|
196
|
+
const flatNamespaces: [string, string, string][] = Object.entries(
|
197
|
+
mDoc.issuerSigned.nameSpaces
|
198
|
+
).flatMap(([namespace, values]) =>
|
199
|
+
values.map(
|
200
|
+
(v) =>
|
201
|
+
[namespace, v.elementIdentifier, v.elementValue] as [
|
202
|
+
string,
|
203
|
+
string,
|
204
|
+
string
|
205
|
+
]
|
206
|
+
)
|
207
|
+
);
|
208
|
+
|
209
|
+
// Attributes defined in the issuer configuration and present in the disclosure set
|
210
|
+
const definedValues = Object.fromEntries(
|
211
|
+
attrDefinitions
|
212
|
+
// Retrieve the value from the corresponding disclosure
|
213
|
+
.map(
|
214
|
+
([attrDefNamespace, attrKey, definition]) =>
|
215
|
+
[
|
216
|
+
attrKey,
|
217
|
+
{
|
218
|
+
...definition,
|
219
|
+
value: flatNamespaces.find(
|
220
|
+
([namespace, name]) =>
|
221
|
+
attrDefNamespace === namespace && name === attrKey
|
222
|
+
)?.[2],
|
223
|
+
},
|
224
|
+
] as const
|
225
|
+
)
|
226
|
+
// Add a human-readable attribute name, with i18n, in the form { locale: name }
|
227
|
+
// Example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
228
|
+
.map(
|
229
|
+
([attrKey, { display, ...definition }]) =>
|
230
|
+
[
|
231
|
+
attrKey,
|
232
|
+
{
|
233
|
+
...definition,
|
234
|
+
name: display.reduce(
|
235
|
+
(names, { locale, name }) => ({ ...names, [locale]: name }),
|
236
|
+
{} as Record<string, string>
|
237
|
+
),
|
238
|
+
},
|
239
|
+
] as const
|
240
|
+
)
|
241
|
+
);
|
242
|
+
|
243
|
+
if (includeUndefinedAttributes) {
|
244
|
+
// Attributes that are present in the disclosure set but not defined in the issuer configuration
|
245
|
+
const undefinedValues = Object.fromEntries(
|
246
|
+
flatNamespaces
|
247
|
+
.filter(([, key]) => !Object.keys(definedValues).includes(key))
|
248
|
+
.map(([, key, value]) => [key, { value, name: key }])
|
249
|
+
);
|
250
|
+
return {
|
251
|
+
...definedValues,
|
252
|
+
...undefinedValues,
|
253
|
+
};
|
254
|
+
}
|
255
|
+
|
256
|
+
return definedValues;
|
257
|
+
};
|
258
|
+
|
145
259
|
/**
|
146
260
|
* Given a credential, verify it's in the supported format
|
147
261
|
* and the credential is correctly signed
|
@@ -180,6 +294,46 @@ async function verifyCredentialSdJwt(
|
|
180
294
|
return decodedCredential;
|
181
295
|
}
|
182
296
|
|
297
|
+
/**
|
298
|
+
* Given a credential, verify it's in the supported format
|
299
|
+
* and the credential is correctly signed
|
300
|
+
* and it's bound to the given key
|
301
|
+
*
|
302
|
+
* @param rawCredential The received credential
|
303
|
+
* @param issuerKeys The set of public keys of the issuer,
|
304
|
+
* which will be used to verify the signature
|
305
|
+
* @param holderBindingContext The access to the holder's key
|
306
|
+
*
|
307
|
+
* @throws If the signature verification fails
|
308
|
+
* @throws If the credential is not in the SdJwt4VC format
|
309
|
+
* @throws If the holder binding is not properly configured
|
310
|
+
*
|
311
|
+
*/
|
312
|
+
async function verifyCredentialMDoc(
|
313
|
+
rawCredential: string,
|
314
|
+
issuerKeys: JWK[],
|
315
|
+
holderBindingContext: CryptoContext
|
316
|
+
): Promise<DecodedMDocCredential> {
|
317
|
+
const [decodedCredential] =
|
318
|
+
// parallel for optimization
|
319
|
+
await Promise.all([
|
320
|
+
verifyMdoc(rawCredential, issuerKeys),
|
321
|
+
holderBindingContext.getPublicKey(),
|
322
|
+
]);
|
323
|
+
|
324
|
+
// TODO Implement the holder binding verification for MDOC
|
325
|
+
|
326
|
+
// Get only the first decoded credential
|
327
|
+
|
328
|
+
if (!decodedCredential) {
|
329
|
+
throw new IoWalletError("No MDOC credentials found!");
|
330
|
+
}
|
331
|
+
|
332
|
+
return {
|
333
|
+
mDoc: decodedCredential.mDoc,
|
334
|
+
};
|
335
|
+
}
|
336
|
+
|
183
337
|
// utility type that specialize VerifyAndParseCredential for given format
|
184
338
|
type WithFormat<Format extends Parameters<VerifyAndParseCredential>[2]> = (
|
185
339
|
_0: Parameters<VerifyAndParseCredential>[0],
|
@@ -223,6 +377,44 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
|
|
223
377
|
};
|
224
378
|
};
|
225
379
|
|
380
|
+
const verifyAndParseCredentialMDoc: WithFormat<"mso_mdoc"> = async (
|
381
|
+
issuerConf,
|
382
|
+
credential,
|
383
|
+
_,
|
384
|
+
{ credentialCryptoContext, ignoreMissingAttributes }
|
385
|
+
) => {
|
386
|
+
const decoded = await verifyCredentialMDoc(
|
387
|
+
credential,
|
388
|
+
issuerConf.keys,
|
389
|
+
credentialCryptoContext
|
390
|
+
);
|
391
|
+
|
392
|
+
const parsedCredential = parseCredentialMDoc(
|
393
|
+
issuerConf.credential_configurations_supported,
|
394
|
+
decoded,
|
395
|
+
ignoreMissingAttributes
|
396
|
+
);
|
397
|
+
|
398
|
+
const expirationDate = extractElementValueAsDate(
|
399
|
+
parsedCredential?.expiry_date?.value as string
|
400
|
+
);
|
401
|
+
if (!expirationDate) {
|
402
|
+
throw new IoWalletError(`expirationDate must be present!!`);
|
403
|
+
}
|
404
|
+
expirationDate?.setDate(expirationDate.getDate() + 1);
|
405
|
+
|
406
|
+
const maybeIssuedAt = extractElementValueAsDate(
|
407
|
+
parsedCredential?.issue_date?.value as string
|
408
|
+
);
|
409
|
+
maybeIssuedAt?.setDate(maybeIssuedAt.getDate() + 1);
|
410
|
+
|
411
|
+
return {
|
412
|
+
parsedCredential,
|
413
|
+
expiration: expirationDate ?? new Date(),
|
414
|
+
issuedAt: maybeIssuedAt ?? undefined,
|
415
|
+
};
|
416
|
+
};
|
417
|
+
|
226
418
|
/**
|
227
419
|
* Verify and parse an encoded credential.
|
228
420
|
* @param issuerConf The Issuer configuration returned by {@link getIssuerConfig}
|
@@ -250,6 +442,14 @@ export const verifyAndParseCredential: VerifyAndParseCredential = async (
|
|
250
442
|
context
|
251
443
|
);
|
252
444
|
}
|
445
|
+
if (format === "mso_mdoc") {
|
446
|
+
return verifyAndParseCredentialMDoc(
|
447
|
+
issuerConf,
|
448
|
+
credential,
|
449
|
+
format,
|
450
|
+
context
|
451
|
+
);
|
452
|
+
}
|
253
453
|
|
254
454
|
throw new IoWalletError(`Unsupported credential format: ${format}`);
|
255
455
|
};
|
@@ -6,7 +6,7 @@ export type TokenResponse = z.infer<typeof TokenResponse>;
|
|
6
6
|
|
7
7
|
export const TokenResponse = z.object({
|
8
8
|
access_token: z.string(),
|
9
|
-
authorization_details: AuthorizationDetail,
|
9
|
+
authorization_details: z.array(AuthorizationDetail),
|
10
10
|
c_nonce: z.string(),
|
11
11
|
c_nonce_expires_in: z.number(),
|
12
12
|
expires_in: z.number(),
|