clone

tiny dependency-free nostr libraries for plain html, each under 5kb and named for an element. public domain

main
nobel / argon / README.md
README.md 1.5K source

📦 argon.js - a relay in your browser

argon.js is a miniature relay, in the way tinyrelay is a big one: an IndexedDB event store that understands replaceable, addressable, ephemeral and deletion events. Loaded alongside xenon.js, it answers every subscription from the cache first and stores every event that arrives or is published. Pages render instantly on reload and keep working offline.

<script src="argon.js"></script>
<script src="xenon.js"></script>

<ol nxe-filter='{"kinds":[1],"limit":50}'></ol>

On reload the list fills from IndexedDB before any relay answers, and xenon drops the duplicates when they arrive.

Attributes

attribute description
nar-ignore Neither read from nor write to the cache for subscriptions on or under this element

window.narCfg = {name} picks the database name (default argon).

Behavior

  • Subscriptions receive cached events with from == "argon", then an nxe:eose with from == "argon".
  • Kinds 0, 3 and 10000-19999 keep the newest per author. Kinds 30000-39999 keep the newest per author and d tag.
  • Kinds 20000-29999 are never stored. Kind 5 removes the author's own events named by e tags.

API

function returns
argon.put(event) true if stored
argon.query(filters) matching events, newest first, honoring each filter's limit
argon.match(filter, event) NIP-01 filter test
argon.remove(id?) removes one record, or everything