3 Commits
Author SHA1 Message Date
Enes Yakıştır ebec73d7aa ci: ensure latest npm CLI and clean OIDC env in publish workflow
Publish PeerTube Plugin to npm / publish (push) Canceled after 0s
2026-12-01 19:19:56 +03:00
Enes Yakıştır 878a13c229 ci: add .npmignore and automated GitHub Actions npm publish workflow
Publish PeerTube Plugin to npm / publish (push) Canceled after 0s
2026-12-01 19:13:49 +03:00
Enes Yakıştır cae4aedeae perf(v1.1.1): replace polling intervals with debounced MutationObserver and accessible SSO live region 2026-12-01 18:42:06 +03:00
4 changed files with 133 additions and 7 deletions
+55
View File
@@ -0,0 +1,55 @@
name: Publish PeerTube Plugin to npm
on:
push:
branches:
- main
- master
tags:
- 'v*'
release:
types:
- published
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Syntax check main plugin entrypoint
run: node --check main.js
- name: Check npm version and publish if new
shell: bash
env:
NPM_TOKEN_SECRET: ${{ secrets.NPM_TOKEN }}
run: |
PKG_NAME=$(node -p "require('./package.json').name")
PKG_VER=$(node -p "require('./package.json').version")
PUBLISHED=$(npm view "${PKG_NAME}@${PKG_VER}" version 2>/dev/null || true)
if [ "$PUBLISHED" = "$PKG_VER" ]; then
echo "Version ${PKG_VER} of ${PKG_NAME} is already on npm. Skipping publish."
exit 0
fi
if [ -n "$NPM_TOKEN_SECRET" ]; then
printf "//registry.npmjs.org/:_authToken=%s\n" "$NPM_TOKEN_SECRET" > ~/.npmrc
npm publish --access public
else
npm install -g npm@latest
npm -v
npm publish --provenance --access public
fi
+4
View File
@@ -0,0 +1,4 @@
docs/
*.log
.git
.github
+72 -5
View File
@@ -8,6 +8,49 @@ async function register({ registerHook, peertubeHelpers }) {
authBaseUrl: 'https://developer-console.yakhub.com.tr' authBaseUrl: 'https://developer-console.yakhub.com.tr'
}; };
function hasPendingReturnUrl() {
try {
return Boolean(
localStorage.getItem('yaktube_return_url') ||
sessionStorage.getItem('yaktube_return_url') ||
sessionStorage.getItem('redirect-url-after-login')
);
} catch (e) {
return false;
}
}
function announceSsoStatus(message) {
try {
var region = document.getElementById('yaknet-sso-live-region');
if (!region && document.body) {
region = document.createElement('div');
region.id = 'yaknet-sso-live-region';
region.setAttribute('role', 'status');
region.setAttribute('aria-live', 'polite');
region.setAttribute('aria-atomic', 'true');
region.style.cssText =
'position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;';
document.body.appendChild(region);
}
if (region) {
region.textContent = '';
setTimeout(function () {
region.textContent = message;
}, 50);
}
} catch (e) {}
}
var postLoginCheckTimer = null;
function stopPostLoginPolling() {
if (postLoginCheckTimer) {
clearInterval(postLoginCheckTimer);
postLoginCheckTimer = null;
}
}
function saveReturnUrlBeforeLogin() { function saveReturnUrlBeforeLogin() {
try { try {
var currentPath = window.location.pathname + window.location.search + window.location.hash; var currentPath = window.location.pathname + window.location.search + window.location.hash;
@@ -22,6 +65,10 @@ async function register({ registerHook, peertubeHelpers }) {
function checkPendingPostLoginRedirect() { function checkPendingPostLoginRedirect() {
try { try {
if (!hasPendingReturnUrl()) {
stopPostLoginPolling();
return;
}
if (window.location.pathname.includes('/login')) return; if (window.location.pathname.includes('/login')) return;
var token = localStorage.getItem('access_token'); var token = localStorage.getItem('access_token');
if (!token) return; if (!token) return;
@@ -29,13 +76,18 @@ async function register({ registerHook, peertubeHelpers }) {
localStorage.getItem('yaktube_return_url') || localStorage.getItem('yaktube_return_url') ||
sessionStorage.getItem('yaktube_return_url') || sessionStorage.getItem('yaktube_return_url') ||
sessionStorage.getItem('redirect-url-after-login'); sessionStorage.getItem('redirect-url-after-login');
if (!savedUrl) return; if (!savedUrl) {
stopPostLoginPolling();
return;
}
var savedTime = parseInt(localStorage.getItem('yaktube_return_url_time') || '0', 10); var savedTime = parseInt(localStorage.getItem('yaktube_return_url_time') || '0', 10);
localStorage.removeItem('yaktube_return_url'); localStorage.removeItem('yaktube_return_url');
localStorage.removeItem('yaktube_return_url_time'); localStorage.removeItem('yaktube_return_url_time');
sessionStorage.removeItem('yaktube_return_url'); sessionStorage.removeItem('yaktube_return_url');
sessionStorage.removeItem('redirect-url-after-login'); sessionStorage.removeItem('redirect-url-after-login');
stopPostLoginPolling();
if (savedTime && Date.now() - savedTime > 15 * 60 * 1000) return; if (savedTime && Date.now() - savedTime > 15 * 60 * 1000) return;
announceSsoStatus('YakNet hesabınızla oturum açıldı.');
var currentFull = window.location.pathname + window.location.search + window.location.hash; var currentFull = window.location.pathname + window.location.search + window.location.hash;
if ( if (
typeof savedUrl === 'string' && typeof savedUrl === 'string' &&
@@ -51,7 +103,9 @@ async function register({ registerHook, peertubeHelpers }) {
checkPendingPostLoginRedirect(); checkPendingPostLoginRedirect();
window.addEventListener('popstate', checkPendingPostLoginRedirect); window.addEventListener('popstate', checkPendingPostLoginRedirect);
setInterval(checkPendingPostLoginRedirect, 800); if (hasPendingReturnUrl()) {
postLoginCheckTimer = setInterval(checkPendingPostLoginRedirect, 800);
}
// Left Menu Hook for "YakNet Hesabım" Link (Configurable from Settings) // Left Menu Hook for "YakNet Hesabım" Link (Configurable from Settings)
if (typeof registerHook === 'function') { if (typeof registerHook === 'function') {
@@ -135,7 +189,7 @@ async function register({ registerHook, peertubeHelpers }) {
wrapper.className = 'yaknet-sso-login-wrapper'; wrapper.className = 'yaknet-sso-login-wrapper';
wrapper.innerHTML = wrapper.innerHTML =
'<a href="/plugins/auth-yaknet/router/auth" class="yaknet-sso-btn" role="button">' + '<a href="/plugins/auth-yaknet/router/auth" class="yaknet-sso-btn" role="button">' +
'<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg>' + '<svg aria-hidden="true" focusable="false" width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg>' +
'<span>YakNet ile Tek Tıkla Giriş Yap</span>' + '<span>YakNet ile Tek Tıkla Giriş Yap</span>' +
'</a>' + '</a>' +
'<div class="yaknet-divider"><span>veya yerel hesap şifresiyle</span></div>'; '<div class="yaknet-divider"><span>veya yerel hesap şifresiyle</span></div>';
@@ -160,7 +214,7 @@ async function register({ registerHook, peertubeHelpers }) {
accountLink.target = '_blank'; accountLink.target = '_blank';
accountLink.rel = 'noopener noreferrer'; accountLink.rel = 'noopener noreferrer';
accountLink.innerHTML = accountLink.innerHTML =
'<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="vertical-align:-2px;"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg> ' + '<svg aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" style="vertical-align:-2px;"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg> ' +
'<span>YakNet Hesabımı Yönet ↗</span>'; '<span>YakNet Hesabımı Yönet ↗</span>';
userMenu.appendChild(accountLink); userMenu.appendChild(accountLink);
} }
@@ -169,7 +223,20 @@ async function register({ registerHook, peertubeHelpers }) {
} catch (uiErr) {} } catch (uiErr) {}
} }
setInterval(injectYakNetUI, 1000); var uiInjectDebounce = null;
function scheduleInjectYakNetUI() {
if (uiInjectDebounce) return;
uiInjectDebounce = setTimeout(function () {
uiInjectDebounce = null;
injectYakNetUI();
}, 150);
}
if (typeof MutationObserver === 'function' && document.body) {
var yaknetDomObserver = new MutationObserver(scheduleInjectYakNetUI);
yaknetDomObserver.observe(document.body, { childList: true, subtree: true });
}
setInterval(injectYakNetUI, 5000);
document.addEventListener('DOMContentLoaded', injectYakNetUI); document.addEventListener('DOMContentLoaded', injectYakNetUI);
// Fetch Plugin Configuration from Backend // Fetch Plugin Configuration from Backend
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "peertube-plugin-auth-yaknet", "name": "peertube-plugin-auth-yaknet",
"version": "1.1.0", "version": "1.1.1",
"description": "YakNet SSO & OAuth2 Single Sign-On Authentication Plugin for PeerTube", "description": "YakNet SSO & OAuth2 Single Sign-On Authentication Plugin for PeerTube",
"main": "main.js", "main": "main.js",
"library": "./main.js", "library": "./main.js",
@@ -35,7 +35,7 @@
"author": "Enes Yakıştır <[email protected]>", "author": "Enes Yakıştır <[email protected]>",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/yakistir98/peertube-plugin-auth-yaknet.git" "url": "git+https://github.com/yakistir98/peertube-plugin-auth-yaknet.git"
}, },
"homepage": "https://yaktube.yakhub.com.tr", "homepage": "https://yaktube.yakhub.com.tr",
"bugs": "https://github.com/yakistir98/peertube-plugin-auth-yaknet/issues", "bugs": "https://github.com/yakistir98/peertube-plugin-auth-yaknet/issues",