Documentation
Add DsxID to your website
One script tag, one button, one backend check. The private key never leaves the user's computer.
1. Load the SDK
The browser SDK is served from this domain and can be cached by any CDN. Put these tags on the page that shows the sign-in or checkout button:
<link rel="stylesheet" href="https://dsxid.org/sdk/dsxid.css">
<script src="https://dsxid.org/sdk/dsxid.js"></script>
Prefer to host it yourself? Save https://dsxid.org/sdk/dsxid.js and https://dsxid.org/sdk/dsxid.css, then serve them from your own domain. dsxid.org only serves these static files; no identity or profile data is sent there.
2. Mount the button
Give the SDK your two backend endpoints. Nothing talks to the desktop app until the user clicks the button.
<button id="dsxid-login" class="dsxid-button" type="button">
Sign in with DsxID
</button>
<script>
DsxID.mount("#dsxid-login", {
startUrl: "/api/dsxid/start",
verifyUrl: "/api/dsxid/verify",
onSuccess: function (result) {
location.reload();
},
onError: function (error) {
console.error(error.message);
}
});
</script>
DsxID must be installed, running, and unlocked on the user's computer. The SDK talks to the local bridge at 127.0.0.1:41991; sign-in data reaches your server only after the user approves the request.
Data attributes work too, which is convenient for server-rendered templates:
<button data-dsxid-login
data-start-url="/api/dsxid/start"
data-verify-url="/api/dsxid/verify"
class="dsxid-button">Sign in with DsxID</button>
<script>DsxID.mountAll({ onSuccess: () => location.reload() });</script>
3. Ask for checkout fields
Add a profile array with only the fields your form needs. DsxID shows the saved values in its approval dialog, and the signed assertion contains only the fields the user approved.
DsxID.mount("#checkout", {
startUrl: "/api/dsxid/start",
verifyUrl: "/api/dsxid/verify",
profile: ["fullName", "email", "phone", "address1",
"city", "postalCode", "country"],
onSuccess: function (result) {
for (const [key, value] of Object.entries(result.profile || {})) {
const input = document.querySelector(`[name="${key}"]`);
if (input) input.value = value;
}
}
});
Supported names: fullName, email, phone, address1, address2, city, postalCode, country, company, vatId. A field the user left empty is never invented and never returned.
4. Backend contract
Your server owns the challenge and the session. Start by creating a random, single-use challenge and storing it with the visitor's session and a short expiry.
POST /api/dsxid/start
{ "challenge": "dGhpcy1pcy1hLW9uZS10aW1lLWNoYWxsZW5nZQ" }
The SDK fetches the challenge, asks the local bridge at 127.0.0.1:41991 to sign it, and then posts this to your verify endpoint:
POST /api/dsxid/verify
{
"challenge": "...",
"assertion": "dsx1...",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\n..."
}
Check the stored challenge, the origin, the key fingerprint, the Ed25519 signature, and the expiry. Consume the challenge once, then create your normal session and return:
{ "ok": true, "keyId": "...", "profile": { "fullName": "...", "email": "..." } }
5. Verify the assertion
The Node helper in the repository implements the checks above. It is server-side code and must not be shipped to the browser.
const { verifyAssertion } = require("./dsxid-verify");
const result = verifyAssertion({
assertion: body.assertion,
publicKeyPem: body.publicKeyPem,
expectedOrigin: pending.origin,
expectedChallenge: pending.challenge,
});
// result.keyId is the stable identity fingerprint
// result.profile holds only the signed, approved fields
expectedOrigin must be the exact browser origin, for example https://shop.example. Never trust an origin supplied by the client.
6. Security notes
- Production sites must use HTTPS. The SDK refuses to start on an HTTP page outside localhost, and the bridge rejects non-loopback HTTP origins.
- Every request names the real website origin and the requested profile values. The user approves or denies it in the desktop app.
- Profile values are covered by the Ed25519 signature, so a network attacker cannot change them after approval.
- The assertion is bound to one origin and one single-use challenge, with a short expiry.
- If you use a Content Security Policy, allow the local bridge:
connect-src 'self' http://127.0.0.1:41991; - Some browsers block or prompt for requests from an HTTPS page to a local HTTP bridge (mixed content or Private Network Access). Test your target browsers before launch.
Need the desktop app?
Install DsxID for Windows, create an identity, then try the example flow on your own site.