@pagopa/io-wallet-oid4vci 0.7.1 → 0.7.3

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/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { decodeJwt, CallbackContext, JwtSignerJwk, ClientAttestationJwtPayload } from '@openid4vc/oauth2';
2
2
  import { getJwtFromFormPost } from '@pagopa/io-wallet-oauth2';
3
3
  import { FetchAuthorizationResponseOptions } from '@pagopa/io-wallet-oid4vp';
4
- import z from 'zod';
4
+ import z, { z as z$1 } from 'zod';
5
5
  import { Openid4vciWalletProvider } from '@openid4vc/openid4vci';
6
6
 
7
7
  declare const zAuthorizationResponse: z.ZodObject<{
@@ -89,6 +89,162 @@ declare function completeAuthorization(options: CompleteAuthorizationOptions): R
89
89
  */
90
90
  declare function sendAuthorizationResponseAndExtractCode(options: SendAuthorizationResponseAndExtractCodeOptions): Promise<AuthorizationResponse>;
91
91
 
92
+ declare const zCredentialRequest: z$1.ZodEffects<z$1.ZodObject<{
93
+ credential_configuration_id: z$1.ZodOptional<z$1.ZodString>;
94
+ credential_identifier: z$1.ZodOptional<z$1.ZodString>;
95
+ proof: z$1.ZodObject<{
96
+ jwt: z$1.ZodString;
97
+ proof_type: z$1.ZodLiteral<"jwt">;
98
+ }, "strip", z$1.ZodTypeAny, {
99
+ jwt: string;
100
+ proof_type: "jwt";
101
+ }, {
102
+ jwt: string;
103
+ proof_type: "jwt";
104
+ }>;
105
+ transaction_id: z$1.ZodOptional<z$1.ZodString>;
106
+ }, "strip", z$1.ZodTypeAny, {
107
+ proof: {
108
+ jwt: string;
109
+ proof_type: "jwt";
110
+ };
111
+ credential_configuration_id?: string | undefined;
112
+ credential_identifier?: string | undefined;
113
+ transaction_id?: string | undefined;
114
+ }, {
115
+ proof: {
116
+ jwt: string;
117
+ proof_type: "jwt";
118
+ };
119
+ credential_configuration_id?: string | undefined;
120
+ credential_identifier?: string | undefined;
121
+ transaction_id?: string | undefined;
122
+ }>, {
123
+ proof: {
124
+ jwt: string;
125
+ proof_type: "jwt";
126
+ };
127
+ credential_configuration_id?: string | undefined;
128
+ credential_identifier?: string | undefined;
129
+ transaction_id?: string | undefined;
130
+ }, {
131
+ proof: {
132
+ jwt: string;
133
+ proof_type: "jwt";
134
+ };
135
+ credential_configuration_id?: string | undefined;
136
+ credential_identifier?: string | undefined;
137
+ transaction_id?: string | undefined;
138
+ }>;
139
+ type CredentialRequest = z$1.infer<typeof zCredentialRequest>;
140
+ declare const zCredentialResponse: z$1.ZodEffects<z$1.ZodObject<{
141
+ credentials: z$1.ZodOptional<z$1.ZodObject<{
142
+ credential: z$1.ZodString;
143
+ }, "strip", z$1.ZodTypeAny, {
144
+ credential: string;
145
+ }, {
146
+ credential: string;
147
+ }>>;
148
+ lead_time: z$1.ZodOptional<z$1.ZodNumber>;
149
+ notification_id: z$1.ZodOptional<z$1.ZodString>;
150
+ transaction_id: z$1.ZodOptional<z$1.ZodString>;
151
+ }, "strip", z$1.ZodTypeAny, {
152
+ transaction_id?: string | undefined;
153
+ credentials?: {
154
+ credential: string;
155
+ } | undefined;
156
+ lead_time?: number | undefined;
157
+ notification_id?: string | undefined;
158
+ }, {
159
+ transaction_id?: string | undefined;
160
+ credentials?: {
161
+ credential: string;
162
+ } | undefined;
163
+ lead_time?: number | undefined;
164
+ notification_id?: string | undefined;
165
+ }>, {
166
+ transaction_id?: string | undefined;
167
+ credentials?: {
168
+ credential: string;
169
+ } | undefined;
170
+ lead_time?: number | undefined;
171
+ notification_id?: string | undefined;
172
+ }, {
173
+ transaction_id?: string | undefined;
174
+ credentials?: {
175
+ credential: string;
176
+ } | undefined;
177
+ lead_time?: number | undefined;
178
+ notification_id?: string | undefined;
179
+ }>;
180
+ type CredentialResponse = z$1.infer<typeof zCredentialResponse>;
181
+
182
+ interface CredentialRequestOptions {
183
+ /**
184
+ * Callbacks to use for signing proof
185
+ */
186
+ callbacks: Pick<CallbackContext, "signJwt">;
187
+ /**
188
+ * Client identifier of the OAuth2 Client making the Credential Request.
189
+ */
190
+ clientId: string;
191
+ /**
192
+ * This MUST be set with one of the value obtained in the credential_identifiers claim of the Token Response.
193
+ */
194
+ credential_identifier: string;
195
+ /**
196
+ * Identifier of the Credential Issuer, for ex: https://issuer.example.com.
197
+ */
198
+ issuerIdentifier: string;
199
+ /**
200
+ * A nonce value previously requested to associate a Client session with the Credential Request.
201
+ */
202
+ nonce: string;
203
+ /**
204
+ * The signer of the credential PoP JWT.
205
+ */
206
+ signer: JwtSignerJwk;
207
+ }
208
+ /**
209
+ * Create a Credential Request.
210
+ * @param options - Options to create the Credential Request
211
+ * @returns The created Credential Request
212
+ */
213
+ declare const createCredentialRequest: (options: CredentialRequestOptions) => Promise<CredentialRequest>;
214
+
215
+ interface FetchCredentialResponseOptions {
216
+ /**
217
+ * Access token to authorize the credential request for DPoP mechanism
218
+ */
219
+ accessToken: string;
220
+ /**
221
+ * Callbacks to use for requesting access token
222
+ */
223
+ callbacks: Pick<CallbackContext, "fetch">;
224
+ /**
225
+ * The credential endpoint URL
226
+ */
227
+ credentialEndpoint: string;
228
+ /**
229
+ * Credential request body
230
+ */
231
+ credentialRequest: CredentialRequest;
232
+ /**
233
+ * DPoP proof with addition of ath claim
234
+ */
235
+ dPoP: string;
236
+ }
237
+ /**
238
+ * Fetches a credential response from the credential endpoint.
239
+ *
240
+ * @param options - Options for fetching the credential response
241
+ * @returns The credential response
242
+ * @throws FetchCredentialResponseError if an unexpected error occurs during the fetch
243
+ * @throws UnexpectedStatusCodeError if the response status code is not 200
244
+ * @throws ValidationError if the response cannot be parsed as a valid credential response
245
+ */
246
+ declare function fetchCredentialResponse(options: FetchCredentialResponseOptions): Promise<CredentialResponse>;
247
+
92
248
  /**
93
249
  * Generic error thrown on Oid4vci operations
94
250
  */
@@ -188,4 +344,4 @@ declare class WalletProvider extends Openid4vciWalletProvider {
188
344
  createItWalletAttestationJwt(options: WalletAttestationOptions): Promise<string>;
189
345
  }
190
346
 
191
- export { type AuthorizationResponse, type CompleteAuthorizationOptions, FetchCredentialResponseError, NonceRequestError, Oid4vciError, type SendAuthorizationResponseAndExtractCodeOptions, type WalletAttestationOptions, WalletProvider, WalletProviderError, completeAuthorization, sendAuthorizationResponseAndExtractCode, zAuthorizationResponse };
347
+ export { type AuthorizationResponse, type CompleteAuthorizationOptions, type CredentialRequest, type CredentialRequestOptions, type CredentialResponse, FetchCredentialResponseError, type FetchCredentialResponseOptions, NonceRequestError, Oid4vciError, type SendAuthorizationResponseAndExtractCodeOptions, type WalletAttestationOptions, WalletProvider, WalletProviderError, completeAuthorization, createCredentialRequest, fetchCredentialResponse, sendAuthorizationResponseAndExtractCode, zAuthorizationResponse, zCredentialRequest, zCredentialResponse };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { decodeJwt, CallbackContext, JwtSignerJwk, ClientAttestationJwtPayload } from '@openid4vc/oauth2';
2
2
  import { getJwtFromFormPost } from '@pagopa/io-wallet-oauth2';
3
3
  import { FetchAuthorizationResponseOptions } from '@pagopa/io-wallet-oid4vp';
4
- import z from 'zod';
4
+ import z, { z as z$1 } from 'zod';
5
5
  import { Openid4vciWalletProvider } from '@openid4vc/openid4vci';
6
6
 
7
7
  declare const zAuthorizationResponse: z.ZodObject<{
@@ -89,6 +89,162 @@ declare function completeAuthorization(options: CompleteAuthorizationOptions): R
89
89
  */
90
90
  declare function sendAuthorizationResponseAndExtractCode(options: SendAuthorizationResponseAndExtractCodeOptions): Promise<AuthorizationResponse>;
91
91
 
92
+ declare const zCredentialRequest: z$1.ZodEffects<z$1.ZodObject<{
93
+ credential_configuration_id: z$1.ZodOptional<z$1.ZodString>;
94
+ credential_identifier: z$1.ZodOptional<z$1.ZodString>;
95
+ proof: z$1.ZodObject<{
96
+ jwt: z$1.ZodString;
97
+ proof_type: z$1.ZodLiteral<"jwt">;
98
+ }, "strip", z$1.ZodTypeAny, {
99
+ jwt: string;
100
+ proof_type: "jwt";
101
+ }, {
102
+ jwt: string;
103
+ proof_type: "jwt";
104
+ }>;
105
+ transaction_id: z$1.ZodOptional<z$1.ZodString>;
106
+ }, "strip", z$1.ZodTypeAny, {
107
+ proof: {
108
+ jwt: string;
109
+ proof_type: "jwt";
110
+ };
111
+ credential_configuration_id?: string | undefined;
112
+ credential_identifier?: string | undefined;
113
+ transaction_id?: string | undefined;
114
+ }, {
115
+ proof: {
116
+ jwt: string;
117
+ proof_type: "jwt";
118
+ };
119
+ credential_configuration_id?: string | undefined;
120
+ credential_identifier?: string | undefined;
121
+ transaction_id?: string | undefined;
122
+ }>, {
123
+ proof: {
124
+ jwt: string;
125
+ proof_type: "jwt";
126
+ };
127
+ credential_configuration_id?: string | undefined;
128
+ credential_identifier?: string | undefined;
129
+ transaction_id?: string | undefined;
130
+ }, {
131
+ proof: {
132
+ jwt: string;
133
+ proof_type: "jwt";
134
+ };
135
+ credential_configuration_id?: string | undefined;
136
+ credential_identifier?: string | undefined;
137
+ transaction_id?: string | undefined;
138
+ }>;
139
+ type CredentialRequest = z$1.infer<typeof zCredentialRequest>;
140
+ declare const zCredentialResponse: z$1.ZodEffects<z$1.ZodObject<{
141
+ credentials: z$1.ZodOptional<z$1.ZodObject<{
142
+ credential: z$1.ZodString;
143
+ }, "strip", z$1.ZodTypeAny, {
144
+ credential: string;
145
+ }, {
146
+ credential: string;
147
+ }>>;
148
+ lead_time: z$1.ZodOptional<z$1.ZodNumber>;
149
+ notification_id: z$1.ZodOptional<z$1.ZodString>;
150
+ transaction_id: z$1.ZodOptional<z$1.ZodString>;
151
+ }, "strip", z$1.ZodTypeAny, {
152
+ transaction_id?: string | undefined;
153
+ credentials?: {
154
+ credential: string;
155
+ } | undefined;
156
+ lead_time?: number | undefined;
157
+ notification_id?: string | undefined;
158
+ }, {
159
+ transaction_id?: string | undefined;
160
+ credentials?: {
161
+ credential: string;
162
+ } | undefined;
163
+ lead_time?: number | undefined;
164
+ notification_id?: string | undefined;
165
+ }>, {
166
+ transaction_id?: string | undefined;
167
+ credentials?: {
168
+ credential: string;
169
+ } | undefined;
170
+ lead_time?: number | undefined;
171
+ notification_id?: string | undefined;
172
+ }, {
173
+ transaction_id?: string | undefined;
174
+ credentials?: {
175
+ credential: string;
176
+ } | undefined;
177
+ lead_time?: number | undefined;
178
+ notification_id?: string | undefined;
179
+ }>;
180
+ type CredentialResponse = z$1.infer<typeof zCredentialResponse>;
181
+
182
+ interface CredentialRequestOptions {
183
+ /**
184
+ * Callbacks to use for signing proof
185
+ */
186
+ callbacks: Pick<CallbackContext, "signJwt">;
187
+ /**
188
+ * Client identifier of the OAuth2 Client making the Credential Request.
189
+ */
190
+ clientId: string;
191
+ /**
192
+ * This MUST be set with one of the value obtained in the credential_identifiers claim of the Token Response.
193
+ */
194
+ credential_identifier: string;
195
+ /**
196
+ * Identifier of the Credential Issuer, for ex: https://issuer.example.com.
197
+ */
198
+ issuerIdentifier: string;
199
+ /**
200
+ * A nonce value previously requested to associate a Client session with the Credential Request.
201
+ */
202
+ nonce: string;
203
+ /**
204
+ * The signer of the credential PoP JWT.
205
+ */
206
+ signer: JwtSignerJwk;
207
+ }
208
+ /**
209
+ * Create a Credential Request.
210
+ * @param options - Options to create the Credential Request
211
+ * @returns The created Credential Request
212
+ */
213
+ declare const createCredentialRequest: (options: CredentialRequestOptions) => Promise<CredentialRequest>;
214
+
215
+ interface FetchCredentialResponseOptions {
216
+ /**
217
+ * Access token to authorize the credential request for DPoP mechanism
218
+ */
219
+ accessToken: string;
220
+ /**
221
+ * Callbacks to use for requesting access token
222
+ */
223
+ callbacks: Pick<CallbackContext, "fetch">;
224
+ /**
225
+ * The credential endpoint URL
226
+ */
227
+ credentialEndpoint: string;
228
+ /**
229
+ * Credential request body
230
+ */
231
+ credentialRequest: CredentialRequest;
232
+ /**
233
+ * DPoP proof with addition of ath claim
234
+ */
235
+ dPoP: string;
236
+ }
237
+ /**
238
+ * Fetches a credential response from the credential endpoint.
239
+ *
240
+ * @param options - Options for fetching the credential response
241
+ * @returns The credential response
242
+ * @throws FetchCredentialResponseError if an unexpected error occurs during the fetch
243
+ * @throws UnexpectedStatusCodeError if the response status code is not 200
244
+ * @throws ValidationError if the response cannot be parsed as a valid credential response
245
+ */
246
+ declare function fetchCredentialResponse(options: FetchCredentialResponseOptions): Promise<CredentialResponse>;
247
+
92
248
  /**
93
249
  * Generic error thrown on Oid4vci operations
94
250
  */
@@ -188,4 +344,4 @@ declare class WalletProvider extends Openid4vciWalletProvider {
188
344
  createItWalletAttestationJwt(options: WalletAttestationOptions): Promise<string>;
189
345
  }
190
346
 
191
- export { type AuthorizationResponse, type CompleteAuthorizationOptions, FetchCredentialResponseError, NonceRequestError, Oid4vciError, type SendAuthorizationResponseAndExtractCodeOptions, type WalletAttestationOptions, WalletProvider, WalletProviderError, completeAuthorization, sendAuthorizationResponseAndExtractCode, zAuthorizationResponse };
347
+ export { type AuthorizationResponse, type CompleteAuthorizationOptions, type CredentialRequest, type CredentialRequestOptions, type CredentialResponse, FetchCredentialResponseError, type FetchCredentialResponseOptions, NonceRequestError, Oid4vciError, type SendAuthorizationResponseAndExtractCodeOptions, type WalletAttestationOptions, WalletProvider, WalletProviderError, completeAuthorization, createCredentialRequest, fetchCredentialResponse, sendAuthorizationResponseAndExtractCode, zAuthorizationResponse, zCredentialRequest, zCredentialResponse };
package/dist/index.js CHANGED
@@ -36,8 +36,12 @@ __export(index_exports, {
36
36
  WalletProvider: () => WalletProvider,
37
37
  WalletProviderError: () => WalletProviderError,
38
38
  completeAuthorization: () => completeAuthorization,
39
+ createCredentialRequest: () => createCredentialRequest,
40
+ fetchCredentialResponse: () => fetchCredentialResponse,
39
41
  sendAuthorizationResponseAndExtractCode: () => sendAuthorizationResponseAndExtractCode,
40
- zAuthorizationResponse: () => zAuthorizationResponse
42
+ zAuthorizationResponse: () => zAuthorizationResponse,
43
+ zCredentialRequest: () => zCredentialRequest,
44
+ zCredentialResponse: () => zCredentialResponse
41
45
  });
42
46
  module.exports = __toCommonJS(index_exports);
43
47
 
@@ -169,9 +173,150 @@ async function sendAuthorizationResponseAndExtractCode(options) {
169
173
  }
170
174
  }
171
175
 
176
+ // src/credential-request/create-credential-request.ts
177
+ var import_utils2 = require("@openid4vc/utils");
178
+
179
+ // src/credential-request/z-credential.ts
180
+ var import_zod2 = require("zod");
181
+ var ProofSchema = import_zod2.z.object({
182
+ jwt: import_zod2.z.string().min(1, "JWT must not be empty"),
183
+ proof_type: import_zod2.z.literal("jwt")
184
+ // MUST be "jwt"
185
+ });
186
+ var zCredentialRequest = import_zod2.z.object({
187
+ credential_configuration_id: import_zod2.z.string().optional().describe(
188
+ "REQUIRED if credential_identifiers param is absent. MUST NOT be used otherwise."
189
+ ),
190
+ credential_identifier: import_zod2.z.string().optional().describe(
191
+ "REQUIRED when Authorization Details of type openid_credential was returned. MUST NOT be used if credential_configuration_id is present."
192
+ ),
193
+ proof: ProofSchema.describe(
194
+ "REQUIRED. Proof of possession of key material (must contain proof_type=jwt and a jwt)."
195
+ ),
196
+ transaction_id: import_zod2.z.string().optional().describe(
197
+ "REQUIRED only in case of deferred flow. MUST NOT be present in immediate flow."
198
+ )
199
+ }).superRefine((data, ctx) => {
200
+ if (data.credential_identifier && data.credential_configuration_id) {
201
+ ctx.addIssue({
202
+ code: "custom",
203
+ message: "credential_identifier and credential_configuration_id MUST NOT be used together",
204
+ path: ["credential_identifier"]
205
+ });
206
+ }
207
+ if (!data.credential_identifier && !data.credential_configuration_id) {
208
+ ctx.addIssue({
209
+ code: "custom",
210
+ message: "One of credential_identifier or credential_configuration_id MUST be present",
211
+ path: ["credential_identifier"]
212
+ });
213
+ }
214
+ });
215
+ var CredentialsSchema = import_zod2.z.object({
216
+ credential: import_zod2.z.string().min(1, "credential must not be empty").describe(
217
+ "REQUIRED. Contains the issued Digital Credential. Depending on format, may be raw JWT or base64url-encoded CBOR structure."
218
+ )
219
+ });
220
+ var zCredentialResponse = import_zod2.z.object({
221
+ credentials: CredentialsSchema.optional().describe(
222
+ "REQUIRED if lead_time and transaction_id are not present. MUST NOT be present otherwise."
223
+ ),
224
+ lead_time: import_zod2.z.number().int().positive().optional().describe(
225
+ "REQUIRED if credentials is not present. MUST NOT be present otherwise."
226
+ ),
227
+ notification_id: import_zod2.z.string().optional().describe("OPTIONAL. MUST NOT be present if credentials is not present."),
228
+ transaction_id: import_zod2.z.string().optional().describe(
229
+ "REQUIRED if credentials is not present. MUST NOT be present otherwise."
230
+ )
231
+ }).superRefine((data, ctx) => {
232
+ if (data.credentials && (data.lead_time || data.transaction_id)) {
233
+ ctx.addIssue({
234
+ code: "custom",
235
+ message: "credentials MUST NOT be present if lead_time or transaction_id is provided",
236
+ path: ["credentials"]
237
+ });
238
+ }
239
+ if (!data.credentials && (!data.lead_time || !data.transaction_id)) {
240
+ ctx.addIssue({
241
+ code: "custom",
242
+ message: "If credentials is absent, both lead_time and transaction_id MUST be present",
243
+ path: ["lead_time"]
244
+ });
245
+ }
246
+ if (!data.credentials && data.notification_id) {
247
+ ctx.addIssue({
248
+ code: "custom",
249
+ message: "notification_id MUST NOT be present if credentials is absent",
250
+ path: ["notification_id"]
251
+ });
252
+ }
253
+ });
254
+
255
+ // src/credential-request/create-credential-request.ts
256
+ var createCredentialRequest = async (options) => {
257
+ try {
258
+ const { signJwt } = options.callbacks;
259
+ const proofJwt = await signJwt(options.signer, {
260
+ header: {
261
+ alg: options.signer.alg,
262
+ jwk: options.signer.publicJwk,
263
+ typ: "openid4vci-proof+jwt"
264
+ },
265
+ payload: {
266
+ aud: options.issuerIdentifier,
267
+ iat: (0, import_utils2.dateToSeconds)(/* @__PURE__ */ new Date()),
268
+ iss: options.clientId,
269
+ nonce: options.nonce
270
+ }
271
+ });
272
+ return (0, import_utils2.parseWithErrorHandling)(zCredentialRequest, {
273
+ credential_identifier: options.credential_identifier,
274
+ proof: {
275
+ jwt: proofJwt.jwt,
276
+ proof_type: "jwt"
277
+ }
278
+ });
279
+ } catch (error) {
280
+ throw new Oid4vciError(
281
+ `Unexpected error during create credential request: ${error instanceof Error ? error.message : String(error)}`
282
+ );
283
+ }
284
+ };
285
+
286
+ // src/credential-request/fetch-credential-response.ts
287
+ var import_utils3 = require("@openid4vc/utils");
288
+ var import_io_wallet_utils2 = require("@pagopa/io-wallet-utils");
289
+ async function fetchCredentialResponse(options) {
290
+ try {
291
+ const fetch = (0, import_utils3.createFetcher)(options.callbacks.fetch);
292
+ const credentialResponse = await fetch(options.credentialEndpoint, {
293
+ body: JSON.stringify(options.credentialRequest),
294
+ headers: {
295
+ [import_io_wallet_utils2.HEADERS.AUTHORIZATION]: `DPoP ${options.accessToken}`,
296
+ [import_io_wallet_utils2.HEADERS.CONTENT_TYPE]: import_io_wallet_utils2.CONTENT_TYPES.JSON,
297
+ [import_io_wallet_utils2.HEADERS.DPOP]: options.dPoP
298
+ },
299
+ method: "POST"
300
+ });
301
+ await (0, import_io_wallet_utils2.hasStatusOrThrow)(200, import_io_wallet_utils2.UnexpectedStatusCodeError)(credentialResponse);
302
+ return (0, import_utils3.parseWithErrorHandling)(
303
+ zCredentialResponse,
304
+ credentialResponse.json(),
305
+ `Failed to parse credential response`
306
+ );
307
+ } catch (error) {
308
+ if (error instanceof import_io_wallet_utils2.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils2.ValidationError) {
309
+ throw error;
310
+ }
311
+ throw new FetchCredentialResponseError(
312
+ `Unexpected error during credential response: ${error instanceof Error ? error.message : String(error)}`
313
+ );
314
+ }
315
+ }
316
+
172
317
  // src/wallet-provider/WalletProvider.ts
173
318
  var import_openid4vci = require("@openid4vc/openid4vci");
174
- var import_utils2 = require("@openid4vc/utils");
319
+ var import_utils4 = require("@openid4vc/utils");
175
320
  var WalletProvider = class extends import_openid4vci.Openid4vciWalletProvider {
176
321
  /**
177
322
  * Creates a wallet attestation JWT.
@@ -195,7 +340,7 @@ var WalletProvider = class extends import_openid4vci.Openid4vciWalletProvider {
195
340
  // We use the same key for DPoP as the wallet attestation
196
341
  jwk: options.dpopJwkPublic
197
342
  },
198
- expiresAt: options.expiresAt ?? (0, import_utils2.addSecondsToDate)(/* @__PURE__ */ new Date(), 3600 * 24 * 60 * 60),
343
+ expiresAt: options.expiresAt ?? (0, import_utils4.addSecondsToDate)(/* @__PURE__ */ new Date(), 3600 * 24 * 60 * 60),
199
344
  issuer: options.issuer,
200
345
  signer: {
201
346
  alg: "ES256",
@@ -218,7 +363,11 @@ var WalletProvider = class extends import_openid4vci.Openid4vciWalletProvider {
218
363
  WalletProvider,
219
364
  WalletProviderError,
220
365
  completeAuthorization,
366
+ createCredentialRequest,
367
+ fetchCredentialResponse,
221
368
  sendAuthorizationResponseAndExtractCode,
222
- zAuthorizationResponse
369
+ zAuthorizationResponse,
370
+ zCredentialRequest,
371
+ zCredentialResponse
223
372
  });
224
373
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAA+C;AAC/C,8BAAmC;AACnC,8BAGO;AACP,6BAGO;;;ACPA,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;AAKO,IAAM,+BAAN,cAA2C,aAAa;AAAA,EAC7D,YACE,SACgB,eAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACqBA,eAAsB,4BACpB,SACgC;AAChC,MAAI,QAAQ,sBAAsB,QAAQ,QAAQ;AAChD,UAAM,IAAI;AAAA,MACR,mEAAmE,QAAQ,GAAG,UAAU,QAAQ,sBAAsB,GAAG;AAAA,IAC3H;AACF,MAAI,QAAQ,sBAAsB,UAAU,QAAQ;AAClD,UAAM,IAAI;AAAA,MACR,qEAAqE,QAAQ,KAAK,UAAU,QAAQ,sBAAsB,KAAK;AAAA,IACjI;AAEF,SAAO,QAAQ;AACjB;AAUA,eAAsB,uCACpB,SACgC;AAChC,MAAI;AACF,UAAM,aAAa,QAAQ;AAC3B,UAAM,SAAS,MAAM,QAAQ,UAAU,UAAU,QAAQ,QAAQ;AAAA,MAC/D,SAAS,QAAQ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IACtB,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":["z","import_utils"]}
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/credential-request/create-credential-request.ts","../src/credential-request/z-credential.ts","../src/credential-request/fetch-credential-response.ts","../src/wallet-provider/WalletProvider.ts"],"sourcesContent":["export * from \"./authorization-response\";\nexport * from \"./credential-request\";\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 { CallbackContext, JwtSignerJwk } from \"@openid4vc/oauth2\";\nimport { dateToSeconds, parseWithErrorHandling } from \"@openid4vc/utils\";\n\nimport { Oid4vciError } from \"../errors\";\nimport { CredentialRequest, zCredentialRequest } from \"./z-credential\";\n\nexport interface CredentialRequestOptions {\n /**\n * Callbacks to use for signing proof\n */\n callbacks: Pick<CallbackContext, \"signJwt\">;\n\n /**\n * Client identifier of the OAuth2 Client making the Credential Request.\n */\n clientId: string;\n\n /**\n * This MUST be set with one of the value obtained in the credential_identifiers claim of the Token Response.\n */\n credential_identifier: string;\n\n /**\n * Identifier of the Credential Issuer, for ex: https://issuer.example.com.\n */\n issuerIdentifier: string;\n\n /**\n * A nonce value previously requested to associate a Client session with the Credential Request.\n */\n nonce: string;\n\n /**\n * The signer of the credential PoP JWT.\n */\n signer: JwtSignerJwk;\n}\n\n/**\n * Create a Credential Request.\n * @param options - Options to create the Credential Request\n * @returns The created Credential Request\n */\nexport const createCredentialRequest = async (\n options: CredentialRequestOptions,\n): Promise<CredentialRequest> => {\n try {\n const { signJwt } = options.callbacks;\n const proofJwt = await signJwt(options.signer, {\n header: {\n alg: options.signer.alg,\n jwk: options.signer.publicJwk,\n typ: \"openid4vci-proof+jwt\",\n },\n payload: {\n aud: options.issuerIdentifier,\n iat: dateToSeconds(new Date()),\n iss: options.clientId,\n nonce: options.nonce,\n },\n });\n\n return parseWithErrorHandling(zCredentialRequest, {\n credential_identifier: options.credential_identifier,\n proof: {\n jwt: proofJwt.jwt,\n proof_type: \"jwt\",\n },\n } satisfies CredentialRequest);\n } catch (error) {\n throw new Oid4vciError(\n `Unexpected error during create credential request: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n};\n","import { z } from \"zod\";\n\n// Proof object schema\nconst ProofSchema = z.object({\n jwt: z.string().min(1, \"JWT must not be empty\"),\n proof_type: z.literal(\"jwt\"), // MUST be \"jwt\"\n});\n\nexport const zCredentialRequest = z\n .object({\n credential_configuration_id: z\n .string()\n .optional()\n .describe(\n \"REQUIRED if credential_identifiers param is absent. MUST NOT be used otherwise.\",\n ),\n\n credential_identifier: z\n .string()\n .optional()\n .describe(\n \"REQUIRED when Authorization Details of type openid_credential was returned. MUST NOT be used if credential_configuration_id is present.\",\n ),\n\n proof: ProofSchema.describe(\n \"REQUIRED. Proof of possession of key material (must contain proof_type=jwt and a jwt).\",\n ),\n\n transaction_id: z\n .string()\n .optional()\n .describe(\n \"REQUIRED only in case of deferred flow. MUST NOT be present in immediate flow.\",\n ),\n })\n .superRefine((data, ctx) => {\n // Exclusive OR between credential_identifier and credential_configuration_id\n if (data.credential_identifier && data.credential_configuration_id) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"credential_identifier and credential_configuration_id MUST NOT be used together\",\n path: [\"credential_identifier\"],\n });\n }\n\n if (!data.credential_identifier && !data.credential_configuration_id) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"One of credential_identifier or credential_configuration_id MUST be present\",\n path: [\"credential_identifier\"],\n });\n }\n });\n\nexport type CredentialRequest = z.infer<typeof zCredentialRequest>;\n\nconst CredentialsSchema = z.object({\n credential: z\n .string()\n .min(1, \"credential must not be empty\")\n .describe(\n \"REQUIRED. Contains the issued Digital Credential. Depending on format, may be raw JWT or base64url-encoded CBOR structure.\",\n ),\n});\n\nexport const zCredentialResponse = z\n .object({\n credentials: CredentialsSchema.optional().describe(\n \"REQUIRED if lead_time and transaction_id are not present. MUST NOT be present otherwise.\",\n ),\n\n lead_time: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\n \"REQUIRED if credentials is not present. MUST NOT be present otherwise.\",\n ),\n\n notification_id: z\n .string()\n .optional()\n .describe(\"OPTIONAL. MUST NOT be present if credentials is not present.\"),\n\n transaction_id: z\n .string()\n .optional()\n .describe(\n \"REQUIRED if credentials is not present. MUST NOT be present otherwise.\",\n ),\n })\n .superRefine((data, ctx) => {\n // Enforce XOR: credentials vs (lead_time + transaction_id)\n if (data.credentials && (data.lead_time || data.transaction_id)) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"credentials MUST NOT be present if lead_time or transaction_id is provided\",\n path: [\"credentials\"],\n });\n }\n\n if (!data.credentials && (!data.lead_time || !data.transaction_id)) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"If credentials is absent, both lead_time and transaction_id MUST be present\",\n path: [\"lead_time\"],\n });\n }\n\n // notification_id must only exist if credentials is present\n if (!data.credentials && data.notification_id) {\n ctx.addIssue({\n code: \"custom\",\n message: \"notification_id MUST NOT be present if credentials is absent\",\n path: [\"notification_id\"],\n });\n }\n });\n\nexport type CredentialResponse = z.infer<typeof zCredentialResponse>;\n","import { CallbackContext } from \"@openid4vc/oauth2\";\nimport { createFetcher, parseWithErrorHandling } from \"@openid4vc/utils\";\nimport {\n CONTENT_TYPES,\n HEADERS,\n UnexpectedStatusCodeError,\n ValidationError,\n hasStatusOrThrow,\n} from \"@pagopa/io-wallet-utils\";\n\nimport { FetchCredentialResponseError } from \"../errors\";\nimport {\n CredentialRequest,\n CredentialResponse,\n zCredentialResponse,\n} from \"./z-credential\";\n\nexport interface FetchCredentialResponseOptions {\n /**\n * Access token to authorize the credential request for DPoP mechanism\n */\n accessToken: string;\n /**\n * Callbacks to use for requesting access token\n */\n callbacks: Pick<CallbackContext, \"fetch\">;\n\n /**\n * The credential endpoint URL\n */\n credentialEndpoint: string;\n\n /**\n * Credential request body\n */\n credentialRequest: CredentialRequest;\n\n /**\n * DPoP proof with addition of ath claim\n */\n dPoP: string;\n}\n\n/**\n * Fetches a credential response from the credential endpoint.\n *\n * @param options - Options for fetching the credential response\n * @returns The credential response\n * @throws FetchCredentialResponseError if an unexpected error occurs during the fetch\n * @throws UnexpectedStatusCodeError if the response status code is not 200\n * @throws ValidationError if the response cannot be parsed as a valid credential response\n */\nexport async function fetchCredentialResponse(\n options: FetchCredentialResponseOptions,\n): Promise<CredentialResponse> {\n try {\n const fetch = createFetcher(options.callbacks.fetch);\n const credentialResponse = await fetch(options.credentialEndpoint, {\n body: JSON.stringify(options.credentialRequest),\n headers: {\n [HEADERS.AUTHORIZATION]: `DPoP ${options.accessToken}`,\n [HEADERS.CONTENT_TYPE]: CONTENT_TYPES.JSON,\n [HEADERS.DPOP]: options.dPoP,\n },\n method: \"POST\",\n });\n\n await hasStatusOrThrow(200, UnexpectedStatusCodeError)(credentialResponse);\n\n return parseWithErrorHandling(\n zCredentialResponse,\n credentialResponse.json(),\n `Failed to parse credential response`,\n );\n } catch (error) {\n if (\n error instanceof UnexpectedStatusCodeError ||\n error instanceof ValidationError\n ) {\n throw error;\n }\n throw new FetchCredentialResponseError(\n `Unexpected error during credential response: ${error instanceof Error ? error.message : String(error)}`,\n );\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAA+C;AAC/C,8BAAmC;AACnC,8BAGO;AACP,6BAGO;;;ACPA,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;AAKO,IAAM,+BAAN,cAA2C,aAAa;AAAA,EAC7D,YACE,SACgB,eAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACqBA,eAAsB,4BACpB,SACgC;AAChC,MAAI,QAAQ,sBAAsB,QAAQ,QAAQ;AAChD,UAAM,IAAI;AAAA,MACR,mEAAmE,QAAQ,GAAG,UAAU,QAAQ,sBAAsB,GAAG;AAAA,IAC3H;AACF,MAAI,QAAQ,sBAAsB,UAAU,QAAQ;AAClD,UAAM,IAAI;AAAA,MACR,qEAAqE,QAAQ,KAAK,UAAU,QAAQ,sBAAsB,KAAK;AAAA,IACjI;AAEF,SAAO,QAAQ;AACjB;AAUA,eAAsB,uCACpB,SACgC;AAChC,MAAI;AACF,UAAM,aAAa,QAAQ;AAC3B,UAAM,SAAS,M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AAA,EACF,SAAS,OAAO;AACd,QACE,iBAAiB,qDACjB,iBAAiB,yCACjB;AACA,YAAM;AAAA,IACR;AACA,UAAM,IAAI;AAAA,MACR,gDAAgD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IACxG;AAAA,EACF;AACF;;;ACpFA,wBAAyC;AACzC,IAAAC,gBAAiC;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,gCAAiB,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":["z","import_utils","import_zod","import_utils","import_io_wallet_utils","import_utils"]}
package/dist/index.mjs CHANGED
@@ -131,6 +131,153 @@ async function sendAuthorizationResponseAndExtractCode(options) {
131
131
  }
