NAME

Net::Blossom::URI - BUD-10 Blossom URI value object

SYNOPSIS

use Net::Blossom::URI;

my $uri = Net::Blossom::URI->new(
    sha256    => $sha256,
    extension => 'png',
    xs        => ['cdn.example.com'],
    as        => [$pubkey],
    sz        => 1234,
);

my $string = $uri->to_string;
my $parsed = Net::Blossom::URI->parse($string);

DESCRIPTION

Net::Blossom::URI builds and parses BUD-10 blossom: URIs.

CONSTRUCTORS

new

my $uri = Net::Blossom::URI->new(%args);

Required sha256 must be lowercase 64-character hex.

Optional extension defaults to bin and must contain only letters and digits. A leading dot is removed.

Optional xs is an array reference of server hints. Each hint must be a domain or HTTP/HTTPS root URL without a path. Optional as is an array reference of lowercase 64-character author public keys. Optional sz is a positive integer byte size.

Unknown arguments or invalid values croak.

parse

my $uri = Net::Blossom::URI->parse($value);

Parses a blossom: URI and returns a Net::Blossom::URI object. Fragments are rejected. Unknown query parameters, duplicate sz, missing values, and invalid percent encoding croak.

ACCESSORS

sha256

Returns the lowercase SHA-256 hash.

extension

Returns the extension without a leading dot.

xs

Returns the server hint array reference.

as

Returns the author hint array reference.

sz

Returns the optional byte size.

METHODS

to_string

my $value = $uri->to_string;

Returns the blossom: URI string. Query parameters are emitted in xs, as, then sz order.