@openid4vc/openid4vci 0.3.0-alpha-20251021081452 → 0.3.0-alpha-20251021082313

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.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ContentType, Fetch, FetchHeaders, HttpMethod, InferOutputUnion, Oid4vcTsConfig, OrPromise, StringWithAutoCompletion, getGlobalConfig, setGlobalConfig } from "@openid4vc/utils";
2
- import * as _openid4vc_oauth23 from "@openid4vc/oauth2";
3
- import { AuthorizationCodeGrantIdentifier, AuthorizationServerMetadata, CallbackContext, CreateAuthorizationRequestUrlOptions, CreateClientAttestationJwtOptions, CreatePkceReturn, Jwk, JwtSigner, PreAuthorizedCodeGrantIdentifier, RequestDpopOptions, ResourceRequestResponseNotOk, ResourceRequestResponseOk, RetrieveAuthorizationCodeAccessTokenOptions, RetrievePreAuthorizedCodeAccessTokenOptions, authorizationCodeGrantIdentifier, preAuthorizedCodeGrantIdentifier } from "@openid4vc/oauth2";
2
+ import * as _openid4vc_oauth20 from "@openid4vc/oauth2";
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";
6
6
  import * as zod_v4_core0 from "zod/v4/core";
@@ -1662,10 +1662,334 @@ declare const zCredentialConfigurationSupportedDraft11To16: z.ZodPipe<z.ZodPipe<
1662
1662
  credential_metadata?: undefined;
1663
1663
  }>>>;
1664
1664
  //#endregion
