npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@saganta/stellar-appkit-siws-verify

v1.9.46

Published

Server-side SIWS signature/envelope verification.

Readme

@saganta/stellar-appkit-siws-verify

Server-side SIWS (Sign-In With Stellar) signature verification.

npm version License: MIT


📖 Official Docs · 🎮 Official Demos

| | Link | |---|---| | 📖 Official Docs | stellar-appkit.saganta.com | | 🎮 Official Demos | demos.stellar-appkit.saganta.com | | 💻 GitHub | github.com/sagantaHQ/stellar-appkit |


Install

npm install @saganta/stellar-appkit-siws-verify

Usage

import { verifySiws } from '@saganta/stellar-appkit-siws-verify';

// The client (browser) sends these after signing:
// { message, signedMessage, signerAddress, signedData }

const result = await verifySiws(
  { message, signedMessage, signerAddress, signedData },
  {
    expectedDomain: 'app.example.com',  // must match the domain in the SIWS message
    expectedNonce: nonce,               // the nonce you issued earlier
  }
);

if (result.ok) {
  // Verification succeeded — the user proved they own signerAddress
  console.log(result.claims.address);
  console.log(result.claims.expirationTime);

  // Set a session cookie, issue a JWT, etc.
} else {
  // Verification failed
  console.log(result.reason);

  // Enable debug mode to see exactly what was tried:
  // const result = await verifySiws(payload, { ...opts, debug: true });
  // console.log(result.diagnostics);
}

How it works

Different Stellar wallets sign messages differently:

  • Freighter signs sha256("Stellar Signed Message:\n" + message) (SEP-0053)
  • Albedo signs a server-derived hash
  • xBull signs raw UTF-8 bytes
  • Ledger signs raw UTF-8 bytes (direct signer)

The signedData field (base64 of the exact bytes the wallet signed) is surfaced by every connector in @saganta/stellar-appkit. The verifier tries 8+ candidate byte sequences so you don't need per-wallet verification logic:

  1. signedData (if present)
  2. utf8(message) — raw bytes
  3. sha256("Stellar Signed Message:\n" + message) — SEP-0053 (Freighter)
  4. sha256(message) — generic prehash
  5. sha512(message) — SHA-512 prehash
  6. sha512(message) truncated to 32 bytes
  7. sha256("\x00" + message) — null-byte domain prefix
  8. utf8(message with CRLF) — Windows line endings

Debug mode

When verification fails, enable debug: true to see exactly what was tried:

const result = await verifySiws(payload, {
  expectedDomain: 'localhost',
  expectedNonce: nonce,
  debug: true,
});

if (!result.ok) {
  console.log(result.diagnostics);
  // {
  //   signatureByteLength: 64,
  //   candidatesTried: [
  //     { label: 'signedData', byteLength: 32, verified: false },
  //     { label: 'utf8(message)', byteLength: 156, verified: false },
  //     { label: 'sha256(SEP-0053)', byteLength: 32, verified: true },
  //     ...
  //   ]
  // }
}

API

function verifySiws(
  payload: {
    message: string;           // the SIWS message text
    signedMessage: string;     // base64 signature
    signerAddress: string;     // G... address
    signedData?: string;       // base64 of the exact bytes signed (optional but recommended)
  },
  opts: {
    expectedDomain: string;    // must match the domain in the SIWS message
    expectedNonce: string;     // the nonce you issued earlier
    debug?: boolean;           // default: false
  }
): Promise<{
  ok: boolean;
  claims?: {
    address: string;
    domain: string;
    nonce: string;
    issuedAt: string;
    expirationTime: string;
  };
  reason?: string;
  diagnostics?: { ... };
}>

Documentation

  • SIWS guide — full client + server flow, automatic SIWS, session lifecycle
  • Live demos — SIWS sign-in, session middleware, debug verification
  • Full docs — complete documentation

License

MIT © Saganta