Some checks failed
release / build-release (push) Has been cancelled
- IChannel: creators -> sub-channels -> video posts (public listing API, search mapped) - IRequiresMediaInfoCallback -> signed proxy URLs; stream controller rewrites HLS so the AES-128 key is fetched server-side with the session cookie, segments stay on the CDN - delivery/info cached per token lifetime and throttled (~2/min) - config page: paste sails.sid + validate, extra creators, quality, search test - scripts/package.sh -> plugin folder + zip + md5 + manifest.json; Gitea release workflow - research docs, HAR analysis (HAR itself gitignored), install-pi5.sh Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
70 lines
1.8 KiB
Plaintext
70 lines
1.8 KiB
Plaintext
' Validates the access token with the server by calling a lightweight authenticated endpoint.
|
|
' 200 = valid, 401 = invalid (tokens cleared). Run in a Task so network is off render thread.
|
|
sub init()
|
|
m.top.functionName = "validate"
|
|
end sub
|
|
|
|
sub validate()
|
|
tokenUtilObj = TokenUtil()
|
|
accessToken = tokenUtilObj.getAccessToken(false)
|
|
if accessToken = invalid then
|
|
m.top.isValid = false
|
|
m.top.error = "Not authenticated"
|
|
m.top.done = true
|
|
return
|
|
end if
|
|
|
|
appInfo = createObject("roAppInfo")
|
|
version = appInfo.getVersion()
|
|
useragent = "Hydravion (Roku) v" + version
|
|
apiConfigObj = ApiConfig()
|
|
url = apiConfigObj.buildApiUrl("/api/v3/user/subscriptions")
|
|
|
|
xfer = CreateObject("roUrlTransfer")
|
|
xfer.RetainBodyOnError(true)
|
|
port = CreateObject("roMessagePort")
|
|
xfer.SetMessagePort(port)
|
|
xfer.SetUrl(url)
|
|
xfer.setCertificatesFile("common:/certs/ca-bundle.crt")
|
|
xfer.AddHeader("Accept", "application/json")
|
|
xfer.AddHeader("User-Agent", useragent)
|
|
xfer.AddHeader("Authorization", "Bearer " + accessToken)
|
|
xfer.initClientCertificates()
|
|
|
|
if not xfer.AsyncGetToString() then
|
|
m.top.isValid = false
|
|
m.top.error = "Request failed"
|
|
m.top.done = true
|
|
return
|
|
end if
|
|
|
|
event = wait(10000, port)
|
|
if type(event) <> "roUrlEvent" then
|
|
if event = invalid then
|
|
xfer.AsyncCancel()
|
|
end if
|
|
m.top.isValid = false
|
|
m.top.error = "Timeout or cancelled"
|
|
m.top.done = true
|
|
return
|
|
end if
|
|
|
|
code = event.GetResponseCode()
|
|
if code = 200 then
|
|
m.top.isValid = true
|
|
m.top.done = true
|
|
return
|
|
end if
|
|
|
|
if code = 401 then
|
|
tokenUtilObj = TokenUtil()
|
|
tokenUtilObj.clearTokens()
|
|
m.top.isValid = false
|
|
m.top.error = "Token rejected by server (401)"
|
|
else
|
|
m.top.isValid = false
|
|
m.top.error = "Unexpected response " + code.ToStr()
|
|
end if
|
|
m.top.done = true
|
|
end sub
|