1665
+ //#region src/metadata/credential-issuer/z-signed-credential-issuer-metadata.d.ts
1666
+ declare const zSignedCredentialIssuerMetadataHeader: z.ZodObject<{
1667
+ typ: z.ZodLiteral<"openidvci-issuer-metadata+jwt">;
1668
+ alg: z.ZodString;
1669
+ kid: z.ZodOptional<z.ZodString>;
1670
+ jwk: z.ZodOptional<z.ZodObject<{
1671
+ kty: z.ZodString;
1672
+ crv: z.ZodOptional<z.ZodString>;
1673
+ x: z.ZodOptional<z.ZodString>;
1674
+ y: z.ZodOptional<z.ZodString>;
1675
+ e: z.ZodOptional<z.ZodString>;
1676
+ n: z.ZodOptional<z.ZodString>;
1677
+ alg: z.ZodOptional<z.ZodString>;
1678
+ d: z.ZodOptional<z.ZodString>;
1679
+ dp: z.ZodOptional<z.ZodString>;
1680
+ dq: z.ZodOptional<z.ZodString>;
1681
+ ext: z.ZodOptional<z.ZodBoolean>;
1682
+ k: z.ZodOptional<z.ZodString>;
1683
+ key_ops: z.ZodOptional<z.ZodArray<z.ZodString>>;
1684
+ kid: z.ZodOptional<z.ZodString>;
1685
+ oth: z.ZodOptional<z.ZodArray<z.ZodObject<{
1686
+ d: z.ZodOptional<z.ZodString>;
1687
+ r: z.ZodOptional<z.ZodString>;
1688
+ t: z.ZodOptional<z.ZodString>;
1689
+ }, z.core.$loose>>>;
1690
+ p: z.ZodOptional<z.ZodString>;
1691
+ q: z.ZodOptional<z.ZodString>;
1692
+ qi: z.ZodOptional<z.ZodString>;
1693
+ use: z.ZodOptional<z.ZodString>;
1694
+ x5c: z.ZodOptional<z.ZodArray<z.ZodString>>;
1695
+ x5t: z.ZodOptional<z.ZodString>;
1696
+ 'x5t#S256': z.ZodOptional<z.ZodString>;
1697
+ x5u: z.ZodOptional<z.ZodString>;
1698
+ }, z.core.$loose>>;
1699
+ x5c: z.ZodOptional<z.ZodArray<z.ZodString>>;
1700
+ trust_chain: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
1701
+ }, z.core.$loose>;
1702
+ declare const zSignedCredentialIssuerMetadataPayload: z.ZodObject<{
1703
+ credential_issuer: z.ZodString;
1704
+ authorization_servers: z.ZodOptional<z.ZodArray<z.ZodString>>;
1705
+ credential_endpoint: z.ZodString;
1706
+ deferred_credential_endpoint: z.ZodOptional<z.ZodString>;
1707
+ notification_endpoint: z.ZodOptional<z.ZodString>;
1708
+ nonce_endpoint: z.ZodOptional<z.ZodString>;
1709
+ credential_response_encryption: z.ZodOptional<z.ZodObject<{
1710
+ alg_values_supported: z.ZodArray<z.ZodString>;
1711
+ enc_values_supported: z.ZodArray<z.ZodString>;
1712
+ encryption_required: z.ZodBoolean;
1713
+ }, z.core.$loose>>;
1714
+ batch_credential_issuance: z.ZodOptional<z.ZodObject<{
1715
+ batch_size: z.ZodNumber;
1716
+ }, z.core.$loose>>;
1717
+ display: z.ZodOptional<z.ZodArray<z.ZodObject<{
1718
+ name: z.ZodOptional<z.ZodString>;
1719
+ locale: z.ZodOptional<z.ZodString>;
1720
+ logo: z.ZodOptional<z.ZodObject<{
1721
+ uri: z.ZodOptional<z.ZodString>;
1722
+ alt_text: z.ZodOptional<z.ZodString>;
1723
+ }, z.core.$loose>>;
1724
+ }, z.core.$loose>>>;
1725
+ credential_configurations_supported: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
1726
+ format: z.ZodString;
1727
+ scope: z.ZodOptional<z.ZodString>;
1728
+ cryptographic_binding_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
1729
+ credential_signing_alg_values_supported: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodArray<z.ZodNumber>]>>;
1730
+ proof_types_supported: z.ZodOptional<z.ZodRecord<z.ZodUnion<readonly [z.ZodLiteral<"jwt">, z.ZodLiteral<"attestation">, z.ZodString]>, z.ZodObject<{
1731
+ proof_signing_alg_values_supported: z.ZodArray<z.ZodString>;
1732
+ key_attestations_required: z.ZodOptional<z.ZodObject<{
1733
+ key_storage: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
1734
+ iso_18045_high: "iso_18045_high";
1735
+ iso_18045_moderate: "iso_18045_moderate";
1736
+ "iso_18045_enhanced-basic": "iso_18045_enhanced-basic";
1737
+ iso_18045_basic: "iso_18045_basic";
1738
+ }>, z.ZodString]>>>;
1739
+ user_authentication: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
1740
+ iso_18045_high: "iso_18045_high";
1741
+ iso_18045_moderate: "iso_18045_moderate";
1742
+ "iso_18045_enhanced-basic": "iso_18045_enhanced-basic";
1743
+ iso_18045_basic: "iso_18045_basic";
1744
+ }>, z.ZodString]>>>;
1745
+ }, z.core.$loose>>;
1746
+ }, z.core.$strip>>>;
1747
+ credential_metadata: z.ZodOptional<z.ZodObject<{
1748
+ display: z.ZodOptional<z.ZodArray<z.ZodObject<{
1749
+ name: z.ZodString;
1750
+ locale: z.ZodOptional<z.ZodString>;
1751
+ logo: z.ZodOptional<z.ZodObject<{
1752
+ uri: z.ZodOptional<z.ZodString>;
1753
+ alt_text: z.ZodOptional<z.ZodString>;
1754
+ }, z.core.$loose>>;
1755
+ description: z.ZodOptional<z.ZodString>;
1756
+ background_color: z.ZodOptional<z.ZodString>;
1757
+ background_image: z.ZodOptional<z.ZodObject<{
1758
+ uri: z.ZodOptional<z.ZodString>;
1759
+ }, z.core.$loose>>;
1760
+ text_color: z.ZodOptional<z.ZodString>;
1761
+ }, z.core.$loose>>>;
1762
+ }, z.core.$strip>>;
1763
+ claims: z.ZodOptional<z.ZodNever>;
1764
+ }, z.core.$loose>, z.ZodObject<{
1765
+ format: z.ZodString;
1766
+ scope: z.ZodOptional<z.ZodString>;
1767
+ cryptographic_binding_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
1768
+ credential_signing_alg_values_supported: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodArray<z.ZodNumber>]>>;
1769
+ proof_types_supported: z.ZodOptional<z.ZodRecord<z.ZodUnion<readonly [z.ZodLiteral<"jwt">, z.ZodLiteral<"attestation">, z.ZodString]>, z.ZodObject<{
1770
+ proof_signing_alg_values_supported: z.ZodArray<z.ZodString>;
1771
+ key_attestations_required: z.ZodOptional<z.ZodObject<{
1772
+ key_storage: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
1773
+ iso_18045_high: "iso_18045_high";
1774
+ iso_18045_moderate: "iso_18045_moderate";
1775
+ "iso_18045_enhanced-basic": "iso_18045_enhanced-basic";
1776
+ iso_18045_basic: "iso_18045_basic";
1777
+ }>, z.ZodString]>>>;
1778
+ user_authentication: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
1779
+ iso_18045_high: "iso_18045_high";
1780
+ iso_18045_moderate: "iso_18045_moderate";
1781
+ "iso_18045_enhanced-basic": "iso_18045_enhanced-basic";
1782
+ iso_18045_basic: "iso_18045_basic";
1783
+ }>, z.ZodString]>>>;
1784
+ }, z.core.$loose>>;
1785
+ }, z.core.$strip>>>;
1786
+ display: z.ZodOptional<z.ZodArray<z.ZodObject<{
1787
+ name: z.ZodString;
1788
+ locale: z.ZodOptional<z.ZodString>;
1789
+ logo: z.ZodOptional<z.ZodObject<{
1790
+ uri: z.ZodOptional<z.ZodString>;
1791
+ alt_text: z.ZodOptional<z.ZodString>;
1792
+ }, z.core.$loose>>;
1793
+ description: z.ZodOptional<z.ZodString>;
1794
+ background_color: z.ZodOptional<z.ZodString>;
1795
+ background_image: z.ZodOptional<z.ZodObject<{
1796
+ uri: z.ZodOptional<z.ZodString>;
1797
+ }, z.core.$loose>>;
1798
+ text_color: z.ZodOptional<z.ZodString>;
1799
+ }, z.core.$loose>>>;
1800
+ credential_metadata: z.ZodOptional<z.ZodNever>;
1801
+ }, z.core.$loose>]>, z.ZodTransform<{
1802
+ [x: string]: unknown;
1803
+ format: string;
1804
+ scope?: string | undefined;
1805
+ cryptographic_binding_methods_supported?: string[] | undefined;
1806
+ credential_signing_alg_values_supported?: string[] | number[] | undefined;
1807
+ proof_types_supported?: Record<string, {
1808
+ proof_signing_alg_values_supported: string[];
1809
+ key_attestations_required?: {
1810
+ [x: string]: unknown;
1811
+ key_storage?: string[] | undefined;
1812
+ user_authentication?: string[] | undefined;
1813
+ } | undefined;
1814
+ }> | undefined;
1815
+ credential_metadata?: {
1816
+ display?: {
1817
+ [x: string]: unknown;
1818
+ name: string;
1819
+ locale?: string | undefined;
1820
+ logo?: {
1821
+ [x: string]: unknown;
1822
+ uri?: string | undefined;
1823
+ alt_text?: string | undefined;
1824
+ } | undefined;
1825
+ description?: string | undefined;
1826
+ background_color?: string | undefined;
1827
+ background_image?: {
1828
+ [x: string]: unknown;
1829
+ uri?: string | undefined;
1830
+ } | undefined;
1831
+ text_color?: string | undefined;
1832
+ }[] | undefined;
1833
+ } | undefined;
1834
+ claims?: undefined;
1835
+ } | {
1836
+ [x: string]: unknown;
1837
+ format: string;
1838
+ scope?: string | undefined;
1839
+ cryptographic_binding_methods_supported?: string[] | undefined;
1840
+ credential_signing_alg_values_supported?: string[] | number[] | undefined;
1841
+ proof_types_supported?: Record<string, {
1842
+ proof_signing_alg_values_supported: string[];
1843
+ key_attestations_required?: {
1844
+ [x: string]: unknown;
1845
+ key_storage?: string[] | undefined;
1846
+ user_authentication?: string[] | undefined;
1847
+ } | undefined;
1848
+ }> | undefined;
1849
+ display?: {
1850
+ [x: string]: unknown;
1851
+ name: string;
1852
+ locale?: string | undefined;
1853
+ logo?: {
1854
+ [x: string]: unknown;
1855
+ uri?: string | undefined;
1856
+ alt_text?: string | undefined;
1857
+ } | undefined;
1858
+ description?: string | undefined;
1859
+ background_color?: string | undefined;
1860
+ background_image?: {
1861
+ [x: string]: unknown;
1862
+ uri?: string | undefined;
1863
+ } | undefined;
1864
+ text_color?: string | undefined;
1865
+ }[] | undefined;
1866
+ credential_metadata?: undefined;
1867
+ }, {
1868
+ [x: string]: unknown;
1869
+ format: string;
1870
+ scope?: string | undefined;
1871
+ cryptographic_binding_methods_supported?: string[] | undefined;
1872
+ credential_signing_alg_values_supported?: string[] | number[] | undefined;
1873
+ proof_types_supported?: Record<string, {
1874
+ proof_signing_alg_values_supported: string[];
1875
+ key_attestations_required?: {
1876
+ [x: string]: unknown;
1877
+ key_storage?: string[] | undefined;
1878
+ user_authentication?: string[] | undefined;
1879
+ } | undefined;
1880
+ }> | undefined;
1881
+ credential_metadata?: {
1882
+ display?: {
1883
+ [x: string]: unknown;
1884
+ name: string;
1885
+ locale?: string | undefined;
1886
+ logo?: {
1887
+ [x: string]: unknown;
1888
+ uri?: string | undefined;
1889
+ alt_text?: string | undefined;
1890
+ } | undefined;
1891
+ description?: string | undefined;
1892
+ background_color?: string | undefined;
1893
+ background_image?: {
1894
+ [x: string]: unknown;
1895
+ uri?: string | undefined;
1896
+ } | undefined;
1897
+ text_color?: string | undefined;
1898
+ }[] | undefined;
1899
+ } | undefined;
1900
+ claims?: undefined;
1901
+ } | {
1902
+ [x: string]: unknown;
1903
+ format: string;
1904
+ scope?: string | undefined;
1905
+ cryptographic_binding_methods_supported?: string[] | undefined;
1906
+ credential_signing_alg_values_supported?: string[] | number[] | undefined;
1907
+ proof_types_supported?: Record<string, {
1908
+ proof_signing_alg_values_supported: string[];
1909
+ key_attestations_required?: {
1910
+ [x: string]: unknown;
1911
+ key_storage?: string[] | undefined;
1912
+ user_authentication?: string[] | undefined;
1913
+ } | undefined;
1914
+ }> | undefined;
1915
+ display?: {
1916
+ [x: string]: unknown;
1917
+ name: string;
1918
+ locale?: string | undefined;
1919
+ logo?: {
1920
+ [x: string]: unknown;
1921
+ uri?: string | undefined;
1922
+ alt_text?: string | undefined;
1923
+ } | undefined;
1924
+ description?: string | undefined;
1925
+ background_color?: string | undefined;
1926
+ background_image?: {
1927
+ [x: string]: unknown;
1928
+ uri?: string | undefined;
1929
+ } | undefined;
1930
+ text_color?: string | undefined;
1931
+ }[] | undefined;
1932
+ credential_metadata?: undefined;
1933
+ }>>>;
1934
+ iat: z.ZodNumber;
1935
+ sub: z.ZodString;
1936
+ iss: z.ZodOptional<z.ZodString>;
1937
+ aud: z.ZodOptional<z.ZodString>;
1938
+ exp: z.ZodOptional<z.ZodNumber>;
1939
+ nbf: z.ZodOptional<z.ZodNumber>;
1940
+ nonce: z.ZodOptional<z.ZodString>;
1941
+ jti: z.ZodOptional<z.ZodString>;
1942
+ cnf: z.ZodOptional<z.ZodObject<{
1943
+ jwk: z.ZodOptional<z.ZodObject<{
1944
+ kty: z.ZodString;
1945
+ crv: z.ZodOptional<z.ZodString>;
1946
+ x: z.ZodOptional<z.ZodString>;
1947
+ y: z.ZodOptional<z.ZodString>;
1948
+ e: z.ZodOptional<z.ZodString>;
1949
+ n: z.ZodOptional<z.ZodString>;
1950
+ alg: z.ZodOptional<z.ZodString>;
1951
+ d: z.ZodOptional<z.ZodString>;
1952
+ dp: z.ZodOptional<z.ZodString>;
1953
+ dq: z.ZodOptional<z.ZodString>;
1954
+ ext: z.ZodOptional<z.ZodBoolean>;
1955
+ k: z.ZodOptional<z.ZodString>;
1956
+ key_ops: z.ZodOptional<z.ZodArray<z.ZodString>>;
1957
+ kid: z.ZodOptional<z.ZodString>;
1958
+ oth: z.ZodOptional<z.ZodArray<z.ZodObject<{
1959
+ d: z.ZodOptional<z.ZodString>;
1960
+ r: z.ZodOptional<z.ZodString>;
1961
+ t: z.ZodOptional<z.ZodString>;
1962
+ }, z.core.$loose>>>;
1963
+ p: z.ZodOptional<z.ZodString>;
1964
+ q: z.ZodOptional<z.ZodString>;
1965
+ qi: z.ZodOptional<z.ZodString>;
1966
+ use: z.ZodOptional<z.ZodString>;
1967
+ x5c: z.ZodOptional<z.ZodArray<z.ZodString>>;
1968
+ x5t: z.ZodOptional<z.ZodString>;
1969
+ 'x5t#S256': z.ZodOptional<z.ZodString>;
1970
+ x5u: z.ZodOptional<z.ZodString>;
1971
+ }, z.core.$loose>>;
1972
+ jkt: z.ZodOptional<z.ZodString>;
1973
+ }, z.core.$loose>>;
1974
+ status: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1975
+ trust_chain: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
1976
+ }, z.core.$loose>;
1977
+ //#endregion
1978
+ //#region src/metadata/credential-issuer/credential-issuer-metadata.d.ts
1979
+ interface CredentialIssuerMetadataSigned {
1980
+ jwt: DecodeJwtResult<typeof zSignedCredentialIssuerMetadataHeader, typeof zSignedCredentialIssuerMetadataPayload>;
1981
+ signer: JwtSignerWithJwk;
1982
+ }
1983
+ //#endregion
1665
1984
  //#region src/metadata/fetch-issuer-metadata.d.ts
