@idrto/idr_browser_sdk
v1.0.0
Published
idr.to browser SDK — WebRTC access to on-prem target agents
Downloads
154
Readme
@idrto/idr_browser_sdk
Browser SDK for idr.to — WebRTC access to on-prem target agents (Ollama, HTTP services, etc.).
ISVs hardcode service at dev time; end-users enter target host only. Auth, billing, and platform URLs are built into the SDK.
Install
npm install @idrto/idr_browser_sdkQuick start (ISV)
<input id="host" placeholder="edge-gpu-1.your-entity.idr" />
<div id="auth"></div>
<button id="go">Connect</button>
<script type="module">
import { IdrClient, mountAuthPanel } from "@idrto/idr_browser_sdk";
const client = IdrClient.forService("ollama");
mountAuthPanel(document.getElementById("auth"), { client });
document.getElementById("go").onclick = async () => {
await client.ensureSession({ interactive: true, mount: document.getElementById("auth") });
await client.connect({ host: document.getElementById("host").value.trim() });
const tags = await (await client.fetch("/api/tags")).json();
console.log(tags);
};
</script>Security
- Never collect access keys in ISV code or send them to your backend.
- Use
mountAuthPanel()or<idr-auth-panel>for credentials. - Do not pass
accessKeytoconnect()— the SDK rejects it.
See docs/ISV_GUIDE.md and docs/ACCESS_KEYS.md.
Platform requirements
- Account sign-in:
POST /v1/auth/browser/login→browser:writescope - Access keys:
POST /v1/auth/access-key/exchange - Resolve:
POST /resolvewithsource_host: "browser"(or key-scoped host) - Signaling:
wss://idr.to/v1/signalwith Ed25519 device auth - Transport: WebRTC data channel
idr-tunnel+ idr-tunnel-v1 binary mux
Target hosts: use .idr synthetic names (buildIdrHostname) or idrto: URIs. Do not parse *.idr.to labels locally — they may be opaque hashes.
Examples
| Framework | Directory | |-----------|-------------| | Vanilla | examples/vanilla-vite/ | | React | examples/react-vite/ | | Vue | examples/vue-vite/ | | Svelte | examples/svelte-vite/ | | Angular | examples/angular-vite/ |
npm run build
cd examples/react-vite && npm install && npm run devDevelopment
npm install
npm test
npm run buildFor local API testing: localStorage.setItem("idr.sdk.devApiBase", "http://localhost:3000").
License
MIT
