@pagopa/io-react-native-wallet 0.7.4 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +49 -31
- package/lib/commonjs/credential/index.js +13 -0
- package/lib/commonjs/credential/index.js.map +1 -0
- package/lib/commonjs/credential/issuance/01-start-flow.js +2 -0
- package/lib/commonjs/credential/issuance/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +26 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +119 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -0
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +6 -0
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -0
- package/lib/commonjs/credential/issuance/05-authorize-access.js +63 -0
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -0
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +128 -0
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -0
- package/lib/commonjs/credential/issuance/07-confirm-credential.js +6 -0
- package/lib/commonjs/credential/issuance/07-confirm-credential.js.map +1 -0
- package/lib/commonjs/credential/issuance/const.js +9 -0
- package/lib/commonjs/credential/issuance/const.js.map +1 -0
- package/lib/commonjs/credential/issuance/index.js +34 -0
- package/lib/commonjs/credential/issuance/index.js.map +1 -0
- package/lib/commonjs/credential/presentation/01-start-flow.js +55 -0
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +32 -0
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -0
- package/lib/commonjs/credential/presentation/03-get-request-object.js +68 -0
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -0
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js +139 -0
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +1 -0
- package/lib/commonjs/credential/presentation/index.js +34 -0
- package/lib/commonjs/credential/presentation/index.js.map +1 -0
- package/lib/commonjs/{rp → credential/presentation}/types.js +17 -34
- package/lib/commonjs/credential/presentation/types.js.map +1 -0
- package/lib/commonjs/index.js +10 -61
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/index.js +1 -3
- package/lib/commonjs/pid/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +1 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +1 -1
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/trust/chain.js +32 -4
- package/lib/commonjs/trust/chain.js.map +1 -1
- package/lib/commonjs/trust/index.js +105 -20
- package/lib/commonjs/trust/index.js.map +1 -1
- package/lib/commonjs/trust/types.js +54 -35
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/crypto.js +5 -18
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/misc.js +23 -0
- package/lib/commonjs/utils/misc.js.map +1 -0
- package/lib/commonjs/utils/par.js +86 -0
- package/lib/commonjs/utils/par.js.map +1 -0
- package/lib/module/credential/index.js +4 -0
- package/lib/module/credential/index.js.map +1 -0
- package/lib/module/credential/issuance/01-start-flow.js +2 -0
- package/lib/module/credential/issuance/01-start-flow.js.map +1 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +19 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +109 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -0
- package/lib/module/credential/issuance/04-complete-user-authorization.js +2 -0
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -0
- package/lib/module/credential/issuance/05-authorize-access.js +55 -0
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -0
- package/lib/module/credential/issuance/06-obtain-credential.js +117 -0
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -0
- package/lib/module/credential/issuance/07-confirm-credential.js +2 -0
- package/lib/module/credential/issuance/07-confirm-credential.js.map +1 -0
- package/lib/module/credential/issuance/const.js +2 -0
- package/lib/module/credential/issuance/const.js.map +1 -0
- package/lib/module/credential/issuance/index.js +6 -0
- package/lib/module/credential/issuance/index.js.map +1 -0
- package/lib/module/credential/presentation/01-start-flow.js +46 -0
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -0
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +25 -0
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -0
- package/lib/module/credential/presentation/03-get-request-object.js +60 -0
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -0
- package/lib/module/credential/presentation/04-send-authorization-response.js +128 -0
- package/lib/module/credential/presentation/04-send-authorization-response.js.map +1 -0
- package/lib/module/credential/presentation/index.js +6 -0
- package/lib/module/credential/presentation/index.js.map +1 -0
- package/lib/module/credential/presentation/types.js +21 -0
- package/lib/module/credential/presentation/types.js.map +1 -0
- package/lib/module/index.js +4 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/index.js +1 -2
- package/lib/module/pid/index.js.map +1 -1
- package/lib/module/sd-jwt/index.js +1 -1
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +1 -1
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/chain.js +30 -3
- package/lib/module/trust/chain.js.map +1 -1
- package/lib/module/trust/index.js +99 -16
- package/lib/module/trust/index.js.map +1 -1
- package/lib/module/trust/types.js +50 -31
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/crypto.js +2 -15
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/misc.js +17 -0
- package/lib/module/utils/misc.js.map +1 -0
- package/lib/module/utils/par.js +74 -0
- package/lib/module/utils/par.js.map +1 -0
- package/lib/typescript/credential/index.d.ts +4 -0
- package/lib/typescript/credential/index.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +11 -0
- package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +18 -0
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +31 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +16 -0
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +26 -0
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +32 -0
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/07-confirm-credential.d.ts +11 -0
- package/lib/typescript/credential/issuance/07-confirm-credential.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/const.d.ts +2 -0
- package/lib/typescript/credential/issuance/const.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/index.d.ts +10 -0
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +20 -0
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +18 -0
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +25 -0
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts +34 -0
- package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/index.d.ts +7 -0
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/types.d.ts +49 -0
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +4 -5
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/index.d.ts +1 -2
- package/lib/typescript/pid/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +2 -2
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +5 -5
- package/lib/typescript/trust/chain.d.ts +12 -3
- package/lib/typescript/trust/chain.d.ts.map +1 -1
- package/lib/typescript/trust/index.d.ts +198 -24
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +1299 -623
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/crypto.d.ts +1 -1
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/dpop.d.ts +2 -2
- package/lib/typescript/utils/misc.d.ts +8 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -0
- package/lib/typescript/utils/par.d.ts +68 -0
- package/lib/typescript/utils/par.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/credential/index.ts +4 -0
- package/src/credential/issuance/01-start-flow.ts +10 -0
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +31 -0
- package/src/credential/issuance/03-start-user-authorization.ts +138 -0
- package/src/credential/issuance/04-complete-user-authorization.ts +17 -0
- package/src/credential/issuance/05-authorize-access.ts +92 -0
- package/src/credential/issuance/06-obtain-credential.ts +179 -0
- package/src/credential/issuance/07-confirm-credential.ts +14 -0
- package/src/credential/issuance/const.ts +2 -0
- package/src/credential/issuance/index.ts +32 -0
- package/src/credential/presentation/01-start-flow.ts +51 -0
- package/src/credential/presentation/02-evaluate-rp-trust.ts +33 -0
- package/src/credential/presentation/03-get-request-object.ts +85 -0
- package/src/credential/presentation/04-send-authorization-response.ts +168 -0
- package/src/credential/presentation/index.ts +26 -0
- package/src/credential/presentation/types.ts +27 -0
- package/src/index.ts +7 -28
- package/src/pid/index.ts +1 -2
- package/src/sd-jwt/index.ts +2 -2
- package/src/sd-jwt/types.ts +1 -1
- package/src/trust/chain.ts +45 -3
- package/src/trust/index.ts +136 -19
- package/src/trust/types.ts +57 -35
- package/src/utils/crypto.ts +2 -20
- package/src/utils/misc.ts +23 -0
- package/src/utils/par.ts +103 -0
- package/lib/commonjs/pid/issuing.js +0 -276
- package/lib/commonjs/pid/issuing.js.map +0 -1
- package/lib/commonjs/rp/__test__/index.test.js +0 -172
- package/lib/commonjs/rp/__test__/index.test.js.map +0 -1
- package/lib/commonjs/rp/index.js +0 -239
- package/lib/commonjs/rp/index.js.map +0 -1
- package/lib/commonjs/rp/types.js.map +0 -1
- package/lib/module/pid/issuing.js +0 -266
- package/lib/module/pid/issuing.js.map +0 -1
- package/lib/module/rp/__test__/index.test.js +0 -168
- package/lib/module/rp/__test__/index.test.js.map +0 -1
- package/lib/module/rp/index.js +0 -228
- package/lib/module/rp/index.js.map +0 -1
- package/lib/module/rp/types.js +0 -36
- package/lib/module/rp/types.js.map +0 -1
- package/lib/typescript/pid/issuing.d.ts +0 -57
- package/lib/typescript/pid/issuing.d.ts.map +0 -1
- package/lib/typescript/rp/__test__/index.test.d.ts +0 -2
- package/lib/typescript/rp/__test__/index.test.d.ts.map +0 -1
- package/lib/typescript/rp/index.d.ts +0 -43
- package/lib/typescript/rp/index.d.ts.map +0 -1
- package/lib/typescript/rp/types.d.ts +0 -122
- package/lib/typescript/rp/types.d.ts.map +0 -1
- package/src/pid/issuing.ts +0 -405
- package/src/rp/__test__/index.test.ts +0 -250
- package/src/rp/index.ts +0 -287
- package/src/rp/types.ts +0 -42
@@ -1,250 +0,0 @@
|
|
1
|
-
import { RelyingPartyEntityConfiguration } from "../../trust/types";
|
2
|
-
import * as RelyingPartySolution from "..";
|
3
|
-
import { AuthRequestDecodeError } from "../../utils/errors";
|
4
|
-
|
5
|
-
describe("decodeAuthRequestQR", () => {
|
6
|
-
it("should return authentication request URL", async () => {
|
7
|
-
const qrcode =
|
8
|
-
"ZXVkaXc6Ly9hdXRob3JpemU/Y2xpZW50X2lkPWh0dHBzOi8vdmVyaWZpZXIuZXhhbXBsZS5vcmcmcmVxdWVzdF91cmk9aHR0cHM6Ly92ZXJpZmllci5leGFtcGxlLm9yZy9yZXF1ZXN0X3VyaQ==";
|
9
|
-
const result = RelyingPartySolution.decodeAuthRequestQR(qrcode);
|
10
|
-
expect(result.requestURI).toEqual(
|
11
|
-
"https://verifier.example.org/request_uri"
|
12
|
-
);
|
13
|
-
});
|
14
|
-
it("should throw exception with invalid QR", async () => {
|
15
|
-
const qrcode = "aHR0cDovL2dvb2dsZS5pdA==";
|
16
|
-
expect(() => RelyingPartySolution.decodeAuthRequestQR(qrcode)).toThrowError(
|
17
|
-
AuthRequestDecodeError
|
18
|
-
);
|
19
|
-
});
|
20
|
-
});
|
21
|
-
|
22
|
-
describe("RpEntityConfiguration", () => {
|
23
|
-
it("should parse a valid conf", async () => {
|
24
|
-
const pp = {
|
25
|
-
header: {
|
26
|
-
alg: "RS256",
|
27
|
-
kid: "9Cquk0X-fNPSdePQIgQcQZtD6J0IjIRrFigW2PPK_-w",
|
28
|
-
typ: "entity-statement+jwt",
|
29
|
-
},
|
30
|
-
payload: {
|
31
|
-
exp: 1692625747,
|
32
|
-
iat: 1692625387,
|
33
|
-
iss: "https://demo.proxy.eudi.wallet.developers.italia.it/OpenID4VP",
|
34
|
-
sub: "https://demo.proxy.eudi.wallet.developers.italia.it/OpenID4VP",
|
35
|
-
jwks: {
|
36
|
-
keys: [
|
37
|
-
{
|
38
|
-
kty: "RSA",
|
39
|
-
kid: "9Cquk0X-fNPSdePQIgQcQZtD6J0IjIRrFigW2PPK_-w",
|
40
|
-
e: "AQAB",
|
41
|
-
n: "utqtxbs-jnK0cPsV7aRkkZKA9t4S-WSZa3nCZtYIKDpgLnR_qcpeF0diJZvKOqXmj2cXaKFUE-8uHKAHo7BL7T-Rj2x3vGESh7SG1pE0thDGlXj4yNsg0qNvCXtk703L2H3i1UXwx6nq1uFxD2EcOE4a6qDYBI16Zl71TUZktJwmOejoHl16CPWqDLGo9GUSk_MmHOV20m4wXWkB4qbvpWVY8H6b2a0rB1B1YPOs5ZLYarSYZgjDEg6DMtZ4NgiwZ-4N1aaLwyO-GLwt9Vf-NBKwoxeRyD3zWE2FXRFBbhKGksMrCGnFDsNl5JTlPjaM3kYyImE941ggcuc495m-Fw",
|
42
|
-
},
|
43
|
-
],
|
44
|
-
},
|
45
|
-
metadata: {
|
46
|
-
federation_entity: {
|
47
|
-
organization_name: "wallet-provider",
|
48
|
-
homepage_uri: "https://wallet-provider.example",
|
49
|
-
policy_uri: "https://wallet-provider.example",
|
50
|
-
logo_uri: "https://wallet-provider.example",
|
51
|
-
contacts: ["https://wallet-provider.example"],
|
52
|
-
},
|
53
|
-
wallet_relying_party: {
|
54
|
-
application_type: "web",
|
55
|
-
authorization_encrypted_response_alg: [
|
56
|
-
"RSA-OAEP",
|
57
|
-
"RSA-OAEP-256",
|
58
|
-
"ECDH-ES",
|
59
|
-
"ECDH-ES+A128KW",
|
60
|
-
"ECDH-ES+A192KW",
|
61
|
-
"ECDH-ES+A256KW",
|
62
|
-
],
|
63
|
-
authorization_encrypted_response_enc: [
|
64
|
-
"A128CBC-HS256",
|
65
|
-
"A192CBC-HS384",
|
66
|
-
"A256CBC-HS512",
|
67
|
-
"A128GCM",
|
68
|
-
"A192GCM",
|
69
|
-
"A256GCM",
|
70
|
-
],
|
71
|
-
authorization_signed_response_alg: [
|
72
|
-
"RS256",
|
73
|
-
"RS384",
|
74
|
-
"RS512",
|
75
|
-
"ES256",
|
76
|
-
"ES384",
|
77
|
-
"ES512",
|
78
|
-
],
|
79
|
-
client_id:
|
80
|
-
"https://demo.proxy.eudi.wallet.developers.italia.it/OpenID4VP",
|
81
|
-
client_name: "Name of an example organization",
|
82
|
-
contacts: ["ops@verifier.example.org"],
|
83
|
-
default_acr_values: [
|
84
|
-
"https://www.spid.gov.it/SpidL2",
|
85
|
-
"https://www.spid.gov.it/SpidL3",
|
86
|
-
],
|
87
|
-
default_max_age: 1111,
|
88
|
-
id_token_encrypted_response_alg: [
|
89
|
-
"RSA-OAEP",
|
90
|
-
"RSA-OAEP-256",
|
91
|
-
"ECDH-ES",
|
92
|
-
"ECDH-ES+A128KW",
|
93
|
-
"ECDH-ES+A192KW",
|
94
|
-
"ECDH-ES+A256KW",
|
95
|
-
],
|
96
|
-
id_token_encrypted_response_enc: [
|
97
|
-
"A128CBC-HS256",
|
98
|
-
"A192CBC-HS384",
|
99
|
-
"A256CBC-HS512",
|
100
|
-
"A128GCM",
|
101
|
-
"A192GCM",
|
102
|
-
"A256GCM",
|
103
|
-
],
|
104
|
-
id_token_signed_response_alg: [
|
105
|
-
"RS256",
|
106
|
-
"RS384",
|
107
|
-
"RS512",
|
108
|
-
"ES256",
|
109
|
-
"ES384",
|
110
|
-
"ES512",
|
111
|
-
],
|
112
|
-
presentation_definitions: [
|
113
|
-
{
|
114
|
-
id: "pid-sd-jwt:unique_id+given_name+family_name",
|
115
|
-
input_descriptors: [
|
116
|
-
{
|
117
|
-
id: "pid-sd-jwt:unique_id+given_name+family_name",
|
118
|
-
format: {
|
119
|
-
constraints: {
|
120
|
-
fields: [
|
121
|
-
{
|
122
|
-
filter: {
|
123
|
-
const: "PersonIdentificationData",
|
124
|
-
type: "string",
|
125
|
-
},
|
126
|
-
path: ["$.sd-jwt.type"],
|
127
|
-
},
|
128
|
-
{
|
129
|
-
filter: {
|
130
|
-
type: "object",
|
131
|
-
},
|
132
|
-
path: ["$.sd-jwt.cnf"],
|
133
|
-
},
|
134
|
-
{
|
135
|
-
intent_to_retain: "true",
|
136
|
-
path: ["$.sd-jwt.family_name"],
|
137
|
-
},
|
138
|
-
{
|
139
|
-
intent_to_retain: "true",
|
140
|
-
path: ["$.sd-jwt.given_name"],
|
141
|
-
},
|
142
|
-
{
|
143
|
-
intent_to_retain: "true",
|
144
|
-
path: ["$.sd-jwt.unique_id"],
|
145
|
-
},
|
146
|
-
],
|
147
|
-
limit_disclosure: "required",
|
148
|
-
},
|
149
|
-
jwt: {
|
150
|
-
alg: ["EdDSA", "ES256"],
|
151
|
-
},
|
152
|
-
},
|
153
|
-
},
|
154
|
-
],
|
155
|
-
},
|
156
|
-
{
|
157
|
-
id: "mDL-sample-req",
|
158
|
-
input_descriptors: [
|
159
|
-
{
|
160
|
-
format: {
|
161
|
-
constraints: {
|
162
|
-
fields: [
|
163
|
-
{
|
164
|
-
filter: {
|
165
|
-
const: "org.iso.18013.5.1.mDL",
|
166
|
-
type: "string",
|
167
|
-
},
|
168
|
-
path: ["$.mdoc.doctype"],
|
169
|
-
},
|
170
|
-
{
|
171
|
-
filter: {
|
172
|
-
const: "org.iso.18013.5.1",
|
173
|
-
type: "string",
|
174
|
-
},
|
175
|
-
path: ["$.mdoc.namespace"],
|
176
|
-
},
|
177
|
-
{
|
178
|
-
intent_to_retain: "false",
|
179
|
-
path: ["$.mdoc.family_name"],
|
180
|
-
},
|
181
|
-
{
|
182
|
-
intent_to_retain: "false",
|
183
|
-
path: ["$.mdoc.portrait"],
|
184
|
-
},
|
185
|
-
{
|
186
|
-
intent_to_retain: "false",
|
187
|
-
path: ["$.mdoc.driving_privileges"],
|
188
|
-
},
|
189
|
-
],
|
190
|
-
limit_disclosure: "required",
|
191
|
-
},
|
192
|
-
mso_mdoc: {
|
193
|
-
alg: ["EdDSA", "ES256"],
|
194
|
-
},
|
195
|
-
},
|
196
|
-
id: "mDL",
|
197
|
-
},
|
198
|
-
],
|
199
|
-
},
|
200
|
-
],
|
201
|
-
redirect_uris: [
|
202
|
-
"https://demo.proxy.eudi.wallet.developers.italia.it/OpenID4VP/redirect-uri",
|
203
|
-
],
|
204
|
-
request_uris: [
|
205
|
-
"https://demo.proxy.eudi.wallet.developers.italia.it/OpenID4VP/request-uri",
|
206
|
-
],
|
207
|
-
require_auth_time: true,
|
208
|
-
subject_type: "pairwise",
|
209
|
-
vp_formats: {
|
210
|
-
jwt_vp_json: {
|
211
|
-
alg: ["EdDSA", "ES256K"],
|
212
|
-
},
|
213
|
-
},
|
214
|
-
jwks: {
|
215
|
-
keys: [
|
216
|
-
{
|
217
|
-
crv: "P-256",
|
218
|
-
d: "KzQBowMMoPmSZe7G8QsdEWc1IvR2nsgE8qTOYmMcLtc",
|
219
|
-
kid: "dDwPWXz5sCtczj7CJbqgPGJ2qQ83gZ9Sfs-tJyULi6s",
|
220
|
-
use: "sig",
|
221
|
-
kty: "EC",
|
222
|
-
x: "TSO-KOqdnUj5SUuasdlRB2VVFSqtJOxuR5GftUTuBdk",
|
223
|
-
y: "ByWgQt1wGBSnF56jQqLdoO1xKUynMY-BHIDB3eXlR7",
|
224
|
-
},
|
225
|
-
{
|
226
|
-
kty: "RSA",
|
227
|
-
d: "QUZsh1NqvpueootsdSjFQz-BUvxwd3Qnzm5qNb-WeOsvt3rWMEv0Q8CZrla2tndHTJhwioo1U4NuQey7znijhZ177bUwPPxSW1r68dEnL2U74nKwwoYeeMdEXnUfZSPxzs7nY6b7vtyCoA-AjiVYFOlgKNAItspv1HxeyGCLhLYhKvS_YoTdAeLuegETU5D6K1xGQIuw0nS13Icjz79Y8jC10TX4FdZwdX-NmuIEDP5-s95V9DMENtVqJAVE3L-wO-NdDilyjyOmAbntgsCzYVGH9U3W_djh4t3qVFCv3r0S-DA2FD3THvlrFi655L0QHR3gu_Fbj3b9Ybtajpue_Q",
|
228
|
-
e: "AQAB",
|
229
|
-
use: "enc",
|
230
|
-
kid: "9Cquk0X-fNPSdePQIgQcQZtD6J0IjIRrFigW2PPK_-w",
|
231
|
-
n: "utqtxbs-jnK0cPsV7aRkkZKA9t4S-WSZa3nCZtYIKDpgLnR_qcpeF0diJZvKOqXmj2cXaKFUE-8uHKAHo7BL7T-Rj2x3vGESh7SG1pE0thDGlXj4yNsg0qNvCXtk703L2H3i1UXwx6nq1uFxD2EcOE4a6qDYBI16Zl71TUZktJwmOejoHl16CPWqDLGo9GUSk_MmHOV20m4wXWkB4qbvpWVY8H6b2a0rB1B1YPOs5ZLYarSYZgjDEg6DMtZ4NgiwZ-4N1aaLwyO-GLwt9Vf-NBKwoxeRyD3zWE2FXRFBbhKGksMrCGnFDsNl5JTlPjaM3kYyImE941ggcuc495m-Fw",
|
232
|
-
p: "2zmGXIMCEHPphw778YjVTar1eycih6fFSJ4I4bl1iq167GqO0PjlOx6CZ1-OdBTVU7HfrYRiUK_BnGRdPDn-DQghwwkB79ZdHWL14wXnpB5y-boHz_LxvjsEqXtuQYcIkidOGaMG68XNT1nM4F9a8UKFr5hHYT5_UIQSwsxlRQ0",
|
233
|
-
q: "2jMFt2iFrdaYabdXuB4QMboVjPvbLA-IVb6_0hSG_-EueGBvgcBxdFGIZaG6kqHqlB7qMsSzdptU0vn6IgmCZnX-Hlt6c5X7JB_q91PZMLTO01pbZ2Bk58GloalCHnw_mjPh0YPviH5jGoWM5RHyl_HDDMI-UeLkzP7ImxGizrM",
|
234
|
-
},
|
235
|
-
],
|
236
|
-
},
|
237
|
-
},
|
238
|
-
},
|
239
|
-
authority_hints: [
|
240
|
-
"https://demo.federation.eudi.wallet.developers.italia.it",
|
241
|
-
],
|
242
|
-
},
|
243
|
-
};
|
244
|
-
const result = RelyingPartyEntityConfiguration.safeParse(pp);
|
245
|
-
if (result.success === false) {
|
246
|
-
throw result.error;
|
247
|
-
}
|
248
|
-
expect(result.success).toBe(true);
|
249
|
-
});
|
250
|
-
});
|
package/src/rp/index.ts
DELETED
@@ -1,287 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
AuthRequestDecodeError,
|
3
|
-
IoWalletError,
|
4
|
-
NoSuitableKeysFoundInEntityConfiguration,
|
5
|
-
} from "../utils/errors";
|
6
|
-
import {
|
7
|
-
decode as decodeJwt,
|
8
|
-
decodeBase64,
|
9
|
-
sha256ToBase64,
|
10
|
-
SignJWT,
|
11
|
-
EncryptJwe,
|
12
|
-
verify,
|
13
|
-
type CryptoContext,
|
14
|
-
} from "@pagopa/io-react-native-jwt";
|
15
|
-
import { QRCodePayload, RequestObject, type Presentation } from "./types";
|
16
|
-
|
17
|
-
import uuid from "react-native-uuid";
|
18
|
-
import type { JWK } from "@pagopa/io-react-native-jwt/lib/typescript/types";
|
19
|
-
import { disclose } from "../sd-jwt";
|
20
|
-
import { createDPopToken } from "../utils/dpop";
|
21
|
-
import { RelyingPartyEntityConfiguration } from "../trust/types";
|
22
|
-
import * as WalletInstanceAttestation from "../wallet-instance-attestation";
|
23
|
-
|
24
|
-
/**
|
25
|
-
* Select a RSA public key from those provided by the RP to encrypt.
|
26
|
-
*
|
27
|
-
* @param entity The RP entity configuration
|
28
|
-
* @returns A suitable public key with its compatible encryption algorithm
|
29
|
-
* @throws {NoSuitableKeysFoundInEntityConfiguration} If entity do not contain any public key suitable for encrypting
|
30
|
-
*/
|
31
|
-
const chooseRSAPublicKeyToEncrypt = (
|
32
|
-
entity: RelyingPartyEntityConfiguration
|
33
|
-
): JWK => {
|
34
|
-
const [usingRsa256] =
|
35
|
-
entity.payload.metadata.wallet_relying_party.jwks.keys.filter(
|
36
|
-
(jwk) => jwk.use === "enc" && jwk.kty === "RSA"
|
37
|
-
);
|
38
|
-
|
39
|
-
if (usingRsa256) {
|
40
|
-
return usingRsa256;
|
41
|
-
}
|
42
|
-
|
43
|
-
// No suitable key has been found
|
44
|
-
throw new NoSuitableKeysFoundInEntityConfiguration(
|
45
|
-
"Encrypt with RP public key"
|
46
|
-
);
|
47
|
-
};
|
48
|
-
|
49
|
-
/**
|
50
|
-
* Decode a QR code content to an authentication request url.
|
51
|
-
* @function
|
52
|
-
* @param qrcode QR code content
|
53
|
-
*
|
54
|
-
* @returns The authentication request url
|
55
|
-
*
|
56
|
-
*/
|
57
|
-
export const decodeAuthRequestQR = (qrcode: string): QRCodePayload => {
|
58
|
-
const decoded = decodeBase64(qrcode);
|
59
|
-
const decodedUrl = new URL(decoded);
|
60
|
-
const protocol = decodedUrl.protocol;
|
61
|
-
const resource = decodedUrl.hostname;
|
62
|
-
const requestURI = decodedUrl.searchParams.get("request_uri");
|
63
|
-
const clientId = decodedUrl.searchParams.get("client_id");
|
64
|
-
|
65
|
-
const result = QRCodePayload.safeParse({
|
66
|
-
protocol,
|
67
|
-
resource,
|
68
|
-
requestURI,
|
69
|
-
clientId,
|
70
|
-
});
|
71
|
-
|
72
|
-
if (result.success) {
|
73
|
-
return result.data;
|
74
|
-
} else {
|
75
|
-
throw new AuthRequestDecodeError(result.error.message, `${decodedUrl}`);
|
76
|
-
}
|
77
|
-
};
|
78
|
-
|
79
|
-
export type RequestObjectConf = {
|
80
|
-
requestObject: RequestObject;
|
81
|
-
rpEntityConfiguration: RelyingPartyEntityConfiguration;
|
82
|
-
walletInstanceAttestation: string;
|
83
|
-
};
|
84
|
-
|
85
|
-
/**
|
86
|
-
* Obtain the Request Object for RP authentication
|
87
|
-
* @see https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html
|
88
|
-
*/
|
89
|
-
export const getRequestObject =
|
90
|
-
({
|
91
|
-
wiaCryptoContext,
|
92
|
-
appFetch = fetch,
|
93
|
-
}: {
|
94
|
-
wiaCryptoContext: CryptoContext;
|
95
|
-
appFetch?: GlobalFetch["fetch"];
|
96
|
-
}) =>
|
97
|
-
async (
|
98
|
-
walletInstanceAttestation: string,
|
99
|
-
requestUri: string,
|
100
|
-
rpEntityConfiguration: RelyingPartyEntityConfiguration
|
101
|
-
): Promise<RequestObjectConf> => {
|
102
|
-
const signedWalletInstanceDPoP = await createDPopToken(
|
103
|
-
{
|
104
|
-
jti: `${uuid.v4()}`,
|
105
|
-
htm: "GET",
|
106
|
-
htu: requestUri,
|
107
|
-
ath: await sha256ToBase64(walletInstanceAttestation),
|
108
|
-
},
|
109
|
-
wiaCryptoContext
|
110
|
-
);
|
111
|
-
|
112
|
-
const response = await appFetch(requestUri, {
|
113
|
-
method: "GET",
|
114
|
-
headers: {
|
115
|
-
Authorization: `DPoP ${walletInstanceAttestation}`,
|
116
|
-
DPoP: signedWalletInstanceDPoP,
|
117
|
-
},
|
118
|
-
});
|
119
|
-
|
120
|
-
if (response.status === 200) {
|
121
|
-
const responseJson = await response.json();
|
122
|
-
const responseEncodedJwt = responseJson.response;
|
123
|
-
|
124
|
-
const responseJwt = decodeJwt(responseEncodedJwt);
|
125
|
-
|
126
|
-
// verify token signature according to RP's entity configuration
|
127
|
-
// to ensure the request object is authentic
|
128
|
-
{
|
129
|
-
const pubKey =
|
130
|
-
rpEntityConfiguration.payload.metadata.wallet_relying_party.jwks.keys.find(
|
131
|
-
({ kid }) => kid === responseJwt.protectedHeader.kid
|
132
|
-
);
|
133
|
-
if (!pubKey) {
|
134
|
-
throw new NoSuitableKeysFoundInEntityConfiguration(
|
135
|
-
"Request Object signature verification"
|
136
|
-
);
|
137
|
-
}
|
138
|
-
await verify(responseEncodedJwt, pubKey);
|
139
|
-
}
|
140
|
-
|
141
|
-
// parse request object it has the expected shape by specification
|
142
|
-
const requestObject = RequestObject.parse({
|
143
|
-
header: responseJwt.protectedHeader,
|
144
|
-
payload: responseJwt.payload,
|
145
|
-
});
|
146
|
-
|
147
|
-
return {
|
148
|
-
requestObject,
|
149
|
-
rpEntityConfiguration,
|
150
|
-
walletInstanceAttestation,
|
151
|
-
};
|
152
|
-
}
|
153
|
-
|
154
|
-
throw new IoWalletError(
|
155
|
-
`Unable to obtain Request Object. Response code: ${response.status}
|
156
|
-
${await response.text()}`
|
157
|
-
);
|
158
|
-
};
|
159
|
-
|
160
|
-
/**
|
161
|
-
* Prepare the Verified Presentation token for a received request object in the context of an authorization request flow.
|
162
|
-
* The presentation is prepared by disclosing data from provided credentials, according to requested claims
|
163
|
-
* Each Verified Credential come along with the claims the user accepts to disclose from it.
|
164
|
-
*
|
165
|
-
* @todo accept more than a Verified Credential
|
166
|
-
*/
|
167
|
-
const prepareVpToken =
|
168
|
-
({ pidCryptoContext }: { pidCryptoContext: CryptoContext }) =>
|
169
|
-
async (
|
170
|
-
{ requestObject, walletInstanceAttestation }: RequestObjectConf,
|
171
|
-
[vc, claims]: Presentation // TODO: [SIW-353] support multiple presentations,
|
172
|
-
): Promise<{
|
173
|
-
vp_token: string;
|
174
|
-
presentation_submission: Record<string, unknown>;
|
175
|
-
}> => {
|
176
|
-
// this throws if vc cannot satisfy all the requested claims
|
177
|
-
const { token: vp, paths } = await disclose(vc, claims);
|
178
|
-
|
179
|
-
// obtain issuer from Wallet Instance
|
180
|
-
const {
|
181
|
-
payload: { iss },
|
182
|
-
} = WalletInstanceAttestation.decode(walletInstanceAttestation);
|
183
|
-
|
184
|
-
const pidKid = await pidCryptoContext.getPublicKey().then((_) => _.kid);
|
185
|
-
|
186
|
-
// TODO: [SIW-359] check all requeste claims of the requestedObj are satisfied
|
187
|
-
const vp_token = await new SignJWT(pidCryptoContext)
|
188
|
-
.setProtectedHeader({
|
189
|
-
typ: "JWT",
|
190
|
-
kid: pidKid,
|
191
|
-
})
|
192
|
-
.setPayload({
|
193
|
-
vp: vp,
|
194
|
-
jti: `${uuid.v4()}`,
|
195
|
-
iss,
|
196
|
-
nonce: requestObject.payload.nonce,
|
197
|
-
})
|
198
|
-
.setAudience(requestObject.payload.response_uri)
|
199
|
-
.setIssuedAt()
|
200
|
-
.setExpirationTime("1h")
|
201
|
-
.sign();
|
202
|
-
|
203
|
-
const vc_scope = requestObject.payload.scope;
|
204
|
-
const presentation_submission = {
|
205
|
-
definition_id: `${uuid.v4()}`,
|
206
|
-
id: `${uuid.v4()}`,
|
207
|
-
descriptor_map: paths.map((p) => ({
|
208
|
-
id: vc_scope,
|
209
|
-
path: `$.vp_token.${p.path}`,
|
210
|
-
format: "vc+sd-jwt",
|
211
|
-
})),
|
212
|
-
};
|
213
|
-
|
214
|
-
return { vp_token, presentation_submission };
|
215
|
-
};
|
216
|
-
|
217
|
-
/**
|
218
|
-
* Compose and send an Authorization Response in the context of an authorization request flow.
|
219
|
-
*
|
220
|
-
* @todo MUST add presentation_submission
|
221
|
-
*
|
222
|
-
*/
|
223
|
-
export const sendAuthorizationResponse =
|
224
|
-
({
|
225
|
-
pidCryptoContext,
|
226
|
-
appFetch = fetch,
|
227
|
-
}: {
|
228
|
-
pidCryptoContext: CryptoContext;
|
229
|
-
appFetch?: GlobalFetch["fetch"];
|
230
|
-
}) =>
|
231
|
-
async (
|
232
|
-
{
|
233
|
-
requestObject,
|
234
|
-
rpEntityConfiguration,
|
235
|
-
walletInstanceAttestation,
|
236
|
-
}: RequestObjectConf,
|
237
|
-
presentation: Presentation // TODO: [SIW-353] support multiple presentations,
|
238
|
-
): Promise<string> => {
|
239
|
-
// the request is an unsigned jws without iss, aud, exp
|
240
|
-
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-respon
|
241
|
-
const jwk = chooseRSAPublicKeyToEncrypt(rpEntityConfiguration);
|
242
|
-
|
243
|
-
const { vp_token, presentation_submission } = await prepareVpToken({
|
244
|
-
pidCryptoContext,
|
245
|
-
})(
|
246
|
-
{
|
247
|
-
requestObject,
|
248
|
-
rpEntityConfiguration,
|
249
|
-
walletInstanceAttestation,
|
250
|
-
},
|
251
|
-
presentation
|
252
|
-
);
|
253
|
-
|
254
|
-
const authzResponsePayload = JSON.stringify({
|
255
|
-
state: requestObject.payload.state,
|
256
|
-
presentation_submission,
|
257
|
-
nonce: requestObject.payload.nonce,
|
258
|
-
vp_token,
|
259
|
-
});
|
260
|
-
|
261
|
-
const encrypted = await new EncryptJwe(authzResponsePayload, {
|
262
|
-
alg: "RSA-OAEP-256",
|
263
|
-
enc: "A256CBC-HS512",
|
264
|
-
kid: jwk.kid,
|
265
|
-
}).encrypt(jwk);
|
266
|
-
|
267
|
-
const formBody = new URLSearchParams({ response: encrypted });
|
268
|
-
const body = formBody.toString();
|
269
|
-
|
270
|
-
const response = await appFetch(requestObject.payload.response_uri, {
|
271
|
-
method: "POST",
|
272
|
-
headers: {
|
273
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
274
|
-
},
|
275
|
-
body,
|
276
|
-
});
|
277
|
-
|
278
|
-
if (response.status === 200) {
|
279
|
-
return await response.json();
|
280
|
-
}
|
281
|
-
|
282
|
-
throw new IoWalletError(
|
283
|
-
`Unable to send Authorization Response. Response: ${await response.text()} with code: ${
|
284
|
-
response.status
|
285
|
-
}`
|
286
|
-
);
|
287
|
-
};
|
package/src/rp/types.ts
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
import { UnixTime } from "../sd-jwt/types";
|
2
|
-
import * as z from "zod";
|
3
|
-
|
4
|
-
export type RequestObject = z.infer<typeof RequestObject>;
|
5
|
-
export const RequestObject = z.object({
|
6
|
-
header: z.object({
|
7
|
-
// FIXME: SIW-421 type field must be either required or omitted, optional isn't useful
|
8
|
-
typ: z.literal("JWT").optional(),
|
9
|
-
alg: z.string(),
|
10
|
-
kid: z.string(),
|
11
|
-
trust_chain: z.array(z.string()),
|
12
|
-
}),
|
13
|
-
payload: z.object({
|
14
|
-
iss: z.string(),
|
15
|
-
iat: UnixTime,
|
16
|
-
exp: UnixTime,
|
17
|
-
state: z.string(),
|
18
|
-
nonce: z.string(),
|
19
|
-
response_uri: z.string(),
|
20
|
-
response_type: z.literal("vp_token"),
|
21
|
-
response_mode: z.literal("direct_post.jwt"),
|
22
|
-
client_id: z.string(),
|
23
|
-
client_id_scheme: z.literal("entity_id"),
|
24
|
-
scope: z.string(),
|
25
|
-
}),
|
26
|
-
});
|
27
|
-
|
28
|
-
export type QRCodePayload = z.infer<typeof QRCodePayload>;
|
29
|
-
export const QRCodePayload = z.object({
|
30
|
-
protocol: z.string(),
|
31
|
-
resource: z.string(), // TODO: refine to known paths using literals
|
32
|
-
clientId: z.string(),
|
33
|
-
requestURI: z.string(),
|
34
|
-
});
|
35
|
-
|
36
|
-
/**
|
37
|
-
* A pair that associate a tokenized Verified Credential with the claims presented or requested to present.
|
38
|
-
*/
|
39
|
-
export type Presentation = [
|
40
|
-
/* verified credential token */ string,
|
41
|
-
/* claims */ string[]
|
42
|
-
];
|