Add self-sovereign identity login and crypto payments to any website. One package — standalone server, Express middleware, and frontend SDK.
npm install github:Fried333/verus-connect
You need a VerusID to sign login challenges. Create one on Verus Desktop or any VerusID registrar. Export the WIF private key.
# .env SIGNING_IADDRESS=iYourVerusIDAddress PRIVATE_KEY=UxYourWIFPrivateKey CALLBACK_URL=https://yoursite.com/verusidlogin PORT=8100
# Standalone sidecar (zero code) npx verus-connect start # Or as Express middleware const { verusAuth } = require('verus-connect/server'); app.use('/auth/verus', verusAuth({ iAddress: process.env.SIGNING_IADDRESS, privateKey: process.env.PRIVATE_KEY, callbackUrl: process.env.CALLBACK_URL, }));
Here's a complete working example you can copy into your project. This creates a login button, handles the QR code, polls for the result, and shows the verified identity.
const express = require('express'); const { verusAuth } = require('verus-connect/server'); const app = express(); app.use(express.static('public')); // Mount the VerusID auth middleware app.use('/verus', verusAuth({ iAddress: process.env.SIGNING_IADDRESS, privateKey: process.env.PRIVATE_KEY, callbackUrl: 'https://yoursite.com/verus/verusidlogin', // Optional: hook called on successful login onLogin: (identity) => { console.log(`User logged in: ${identity.friendlyName}`); // Create JWT, session, save to DB, etc. } })); app.listen(3000);
<!-- Add a login button and result container --> <button id="loginBtn">Login with VerusID</button> <div id="qrBox" style="display:none"> <canvas id="qr"></canvas> <p id="status">Scan with Verus Mobile...</p> </div> <div id="welcome" style="display:none"></div> <!-- QR library (4KB) --> <script src="https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js"></script> <script> document.getElementById('loginBtn').onclick = async () => { // 1. Request a challenge from your sidecar const res = await fetch('/verus/login', { method: 'POST' }); const { challengeId, deepLink } = await res.json(); // 2. Show QR code document.getElementById('qrBox').style.display = 'block'; await QRCode.toCanvas(document.getElementById('qr'), deepLink, { width: 250 }); // 3. On mobile? Open the wallet directly if (/iPhone|Android/i.test(navigator.userAgent)) { window.location.href = deepLink; } // 4. Poll for result (every 3s, timeout 5min) const poll = setInterval(async () => { const r = await fetch(`/verus/result/${challengeId}`); const data = await r.json(); if (data.status === 'verified') { clearInterval(poll); document.getElementById('qrBox').style.display = 'none'; document.getElementById('welcome').style.display = 'block'; document.getElementById('welcome').textContent = `Welcome, ${data.friendlyName}!`; } }, 3000); }; </script>
<!-- Accept payment for a product/service --> <button onclick="pay()">Pay 5 VRSC</button> <canvas id="payQr"></canvas> <script> async function pay() { const res = await fetch('/verus/pay-deeplink', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ address: 'REpxm9bCLMiHRNVPA9unPBWixie7uHFA5C', amount: 5 }) }); const { deep_link } = await res.json(); // Desktop: show QR. Mobile: open wallet. if (/iPhone|Android/i.test(navigator.userAgent)) { window.location.href = deep_link; } else { await QRCode.toCanvas(document.getElementById('payQr'), deep_link, { width: 250 }); } } </script>
Click the button to generate a login challenge. Scan the QR code with Verus Mobile or use the Verus browser extension.
// Frontend: request a challenge const res = await fetch('/verus/login', { method: 'POST' }); const { challengeId, deepLink } = await res.json(); // Show QR code with deepLink URI showQR(deepLink); // Poll for result const poll = setInterval(async () => { const r = await fetch(`/verus/result/${challengeId}`); const data = await r.json(); if (data.status === 'verified') { clearInterval(poll); console.log('Logged in as:', data.friendlyName); } }, 3000);
Generate a VerusPay QR code for any amount and address. The user scans it and their wallet opens with the payment pre-filled.
// Generate a payment deep link const res = await fetch('/verus/pay-deeplink', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ address: 'REpxm9bCLMiHRNVPA9unPBWixie7uHFA5C', amount: 1.0 }) }); const { deep_link } = await res.json(); // Show QR code showQR(deep_link);
Look up any VerusID directly from the blockchain. No API key needed — this calls the public Verus RPC.
// Call the public Verus RPC (no auth needed) const res = await fetch('https://api.verus.services', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '1.0', method: 'getidentity', params: ['Verus Coin Foundation@'] }) }); const { result } = await res.json();
Your frontend calls POST /login on the sidecar. It creates a cryptographic challenge signed with your app's VerusID.
The QR contains a deep link that opens Verus Mobile. The wallet shows "App X wants to verify your identity" and the user approves.
The wallet signs a response with the user's VerusID private key and POSTs it to your callback URL.
The sidecar verifies the signature against the Verus blockchain. If valid, it stores the result with the user's i-address and friendly name.
Your frontend polls GET /result/:challengeId and receives the verified VerusID. Create a session, JWT, or whatever your app needs.