@pagopa/io-react-native-wallet 2.2.0 → 2.3.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/README.md +4 -3
- package/lib/commonjs/credential/index.js +3 -1
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/offer/01-start-flow.js +75 -0
- package/lib/commonjs/credential/offer/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/offer/02-fetch-credential-offer.js +45 -0
- package/lib/commonjs/credential/offer/02-fetch-credential-offer.js.map +1 -0
- package/lib/commonjs/credential/offer/README.md +174 -0
- package/lib/commonjs/credential/offer/errors.js +22 -0
- package/lib/commonjs/credential/offer/errors.js.map +1 -0
- package/lib/commonjs/credential/offer/index.js +25 -0
- package/lib/commonjs/credential/offer/index.js.map +1 -0
- package/lib/commonjs/credential/offer/types.js +51 -0
- package/lib/commonjs/credential/offer/types.js.map +1 -0
- package/lib/commonjs/credential/presentation/01-start-flow.js +1 -1
- package/lib/commonjs/credentials-catalogue/README.md +15 -0
- package/lib/commonjs/credentials-catalogue/fetch-and-parse-catalogue.js +42 -0
- package/lib/commonjs/credentials-catalogue/fetch-and-parse-catalogue.js.map +1 -0
- package/lib/commonjs/credentials-catalogue/index.js +13 -0
- package/lib/commonjs/credentials-catalogue/index.js.map +1 -0
- package/lib/commonjs/credentials-catalogue/types.js +99 -0
- package/lib/commonjs/credentials-catalogue/types.js.map +1 -0
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/zod.js +28 -0
- package/lib/commonjs/utils/zod.js.map +1 -0
- package/lib/module/credential/index.js +2 -1
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/offer/01-start-flow.js +66 -0
- package/lib/module/credential/offer/01-start-flow.js.map +1 -0
- package/lib/module/credential/offer/02-fetch-credential-offer.js +38 -0
- package/lib/module/credential/offer/02-fetch-credential-offer.js.map +1 -0
- package/lib/module/credential/offer/README.md +174 -0
- package/lib/module/credential/offer/errors.js +14 -0
- package/lib/module/credential/offer/errors.js.map +1 -0
- package/lib/module/credential/offer/index.js +5 -0
- package/lib/module/credential/offer/index.js.map +1 -0
- package/lib/module/credential/offer/types.js +41 -0
- package/lib/module/credential/offer/types.js.map +1 -0
- package/lib/module/credential/presentation/01-start-flow.js +1 -1
- package/lib/module/credentials-catalogue/README.md +15 -0
- package/lib/module/credentials-catalogue/fetch-and-parse-catalogue.js +35 -0
- package/lib/module/credentials-catalogue/fetch-and-parse-catalogue.js.map +1 -0
- package/lib/module/credentials-catalogue/index.js +2 -0
- package/lib/module/credentials-catalogue/index.js.map +1 -0
- package/lib/module/credentials-catalogue/types.js +89 -0
- package/lib/module/credentials-catalogue/types.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/zod.js +20 -0
- package/lib/module/utils/zod.js.map +1 -0
- package/lib/typescript/credential/index.d.ts +2 -1
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
- package/lib/typescript/credential/offer/01-start-flow.d.ts +172 -0
- package/lib/typescript/credential/offer/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/offer/02-fetch-credential-offer.d.ts +20 -0
- package/lib/typescript/credential/offer/02-fetch-credential-offer.d.ts.map +1 -0
- package/lib/typescript/credential/offer/errors.d.ts +10 -0
- package/lib/typescript/credential/offer/errors.d.ts.map +1 -0
- package/lib/typescript/credential/offer/index.d.ts +7 -0
- package/lib/typescript/credential/offer/index.d.ts.map +1 -0
- package/lib/typescript/credential/offer/types.d.ts +264 -0
- package/lib/typescript/credential/offer/types.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +1 -1
- package/lib/typescript/credentials-catalogue/fetch-and-parse-catalogue.d.ts +15 -0
- package/lib/typescript/credentials-catalogue/fetch-and-parse-catalogue.d.ts.map +1 -0
- package/lib/typescript/credentials-catalogue/index.d.ts +3 -0
- package/lib/typescript/credentials-catalogue/index.d.ts.map +1 -0
- package/lib/typescript/credentials-catalogue/types.d.ts +844 -0
- package/lib/typescript/credentials-catalogue/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/zod.d.ts +15 -0
- package/lib/typescript/utils/zod.d.ts.map +1 -0
- package/package.json +21 -2
- package/src/credential/index.ts +2 -1
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/offer/01-start-flow.ts +89 -0
- package/src/credential/offer/02-fetch-credential-offer.ts +54 -0
- package/src/credential/offer/README.md +174 -0
- package/src/credential/offer/errors.ts +17 -0
- package/src/credential/offer/index.ts +16 -0
- package/src/credential/offer/types.ts +59 -0
- package/src/credential/presentation/01-start-flow.ts +1 -1
- package/src/credentials-catalogue/README.md +15 -0
- package/src/credentials-catalogue/fetch-and-parse-catalogue.ts +54 -0
- package/src/credentials-catalogue/index.ts +2 -0
- package/src/credentials-catalogue/types.ts +97 -0
- package/src/index.ts +2 -0
- package/src/utils/zod.ts +28 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { UnixTime } from "../sd-jwt/types";
|
|
3
|
+
|
|
4
|
+
const CredentialPurpose = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
description: z.string(),
|
|
7
|
+
category: z.string(),
|
|
8
|
+
subcategory: z.string(),
|
|
9
|
+
claims_required: z.array(z.string()),
|
|
10
|
+
claim_recommended: z.array(z.string()),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const CredentialIssuer = z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
organization_name: z.string(),
|
|
16
|
+
organization_code: z.string(),
|
|
17
|
+
organization_country: z.string(),
|
|
18
|
+
contacts: z.array(z.string()).optional(),
|
|
19
|
+
homepage_uri: z.string().optional(),
|
|
20
|
+
logo_uri: z.string().optional(),
|
|
21
|
+
policy_uri: z.string().optional(),
|
|
22
|
+
tos_uri: z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const AuthenticSource = z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
organization_name: z.string(),
|
|
28
|
+
organization_code: z.string(),
|
|
29
|
+
organization_country: z.string(),
|
|
30
|
+
source_type: z.enum(["public", "private"]),
|
|
31
|
+
contacts: z.array(z.string()).optional(),
|
|
32
|
+
homepage_uri: z.string().optional(),
|
|
33
|
+
logo_uri: z.string().optional(),
|
|
34
|
+
user_information: z.string().optional(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const CredentialFormat = z.object({
|
|
38
|
+
configuration_id: z.string(),
|
|
39
|
+
format: z.enum(["dc+sd-jwt", "mso_mdoc"]),
|
|
40
|
+
vct: z.string().url().optional(),
|
|
41
|
+
docType: z.string().optional(),
|
|
42
|
+
schema_uri: z.string().url().optional(),
|
|
43
|
+
"schema_uri#integrity": z.string().optional(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const Claim = z.object({
|
|
47
|
+
name: z.string(),
|
|
48
|
+
taxonomy_ref: z.string(),
|
|
49
|
+
display_name: z.string(),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const DigitalCredential = z.object({
|
|
53
|
+
version: z.string(),
|
|
54
|
+
credential_type: z.string(),
|
|
55
|
+
legal_type: z.string(),
|
|
56
|
+
name: z.string(),
|
|
57
|
+
description: z.string(),
|
|
58
|
+
validity_info: z.object({
|
|
59
|
+
max_validity_days: z.number(),
|
|
60
|
+
status_methods: z.array(z.string()),
|
|
61
|
+
allowed_states: z.array(z.string()),
|
|
62
|
+
}),
|
|
63
|
+
authentication: z.object({
|
|
64
|
+
user_auth_required: z.boolean(),
|
|
65
|
+
min_loa: z.string(),
|
|
66
|
+
supported_eid_schemes: z.array(z.string()),
|
|
67
|
+
}),
|
|
68
|
+
purposes: z.array(CredentialPurpose),
|
|
69
|
+
issuers: z.array(CredentialIssuer),
|
|
70
|
+
authentic_sources: z.array(AuthenticSource),
|
|
71
|
+
formats: z.array(CredentialFormat),
|
|
72
|
+
claims: z.array(Claim),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The Digital Credentials Catalogue published by the Trust Anchor
|
|
77
|
+
*
|
|
78
|
+
* @version 1.1.0
|
|
79
|
+
* @see https://italia.github.io/eid-wallet-it-docs/releases/1.1.0/en/registry-catalogue.html
|
|
80
|
+
*/
|
|
81
|
+
export const DigitalCredentialsCatalogue = z.object({
|
|
82
|
+
header: z.object({
|
|
83
|
+
typ: z.string(),
|
|
84
|
+
alg: z.string(),
|
|
85
|
+
kid: z.string(),
|
|
86
|
+
}),
|
|
87
|
+
payload: z.object({
|
|
88
|
+
catalog_version: z.string(),
|
|
89
|
+
taxonomy_uri: z.string().url(),
|
|
90
|
+
credentials: z.array(DigitalCredential),
|
|
91
|
+
iat: UnixTime,
|
|
92
|
+
exp: UnixTime,
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
export type DigitalCredentialsCatalogue = z.infer<
|
|
96
|
+
typeof DigitalCredentialsCatalogue
|
|
97
|
+
>;
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { fixBase64EncodingOnKey } from "./utils/jwk";
|
|
|
5
5
|
import "react-native-url-polyfill/auto";
|
|
6
6
|
|
|
7
7
|
import * as Credential from "./credential";
|
|
8
|
+
import * as CredentialsCatalogue from "./credentials-catalogue";
|
|
8
9
|
import * as PID from "./pid";
|
|
9
10
|
import * as SdJwt from "./sd-jwt";
|
|
10
11
|
import * as Mdoc from "./mdoc";
|
|
@@ -22,6 +23,7 @@ export {
|
|
|
22
23
|
Mdoc,
|
|
23
24
|
PID,
|
|
24
25
|
Credential,
|
|
26
|
+
CredentialsCatalogue,
|
|
25
27
|
WalletInstanceAttestation,
|
|
26
28
|
WalletInstance,
|
|
27
29
|
Errors,
|
package/src/utils/zod.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://github.com/JacobWeisenburger/zod_utilz/blob/main/src/stringToJSON.ts
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
8
|
+
|
|
9
|
+
type Literal = z.infer<typeof literalSchema>;
|
|
10
|
+
|
|
11
|
+
type Json = Literal | { [key: string]: Json } | Json[];
|
|
12
|
+
|
|
13
|
+
const jsonSchema: z.ZodType<Json> = z.lazy(() =>
|
|
14
|
+
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const json = () => jsonSchema;
|
|
18
|
+
|
|
19
|
+
export const stringToJSONSchema = z
|
|
20
|
+
.string()
|
|
21
|
+
.transform((str, ctx): z.infer<ReturnType<typeof json>> => {
|
|
22
|
+
try {
|
|
23
|
+
return JSON.parse(str);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
ctx.addIssue({ code: "custom", message: "Invalid JSON" });
|
|
26
|
+
return z.NEVER;
|
|
27
|
+
}
|
|
28
|
+
});
|