1666
1985
  interface IssuerMetadataResult {
1667
- originalDraftVersion?: Openid4vciDraftVersion;
1986
+ originalDraftVersion: Openid4vciDraftVersion;
1668
1987
  credentialIssuer: CredentialIssuerMetadata;
1988
+ /**
1989
+ * Metadata about the signed credential issuer metadata,
1990
+ * if the issuer metadata was signed
1991
+ */
1992
+ signedCredentialIssuer?: CredentialIssuerMetadataSigned;
1669
1993
  authorizationServers: AuthorizationServerMetadata[];
1670
1994
  }
1671
1995
  //#endregion
@@ -2725,7 +3049,7 @@ interface ParseKeyAttestationJwtOptions {
2725
3049
  declare function parseKeyAttestationJwt({
2726
3050
  keyAttestationJwt,
2727
3051
  use
2728
- }: ParseKeyAttestationJwtOptions): _openid4vc_oauth23.DecodeJwtResult<zod0.ZodObject<{
3052
+ }: ParseKeyAttestationJwtOptions): _openid4vc_oauth20.DecodeJwtResult<zod0.ZodObject<{
2729
3053
  typ: zod0.ZodUnion<[zod0.ZodLiteral<"keyattestation+jwt">, zod0.ZodLiteral<"key-attestation+jwt">]>;
2730
3054
  alg: zod0.ZodString;
2731
3055
  kid: zod0.ZodOptional<zod0.ZodString>;
@@ -2997,7 +3321,7 @@ declare function verifyKeyAttestationJwt(options: VerifyKeyAttestationJwtOptions
2997
3321
  status?: Record<string, any> | undefined;
2998
3322
  trust_chain?: [string, ...string[]] | undefined;
2999
3323
  };
3000
- signer: _openid4vc_oauth23.JwtSignerWithJwk;
3324
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
3001
3325
  }>;
