NAME
Net::Blossom::ServerList - BUD-03 Blossom server-list value object
SYNOPSIS
use Net::Blossom::ServerList;
my $list = Net::Blossom::ServerList->new(
servers => [
'https://cdn.example.com',
'https://backup.example.com',
],
);
my $servers = $list->servers;
DESCRIPTION
Net::Blossom::ServerList represents a user's BUD-03 list of Blossom servers. Server order is preserved. The first server is treated as primary by helper methods. This class is a Blossom-facing wrapper around Net::Nostr::Blossom.
CONSTRUCTORS
new
my $list = Net::Blossom::ServerList->new(servers => \@servers);
Creates a server list from an array reference of HTTP or HTTPS base URLs. At least one server is required. Unknown arguments or invalid server URLs croak. Server URL validation is provided by Net::Nostr::Blossom.
from_event
my $list = Net::Blossom::ServerList->from_event($event);
Builds a server list from a kind 10063 Net::Nostr::Event. server tags are read in order. Plain hash references are not accepted; parse wire data with Net::Nostr::Event first.
METHODS
servers
my $servers = $list->servers;
Returns a copy array reference of server base URLs. Mutating the returned array reference does not mutate the object.
primary_server
my $server = $list->primary_server;
Returns the first listed server.
to_tags
my $tags = $list->to_tags;
Returns a Nostr tag array reference containing one server tag per server.
to_event
my $event = $list->to_event(%event_args);
Returns a Net::Nostr::Event for kind 10063. Arguments are passed through to Net::Nostr::Event->new; kind, content, and tags are supplied by the server list.
extract_sha256
my $sha256 = Net::Blossom::ServerList->extract_sha256($url);
Extracts and returns the last 64-character hex SHA-256 value from $url, normalized to lowercase. Returns undef when no hash is found.
extract_blob_reference
my ($sha256, $extension) =
Net::Blossom::ServerList->extract_blob_reference($url);
Extracts the last SHA-256 hash and an optional alphanumeric extension. Returns an empty list when no hash is found.
blob_urls_for
my $urls = $list->blob_urls_for($url);
Builds fallback blob URLs for every server in the list using the hash and optional extension extracted from $url. Returns an array reference. Returns an empty array reference when $url does not contain a hash.