p2p-cljs / site / index.html
758 words
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!doctype html>
<html lang="en" data-releases="../releases.json">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>p2p-cljs.git — ird-p2p-cljs, ClojureScript peer SDK for the ird p2p service</title>
<style>
  :root {
    color-scheme: dark;
    --paper: #12161c; --ink: #e8edf2; --ink-soft: #9aa7b3;
    --line: #263241; --card: #182029; --code-bg: #1f2a36; --accent: #7fc4a8;
  }
  @media (prefers-color-scheme: light) {
    :root {
      color-scheme: light;
      --paper: #f8f9fa; --ink: #232a30; --ink-soft: #61707d;
      --line: #dde4ea; --card: #ffffff; --code-bg: #eef2f5; --accent: #35836a;
    }
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    background: var(--paper); color: var(--ink);
    font: 16.5px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
      "Helvetica Neue", Arial, sans-serif;
    padding: 64px 22px 90px;
  }
  main { max-width: 660px; margin: 0 auto; }
  h1 { font-size: 40px; font-weight: 600; letter-spacing: -.4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
  .tag { margin: 14px 0 34px; font-size: 18px; color: var(--ink-soft); }
  h2 { font-size: 20px; font-weight: 600; margin: 36px 0 10px; }
  p { margin: 10px 0; }
  a { color: var(--accent); }
  pre {
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    padding: 13px 16px; overflow-x: auto; margin: 14px 0;
    font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  }
  code { font: 15px ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--code-bg); border-radius: 5px; padding: 1px 6px; }
  pre code { background: none; padding: 0; }
  ul { padding-left: 22px; } li { margin: 6px 0; }
  footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line);
    font-size: 14px; color: var(--ink-soft); }
  footer a { color: inherit; }
</style>
</head>
<body>
<main>
  <h1>p2p-cljs.git</h1>
  <p class="tag"><strong>ird-p2p-cljs</strong> — ClojureScript peer SDK for the
  <a href="https://ird.ro">ird p2p service</a> on Node.js (18+): rooms that find
  each other through the app's signaling relay, WebRTC data channels with TURN
  and the relay as fallback, end-to-end encryption, invite links, verified
  identities, and the offline mailbox. core.async channels end to end; a sibling
  of <a href="../p2p-swift/">p2p-swift</a>, byte-for-byte interoperable with it.</p>

  <h2>Use as a dependency</h2>
  <p>No registry — a source library served straight from this domain, consumed
  as a git dependency (with <a href="https://shadow-cljs.github.io/docs/UsersGuide.html">shadow-cljs</a>
  reading <code>deps.edn</code>):</p>
  <pre><code>;; deps.edn
{:deps {ro.ird/ird-p2p-cljs {:git/url "https://ird.cod-sursa.ro/p2p-cljs.git"
                             :git/tag "<span data-rel="p2p-cljs.tag">v0.3.1</span>" :git/sha "<span data-rel="p2p-cljs.tag_sha_short">0000000</span>"}
        thheller/shadow-cljs {:mvn/version "3.5.0"}}}</code></pre>
  <p>The latest release is <code><span data-rel="p2p-cljs.tag">v0.3.1</span></code>
  (<code><span data-rel="p2p-cljs.tag_sha_short">0000000</span></code>). To pin that exact commit:</p>
  <pre><code>ro.ird/ird-p2p-cljs {:git/url "https://ird.cod-sursa.ro/p2p-cljs.git"
                     :git/sha "<span data-rel="p2p-cljs.tag_sha">0000000000000000000000000000000000000000</span>"}</code></pre>
  <p>Add <code>ws</code> to your <code>package.json</code> dependencies (the
  default relay socket); ClojureScript and core.async come from
  <code>deps.edn</code>. These coordinates are filled from
  <a href="../releases.json">releases.json</a>, which scripts and agents can read
  directly (<code>head</code>, <code>tag</code>, <code>tag_sha</code> per repo).</p>

  <h2>Quickstart</h2>
  <pre><code>(require '[cljs.core.async :refer [go <!]]
         '[ird.p2p.async :refer [<?]]
         '[ird.p2p :as p2p])

(def app (p2p/make-app {:host "myapp.ap2p.ro" :app-salt "myapp/v1"
                        :origin "https://myapp.example"}))
(def secret (p2p/random-secret))            ; share it in an invite link's fragment

(go
  (let [room (<? (p2p/join app secret))]
    (go (loop []
          (when-let [e (<! (p2p/events room))]
            (case (:type e)
              :peer-ready (println (:peer e) (:via e))   ; :relayed, then :direct
              :message    (println (:from e) (get-in e [:message :value]))
              nil)
            (recur))))
    (<? (p2p/broadcast room (p2p/json {:text "salut"})))))</code></pre>
  <p>Every async call returns a core.async channel delivering one value — the
  result or an <code>ex-info</code> error. The full guide — one API for the
  <code>/ws</code> relay or libp2p, identity and invite links, the offline
  mailbox, errors, origins for Node clients, WebRTC — is in the repo's
  <code>README.md</code>; the end-to-end envelope format is in
  <code>PROTOCOL.md</code>.</p>

  <h2>Clone</h2>
  <pre>git clone https://ird.cod-sursa.ro/p2p-cljs.git</pre>
  <p><a href="browse/">browse the source in your browser →</a></p>

  <h2>What's inside</h2>
  <ul>
    <li><code>src/ird/p2p.cljs</code> — the public facade: make-app, join, send/broadcast, mailbox, identity</li>
    <li><code>src/ird/p2p/{crypto,envelope,identity}.cljs</code> — HKDF derivations, sealed envelopes, Ed25519 identities and fingerprints</li>
    <li><code>src/ird/p2p/{transport,transport/ws,transport/libp2p}.cljs</code> — the relay SPI, the <code>/ws</code> relay, and the gossipsub adapter</li>
    <li><code>src/ird/p2p/{room,webrtc,descriptor,turn,mailbox,errors}.cljs</code> — rooms, the pc-factory SPI and the in-memory factory, the descriptor, TURN, the mailbox</li>
    <li><code>src/ird/p2p/impl/</code> — the only namespaces with JavaScript interop (WebCrypto, ws, fetch, libp2p, and <code>impl/wrtc</code>: the optional real WebRTC factory over node-datachannel)</li>
    <li><code>test/</code> — golden vectors, offline suites with fake transports, two real libp2p nodes (and a third as a circuit-relay hop) and two real data channels over loopback, the zero-interop gate, an env-gated live suite</li>
    <li><code>PROTOCOL.md</code> — the SDK's end-to-end envelope specification</li>
  </ul>

  <h2>License</h2>
  <p>MIT.</p>

  <footer>Part of <a href="../">ird.cod-sursa.ro</a> — source published on IPFS,
  cloned over plain HTTP.</footer>
</main>
<script>
// Fill release coordinates from the site's releases.json (written by the
// assembler from the mirrors it publishes); the static text is the fallback.
(function () {
  var els = document.querySelectorAll('[data-rel]');
  if (!els.length || !window.fetch) return;
  fetch(document.documentElement.getAttribute('data-releases') || 'releases.json')
    .then(function (r) { return r.ok ? r.json() : null; })
    .then(function (j) {
      if (!j || !j.apps) return;
      Array.prototype.forEach.call(els, function (el) {
        var k = el.getAttribute('data-rel').split('.'), a = j.apps[k[0]];
        var v = a && a[k[1]];
        if (typeof v === 'string' && v) el.textContent = v;
      });
    })
    .catch(function () {});
})();
</script>
</body>
</html>

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/p2p-cljs.git