šŸ“¦āž”šŸ¦‹ Store and retrieve files on the Atmosphere
34
fork

Configure Feed

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

at dev 100 lines 2.5 kB view raw
1#!/usr/bin/env bash 2 3# PDS 4 5function atfile.xrpc.pds.blob() { 6 file="$1" 7 type="$2" 8 lexi="$3" 9 10 [[ -z $lexi ]] && lexi="com.atproto.repo.uploadBlob" 11 [[ -z $type ]] && type="*/*" 12 13 atfile.http.upload \ 14 "$_server/xrpc/$lexi" \ 15 "$file" \ 16 "Bearer $(atfile.xrpc.pds.jwt)" \ 17 "$type" | jq 18} 19 20function atfile.xrpc.pds.get() { 21 lexi="$1" 22 query="$2" 23 type="$3" 24 endpoint="$4" 25 26 [[ -z $endpoint ]] && endpoint="$_server" 27 28 atfile.http.get \ 29 "$endpoint/xrpc/$lexi?$query" \ 30 "Bearer $(atfile.xrpc.pds.jwt)" \ 31 "$type" | jq 32} 33 34# shellcheck disable=SC2120 35function atfile.xrpc.pds.jwt() { 36 token="$1" 37 38 [[ -z "$token" ]] && token="$(atfile.util.get_token_cache "access")" 39 40 if [[ -z "$token" ]]; then 41 atfile.say.debug "Generating JWT for '$_username'..." 42 new_session="$(atfile.http.post \ 43 "$_server/xrpc/com.atproto.server.createSession" \ 44 '{"identifier": "'"$_username"'", "password": "'"$_password"'"}')" 45 46 token_access="$(echo "$new_session" | jq -r ".accessJwt")" 47 token_refresh="$(echo "$new_session" | jq -r ".refreshJwt")" 48 49 atfile.say.debug "Generated JWT\n↳ DID: $_username\n↳ Access: $token_access\n↳ Refresh: $token_refresh" 50 51 atfile.util.set_token_cache "$_username" "$token_access" "$token_refresh" > /dev/null 52 53 token="$token_access" 54 else 55 if [[ $_username == "$(atfile.util.get_token_cache "did")" ]]; then 56 atfile.say.debug "Reusing cached JWT for '$_username'..." 57 else 58 atfile.say.debug "Deleting JWT cache (DID does not match)..." 59 atfile.cache.del "token" 60 atfile.xrpc.pds.jwt 61 fi 62 fi 63 64 echo "$token" 65} 66 67function atfile.xrpc.pds.post() { 68 lexi="$1" 69 data="$2" 70 type="$3" 71 auth="$4" 72 73 [[ -z $type ]] && type="application/json" 74 [[ -z $auth ]] && auth="Bearer $(atfile.xrpc.pds.jwt)" 75 76 curl -s -X POST "$_server/xrpc/$lexi" \ 77 -H "Authorization: $auth" \ 78 -H "Content-Type: $type" \ 79 -H "User-Agent: $(atfile.util.get_uas)" \ 80 -d "$data" | jq 81} 82 83# AppView 84 85## Bluesky 86 87function atfile.xrpc.bsky.get() { 88 lexi="$1" 89 query="$2" 90 type="$3" 91 appview="$4" 92 93 # shellcheck disable=SC2154 94 [[ -z "$appview" ]] && appview="$_endpoint_appview" 95 96 atfile.http.get \ 97 "$appview/xrpc/$lexi?$query" \ 98 "" \ 99 "$type" | jq 100}