๐Ÿ“ฆโž”๐Ÿฆ‹ Store and retrieve files on the Atmosphere

add JWT refreshing

+12 -13
+11 -12
src/commands/auth.sh
··· 76 76 77 77 # TODO: Handle accessJwt expiry 78 78 if [[ -n "$error" ]]; then 79 - #if [[ $error == "[InvalidToken] Token could not be verified" ]]; then 80 - # session="$(com.atproto.server.refreshSession)" 81 - # error="$(atfile.util.get_xrpc_error $? "$session")" 82 - # 83 - # if [[ -n $error ]]; then 84 - # atfile.cache.del "token" 85 - # atfile.die.xrpc_error "Unable to refresh token" "$error" 86 - # fi 87 - #else 88 - # atfile.die.xrpc_error "Unable to authenticate" "$error" 89 - #fi 90 - atfile.die.xrpc_error "Unable to authenticate" "$error" 79 + if [[ $error == "[ExpiredToken]"* ]];then 80 + session="$(com.atproto.server.refreshSession)" 81 + error="$(atfile.util.get_xrpc_error $? "$session")" 82 + 83 + if [[ -n $error ]]; then 84 + atfile.cache.del "token" 85 + atfile.die.xrpc_error "Unable to refresh session" "$error" 86 + fi 87 + else 88 + atfile.die.xrpc_error "Unable to authenticate" "$error" 89 + fi 91 90 else 92 91 _username="$(echo "$session" | jq -r ".did")" 93 92 fi
+1 -1
src/lexi/com_atproto.sh
··· 77 77 78 78 function com.atproto.server.refreshSession() { 79 79 refresh_token="$(atfile.util.get_token_cache "refresh")" 80 - atfile.xrpc.pds.get "com.atproto.server.refreshSession" "" "" "Bearer $refresh_token" 80 + atfile.xrpc.pds.post "com.atproto.server.refreshSession" "" "" "Bearer $refresh_token" 81 81 } 82 82 83 83 function com.atproto.sync.uploadBlob() {