From 52480401c8c26f72c7fe3012f148995d092e870f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Yak=C4=B1=C5=9Ft=C4=B1r?= Date: Mon, 31 Aug 2026 20:35:08 +0300 Subject: [PATCH] feat(sso): add silent sso-frame probe to automatically recognize active YakNet sessions v1.4.15 --- client.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/client.js b/client.js index 5487558..d0f0dda 100644 --- a/client.js +++ b/client.js @@ -50,6 +50,52 @@ try { }, 50); } + // Load official YakNet Web Component definition + if ( + typeof customElements !== 'undefined' && + !customElements.get('yaknet-account') && + !document.getElementById('yaknet-account-script') + ) { + var s = document.createElement('script'); + s.id = 'yaknet-account-script'; + s.src = 'https://auth.yakhub.com.tr/js/yaknet-account.js'; + s.async = true; + document.head.appendChild(s); + } + + // Silent background SSO Probe Engine + function initSilentSSOProbe() { + var token = localStorage.getItem('access_token'); + var isManualLogout = sessionStorage.getItem('yaknet_manual_logout'); + if ( + token || + isManualLogout || + window.location.search.includes('local=true') || + window.location.search.includes('externalAuthError') || + window.location.pathname.includes('/login') + ) { + return; + } + + var iframeId = 'yaknet-sso-iframe-instance'; + if (!document.getElementById(iframeId)) { + var iframe = document.createElement('iframe'); + iframe.id = iframeId; + iframe.src = 'https://auth.yakhub.com.tr/sdk/sso-frame'; + iframe.title = 'YakNet Oturum Kontrolü'; + iframe.setAttribute('aria-hidden', 'true'); + iframe.tabIndex = -1; + iframe.style.cssText = + 'display:none!important;width:0!important;height:0!important;border:0!important;position:absolute!important;pointer-events:none!important;'; + document.body.appendChild(iframe); + } + } + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initSilentSSOProbe); + } else { + initSilentSSOProbe(); + } + function triggerYakNetOAuth() { sessionStorage.removeItem('yaknet_manual_logout'); var callbackUrl = 'https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback'; diff --git a/package.json b/package.json index dc64601..cf11cce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "peertube-plugin-yaktube-ondemand", - "version": "1.4.14", + "version": "1.4.15", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube", "main": "main.js", "library": "./main.js",