06-oct: [omniroute] re-auth provider Claude + helper OAuth y vigilante portapapeles

This commit is contained in:
minguezsanzjuanjose
2026-10-06 14:44:40 +02:00
parent cba0e1f931
commit f484eaab38
4 changed files with 135 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
Add-Type -AssemblyName System.Windows.Forms
$codeFile = "C:\Users\juanm\Documents\Github\INFRAESTRUCTURA\omniroute\oauth_code.txt"
$exitFile = "C:\Users\juanm\Documents\Github\INFRAESTRUCTURA\omniroute\oauth_helper.exit"
$last = ""
try { $last = [System.Windows.Forms.Clipboard]::GetText() } catch {}
$deadline = (Get-Date).AddMinutes(20)
while ((Get-Date) -lt $deadline) {
if (Test-Path $exitFile) { break }
$c = ""
try { $c = [System.Windows.Forms.Clipboard]::GetText() } catch {}
if ($c -and $c -ne $last -and $c.Length -ge 20 -and ($c -match "#" -or $c -match "code=")) {
# Limpiar espacios/saltos por si copia con formato
$clean = $c.Trim()
if ($clean -match "https?://") {
$m = [regex]::Match($clean, "code=([^&#\s]+)")
$s = [regex]::Match($clean, "state=([^&#\s]+)")
if ($m.Success -and $s.Success) { $clean = $m.Groups[1].Value + "#" + $s.Groups[1].Value }
}
Set-Content -Path $codeFile -Value $clean -NoNewline
break
}
$last = $c
Start-Sleep -Milliseconds 700
}