broadcast_queue_shim_for_ndk 0.8.2 copy "broadcast_queue_shim_for_ndk: ^0.8.2" to clipboard
broadcast_queue_shim_for_ndk: ^0.8.2 copied to clipboard

Offline-first wrapper around the ndk package's broadcast use case. Persists Nostr events to a local sembast queue and retries until targeted relays acknowledge delivery, return terminal NIP-01 rejecti [...]

0.8.2 #

  • Accept url_set_for_ndk 0.2.0 alongside 0.1, so the queue can be used with sync_engine_shim_for_ndk 0.9.0. Nothing changed in the code.

0.8.1 #

  • Widen the ndk constraint to >=0.10.0-dev.7 <0.12.0 so the shim can be used alongside ndk 0.11.x. The lower bound matches url_set_for_ndk.

0.8.0 #

  • Breaking: RelaySet moves to the url_set_for_ndk package as UrlSet, re-exported by this one. Rename RelaySet to UrlSet, and the related types to match: RelayListFn to UrlListFn, RelayLookup to UrlListLookup (RelayListFound.relays becomes UrlListFound.urls), RelayListKind to UrlListKind, ndkRelayListFn to ndkUrlListFn, OutboxRelays to OutboxUrls, etc. The hide RelaySet on the ndk import is no longer needed.
  • Breaking: UrlSet.inbox and UrlSet.dm take one pubkey. Replace RelaySet.dm(pubkeys) with UrlSet.union([for (final p in pubkeys) UrlSet.dm(p)]). Queues stored by earlier versions load unchanged.
  • broadcast rejects UrlSet.blossom leaves, which name Blossom servers.

0.7.0 #

  • Breaking: BroadcastStatus gains superseded and cancelled. Exhaustive switch statements on it need new cases.
  • Queuing a replaceable or addressable event supersedes the pending records of its older versions: they stop retrying, become BroadcastStatus.superseded and get QueuedBroadcast.supersededBy. An older version queued after a newer one is never sent.
  • Add cancel(id, {pubkey}): stops the retries of a pending record, which becomes BroadcastStatus.cancelled and gets QueuedBroadcast.cancelledAt. Queuing it again with broadcast reopens it.

0.6.0 #

  • Breaking: require ndk: ^0.10.0-dev.1.
  • Breaking: broadcast takes required RelaySet relaySet instead of relays. Migrate with relaySet: RelaySet.explicit([...]). Files importing package:ndk/ndk.dart need hide RelaySet.
  • Add RelaySet: explicit, outbox, inbox, nip65, dm (kind 10050), private (NIP-37, kind 10013), union and fallback. Sets are persisted, resolved by the worker (offline included) and frozen at the first successful resolution. dm and private lists are searched on the NIP-65 write relays.
  • A lookup is found, not found (EOSE) or unavailable. Unavailable ones retry with backoff and never make fallback fall through. An entry resolving to no relay is failed.
  • Relay lists are queried on defaultIndexerRelays. Private lists are decrypted once through ndk.decryptedEventPayloads, never timed out.
  • New options: relayListFn, relayListDiscoveryRelays, relayListQueryTimeout. New QueuedBroadcast fields: pendingRelaySet, resolutionAttempts, resolutionError.

0.5.1 #

  • Widen the ndk constraint to >=0.9.0 <0.11.0 so the shim can be used alongside ndk 0.10.x.

0.5.0 #

  • Require ndk: ^0.9.0.

0.4.0 #

  • Add an optional pubkey argument to broadcast, get, watch, and rebroadcast that attributes a queued entry to a local account. Records are now keyed by the pair (event.id, pubkey), so the same event queued under two accounts is two independent records. QueuedBroadcast gains a pubkey field and key / keyFor helpers.
  • Add clearLocalAccountData({required String pubkey}) to remove every entry queued under an account (for logout) and clearAllLocalData() to empty the store. pubkey is a plain label, not event.pubKey: gift wraps (kind 1059) carry an ephemeral event pubkey, so pass the real sending account for NIP-17 DMs to be clearable.
  • Entries queued without a pubkey stay unattributed and keep the bare event.id as their sembast key, so databases written before 0.4.0 keep working. Unattributed entries are never removed by clearLocalAccountData.

0.3.0 #

  • Stop retrying a relay/event pair when the relay returns NIP-01 OK false with a terminal machine-readable prefix: pow, blocked, invalid, restricted, or error.
  • Add BroadcastStatus.failed, QueuedBroadcast.terminalErrors, and QueuedBroadcast.failedAt for entries where every relay is either acked or terminally rejected.
  • Keep retrying non-terminal failures such as rate-limited, unknown prefixes, timeouts, no response, and transport errors.
  • Stop retrying a relay/event pair after 12 consecutive online attempts where the relay is inaccessible.

0.2.1 #

  • Fix int64 overflow in computeBackoff on native platforms (Android, iOS, Linux, macOS, Windows). After ~52 failed attempts (with the default 5s initial delay), pow(2, attempts) wrapped to a negative integer, causing double.clamp to throw Invalid argument(s). The calculation now uses double arithmetic (pow(2.0, ...)) to avoid the overflow.

0.2.0 #

  • Connectivity-aware periodic retries. OfflineBroadcast.withNdk() now subscribes to ndk.connectivity.relayConnectivityChanges and pauses the internal timer while no public relay is connected. The offline -> online edge triggers an immediate replay. retryNow() always bypasses the check.
  • Local/private hosts (loopback, RFC1918 IPv4, ULA/link-local IPv6, mDNS .local) are filtered out when deriving the online signal, so a connected dev relay on localhost cannot mask a real outage.
  • The default constructor accepts an optional Stream<bool> onlineSignal for callers who want to wire their own connectivity source.

0.1.0 #

Initial release.

  • OfflineBroadcast wraps ndk.broadcast and persists every event to a caller-provided sembast database before attempting to send it.
  • Required relays list at broadcast time. No gossip-based auto-selection.
  • Per-relay acks are tracked monotonically. An entry is considered delivered only when every targeted relay has acknowledged the event with broadcastSuccessful: true; once set, the delivery timestamp is never cleared by the shim.
  • Records are kept after delivery. They are never auto-deleted.
  • rebroadcast(id) queues a one-shot push to every relay without touching the historical ack set.
  • rebroadcast(id, relay: ...) queues a one-shot push to a specific relay, adding it to the entry's target list if absent.
  • Retries are driven by an internal periodic timer started via start(), plus a public retryNow() callers can wire to connectivity signals.
  • Backoff is exponential with full jitter, bounded by initialBackoff and maxBackoff.
  • The shim never signs events. Signing remains NDK's responsibility.
1
likes
150
points
548
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Offline-first wrapper around the ndk package's broadcast use case. Persists Nostr events to a local sembast queue and retries until targeted relays acknowledge delivery, return terminal NIP-01 rejections, or stay inaccessible while online.

Repository (GitHub)
View/report issues

Topics

#nostr #ndk #offline-first #queue

License

MIT (license)

Dependencies

ndk, sembast, url_set_for_ndk

More

Packages that depend on broadcast_queue_shim_for_ndk