132
132
  }
133
133
 
134
+ // src/credential-request/create-credential-request.ts
135
+ import { dateToSeconds, parseWithErrorHandling } from "@openid4vc/utils";
136
+
137
+ // src/credential-request/z-credential.ts
138
+ import { z as z2 } from "zod";
139
+ var ProofSchema = z2.object({
140
+ jwt: z2.string().min(1, "JWT must not be empty"),
141
+ proof_type: z2.literal("jwt")
142
+ // MUST be "jwt"
143
+ });
144
+ var zCredentialRequest = z2.object({
145
+ credential_configuration_id: z2.string().optional().describe(
146
+ "REQUIRED if credential_identifiers param is absent. MUST NOT be used otherwise."
147
+ ),
148
+ credential_identifier: z2.string().optional().describe(
149
+ "REQUIRED when Authorization Details of type openid_credential was returned. MUST NOT be used if credential_configuration_id is present."
150
+ ),
151
+ proof: ProofSchema.describe(
152
+ "REQUIRED. Proof of possession of key material (must contain proof_type=jwt and a jwt)."
153
+ ),
154
+ transaction_id: z2.string().optional().describe(
155
+ "REQUIRED only in case of deferred flow. MUST NOT be present in immediate flow."
156
+ )
157
+ }).superRefine((data, ctx) => {
158
+ if (data.credential_identifier && data.credential_configuration_id) {
159
+ ctx.addIssue({
160
+ code: "custom",
161
+ message: "credential_identifier and credential_configuration_id MUST NOT be used together",
162
+ path: ["credential_identifier"]
163
+ });
164
+ }
165
+ if (!data.credential_identifier && !data.credential_configuration_id) {
166
+ ctx.addIssue({
167
+ code: "custom",
168
+ message: "One of credential_identifier or credential_configuration_id MUST be present",
169
+ path: ["credential_identifier"]
170
+ });
171
+ }
172
+ });
173
+ var CredentialsSchema = z2.object({
174
+ credential: z2.string().min(1, "credential must not be empty").describe(
175
+ "REQUIRED. Contains the issued Digital Credential. Depending on format, may be raw JWT or base64url-encoded CBOR structure."
176
+ )
177
+ });
178
+ var zCredentialResponse = z2.object({
179
+ credentials: CredentialsSchema.optional().describe(
180
+ "REQUIRED if lead_time and transaction_id are not present. MUST NOT be present otherwise."
181
+ ),
182
+ lead_time: z2.number().int().positive().optional().describe(
183
+ "REQUIRED if credentials is not present. MUST NOT be present otherwise."
184
+ ),
185
+ notification_id: z2.string().optional().describe("OPTIONAL. MUST NOT be present if credentials is not present."),
186
+ transaction_id: z2.string().optional().describe(
187
+ "REQUIRED if credentials is not present. MUST NOT be present otherwise."
188
+ )
189
+ }).superRefine((data, ctx) => {
190
+ if (data.credentials && (data.lead_time || data.transaction_id)) {
191
+ ctx.addIssue({
192
+ code: "custom",
193
+ message: "credentials MUST NOT be present if lead_time or transaction_id is provided",
194
+ path: ["credentials"]
195
+ });
196
+ }
197
+ if (!data.credentials && (!data.lead_time || !data.transaction_id)) {
198
+ ctx.addIssue({
199
+ code: "custom",
200
+ message: "If credentials is absent, both lead_time and transaction_id MUST be present",
201
+ path: ["lead_time"]
202
+ });
203
+ }
204
+ if (!data.credentials && data.notification_id) {
205
+ ctx.addIssue({
206
+ code: "custom",
207
+ message: "notification_id MUST NOT be present if credentials is absent",
208
+ path: ["notification_id"]
209
+ });
210
+ }
211
+ });
212
+
213
+ // src/credential-request/create-credential-request.ts
214
+ var createCredentialRequest = async (options) => {
215
+ try {
216
+ const { signJwt } = options.callbacks;
217
+ const proofJwt = await signJwt(options.signer, {
218
+ header: {
219
+ alg: options.signer.alg,
220
+ jwk: options.signer.publicJwk,
221
+ typ: "openid4vci-proof+jwt"
222
+ },
223
+ payload: {
224
+ aud: options.issuerIdentifier,
225
+ iat: dateToSeconds(/* @__PURE__ */ new Date()),
226
+ iss: options.clientId,
227
+ nonce: options.nonce
228
+ }
229
+ });
230
+ return parseWithErrorHandling(zCredentialRequest, {
231
+ credential_identifier: options.credential_identifier,
232
+ proof: {
233
+ jwt: proofJwt.jwt,
234
+ proof_type: "jwt"
235
+ }
236
+ });
237
+ } catch (error) {
238
+ throw new Oid4vciError(
239
+ `Unexpected error during create credential request: ${error instanceof Error ? error.message : String(error)}`
240
+ );
241
+ }
242
+ };
243
+
244
+ // src/credential-request/fetch-credential-response.ts
245
+ import { createFetcher as createFetcher2, parseWithErrorHandling as parseWithErrorHandling2 } from "@openid4vc/utils";
246
+ import {
247
+ CONTENT_TYPES,
248
+ HEADERS,
249
+ UnexpectedStatusCodeError as UnexpectedStatusCodeError2,
250
+ ValidationError as ValidationError2,
251
+ hasStatusOrThrow as hasStatusOrThrow2
252
+ } from "@pagopa/io-wallet-utils";
253
+ async function fetchCredentialResponse(options) {
254
+ try {
255
+ const fetch = createFetcher2(options.callbacks.fetch);
256
+ const credentialResponse = await fetch(options.credentialEndpoint, {
257
+ body: JSON.stringify(options.credentialRequest),
258
+ headers: {
259
+ [HEADERS.AUTHORIZATION]: `DPoP ${options.accessToken}`,
260
+ [HEADERS.CONTENT_TYPE]: CONTENT_TYPES.JSON,
261
+ [HEADERS.DPOP]: options.dPoP
262
+ },
263
+ method: "POST"
264
+ });
265
+ await hasStatusOrThrow2(200, UnexpectedStatusCodeError2)(credentialResponse);
266
+ return parseWithErrorHandling2(
267
+ zCredentialResponse,
268
+ credentialResponse.json(),
269
+ `Failed to parse credential response`
270
+ );
271
+ } catch (error) {
272
+ if (error instanceof UnexpectedStatusCodeError2 || error instanceof ValidationError2) {
273
+ throw error;
274
+ }
275
+ throw new FetchCredentialResponseError(
276
+ `Unexpected error during credential response: ${error instanceof Error ? error.message : String(error)}`
277
+ );
278
+ }
279
+ }
280
+
134
281
  // src/wallet-provider/WalletProvider.ts