3002
3326
  //#endregion
3003
3327
  //#region src/metadata/credential-issuer/credential-configurations.d.ts
@@ -3162,7 +3486,7 @@ declare class Openid4vciClient {
3162
3486
  };
3163
3487
  dpop: {
3164
3488
  nonce: string | undefined;
3165
- signer: _openid4vc_oauth23.JwtSignerJwk;
3489
+ signer: _openid4vc_oauth20.JwtSignerJwk;
3166
3490
  } | undefined;
3167
3491
  }>;
3168
3492
  /**
@@ -3221,7 +3545,7 @@ declare class Openid4vciClient {
3221
3545
  issuerMetadata: IssuerMetadataResult;
3222
3546
  }): Promise<{
3223
3547
  authorizationServer: string;
3224
- accessTokenResponse: _openid4vc_oauth23.AccessTokenResponse;
3548
+ accessTokenResponse: _openid4vc_oauth20.AccessTokenResponse;
3225
3549
  dpop?: RequestDpopOptions;
3226
3550
  }>;
3227
3551
  /**
@@ -3241,7 +3565,7 @@ declare class Openid4vciClient {
3241
3565
  issuerMetadata: IssuerMetadataResult;
3242
3566
  }): Promise<{
3243
3567
  authorizationServer: string;
3244
- accessTokenResponse: _openid4vc_oauth23.AccessTokenResponse;
3568
+ accessTokenResponse: _openid4vc_oauth20.AccessTokenResponse;
3245
3569
  dpop?: RequestDpopOptions;
3246
3570
  }>;
3247
3571
  /**
@@ -3296,7 +3620,7 @@ declare class Openid4vciClient {
3296
3620
  additionalRequestPayload,
3297
3621
  accessToken,
3298
3622
  dpop
3299
- }: Pick<SendNotificationOptions, 'accessToken' | 'additionalRequestPayload' | 'issuerMetadata' | 'dpop' | 'notification'>): Promise<_openid4vc_oauth23.ResourceRequestResponseOk>;
3623
+ }: Pick<SendNotificationOptions, 'accessToken' | 'additionalRequestPayload' | 'issuerMetadata' | 'dpop' | 'notification'>): Promise<_openid4vc_oauth20.ResourceRequestResponseOk>;
3300
3624
  }
3301
3625
  //#endregion
3302
3626
  //#region ../oauth2/src/common/jwk/z-jwk.d.ts
@@ -3715,6 +4039,39 @@ interface ParseDeferredCredentialRequestReturn {
3715
4039
  //#region src/formats/proof-type/attestation/attestation-proof-type.d.ts
3716
4040
  interface VerifyCredentialRequestAttestationProofOptions extends Omit<VerifyKeyAttestationJwtOptions, 'use'> {}
3717
4041
  //#endregion
4042
+ //#region src/metadata/credential-issuer/signed-credential-issuer-metadata.d.ts
4043
+ interface CreateSignedCredentialIssuerMetadataJwtOptions {
4044
+ /**
4045
+ * The credential issuer metadata to include in the jwt
4046
+ */
4047
+ credentialIssuerMetadata: CredentialIssuerMetadata;
4048
+ /**
4049
+ * The date when the credential issuer metadata was issued. If not provided the current time will be used.
4050
+ */
4051
+ issuedAt?: Date;
4052
+ /**
4053
+ * The date when the credential issuer metadata will expire.
4054
+ */
4055
+ expiresAt?: Date;
4056
+ /**
4057
+ * Signer of the credential issuer metadata jwt
4058
+ */
4059
+ signer: JwtSigner;
4060
+ /**
4061
+ * The issuer of the issuer metadata jwt. This field is optional
4062
+ */
4063
+ issuer?: string;
4064
+ /**
4065
+ * Callbacks used for creating the credential issuer metadata jwt
4066
+ */
4067
+ callbacks: Pick<CallbackContext, 'signJwt'>;
4068
+ /**
4069
+ * Additional payload to include in the credential issuer metadata jwt payload. Will be applied after
4070
+ * any default claims that are included, so add claims with caution.
4071
+ */
4072
+ additionalPayload?: Record<string, unknown>;
4073
+ }
4074
+ //#endregion
3718
4075
  //#region src/Openid4vciIssuer.d.ts
