@pagopa/io-react-native-wallet 0.11.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/client/generated/wallet-provider.js +126 -0
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -0
- package/lib/commonjs/client/index.js +40 -0
- package/lib/commonjs/client/index.js.map +1 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +2 -1
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -1
- package/lib/commonjs/credential/issuance/03-start-credential-issuance.js +287 -0
- package/lib/commonjs/credential/issuance/03-start-credential-issuance.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +56 -83
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +88 -0
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +56 -33
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +51 -78
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +21 -44
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +7 -0
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +28 -0
- package/lib/commonjs/credential/issuance/types.js.map +1 -0
- package/lib/commonjs/index.js +10 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/converters.js +5 -9
- package/lib/commonjs/pid/sd-jwt/converters.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +3 -3
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/converters.test.js +1 -1
- package/lib/commonjs/sd-jwt/__test__/converters.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +30 -43
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +16 -24
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +3 -9
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +11 -16
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/trust/types.js +70 -29
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/auth.js +44 -0
- package/lib/commonjs/utils/auth.js.map +1 -0
- package/lib/commonjs/utils/errors.js +104 -1
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/integrity.js +2 -0
- package/lib/commonjs/utils/integrity.js.map +1 -0
- package/lib/commonjs/utils/misc.js +34 -1
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +23 -15
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/pop.js +33 -0
- package/lib/commonjs/utils/pop.js.map +1 -0
- package/lib/commonjs/wallet-instance/index.js +29 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -0
- package/lib/commonjs/wallet-instance-attestation/issuing.js +62 -65
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +8 -8
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +102 -0
- package/lib/module/client/generated/wallet-provider.js.map +1 -0
- package/lib/module/client/index.js +33 -0
- package/lib/module/client/index.js.map +1 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +2 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -1
- package/lib/module/credential/issuance/03-start-credential-issuance.js +276 -0
- package/lib/module/credential/issuance/03-start-credential-issuance.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +56 -80
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +85 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +54 -33
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +50 -75
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +21 -44
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -1
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/issuance/types.js +18 -0
- package/lib/module/credential/issuance/types.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/converters.js +5 -9
- package/lib/module/pid/sd-jwt/converters.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +3 -3
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/converters.test.js +1 -1
- package/lib/module/sd-jwt/__test__/converters.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +30 -43
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +16 -24
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +3 -9
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +11 -16
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/types.js +70 -29
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/auth.js +35 -0
- package/lib/module/utils/auth.js.map +1 -0
- package/lib/module/utils/errors.js +98 -0
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/integrity.js +2 -0
- package/lib/module/utils/integrity.js.map +1 -0
- package/lib/module/utils/misc.js +31 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +24 -16
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/pop.js +24 -0
- package/lib/module/utils/pop.js.map +1 -0
- package/lib/module/wallet-instance/index.js +23 -0
- package/lib/module/wallet-instance/index.js.map +1 -0
- package/lib/module/wallet-instance-attestation/issuing.js +63 -67
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +8 -8
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +264 -0
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -0
- package/lib/typescript/client/index.d.ts +7 -0
- package/lib/typescript/client/index.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -0
- package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +2 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts +41 -0
- package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +23 -18
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +24 -12
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +22 -16
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +19 -26
- 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 +10 -15
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -4
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +63 -0
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/types.d.ts +6 -6
- package/lib/typescript/index.d.ts +6 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/converters.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +36 -36
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +40 -68
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +64 -121
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/trust/index.d.ts +150 -48
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +2838 -1740
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/auth.d.ts +52 -0
- package/lib/typescript/utils/auth.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +48 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/integrity.d.ts +21 -0
- package/lib/typescript/utils/integrity.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts +18 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +8 -31
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/utils/pop.d.ts +26 -0
- package/lib/typescript/utils/pop.d.ts.map +1 -0
- package/lib/typescript/wallet-instance/index.d.ts +7 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -0
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +17 -4
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +64 -64
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/client/generated/wallet-provider.ts +173 -0
- package/src/client/index.ts +53 -0
- package/src/credential/issuance/01-start-flow.ts +1 -0
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +2 -1
- package/src/credential/issuance/03-start-credential-issuance.ts +407 -0
- package/src/credential/issuance/03-start-user-authorization.ts +91 -92
- package/src/credential/issuance/04-complete-user-authorization.ts +114 -13
- package/src/credential/issuance/05-authorize-access.ts +74 -49
- package/src/credential/issuance/06-obtain-credential.ts +77 -111
- package/src/credential/issuance/07-verify-and-parse-credential.ts +30 -67
- package/src/credential/issuance/index.ts +6 -4
- package/src/credential/issuance/types.ts +25 -0
- package/src/index.ts +8 -0
- package/src/pid/sd-jwt/converters.ts +5 -11
- package/src/pid/sd-jwt/types.ts +8 -6
- package/src/sd-jwt/__test__/converters.test.ts +1 -1
- package/src/sd-jwt/__test__/index.test.ts +45 -74
- package/src/sd-jwt/__test__/types.test.ts +21 -33
- package/src/sd-jwt/index.ts +3 -12
- package/src/sd-jwt/types.ts +17 -22
- package/src/trust/types.ts +64 -32
- package/src/utils/auth.ts +37 -0
- package/src/utils/errors.ts +112 -0
- package/src/utils/integrity.ts +23 -0
- package/src/utils/misc.ts +43 -0
- package/src/utils/par.ts +29 -17
- package/src/utils/pop.ts +34 -0
- package/src/wallet-instance/index.ts +29 -0
- package/src/wallet-instance-attestation/issuing.ts +101 -97
- package/src/wallet-instance-attestation/types.ts +12 -8
- package/lib/commonjs/credential/issuance/07-confirm-credential.js +0 -6
- package/lib/commonjs/credential/issuance/07-confirm-credential.js.map +0 -1
- package/lib/commonjs/credential/issuance/08-confirm-credential.js +0 -6
- package/lib/commonjs/credential/issuance/08-confirm-credential.js.map +0 -1
- package/lib/module/credential/issuance/07-confirm-credential.js +0 -2
- package/lib/module/credential/issuance/07-confirm-credential.js.map +0 -1
- package/lib/module/credential/issuance/08-confirm-credential.js +0 -2
- package/lib/module/credential/issuance/08-confirm-credential.js.map +0 -1
- package/lib/typescript/credential/issuance/07-confirm-credential.d.ts +0 -11
- package/lib/typescript/credential/issuance/07-confirm-credential.d.ts.map +0 -1
- package/lib/typescript/credential/issuance/08-confirm-credential.d.ts +0 -11
- package/lib/typescript/credential/issuance/08-confirm-credential.d.ts.map +0 -1
- package/src/credential/issuance/07-confirm-credential.ts +0 -14
- package/src/credential/issuance/08-confirm-credential.ts +0 -14
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/wallet-instance-attestation/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AA2BzB,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CACvD,OAAO,mCAAmC,CAC3C,CAAC;AACF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe9C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,4BAA4B,CACpC,CAAC;AACF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/wallet-instance-attestation/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AA2BzB,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CACvD,OAAO,mCAAmC,CAC3C,CAAC;AACF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe9C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,4BAA4B,CACpC,CAAC;AACF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BvC,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pagopa/io-react-native-wallet",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.13.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",
|
@@ -34,7 +34,9 @@
|
|
34
34
|
"release": "release-it",
|
35
35
|
"example": "yarn --cwd example",
|
36
36
|
"bootstrap": "yarn example && yarn install",
|
37
|
-
"code-review": "yarn lint && yarn typecheck && yarn test"
|
37
|
+
"code-review": "yarn generate && yarn lint && yarn typecheck && yarn test",
|
38
|
+
"generate-wallet-provider-client": "typed-openapi openapi/wallet-provider.yaml -o src/client/generated/wallet-provider.ts -r zod",
|
39
|
+
"generate": "yarn generate-wallet-provider-client"
|
38
40
|
},
|
39
41
|
"keywords": [
|
40
42
|
"react-native",
|
@@ -53,8 +55,8 @@
|
|
53
55
|
"devDependencies": {
|
54
56
|
"@pagopa/eslint-config": "^3.0.0",
|
55
57
|
"@pagopa/io-react-native-crypto": "^0.2.3",
|
56
|
-
"@pagopa/io-react-native-jwt": "^1.
|
57
|
-
"@react-native
|
58
|
+
"@pagopa/io-react-native-jwt": "^1.2.0",
|
59
|
+
"@react-native/eslint-config": "^0.72.2",
|
58
60
|
"@rushstack/eslint-patch": "^1.3.2",
|
59
61
|
"@types/jest": "^28.1.2",
|
60
62
|
"@types/react": "~17.0.21",
|
@@ -66,8 +68,9 @@
|
|
66
68
|
"pod-install": "^0.1.0",
|
67
69
|
"prettier": "^2.0.5",
|
68
70
|
"react": "18.2.0",
|
69
|
-
"react-native": "0.
|
71
|
+
"react-native": "0.72.14",
|
70
72
|
"react-native-builder-bob": "^0.20.0",
|
73
|
+
"typed-openapi": "^0.4.1",
|
71
74
|
"typescript": "^5.0.2"
|
72
75
|
},
|
73
76
|
"resolutions": {
|
@@ -105,6 +108,7 @@
|
|
105
108
|
]
|
106
109
|
},
|
107
110
|
"dependencies": {
|
111
|
+
"parse-url": "^9.2.0",
|
108
112
|
"react-native-url-polyfill": "^2.0.0",
|
109
113
|
"react-native-uuid": "^2.0.1",
|
110
114
|
"zod": "^3.21.4"
|
@@ -0,0 +1,173 @@
|
|
1
|
+
import z from "zod";
|
2
|
+
|
3
|
+
export type NonceDetailView = z.infer<typeof NonceDetailView>;
|
4
|
+
export const NonceDetailView = z.object({
|
5
|
+
nonce: z.string(),
|
6
|
+
});
|
7
|
+
|
8
|
+
export type WalletAttestationView = z.infer<typeof WalletAttestationView>;
|
9
|
+
export const WalletAttestationView = z.string();
|
10
|
+
|
11
|
+
export type CreateWalletInstanceBody = z.infer<typeof CreateWalletInstanceBody>;
|
12
|
+
export const CreateWalletInstanceBody = z.object({
|
13
|
+
challenge: z.string(),
|
14
|
+
key_attestation: z.string(),
|
15
|
+
hardware_key_tag: z.string(),
|
16
|
+
});
|
17
|
+
|
18
|
+
export type CreateWalletAttestationBody = z.infer<typeof CreateWalletAttestationBody>;
|
19
|
+
export const CreateWalletAttestationBody = z.object({
|
20
|
+
grant_type: z.literal("urn:ietf:params:oauth:grant-type:jwt-bearer"),
|
21
|
+
assertion: z.string(),
|
22
|
+
});
|
23
|
+
|
24
|
+
export type ProblemDetail = z.infer<typeof ProblemDetail>;
|
25
|
+
export const ProblemDetail = z.object({
|
26
|
+
type: z.string().optional(),
|
27
|
+
title: z.string().optional(),
|
28
|
+
status: z.number().optional(),
|
29
|
+
detail: z.string().optional(),
|
30
|
+
instance: z.string().optional(),
|
31
|
+
});
|
32
|
+
|
33
|
+
export type FiscalCode = z.infer<typeof FiscalCode>;
|
34
|
+
export const FiscalCode = z.string();
|
35
|
+
|
36
|
+
export type Id = z.infer<typeof Id>;
|
37
|
+
export const Id = z.string();
|
38
|
+
|
39
|
+
export type get_GetNonce = typeof get_GetNonce;
|
40
|
+
export const get_GetNonce = {
|
41
|
+
method: z.literal("GET"),
|
42
|
+
path: z.literal("/nonce"),
|
43
|
+
parameters: z.never(),
|
44
|
+
response: NonceDetailView,
|
45
|
+
};
|
46
|
+
|
47
|
+
export type post_CreateWalletInstance = typeof post_CreateWalletInstance;
|
48
|
+
export const post_CreateWalletInstance = {
|
49
|
+
method: z.literal("POST"),
|
50
|
+
path: z.literal("/wallet-instances"),
|
51
|
+
parameters: z.object({
|
52
|
+
body: CreateWalletInstanceBody,
|
53
|
+
}),
|
54
|
+
response: z.unknown(),
|
55
|
+
};
|
56
|
+
|
57
|
+
export type post_CreateWalletAttestation = typeof post_CreateWalletAttestation;
|
58
|
+
export const post_CreateWalletAttestation = {
|
59
|
+
method: z.literal("POST"),
|
60
|
+
path: z.literal("/token"),
|
61
|
+
parameters: z.object({
|
62
|
+
body: CreateWalletAttestationBody,
|
63
|
+
}),
|
64
|
+
response: z.unknown(),
|
65
|
+
};
|
66
|
+
|
67
|
+
// <EndpointByMethod>
|
68
|
+
export const EndpointByMethod = {
|
69
|
+
get: {
|
70
|
+
"/nonce": get_GetNonce,
|
71
|
+
},
|
72
|
+
post: {
|
73
|
+
"/wallet-instances": post_CreateWalletInstance,
|
74
|
+
"/token": post_CreateWalletAttestation,
|
75
|
+
},
|
76
|
+
};
|
77
|
+
export type EndpointByMethod = typeof EndpointByMethod;
|
78
|
+
// </EndpointByMethod>
|
79
|
+
|
80
|
+
// <EndpointByMethod.Shorthands>
|
81
|
+
export type GetEndpoints = EndpointByMethod["get"];
|
82
|
+
export type PostEndpoints = EndpointByMethod["post"];
|
83
|
+
export type AllEndpoints = EndpointByMethod[keyof EndpointByMethod];
|
84
|
+
// </EndpointByMethod.Shorthands>
|
85
|
+
|
86
|
+
// <ApiClientTypes>
|
87
|
+
export type EndpointParameters = {
|
88
|
+
body?: unknown;
|
89
|
+
query?: Record<string, unknown>;
|
90
|
+
header?: Record<string, unknown>;
|
91
|
+
path?: Record<string, unknown>;
|
92
|
+
};
|
93
|
+
|
94
|
+
export type MutationMethod = "post" | "put" | "patch" | "delete";
|
95
|
+
export type Method = "get" | "head" | MutationMethod;
|
96
|
+
|
97
|
+
export type DefaultEndpoint = {
|
98
|
+
parameters?: EndpointParameters | undefined;
|
99
|
+
response: unknown;
|
100
|
+
};
|
101
|
+
|
102
|
+
export type Endpoint<TConfig extends DefaultEndpoint = DefaultEndpoint> = {
|
103
|
+
operationId: string;
|
104
|
+
method: Method;
|
105
|
+
path: string;
|
106
|
+
parameters?: TConfig["parameters"];
|
107
|
+
meta: {
|
108
|
+
alias: string;
|
109
|
+
hasParameters: boolean;
|
110
|
+
areParametersRequired: boolean;
|
111
|
+
};
|
112
|
+
response: TConfig["response"];
|
113
|
+
};
|
114
|
+
|
115
|
+
type Fetcher = (
|
116
|
+
method: Method,
|
117
|
+
url: string,
|
118
|
+
parameters?: EndpointParameters | undefined,
|
119
|
+
) => Promise<Endpoint["response"]>;
|
120
|
+
|
121
|
+
type RequiredKeys<T> = {
|
122
|
+
[P in keyof T]-?: undefined extends T[P] ? never : P;
|
123
|
+
}[keyof T];
|
124
|
+
|
125
|
+
type MaybeOptionalArg<T> = RequiredKeys<T> extends never ? [config?: T] : [config: T];
|
126
|
+
|
127
|
+
// </ApiClientTypes>
|
128
|
+
|
129
|
+
// <ApiClient>
|
130
|
+
export class ApiClient {
|
131
|
+
baseUrl: string = "";
|
132
|
+
|
133
|
+
constructor(public fetcher: Fetcher) {}
|
134
|
+
|
135
|
+
setBaseUrl(baseUrl: string) {
|
136
|
+
this.baseUrl = baseUrl;
|
137
|
+
return this;
|
138
|
+
}
|
139
|
+
|
140
|
+
// <ApiClient.get>
|
141
|
+
get<Path extends keyof GetEndpoints, TEndpoint extends GetEndpoints[Path]>(
|
142
|
+
path: Path,
|
143
|
+
...params: MaybeOptionalArg<z.infer<TEndpoint["parameters"]>>
|
144
|
+
): Promise<z.infer<TEndpoint["response"]>> {
|
145
|
+
return this.fetcher("get", this.baseUrl + path, params[0]) as Promise<z.infer<TEndpoint["response"]>>;
|
146
|
+
}
|
147
|
+
// </ApiClient.get>
|
148
|
+
|
149
|
+
// <ApiClient.post>
|
150
|
+
post<Path extends keyof PostEndpoints, TEndpoint extends PostEndpoints[Path]>(
|
151
|
+
path: Path,
|
152
|
+
...params: MaybeOptionalArg<z.infer<TEndpoint["parameters"]>>
|
153
|
+
): Promise<z.infer<TEndpoint["response"]>> {
|
154
|
+
return this.fetcher("post", this.baseUrl + path, params[0]) as Promise<z.infer<TEndpoint["response"]>>;
|
155
|
+
}
|
156
|
+
// </ApiClient.post>
|
157
|
+
}
|
158
|
+
|
159
|
+
export function createApiClient(fetcher: Fetcher, baseUrl?: string) {
|
160
|
+
return new ApiClient(fetcher).setBaseUrl(baseUrl ?? "");
|
161
|
+
}
|
162
|
+
|
163
|
+
/**
|
164
|
+
Example usage:
|
165
|
+
const api = createApiClient((method, url, params) =>
|
166
|
+
fetch(url, { method, body: JSON.stringify(params) }).then((res) => res.json()),
|
167
|
+
);
|
168
|
+
api.get("/users").then((users) => console.log(users));
|
169
|
+
api.post("/users", { body: { name: "John" } }).then((user) => console.log(user));
|
170
|
+
api.put("/users/:id", { path: { id: 1 }, body: { name: "John" } }).then((user) => console.log(user));
|
171
|
+
*/
|
172
|
+
|
173
|
+
// </ApiClient
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { WalletProviderResponseError } from "../utils/errors";
|
2
|
+
import {
|
3
|
+
ProblemDetail,
|
4
|
+
createApiClient as createWalletProviderApiClient,
|
5
|
+
} from "./generated/wallet-provider";
|
6
|
+
import { ApiClient as WalletProviderApiClient } from "./generated/wallet-provider";
|
7
|
+
|
8
|
+
export type WalletProviderClient = WalletProviderApiClient;
|
9
|
+
|
10
|
+
const validateResponse = async (response: Response) => {
|
11
|
+
if (!response.ok) {
|
12
|
+
let problemDetail: ProblemDetail = {};
|
13
|
+
try {
|
14
|
+
problemDetail = ProblemDetail.parse(await response.json());
|
15
|
+
} catch {
|
16
|
+
problemDetail = {
|
17
|
+
title: "Invalid response from Wallet Provider",
|
18
|
+
};
|
19
|
+
}
|
20
|
+
|
21
|
+
throw new WalletProviderResponseError(
|
22
|
+
problemDetail.title ?? "Invalid response from Wallet Provider",
|
23
|
+
problemDetail.type,
|
24
|
+
problemDetail.detail,
|
25
|
+
response.status
|
26
|
+
);
|
27
|
+
}
|
28
|
+
return response;
|
29
|
+
};
|
30
|
+
|
31
|
+
export const getWalletProviderClient = (context: {
|
32
|
+
walletProviderBaseUrl: string;
|
33
|
+
appFetch?: GlobalFetch["fetch"];
|
34
|
+
}) => {
|
35
|
+
const { walletProviderBaseUrl, appFetch = fetch } = context;
|
36
|
+
|
37
|
+
return createWalletProviderApiClient(
|
38
|
+
(method, url, params) =>
|
39
|
+
appFetch(url, {
|
40
|
+
method,
|
41
|
+
body: params ? JSON.stringify(params.body) : undefined,
|
42
|
+
})
|
43
|
+
.then(validateResponse)
|
44
|
+
.then((res) => {
|
45
|
+
const contentType = res.headers.get("content-type");
|
46
|
+
if (contentType === "application/json") {
|
47
|
+
return res.json();
|
48
|
+
}
|
49
|
+
return res.text();
|
50
|
+
}),
|
51
|
+
walletProviderBaseUrl
|
52
|
+
);
|
53
|
+
};
|
@@ -13,10 +13,11 @@ export type EvaluateIssuerTrust = (
|
|
13
13
|
}>;
|
14
14
|
|
15
15
|
/**
|
16
|
+
* WARNING: This function must be called after {@link startFlow}. The next function to be called is {@link startUserAuthorization}.
|
16
17
|
* The Issuer trust evaluation phase.
|
17
18
|
* Fetch the Issuer's configuration and verify trust.
|
18
19
|
*
|
19
|
-
* @param issuerUrl The base url of the Issuer
|
20
|
+
* @param issuerUrl The base url of the Issuer returned by {@link startFlow}
|
20
21
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
21
22
|
* @returns The Issuer's configuration
|
22
23
|
*/
|