NAME
At::Protocol::Handle - AT Protocol Handle Validation
SYNOPSIS
use At::Protocol::Handle qw[:all];
try {
ensureValidHandle( 'org.cpan.sanko' );
}
catch($err) {
...; # do something about it
}
DESCRIPTION
DIDs are the long-term persistent identifiers for accounts in atproto, but they can be opaque and unfriendly for human use. Handles are a less-permanent identifier for accounts. The mechanism for verifying the link between an account handle and an account DID relies on DNS, and possibly connections to a network host, so every handle must be a valid network hostname. Almost every valid "hostname" is also a valid handle, though there are a small number of exceptions.
This package aims to validate them.
Functions
You may import functions by name or with the :all
tag.
new( ... )
Verifies an id and creates a new object containing it.
my $handle = At::Protocol::Handle->new( 'org.cpan.sanko' );
On success, an object is returned that will stringify to the id itself.
ensureValidHandle( ... )
ensureValidHandle( 'org.cpan.sanko' );
Validates an id. Throws errors on failure and returns a true value on success.
ensureValidHandleRegex( ... )
ensureValidHandleRegex( 'org.cpan.sanko' );
Validates an id with cursory regex provided by the AT protocol designers. Throws errors on failure and returns a true value on success.
normalizeHandle( ... )
my $handle = ensureValidHandleRegex( 'org.cpan.SANKO' );
Normalizes a handle according to spec. ...honestly, it just makes sure it's lowercase.
normalizeAndEnsureValidHandle( ... )
my $handle = normalizeAndEnsureValidHandle( 'org.cpan.SANKO' );
Normalizes and validates an id. Throws errors on failure and returns the normalized id on success.
isValidHandle( ... )
my $ok = ensureValidHandle( 'org.cpan.sanko' );
Validates an id and catches any fatal errors. Returns a boolean value.
isValidTld( ... )
my $ok = isValidTld( 'cpan.org' );
Returns a boolean indicating whether the given TLD is valid for use as a handle according to the AT protocol spec.
See Also
https://atproto.com/specs/handle
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.
AUTHOR
Sanko Robinson <sanko@cpan.org>