ai/at
1
0

update scpt

This commit is contained in:
2024-12-27 21:36:13 +09:00
parent f26ef781f3
commit b5e44947da
14 changed files with 206 additions and 84 deletions

View File

@ -8,7 +8,7 @@ source $d/src/func.zsh
at-env
case $1 in
version|v)
at-version
at-version $2
;;
uri|u)
at-uri $2

View File

@ -1,5 +1,5 @@
function at-env() {
host=bsky.social
host=https://bsky.social
handle_syui=syui.ai
handle_yui=yui.syui.ai
did_yui=did:plc:4hqjfn7m6n5hno3doamuhgef
@ -15,6 +15,7 @@ function at-env() {
d=${0:a:h}
f=~/.config/.at-zsh.json
if [ -f $f ];then
host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"`
token=`cat $f|jq -r .accessJwt`
did=`cat $f|jq -r .did`
handle=`cat $f|jq -r .handle`
@ -26,8 +27,45 @@ function at-unset() {
unset t password token refresh
}
function at-version-env() {
case $1 in
bsky)
tag=$1
list=( public.api.bsky.app bsky.syu.is )
;;
ozone)
tag=$1
list=( ozone.bsky.social ozone.syu.is )
;;
*)
tag=pds
list=( bsky.social syu.is boobee.blue socl.is )
;;
esac
title="atproto $tag version"
latest=https://raw.githubusercontent.com/bluesky-social/atproto/refs/heads/main/packages/$tag/package.json
# bgs=( bsky.network bgs.syu.is )
# plc=( plc.directory plc.syu.is )
}
function at-version-json() {
latest=`curl -sL $latest |jq -r .version`
echo "[{\"title\":\"$title\",\"latest\":\"$latest\"},["
e=${list[@]: -1}
for i in $list; do
t=`curl -sL ${i}/xrpc/_health |jq -r .version`
echo "{\"$i\":\"$t\"}"
if [ "$e" != "$i" ];then
echo ,
fi
done
echo "]]"
}
function at-version() {
curl -sL ${host}/xrpc/_health |jq .
at-version-env $1
at-version-json |jq .
}
function at-uri() {
@ -98,7 +136,7 @@ function at-refresh() {
echo $f
token=`cat $f|jq -r .refreshJwt`
req=/xrpc/com.atproto.server.refreshSession
url=https://${host}${req}
url=${host}${req}
t=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url`
if echo $t |jq .;then
echo $t >! $f
@ -109,13 +147,13 @@ function at-cid() {
did=`at-did $1|jq -r .did`
cid=$2
req=/xrpc/com.atproto.sync.getBlob
url="https://${host}${req}?did=${did}&cid=${cid}"
url="${host}${req}?did=${did}&cid=${cid}"
curl -sL $url
}
function at-session() {
req=/xrpc/com.atproto.server.getSession
url=https://${host}${req}
url=${host}${req}
t=`curl -sL -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url`
if ! echo $t |jq .;then
echo refresh
@ -131,6 +169,6 @@ function at-profile() {
t=`at-session`
fi
req=/xrpc/app.bsky.actor.getProfile
url="https://${host}${req}?actor=$did"
url="${host}${req}?actor=$did"
curl -sL -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url|jq .
}

View File

@ -37,3 +37,4 @@ github=(
https://github.com/did-method-plc/did-method-plc
)
tag=( at bsky bsync pds bgs plc ozone feed jetstream social-app oauth )
#pds_list=(bsky.social syu.is boobee.blue socl.is )