@pagopa/io-wallet-oid4vci 2.0.2-apt → 2.1.0-apt
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 +43509 -3939
- package/dist/index.d.ts +43509 -3939
- package/dist/index.js +36 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1699,6 +1699,7 @@ import z16 from "zod";
|
|
|
1699
1699
|
// src/metadata/z-metadata-response.ts
|
|
1700
1700
|
import {
|
|
1701
1701
|
itWalletEntityStatementClaimsSchema,
|
|
1702
|
+
itWalletMetadataAPTITUDE,
|
|
1702
1703
|
itWalletMetadataV1_0,
|
|
1703
1704
|
itWalletMetadataV1_3,
|
|
1704
1705
|
itWalletMetadataV1_4
|
|
@@ -1723,10 +1724,14 @@ var zMetadataResponseV1_3 = z15.object({
|
|
|
1723
1724
|
var zMetadataResponseV1_4 = zMetadataResponseV1_3.extend({
|
|
1724
1725
|
metadata: itWalletMetadataV1_4
|
|
1725
1726
|
});
|
|
1727
|
+
var zMetadataResponseAPTITUDE = zMetadataResponseV1_3.extend({
|
|
1728
|
+
metadata: itWalletMetadataAPTITUDE
|
|
1729
|
+
});
|
|
1726
1730
|
var zMetadataResponse = z15.union([
|
|
1727
1731
|
zMetadataResponseV1_0,
|
|
1728
1732
|
zMetadataResponseV1_3,
|
|
1729
|
-
zMetadataResponseV1_4
|
|
1733
|
+
zMetadataResponseV1_4,
|
|
1734
|
+
zMetadataResponseAPTITUDE
|
|
1730
1735
|
]);
|
|
1731
1736
|
var zPartialIssuerMetadata = z15.looseObject({
|
|
1732
1737
|
authorization_servers: z15.tuple([z15.url()], z15.url()).optional()
|
|
@@ -1817,7 +1822,22 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
|
|
|
1817
1822
|
authorization_server_federation_claims: authorizationServerResult.openid_federation_claims
|
|
1818
1823
|
};
|
|
1819
1824
|
}
|
|
1820
|
-
async function
|
|
1825
|
+
async function tryFetchAuthorizationServerMetadata(fetch, baseUrl) {
|
|
1826
|
+
try {
|
|
1827
|
+
const authServerUrl = new URL(
|
|
1828
|
+
".well-known/oauth-authorization-server",
|
|
1829
|
+
ensureTrailingSlash(baseUrl)
|
|
1830
|
+
).toString();
|
|
1831
|
+
const response = await fetch(authServerUrl);
|
|
1832
|
+
if (response.status !== 200) {
|
|
1833
|
+
return void 0;
|
|
1834
|
+
}
|
|
1835
|
+
return await response.json();
|
|
1836
|
+
} catch {
|
|
1837
|
+
return void 0;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
async function fallbackDiscovery(fetch, baseUrl, authorizationServer, fetchColocatedAuthorizationServer = false) {
|
|
1821
1841
|
const issuerUrl = new URL(
|
|
1822
1842
|
".well-known/openid-credential-issuer",
|
|
1823
1843
|
ensureTrailingSlash(baseUrl)
|
|
@@ -1848,7 +1868,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
|
|
|
1848
1868
|
await hasStatusOrThrow4(200, UnexpectedStatusCodeError4)(authServerResponse);
|
|
1849
1869
|
oauthAuthorizationServer = await authServerResponse.json();
|
|
1850
1870
|
} else {
|
|
1851
|
-
oauthAuthorizationServer = issuerJson;
|
|
1871
|
+
oauthAuthorizationServer = (fetchColocatedAuthorizationServer ? await tryFetchAuthorizationServerMetadata(fetch, baseUrl) : void 0) ?? issuerJson;
|
|
1852
1872
|
}
|
|
1853
1873
|
return {
|
|
1854
1874
|
discoveredVia: "oid4vci",
|
|
@@ -1858,7 +1878,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
|
|
|
1858
1878
|
}
|
|
1859
1879
|
};
|
|
1860
1880
|
}
|
|
1861
|
-
var fetchMetadataWithFallbackDiscovery = async (options) => {
|
|
1881
|
+
var fetchMetadataWithFallbackDiscovery = async (options, fetchColocatedAuthorizationServer = false) => {
|
|
1862
1882
|
const fetch = createFetcher4(options.callbacks.fetch);
|
|
1863
1883
|
const federationResult = await tryFederationDiscovery(
|
|
1864
1884
|
fetch,
|
|
@@ -1873,7 +1893,8 @@ var fetchMetadataWithFallbackDiscovery = async (options) => {
|
|
|
1873
1893
|
) : await fallbackDiscovery(
|
|
1874
1894
|
fetch,
|
|
1875
1895
|
options.credentialIssuerUrl,
|
|
1876
|
-
options.authorizationServer
|
|
1896
|
+
options.authorizationServer,
|
|
1897
|
+
fetchColocatedAuthorizationServer
|
|
1877
1898
|
);
|
|
1878
1899
|
return raw;
|
|
1879
1900
|
};
|
|
@@ -1911,8 +1932,16 @@ async function fetchMetadataV1_4(options) {
|
|
|
1911
1932
|
"Failed to parse v1.4 metadata response"
|
|
1912
1933
|
);
|
|
1913
1934
|
}
|
|
1935
|
+
async function fetchMetadataAptitude(options) {
|
|
1936
|
+
const raw = await fetchMetadataWithFallbackDiscovery(options, true);
|
|
1937
|
+
return parseWithErrorHandling7(
|
|
1938
|
+
zMetadataResponseAPTITUDE,
|
|
1939
|
+
raw,
|
|
1940
|
+
"Failed to parse APTITUDE metadata response"
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1914
1943
|
var dispatchFetchMetadata = createVersionDispatcher7({
|
|
1915
|
-
[ItWalletSpecsVersion10.APTITUDE]: (o) =>
|
|
1944
|
+
[ItWalletSpecsVersion10.APTITUDE]: (o) => fetchMetadataAptitude(o),
|
|
1916
1945
|
[ItWalletSpecsVersion10.V1_0]: (o) => fetchMetadataV1_0(o),
|
|
1917
1946
|
[ItWalletSpecsVersion10.V1_3]: (o) => fetchMetadataV1_3(o),
|
|
1918
1947
|
[ItWalletSpecsVersion10.V1_4]: (o) => fetchMetadataV1_4(o)
|
|
@@ -2207,6 +2236,7 @@ export {
|
|
|
2207
2236
|
zKeyAttestationStatus,
|
|
2208
2237
|
zKeyAttestationTypeHeader,
|
|
2209
2238
|
zMetadataResponse,
|
|
2239
|
+
zMetadataResponseAPTITUDE,
|
|
2210
2240
|
zMetadataResponseV1_0,
|
|
2211
2241
|
zMetadataResponseV1_3,
|
|
2212
2242
|
zMetadataResponseV1_4,
|