@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.js
CHANGED
|
@@ -83,6 +83,7 @@ __export(index_exports, {
|
|
|
83
83
|
zKeyAttestationStatus: () => zKeyAttestationStatus,
|
|
84
84
|
zKeyAttestationTypeHeader: () => zKeyAttestationTypeHeader,
|
|
85
85
|
zMetadataResponse: () => zMetadataResponse,
|
|
86
|
+
zMetadataResponseAPTITUDE: () => zMetadataResponseAPTITUDE,
|
|
86
87
|
zMetadataResponseV1_0: () => zMetadataResponseV1_0,
|
|
87
88
|
zMetadataResponseV1_3: () => zMetadataResponseV1_3,
|
|
88
89
|
zMetadataResponseV1_4: () => zMetadataResponseV1_4,
|
|
@@ -1720,10 +1721,14 @@ var zMetadataResponseV1_3 = import_zod15.z.object({
|
|
|
1720
1721
|
var zMetadataResponseV1_4 = zMetadataResponseV1_3.extend({
|
|
1721
1722
|
metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_4
|
|
1722
1723
|
});
|
|
1724
|
+
var zMetadataResponseAPTITUDE = zMetadataResponseV1_3.extend({
|
|
1725
|
+
metadata: import_io_wallet_oid_federation2.itWalletMetadataAPTITUDE
|
|
1726
|
+
});
|
|
1723
1727
|
var zMetadataResponse = import_zod15.z.union([
|
|
1724
1728
|
zMetadataResponseV1_0,
|
|
1725
1729
|
zMetadataResponseV1_3,
|
|
1726
|
-
zMetadataResponseV1_4
|
|
1730
|
+
zMetadataResponseV1_4,
|
|
1731
|
+
zMetadataResponseAPTITUDE
|
|
1727
1732
|
]);
|
|
1728
1733
|
var zPartialIssuerMetadata = import_zod15.z.looseObject({
|
|
1729
1734
|
authorization_servers: import_zod15.z.tuple([import_zod15.z.url()], import_zod15.z.url()).optional()
|
|
@@ -1814,7 +1819,22 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
|
|
|
1814
1819
|
authorization_server_federation_claims: authorizationServerResult.openid_federation_claims
|
|
1815
1820
|
};
|
|
1816
1821
|
}
|
|
1817
|
-
async function
|
|
1822
|
+
async function tryFetchAuthorizationServerMetadata(fetch, baseUrl) {
|
|
1823
|
+
try {
|
|
1824
|
+
const authServerUrl = new URL(
|
|
1825
|
+
".well-known/oauth-authorization-server",
|
|
1826
|
+
ensureTrailingSlash(baseUrl)
|
|
1827
|
+
).toString();
|
|
1828
|
+
const response = await fetch(authServerUrl);
|
|
1829
|
+
if (response.status !== 200) {
|
|
1830
|
+
return void 0;
|
|
1831
|
+
}
|
|
1832
|
+
return await response.json();
|
|
1833
|
+
} catch {
|
|
1834
|
+
return void 0;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
async function fallbackDiscovery(fetch, baseUrl, authorizationServer, fetchColocatedAuthorizationServer = false) {
|
|
1818
1838
|
const issuerUrl = new URL(
|
|
1819
1839
|
".well-known/openid-credential-issuer",
|
|
1820
1840
|
ensureTrailingSlash(baseUrl)
|
|
@@ -1845,7 +1865,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
|
|
|
1845
1865
|
await (0, import_io_wallet_utils19.hasStatusOrThrow)(200, import_io_wallet_utils19.UnexpectedStatusCodeError)(authServerResponse);
|
|
1846
1866
|
oauthAuthorizationServer = await authServerResponse.json();
|
|
1847
1867
|
} else {
|
|
1848
|
-
oauthAuthorizationServer = issuerJson;
|
|
1868
|
+
oauthAuthorizationServer = (fetchColocatedAuthorizationServer ? await tryFetchAuthorizationServerMetadata(fetch, baseUrl) : void 0) ?? issuerJson;
|
|
1849
1869
|
}
|
|
1850
1870
|
return {
|
|
1851
1871
|
discoveredVia: "oid4vci",
|
|
@@ -1855,7 +1875,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
|
|
|
1855
1875
|
}
|
|
1856
1876
|
};
|
|
1857
1877
|
}
|
|
1858
|
-
var fetchMetadataWithFallbackDiscovery = async (options) => {
|
|
1878
|
+
var fetchMetadataWithFallbackDiscovery = async (options, fetchColocatedAuthorizationServer = false) => {
|
|
1859
1879
|
const fetch = (0, import_io_wallet_utils19.createFetcher)(options.callbacks.fetch);
|
|
1860
1880
|
const federationResult = await tryFederationDiscovery(
|
|
1861
1881
|
fetch,
|
|
@@ -1870,7 +1890,8 @@ var fetchMetadataWithFallbackDiscovery = async (options) => {
|
|
|
1870
1890
|
) : await fallbackDiscovery(
|
|
1871
1891
|
fetch,
|
|
1872
1892
|
options.credentialIssuerUrl,
|
|
1873
|
-
options.authorizationServer
|
|
1893
|
+
options.authorizationServer,
|
|
1894
|
+
fetchColocatedAuthorizationServer
|
|
1874
1895
|
);
|
|
1875
1896
|
return raw;
|
|
1876
1897
|
};
|
|
@@ -1908,8 +1929,16 @@ async function fetchMetadataV1_4(options) {
|
|
|
1908
1929
|
"Failed to parse v1.4 metadata response"
|
|
1909
1930
|
);
|
|
1910
1931
|
}
|
|
1932
|
+
async function fetchMetadataAptitude(options) {
|
|
1933
|
+
const raw = await fetchMetadataWithFallbackDiscovery(options, true);
|
|
1934
|
+
return (0, import_io_wallet_utils19.parseWithErrorHandling)(
|
|
1935
|
+
zMetadataResponseAPTITUDE,
|
|
1936
|
+
raw,
|
|
1937
|
+
"Failed to parse APTITUDE metadata response"
|
|
1938
|
+
);
|
|
1939
|
+
}
|
|
1911
1940
|
var dispatchFetchMetadata = (0, import_io_wallet_utils19.createVersionDispatcher)({
|
|
1912
|
-
[import_io_wallet_utils19.ItWalletSpecsVersion.APTITUDE]: (o) =>
|
|
1941
|
+
[import_io_wallet_utils19.ItWalletSpecsVersion.APTITUDE]: (o) => fetchMetadataAptitude(o),
|
|
1913
1942
|
[import_io_wallet_utils19.ItWalletSpecsVersion.V1_0]: (o) => fetchMetadataV1_0(o),
|
|
1914
1943
|
[import_io_wallet_utils19.ItWalletSpecsVersion.V1_3]: (o) => fetchMetadataV1_3(o),
|
|
1915
1944
|
[import_io_wallet_utils19.ItWalletSpecsVersion.V1_4]: (o) => fetchMetadataV1_4(o)
|
|
@@ -2196,6 +2225,7 @@ var WalletProvider = class {
|
|
|
2196
2225
|
zKeyAttestationStatus,
|
|
2197
2226
|
zKeyAttestationTypeHeader,
|
|
2198
2227
|
zMetadataResponse,
|
|
2228
|
+
zMetadataResponseAPTITUDE,
|
|
2199
2229
|
zMetadataResponseV1_0,
|
|
2200
2230
|
zMetadataResponseV1_3,
|
|
2201
2231
|
zMetadataResponseV1_4,
|