3719
4076
  interface Openid4vciIssuerOptions {
3720
4077
  /**
@@ -3877,6 +4234,10 @@ declare class Openid4vciIssuer {
3877
4234
  * Create issuer metadata and validates the structure is correct
3878
4235
  */
3879
4236
  createCredentialIssuerMetadata(credentialIssuerMetadata: CredentialIssuerMetadata): CredentialIssuerMetadata;
4237
+ /**
4238
+ * Validates credential issuer metadata structure is correct and creates signed credential issuer metadata JWT
4239
+ */
4240
+ createSignedCredentialIssuerMetadataJwt(options: Omit<CreateSignedCredentialIssuerMetadataJwtOptions, 'callbacks'>): Promise<string>;
3880
4241
  createCredentialOffer(options: Pick<CreateCredentialOfferOptions, 'issuerMetadata' | 'additionalPayload' | 'grants' | 'credentialOfferUri' | 'credentialOfferScheme' | 'credentialConfigurationIds'>): Promise<{
3881
4242
  credentialOffer: string;
3882
4243
  credentialOfferObject: CredentialOfferObject;
@@ -3975,7 +4336,7 @@ declare class Openid4vciIssuer {
3975
4336
  status?: Record<string, any> | undefined;
3976
4337
  trust_chain?: [string, ...string[]] | undefined;
3977
4338
  };
3978
- signer: _openid4vc_oauth23.JwtSignerWithJwk;
4339
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
3979
4340
  keyAttestation: {
3980
4341
  header: {
3981
4342
  [x: string]: unknown;
@@ -4097,7 +4458,7 @@ declare class Openid4vciIssuer {
4097
4458
  status?: Record<string, any> | undefined;
4098
4459
  trust_chain?: [string, ...string[]] | undefined;
4099
4460
  };
4100
- signer: _openid4vc_oauth23.JwtSignerWithJwk;
4461
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
4101
4462
  } | undefined;
4102
4463
  }>;
4103
4464
  /**
@@ -4227,7 +4588,7 @@ declare class Openid4vciIssuer {
4227
4588
  status?: Record<string, any> | undefined;
4228
4589
  trust_chain?: [string, ...string[]] | undefined;
4229
4590
  };
4230
- signer: _openid4vc_oauth23.JwtSignerWithJwk;
4591
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
4231
4592
  }>;
4232
4593
  /**
4233
4594
  * @throws Oauth2ServerErrorResponseError - when validation of the credential request fails
@@ -4363,7 +4724,7 @@ declare class Openid4vciIssuer {
4363
4724
  status?: Record<string, any> | undefined;
4364
4725
  trust_chain?: [string, ...string[]] | undefined;
4365
4726
  };
4366
- signer: _openid4vc_oauth23.JwtSignerWithJwk;
4727
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
4367
4728
  };
4368
4729
  clientAttestationPop: {
4369
4730
  header: {
@@ -4452,7 +4813,7 @@ declare class Openid4vciIssuer {
4452
4813
  status?: Record<string, any> | undefined;
4453
4814
  trust_chain?: [string, ...string[]] | undefined;
4454
4815
  };
4455
- signer: _openid4vc_oauth23.JwtSignerWithJwk;
4816
+ signer: _openid4vc_oauth20.JwtSignerWithJwk;
4456
4817
  };
4457
4818
  }>;
4458
4819
  }
package/dist/index.js CHANGED
@@ -759,20 +759,76 @@ const zCredentialIssuerMetadataWithDraftVersion = zod.default.union([zCredential
759
759
  originalDraftVersion: Openid4vciDraftVersion.Draft11
760
760
  }))]);
761
761
 
762
+ //#endregion
763
+ //#region src/metadata/credential-issuer/z-signed-credential-issuer-metadata.ts
764
+ const zSignedCredentialIssuerMetadataHeader = zod.default.object({
765
+ ...__openid4vc_oauth2.zJwtHeader.shape,
766
+ typ: zod.default.literal("openidvci-issuer-metadata+jwt")
767
+ }).loose();
768
+ const zSignedCredentialIssuerMetadataPayload = zod.default.object({
769
+ ...__openid4vc_oauth2.zJwtPayload.shape,
770
+ iat: __openid4vc_utils.zInteger,
771
+ sub: zod.default.string(),
772
+ ...zCredentialIssuerMetadataDraft14Draft15V1.shape
773
+ }).loose();
774
+
762
775
  //#endregion
763
776
  //#region src/metadata/credential-issuer/credential-issuer-metadata.ts
764
777
  const wellKnownCredentialIssuerSuffix = ".well-known/openid-credential-issuer";
765
778
  /**
766
779
  * @inheritdoc {@link fetchWellKnownMetadata}
767
780
  */
768
- async function fetchCredentialIssuerMetadata(credentialIssuer, fetch) {
781
+ async function fetchCredentialIssuerMetadata(credentialIssuer, options) {
769
782
  const parsedIssuerUrl = new __openid4vc_utils.URL(credentialIssuer);
770
783
  const legacyWellKnownMetadataUrl = (0, __openid4vc_utils.joinUriParts)(credentialIssuer, [wellKnownCredentialIssuerSuffix]);
771
784
  const wellKnownMetadataUrl = (0, __openid4vc_utils.joinUriParts)(parsedIssuerUrl.origin, [wellKnownCredentialIssuerSuffix, parsedIssuerUrl.pathname]);
772
- let result = await (0, __openid4vc_oauth2.fetchWellKnownMetadata)(wellKnownMetadataUrl, zCredentialIssuerMetadataWithDraftVersion, fetch);
773
- if (!result && legacyWellKnownMetadataUrl !== wellKnownMetadataUrl) result = await (0, __openid4vc_oauth2.fetchWellKnownMetadata)(legacyWellKnownMetadataUrl, zCredentialIssuerMetadataWithDraftVersion, fetch);
774
- if (result && result.credentialIssuerMetadata.credential_issuer !== credentialIssuer) throw new __openid4vc_oauth2.Oauth2Error(`The 'credential_issuer' parameter '${result.credentialIssuerMetadata.credential_issuer}' in the well known credential issuer metadata at '${wellKnownMetadataUrl}' does not match the provided credential issuer '${credentialIssuer}'.`);
775
- return result;
785
+ const acceptedContentType = options?.callbacks?.verifyJwt ? [__openid4vc_utils.ContentType.Jwt, __openid4vc_utils.ContentType.Json] : [__openid4vc_utils.ContentType.Json];
786
+ const responseSchema = zCredentialIssuerMetadataWithDraftVersion.or(__openid4vc_oauth2.zCompactJwt);
787
+ let result = await (0, __openid4vc_oauth2.fetchWellKnownMetadata)(wellKnownMetadataUrl, responseSchema, {
788
+ fetch: options?.callbacks?.fetch,
789
+ acceptedContentType
790
+ });
791
+ if (!result && legacyWellKnownMetadataUrl !== wellKnownMetadataUrl) result = await (0, __openid4vc_oauth2.fetchWellKnownMetadata)(legacyWellKnownMetadataUrl, responseSchema, {
792
+ fetch: options?.callbacks?.fetch,
793
+ acceptedContentType
794
+ });
795
+ let issuerMetadataWithVersion = null;
796
+ if (typeof result === "string") {
797
+ if (!options?.callbacks?.verifyJwt) throw new __openid4vc_oauth2.Oauth2Error(`Unable to verify signed credential issuer metadata, no 'verifyJwt' callback provided to fetch credential issuer metadata method.`);
798
+ const { header, payload, signature } = (0, __openid4vc_oauth2.decodeJwt)({
799
+ jwt: result,
800
+ headerSchema: zSignedCredentialIssuerMetadataHeader,
801
+ payloadSchema: zSignedCredentialIssuerMetadataPayload
802
+ });
803
+ if (payload.sub !== credentialIssuer) throw new __openid4vc_oauth2.Oauth2Error(`The 'sub' parameter '${payload.sub}' in the signed well known credential issuer metadata at '${wellKnownMetadataUrl}' does not match the provided credential issuer '${credentialIssuer}'.`);
804
+ const signer = (0, __openid4vc_oauth2.jwtSignerFromJwt)({
805
+ header,
806
+ payload
807
+ });
808
+ const verifyResult = await (0, __openid4vc_oauth2.verifyJwt)({
809
+ compact: result,
810
+ header,
811
+ payload,
812
+ verifyJwtCallback: options.callbacks.verifyJwt,
813
+ now: options.now,
814
+ signer,
815
+ errorMessage: "signed credential issuer metadata jwt verification failed"
816
+ });
817
+ issuerMetadataWithVersion = {
818
+ ...(0, __openid4vc_utils.parseWithErrorHandling)(zCredentialIssuerMetadataWithDraftVersion, payload, "Unable to determine version for signed issuer metadata"),
819
+ signed: {
820
+ signer: verifyResult.signer,
821
+ jwt: {
822
+ header,
823
+ payload,
824
+ signature,
825
+ compact: result
826
+ }
827
+ }
828
+ };
829
+ } else if (result) issuerMetadataWithVersion = result;
830
+ if (issuerMetadataWithVersion && issuerMetadataWithVersion.credentialIssuerMetadata.credential_issuer !== credentialIssuer) throw new __openid4vc_oauth2.Oauth2Error(`The 'credential_issuer' parameter '${issuerMetadataWithVersion.credentialIssuerMetadata.credential_issuer}' in the well known credential issuer metadata at '${wellKnownMetadataUrl}' does not match the provided credential issuer '${credentialIssuer}'.`);
831
+ return issuerMetadataWithVersion;
776
832
  }
777
833
  /**
778
834
  * Extract credential configuration supported entries where the `format` is known to this
@@ -1397,14 +1453,17 @@ async function verifyCredentialRequestJwtProof(options) {
1397
1453
  //#region src/metadata/fetch-issuer-metadata.ts
1398
1454
  async function resolveIssuerMetadata(credentialIssuer, options) {
1399
1455
  const allowAuthorizationMetadataFromCredentialIssuerMetadata = options?.allowAuthorizationMetadataFromCredentialIssuerMetadata ?? true;
1400
- const credentialIssuerMetadataWithDraftVersion = await fetchCredentialIssuerMetadata(credentialIssuer, options?.fetch);
1456
+ const credentialIssuerMetadataWithDraftVersion = await fetchCredentialIssuerMetadata(credentialIssuer, {
1457
+ callbacks: options?.callbacks,
1458
+ now: options?.now
1459
+ });
1401
1460
  if (!credentialIssuerMetadataWithDraftVersion) throw new __openid4vc_oauth2.Oauth2Error(`Well known credential issuer metadata for issuer '${credentialIssuer}' not found.`);
1402
- const { credentialIssuerMetadata, originalDraftVersion } = credentialIssuerMetadataWithDraftVersion;
1461
+ const { credentialIssuerMetadata, originalDraftVersion, signed } = credentialIssuerMetadataWithDraftVersion;
1403
1462
  const authorizationServers = credentialIssuerMetadata.authorization_servers ?? [credentialIssuer];
1404
1463
  const authoriationServersMetadata = [];
1405
1464
  for (const authorizationServer of authorizationServers) {
1406
1465
  if (options?.restrictToAuthorizationServers && !options.restrictToAuthorizationServers.includes(authorizationServer)) continue;
1407
- let authorizationServerMetadata = await (0, __openid4vc_oauth2.fetchAuthorizationServerMetadata)(authorizationServer, options?.fetch);
1466
+ let authorizationServerMetadata = await (0, __openid4vc_oauth2.fetchAuthorizationServerMetadata)(authorizationServer, options?.callbacks.fetch);
1408
1467
  if (!authorizationServerMetadata && authorizationServer === credentialIssuer && allowAuthorizationMetadataFromCredentialIssuerMetadata) authorizationServerMetadata = (0, __openid4vc_utils.parseWithErrorHandling)(__openid4vc_oauth2.zAuthorizationServerMetadata, {
1409
1468
  token_endpoint: credentialIssuerMetadata.token_endpoint,
1410
1469
  issuer: credentialIssuer
@@ -1415,6 +1474,7 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
1415
1474
  return {
1416
1475
  originalDraftVersion,
1417
1476
  credentialIssuer: credentialIssuerMetadata,
1477
+ signedCredentialIssuer: signed,
1418
1478
  authorizationServers: authoriationServersMetadata
1419
1479
  };
1420
1480
  }
@@ -1520,7 +1580,7 @@ var Openid4vciClient = class {
1520
1580
  return resolveCredentialOffer(credentialOffer, { fetch: this.options.callbacks.fetch });
1521
1581
  }
1522
1582
  async resolveIssuerMetadata(credentialIssuer) {
1523
- return resolveIssuerMetadata(credentialIssuer, { fetch: this.options.callbacks.fetch });
1583
+ return resolveIssuerMetadata(credentialIssuer, { callbacks: this.options.callbacks });
1524
1584
  }
1525
1585
  /**
1526
1586
  * Retrieve an authorization code for a presentation during issuance session
@@ -1855,6 +1915,28 @@ async function verifyCredentialRequestAttestationProof(options) {
1855
1915
  });
1856
1916
  }
1857
1917
 
1918
+ //#endregion
1919
+ //#region src/metadata/credential-issuer/signed-credential-issuer-metadata.ts
1920
+ async function createSignedCredentialIssuerMetadataJwt(options) {
1921
+ const header = (0, __openid4vc_utils.parseWithErrorHandling)(zSignedCredentialIssuerMetadataHeader, {
1922
+ ...(0, __openid4vc_oauth2.jwtHeaderFromJwtSigner)(options.signer),
1923
+ typ: "openidvci-issuer-metadata+jwt"
1924
+ });
1925
+ const payload = (0, __openid4vc_utils.parseWithErrorHandling)(zSignedCredentialIssuerMetadataPayload, {
1926
+ ...options.credentialIssuerMetadata,
1927
+ sub: options.credentialIssuerMetadata.credential_issuer,
1928
+ iat: (0, __openid4vc_utils.dateToSeconds)(options.issuedAt),
1929
+ exp: options.expiresAt ? (0, __openid4vc_utils.dateToSeconds)(options.expiresAt) : void 0,
1930
+ iss: options.issuer,
1931
+ ...options.additionalPayload
1932
+ });
1933
+ const { jwt } = await options.callbacks.signJwt(options.signer, {
1934
+ header,
1935
+ payload
1936
+ });
1937
+ return jwt;
1938
+ }
1939
+
1858
1940
  //#endregion
1859
1941
  //#region src/Openid4vciIssuer.ts
1860
1942
  var Openid4vciIssuer = class {
@@ -1873,6 +1955,15 @@ var Openid4vciIssuer = class {
1873
1955
  createCredentialIssuerMetadata(credentialIssuerMetadata) {
1874
1956
  return (0, __openid4vc_utils.parseWithErrorHandling)(zCredentialIssuerMetadata, credentialIssuerMetadata, "Error validating credential issuer metadata");
1875
1957
  }
1958
+ /**
1959
+ * Validates credential issuer metadata structure is correct and creates signed credential issuer metadata JWT
1960
+ */
1961
+ createSignedCredentialIssuerMetadataJwt(options) {
1962
+ return createSignedCredentialIssuerMetadataJwt({
1963
+ callbacks: this.options.callbacks,
1964
+ ...options
1965
+ });
1966
+ }
1876
1967
  async createCredentialOffer(options) {
1877
1968
  return createCredentialOffer({
1878
1969
  callbacks: this.options.callbacks,