@pagopa/io-react-native-wallet 2.4.2 → 2.5.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.
- package/lib/commonjs/client/generated/wallet-provider.js +48 -42
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/client/index.js +1 -1
- package/lib/commonjs/client/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +148 -123
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/utils/parser.js +20 -0
- package/lib/commonjs/utils/parser.js.map +1 -0
- package/lib/commonjs/wallet-instance/index.js +4 -2
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +37 -31
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/client/index.js +2 -2
- package/lib/module/client/index.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +144 -119
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +1 -3
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/utils/parser.js +12 -0
- package/lib/module/utils/parser.js.map +1 -0
- package/lib/module/wallet-instance/index.js +4 -2
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +127 -124
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +1 -1
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +3 -3
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/parser.d.ts +9 -0
- package/lib/typescript/utils/parser.d.ts.map +1 -0
- package/lib/typescript/wallet-instance/index.d.ts +1 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/package.json +7 -2
- package/src/client/generated/wallet-provider.ts +53 -46
- package/src/client/index.ts +3 -3
- package/src/credential/issuance/07-verify-and-parse-credential.ts +138 -94
- package/src/sd-jwt/__test__/index.test.ts +1 -1
- package/src/sd-jwt/index.ts +7 -5
- package/src/utils/errors.ts +3 -3
- package/src/utils/parser.ts +18 -0
- package/src/wallet-instance/index.ts +3 -1
- package/lib/commonjs/utils/nestedProperty.js +0 -153
- package/lib/commonjs/utils/nestedProperty.js.map +0 -1
- package/lib/module/utils/nestedProperty.js +0 -147
- package/lib/module/utils/nestedProperty.js.map +0 -1
- package/lib/typescript/utils/nestedProperty.d.ts +0 -24
- package/lib/typescript/utils/nestedProperty.d.ts.map +0 -1
- package/src/utils/nestedProperty.ts +0 -223
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-provider.d.ts","sourceRoot":"","sources":["../../../../src/client/generated/wallet-provider.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"wallet-provider.d.ts","sourceRoot":"","sources":["../../../../src/client/generated/wallet-provider.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AACtF,eAAO,MAAM,2BAA2B;;;;;;EAEtC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,eAAO,MAAM,gBAAgB,oLAK3B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CA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AAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,aAEjE;;AAED;;;;;;;;EAQE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"07-verify-and-parse-credential.d.ts","sourceRoot":"","sources":["../../../../src/credential/issuance/07-verify-and-parse-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"07-verify-and-parse-credential.d.ts","sourceRoot":"","sources":["../../../../src/credential/issuance/07-verify-and-parse-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAItE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAW/D,KAAK,UAAU,GAAG,GAAG,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,CAAC;AAQzD,MAAM,MAAM,wBAAwB,GAAG,CACrC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,EAC/C,yBAAyB,EAAE,MAAM,EACjC,OAAO,EAAE;IACP,uBAAuB,EAAE,aAAa,CAAC;IACvC;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,EACD,YAAY,CAAC,EAAE,MAAM,KAClB,OAAO,CAAC;IACX,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;CAC5B,CAAC,CAAC;AAGH,KAAK,gBAAgB,GAAG;IACtB,oBAAoB;IACpB,CAAC,KAAK,EAAE,MAAM,GAAG;QACf,IAAI,EACA,yBAAyB,CAAC,MAAM,CAC9B,MAAM,EACN,MAAM,CACP,GACD,4BAA4B,CAAC,MAAM,GACnC,SAAS,CAAC;QACd,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;CACH,CAAC;AA2cF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,EAAE,wBAuCtC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { Disclosure,
|
|
2
|
+
import { Disclosure, type DisclosureWithEncoded, SdJwt4VC } from "./types";
|
|
3
3
|
import type { JWK } from "../utils/jwk";
|
|
4
4
|
import * as Errors from "./errors";
|
|
5
5
|
import { type Presentation } from "../credential/presentation/types";
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sd-jwt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,EAAE,UAAU,EAAE,KAAK,qBAAqB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE3E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,cAAc,SAAS,CAAC;AAQxB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WACV,MAAM;;iBAIA,qBAAqB,EAAE;CA0BrC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,UACZ,MAAM,UACL,MAAM,EAAE;WACE,MAAM;WAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;EA2CnE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WACV,MAAM,aACF,GAAG,GAAG,GAAG,EAAE;;iBAEqB,UAAU,EAAE;EAqBxD,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,UAClB,MAAM,aACF,MAAM;cAGP,MAAM;EAyBjB,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProblemJson } from "../client/generated/wallet-provider";
|
|
2
2
|
import { type IssuerResponseErrorCode, IssuerResponseErrorCodes, type RelyingPartyResponseErrorCode, RelyingPartyResponseErrorCodes, type WalletProviderResponseErrorCode, WalletProviderResponseErrorCodes } from "./error-codes";
|
|
3
3
|
import type { CredentialIssuerEntityConfiguration } from "../trust/types";
|
|
4
4
|
export { IssuerResponseErrorCodes, WalletProviderResponseErrorCodes, RelyingPartyResponseErrorCodes, };
|
|
@@ -78,11 +78,11 @@ export declare class IssuerResponseError extends UnexpectedStatusCodeError {
|
|
|
78
78
|
*/
|
|
79
79
|
export declare class WalletProviderResponseError extends UnexpectedStatusCodeError {
|
|
80
80
|
code: WalletProviderResponseErrorCode;
|
|
81
|
-
reason:
|
|
81
|
+
reason: ProblemJson;
|
|
82
82
|
constructor(params: {
|
|
83
83
|
code?: WalletProviderResponseErrorCode;
|
|
84
84
|
message: string;
|
|
85
|
-
reason:
|
|
85
|
+
reason: ProblemJson;
|
|
86
86
|
statusCode: number;
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EACL,KAAK,uBAAuB,EAC5B,wBAAwB,EACxB,KAAK,6BAA6B,EAClC,8BAA8B,EAC9B,KAAK,+BAA+B,EACpC,gCAAgC,EACjC,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,8BAA8B,GAC/B,CAAC;AAGF,KAAK,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3D;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,UAClB,OAAO,MAAM,EAAE,kBAAkB,GAAG,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC,KAC7E,MASW,CAAC;AAEf;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAA2B;gBAE3B,OAAO,CAAC,EAAE,MAAM;CAI7B;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,IAAI,SAAqC;IAEzC,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAA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AyB;IAK9D,OAAO,CAAC,UAAU;IAJ9B,OAAO,CAAC,UAAU,CAEX;gBAEa,UAAU,EAAE,CAAC;IAEjC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAKjD,SAAS,CAAC,aAAa,EAAE,yBAAyB;CAUnD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to determine if two paths are equal (Supports string | number | null)
|
|
3
|
+
*/
|
|
4
|
+
export declare const isPathEqual: (pathA: (string | number | null)[], pathB: (string | number | null)[]) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Helper to check if prefix is the start of fullPath
|
|
7
|
+
*/
|
|
8
|
+
export declare const isPrefixOf: (prefix: (string | number | null)[], fullPath: (string | number | null)[]) => boolean;
|
|
9
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/utils/parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW,UACf,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,SAC1B,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,KAChC,OACqE,CAAC;AACzE;;GAEG;AACH,eAAO,MAAM,UAAU,WACb,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,YACxB,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,KACnC,OAGF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallet-instance/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAG3C,wBAAs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1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/io-react-native-wallet",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Provide data structures, helpers and API for IO Wallet",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"react": "19.0.0",
|
|
75
75
|
"react-native": "0.78.3",
|
|
76
76
|
"react-native-builder-bob": "^0.20.0",
|
|
77
|
+
"react-native-quick-crypto": "^0.7.17",
|
|
77
78
|
"release-it": "^19.0.6",
|
|
78
79
|
"typed-openapi": "^0.4.1",
|
|
79
80
|
"typescript": "5.0.4"
|
|
@@ -83,7 +84,8 @@
|
|
|
83
84
|
"@pagopa/io-react-native-iso18013": "*",
|
|
84
85
|
"@pagopa/io-react-native-jwt": "*",
|
|
85
86
|
"react": "*",
|
|
86
|
-
"react-native": "*"
|
|
87
|
+
"react-native": "*",
|
|
88
|
+
"react-native-quick-crypto": "*"
|
|
87
89
|
},
|
|
88
90
|
"engines": {
|
|
89
91
|
"node": ">= 16.0.0"
|
|
@@ -134,6 +136,9 @@
|
|
|
134
136
|
]
|
|
135
137
|
},
|
|
136
138
|
"dependencies": {
|
|
139
|
+
"@sd-jwt/core": "^0.18.0",
|
|
140
|
+
"@sd-jwt/crypto-nodejs": "^0.18.0",
|
|
141
|
+
"@sd-jwt/types": "^0.18.0",
|
|
137
142
|
"dcql": "^0.2.21",
|
|
138
143
|
"js-base64": "^3.7.7",
|
|
139
144
|
"js-sha256": "^0.9.0",
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
2
|
|
|
3
|
+
export type SetWalletInstanceStatusData = z.infer<typeof SetWalletInstanceStatusData>;
|
|
4
|
+
export const SetWalletInstanceStatusData = z.object({
|
|
5
|
+
status: z.literal("REVOKED"),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export type RevocationReason = z.infer<typeof RevocationReason>;
|
|
9
|
+
export const RevocationReason = z.union([
|
|
10
|
+
z.literal("CERTIFICATE_REVOKED_BY_ISSUER"),
|
|
11
|
+
z.literal("NEW_WALLET_INSTANCE_CREATED"),
|
|
12
|
+
z.literal("WALLET_INSTANCE_RENEWAL"),
|
|
13
|
+
z.literal("REVOKED_BY_USER"),
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
export type WalletInstanceData = z.infer<typeof WalletInstanceData>;
|
|
17
|
+
export const WalletInstanceData = z.object({
|
|
18
|
+
id: z.string(),
|
|
19
|
+
is_revoked: z.boolean(),
|
|
20
|
+
revocation_reason: z.union([RevocationReason, z.undefined()]).optional(),
|
|
21
|
+
});
|
|
22
|
+
|
|
3
23
|
export type NonceDetailView = z.infer<typeof NonceDetailView>;
|
|
4
24
|
export const NonceDetailView = z.object({
|
|
5
25
|
nonce: z.string(),
|
|
6
26
|
});
|
|
7
27
|
|
|
8
|
-
export type WalletAttestationView = z.infer<typeof WalletAttestationView>;
|
|
9
|
-
export const WalletAttestationView = z.object({
|
|
10
|
-
wallet_attestation: z.string(),
|
|
11
|
-
});
|
|
12
|
-
|
|
13
28
|
export type WalletAttestationsView = z.infer<typeof WalletAttestationsView>;
|
|
14
29
|
export const WalletAttestationsView = z.object({
|
|
15
30
|
wallet_attestations: z.array(
|
|
@@ -25,40 +40,16 @@ export const CreateWalletInstanceBody = z.object({
|
|
|
25
40
|
challenge: z.string(),
|
|
26
41
|
key_attestation: z.string(),
|
|
27
42
|
hardware_key_tag: z.string(),
|
|
43
|
+
is_renewal: z.union([z.boolean(), z.undefined()]).optional(),
|
|
28
44
|
});
|
|
29
45
|
|
|
30
46
|
export type CreateWalletAttestationBody = z.infer<typeof CreateWalletAttestationBody>;
|
|
31
47
|
export const CreateWalletAttestationBody = z.object({
|
|
32
|
-
grant_type: z.literal("urn:ietf:params:oauth:grant-type:jwt-bearer"),
|
|
33
|
-
assertion: z.string(),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export type CreateWalletAttestationV2Body = z.infer<typeof CreateWalletAttestationV2Body>;
|
|
37
|
-
export const CreateWalletAttestationV2Body = z.object({
|
|
38
48
|
assertion: z.string(),
|
|
39
49
|
});
|
|
40
50
|
|
|
41
|
-
export type
|
|
42
|
-
export const
|
|
43
|
-
status: z.literal("REVOKED"),
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export type RevocationReason = z.infer<typeof RevocationReason>;
|
|
47
|
-
export const RevocationReason = z.union([
|
|
48
|
-
z.literal("CERTIFICATE_REVOKED_BY_ISSUER"),
|
|
49
|
-
z.literal("NEW_WALLET_INSTANCE_CREATED"),
|
|
50
|
-
z.literal("REVOKED_BY_USER"),
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
export type WalletInstanceData = z.infer<typeof WalletInstanceData>;
|
|
54
|
-
export const WalletInstanceData = z.object({
|
|
55
|
-
id: z.string(),
|
|
56
|
-
is_revoked: z.boolean(),
|
|
57
|
-
revocation_reason: z.union([RevocationReason, z.undefined()]).optional(),
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
export type ProblemDetail = z.infer<typeof ProblemDetail>;
|
|
61
|
-
export const ProblemDetail = z.object({
|
|
51
|
+
export type ProblemJson = z.infer<typeof ProblemJson>;
|
|
52
|
+
export const ProblemJson = z.object({
|
|
62
53
|
type: z.string().optional(),
|
|
63
54
|
title: z.string().optional(),
|
|
64
55
|
status: z.number().optional(),
|
|
@@ -66,6 +57,13 @@ export const ProblemDetail = z.object({
|
|
|
66
57
|
instance: z.string().optional(),
|
|
67
58
|
});
|
|
68
59
|
|
|
60
|
+
export type WhitelistedFiscalCodeData = z.infer<typeof WhitelistedFiscalCodeData>;
|
|
61
|
+
export const WhitelistedFiscalCodeData = z.object({
|
|
62
|
+
whitelisted: z.boolean(),
|
|
63
|
+
whitelistedAt: z.union([z.string(), z.undefined()]).optional(),
|
|
64
|
+
fiscalCode: z.string(),
|
|
65
|
+
});
|
|
66
|
+
|
|
69
67
|
export type get_GetNonce = typeof get_GetNonce;
|
|
70
68
|
export const get_GetNonce = {
|
|
71
69
|
method: z.literal("GET"),
|
|
@@ -86,20 +84,10 @@ export const post_CreateWalletInstance = {
|
|
|
86
84
|
|
|
87
85
|
export type post_CreateWalletAttestation = typeof post_CreateWalletAttestation;
|
|
88
86
|
export const post_CreateWalletAttestation = {
|
|
89
|
-
method: z.literal("POST"),
|
|
90
|
-
path: z.literal("/token"),
|
|
91
|
-
parameters: z.object({
|
|
92
|
-
body: CreateWalletAttestationBody,
|
|
93
|
-
}),
|
|
94
|
-
response: WalletAttestationView,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export type post_CreateWalletAttestationV2 = typeof post_CreateWalletAttestationV2;
|
|
98
|
-
export const post_CreateWalletAttestationV2 = {
|
|
99
87
|
method: z.literal("POST"),
|
|
100
88
|
path: z.literal("/wallet-attestations"),
|
|
101
89
|
parameters: z.object({
|
|
102
|
-
body:
|
|
90
|
+
body: CreateWalletAttestationBody,
|
|
103
91
|
}),
|
|
104
92
|
response: WalletAttestationsView,
|
|
105
93
|
};
|
|
@@ -132,22 +120,41 @@ export const put_SetWalletInstanceStatus = {
|
|
|
132
120
|
path: z.object({
|
|
133
121
|
id: z.string(),
|
|
134
122
|
}),
|
|
135
|
-
body:
|
|
123
|
+
body: SetWalletInstanceStatusData,
|
|
136
124
|
}),
|
|
137
125
|
response: z.unknown(),
|
|
138
126
|
};
|
|
139
127
|
|
|
128
|
+
export type get_HealthCheck = typeof get_HealthCheck;
|
|
129
|
+
export const get_HealthCheck = {
|
|
130
|
+
method: z.literal("GET"),
|
|
131
|
+
path: z.literal("/info"),
|
|
132
|
+
parameters: z.never(),
|
|
133
|
+
response: z.object({
|
|
134
|
+
message: z.string().optional(),
|
|
135
|
+
}),
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type get_IsFiscalCodeWhitelisted = typeof get_IsFiscalCodeWhitelisted;
|
|
139
|
+
export const get_IsFiscalCodeWhitelisted = {
|
|
140
|
+
method: z.literal("GET"),
|
|
141
|
+
path: z.literal("/whitelisted-fiscal-code"),
|
|
142
|
+
parameters: z.never(),
|
|
143
|
+
response: WhitelistedFiscalCodeData,
|
|
144
|
+
};
|
|
145
|
+
|
|
140
146
|
// <EndpointByMethod>
|
|
141
147
|
export const EndpointByMethod = {
|
|
142
148
|
get: {
|
|
143
149
|
"/nonce": get_GetNonce,
|
|
144
150
|
"/wallet-instances/current/status": get_GetCurrentWalletInstanceStatus,
|
|
145
151
|
"/wallet-instances/{id}/status": get_GetWalletInstanceStatus,
|
|
152
|
+
"/info": get_HealthCheck,
|
|
153
|
+
"/whitelisted-fiscal-code": get_IsFiscalCodeWhitelisted,
|
|
146
154
|
},
|
|
147
155
|
post: {
|
|
148
156
|
"/wallet-instances": post_CreateWalletInstance,
|
|
149
|
-
"/
|
|
150
|
-
"/wallet-attestations": post_CreateWalletAttestationV2,
|
|
157
|
+
"/wallet-attestations": post_CreateWalletAttestation,
|
|
151
158
|
},
|
|
152
159
|
put: {
|
|
153
160
|
"/wallet-instances/{id}/status": put_SetWalletInstanceStatus,
|
package/src/client/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseRawHttpResponse } from "../utils/misc";
|
|
2
2
|
import { WalletProviderResponseError } from "../utils/errors";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
ProblemJson,
|
|
5
5
|
createApiClient as createWalletProviderApiClient,
|
|
6
6
|
ApiClient as WalletProviderApiClient,
|
|
7
7
|
type EndpointParameters,
|
|
@@ -13,9 +13,9 @@ type RawHttpResponse = Awaited<ReturnType<typeof parseRawHttpResponse>>;
|
|
|
13
13
|
|
|
14
14
|
const validateResponse = async (response: Response) => {
|
|
15
15
|
if (!response.ok) {
|
|
16
|
-
let problemDetail:
|
|
16
|
+
let problemDetail: ProblemJson = {};
|
|
17
17
|
try {
|
|
18
|
-
problemDetail =
|
|
18
|
+
problemDetail = ProblemJson.parse(await response.json());
|
|
19
19
|
} catch {
|
|
20
20
|
problemDetail = {
|
|
21
21
|
title: "Invalid response from Wallet Provider",
|
|
@@ -3,17 +3,17 @@ import { type Out } from "../../utils/misc";
|
|
|
3
3
|
import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
|
4
4
|
import { IoWalletError } from "../../utils/errors";
|
|
5
5
|
import { SdJwt4VC, verify as verifySdJwt } from "../../sd-jwt";
|
|
6
|
-
import { getValueFromDisclosures } from "../../sd-jwt/converters";
|
|
7
6
|
import { isSameThumbprint, type JWK } from "../../utils/jwk";
|
|
8
7
|
import type { ObtainCredential } from "./06-obtain-credential";
|
|
9
|
-
import { verify as verifyMdoc } from "../../mdoc";
|
|
8
|
+
import { getParsedCredentialClaimKey, verify as verifyMdoc } from "../../mdoc";
|
|
10
9
|
import { MDOC_DEFAULT_NAMESPACE } from "../../mdoc/const";
|
|
11
|
-
import { getParsedCredentialClaimKey } from "../../mdoc/utils";
|
|
12
10
|
import { Logger, LogLevel } from "../../utils/logging";
|
|
13
11
|
import { extractElementValueAsDate } from "../../mdoc/converter";
|
|
14
12
|
import type { CBOR } from "@pagopa/io-react-native-iso18013";
|
|
15
13
|
import type { PublicKey } from "@pagopa/io-react-native-crypto";
|
|
16
|
-
import {
|
|
14
|
+
import { type SDJwt, SDJwtInstance } from "@sd-jwt/core";
|
|
15
|
+
import { digest } from "@sd-jwt/crypto-nodejs";
|
|
16
|
+
import { isPathEqual, isPrefixOf } from "../../utils/parser";
|
|
17
17
|
|
|
18
18
|
type IssuerConf = Out<EvaluateIssuerTrust>["issuerConf"];
|
|
19
19
|
type CredentialConf =
|
|
@@ -60,112 +60,139 @@ type ParsedCredential = {
|
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Parse a Sd-Jwt credential according to the issuer configuration
|
|
65
|
+
* @param credentialConfig - the list of supported credentials, as defined in the issuer configuration with their claims metadata
|
|
66
|
+
* @param parsedCredentialRaw - the raw parsed credential
|
|
67
|
+
* @param ignoreMissingAttributes - skip error when attributes declared in the issuer configuration are not found within disclosures
|
|
68
|
+
* @param includeUndefinedAttributes - include attributes not explicitly declared in the issuer configuration
|
|
69
|
+
* @returns The parsed credential with attributes in plain value
|
|
70
|
+
*/
|
|
68
71
|
const parseCredentialSdJwt = (
|
|
69
|
-
// The credential configuration to use to parse the provided credential
|
|
70
72
|
credentialConfig: CredentialConf,
|
|
71
|
-
|
|
73
|
+
parsedCredentialRaw: Record<string, unknown>,
|
|
72
74
|
ignoreMissingAttributes: boolean = false,
|
|
73
75
|
includeUndefinedAttributes: boolean = false
|
|
74
76
|
): ParsedCredential => {
|
|
75
|
-
|
|
76
|
-
const message = `Received credential is of an unknown type. Expected one of [${credentialConfig.format}], received '${sdJwt.header.typ}'`;
|
|
77
|
-
Logger.log(LogLevel.ERROR, message);
|
|
78
|
-
throw new IoWalletError(message);
|
|
79
|
-
}
|
|
77
|
+
const claimsMetadata = credentialConfig.claims || [];
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
|
|
83
|
-
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const attrDefinitions = credentialConfig.claims;
|
|
87
|
-
|
|
88
|
-
// Validate that all attributes from the config exist in either disclosures OR payload
|
|
79
|
+
// Check that all mandatory attributes defined in the issuer configuration are present in the credential
|
|
89
80
|
if (!ignoreMissingAttributes) {
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
const missingPaths: string[] = [];
|
|
82
|
+
const rootKeysToVerify = new Set(
|
|
83
|
+
claimsMetadata
|
|
84
|
+
.map((c) => c.path[0])
|
|
85
|
+
.filter((p): p is string => typeof p === "string")
|
|
95
86
|
);
|
|
96
87
|
|
|
97
|
-
const
|
|
98
|
-
(
|
|
99
|
-
|
|
88
|
+
for (const rootKey of rootKeysToVerify) {
|
|
89
|
+
if (!(rootKey in parsedCredentialRaw)) {
|
|
90
|
+
missingPaths.push(rootKey);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
100
93
|
|
|
101
|
-
if (
|
|
94
|
+
if (missingPaths.length > 0) {
|
|
95
|
+
const missing = missingPaths.join(", ");
|
|
96
|
+
const received = Object.keys(parsedCredentialRaw).join(", ");
|
|
102
97
|
throw new IoWalletError(
|
|
103
|
-
`Some attributes are missing in the credential. Missing: [${
|
|
98
|
+
`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
|
|
104
99
|
);
|
|
105
100
|
}
|
|
106
101
|
}
|
|
107
102
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
// Loop through each group
|
|
126
|
-
for (const topLevelKey in groupedDefinitions) {
|
|
127
|
-
const definitionsForThisKey = groupedDefinitions[topLevelKey];
|
|
103
|
+
/**
|
|
104
|
+
* Helper to find display metadata for any given path
|
|
105
|
+
*/
|
|
106
|
+
const getDisplayNames = (
|
|
107
|
+
path: (string | number | null)[]
|
|
108
|
+
): Record<string, string> | undefined => {
|
|
109
|
+
const match = claimsMetadata.find((c) => isPathEqual(c.path, path));
|
|
110
|
+
if (!match) return undefined;
|
|
111
|
+
|
|
112
|
+
const nameMap: Record<string, string> = {};
|
|
113
|
+
for (const entry of match.display) {
|
|
114
|
+
nameMap[entry.locale] = entry.name;
|
|
115
|
+
}
|
|
116
|
+
return nameMap;
|
|
117
|
+
};
|
|
128
118
|
|
|
129
|
-
|
|
130
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Recursive function to build the localized structure
|
|
121
|
+
*/
|
|
122
|
+
const processLevel = (
|
|
123
|
+
currentData: unknown,
|
|
124
|
+
currentPath: (string | number | null)[]
|
|
125
|
+
): unknown => {
|
|
126
|
+
// Handle Arrays
|
|
127
|
+
if (Array.isArray(currentData)) {
|
|
128
|
+
return currentData.map((item) =>
|
|
129
|
+
processLevel(item, [...currentPath, null])
|
|
130
|
+
);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
// Handle Objects
|
|
134
|
+
if (typeof currentData !== "object" || currentData === null) {
|
|
135
|
+
return currentData;
|
|
136
|
+
}
|
|
136
137
|
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
const dataObj = currentData as Record<string, unknown>;
|
|
139
|
+
const result: ParsedCredential = {};
|
|
140
|
+
const processedKeys = new Set<string | number>();
|
|
141
|
+
|
|
142
|
+
// Identify unique keys in config at this level
|
|
143
|
+
const configKeysAtThisLevel: (string | number)[] = [];
|
|
144
|
+
for (const claim of claimsMetadata) {
|
|
145
|
+
// Check if the claim path starts with the current path
|
|
146
|
+
if (isPrefixOf(currentPath, claim.path)) {
|
|
147
|
+
const nextPart = claim.path[currentPath.length];
|
|
148
|
+
if (
|
|
149
|
+
(typeof nextPart === "string" || typeof nextPart === "number") &&
|
|
150
|
+
!configKeysAtThisLevel.includes(nextPart)
|
|
151
|
+
) {
|
|
152
|
+
configKeysAtThisLevel.push(nextPart);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
139
155
|
}
|
|
140
156
|
|
|
141
|
-
|
|
157
|
+
// Process keys
|
|
158
|
+
for (const key of configKeysAtThisLevel) {
|
|
159
|
+
const stringKey = key.toString();
|
|
160
|
+
const dataValue = dataObj[stringKey];
|
|
161
|
+
if (dataValue === undefined) continue;
|
|
142
162
|
|
|
143
|
-
|
|
144
|
-
(acc, { path, display }) =>
|
|
145
|
-
createNestedProperty(acc, path, disclosureValue, display),
|
|
146
|
-
{}
|
|
147
|
-
);
|
|
163
|
+
const newPath = [...currentPath, key];
|
|
148
164
|
|
|
149
|
-
|
|
150
|
-
Object.assign(definedValues, tempObjectForGroup);
|
|
151
|
-
}
|
|
165
|
+
let localizedNames = getDisplayNames(newPath);
|
|
152
166
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
disclosures
|
|
158
|
-
.filter((_) => !Object.keys(definedValues).includes(_[1]))
|
|
159
|
-
.map(([, key, value]) => [key, { value, name: key }])
|
|
160
|
-
);
|
|
167
|
+
// Fallback for arrays
|
|
168
|
+
if (!localizedNames && Array.isArray(dataValue)) {
|
|
169
|
+
localizedNames = getDisplayNames([...newPath, null]);
|
|
170
|
+
}
|
|
161
171
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
172
|
+
result[stringKey] = {
|
|
173
|
+
name: localizedNames || stringKey,
|
|
174
|
+
value: processLevel(dataValue, newPath),
|
|
175
|
+
};
|
|
167
176
|
|
|
168
|
-
|
|
177
|
+
processedKeys.add(key);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Handle Undefined Attributes
|
|
181
|
+
if (includeUndefinedAttributes) {
|
|
182
|
+
for (const [key, value] of Object.entries(dataObj)) {
|
|
183
|
+
if (!processedKeys.has(key)) {
|
|
184
|
+
result[key] = {
|
|
185
|
+
name: key,
|
|
186
|
+
value: value,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return result;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
return processLevel(parsedCredentialRaw, []) as ParsedCredential;
|
|
169
196
|
};
|
|
170
197
|
|
|
171
198
|
const parseCredentialMDoc = (
|
|
@@ -305,7 +332,8 @@ async function verifyCredentialSdJwt(
|
|
|
305
332
|
rawCredential: string,
|
|
306
333
|
issuerKeys: JWK[],
|
|
307
334
|
holderBindingContext: CryptoContext
|
|
308
|
-
): Promise<
|
|
335
|
+
): Promise<SDJwt> {
|
|
336
|
+
// TODO: change verification using sd-jwt library with 1.3.x update
|
|
309
337
|
const [decodedCredential, holderBindingKey] =
|
|
310
338
|
// parallel for optimization
|
|
311
339
|
await Promise.all([
|
|
@@ -320,8 +348,13 @@ async function verifyCredentialSdJwt(
|
|
|
320
348
|
throw new IoWalletError(message);
|
|
321
349
|
}
|
|
322
350
|
|
|
323
|
-
|
|
351
|
+
const sdJwtInstance = new SDJwtInstance({
|
|
352
|
+
hasher: digest,
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
return await sdJwtInstance.decode(rawCredential);
|
|
324
356
|
}
|
|
357
|
+
|
|
325
358
|
/**
|
|
326
359
|
* Given a credential, verify it's in the supported format
|
|
327
360
|
* and the credential is correctly signed
|
|
@@ -396,26 +429,37 @@ const verifyAndParseCredentialSdJwt: VerifyAndParseCredential = async (
|
|
|
396
429
|
throw new IoWalletError("Credential type not supported by the issuer");
|
|
397
430
|
}
|
|
398
431
|
|
|
432
|
+
const parsedCredentialRaw = (await decoded.getClaims(digest)) as Record<
|
|
433
|
+
string,
|
|
434
|
+
unknown
|
|
435
|
+
>;
|
|
436
|
+
|
|
399
437
|
const parsedCredential = parseCredentialSdJwt(
|
|
400
438
|
credentialConfig,
|
|
401
|
-
|
|
439
|
+
parsedCredentialRaw,
|
|
402
440
|
ignoreMissingAttributes,
|
|
403
441
|
includeUndefinedAttributes
|
|
404
442
|
);
|
|
405
|
-
|
|
443
|
+
|
|
444
|
+
const issuedAt =
|
|
445
|
+
typeof parsedCredentialRaw.iat === "number"
|
|
446
|
+
? new Date(parsedCredentialRaw.iat * 1000)
|
|
447
|
+
: undefined;
|
|
448
|
+
|
|
449
|
+
if (typeof parsedCredentialRaw.exp !== "number") {
|
|
450
|
+
throw new IoWalletError("Invalid or missing expiration claim (exp)");
|
|
451
|
+
}
|
|
452
|
+
const expiration = new Date(parsedCredentialRaw.exp * 1000);
|
|
406
453
|
|
|
407
454
|
Logger.log(
|
|
408
455
|
LogLevel.DEBUG,
|
|
409
|
-
`Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${
|
|
456
|
+
`Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${issuedAt}`
|
|
410
457
|
);
|
|
411
458
|
|
|
412
459
|
return {
|
|
413
460
|
parsedCredential,
|
|
414
|
-
expiration
|
|
415
|
-
issuedAt
|
|
416
|
-
typeof maybeIssuedAt === "number"
|
|
417
|
-
? new Date(maybeIssuedAt * 1000)
|
|
418
|
-
: undefined,
|
|
461
|
+
expiration,
|
|
462
|
+
issuedAt,
|
|
419
463
|
};
|
|
420
464
|
};
|
|
421
465
|
|