feat(cses): implement submit via REST API

Problem: CSES submit was a stub returning "not yet implemented".

Solution: authenticate via web login + API token bridge (POST
`/login` form, then POST `/api/login` and confirm the auth page),
submit source to `/api/courses/problemset/submissions` with
base64-encoded content, and poll for verdict. Uses the same
username/password credential model as AtCoder.

Also update `scraper.lua` to pass the full ndjson event to `on_status`
(instead of just the status string) and handle `credentials` events
for platforms that return updated credentials.
This commit is contained in:
Barrett Ruth 2026-03-05 01:03:53 -05:00
parent c194f12eee
commit 972044fd0f
3 changed files with 165 additions and 9 deletions

View file

@ -298,9 +298,12 @@ function M.submit(
stdin = source_code,
env_extra = { CP_CREDENTIALS = vim.json.encode(credentials) },
on_event = function(ev)
if ev.credentials ~= nil then
require('cp.cache').set_credentials(platform, ev.credentials)
end
if ev.status ~= nil then
if type(on_status) == 'function' then
on_status(ev.status)
on_status(ev)
end
elseif ev.success ~= nil then
done = true