This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.covibe: re-login when the cached session has expired

+10 -2
+10 -2
tools/covibe/flake-module.nix
··· 52 52 text = '' 53 53 server=${server} 54 54 tokens="$HOME/.omnigent/auth_tokens.json" 55 - if ! jq -e --arg s "$server" '.[$s].token // empty' "$tokens" >/dev/null 2>&1; then 56 - echo "covibe: no session for $server yet, logging in" >&2 55 + # The cached session is a JWT with a server-side TTL 56 + # (OMNIGENT_OIDC_SESSION_TTL_HOURS), so "a token exists" is not the 57 + # same as "we are logged in": a stale entry makes omnigent fail with 58 + # `Pi session creation failed (401): Authentication required` 59 + # instead of re-authenticating. Check the recorded expiry (with a 60 + # minute of slack, via jq's own clock so this needs no coreutils). 61 + if ! jq -e --arg s "$server" \ 62 + '((.[$s].expires_at // 0) > (now + 60)) and ((.[$s].token // "") != "")' \ 63 + "$tokens" >/dev/null 2>&1; then 64 + echo "covibe: no valid session for $server, logging in" >&2 57 65 omnigent login "$server" 58 66 fi 59 67 exec omnigent pi --server "$server" "$@"