135
282
  import { Openid4vciWalletProvider } from "@openid4vc/openid4vci";
136
283
  import { addSecondsToDate } from "@openid4vc/utils";
@@ -179,7 +326,11 @@ export {
179
326
  WalletProvider,
180
327
  WalletProviderError,
181
328
  completeAuthorization,
329
+ createCredentialRequest,
330
+ fetchCredentialResponse,
182
331
  sendAuthorizationResponseAndExtractCode,
183
- zAuthorizationResponse
332
+ zAuthorizationResponse,
333
+ zCredentialRequest,
334
+ zCredentialResponse
184
335
  };
185
336
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
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":";AACA,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,0BAA0B;AACnC;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACPA,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;AAKO,IAAM,+BAAN,cAA2C,aAAa;AAAA,EAC7D,YACE,SACgB,eAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACqBA,eAAsB,4BACpB,SACgC;AAChC,MAAI,QAAQ,sBAAsB,QAAQ,QAAQ;AAChD,UAAM,IAAI;AAAA,MACR,mEAAmE,QAAQ,GAAG,UAAU,QAAQ,sBAAsB,G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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/credential-request/create-credential-request.ts","../src/credential-request/z-credential.ts","../src/credential-request/fetch-credential-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 { CallbackContext, JwtSignerJwk } from \"@openid4vc/oauth2\";\nimport { dateToSeconds, parseWithErrorHandling } from \"@openid4vc/utils\";\n\nimport { Oid4vciError } from \"../errors\";\nimport { CredentialRequest, zCredentialRequest } from \"./z-credential\";\n\nexport interface CredentialRequestOptions {\n /**\n * Callbacks to use for signing proof\n */\n callbacks: Pick<CallbackContext, \"signJwt\">;\n\n /**\n * Client identifier of the OAuth2 Client making the Credential Request.\n */\n clientId: string;\n\n /**\n * This MUST be set with one of the value obtained in the credential_identifiers claim of the Token Response.\n */\n credential_identifier: string;\n\n /**\n * Identifier of the Credential Issuer, for ex: https://issuer.example.com.\n */\n issuerIdentifier: string;\n\n /**\n * A nonce value previously requested to associate a Client session with the Credential Request.\n */\n nonce: string;\n\n /**\n * The signer of the credential PoP JWT.\n */\n signer: JwtSignerJwk;\n}\n\n/**\n * Create a Credential Request.\n * @param options - Options to create the Credential Request\n * @returns The created Credential Request\n */\nexport const createCredentialRequest = async (\n options: CredentialRequestOptions,\n): Promise<CredentialRequest> => {\n try {\n const { signJwt } = options.callbacks;\n const proofJwt = await signJwt(options.signer, {\n header: {\n alg: options.signer.alg,\n jwk: options.signer.publicJwk,\n typ: \"openid4vci-proof+jwt\",\n },\n payload: {\n aud: options.issuerIdentifier,\n iat: dateToSeconds(new Date()),\n iss: options.clientId,\n nonce: options.nonce,\n },\n });\n\n return parseWithErrorHandling(zCredentialRequest, {\n credential_identifier: options.credential_identifier,\n proof: {\n jwt: proofJwt.jwt,\n proof_type: \"jwt\",\n },\n } satisfies CredentialRequest);\n } catch (error) {\n throw new Oid4vciError(\n `Unexpected error during create credential request: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n};\n","import { z } from \"zod\";\n\n// Proof object schema\nconst ProofSchema = z.object({\n jwt: z.string().min(1, \"JWT must not be empty\"),\n proof_type: z.literal(\"jwt\"), // MUST be \"jwt\"\n});\n\nexport const zCredentialRequest = z\n .object({\n credential_configuration_id: z\n .string()\n .optional()\n .describe(\n \"REQUIRED if credential_identifiers param is absent. MUST NOT be used otherwise.\",\n ),\n\n credential_identifier: z\n .string()\n .optional()\n .describe(\n \"REQUIRED when Authorization Details of type openid_credential was returned. MUST NOT be used if credential_configuration_id is present.\",\n ),\n\n proof: ProofSchema.describe(\n \"REQUIRED. Proof of possession of key material (must contain proof_type=jwt and a jwt).\",\n ),\n\n transaction_id: z\n .string()\n .optional()\n .describe(\n \"REQUIRED only in case of deferred flow. MUST NOT be present in immediate flow.\",\n ),\n })\n .superRefine((data, ctx) => {\n // Exclusive OR between credential_identifier and credential_configuration_id\n if (data.credential_identifier && data.credential_configuration_id) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"credential_identifier and credential_configuration_id MUST NOT be used together\",\n path: [\"credential_identifier\"],\n });\n }\n\n if (!data.credential_identifier && !data.credential_configuration_id) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"One of credential_identifier or credential_configuration_id MUST be present\",\n path: [\"credential_identifier\"],\n });\n }\n });\n\nexport type CredentialRequest = z.infer<typeof zCredentialRequest>;\n\nconst CredentialsSchema = z.object({\n credential: z\n .string()\n .min(1, \"credential must not be empty\")\n .describe(\n \"REQUIRED. Contains the issued Digital Credential. Depending on format, may be raw JWT or base64url-encoded CBOR structure.\",\n ),\n});\n\nexport const zCredentialResponse = z\n .object({\n credentials: CredentialsSchema.optional().describe(\n \"REQUIRED if lead_time and transaction_id are not present. MUST NOT be present otherwise.\",\n ),\n\n lead_time: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\n \"REQUIRED if credentials is not present. MUST NOT be present otherwise.\",\n ),\n\n notification_id: z\n .string()\n .optional()\n .describe(\"OPTIONAL. MUST NOT be present if credentials is not present.\"),\n\n transaction_id: z\n .string()\n .optional()\n .describe(\n \"REQUIRED if credentials is not present. MUST NOT be present otherwise.\",\n ),\n })\n .superRefine((data, ctx) => {\n // Enforce XOR: credentials vs (lead_time + transaction_id)\n if (data.credentials && (data.lead_time || data.transaction_id)) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"credentials MUST NOT be present if lead_time or transaction_id is provided\",\n path: [\"credentials\"],\n });\n }\n\n if (!data.credentials && (!data.lead_time || !data.transaction_id)) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"If credentials is absent, both lead_time and transaction_id MUST be present\",\n path: [\"lead_time\"],\n });\n }\n\n // notification_id must only exist if credentials is present\n if (!data.credentials && data.notification_id) {\n ctx.addIssue({\n code: \"custom\",\n message: \"notification_id MUST NOT be present if credentials is absent\",\n path: [\"notification_id\"],\n });\n }\n });\n\nexport type CredentialResponse = z.infer<typeof zCredentialResponse>;\n","import { CallbackContext } from \"@openid4vc/oauth2\";\nimport { createFetcher, parseWithErrorHandling } from \"@openid4vc/utils\";\nimport {\n CONTENT_TYPES,\n HEADERS,\n UnexpectedStatusCodeError,\n ValidationError,\n hasStatusOrThrow,\n} from \"@pagopa/io-wallet-utils\";\n\nimport { FetchCredentialResponseError } from \"../errors\";\nimport {\n CredentialRequest,\n CredentialResponse,\n zCredentialResponse,\n} from \"./z-credential\";\n\nexport interface FetchCredentialResponseOptions {\n /**\n * Access token to authorize the credential request for DPoP mechanism\n */\n accessToken: string;\n /**\n * Callbacks to use for requesting access token\n */\n callbacks: Pick<CallbackContext, \"fetch\">;\n\n /**\n * The credential endpoint URL\n */\n credentialEndpoint: string;\n\n /**\n * Credential request body\n */\n credentialRequest: CredentialRequest;\n\n /**\n * DPoP proof with addition of ath claim\n */\n dPoP: string;\n}\n\n/**\n * Fetches a credential response from the credential endpoint.\n *\n * @param options - Options for fetching the credential response\n * @returns The credential response\n * @throws FetchCredentialResponseError if an unexpected error occurs during the fetch\n * @throws UnexpectedStatusCodeError if the response status code is not 200\n * @throws ValidationError if the response cannot be parsed as a valid credential response\n */\nexport async function fetchCredentialResponse(\n options: FetchCredentialResponseOptions,\n): Promise<CredentialResponse> {\n try {\n const fetch = createFetcher(options.callbacks.fetch);\n const credentialResponse = await fetch(options.credentialEndpoint, {\n body: JSON.stringify(options.credentialRequest),\n headers: {\n [HEADERS.AUTHORIZATION]: `DPoP ${options.accessToken}`,\n [HEADERS.CONTENT_TYPE]: CONTENT_TYPES.JSON,\n [HEADERS.DPOP]: options.dPoP,\n },\n method: \"POST\",\n });\n\n await hasStatusOrThrow(200, UnexpectedStatusCodeError)(credentialResponse);\n\n return parseWithErrorHandling(\n zCredentialResponse,\n credentialResponse.json(),\n `Failed to parse credential response`,\n );\n } catch (error) {\n if (\n error instanceof UnexpectedStatusCodeError ||\n error instanceof ValidationError\n ) {\n throw error;\n }\n throw new FetchCredentialResponseError(\n `Unexpected error during credential response: ${error instanceof Error ? error.message : String(error)}`,\n );\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":";AACA,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,0BAA0B;AACnC;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACPA,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;AAKO,IAAM,+BAAN,cAA2C,aAAa;AAAA,EAC7D,YACE,SACgB,eAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACqBA,eAAsB,4BACpB,SACgC;AAChC,MAAI,QAAQ,sBAAsB,QAAQ,QAAQ;AAChD,UAAM,IAAI;AAAA,MACR,mEAAmE,QAAQ,GAAG,UAAU,QAAQ,sBAAsB,GAAG;AAAA,IAC3H;AACF,MAAI,QAAQ,sBAAsB,UAAU,QAAQ;AAClD,UAAM,IAAI;AAAA,MACR,qEAAqE,QAAQ,KAAK,UAAU,QAAQ,sBAAsB,KA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;AAAA,QACtC,CAAC,QAAQ,IAAI,GAAG,QAAQ;AAAA,MAC1B;AAAA,MACA,QAAQ;AAAA,IACV,CAAC;AAED,UAAMC,kBAAiB,KAAKC,0BAAyB,EAAE,kBAAkB;AAEzE,WAAOC;AAAA,MACL;AAAA,MACA,mBAAmB,KAAK;AAAA,MACxB;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,QACE,iBAAiBD,8BACjB,iBAAiBE,kBACjB;AACA,YAAM;AAAA,IACR;AACA,UAAM,IAAI;AAAA,MACR,gDAAgD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IACxG;AAAA,EACF;AACF;;;ACpFA,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":["z","createFetcher","parseWithErrorHandling","UnexpectedStatusCodeError","ValidationError","hasStatusOrThrow","createFetcher","hasStatusOrThrow","UnexpectedStatusCodeError","parseWithErrorHandling","ValidationError"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/io-wallet-oid4vci",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -31,9 +31,9 @@
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.7.1",
35
- "@pagopa/io-wallet-oauth2": "0.7.1",
36
- "@pagopa/io-wallet-oid4vp": "0.7.1"
34
+ "@pagopa/io-wallet-utils": "0.7.3",
35
+ "@pagopa/io-wallet-oauth2": "0.7.3",
36
+ "@pagopa/io-wallet-oid4vp": "0.7.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "js-base64": "^3.7.8"