@signinwithethereum/siwe-parser
Parse Messages that conform to EIP-4361: Sign in with Ethereum (SIWE)
Last updated 3 months ago by jwahdatehagh .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @signinwithethereum/siwe-parser 
SYNC missed versions from official npm registry.

@signinwithethereum/siwe-parser

A parser for EIP-4361: Sign in with Ethereum messages, using an ABNF grammar for strict specification compliance.

Installation

npm install @signinwithethereum/siwe-parser

Usage

Parsing a SIWE message

import { ParsedMessage } from '@signinwithethereum/siwe-parser'

const message = new ParsedMessage(rawMessage)

console.log(message.domain)
console.log(message.address)
console.log(message.uri)
console.log(message.version)
console.log(message.chainId)
console.log(message.nonce)
console.log(message.issuedAt)

The constructor throws if the message does not conform to EIP-4361.

Validating a URI

import { isUri } from '@signinwithethereum/siwe-parser'

isUri('https://example.com') // true

Utilities

import {
  isEIP55Address,
  isValidISO8601Date,
} from '@signinwithethereum/siwe-parser'

isEIP55Address('0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B') // true
isValidISO8601Date('2024-01-01T00:00:00Z') // true

Parsed Fields

Field Type Required
domain string Yes
address string Yes
uri string Yes
version string Yes
chainId number Yes
nonce string Yes
issuedAt string Yes
scheme string No
statement string No
expirationTime string No
notBefore string No
requestId string No
resources string[] No

Related

For full SIWE message creation, signing, and verification (including ERC-1271 and EIP-6492 support), use @signinwithethereum/siwe which includes this parser.

Disclaimer

Our TypeScript library for Sign In with Ethereum has not yet undergone a formal security audit. We welcome continued feedback on the usability, architecture, and security of this implementation.

Current Tags

  • 4.2.1                                ...           latest (3 months ago)

6 Versions

  • 4.2.1                                ...           3 months ago
  • 4.2.0                                ...           7 months ago
  • 4.1.0                                ...           8 months ago
  • 4.0.2                                ...           8 months ago
  • 4.0.1                                ...           8 months ago
  • 4.0.0                                ...           8 months ago
Downloads
Total 23
Today 0
This Week 0
This Month 18
Last Day 0
Last Week 0
Last Month 5
Dependencies (2)
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE