@openid4vc/openid4vci 0.3.0 → 0.3.1-alpha-20251124151046

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.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ContentType, Fetch, FetchHeaders, HttpMethod, InferOutputUnion, Oid4vcTsConfig, OrPromise, StringWithAutoCompletion, getGlobalConfig, setGlobalConfig } from "@openid4vc/utils";
2
- import * as _openid4vc_oauth28 from "@openid4vc/oauth2";
2
+ import * as _openid4vc_oauth20 from "@openid4vc/oauth2";
3
3
  import { AuthorizationCodeGrantIdentifier, AuthorizationServerMetadata, CallbackContext, CreateAuthorizationRequestUrlOptions, CreateClientAttestationJwtOptions, CreatePkceReturn, DecodeJwtResult, Jwk, JwtSigner, JwtSignerWithJwk, PreAuthorizedCodeGrantIdentifier, RequestDpopOptions, ResourceRequestResponseNotOk, ResourceRequestResponseOk, RetrieveAuthorizationCodeAccessTokenOptions, RetrievePreAuthorizedCodeAccessTokenOptions, authorizationCodeGrantIdentifier, preAuthorizedCodeGrantIdentifier } from "@openid4vc/oauth2";
4
4
  import * as zod0 from "zod";
5
5
  import z from "zod";
@@ -2643,7 +2643,7 @@ interface ParseKeyAttestationJwtOptions {
2643
2643
  declare function parseKeyAttestationJwt({
2644
2644
  keyAttestationJwt,
2645
2645
  use
2646
- }: ParseKeyAttestationJwtOptions): _openid4vc_oauth28.DecodeJwtResult<zod0.ZodObject<{
2646
+ }: ParseKeyAttestationJwtOptions): _openid4vc_oauth20.DecodeJwtResult<zod0.ZodObject<{
2647
2647
  typ: zod0.ZodUnion<[zod0.ZodLiteral<"keyattestation+jwt">, zod0.ZodLiteral<"key-attestation+jwt">]>;
2648
2648
  alg: zod0.ZodString;
2649
2649
  kid: zod0.ZodOptional<zod0.ZodString>;
@@ -2917,7 +2917,7 @@ declare function verifyKeyAttestationJwt(options: VerifyKeyAttestationJwtOptions
2917
2917
  status?: Record<string, any> | undefined;
2918
2918
  trust_chain?: [string, ...string[]] | undefined;
2919
2919
  };
2920
- signer: _openid4vc_oauth28.JwtSignerWithJwk;
2920
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
2921
2921
  }>;
2922
2922
  //#endregion
2923
2923
  //#region src/metadata/credential-issuer/credential-configurations.d.ts
@@ -3081,7 +3081,7 @@ declare class Openid4vciClient {
3081
3081
  };
3082
3082
  dpop: {
3083
3083
  nonce: string | undefined;
3084
- signer: _openid4vc_oauth28.JwtSignerJwk;
3084
+ signer: _openid4vc_oauth20.JwtSignerJwk;
3085
3085
  } | undefined;
3086
3086
  }>;
3087
3087
  /**
@@ -3140,7 +3140,7 @@ declare class Openid4vciClient {
3140
3140
  issuerMetadata: IssuerMetadataResult;
3141
3141
  }): Promise<{
3142
3142
  authorizationServer: string;
3143
- accessTokenResponse: _openid4vc_oauth28.AccessTokenResponse;
3143
+ accessTokenResponse: _openid4vc_oauth20.AccessTokenResponse;
3144
3144
  dpop?: RequestDpopOptions;
3145
3145
  }>;
3146
3146
  /**
@@ -3160,7 +3160,7 @@ declare class Openid4vciClient {
3160
3160
  issuerMetadata: IssuerMetadataResult;
3161
3161
  }): Promise<{
3162
3162
  authorizationServer: string;
3163
- accessTokenResponse: _openid4vc_oauth28.AccessTokenResponse;
3163
+ accessTokenResponse: _openid4vc_oauth20.AccessTokenResponse;
3164
3164
  dpop?: RequestDpopOptions;
3165
3165
  }>;
3166
3166
  /**
@@ -3215,7 +3215,7 @@ declare class Openid4vciClient {
3215
3215
  additionalRequestPayload,
3216
3216
  accessToken,
3217
3217
  dpop
3218
- }: Pick<SendNotificationOptions, 'accessToken' | 'additionalRequestPayload' | 'issuerMetadata' | 'dpop' | 'notification'>): Promise<_openid4vc_oauth28.ResourceRequestResponseOk>;
3218
+ }: Pick<SendNotificationOptions, 'accessToken' | 'additionalRequestPayload' | 'issuerMetadata' | 'dpop' | 'notification'>): Promise<_openid4vc_oauth20.ResourceRequestResponseOk>;
3219
3219
  }
3220
3220
  //#endregion
3221
3221
  //#region ../oauth2/src/common/jwk/z-jwk.d.ts
@@ -3901,7 +3901,7 @@ declare class Openid4vciIssuer {
3901
3901
  status?: Record<string, any> | undefined;
3902
3902
  trust_chain?: [string, ...string[]] | undefined;
3903
3903
  };
3904
- signer: _openid4vc_oauth28.JwtSignerWithJwk;
3904
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
3905
3905
  keyAttestation: {
3906
3906
  header: {
3907
3907
  [x: string]: unknown;
@@ -4024,7 +4024,7 @@ declare class Openid4vciIssuer {
4024
4024
  status?: Record<string, any> | undefined;
4025
4025
  trust_chain?: [string, ...string[]] | undefined;
4026
4026
  };
4027
- signer: _openid4vc_oauth28.JwtSignerWithJwk;
4027
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
4028
4028
  } | undefined;
4029
4029
  }>;
4030
4030
  /**
@@ -4155,7 +4155,7 @@ declare class Openid4vciIssuer {
4155
4155
  status?: Record<string, any> | undefined;
4156
4156
  trust_chain?: [string, ...string[]] | undefined;
4157
4157
  };
4158
- signer: _openid4vc_oauth28.JwtSignerWithJwk;
4158
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
4159
4159
  }>;
4160
4160
  /**
4161
4161
  * @throws Oauth2ServerErrorResponseError - when validation of the credential request fails
@@ -4291,7 +4291,7 @@ declare class Openid4vciIssuer {
4291
4291
  status?: Record<string, any> | undefined;
4292
4292
  trust_chain?: [string, ...string[]] | undefined;
4293
4293
  };
4294
- signer: _openid4vc_oauth28.JwtSignerWithJwk;
4294
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
4295
4295
  };
4296
4296
  clientAttestationPop: {
4297
4297
  header: {
@@ -4381,7 +4381,7 @@ declare class Openid4vciIssuer {
4381
4381
  status?: Record<string, any> | undefined;
4382
4382
  trust_chain?: [string, ...string[]] | undefined;
4383
4383
  };
4384
- signer: _openid4vc_oauth28.JwtSignerWithJwk;
4384
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
4385
4385
  };
4386
4386
  }>;
4387
4387
  }
package/dist/index.mjs CHANGED
@@ -44,7 +44,7 @@ const zCredentialOfferObjectDraft11To14 = z.object({
44
44
  user_pin_required: z.optional(z.boolean())
45
45
  }).loose().optional()
46
46
  }))
47
- }).loose().transform(({ credentials, grants,...rest }) => {
47
+ }).loose().transform(({ credentials, grants, ...rest }) => {
48
48
  const v14 = {
49
49
  ...rest,
50
50
  credential_configuration_ids: credentials
@@ -52,7 +52,7 @@ const zCredentialOfferObjectDraft11To14 = z.object({
52
52
  if (grants) {
53
53
  v14.grants = { ...grants };
54
54
  if (grants[preAuthorizedCodeGrantIdentifier]) {
55
- const { user_pin_required,...restGrants } = grants[preAuthorizedCodeGrantIdentifier];
55
+ const { user_pin_required, ...restGrants } = grants[preAuthorizedCodeGrantIdentifier];
56
56
  v14.grants[preAuthorizedCodeGrantIdentifier] = { ...restGrants };
57
57
  if (user_pin_required) v14.grants[preAuthorizedCodeGrantIdentifier].tx_code = { input_mode: "text" };
58
58
  }
@@ -101,7 +101,7 @@ function determineAuthorizationServerForCredentialOffer(options) {
101
101
  return authorizationServer;
102
102
  }
103
103
  async function createCredentialOffer(options) {
104
- const { [preAuthorizedCodeGrantIdentifier]: preAuthorizedCodeGrant, [authorizationCodeGrantIdentifier]: authorizationCodeGrant,...restGrants } = options.grants;
104
+ const { [preAuthorizedCodeGrantIdentifier]: preAuthorizedCodeGrant, [authorizationCodeGrantIdentifier]: authorizationCodeGrant, ...restGrants } = options.grants;
105
105
  const grants = { ...restGrants };
106
106
  if (authorizationCodeGrant) {
107
107
  determineAuthorizationServerForCredentialOffer({
@@ -492,14 +492,14 @@ const zJwtVcJsonCredentialIssuerMetadataDraft11 = z.object({
492
492
  types: z.tuple([z.string()], z.string()),
493
493
  credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
494
494
  }).loose();
495
- const zJwtVcJsonCredentialIssuerMetadataDraft11To14 = zJwtVcJsonCredentialIssuerMetadataDraft11.transform(({ types, credentialSubject,...rest }) => ({
495
+ const zJwtVcJsonCredentialIssuerMetadataDraft11To14 = zJwtVcJsonCredentialIssuerMetadataDraft11.transform(({ types, credentialSubject, ...rest }) => ({
496
496
  ...rest,
497
497
  credential_definition: {
498
498
  type: types,
499
499
  ...credentialSubject ? { credentialSubject } : {}
500
500
  }
501
501
  }));
502
- const zJwtVcJsonCredentialIssuerMetadataDraft14To11 = zJwtVcJsonCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type,...credentialDefinition },...rest }) => ({
502
+ const zJwtVcJsonCredentialIssuerMetadataDraft14To11 = zJwtVcJsonCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type, ...credentialDefinition }, ...rest }) => ({
503
503
  ...rest,
504
504
  types: type,
505
505
  ...credentialDefinition
@@ -513,7 +513,7 @@ const zJwtVcJsonCredentialRequestDraft11 = z.object({
513
513
  types: z.tuple([z.string()], z.string()),
514
514
  credentialSubject: z.optional(zW3cVcCredentialSubjectDraft14)
515
515
  }).loose();
516
- const zJwtVcJsonCredentialRequestDraft11To14 = zJwtVcJsonCredentialRequestDraft11.transform(({ types, credentialSubject,...rest }) => {
516
+ const zJwtVcJsonCredentialRequestDraft11To14 = zJwtVcJsonCredentialRequestDraft11.transform(({ types, credentialSubject, ...rest }) => {
517
517
  return {
518
518
  ...rest,
519
519
  credential_definition: {
@@ -522,7 +522,7 @@ const zJwtVcJsonCredentialRequestDraft11To14 = zJwtVcJsonCredentialRequestDraft1
522
522
  }
523
523
  };
524
524
  });
525
- const zJwtVcJsonCredentialRequestDraft14To11 = zJwtVcJsonCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type,...credentialDefinition },...rest }) => ({
525
+ const zJwtVcJsonCredentialRequestDraft14To11 = zJwtVcJsonCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type, ...credentialDefinition }, ...rest }) => ({
526
526
  ...rest,
527
527
  types: type,
528
528
  ...credentialDefinition
@@ -554,7 +554,7 @@ const zJwtVcJsonLdCredentialIssuerMetadataDraft11 = z.object({
554
554
  types: z.tuple([z.string()], z.string()),
555
555
  credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
556
556
  }).loose();
557
- const zJwtVcJsonLdCredentialIssuerMetadataDraft11To14 = zJwtVcJsonLdCredentialIssuerMetadataDraft11.transform(({ "@context": context, types, credentialSubject,...rest }) => ({
557
+ const zJwtVcJsonLdCredentialIssuerMetadataDraft11To14 = zJwtVcJsonLdCredentialIssuerMetadataDraft11.transform(({ "@context": context, types, credentialSubject, ...rest }) => ({
558
558
  ...rest,
559
559
  credential_definition: {
560
560
  "@context": context,
@@ -562,7 +562,7 @@ const zJwtVcJsonLdCredentialIssuerMetadataDraft11To14 = zJwtVcJsonLdCredentialIs
562
562
  ...credentialSubject ? { credentialSubject } : {}
563
563
  }
564
564
  }));
565
- const zJwtVcJsonLdCredentialIssuerMetadataDraft14To11 = zJwtVcJsonLdCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type,...credentialDefinition },...rest }) => ({
565
+ const zJwtVcJsonLdCredentialIssuerMetadataDraft14To11 = zJwtVcJsonLdCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type, ...credentialDefinition }, ...rest }) => ({
566
566
  ...rest,
567
567
  ...credentialDefinition,
568
568
  types: type
@@ -579,14 +579,14 @@ const zJwtVcJsonLdCredentialRequestDraft11 = z.object({
579
579
  credentialSubject: z.optional(zW3cVcCredentialSubjectDraft14)
580
580
  }).loose()
581
581
  }).loose();
582
- const zJwtVcJsonLdCredentialRequestDraft11To14 = zJwtVcJsonLdCredentialRequestDraft11.transform(({ credential_definition: { types,...restCredentialDefinition },...rest }) => ({
582
+ const zJwtVcJsonLdCredentialRequestDraft11To14 = zJwtVcJsonLdCredentialRequestDraft11.transform(({ credential_definition: { types, ...restCredentialDefinition }, ...rest }) => ({
583
583
  ...rest,
584
584
  credential_definition: {
585
585
  ...restCredentialDefinition,
586
586
  type: types
587
587
  }
588
588
  }));
589
- const zJwtVcJsonLdCredentialRequestDraft14To11 = zJwtVcJsonLdCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type,...restCredentialDefinition },...rest }) => ({
589
+ const zJwtVcJsonLdCredentialRequestDraft14To11 = zJwtVcJsonLdCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type, ...restCredentialDefinition }, ...rest }) => ({
590
590
  ...rest,
591
591
  credential_definition: {
592
592
  ...restCredentialDefinition,
@@ -620,7 +620,7 @@ const zLdpVcCredentialIssuerMetadataDraft11 = z.object({
620
620
  types: z.tuple([z.string()], z.string()),
621
621
  credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
622
622
  }).loose();
623
- const zLdpVcCredentialIssuerMetadataDraft11To14 = zLdpVcCredentialIssuerMetadataDraft11.transform(({ "@context": context, types, credentialSubject,...rest }) => ({
623
+ const zLdpVcCredentialIssuerMetadataDraft11To14 = zLdpVcCredentialIssuerMetadataDraft11.transform(({ "@context": context, types, credentialSubject, ...rest }) => ({
624
624
  ...rest,
625
625
  credential_definition: {
626
626
  "@context": context,
@@ -628,7 +628,7 @@ const zLdpVcCredentialIssuerMetadataDraft11To14 = zLdpVcCredentialIssuerMetadata
628
628
  ...credentialSubject ? { credentialSubject } : {}
629
629
  }
630
630
  }));
631
- const zLdpVcCredentialIssuerMetadataDraft14To11 = zLdpVcCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type,...credentialDefinition },...rest }) => ({
631
+ const zLdpVcCredentialIssuerMetadataDraft14To11 = zLdpVcCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type, ...credentialDefinition }, ...rest }) => ({
632
632
  ...rest,
633
633
  ...credentialDefinition,
634
634
  types: type
@@ -645,14 +645,14 @@ const zLdpVcCredentialRequestDraft11 = z.object({
645
645
  credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
646
646
  })
647
647
  }).loose();
648
- const zLdpVcCredentialRequestDraft11To14 = zLdpVcCredentialRequestDraft11.transform(({ credential_definition: { types,...restCredentialDefinition },...rest }) => ({
648
+ const zLdpVcCredentialRequestDraft11To14 = zLdpVcCredentialRequestDraft11.transform(({ credential_definition: { types, ...restCredentialDefinition }, ...rest }) => ({
649
649
  ...rest,
650
650
  credential_definition: {
651
651
  ...restCredentialDefinition,
652
652
  type: types
653
653
  }
654
654
  }));
655
- const zLdpVcCredentialRequestDraft14To11 = zLdpVcCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type,...restCredentialDefinition },...rest }) => ({
655
+ const zLdpVcCredentialRequestDraft14To11 = zLdpVcCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type, ...restCredentialDefinition }, ...rest }) => ({
656
656
  ...rest,
657
657
  credential_definition: {
658
658
  ...restCredentialDefinition,
@@ -750,13 +750,13 @@ const zCredentialConfigurationSupportedDraft11ToV1 = z.object({
750
750
  background_image: z.object({ url: zHttpsUrl.or(zDataUrl).optional() }).loose().optional()
751
751
  }).loose()).optional(),
752
752
  claims: z.any().optional()
753
- }).loose().transform(({ cryptographic_suites_supported, display, claims, id, format,...rest }) => ({
753
+ }).loose().transform(({ cryptographic_suites_supported, display, claims, id, format, ...rest }) => ({
754
754
  ...rest,
755
755
  format,
756
756
  ...cryptographic_suites_supported ? { credential_signing_alg_values_supported: format === zMsoMdocFormatIdentifier.value ? jwaSignatureAlgorithmArrayToFullySpecifiedCoseAlgorithmArray(cryptographic_suites_supported) : cryptographic_suites_supported } : {},
757
757
  ...claims || display ? { credential_metadata: {
758
758
  ...claims ? { claims } : {},
759
- ...display ? { display: display.map(({ logo, background_image,...displayRest }) => ({
759
+ ...display ? { display: display.map(({ logo, background_image, ...displayRest }) => ({
760
760
  ...displayRest,
761
761
  ...logo?.url ? { logo: { uri: logo.url } } : {},
762
762
  ...background_image?.url ? { background_image: { uri: background_image.url } } : {}
@@ -777,16 +777,16 @@ const zCredentialConfigurationSupportedDraft11ToV1 = z.object({
777
777
  });
778
778
  return z.NEVER;
779
779
  }).pipe(zCredentialConfigurationSupportedWithFormats);
780
- const zCredentialConfigurationSupportedV1ToDraft11 = zCredentialConfigurationSupportedWithFormats.transform(({ credential_metadata,...rest }) => ({
780
+ const zCredentialConfigurationSupportedV1ToDraft11 = zCredentialConfigurationSupportedWithFormats.transform(({ credential_metadata, ...rest }) => ({
781
781
  ...credential_metadata,
782
782
  ...rest
783
- })).and(z.object({ id: z.string() }).loose()).transform(({ id, credential_signing_alg_values_supported, display, proof_types_supported, scope, format,...rest }) => ({
783
+ })).and(z.object({ id: z.string() }).loose()).transform(({ id, credential_signing_alg_values_supported, display, proof_types_supported, scope, format, ...rest }) => ({
784
784
  ...rest,
785
785
  format,
786
786
  ...credential_signing_alg_values_supported ? { cryptographic_suites_supported: format === zMsoMdocFormatIdentifier.value && typeof credential_signing_alg_values_supported[0] === "number" ? fullySpecifiedCoseAlgorithmArrayToJwaSignatureAlgorithmArray(credential_signing_alg_values_supported) : credential_signing_alg_values_supported } : {},
787
- ...display ? { display: display.map(({ logo, background_image,...displayRest }) => {
788
- const { uri: logoUri,...logoRest } = logo ?? {};
789
- const { uri: backgroundImageUri,...backgroundImageRest } = background_image ?? {};
787
+ ...display ? { display: display.map(({ logo, background_image, ...displayRest }) => {
788
+ const { uri: logoUri, ...logoRest } = logo ?? {};
789
+ const { uri: backgroundImageUri, ...backgroundImageRest } = background_image ?? {};
790
790
  return {
791
791
  ...displayRest,
792
792
  ...logoUri ? { logo: {
@@ -813,7 +813,7 @@ const zCredentialConfigurationSupportedV1ToDraft11 = zCredentialConfigurationSup
813
813
  const zCredentialIssuerMetadataDraft11ToV1 = z.object({
814
814
  authorization_server: z.string().optional(),
815
815
  credentials_supported: z.array(z.object({ id: z.string().optional() }).loose())
816
- }).loose().transform(({ authorization_server, credentials_supported,...rest }) => {
816
+ }).loose().transform(({ authorization_server, credentials_supported, ...rest }) => {
817
817
  return {
818
818
  ...rest,
819
819
  ...authorization_server ? { authorization_servers: [authorization_server] } : {},