@pagopa/io-wallet-oid4vci 1.5.1 → 1.5.2

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
@@ -326,23 +326,27 @@ interface BaseResolveCredentialOfferOptions {
326
326
  */
327
327
  credentialOffer: string;
328
328
  }
329
+ /**
330
+ * Options for resolving a credential offer.
331
+ *
332
+ * Accepts a runtime-selected SDK config and defers version support checks to
333
+ * the credential offer parser.
334
+ */
335
+ interface ResolveCredentialOfferOptions extends BaseResolveCredentialOfferOptions {
336
+ config: IoWalletSdkConfig;
337
+ }
329
338
  /**
330
339
  * Options for resolving a credential offer against the IT-Wallet v1.3 schema.
331
340
  */
332
- interface ResolveCredentialOfferOptionsV1_3 extends BaseResolveCredentialOfferOptions {
341
+ interface ResolveCredentialOfferOptionsV1_3 extends ResolveCredentialOfferOptions {
333
342
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_3>;
334
343
  }
335
344
  /**
336
345
  * Options for resolving a credential offer against the IT-Wallet v1.4 schema.
337
346
  */
338
- interface ResolveCredentialOfferOptionsV1_4 extends BaseResolveCredentialOfferOptions {
347
+ interface ResolveCredentialOfferOptionsV1_4 extends ResolveCredentialOfferOptions {
339
348
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_4>;
340
349
  }
341
- /**
342
- * Options for resolving a credential offer.
343
- * The configured version selects the schema used to parse the offer.
344
- */
345
- type ResolveCredentialOfferOptions = ResolveCredentialOfferOptionsV1_3 | ResolveCredentialOfferOptionsV1_4;
346
350
  /**
347
351
  * Base options shared across all validate-credential-offer versions.
348
352
  */
@@ -363,14 +367,24 @@ interface BaseValidateCredentialOfferOptions {
363
367
  * ]
364
368
  * };
365
369
  */
366
- credentialIssuerMetadata?: {
370
+ credentialIssuerMetadata: {
367
371
  authorization_servers?: [string, ...string[]];
368
372
  };
369
373
  }
374
+ /**
375
+ * Options for validating a credential offer against the configured IT-Wallet specification.
376
+ */
377
+ interface ValidateCredentialOfferOptions extends BaseValidateCredentialOfferOptions {
378
+ config: IoWalletSdkConfig;
379
+ /**
380
+ * The credential offer to validate against the configured IT-Wallet specification.
381
+ */
382
+ credentialOffer: CredentialOfferV1_3 | CredentialOfferV1_4;
383
+ }
370
384
  /**
371
385
  * Options for validating an IT-Wallet v1.3 credential offer.
372
386
  */
373
- interface ValidateCredentialOfferOptionsV1_3 extends BaseValidateCredentialOfferOptions {
387
+ interface ValidateCredentialOfferOptionsV1_3 extends ValidateCredentialOfferOptions {
374
388
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_3>;
375
389
  /**
376
390
  * The credential offer to validate against IT-Wallet v1.3 specifications.
@@ -380,7 +394,7 @@ interface ValidateCredentialOfferOptionsV1_3 extends BaseValidateCredentialOffer
380
394
  /**
381
395
  * Options for validating an IT-Wallet v1.4 credential offer.
382
396
  */
383
- interface ValidateCredentialOfferOptionsV1_4 extends BaseValidateCredentialOfferOptions {
397
+ interface ValidateCredentialOfferOptionsV1_4 extends ValidateCredentialOfferOptions {
384
398
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_4>;
385
399
  /**
386
400
  * The credential offer to validate against IT-Wallet v1.4 specifications.
@@ -388,13 +402,19 @@ interface ValidateCredentialOfferOptionsV1_4 extends BaseValidateCredentialOffer
388
402
  credentialOffer: CredentialOfferV1_4;
389
403
  }
390
404
  /**
391
- * Options for validating a credential offer against IT-Wallet specifications.
405
+ * Options for extracting grant details from a credential offer.
392
406
  */
393
- type ValidateCredentialOfferOptions = ValidateCredentialOfferOptionsV1_3 | ValidateCredentialOfferOptionsV1_4;
407
+ interface ExtractGrantDetailsOptions {
408
+ config: IoWalletSdkConfig;
409
+ /**
410
+ * The credential offer to extract grant details from.
411
+ */
412
+ credentialOffer: CredentialOfferV1_3 | CredentialOfferV1_4;
413
+ }
394
414
  /**
395
415
  * Options for extracting grant details from an IT-Wallet v1.3 credential offer.
396
416
  */
397
- interface ExtractGrantDetailsOptionsV1_3 {
417
+ interface ExtractGrantDetailsOptionsV1_3 extends ExtractGrantDetailsOptions {
398
418
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_3>;
399
419
  /**
400
420
  * The credential offer to extract grant details from.
@@ -404,17 +424,13 @@ interface ExtractGrantDetailsOptionsV1_3 {
404
424
  /**
405
425
  * Options for extracting grant details from an IT-Wallet v1.4 credential offer.
406
426
  */
407
- interface ExtractGrantDetailsOptionsV1_4 {
427
+ interface ExtractGrantDetailsOptionsV1_4 extends ExtractGrantDetailsOptions {
408
428
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_4>;
409
429
  /**
410
430
  * The credential offer to extract grant details from.
411
431
  */
412
432
  credentialOffer: CredentialOfferV1_4;
413
433
  }
414
- /**
415
- * Options for extracting grant details from a credential offer.
416
- */
417
- type ExtractGrantDetailsOptions = ExtractGrantDetailsOptionsV1_3 | ExtractGrantDetailsOptionsV1_4;
418
434
  /**
419
435
  * Result of extracting grant details from an IT-Wallet v1.3 credential offer.
420
436
  */
@@ -466,6 +482,12 @@ interface ExtractGrantDetailsResultV1_4 {
466
482
  * OPTIONAL. Used to correlate the authorization request with the credential offer.
467
483
  */
468
484
  issuerState?: string;
485
+ /**
486
+ * Version 1.4 has dropped support for the scope field,
487
+ * But typescript inference might have trouble recognizing this fact
488
+ * in its union type, so this is needed
489
+ */
490
+ scope?: never;
469
491
  };
470
492
  /**
471
493
  * The type of grant present in the credential offer.
@@ -497,6 +519,7 @@ type ExtractGrantDetailsResult = ExtractGrantDetailsResultV1_3 | ExtractGrantDet
497
519
  */
498
520
  declare function extractGrantDetails(options: ExtractGrantDetailsOptionsV1_3): ExtractGrantDetailsResultV1_3;
499
521
  declare function extractGrantDetails(options: ExtractGrantDetailsOptionsV1_4): ExtractGrantDetailsResultV1_4;
522
+ declare function extractGrantDetails(options: ExtractGrantDetailsOptions): ExtractGrantDetailsResult;
500
523
 
501
524
  /**
502
525
  * Parses a credential offer URI and extracts the scheme and parameters.
@@ -596,6 +619,7 @@ declare function parseCredentialOfferUri(options: ParseCredentialOfferUriOptions
596
619
  */
597
620
  declare function resolveCredentialOffer(options: ResolveCredentialOfferOptionsV1_3): Promise<CredentialOfferV1_3>;
598
621
  declare function resolveCredentialOffer(options: ResolveCredentialOfferOptionsV1_4): Promise<CredentialOfferV1_4>;
622
+ declare function resolveCredentialOffer(options: ResolveCredentialOfferOptions): Promise<CredentialOffer>;
599
623
 
600
624
  /**
601
625
  * Validates a credential offer against IT-Wallet specifications for the configured version.
package/dist/index.d.ts CHANGED
@@ -326,23 +326,27 @@ interface BaseResolveCredentialOfferOptions {
326
326
  */
327
327
  credentialOffer: string;
328
328
  }
329
+ /**
330
+ * Options for resolving a credential offer.
331
+ *
332
+ * Accepts a runtime-selected SDK config and defers version support checks to
333
+ * the credential offer parser.
334
+ */
335
+ interface ResolveCredentialOfferOptions extends BaseResolveCredentialOfferOptions {
336
+ config: IoWalletSdkConfig;
337
+ }
329
338
  /**
330
339
  * Options for resolving a credential offer against the IT-Wallet v1.3 schema.
331
340
  */
332
- interface ResolveCredentialOfferOptionsV1_3 extends BaseResolveCredentialOfferOptions {
341
+ interface ResolveCredentialOfferOptionsV1_3 extends ResolveCredentialOfferOptions {
333
342
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_3>;
334
343
  }
335
344
  /**
336
345
  * Options for resolving a credential offer against the IT-Wallet v1.4 schema.
337
346
  */
338
- interface ResolveCredentialOfferOptionsV1_4 extends BaseResolveCredentialOfferOptions {
347
+ interface ResolveCredentialOfferOptionsV1_4 extends ResolveCredentialOfferOptions {
339
348
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_4>;
340
349
  }
341
- /**
342
- * Options for resolving a credential offer.
343
- * The configured version selects the schema used to parse the offer.
344
- */
345
- type ResolveCredentialOfferOptions = ResolveCredentialOfferOptionsV1_3 | ResolveCredentialOfferOptionsV1_4;
346
350
  /**
347
351
  * Base options shared across all validate-credential-offer versions.
348
352
  */
@@ -363,14 +367,24 @@ interface BaseValidateCredentialOfferOptions {
363
367
  * ]
364
368
  * };
365
369
  */
366
- credentialIssuerMetadata?: {
370
+ credentialIssuerMetadata: {
367
371
  authorization_servers?: [string, ...string[]];
368
372
  };
369
373
  }
374
+ /**
375
+ * Options for validating a credential offer against the configured IT-Wallet specification.
376
+ */
377
+ interface ValidateCredentialOfferOptions extends BaseValidateCredentialOfferOptions {
378
+ config: IoWalletSdkConfig;
379
+ /**
380
+ * The credential offer to validate against the configured IT-Wallet specification.
381
+ */
382
+ credentialOffer: CredentialOfferV1_3 | CredentialOfferV1_4;
383
+ }
370
384
  /**
371
385
  * Options for validating an IT-Wallet v1.3 credential offer.
372
386
  */
373
- interface ValidateCredentialOfferOptionsV1_3 extends BaseValidateCredentialOfferOptions {
387
+ interface ValidateCredentialOfferOptionsV1_3 extends ValidateCredentialOfferOptions {
374
388
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_3>;
375
389
  /**
376
390
  * The credential offer to validate against IT-Wallet v1.3 specifications.
@@ -380,7 +394,7 @@ interface ValidateCredentialOfferOptionsV1_3 extends BaseValidateCredentialOffer
380
394
  /**
381
395
  * Options for validating an IT-Wallet v1.4 credential offer.
382
396
  */
383
- interface ValidateCredentialOfferOptionsV1_4 extends BaseValidateCredentialOfferOptions {
397
+ interface ValidateCredentialOfferOptionsV1_4 extends ValidateCredentialOfferOptions {
384
398
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_4>;
385
399
  /**
386
400
  * The credential offer to validate against IT-Wallet v1.4 specifications.
@@ -388,13 +402,19 @@ interface ValidateCredentialOfferOptionsV1_4 extends BaseValidateCredentialOffer
388
402
  credentialOffer: CredentialOfferV1_4;
389
403
  }
390
404
  /**
391
- * Options for validating a credential offer against IT-Wallet specifications.
405
+ * Options for extracting grant details from a credential offer.
392
406
  */
393
- type ValidateCredentialOfferOptions = ValidateCredentialOfferOptionsV1_3 | ValidateCredentialOfferOptionsV1_4;
407
+ interface ExtractGrantDetailsOptions {
408
+ config: IoWalletSdkConfig;
409
+ /**
410
+ * The credential offer to extract grant details from.
411
+ */
412
+ credentialOffer: CredentialOfferV1_3 | CredentialOfferV1_4;
413
+ }
394
414
  /**
395
415
  * Options for extracting grant details from an IT-Wallet v1.3 credential offer.
396
416
  */
397
- interface ExtractGrantDetailsOptionsV1_3 {
417
+ interface ExtractGrantDetailsOptionsV1_3 extends ExtractGrantDetailsOptions {
398
418
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_3>;
399
419
  /**
400
420
  * The credential offer to extract grant details from.
@@ -404,17 +424,13 @@ interface ExtractGrantDetailsOptionsV1_3 {
404
424
  /**
405
425
  * Options for extracting grant details from an IT-Wallet v1.4 credential offer.
406
426
  */
407
- interface ExtractGrantDetailsOptionsV1_4 {
427
+ interface ExtractGrantDetailsOptionsV1_4 extends ExtractGrantDetailsOptions {
408
428
  config: IoWalletSdkConfig<ItWalletSpecsVersion.V1_4>;
409
429
  /**
410
430
  * The credential offer to extract grant details from.
411
431
  */
412
432
  credentialOffer: CredentialOfferV1_4;
413
433
  }
414
- /**
415
- * Options for extracting grant details from a credential offer.
416
- */
417
- type ExtractGrantDetailsOptions = ExtractGrantDetailsOptionsV1_3 | ExtractGrantDetailsOptionsV1_4;
418
434
  /**
419
435
  * Result of extracting grant details from an IT-Wallet v1.3 credential offer.
420
436
  */
@@ -466,6 +482,12 @@ interface ExtractGrantDetailsResultV1_4 {
466
482
  * OPTIONAL. Used to correlate the authorization request with the credential offer.
467
483
  */
468
484
  issuerState?: string;
485
+ /**
486
+ * Version 1.4 has dropped support for the scope field,
487
+ * But typescript inference might have trouble recognizing this fact
488
+ * in its union type, so this is needed
489
+ */
490
+ scope?: never;
469
491
  };
470
492
  /**
471
493
  * The type of grant present in the credential offer.
@@ -497,6 +519,7 @@ type ExtractGrantDetailsResult = ExtractGrantDetailsResultV1_3 | ExtractGrantDet
497
519
  */
498
520
  declare function extractGrantDetails(options: ExtractGrantDetailsOptionsV1_3): ExtractGrantDetailsResultV1_3;
499
521
  declare function extractGrantDetails(options: ExtractGrantDetailsOptionsV1_4): ExtractGrantDetailsResultV1_4;
522
+ declare function extractGrantDetails(options: ExtractGrantDetailsOptions): ExtractGrantDetailsResult;
500
523
 
501
524
  /**
502
525
  * Parses a credential offer URI and extracts the scheme and parameters.
@@ -596,6 +619,7 @@ declare function parseCredentialOfferUri(options: ParseCredentialOfferUriOptions
596
619
  */
597
620
  declare function resolveCredentialOffer(options: ResolveCredentialOfferOptionsV1_3): Promise<CredentialOfferV1_3>;
598
621
  declare function resolveCredentialOffer(options: ResolveCredentialOfferOptionsV1_4): Promise<CredentialOfferV1_4>;
622
+ declare function resolveCredentialOffer(options: ResolveCredentialOfferOptions): Promise<CredentialOffer>;
599
623
 
600
624
  /**
601
625
  * Validates a credential offer against IT-Wallet specifications for the configured version.
package/dist/index.js CHANGED
@@ -1617,19 +1617,14 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
1617
1617
  parsedSelectedAuthorizationServer.data,
1618
1618
  verifyJwt4
1619
1619
  );
1620
- const resolvedAuthorizationServer = authorizationServerResult?.metadata?.oauth_authorization_server;
1621
- if (!resolvedAuthorizationServer) {
1620
+ if (!authorizationServerResult) {
1622
1621
  throw new import_io_wallet_utils16.ValidationError(
1623
- `Federation discovery did not yield oauth_authorization_server metadata for authorization server '${selectedAuthorizationServer}'`
1622
+ `Federation discovery did not yield OpenID Federation metadata for authorization server '${selectedAuthorizationServer}'`
1624
1623
  );
1625
1624
  }
1626
1625
  return {
1627
1626
  ...federationResult,
1628
- authorization_server_federation_claims: authorizationServerResult.openid_federation_claims,
1629
- metadata: {
1630
- ...federationResult.metadata,
1631
- oauth_authorization_server: resolvedAuthorizationServer
1632
- }
1627
+ authorization_server_federation_claims: authorizationServerResult.openid_federation_claims
1633
1628
  };
1634
1629
  }
1635
1630
  async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {