@pagopa/io-wallet-oid4vci 0.5.0 → 0.6.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 +162 -0
- package/dist/index.d.mts +97 -2
- package/dist/index.d.ts +97 -2
- package/dist/index.js +127 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +115 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -63,10 +63,172 @@ const attestationJwt = await walletProvider.createItWalletAttestationJwt(attesta
|
|
|
63
63
|
|
|
64
64
|
The wallet attestation JWT can then be used in the OID4VCI protocol flow to prove the wallet's identity and key possession.
|
|
65
65
|
|
|
66
|
+
### `completeAuthorization`
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { CompleteAuthorizationOptions, completeAuthorization } from "@pagopa/io-wallet-oid4ci"
|
|
70
|
+
|
|
71
|
+
//Obtain a response uri from an OID4VP authorization flow
|
|
72
|
+
const response_uri = "https://response.example.com"
|
|
73
|
+
|
|
74
|
+
//Build the parameters
|
|
75
|
+
const options : CompleteAuthorizationOptions = {
|
|
76
|
+
fetch,
|
|
77
|
+
response_uri
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Result is in the following form:
|
|
82
|
+
* {
|
|
83
|
+
* jwt : "ey...",
|
|
84
|
+
* decodedJwt : {
|
|
85
|
+
* header : {
|
|
86
|
+
* alg : "ES256",
|
|
87
|
+
* ...
|
|
88
|
+
* },
|
|
89
|
+
* payload : {
|
|
90
|
+
* iss : "https://iss.example.com",
|
|
91
|
+
* state : "EXAMPLE_STATE",
|
|
92
|
+
* code : "ACCESS_CODE"
|
|
93
|
+
* },
|
|
94
|
+
* signature : "..."
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
*/
|
|
98
|
+
const result = await completeAuthorization(options)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `verifyAuthorizationResponse`
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import {verifyAuthorizationResponse, VerifyAuthorizationResponseOptions} from "@pagopa/io-wallet-oid4vci"
|
|
105
|
+
|
|
106
|
+
// Obtain an authorizationResponse
|
|
107
|
+
const response = {
|
|
108
|
+
code : "TEST_CODE",
|
|
109
|
+
iss : "http://iss.example.com",
|
|
110
|
+
state : "TEST_STATE"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//Retrieve the expected issuer and state sent at the start of the authorization flow
|
|
114
|
+
const EXPECTED_ISS = "http://iss.example.com"
|
|
115
|
+
const EXPECTED_STATE = "TEST_STATE"
|
|
116
|
+
|
|
117
|
+
//Check if they are correct
|
|
118
|
+
verifyAuthorizationResponse({
|
|
119
|
+
authorizationResponse : response,
|
|
120
|
+
iss : EXPECTED_ISS,
|
|
121
|
+
state: EXPECTED_STATE
|
|
122
|
+
} satisfies VerifyAuthorizationResponseOptions)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### `verifyAuthorizationResponseFormPostJWT`
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import {verifyAuthorizationResponseFormPostJWT, VerifyAuthorizationResponseFormPostJWTOptions} from "@pagopa/io-wallet-oid4vci"
|
|
129
|
+
import { JwtSignerJwk } from "@pagopa/io-wallet-oauth2"
|
|
130
|
+
|
|
131
|
+
// Obtain a decoded jwt cotaining the authoization response...
|
|
132
|
+
const decodedJwt = {
|
|
133
|
+
header : {
|
|
134
|
+
alg : "ES256",
|
|
135
|
+
...
|
|
136
|
+
},
|
|
137
|
+
payload :{
|
|
138
|
+
code : "TEST_CODE",
|
|
139
|
+
iss : "http://iss.example.com",
|
|
140
|
+
state : "TEST_STATE"
|
|
141
|
+
},
|
|
142
|
+
signature : "..."
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//...and its compact form
|
|
146
|
+
const jwt = "ey..."
|
|
147
|
+
|
|
148
|
+
//Retrieve the signer's public key and build the corrsponing Signer object
|
|
149
|
+
const signer : JwtSignerJwk = {
|
|
150
|
+
mehtod: "jwk",
|
|
151
|
+
alg : "ES256",
|
|
152
|
+
publicJwk : {
|
|
153
|
+
kty : "EC",
|
|
154
|
+
...
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//Retrieve the expected issuer and state sent at the start of the authorization flow
|
|
159
|
+
const EXPECTED_ISS = "http://iss.example.com"
|
|
160
|
+
const EXPECTED_STATE = "TEST_STATE"
|
|
161
|
+
|
|
162
|
+
//Check the iss and state fields match the expected values and verify jwt signature
|
|
163
|
+
verifyAuthorizationResponseFormPostJWT({
|
|
164
|
+
authorizationResponseCompact : jwt,
|
|
165
|
+
authorizationResponseDecoded : decodedJwt,
|
|
166
|
+
callbacks : {
|
|
167
|
+
verifyJwt : (signer, {header, payload, compact}) => {
|
|
168
|
+
... //Signature verification
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
iss : EXPECTED_ISS,
|
|
172
|
+
signer,
|
|
173
|
+
state: EXPECTED_STATE
|
|
174
|
+
} satisfies VerifyAuthorizationResponseFormPostJWTOptions)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### `sendAuthorizationResponseAndExtractCode`
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import {sendAuthorizationResponseAndExtractCode, SendAuthorizationResponseAndExtractCodeOptions} from "@pagopa/io-wallet-oid4vci"
|
|
181
|
+
|
|
182
|
+
//Retrieve the necessary parameters
|
|
183
|
+
const baseOptions: SendAuthorizationResponseAndExtractCodeOptions = {
|
|
184
|
+
//Signature JARM
|
|
185
|
+
authorizationResponseJarm: "...",
|
|
186
|
+
callbacks: {
|
|
187
|
+
fetch,
|
|
188
|
+
verifyJwt: (signer, {header, payload, compact}) => {
|
|
189
|
+
... //verify signature
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
//Issuance session's credential issuer
|
|
193
|
+
iss: "http://iss.example.com",
|
|
194
|
+
presentationResponseUri: "http://response.oidvp.example.com",
|
|
195
|
+
//Retrieve the form_post.jwt response's corresponsing public key and create its corresponding signer
|
|
196
|
+
signer: {
|
|
197
|
+
alg: "ES256",
|
|
198
|
+
method: "jwk",
|
|
199
|
+
publicJwk: {
|
|
200
|
+
kty: "EC",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
//The authorization state
|
|
204
|
+
state: "TEST_STATE",
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
//Obtain the authorization code
|
|
208
|
+
|
|
209
|
+
const {code, iss, state} = await sendAuthorizationResponseAndExtractCode(options)
|
|
210
|
+
```
|
|
211
|
+
|
|
66
212
|
## API Reference
|
|
67
213
|
|
|
68
214
|
`WalletProvider`: A class that extends Openid4vciWalletProvider to provide specialized methods for the Italian Wallet ecosystem.
|
|
69
215
|
|
|
216
|
+
|
|
217
|
+
`completeAuthorization` : Method that completes the `form_post.jwt` based authorization process for credentials issuance following the ITWallet
|
|
218
|
+
specification by retrieving the form from the provided uri, extracting and parsing the contained JWT and verifying the
|
|
219
|
+
`iss` and `state` fields match the authorization session's expected values.
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
`verifyAuthorizationResponse` : Utility that verifies if the returned Authorization Response's
|
|
223
|
+
`iss` and `state` field match the Authorization Session ones
|
|
224
|
+
|
|
225
|
+
`verifyAuthorizationResponseFormPostJWT` : Wrapper of `verifyAuthorizationResponse` that verifies the signature of the JWT containing
|
|
226
|
+
the authorization response and extracts the Authorization Response payload
|
|
227
|
+
|
|
228
|
+
`sendAuthorizationResponseAndExtractCode` : Convenience method that combines `completeAuthorization`,
|
|
229
|
+
oid4vp package's `fetchAuthorizationResponse` and `verifyAuthorizationResponseFormPostJWT`
|
|
230
|
+
to retrieve the access code starting from the authorization response and the response uri
|
|
231
|
+
|
|
70
232
|
## Errors
|
|
71
233
|
|
|
72
234
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,94 @@
|
|
|
1
|
-
import { ClientAttestationJwtPayload } from '@openid4vc/oauth2';
|
|
1
|
+
import { decodeJwt, CallbackContext, JwtSignerJwk, ClientAttestationJwtPayload } from '@openid4vc/oauth2';
|
|
2
|
+
import { getJwtFromFormPost } from '@pagopa/io-wallet-oauth2';
|
|
3
|
+
import { FetchAuthorizationResponseOptions } from '@pagopa/io-wallet-oid4vp';
|
|
4
|
+
import z from 'zod';
|
|
2
5
|
import { Openid4vciWalletProvider } from '@openid4vc/openid4vci';
|
|
3
6
|
|
|
7
|
+
declare const zAuthorizationResponse: z.ZodObject<{
|
|
8
|
+
code: z.ZodString;
|
|
9
|
+
iss: z.ZodString;
|
|
10
|
+
state: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
code: string;
|
|
13
|
+
iss: string;
|
|
14
|
+
state: string;
|
|
15
|
+
}, {
|
|
16
|
+
code: string;
|
|
17
|
+
iss: string;
|
|
18
|
+
state: string;
|
|
19
|
+
}>;
|
|
20
|
+
type AuthorizationResponse = z.infer<typeof zAuthorizationResponse>;
|
|
21
|
+
|
|
22
|
+
interface VerifyAuthorizationResponseFormPostJWTOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Compact AuthorizaitonResponse JWT
|
|
25
|
+
*/
|
|
26
|
+
authorizationResponseCompact: string;
|
|
27
|
+
/**
|
|
28
|
+
* Authorization Response object containing the authorization
|
|
29
|
+
* code, the issuer and the session's state
|
|
30
|
+
*/
|
|
31
|
+
authorizationResponseDecoded: ReturnType<typeof decodeJwt<undefined, typeof zAuthorizationResponse>>;
|
|
32
|
+
/**
|
|
33
|
+
* Callback for verifying the authorization jwt signature
|
|
34
|
+
*/
|
|
35
|
+
callbacks: Pick<CallbackContext, "verifyJwt">;
|
|
36
|
+
/**
|
|
37
|
+
* The issuer the Wallet Instance started the
|
|
38
|
+
* authorization flow (either via PAR or directly) with
|
|
39
|
+
*/
|
|
40
|
+
iss: string;
|
|
41
|
+
/**
|
|
42
|
+
* Signer of the form POST returned jwt
|
|
43
|
+
*/
|
|
44
|
+
signer: JwtSignerJwk;
|
|
45
|
+
/**
|
|
46
|
+
* The state sent by the Wallet Instance at the start
|
|
47
|
+
* of the authorization flow (either via PAR or directly)
|
|
48
|
+
*/
|
|
49
|
+
state: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface CompleteAuthorizationOptions {
|
|
53
|
+
callbacks: Pick<CallbackContext, "fetch">;
|
|
54
|
+
/**
|
|
55
|
+
* The response_uri returned by the server after a successful
|
|
56
|
+
* OID4VP Authorization Response is sent
|
|
57
|
+
*/
|
|
58
|
+
response_uri: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Combination of {@link CompleteAuthorizationOptions},
|
|
62
|
+
* {@link FetchAuthorizationResponseOptions} and
|
|
63
|
+
* {@link VerifyAuthorizationResponseFormPostJWTOptions}
|
|
64
|
+
*/
|
|
65
|
+
type SendAuthorizationResponseAndExtractCodeOptions = FetchAuthorizationResponseOptions & Omit<VerifyAuthorizationResponseFormPostJWTOptions, "authorizationResponseCompact" | "authorizationResponseDecoded"> & Omit<CompleteAuthorizationOptions, "response_uri">;
|
|
66
|
+
/**
|
|
67
|
+
* Method that completes the form_post.jwt based authorization
|
|
68
|
+
* process for credentials issuance following the ITWallet
|
|
69
|
+
* specification by retrieving the form from the provided uri,
|
|
70
|
+
* extracting and parsing the contained JWT and verifying the
|
|
71
|
+
* iss and state fields match the authorization session's expected
|
|
72
|
+
* values.
|
|
73
|
+
* See https://italia.github.io/eid-wallet-it-docs/versione-corrente/en/credential-issuance-low-level.html#
|
|
74
|
+
* steps 6-7 for details.
|
|
75
|
+
*
|
|
76
|
+
* @param options {@link CompleteAuthorizationOptions}
|
|
77
|
+
* @returns An object containing the fetched JWT and its decoding. The JWT contains the access code
|
|
78
|
+
* necessary for access token issuance
|
|
79
|
+
*/
|
|
80
|
+
declare function completeAuthorization(options: CompleteAuthorizationOptions): ReturnType<typeof getJwtFromFormPost<typeof zAuthorizationResponse>>;
|
|
81
|
+
/**
|
|
82
|
+
* Convenience method that combines {@link completeAuthorization},
|
|
83
|
+
* oid4vp package's {@link fetchAuthorizationResponse} and {@link verifyAuthorizationResponseFormPostJWT} to retrieve the
|
|
84
|
+
* access code starting from the authorization response and the response uri
|
|
85
|
+
*
|
|
86
|
+
* @param options {@link SendAuthorizationResponseAndExtractCodeOptions}
|
|
87
|
+
* @returns An object containing the fetched JWT and its decoding. The JWT contains the access code
|
|
88
|
+
* for necessary for access token issuance
|
|
89
|
+
*/
|
|
90
|
+
declare function sendAuthorizationResponseAndExtractCode(options: SendAuthorizationResponseAndExtractCodeOptions): Promise<AuthorizationResponse>;
|
|
91
|
+
|
|
4
92
|
/**
|
|
5
93
|
* Generic error thrown on Oid4vci operations
|
|
6
94
|
*/
|
|
@@ -24,6 +112,13 @@ declare class NonceRequestError extends Error {
|
|
|
24
112
|
readonly statusCode?: number | undefined;
|
|
25
113
|
constructor(message: string, statusCode?: number | undefined);
|
|
26
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Error thrown when an unexpected error occurs during credential response fetching.
|
|
117
|
+
*/
|
|
118
|
+
declare class FetchCredentialResponseError extends Oid4vciError {
|
|
119
|
+
readonly originalError?: unknown;
|
|
120
|
+
constructor(message: string, originalError?: unknown);
|
|
121
|
+
}
|
|
27
122
|
|
|
28
123
|
/**
|
|
29
124
|
* @interface WalletAttestationOptions
|
|
@@ -93,4 +188,4 @@ declare class WalletProvider extends Openid4vciWalletProvider {
|
|
|
93
188
|
createItWalletAttestationJwt(options: WalletAttestationOptions): Promise<string>;
|
|
94
189
|
}
|
|
95
190
|
|
|
96
|
-
export { NonceRequestError, Oid4vciError, type WalletAttestationOptions, WalletProvider, WalletProviderError };
|
|
191
|
+
export { type AuthorizationResponse, type CompleteAuthorizationOptions, FetchCredentialResponseError, NonceRequestError, Oid4vciError, type SendAuthorizationResponseAndExtractCodeOptions, type WalletAttestationOptions, WalletProvider, WalletProviderError, completeAuthorization, sendAuthorizationResponseAndExtractCode, zAuthorizationResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,94 @@
|
|
|
1
|
-
import { ClientAttestationJwtPayload } from '@openid4vc/oauth2';
|
|
1
|
+
import { decodeJwt, CallbackContext, JwtSignerJwk, ClientAttestationJwtPayload } from '@openid4vc/oauth2';
|
|
2
|
+
import { getJwtFromFormPost } from '@pagopa/io-wallet-oauth2';
|
|
3
|
+
import { FetchAuthorizationResponseOptions } from '@pagopa/io-wallet-oid4vp';
|
|
4
|
+
import z from 'zod';
|
|
2
5
|
import { Openid4vciWalletProvider } from '@openid4vc/openid4vci';
|
|
3
6
|
|
|
7
|
+
declare const zAuthorizationResponse: z.ZodObject<{
|
|
8
|
+
code: z.ZodString;
|
|
9
|
+
iss: z.ZodString;
|
|
10
|
+
state: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
code: string;
|
|
13
|
+
iss: string;
|
|
14
|
+
state: string;
|
|
15
|
+
}, {
|
|
16
|
+
code: string;
|
|
17
|
+
iss: string;
|
|
18
|
+
state: string;
|
|
19
|
+
}>;
|
|
20
|
+
type AuthorizationResponse = z.infer<typeof zAuthorizationResponse>;
|
|
21
|
+
|
|
22
|
+
interface VerifyAuthorizationResponseFormPostJWTOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Compact AuthorizaitonResponse JWT
|
|
25
|
+
*/
|
|
26
|
+
authorizationResponseCompact: string;
|
|
27
|
+
/**
|
|
28
|
+
* Authorization Response object containing the authorization
|
|
29
|
+
* code, the issuer and the session's state
|
|
30
|
+
*/
|
|
31
|
+
authorizationResponseDecoded: ReturnType<typeof decodeJwt<undefined, typeof zAuthorizationResponse>>;
|
|
32
|
+
/**
|
|
33
|
+
* Callback for verifying the authorization jwt signature
|
|
34
|
+
*/
|
|
35
|
+
callbacks: Pick<CallbackContext, "verifyJwt">;
|
|
36
|
+
/**
|
|
37
|
+
* The issuer the Wallet Instance started the
|
|
38
|
+
* authorization flow (either via PAR or directly) with
|
|
39
|
+
*/
|
|
40
|
+
iss: string;
|
|
41
|
+
/**
|
|
42
|
+
* Signer of the form POST returned jwt
|
|
43
|
+
*/
|
|
44
|
+
signer: JwtSignerJwk;
|
|
45
|
+
/**
|
|
46
|
+
* The state sent by the Wallet Instance at the start
|
|
47
|
+
* of the authorization flow (either via PAR or directly)
|
|
48
|
+
*/
|
|
49
|
+
state: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface CompleteAuthorizationOptions {
|
|
53
|
+
callbacks: Pick<CallbackContext, "fetch">;
|
|
54
|
+
/**
|
|
55
|
+
* The response_uri returned by the server after a successful
|
|
56
|
+
* OID4VP Authorization Response is sent
|
|
57
|
+
*/
|
|
58
|
+
response_uri: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Combination of {@link CompleteAuthorizationOptions},
|
|
62
|
+
* {@link FetchAuthorizationResponseOptions} and
|
|
63
|
+
* {@link VerifyAuthorizationResponseFormPostJWTOptions}
|
|
64
|
+
*/
|
|
65
|
+
type SendAuthorizationResponseAndExtractCodeOptions = FetchAuthorizationResponseOptions & Omit<VerifyAuthorizationResponseFormPostJWTOptions, "authorizationResponseCompact" | "authorizationResponseDecoded"> & Omit<CompleteAuthorizationOptions, "response_uri">;
|
|
66
|
+
/**
|
|
67
|
+
* Method that completes the form_post.jwt based authorization
|
|
68
|
+
* process for credentials issuance following the ITWallet
|
|
69
|
+
* specification by retrieving the form from the provided uri,
|
|
70
|
+
* extracting and parsing the contained JWT and verifying the
|
|
71
|
+
* iss and state fields match the authorization session's expected
|
|
72
|
+
* values.
|
|
73
|
+
* See https://italia.github.io/eid-wallet-it-docs/versione-corrente/en/credential-issuance-low-level.html#
|
|
74
|
+
* steps 6-7 for details.
|
|
75
|
+
*
|
|
76
|
+
* @param options {@link CompleteAuthorizationOptions}
|
|
77
|
+
* @returns An object containing the fetched JWT and its decoding. The JWT contains the access code
|
|
78
|
+
* necessary for access token issuance
|
|
79
|
+
*/
|
|
80
|
+
declare function completeAuthorization(options: CompleteAuthorizationOptions): ReturnType<typeof getJwtFromFormPost<typeof zAuthorizationResponse>>;
|
|
81
|
+
/**
|
|
82
|
+
* Convenience method that combines {@link completeAuthorization},
|
|
83
|
+
* oid4vp package's {@link fetchAuthorizationResponse} and {@link verifyAuthorizationResponseFormPostJWT} to retrieve the
|
|
84
|
+
* access code starting from the authorization response and the response uri
|
|
85
|
+
*
|
|
86
|
+
* @param options {@link SendAuthorizationResponseAndExtractCodeOptions}
|
|
87
|
+
* @returns An object containing the fetched JWT and its decoding. The JWT contains the access code
|
|
88
|
+
* for necessary for access token issuance
|
|
89
|
+
*/
|
|
90
|
+
declare function sendAuthorizationResponseAndExtractCode(options: SendAuthorizationResponseAndExtractCodeOptions): Promise<AuthorizationResponse>;
|
|
91
|
+
|
|
4
92
|
/**
|
|
5
93
|
* Generic error thrown on Oid4vci operations
|
|
6
94
|
*/
|
|
@@ -24,6 +112,13 @@ declare class NonceRequestError extends Error {
|
|
|
24
112
|
readonly statusCode?: number | undefined;
|
|
25
113
|
constructor(message: string, statusCode?: number | undefined);
|
|
26
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Error thrown when an unexpected error occurs during credential response fetching.
|
|
117
|
+
*/
|
|
118
|
+
declare class FetchCredentialResponseError extends Oid4vciError {
|
|
119
|
+
readonly originalError?: unknown;
|
|
120
|
+
constructor(message: string, originalError?: unknown);
|
|
121
|
+
}
|
|
27
122
|
|
|
28
123
|
/**
|
|
29
124
|
* @interface WalletAttestationOptions
|
|
@@ -93,4 +188,4 @@ declare class WalletProvider extends Openid4vciWalletProvider {
|
|
|
93
188
|
createItWalletAttestationJwt(options: WalletAttestationOptions): Promise<string>;
|
|
94
189
|
}
|
|
95
190
|
|
|
96
|
-
export { NonceRequestError, Oid4vciError, type WalletAttestationOptions, WalletProvider, WalletProviderError };
|
|
191
|
+
export { type AuthorizationResponse, type CompleteAuthorizationOptions, FetchCredentialResponseError, NonceRequestError, Oid4vciError, type SendAuthorizationResponseAndExtractCodeOptions, type WalletAttestationOptions, WalletProvider, WalletProviderError, completeAuthorization, sendAuthorizationResponseAndExtractCode, zAuthorizationResponse };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,18 +17,36 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
33
|
+
FetchCredentialResponseError: () => FetchCredentialResponseError,
|
|
23
34
|
NonceRequestError: () => NonceRequestError,
|
|
24
35
|
Oid4vciError: () => Oid4vciError,
|
|
25
36
|
WalletProvider: () => WalletProvider,
|
|
26
|
-
WalletProviderError: () => WalletProviderError
|
|
37
|
+
WalletProviderError: () => WalletProviderError,
|
|
38
|
+
completeAuthorization: () => completeAuthorization,
|
|
39
|
+
sendAuthorizationResponseAndExtractCode: () => sendAuthorizationResponseAndExtractCode,
|
|
40
|
+
zAuthorizationResponse: () => zAuthorizationResponse
|
|
27
41
|
});
|
|
28
42
|
module.exports = __toCommonJS(index_exports);
|
|
29
43
|
|
|
44
|
+
// src/authorization-response/complete-authorization.ts
|
|
45
|
+
var import_utils = require("@openid4vc/utils");
|
|
46
|
+
var import_io_wallet_oauth2 = require("@pagopa/io-wallet-oauth2");
|
|
47
|
+
var import_io_wallet_oid4vp = require("@pagopa/io-wallet-oid4vp");
|
|
48
|
+
var import_io_wallet_utils = require("@pagopa/io-wallet-utils");
|
|
49
|
+
|
|
30
50
|
// src/errors.ts
|
|
31
51
|
var Oid4vciError = class extends Error {
|
|
32
52
|
constructor(message, statusCode) {
|
|
@@ -49,10 +69,109 @@ var NonceRequestError = class extends Error {
|
|
|
49
69
|
this.name = "NonceRequestError";
|
|
50
70
|
}
|
|
51
71
|
};
|
|
72
|
+
var FetchCredentialResponseError = class extends Oid4vciError {
|
|
73
|
+
constructor(message, originalError) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.originalError = originalError;
|
|
76
|
+
this.name = "FetchCredentialResponseError";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/authorization-response/verify-authorization-response.ts
|
|
81
|
+
async function verifyAuthorizationResponse(options) {
|
|
82
|
+
if (options.authorizationResponse.iss !== options.iss)
|
|
83
|
+
throw new Oid4vciError(
|
|
84
|
+
`Response result iss doesn't match passed counterpart. Expected: ${options.iss}, Got: ${options.authorizationResponse.iss}`
|
|
85
|
+
);
|
|
86
|
+
if (options.authorizationResponse.state !== options.state)
|
|
87
|
+
throw new Oid4vciError(
|
|
88
|
+
`Response result state doesn't match passed counterpart. Expected: ${options.state}, Got: ${options.authorizationResponse.state}`
|
|
89
|
+
);
|
|
90
|
+
return options.authorizationResponse;
|
|
91
|
+
}
|
|
92
|
+
async function verifyAuthorizationResponseFormPostJWT(options) {
|
|
93
|
+
try {
|
|
94
|
+
const decodedJwt = options.authorizationResponseDecoded;
|
|
95
|
+
const result = await options.callbacks.verifyJwt(options.signer, {
|
|
96
|
+
compact: options.authorizationResponseCompact,
|
|
97
|
+
...decodedJwt
|
|
98
|
+
});
|
|
99
|
+
if (!result.verified) {
|
|
100
|
+
throw new Oid4vciError("Error verifying JWT signature");
|
|
101
|
+
}
|
|
102
|
+
return verifyAuthorizationResponse({
|
|
103
|
+
authorizationResponse: options.authorizationResponseDecoded.payload,
|
|
104
|
+
iss: options.iss,
|
|
105
|
+
state: options.state
|
|
106
|
+
});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
if (error instanceof Oid4vciError) throw error;
|
|
109
|
+
throw new Oid4vciError(
|
|
110
|
+
`Unexpected error verifying form post jwt: ${error instanceof Error ? `${error.name} : ${error.message}` : String(error)}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/authorization-response/z-authorization-response.ts
|
|
116
|
+
var import_zod = __toESM(require("zod"));
|
|
117
|
+
var zAuthorizationResponse = import_zod.default.object({
|
|
118
|
+
code: import_zod.default.string(),
|
|
119
|
+
iss: import_zod.default.string(),
|
|
120
|
+
state: import_zod.default.string()
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// src/authorization-response/complete-authorization.ts
|
|
124
|
+
async function completeAuthorization(options) {
|
|
125
|
+
try {
|
|
126
|
+
const fetch = (0, import_utils.createFetcher)(options.callbacks.fetch);
|
|
127
|
+
const authorizationResponseResult = await fetch(options.response_uri);
|
|
128
|
+
await (0, import_io_wallet_utils.hasStatusOrThrow)(
|
|
129
|
+
200,
|
|
130
|
+
import_io_wallet_utils.UnexpectedStatusCodeError
|
|
131
|
+
)(authorizationResponseResult);
|
|
132
|
+
return await (0, import_io_wallet_oauth2.getJwtFromFormPost)({
|
|
133
|
+
formData: await authorizationResponseResult.text(),
|
|
134
|
+
schema: zAuthorizationResponse
|
|
135
|
+
});
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (error instanceof import_io_wallet_utils.UnexpectedStatusCodeError || error instanceof import_utils.ValidationError || error instanceof Oid4vciError) {
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
throw new Oid4vciError(
|
|
141
|
+
`Unexpected error completing the authorization process: ${error instanceof Error ? `${error.name} : ${error.message}` : String(error)}`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function sendAuthorizationResponseAndExtractCode(options) {
|
|
146
|
+
try {
|
|
147
|
+
const authorizationResult = await (0, import_io_wallet_oid4vp.fetchAuthorizationResponse)(options);
|
|
148
|
+
const jwtAndPayload = await completeAuthorization({
|
|
149
|
+
...options,
|
|
150
|
+
response_uri: authorizationResult.redirect_uri
|
|
151
|
+
});
|
|
152
|
+
return verifyAuthorizationResponseFormPostJWT({
|
|
153
|
+
authorizationResponseCompact: jwtAndPayload.jwt,
|
|
154
|
+
authorizationResponseDecoded: jwtAndPayload.decodedJwt,
|
|
155
|
+
callbacks: {
|
|
156
|
+
verifyJwt: options.callbacks.verifyJwt
|
|
157
|
+
},
|
|
158
|
+
iss: options.iss,
|
|
159
|
+
signer: options.signer,
|
|
160
|
+
state: options.state
|
|
161
|
+
});
|
|
162
|
+
} catch (error) {
|
|
163
|
+
if (error instanceof import_io_wallet_utils.UnexpectedStatusCodeError || error instanceof import_utils.ValidationError || error instanceof Oid4vciError) {
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
throw new Oid4vciError(
|
|
167
|
+
`Unexpected error sending the authorization response and retrieving the acces code: ${error instanceof Error ? error.message : String(error)}`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
52
171
|
|
|
53
172
|
// src/wallet-provider/WalletProvider.ts
|
|
54
173
|
var import_openid4vci = require("@openid4vc/openid4vci");
|
|
55
|
-
var
|
|
174
|
+
var import_utils2 = require("@openid4vc/utils");
|
|
56
175
|
var WalletProvider = class extends import_openid4vci.Openid4vciWalletProvider {
|
|
57
176
|
/**
|
|
58
177
|
* Creates a wallet attestation JWT.
|
|
@@ -76,7 +195,7 @@ var WalletProvider = class extends import_openid4vci.Openid4vciWalletProvider {
|
|
|
76
195
|
// We use the same key for DPoP as the wallet attestation
|
|
77
196
|
jwk: options.dpopJwkPublic
|
|
78
197
|
},
|
|
79
|
-
expiresAt: options.expiresAt ?? (0,
|
|
198
|
+
expiresAt: options.expiresAt ?? (0, import_utils2.addSecondsToDate)(/* @__PURE__ */ new Date(), 3600 * 24 * 60 * 60),
|
|
80
199
|
issuer: options.issuer,
|
|
81
200
|
signer: {
|
|
82
201
|
alg: "ES256",
|
|
@@ -93,9 +212,13 @@ var WalletProvider = class extends import_openid4vci.Openid4vciWalletProvider {
|
|
|
93
212
|
};
|
|
94
213
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
214
|
0 && (module.exports = {
|
|
215
|
+
FetchCredentialResponseError,
|
|
96
216
|
NonceRequestError,
|
|
97
217
|
Oid4vciError,
|
|
98
218
|
WalletProvider,
|
|
99
|
-
WalletProviderError
|
|
219
|
+
WalletProviderError,
|
|
220
|
+
completeAuthorization,
|
|
221
|
+
sendAuthorizationResponseAndExtractCode,
|
|
222
|
+
zAuthorizationResponse
|
|
100
223
|
});
|
|
101
224
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/wallet-provider/WalletProvider.ts"],"sourcesContent":["export * from \"./errors\";\nexport * from \"./wallet-provider/WalletProvider\";\n","/**\n * Generic error thrown on Oid4vci operations\n */\nexport class Oid4vciError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"Oid4vciError\";\n }\n}\n\n/**\n * Error thrown in case the DPoP key passed to the\n * {@link WalletProvider.createItWalletAttestationJwt} method\n * doesn't contain a kid\n */\nexport class WalletProviderError extends Oid4vciError {\n constructor(\n message: string,\n public readonly originalError?: unknown,\n ) {\n super(message);\n this.name = \"WalletProviderError\";\n }\n}\n\n/**\n * Error thrown when an unexpected error occurs during nonce request.\n */\nexport class NonceRequestError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"NonceRequestError\";\n }\n}\n","import { ClientAttestationJwtPayload } from \"@openid4vc/oauth2\";\nimport { Openid4vciWalletProvider } from \"@openid4vc/openid4vci\";\nimport { addSecondsToDate } from \"@openid4vc/utils\";\n\nimport { WalletProviderError } from \"../errors\";\n\n/**\n * @interface WalletAttestationOptions\n * @description Defines the options required to create a wallet attestation JWT.\n * This attestation is a signed token that proves the wallet's identity and possession of a cryptographic key.\n */\nexport interface WalletAttestationOptions {\n /**\n * The public part of the DPoP (Demonstrating Proof-of-Possession) key in JWK (JSON Web Key) format.\n * This key is used to bind the attestation to the client's session.\n * @type {ClientAttestationJwtPayload['cnf']}\n */\n dpopJwkPublic: ClientAttestationJwtPayload[\"cnf\"][\"jwk\"];\n\n /**\n * The optional expiration date for the attestation JWT. If not provided, a default lifetime will be used.\n * @type {Date}\n */\n expiresAt?: Date;\n /**\n * The issuer of the attestation, typically the Wallet Provider's identifier.\n * @type {string}\n */\n issuer: string;\n\n signer: {\n /**\n * An array of JWTs representing the chain of trust from the federation's trust anchor\n * to the wallet provider. This is used in federated identity systems to validate the provider's authenticity.\n * @type {[string, ...string[]]}\n */\n trustChain: [string, ...string[]];\n\n /**\n * The Key ID (`kid`) of the wallet provider's public key used for signing the attestation.\n * @type {string}\n */\n walletProviderJwkPublicKid: string;\n };\n\n /**\n * An optional deep link or URL that can be used to open or interact with the wallet.\n * @type {string}\n */\n walletLink?: string;\n\n /**\n * An optional display name for the wallet.\n * @type {string}\n */\n walletName?: string;\n}\n\n/**\n * @class WalletProvider\n * @extends Openid4vciWalletProvider\n * @description An implementation of a wallet provider for the OpenID4VCI protocol, tailored for a specific ecosystem (e.g., the Italian one).\n * It handles the creation of wallet attestations required during the credential issuance flow.\n */\nexport class WalletProvider extends Openid4vciWalletProvider {\n /**\n * Creates a wallet attestation JWT.\n *\n * This method constructs a signed JWT that asserts the wallet's control over a specific\n * cryptographic key (DPoP key). This is a security measure to ensure that the entity\n * presenting the credential offer is the legitimate wallet instance.\n *\n * @public\n * @async\n * @param {WalletAttestationOptions} options - The necessary parameters to build the attestation.\n * @returns {Promise<string>} A promise that resolves to the signed wallet attestation JWT as a string.\n */\n public async createItWalletAttestationJwt(\n options: WalletAttestationOptions,\n ): Promise<string> {\n if (!options.dpopJwkPublic.kid) {\n throw new WalletProviderError(\"The DPoP JWK must have a 'kid' property\");\n }\n\n const walletAttestation = await this.createWalletAttestationJwt({\n clientId: options.dpopJwkPublic.kid,\n confirmation: {\n // We use the same key for DPoP as the wallet attestation\n jwk: options.dpopJwkPublic,\n },\n expiresAt:\n options.expiresAt ?? addSecondsToDate(new Date(), 3600 * 24 * 60 * 60),\n issuer: options.issuer,\n signer: {\n alg: \"ES256\",\n kid: options.signer.walletProviderJwkPublicKid,\n method: \"federation\", // Indicates the validation method relies on a trust chain.\n trustChain: options.signer.trustChain,\n },\n walletLink: options.walletLink,\n walletName: options.walletName,\n });\n\n return walletAttestation;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAOO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,YACE,SACgB,eAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACtCA,wBAAyC;AACzC,mBAAiC;AA8D1B,IAAM,iBAAN,cAA6B,2CAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAa3D,MAAa,6BACX,SACiB;AACjB,QAAI,CAAC,QAAQ,cAAc,KAAK;AAC9B,YAAM,IAAI,oBAAoB,yCAAyC;AAAA,IACzE;AAEA,UAAM,oBAAoB,MAAM,KAAK,2BAA2B;AAAA,MAC9D,UAAU,QAAQ,cAAc;AAAA,MAChC,cAAc;AAAA;AAAA,QAEZ,KAAK,QAAQ;AAAA,MACf;AAAA,MACA,WACE,QAAQ,iBAAa,+BAAiB,oBAAI,KAAK,GAAG,OAAO,KAAK,KAAK,EAAE;AAAA,MACvE,QAAQ,QAAQ;AAAA,MAChB,QAAQ;AAAA,QACN,KAAK;AAAA,QACL,KAAK,QAAQ,OAAO;AAAA,QACpB,QAAQ;AAAA;AAAA,QACR,YAAY,QAAQ,OAAO;AAAA,MAC7B;AAAA,MACA,YAAY,QAAQ;AAAA,MACpB,YAAY,QAAQ;AAAA,IACtB,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/authorization-response/complete-authorization.ts","../src/errors.ts","../src/authorization-response/verify-authorization-response.ts","../src/authorization-response/z-authorization-response.ts","../src/wallet-provider/WalletProvider.ts"],"sourcesContent":["export * from \"./authorization-response\";\nexport * from \"./errors\";\nexport * from \"./wallet-provider/WalletProvider\";\n","import { CallbackContext } from \"@openid4vc/oauth2\";\nimport { ValidationError, createFetcher } from \"@openid4vc/utils\";\nimport { getJwtFromFormPost } from \"@pagopa/io-wallet-oauth2\";\nimport {\n FetchAuthorizationResponseOptions,\n fetchAuthorizationResponse,\n} from \"@pagopa/io-wallet-oid4vp\";\nimport {\n UnexpectedStatusCodeError,\n hasStatusOrThrow,\n} from \"@pagopa/io-wallet-utils\";\n\nimport { Oid4vciError } from \"../errors\";\nimport {\n VerifyAuthorizationResponseFormPostJWTOptions,\n verifyAuthorizationResponseFormPostJWT,\n} from \"./verify-authorization-response\";\nimport {\n AuthorizationResponse,\n zAuthorizationResponse,\n} from \"./z-authorization-response\";\n\nexport interface CompleteAuthorizationOptions {\n callbacks: Pick<CallbackContext, \"fetch\">;\n\n /**\n * The response_uri returned by the server after a successful\n * OID4VP Authorization Response is sent\n */\n response_uri: string;\n}\n\n/**\n * Combination of {@link CompleteAuthorizationOptions},\n * {@link FetchAuthorizationResponseOptions} and\n * {@link VerifyAuthorizationResponseFormPostJWTOptions}\n */\nexport type SendAuthorizationResponseAndExtractCodeOptions =\n FetchAuthorizationResponseOptions &\n Omit<\n VerifyAuthorizationResponseFormPostJWTOptions,\n \"authorizationResponseCompact\" | \"authorizationResponseDecoded\"\n > &\n Omit<CompleteAuthorizationOptions, \"response_uri\">;\n\n/**\n * Method that completes the form_post.jwt based authorization\n * process for credentials issuance following the ITWallet\n * specification by retrieving the form from the provided uri,\n * extracting and parsing the contained JWT and verifying the\n * iss and state fields match the authorization session's expected\n * values.\n * See https://italia.github.io/eid-wallet-it-docs/versione-corrente/en/credential-issuance-low-level.html#\n * steps 6-7 for details.\n *\n * @param options {@link CompleteAuthorizationOptions}\n * @returns An object containing the fetched JWT and its decoding. The JWT contains the access code\n * necessary for access token issuance\n */\nexport async function completeAuthorization(\n options: CompleteAuthorizationOptions,\n): ReturnType<typeof getJwtFromFormPost<typeof zAuthorizationResponse>> {\n try {\n const fetch = createFetcher(options.callbacks.fetch);\n const authorizationResponseResult = await fetch(options.response_uri);\n\n await hasStatusOrThrow(\n 200,\n UnexpectedStatusCodeError,\n )(authorizationResponseResult);\n\n return await getJwtFromFormPost({\n formData: await authorizationResponseResult.text(),\n schema: zAuthorizationResponse,\n });\n } catch (error) {\n if (\n error instanceof UnexpectedStatusCodeError ||\n error instanceof ValidationError ||\n error instanceof Oid4vciError\n ) {\n throw error;\n }\n throw new Oid4vciError(\n `Unexpected error completing the authorization process: ${error instanceof Error ? `${error.name} : ${error.message}` : String(error)}`,\n );\n }\n}\n\n/**\n * Convenience method that combines {@link completeAuthorization},\n * oid4vp package's {@link fetchAuthorizationResponse} and {@link verifyAuthorizationResponseFormPostJWT} to retrieve the\n * access code starting from the authorization response and the response uri\n *\n * @param options {@link SendAuthorizationResponseAndExtractCodeOptions}\n * @returns An object containing the fetched JWT and its decoding. The JWT contains the access code\n * for necessary for access token issuance\n */\nexport async function sendAuthorizationResponseAndExtractCode(\n options: SendAuthorizationResponseAndExtractCodeOptions,\n): Promise<AuthorizationResponse> {\n try {\n const authorizationResult = await fetchAuthorizationResponse(options);\n\n const jwtAndPayload = await completeAuthorization({\n ...options,\n response_uri: authorizationResult.redirect_uri,\n });\n\n return verifyAuthorizationResponseFormPostJWT({\n authorizationResponseCompact: jwtAndPayload.jwt,\n authorizationResponseDecoded: jwtAndPayload.decodedJwt,\n callbacks: {\n verifyJwt: options.callbacks.verifyJwt,\n },\n iss: options.iss,\n signer: options.signer,\n state: options.state,\n });\n } catch (error) {\n if (\n error instanceof UnexpectedStatusCodeError ||\n error instanceof ValidationError ||\n error instanceof Oid4vciError\n ) {\n throw error;\n }\n throw new Oid4vciError(\n `Unexpected error sending the authorization response and retrieving the acces code: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","/**\n * Generic error thrown on Oid4vci operations\n */\nexport class Oid4vciError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"Oid4vciError\";\n }\n}\n\n/**\n * Error thrown in case the DPoP key passed to the\n * {@link WalletProvider.createItWalletAttestationJwt} method\n * doesn't contain a kid\n */\nexport class WalletProviderError extends Oid4vciError {\n constructor(\n message: string,\n public readonly originalError?: unknown,\n ) {\n super(message);\n this.name = \"WalletProviderError\";\n }\n}\n\n/**\n * Error thrown when an unexpected error occurs during nonce request.\n */\nexport class NonceRequestError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"NonceRequestError\";\n }\n}\n\n/**\n * Error thrown when an unexpected error occurs during credential response fetching.\n */\nexport class FetchCredentialResponseError extends Oid4vciError {\n constructor(\n message: string,\n public readonly originalError?: unknown,\n ) {\n super(message);\n this.name = \"FetchCredentialResponseError\";\n }\n}\n","import { CallbackContext, JwtSignerJwk, decodeJwt } from \"@openid4vc/oauth2\";\n\nimport { Oid4vciError } from \"../errors\";\nimport {\n AuthorizationResponse,\n zAuthorizationResponse,\n} from \"./z-authorization-response\";\n\nexport interface VerifyAuthorizationResponseOptions {\n /**\n * Authorization response object containing the authorization\n * code, the issuer and the session's state\n */\n authorizationResponse: AuthorizationResponse;\n\n /**\n * The issuer the Wallet Instance started the\n * authorization flow (either via PAR or directly) with\n */\n iss: string;\n\n /**\n * The state sent by the Wallet Instance at the start\n * of the authorization flow (either via PAR or directly)\n */\n state: string;\n}\n\nexport interface VerifyAuthorizationResponseFormPostJWTOptions {\n /**\n * Compact AuthorizaitonResponse JWT\n */\n authorizationResponseCompact: string;\n\n /**\n * Authorization Response object containing the authorization\n * code, the issuer and the session's state\n */\n authorizationResponseDecoded: ReturnType<\n typeof decodeJwt<undefined, typeof zAuthorizationResponse>\n >;\n\n /**\n * Callback for verifying the authorization jwt signature\n */\n callbacks: Pick<CallbackContext, \"verifyJwt\">;\n\n /**\n * The issuer the Wallet Instance started the\n * authorization flow (either via PAR or directly) with\n */\n iss: string;\n\n /**\n * Signer of the form POST returned jwt\n */\n signer: JwtSignerJwk;\n\n /**\n * The state sent by the Wallet Instance at the start\n * of the authorization flow (either via PAR or directly)\n */\n state: string;\n}\n\n/**\n * Utility that verifies if the returned Authorization Response's iss and state field match\n * the Authorization Session ones\n * @param options {@link VerifyAuthorizationResponseOptions}\n * @returns the {@link AuthorizationResponse} passed as an option\n * @throws {Oid4vciError} in case the iss or state field of the Authorization request don't\n * match the provided ones\n */\nexport async function verifyAuthorizationResponse(\n options: VerifyAuthorizationResponseOptions,\n): Promise<AuthorizationResponse> {\n if (options.authorizationResponse.iss !== options.iss)\n throw new Oid4vciError(\n `Response result iss doesn't match passed counterpart. Expected: ${options.iss}, Got: ${options.authorizationResponse.iss}`,\n );\n if (options.authorizationResponse.state !== options.state)\n throw new Oid4vciError(\n `Response result state doesn't match passed counterpart. Expected: ${options.state}, Got: ${options.authorizationResponse.state}`,\n );\n\n return options.authorizationResponse;\n}\n\n/**\n * Wrapper of {@link verifyAuthorizationResponse} that verifies the signature of the JWT containing\n * the authorization response and extracts the {@link AuthorizationResponse} payload\n * @param options {@link VerifyAuthorizationResponseFormPostJWTOptions}\n * @returns the {@link AuthorizationResponse} passed as an option\n * @throws {Oid4vciError} in case {@link verifyAuthorizationResponse} throws or in case\n * signature verification fails\n */\nexport async function verifyAuthorizationResponseFormPostJWT(\n options: VerifyAuthorizationResponseFormPostJWTOptions,\n): Promise<AuthorizationResponse> {\n try {\n const decodedJwt = options.authorizationResponseDecoded;\n const result = await options.callbacks.verifyJwt(options.signer, {\n compact: options.authorizationResponseCompact,\n ...decodedJwt,\n });\n\n if (!result.verified) {\n throw new Oid4vciError(\"Error verifying JWT signature\");\n }\n\n return verifyAuthorizationResponse({\n authorizationResponse: options.authorizationResponseDecoded.payload,\n iss: options.iss,\n state: options.state,\n });\n } catch (error) {\n if (error instanceof Oid4vciError) throw error;\n\n throw new Oid4vciError(\n `Unexpected error verifying form post jwt: ${error instanceof Error ? `${error.name} : ${error.message}` : String(error)}`,\n );\n }\n}\n","import z from \"zod\";\n\nexport const zAuthorizationResponse = z.object({\n code: z.string(),\n iss: z.string(),\n state: z.string(),\n});\n\nexport type AuthorizationResponse = z.infer<typeof zAuthorizationResponse>;\n","import { ClientAttestationJwtPayload } from \"@openid4vc/oauth2\";\nimport { Openid4vciWalletProvider } from \"@openid4vc/openid4vci\";\nimport { addSecondsToDate } from \"@openid4vc/utils\";\n\nimport { WalletProviderError } from \"../errors\";\n\n/**\n * @interface WalletAttestationOptions\n * @description Defines the options required to create a wallet attestation JWT.\n * This attestation is a signed token that proves the wallet's identity and possession of a cryptographic key.\n */\nexport interface WalletAttestationOptions {\n /**\n * The public part of the DPoP (Demonstrating Proof-of-Possession) key in JWK (JSON Web Key) format.\n * This key is used to bind the attestation to the client's session.\n * @type {ClientAttestationJwtPayload['cnf']}\n */\n dpopJwkPublic: ClientAttestationJwtPayload[\"cnf\"][\"jwk\"];\n\n /**\n * The optional expiration date for the attestation JWT. If not provided, a default lifetime will be used.\n * @type {Date}\n */\n expiresAt?: Date;\n /**\n * The issuer of the attestation, typically the Wallet Provider's identifier.\n * @type {string}\n */\n issuer: string;\n\n signer: {\n /**\n * An array of JWTs representing the chain of trust from the federation's trust anchor\n * to the wallet provider. This is used in federated identity systems to validate the provider's authenticity.\n * @type {[string, ...string[]]}\n */\n trustChain: [string, ...string[]];\n\n /**\n * The Key ID (`kid`) of the wallet provider's public key used for signing the attestation.\n * @type {string}\n */\n walletProviderJwkPublicKid: string;\n };\n\n /**\n * An optional deep link or URL that can be used to open or interact with the wallet.\n * @type {string}\n */\n walletLink?: string;\n\n /**\n * An optional display name for the wallet.\n * @type {string}\n */\n walletName?: string;\n}\n\n/**\n * @class WalletProvider\n * @extends Openid4vciWalletProvider\n * @description An implementation of a wallet provider for the OpenID4VCI protocol, tailored for a specific ecosystem (e.g., the Italian one).\n * It handles the creation of wallet attestations required during the credential issuance flow.\n */\nexport class WalletProvider extends Openid4vciWalletProvider {\n /**\n * Creates a wallet attestation JWT.\n *\n * This method constructs a signed JWT that asserts the wallet's control over a specific\n * cryptographic key (DPoP key). This is a security measure to ensure that the entity\n * presenting the credential offer is the legitimate wallet instance.\n *\n * @public\n * @async\n * @param {WalletAttestationOptions} options - The necessary parameters to build the attestation.\n * @returns {Promise<string>} A promise that resolves to the signed wallet attestation JWT as a string.\n */\n public async createItWalletAttestationJwt(\n options: WalletAttestationOptions,\n ): Promise<string> {\n if (!options.dpopJwkPublic.kid) {\n throw new WalletProviderError(\"The DPoP JWK must have a 'kid' property\");\n }\n\n const walletAttestation = await this.createWalletAttestationJwt({\n clientId: options.dpopJwkPublic.kid,\n confirmation: {\n // We use the same key for DPoP as the wallet attestation\n jwk: options.dpopJwkPublic,\n },\n expiresAt:\n options.expiresAt ?? addSecondsToDate(new Date(), 3600 * 24 * 60 * 60),\n issuer: options.issuer,\n signer: {\n alg: \"ES256\",\n kid: options.signer.walletProviderJwkPublicKid,\n method: \"federation\", // Indicates the validation method relies on a trust chain.\n trustChain: options.signer.trustChain,\n },\n walletLink: options.walletLink,\n walletName: options.walletName,\n });\n\n return walletAttestation;\n }\n}\n"],"mappings":"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","names":["z","import_utils"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
// src/authorization-response/complete-authorization.ts
|
|
2
|
+
import { ValidationError, createFetcher } from "@openid4vc/utils";
|
|
3
|
+
import { getJwtFromFormPost } from "@pagopa/io-wallet-oauth2";
|
|
4
|
+
import {
|
|
5
|
+
fetchAuthorizationResponse
|
|
6
|
+
} from "@pagopa/io-wallet-oid4vp";
|
|
7
|
+
import {
|
|
8
|
+
UnexpectedStatusCodeError,
|
|
9
|
+
hasStatusOrThrow
|
|
10
|
+
} from "@pagopa/io-wallet-utils";
|
|
11
|
+
|
|
1
12
|
// src/errors.ts
|
|
2
13
|
var Oid4vciError = class extends Error {
|
|
3
14
|
constructor(message, statusCode) {
|
|
@@ -20,6 +31,105 @@ var NonceRequestError = class extends Error {
|
|
|
20
31
|
this.name = "NonceRequestError";
|
|
21
32
|
}
|
|
22
33
|
};
|
|
34
|
+
var FetchCredentialResponseError = class extends Oid4vciError {
|
|
35
|
+
constructor(message, originalError) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.originalError = originalError;
|
|
38
|
+
this.name = "FetchCredentialResponseError";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/authorization-response/verify-authorization-response.ts
|
|
43
|
+
async function verifyAuthorizationResponse(options) {
|
|
44
|
+
if (options.authorizationResponse.iss !== options.iss)
|
|
45
|
+
throw new Oid4vciError(
|
|
46
|
+
`Response result iss doesn't match passed counterpart. Expected: ${options.iss}, Got: ${options.authorizationResponse.iss}`
|
|
47
|
+
);
|
|
48
|
+
if (options.authorizationResponse.state !== options.state)
|
|
49
|
+
throw new Oid4vciError(
|
|
50
|
+
`Response result state doesn't match passed counterpart. Expected: ${options.state}, Got: ${options.authorizationResponse.state}`
|
|
51
|
+
);
|
|
52
|
+
return options.authorizationResponse;
|
|
53
|
+
}
|
|
54
|
+
async function verifyAuthorizationResponseFormPostJWT(options) {
|
|
55
|
+
try {
|
|
56
|
+
const decodedJwt = options.authorizationResponseDecoded;
|
|
57
|
+
const result = await options.callbacks.verifyJwt(options.signer, {
|
|
58
|
+
compact: options.authorizationResponseCompact,
|
|
59
|
+
...decodedJwt
|
|
60
|
+
});
|
|
61
|
+
if (!result.verified) {
|
|
62
|
+
throw new Oid4vciError("Error verifying JWT signature");
|
|
63
|
+
}
|
|
64
|
+
return verifyAuthorizationResponse({
|
|
65
|
+
authorizationResponse: options.authorizationResponseDecoded.payload,
|
|
66
|
+
iss: options.iss,
|
|
67
|
+
state: options.state
|
|
68
|
+
});
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error instanceof Oid4vciError) throw error;
|
|
71
|
+
throw new Oid4vciError(
|
|
72
|
+
`Unexpected error verifying form post jwt: ${error instanceof Error ? `${error.name} : ${error.message}` : String(error)}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/authorization-response/z-authorization-response.ts
|
|
78
|
+
import z from "zod";
|
|
79
|
+
var zAuthorizationResponse = z.object({
|
|
80
|
+
code: z.string(),
|
|
81
|
+
iss: z.string(),
|
|
82
|
+
state: z.string()
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// src/authorization-response/complete-authorization.ts
|
|
86
|
+
async function completeAuthorization(options) {
|
|
87
|
+
try {
|
|
88
|
+
const fetch = createFetcher(options.callbacks.fetch);
|
|
89
|
+
const authorizationResponseResult = await fetch(options.response_uri);
|
|
90
|
+
await hasStatusOrThrow(
|
|
91
|
+
200,
|
|
92
|
+
UnexpectedStatusCodeError
|
|
93
|
+
)(authorizationResponseResult);
|
|
94
|
+
return await getJwtFromFormPost({
|
|
95
|
+
formData: await authorizationResponseResult.text(),
|
|
96
|
+
schema: zAuthorizationResponse
|
|
97
|
+
});
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (error instanceof UnexpectedStatusCodeError || error instanceof ValidationError || error instanceof Oid4vciError) {
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
throw new Oid4vciError(
|
|
103
|
+
`Unexpected error completing the authorization process: ${error instanceof Error ? `${error.name} : ${error.message}` : String(error)}`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function sendAuthorizationResponseAndExtractCode(options) {
|
|
108
|
+
try {
|
|
109
|
+
const authorizationResult = await fetchAuthorizationResponse(options);
|
|
110
|
+
const jwtAndPayload = await completeAuthorization({
|
|
111
|
+
...options,
|
|
112
|
+
response_uri: authorizationResult.redirect_uri
|
|
113
|
+
});
|
|
114
|
+
return verifyAuthorizationResponseFormPostJWT({
|
|
115
|
+
authorizationResponseCompact: jwtAndPayload.jwt,
|
|
116
|
+
authorizationResponseDecoded: jwtAndPayload.decodedJwt,
|
|
117
|
+
callbacks: {
|
|
118
|
+
verifyJwt: options.callbacks.verifyJwt
|
|
119
|
+
},
|
|
120
|
+
iss: options.iss,
|
|
121
|
+
signer: options.signer,
|
|
122
|
+
state: options.state
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (error instanceof UnexpectedStatusCodeError || error instanceof ValidationError || error instanceof Oid4vciError) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
throw new Oid4vciError(
|
|
129
|
+
`Unexpected error sending the authorization response and retrieving the acces code: ${error instanceof Error ? error.message : String(error)}`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
23
133
|
|
|
24
134
|
// src/wallet-provider/WalletProvider.ts
|
|
25
135
|
import { Openid4vciWalletProvider } from "@openid4vc/openid4vci";
|
|
@@ -63,9 +173,13 @@ var WalletProvider = class extends Openid4vciWalletProvider {
|
|
|
63
173
|
}
|
|
64
174
|
};
|
|
65
175
|
export {
|
|
176
|
+
FetchCredentialResponseError,
|
|
66
177
|
NonceRequestError,
|
|
67
178
|
Oid4vciError,
|
|
68
179
|
WalletProvider,
|
|
69
|
-
WalletProviderError
|
|
180
|
+
WalletProviderError,
|
|
181
|
+
completeAuthorization,
|
|
182
|
+
sendAuthorizationResponseAndExtractCode,
|
|
183
|
+
zAuthorizationResponse
|
|
70
184
|
};
|
|
71
185
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/wallet-provider/WalletProvider.ts"],"sourcesContent":["/**\n * Generic error thrown on Oid4vci operations\n */\nexport class Oid4vciError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"Oid4vciError\";\n }\n}\n\n/**\n * Error thrown in case the DPoP key passed to the\n * {@link WalletProvider.createItWalletAttestationJwt} method\n * doesn't contain a kid\n */\nexport class WalletProviderError extends Oid4vciError {\n constructor(\n message: string,\n public readonly originalError?: unknown,\n ) {\n super(message);\n this.name = \"WalletProviderError\";\n }\n}\n\n/**\n * Error thrown when an unexpected error occurs during nonce request.\n */\nexport class NonceRequestError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"NonceRequestError\";\n }\n}\n","import { ClientAttestationJwtPayload } from \"@openid4vc/oauth2\";\nimport { Openid4vciWalletProvider } from \"@openid4vc/openid4vci\";\nimport { addSecondsToDate } from \"@openid4vc/utils\";\n\nimport { WalletProviderError } from \"../errors\";\n\n/**\n * @interface WalletAttestationOptions\n * @description Defines the options required to create a wallet attestation JWT.\n * This attestation is a signed token that proves the wallet's identity and possession of a cryptographic key.\n */\nexport interface WalletAttestationOptions {\n /**\n * The public part of the DPoP (Demonstrating Proof-of-Possession) key in JWK (JSON Web Key) format.\n * This key is used to bind the attestation to the client's session.\n * @type {ClientAttestationJwtPayload['cnf']}\n */\n dpopJwkPublic: ClientAttestationJwtPayload[\"cnf\"][\"jwk\"];\n\n /**\n * The optional expiration date for the attestation JWT. If not provided, a default lifetime will be used.\n * @type {Date}\n */\n expiresAt?: Date;\n /**\n * The issuer of the attestation, typically the Wallet Provider's identifier.\n * @type {string}\n */\n issuer: string;\n\n signer: {\n /**\n * An array of JWTs representing the chain of trust from the federation's trust anchor\n * to the wallet provider. This is used in federated identity systems to validate the provider's authenticity.\n * @type {[string, ...string[]]}\n */\n trustChain: [string, ...string[]];\n\n /**\n * The Key ID (`kid`) of the wallet provider's public key used for signing the attestation.\n * @type {string}\n */\n walletProviderJwkPublicKid: string;\n };\n\n /**\n * An optional deep link or URL that can be used to open or interact with the wallet.\n * @type {string}\n */\n walletLink?: string;\n\n /**\n * An optional display name for the wallet.\n * @type {string}\n */\n walletName?: string;\n}\n\n/**\n * @class WalletProvider\n * @extends Openid4vciWalletProvider\n * @description An implementation of a wallet provider for the OpenID4VCI protocol, tailored for a specific ecosystem (e.g., the Italian one).\n * It handles the creation of wallet attestations required during the credential issuance flow.\n */\nexport class WalletProvider extends Openid4vciWalletProvider {\n /**\n * Creates a wallet attestation JWT.\n *\n * This method constructs a signed JWT that asserts the wallet's control over a specific\n * cryptographic key (DPoP key). This is a security measure to ensure that the entity\n * presenting the credential offer is the legitimate wallet instance.\n *\n * @public\n * @async\n * @param {WalletAttestationOptions} options - The necessary parameters to build the attestation.\n * @returns {Promise<string>} A promise that resolves to the signed wallet attestation JWT as a string.\n */\n public async createItWalletAttestationJwt(\n options: WalletAttestationOptions,\n ): Promise<string> {\n if (!options.dpopJwkPublic.kid) {\n throw new WalletProviderError(\"The DPoP JWK must have a 'kid' property\");\n }\n\n const walletAttestation = await this.createWalletAttestationJwt({\n clientId: options.dpopJwkPublic.kid,\n confirmation: {\n // We use the same key for DPoP as the wallet attestation\n jwk: options.dpopJwkPublic,\n },\n expiresAt:\n options.expiresAt ?? addSecondsToDate(new Date(), 3600 * 24 * 60 * 60),\n issuer: options.issuer,\n signer: {\n alg: \"ES256\",\n kid: options.signer.walletProviderJwkPublicKid,\n method: \"federation\", // Indicates the validation method relies on a trust chain.\n trustChain: options.signer.trustChain,\n },\n walletLink: options.walletLink,\n walletName: options.walletName,\n });\n\n return walletAttestation;\n }\n}\n"],"mappings":";AAGO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAOO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,YACE,SACgB,eAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACtCA,SAAS,gCAAgC;AACzC,SAAS,wBAAwB;AA8D1B,IAAM,iBAAN,cAA6B,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAa3D,MAAa,6BACX,SACiB;AACjB,QAAI,CAAC,QAAQ,cAAc,KAAK;AAC9B,YAAM,IAAI,oBAAoB,yCAAyC;AAAA,IACzE;AAEA,UAAM,oBAAoB,MAAM,KAAK,2BAA2B;AAAA,MAC9D,UAAU,QAAQ,cAAc;AAAA,MAChC,cAAc;AAAA;AAAA,QAEZ,KAAK,QAAQ;AAAA,MACf;AAAA,MACA,WACE,QAAQ,aAAa,iBAAiB,oBAAI,KAAK,GAAG,OAAO,KAAK,KAAK,EAAE;AAAA,MACvE,QAAQ,QAAQ;AAAA,MAChB,QAAQ;AAAA,QACN,KAAK;AAAA,QACL,KAAK,QAAQ,OAAO;AAAA,QACpB,QAAQ;AAAA;AAAA,QACR,YAAY,QAAQ,OAAO;AAAA,MAC7B;AAAA,MACA,YAAY,QAAQ;AAAA,MACpB,YAAY,QAAQ;AAAA,IACtB,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/authorization-response/complete-authorization.ts","../src/errors.ts","../src/authorization-response/verify-authorization-response.ts","../src/authorization-response/z-authorization-response.ts","../src/wallet-provider/WalletProvider.ts"],"sourcesContent":["import { CallbackContext } from \"@openid4vc/oauth2\";\nimport { ValidationError, createFetcher } from \"@openid4vc/utils\";\nimport { getJwtFromFormPost } from \"@pagopa/io-wallet-oauth2\";\nimport {\n FetchAuthorizationResponseOptions,\n fetchAuthorizationResponse,\n} from \"@pagopa/io-wallet-oid4vp\";\nimport {\n UnexpectedStatusCodeError,\n hasStatusOrThrow,\n} from \"@pagopa/io-wallet-utils\";\n\nimport { Oid4vciError } from \"../errors\";\nimport {\n VerifyAuthorizationResponseFormPostJWTOptions,\n verifyAuthorizationResponseFormPostJWT,\n} from \"./verify-authorization-response\";\nimport {\n AuthorizationResponse,\n zAuthorizationResponse,\n} from \"./z-authorization-response\";\n\nexport interface CompleteAuthorizationOptions {\n callbacks: Pick<CallbackContext, \"fetch\">;\n\n /**\n * The response_uri returned by the server after a successful\n * OID4VP Authorization Response is sent\n */\n response_uri: string;\n}\n\n/**\n * Combination of {@link CompleteAuthorizationOptions},\n * {@link FetchAuthorizationResponseOptions} and\n * {@link VerifyAuthorizationResponseFormPostJWTOptions}\n */\nexport type SendAuthorizationResponseAndExtractCodeOptions =\n FetchAuthorizationResponseOptions &\n Omit<\n VerifyAuthorizationResponseFormPostJWTOptions,\n \"authorizationResponseCompact\" | \"authorizationResponseDecoded\"\n > &\n Omit<CompleteAuthorizationOptions, \"response_uri\">;\n\n/**\n * Method that completes the form_post.jwt based authorization\n * process for credentials issuance following the ITWallet\n * specification by retrieving the form from the provided uri,\n * extracting and parsing the contained JWT and verifying the\n * iss and state fields match the authorization session's expected\n * values.\n * See https://italia.github.io/eid-wallet-it-docs/versione-corrente/en/credential-issuance-low-level.html#\n * steps 6-7 for details.\n *\n * @param options {@link CompleteAuthorizationOptions}\n * @returns An object containing the fetched JWT and its decoding. The JWT contains the access code\n * necessary for access token issuance\n */\nexport async function completeAuthorization(\n options: CompleteAuthorizationOptions,\n): ReturnType<typeof getJwtFromFormPost<typeof zAuthorizationResponse>> {\n try {\n const fetch = createFetcher(options.callbacks.fetch);\n const authorizationResponseResult = await fetch(options.response_uri);\n\n await hasStatusOrThrow(\n 200,\n UnexpectedStatusCodeError,\n )(authorizationResponseResult);\n\n return await getJwtFromFormPost({\n formData: await authorizationResponseResult.text(),\n schema: zAuthorizationResponse,\n });\n } catch (error) {\n if (\n error instanceof UnexpectedStatusCodeError ||\n error instanceof ValidationError ||\n error instanceof Oid4vciError\n ) {\n throw error;\n }\n throw new Oid4vciError(\n `Unexpected error completing the authorization process: ${error instanceof Error ? `${error.name} : ${error.message}` : String(error)}`,\n );\n }\n}\n\n/**\n * Convenience method that combines {@link completeAuthorization},\n * oid4vp package's {@link fetchAuthorizationResponse} and {@link verifyAuthorizationResponseFormPostJWT} to retrieve the\n * access code starting from the authorization response and the response uri\n *\n * @param options {@link SendAuthorizationResponseAndExtractCodeOptions}\n * @returns An object containing the fetched JWT and its decoding. The JWT contains the access code\n * for necessary for access token issuance\n */\nexport async function sendAuthorizationResponseAndExtractCode(\n options: SendAuthorizationResponseAndExtractCodeOptions,\n): Promise<AuthorizationResponse> {\n try {\n const authorizationResult = await fetchAuthorizationResponse(options);\n\n const jwtAndPayload = await completeAuthorization({\n ...options,\n response_uri: authorizationResult.redirect_uri,\n });\n\n return verifyAuthorizationResponseFormPostJWT({\n authorizationResponseCompact: jwtAndPayload.jwt,\n authorizationResponseDecoded: jwtAndPayload.decodedJwt,\n callbacks: {\n verifyJwt: options.callbacks.verifyJwt,\n },\n iss: options.iss,\n signer: options.signer,\n state: options.state,\n });\n } catch (error) {\n if (\n error instanceof UnexpectedStatusCodeError ||\n error instanceof ValidationError ||\n error instanceof Oid4vciError\n ) {\n throw error;\n }\n throw new Oid4vciError(\n `Unexpected error sending the authorization response and retrieving the acces code: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","/**\n * Generic error thrown on Oid4vci operations\n */\nexport class Oid4vciError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"Oid4vciError\";\n }\n}\n\n/**\n * Error thrown in case the DPoP key passed to the\n * {@link WalletProvider.createItWalletAttestationJwt} method\n * doesn't contain a kid\n */\nexport class WalletProviderError extends Oid4vciError {\n constructor(\n message: string,\n public readonly originalError?: unknown,\n ) {\n super(message);\n this.name = \"WalletProviderError\";\n }\n}\n\n/**\n * Error thrown when an unexpected error occurs during nonce request.\n */\nexport class NonceRequestError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"NonceRequestError\";\n }\n}\n\n/**\n * Error thrown when an unexpected error occurs during credential response fetching.\n */\nexport class FetchCredentialResponseError extends Oid4vciError {\n constructor(\n message: string,\n public readonly originalError?: unknown,\n ) {\n super(message);\n this.name = \"FetchCredentialResponseError\";\n }\n}\n","import { CallbackContext, JwtSignerJwk, decodeJwt } from \"@openid4vc/oauth2\";\n\nimport { Oid4vciError } from \"../errors\";\nimport {\n AuthorizationResponse,\n zAuthorizationResponse,\n} from \"./z-authorization-response\";\n\nexport interface VerifyAuthorizationResponseOptions {\n /**\n * Authorization response object containing the authorization\n * code, the issuer and the session's state\n */\n authorizationResponse: AuthorizationResponse;\n\n /**\n * The issuer the Wallet Instance started the\n * authorization flow (either via PAR or directly) with\n */\n iss: string;\n\n /**\n * The state sent by the Wallet Instance at the start\n * of the authorization flow (either via PAR or directly)\n */\n state: string;\n}\n\nexport interface VerifyAuthorizationResponseFormPostJWTOptions {\n /**\n * Compact AuthorizaitonResponse JWT\n */\n authorizationResponseCompact: string;\n\n /**\n * Authorization Response object containing the authorization\n * code, the issuer and the session's state\n */\n authorizationResponseDecoded: ReturnType<\n typeof decodeJwt<undefined, typeof zAuthorizationResponse>\n >;\n\n /**\n * Callback for verifying the authorization jwt signature\n */\n callbacks: Pick<CallbackContext, \"verifyJwt\">;\n\n /**\n * The issuer the Wallet Instance started the\n * authorization flow (either via PAR or directly) with\n */\n iss: string;\n\n /**\n * Signer of the form POST returned jwt\n */\n signer: JwtSignerJwk;\n\n /**\n * The state sent by the Wallet Instance at the start\n * of the authorization flow (either via PAR or directly)\n */\n state: string;\n}\n\n/**\n * Utility that verifies if the returned Authorization Response's iss and state field match\n * the Authorization Session ones\n * @param options {@link VerifyAuthorizationResponseOptions}\n * @returns the {@link AuthorizationResponse} passed as an option\n * @throws {Oid4vciError} in case the iss or state field of the Authorization request don't\n * match the provided ones\n */\nexport async function verifyAuthorizationResponse(\n options: VerifyAuthorizationResponseOptions,\n): Promise<AuthorizationResponse> {\n if (options.authorizationResponse.iss !== options.iss)\n throw new Oid4vciError(\n `Response result iss doesn't match passed counterpart. Expected: ${options.iss}, Got: ${options.authorizationResponse.iss}`,\n );\n if (options.authorizationResponse.state !== options.state)\n throw new Oid4vciError(\n `Response result state doesn't match passed counterpart. Expected: ${options.state}, Got: ${options.authorizationResponse.state}`,\n );\n\n return options.authorizationResponse;\n}\n\n/**\n * Wrapper of {@link verifyAuthorizationResponse} that verifies the signature of the JWT containing\n * the authorization response and extracts the {@link AuthorizationResponse} payload\n * @param options {@link VerifyAuthorizationResponseFormPostJWTOptions}\n * @returns the {@link AuthorizationResponse} passed as an option\n * @throws {Oid4vciError} in case {@link verifyAuthorizationResponse} throws or in case\n * signature verification fails\n */\nexport async function verifyAuthorizationResponseFormPostJWT(\n options: VerifyAuthorizationResponseFormPostJWTOptions,\n): Promise<AuthorizationResponse> {\n try {\n const decodedJwt = options.authorizationResponseDecoded;\n const result = await options.callbacks.verifyJwt(options.signer, {\n compact: options.authorizationResponseCompact,\n ...decodedJwt,\n });\n\n if (!result.verified) {\n throw new Oid4vciError(\"Error verifying JWT signature\");\n }\n\n return verifyAuthorizationResponse({\n authorizationResponse: options.authorizationResponseDecoded.payload,\n iss: options.iss,\n state: options.state,\n });\n } catch (error) {\n if (error instanceof Oid4vciError) throw error;\n\n throw new Oid4vciError(\n `Unexpected error verifying form post jwt: ${error instanceof Error ? `${error.name} : ${error.message}` : String(error)}`,\n );\n }\n}\n","import z from \"zod\";\n\nexport const zAuthorizationResponse = z.object({\n code: z.string(),\n iss: z.string(),\n state: z.string(),\n});\n\nexport type AuthorizationResponse = z.infer<typeof zAuthorizationResponse>;\n","import { ClientAttestationJwtPayload } from \"@openid4vc/oauth2\";\nimport { Openid4vciWalletProvider } from \"@openid4vc/openid4vci\";\nimport { addSecondsToDate } from \"@openid4vc/utils\";\n\nimport { WalletProviderError } from \"../errors\";\n\n/**\n * @interface WalletAttestationOptions\n * @description Defines the options required to create a wallet attestation JWT.\n * This attestation is a signed token that proves the wallet's identity and possession of a cryptographic key.\n */\nexport interface WalletAttestationOptions {\n /**\n * The public part of the DPoP (Demonstrating Proof-of-Possession) key in JWK (JSON Web Key) format.\n * This key is used to bind the attestation to the client's session.\n * @type {ClientAttestationJwtPayload['cnf']}\n */\n dpopJwkPublic: ClientAttestationJwtPayload[\"cnf\"][\"jwk\"];\n\n /**\n * The optional expiration date for the attestation JWT. If not provided, a default lifetime will be used.\n * @type {Date}\n */\n expiresAt?: Date;\n /**\n * The issuer of the attestation, typically the Wallet Provider's identifier.\n * @type {string}\n */\n issuer: string;\n\n signer: {\n /**\n * An array of JWTs representing the chain of trust from the federation's trust anchor\n * to the wallet provider. This is used in federated identity systems to validate the provider's authenticity.\n * @type {[string, ...string[]]}\n */\n trustChain: [string, ...string[]];\n\n /**\n * The Key ID (`kid`) of the wallet provider's public key used for signing the attestation.\n * @type {string}\n */\n walletProviderJwkPublicKid: string;\n };\n\n /**\n * An optional deep link or URL that can be used to open or interact with the wallet.\n * @type {string}\n */\n walletLink?: string;\n\n /**\n * An optional display name for the wallet.\n * @type {string}\n */\n walletName?: string;\n}\n\n/**\n * @class WalletProvider\n * @extends Openid4vciWalletProvider\n * @description An implementation of a wallet provider for the OpenID4VCI protocol, tailored for a specific ecosystem (e.g., the Italian one).\n * It handles the creation of wallet attestations required during the credential issuance flow.\n */\nexport class WalletProvider extends Openid4vciWalletProvider {\n /**\n * Creates a wallet attestation JWT.\n *\n * This method constructs a signed JWT that asserts the wallet's control over a specific\n * cryptographic key (DPoP key). This is a security measure to ensure that the entity\n * presenting the credential offer is the legitimate wallet instance.\n *\n * @public\n * @async\n * @param {WalletAttestationOptions} options - The necessary parameters to build the attestation.\n * @returns {Promise<string>} A promise that resolves to the signed wallet attestation JWT as a string.\n */\n public async createItWalletAttestationJwt(\n options: WalletAttestationOptions,\n ): Promise<string> {\n if (!options.dpopJwkPublic.kid) {\n throw new WalletProviderError(\"The DPoP JWK must have a 'kid' property\");\n }\n\n const walletAttestation = await this.createWalletAttestationJwt({\n clientId: options.dpopJwkPublic.kid,\n confirmation: {\n // We use the same key for DPoP as the wallet attestation\n jwk: options.dpopJwkPublic,\n },\n expiresAt:\n options.expiresAt ?? addSecondsToDate(new Date(), 3600 * 24 * 60 * 60),\n issuer: options.issuer,\n signer: {\n alg: \"ES256\",\n kid: options.signer.walletProviderJwkPublicKid,\n method: \"federation\", // Indicates the validation method relies on a trust chain.\n trustChain: options.signer.trustChain,\n },\n walletLink: options.walletLink,\n walletName: options.walletName,\n });\n\n return walletAttestation;\n }\n}\n"],"mappings":"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","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/io-wallet-oid4vci",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -31,7 +31,12 @@
|
|
|
31
31
|
"@openid4vc/openid4vci": "0.3.0-alpha-20250714110838",
|
|
32
32
|
"@openid4vc/utils": "0.3.0-alpha-20250714110838",
|
|
33
33
|
"zod": "^3.24.2",
|
|
34
|
-
"@pagopa/io-wallet-utils": "0.
|
|
34
|
+
"@pagopa/io-wallet-utils": "0.6.0",
|
|
35
|
+
"@pagopa/io-wallet-oauth2": "0.6.0",
|
|
36
|
+
"@pagopa/io-wallet-oid4vp": "0.6.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"js-base64": "^3.7.8"
|
|
35
40
|
},
|
|
36
41
|
"scripts": {
|
|
37
42
|
"build": "tsup src/index.ts --format cjs,esm --dts --sourcemap",
|