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 🙏

© 2024 – Pkg Stats / Ryan Hefner

parse-siwe

v1.0.2

Published

Standalone, high-performance, validating 'ERC-4361: Sign in with Ethereum' Parser

Downloads

159

Readme

parse-siwe - a Sign in with Ethereum Parser

ERC-4361: Sign-In with Ethereum establishes a standard for using an Ethereum account to sign into services that support the standard. ERC-4361 defines a message format for this purpose and any application implementing the standard will need to parse that message, validating each of the line items defined in it. parse-siwe is such a parser. It is designed to be simple to use and simple to integrate into either Node.js or web page applications.

Some highlights of its features:

  • it is stand alone - it has no external dependencies
  • well-tested
  • URI validation - includes a complete and well-tested URI parser
  • ERC-55 options - includes a keccak-256 hash function
    • validation of Ethereum address ERC-55 encoding
    • convert the Ethereum address to ERC-55 encoding
    • ignore ERC-55 encoding
  • date time validation
  • correct handling of statement, request ID and resources
    • these optional items can be empty as well as missing or present
  • good error reporting (Well, pretty good. Usually, but not always, points out the offending message line.)
  • can be used in Node.js or web page application

Installation and Basic Usage

Installation

In your working directory,

npm init
npm install parse-siwe

Sample Usage

import { parseSiweMessage } from 'parse-siwe';

const msg = `example.com:80 wants you to sign in with your Ethereum account:
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

Valid statement

URI: https://example.com/login
Version: 1
Chain ID: 2
Nonce: 32891756
Issued At: 2021-09-30T16:25:24Z
Request ID: someRequestId
Resources:
- ftp://myftpsite.com/
- https://example.com/mypage`;

try {
  const obj = parseSiweMessage(msg, 'validate');
  console.log('output message object');
  console.dir(obj);
} catch (e) {
  console.log(`parsing error: ${e.message}`);
}

./examples/node-app.js provides a more complete example of its usage. ./examples/web.html demonstrates its use in a simple web page.

Documentation

The documentation is in the code as JSDoc comments. To generate the documentation use npm run jsdoc

The documentation will be at out/index.html. Or view it online here.

License

2-Clause BSD License