From fcd21e72e5608c952ae0e6cb73599965c1bb66a4 Mon Sep 17 00:00:00 2001 From: Spaghet Date: Mon, 23 Nov 2026 23:51:54 -0500 Subject: [PATCH] Piped login: real username from /feed/rss subtitle (Split-based parse); profiles DELETE needs X-Playlet header + urlencoded id --- playlet-app/src/manifest | 2 +- .../Middleware/PipedBackendRouter.bs | 2 +- .../Middleware/PipedLoginRouter.bs | 30 +++++++++++++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/playlet-app/src/manifest b/playlet-app/src/manifest index 7d47ea6e..640ec43f 100644 --- a/playlet-app/src/manifest +++ b/playlet-app/src/manifest @@ -40,7 +40,7 @@ requires_widevine_version=1.0 playlet_lib_squashfs_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.squashfs.pkg playlet_lib_zip_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip playlet_lib_zip_embedded_url=pkg:/lib/playlet-lib.zip -playlet_lib_zip_debug_url=https://gitea.spaghet.io/spaghet/playlet-piped/raw/branch/main/piped/playlet-lib-1795491297.zip +playlet_lib_zip_debug_url=https://gitea.spaghet.io/spaghet/playlet-piped/raw/branch/main/piped/playlet-lib-1795495815.zip git_commit_sha=unknown diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PipedBackendRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PipedBackendRouter.bs index d9402080..eae12597 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PipedBackendRouter.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PipedBackendRouter.bs @@ -129,7 +129,7 @@ namespace Http end function function LibBuildTag() as string - return "PIPED-LIB-19" + return "PIPED-LIB-23" end function function FetchJson(path as string, params = invalid as object) as dynamic diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PipedLoginRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PipedLoginRouter.bs index 5358e62b..49a9ee5e 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PipedLoginRouter.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PipedLoginRouter.bs @@ -383,20 +383,40 @@ namespace Http return true end function + ' The fork has no /user endpoint, but the authenticated RSS feed names + ' the account: its is "Piped's RSS subscription feed for + ' .". Read the username from there; fall back to a stable + ' uuid label if the shape ever changes. (The profile name is cosmetic.) function LookupUsername(sessionUuid as string) as string instance = m.GetInstance() if StringUtils.IsNullOrEmpty(instance) return "piped" end if - res = HttpClient.Get(`${instance}/subscriptions`).Header("Authorization", sessionUuid).Await() + ' /feed/rss authenticates via ?authToken= (same contract as /feed). + ' The pb nonce keeps this off Piped's ThrottlingCache replay keys. + nonce = CreateObject("roDeviceInfo").GetRandomUUID() + url = `${instance}/feed/rss?authToken=${sessionUuid}&pb=${nonce}` + res = HttpClient.Get(url).Await() + xml = "" if res.IsSuccess() - ' no username in the body; just prove the session works + xml = res.Text() + end if + if not StringUtils.IsNullOrEmpty(xml) + ' Split instead of Mid/InStr: substring indexing disagreed with + ' the docs on this firmware (both off-by-one directions shipped + ' wrong results); Split boundaries are unambiguous. + marker = "feed for " + parts = xml.Split(marker) + if parts.Count() > 1 + tail = ValidString(parts[1]) + name = ValidString(tail.Split(".")[0]) + if name.Len() > 0 and name.Len() < 25 + return name + end if + end if end if - ' Piped has no /user endpoint on this fork; the SSO broker's username - ' equals the Authentik identity, which we can't see here. Fall back - ' to a stable label. (The profile display name is cosmetic.) return "piped-" + Left(sessionUuid, 8) end function