at_commons 5.9.0 copy "at_commons: ^5.9.0" to clipboard
at_commons: ^5.9.0 copied to clipboard

A library of Dart and Flutter utility classes that are used across other components of the atPlatform.

The Atsign FoundationThe Atsign Foundation

Pub Package

at_commons #

Foundational types used across every package in the Atsign Protocol SDK: key representations, metadata, atSign validation, root-domain parsing, verb builders (Atsign Protocol wire format), and the exception hierarchy.

at_commons is a pure-Dart library with no dependency on any specific client implementation. Most application developers consume these types transitively via at_client; you'll reach for at_commons directly when you need to construct an AtKey by hand, interpret exceptions, or build Atsign Protocol verbs at a lower level.

AtKey #

AtKey represents a key in the atServer keystore. Prefer the static factory methods over the field-builder form — they encode the key shape (self / shared / public / local / cached) at the type level:

// Shared with another atSign
AtKey shared = (AtKey.shared('phone', namespace: 'myapp', sharedBy: '@alice')
      ..sharedWith('@bob'))
    .build();

// Public (readable by anyone)
AtKey pub = AtKey.public('avatar', namespace: 'myapp', sharedBy: '@alice').build();

// Self (only readable by the owner)
AtKey self = AtKey.self('prefs', namespace: 'myapp', sharedBy: '@alice').build();

// Local (never synced to the cloud)
AtKey local = AtKey.local('cache', '@alice', namespace: 'myapp').build();

// Parse from a wire-format string
AtKey parsed = AtKey.fromString('@bob:phone.myapp@alice');

Useful getters:

Getter Example output
fullKey phone.myapp
fullKeyAndOwner phone.myapp@alice
toString() @bob:phone.myapp@alice

Metadata #

Metadata carries per-key settings. The fields most app code actually touches:

Field Type Description
ttl int? Time-to-live in ms (key self-expires)
ttb int? Time-to-birth in ms (key becomes visible after this delay)
ttr int? Recipient cache refresh interval in seconds; -1 means cache indefinitely
ccd bool? Cascade-delete cached copies when the original is deleted
isPublic bool? Key is publicly readable
isEncrypted bool? Value is encrypted
isBinary bool? Value is binary data
namespaceAware bool Whether the namespace is appended to the key on the wire
immutable bool? Key may not be updated once set
expiresAt DateTime? Derived expiry timestamp (from ttl)
availableAt DateTime? Derived availability timestamp (from ttb)

Atsign / AtRootDomain #

Atsign alice = '@alice'.toAtsign();          // validated, fully qualified
AtsignWithoutAt a = alice.withoutAt;         // no leading '@'

AtRootDomain root = AtRootDomain.parse('root.atsign.org:64');
AtRootDomain prod = AtRootDomain.atsignDomain; // production default

Exceptions #

All exceptions extend AtException. The main sub-hierarchies are:

  • AtConnectException — connection / auth failures (SecondaryServerConnectivityException, UnAuthorizedException, HandShakeException, …)
  • AtServerException — server-side errors (InboundConnectionLimitException, LookupException, InternalServerException, …)
  • AtEnrollmentException — APKAM enrollment failures (AtInvalidEnrollmentException, AtEnrollmentRevokeException, AtThrottleLimitExceeded)
  • Standalone: InvalidAtKeyException, KeyNotFoundException, AtTimeoutException, InvalidAtSignException, AtSigningException, AtIOException, and others.

Verb builders #

Each builder constructs an Atsign Protocol wire command via buildCommand(). Application code normally doesn't touch these directly — the client packages use them internally — but they're exposed for lower-level tooling (see the test suite in test/ for concrete usage).

Builder Protocol verb
UpdateVerbBuilder update:
DeleteVerbBuilder delete:
LookupVerbBuilder lookup:
LLookupVerbBuilder llookup:
PLookupVerbBuilder plookup:
ScanVerbBuilder scan
NotifyVerbBuilder notify:
MonitorVerbBuilder monitor
SyncVerbBuilder sync:
EnrollVerbBuilder enroll:
StatsVerbBuilder stats:

Other types #

  • AtBytes — wrapper for base64-encoded binary payloads
  • KeyTypeselfKey, sharedKey, publicKey, localKey, cachedSharedKey, …
  • EnrollmentStatuspending, approved, denied, revoked, expired
  • PublicKeyHash — hash + algorithm of a public encryption key
  • SecureSocketConfig — TLS configuration for atServer connections

Where to go next #

  • at_client — the client that uses these types
  • at_auth — onboarding / authentication that produces the keys embedded in AtKey
14
likes
150
points
11.1k
downloads

Documentation

Documentation
API reference

Publisher

verified publisheratsign.org

Weekly Downloads

A library of Dart and Flutter utility classes that are used across other components of the atPlatform.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

BSD-3-Clause (license)

Dependencies

json_annotation, meta, uuid

More

Packages that depend on at_commons