diff --git a/README.md b/README.md index a133ae4..c4e274f 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ atfile help * Both GNU and BusyBox versions supported * [`websocat`](https://github.com/vi/websocat) _(optional: needed for `stream`)_ * **ATProto account** - * Both [Bluesky PLC-operated](https://bsky.social) and self-hosted accounts supported - * If you're using a `bsky.network` (`@*.bsky.social`) account, limit the amount of files you upload to Bluesky PLC's servers. Heed the copyright warning: **do not upload copyrighted files.** + * Both [Bluesky PBC-operated](https://bsky.social) and self-hosted accounts supported + * If you're using a `bsky.network` (`@*.bsky.social`) account, limit the amount of files you upload to Bluesky PBC's servers. Heed the copyright warning: **do not upload copyrighted files.** * `did:web` accounts supported! * Confirmed to work on [Bluesky PDS](https://github.com/bluesky-social/pds) and [millipds](https://github.com/DavidBuchanan314/millipds) * Other PDSs remain untested, but if they implement standard `com.atproto.*` endpoints, there should be no reason these won't work diff --git a/src/commands/help.sh b/src/commands/help.sh index fb279e0..e9e5563 100644 --- a/src/commands/help.sh +++ b/src/commands/help.sh @@ -157,7 +157,12 @@ function atfile.help() { ℹ️ Your PDS is resolved from your username. Set to override it (or if resolving fails) ${_envvar_prefix}_ENDPOINT_PLC_DIRECTORY (default: ${_endpoint_plc_directory_default}$([[ $_endpoint_plc_directory_default == *"zio.blue" ]] && echo "²")) - Endpoint of the PLC directory\n + Endpoint of the PLC directory + ${_envvar_prefix}_DISABLE_PBC_FALLBACK (default: $_disable_pbc_fallback) + Disable the (hardcoded) usage of various Bluesky PBC-hosted fallbacks + if/when required. Currently, there are fallbacks for: + * ${_envvar_prefix}_ENDPOINT_APPVIEW ($_endpoint_appview_fallback) + * ${_envvar_prefix}_ENDPOINT_PLC_DIRECTORY ($_endpoint_plc_directory_fallback)\n ${_envvar_prefix}_DEBUG (default: $_debug_default) Print debug outputs ⚠️ When output is JSON (${_envvar_prefix}_OUTPUT_JSON=1), sets to 0 diff --git a/src/entry.sh b/src/entry.sh index 1f784b5..0725d82 100644 --- a/src/entry.sh +++ b/src/entry.sh @@ -69,6 +69,7 @@ _path_envvar="$(atfile.util.get_envvar "${_envvar_prefix}_PATH_CONF" "$_path_env _debug_default=$([[ $ATFILE_DEVEL == 1 ]] && echo 1 || echo 0) _devel_publish_default=0 +_disable_pbc_fallback_default=0 _disable_update_checking_default=0 _disable_updater_default=0 _dist_username_default="$_meta_did" @@ -92,6 +93,7 @@ _skip_unsupported_os_warn_default=0 #### Fallbacks +_endpoint_appview_fallback="https://api.bsky.app" _endpoint_plc_directory_fallback="https://plc.directory" _max_list_fallback=100 @@ -99,6 +101,7 @@ _max_list_fallback=100 _debug="$(atfile.util.get_envvar "${_envvar_prefix}_DEBUG" "$_debug_default")" _devel_publish="$(atfile.util.get_envvar "${_envvar_prefix}_DEVEL_PUBLISH" $_devel_publish_default)" +_disable_pbc_fallback="$(atfile.util.get_envvar "${_envvar_prefix}_DISABLE_PBC_FALLBACK" $_disable_pbc_fallback_default)" _disable_update_checking="$(atfile.util.get_envvar "${_envvar_prefix}_DISABLE_UPDATE_CHECKING" $_disable_update_checking_default)" _disable_updater="$(atfile.util.get_envvar "${_envvar_prefix}_DISABLE_UPDATER" $_disable_updater_default)" _dist_password="$(atfile.util.get_envvar "${_envvar_prefix}_DIST_PASSWORD")" diff --git a/src/lexi/app_bsky.sh b/src/lexi/app_bsky.sh index f08cec5..3d125f6 100644 --- a/src/lexi/app_bsky.sh +++ b/src/lexi/app_bsky.sh @@ -7,11 +7,23 @@ function app.bsky.actor.getProfile() { actor="$1" - atfile.xrpc.bsky.get "app.bsky.actor.getProfile" "actor=$actor" + # NOTE: AppViewLite does not fully support app.bsky.actor.getProfile + # shellcheck disable=SC2154 + appview="$_endpoint_appview_fallback" + # shellcheck disable=SC2154 + [[ $_disable_pbc_fallback == 1 ]] && unset appview + + atfile.xrpc.bsky.get "app.bsky.actor.getProfile" "actor=$actor" "" "$appview" } function app.bsky.labeler.getServices() { did="$1" + + # NOTE: AppViewLite does not fully support app.bsky.labeler.getServices + # shellcheck disable=SC2154 + appview="$_endpoint_appview_fallback" + # shellcheck disable=SC2154 + [[ $_disable_pbc_fallback == 1 ]] && unset appview atfile.xrpc.bsky.get "app.bsky.labeler.getServices" "dids=$did" } diff --git a/src/shared/util.sh b/src/shared/util.sh index b88f941..0f8b06a 100644 --- a/src/shared/util.sh +++ b/src/shared/util.sh @@ -264,10 +264,13 @@ function atfile.util.get_didplc_doc() { didplc_endpoint="$_endpoint_plc_directory" didplc_doc="$(atfile.util.get_didplc_doc.request_doc "$didplc_endpoint" "$actor")" - if [[ "$didplc_doc" != "{"* ]]; then - # shellcheck disable=SC2154 - didplc_endpoint="$_endpoint_plc_directory_fallback" - didplc_doc="$(atfile.util.get_didplc_doc.request_doc "$didplc_endpoint" "$actor")" + # shellcheck disable=SC2154 + if [[ $_disable_pbc_fallback == 0 ]]; then + if [[ "$didplc_doc" != "{"* ]]; then + # shellcheck disable=SC2154 + didplc_endpoint="$_endpoint_plc_directory_fallback" + didplc_doc="$(atfile.util.get_didplc_doc.request_doc "$didplc_endpoint" "$actor")" + fi fi echo "$didplc_doc" | jq ". += {\"directory\": \"$didplc_endpoint\"}" diff --git a/src/shared/xrpc.sh b/src/shared/xrpc.sh index 02bce85..789ff6c 100644 --- a/src/shared/xrpc.sh +++ b/src/shared/xrpc.sh @@ -59,9 +59,13 @@ function atfile.xrpc.bsky.get() { lexi="$1" query="$2" type="$3" + appview="$4" + + # shellcheck disable=SC2154 + [[ -z "$appview" ]] && appview="$_endpoint_appview" atfile.http.get \ - "$_endpoint_appview/xrpc/$lexi?$query" \ + "$appview/xrpc/$lexi?$query" \ "" \ "$type" | jq }