fix and update

This commit is contained in:
lendry
2026-06-29 14:40:35 +03:00
parent 75ccbe5fc4
commit 0df7240dc8
21 changed files with 934 additions and 113 deletions

View File

@@ -71,30 +71,66 @@
return Promise.resolve(null);
}
return global.navigator.credentials
.get({
identity: {
providers: [
{
configURL: idpApiBase + '/fedcm/config.json',
clientId: clientId
}
]
},
mediation: 'optional'
function requestFedCM(configBase) {
return global.navigator.credentials
.get({
identity: {
providers: [
{
configURL: configBase + '/fedcm/config.json',
configUrl: configBase + '/fedcm/config.json',
clientId: clientId
}
]
},
mediation: 'optional'
})
.then(function (credential) {
if (!credential || typeof credential !== 'object') return null;
var token = credential.token;
if (!token) return null;
return {
token: token,
method: 'fedcm'
};
});
}
return global.fetch(idpApiBase + '/fedcm/discover.json', { credentials: 'omit' })
.then(function (response) {
if (!response.ok) {
return idpApiBase;
}
return response.json().then(function (payload) {
if (payload && payload.enabled === false) {
return null;
}
if (payload && payload.apiBase) {
return trimSlash(payload.apiBase);
}
return idpApiBase;
});
})
.then(function (credential) {
if (!credential || typeof credential !== 'object') return null;
var token = credential.token;
if (!token) return null;
return {
token: token,
method: 'fedcm'
};
.catch(function () {
return idpApiBase;
})
.then(function (resolvedBase) {
if (!resolvedBase) {
return null;
}
return requestFedCM(resolvedBase);
})
.catch(function (error) {
if (global.console && typeof global.console.warn === 'function') {
global.console.warn('[MVK ID] FedCM недоступен:', error);
global.console.warn(
'[MVK ID] FedCM недоступен:',
error,
'Проверьте доступность',
idpApiBase + '/fedcm/config.json',
'и',
idpApiBase.replace(/\/idp-api$/, '') + '/.well-known/web-identity',
'(PUBLIC_API_URL должен совпадать с data-idp-url виджета)'
);
}
return null;
});
@@ -232,10 +268,6 @@
return;
}
if (supportsFedCM()) {
return;
}
createWidget(providerName, function () {
var popupUrl = buildPopupUrl(frontendBase, clientId, global.location.origin, redirectUri, scope);
openPopup(popupUrl, frontendBase, function (payload) {