@tevm/voltaire / primitives/Siwe
primitives/Siwe
Classes
InvalidFieldError
Defined in: src/primitives/Siwe/errors.js:59 SIWE message field has invalid valueThrows
Extends
Constructors
Constructor
new InvalidFieldError(Defined in: src/primitives/Siwe/errors.js:67field,reason,options?):InvalidFieldError
Parameters
field
string
Name of the invalid field
reason
string
Why the field is invalid
options?
cause?
Error
value?
unknown
Returns
InvalidFieldError
Overrides
InvalidFormatError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
InvalidFormatError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
InvalidFormatError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidFormatError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
InvalidFormatError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidFormatError.expected
name
name: string
Defined in: src/primitives/Siwe/errors.js:75
Inherited from
InvalidFormatError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidFormatError.value
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
InvalidFormatError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidFormatError.toJSON
InvalidNonceLengthError
Defined in: src/primitives/Siwe/errors.js:84 SIWE nonce length is invalidThrows
Extends
Constructors
Constructor
new InvalidNonceLengthError(Defined in: src/primitives/Siwe/errors.js:90length,options?):InvalidNonceLengthError
Parameters
length
number
Requested nonce length
options?
cause?
Error
Returns
InvalidNonceLengthError
Overrides
InvalidLengthError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
InvalidLengthError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
InvalidLengthError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidLengthError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
InvalidLengthError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidLengthError.expected
name
name: string
Defined in: src/primitives/Siwe/errors.js:98
Inherited from
InvalidLengthError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidLengthError.value
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
InvalidLengthError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidLengthError.toJSON
InvalidSiweMessageError
Defined in: src/primitives/Siwe/errors.js:12 SIWE message format is invalidThrows
Extends
Constructors
Constructor
new InvalidSiweMessageError(Defined in: src/primitives/Siwe/errors.js:19message,options?):InvalidSiweMessageError
Parameters
message
string
Description of the format issue
options?
cause?
Error
value?
unknown
Returns
InvalidSiweMessageError
Overrides
InvalidFormatError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
InvalidFormatError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
InvalidFormatError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidFormatError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
InvalidFormatError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidFormatError.expected
name
name: string
Defined in: src/primitives/Siwe/errors.js:27
Inherited from
InvalidFormatError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidFormatError.value
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
InvalidFormatError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidFormatError.toJSON
MissingFieldError
Defined in: src/primitives/Siwe/errors.js:36 SIWE message missing required fieldThrows
Extends
Constructors
Constructor
new MissingFieldError(Defined in: src/primitives/Siwe/errors.js:42field,options?):MissingFieldError
Parameters
field
string
Name of the missing field
options?
cause?
Error
Returns
MissingFieldError
Overrides
InvalidFormatError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
InvalidFormatError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
InvalidFormatError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidFormatError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
InvalidFormatError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidFormatError.expected
name
name: string
Defined in: src/primitives/Siwe/errors.js:50
Inherited from
InvalidFormatError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidFormatError.value
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
InvalidFormatError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidFormatError.toJSON
SiweParseError
Defined in: src/primitives/Siwe/errors.js:107 SIWE message parsing failedThrows
Extends
Constructors
Constructor
new SiweParseError(Defined in: src/primitives/Siwe/errors.js:114message,options?):SiweParseError
Parameters
message
string
Description of the parse error
options?
cause?
Error
value?
unknown
Returns
SiweParseError
Overrides
DecodingError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
DecodingError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
DecodingError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
DecodingError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
DecodingError.docsPath
name
name: string
Defined in: src/primitives/Siwe/errors.js:121
Inherited from
DecodingError.name
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
DecodingError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
DecodingError.toJSON
Type Aliases
BrandedMessage
BrandedMessage<Defined in: src/primitives/Siwe/SiweMessageType.ts:74 Branded SIWE Message type (for backwards compatibility)TDomain,TAddress,TUri,TVersion,TChainId> =SiweMessageType<TDomain,TAddress,TUri,TVersion,TChainId>
Type Parameters
TDomain
TDomain extends string = string
TAddress
TAddress extends AddressType = AddressType
TUri
TUri extends string = string
TVersion
TVersion extends string = string
TChainId
TChainId extends number = number
Deprecated
Use SiweMessageType insteadSignature
Signature = Uint8Array
Defined in: src/primitives/Siwe/SiweMessageType.ts:46
Signature type for SIWE verification
65 bytes: r (32) + s (32) + v (1)
SiweMessageType
SiweMessageType<Defined in: src/primitives/Siwe/SiweMessageType.ts:9 Sign-In with Ethereum Message (EIP-4361) A structured message format for authentication using Ethereum accounts. Supports domains, URIs, nonces, timestamps, and optional resources.TDomain,TAddress,TUri,TVersion,TChainId> =object
Type Parameters
TDomain
TDomain extends string = string
TAddress
TAddress extends AddressType = AddressType
TUri
TUri extends string = string
TVersion
TVersion extends string = string
TChainId
TChainId extends number = number
Properties
address
address: TAddress
Defined in: src/primitives/Siwe/SiweMessageType.ts:19
Ethereum address performing the signing
chainId
chainId: TChainId
Defined in: src/primitives/Siwe/SiweMessageType.ts:27
EIP-155 Chain ID to which the session is bound
domain
domain: TDomain
Defined in: src/primitives/Siwe/SiweMessageType.ts:17
RFC 4501 dns authority that is requesting the signing
expirationTime?
Defined in: src/primitives/Siwe/SiweMessageType.ts:33 ISO 8601 datetime string after which the message is no longer valid (optional)optionalexpirationTime:string
issuedAt
issuedAt: string
Defined in: src/primitives/Siwe/SiweMessageType.ts:31
ISO 8601 datetime string of the current time
nonce
nonce: string
Defined in: src/primitives/Siwe/SiweMessageType.ts:29
Randomized token to prevent replay attacks, at least 8 alphanumeric characters
notBefore?
Defined in: src/primitives/Siwe/SiweMessageType.ts:35 ISO 8601 datetime string before which the message is invalid (optional)optionalnotBefore:string
requestId?
Defined in: src/primitives/Siwe/SiweMessageType.ts:37 System-specific identifier that may be used to uniquely refer to the sign-in request (optional)optionalrequestId:string
resources?
Defined in: src/primitives/Siwe/SiweMessageType.ts:39 List of information or references to information the user wishes to have resolved (optional)optionalresources:string[]
statement?
Defined in: src/primitives/Siwe/SiweMessageType.ts:21 Human-readable ASCII assertion that the user will sign (optional)optionalstatement:string
uri
uri: TUri
Defined in: src/primitives/Siwe/SiweMessageType.ts:23
RFC 3986 URI referring to the resource that is the subject of the signing
version
version: TVersion
Defined in: src/primitives/Siwe/SiweMessageType.ts:25
Current version of the message (must be “1”)
ValidationError
ValidationError = {Defined in: src/primitives/Siwe/SiweMessageType.ts:58 Validation error typesmessage:string;type:"invalid_domain"; } | {message:string;type:"invalid_address"; } | {message:string;type:"invalid_uri"; } | {message:string;type:"invalid_version"; } | {message:string;type:"invalid_chain_id"; } | {message:string;type:"invalid_nonce"; } | {message:string;type:"invalid_timestamp"; } | {message:string;type:"expired"; } | {message:string;type:"not_yet_valid"; } | {message:string;type:"signature_mismatch"; }
ValidationResult
ValidationResult = {Defined in: src/primitives/Siwe/SiweMessageType.ts:51 Validation result with detailed error informationvalid:true; } | {error:ValidationError;valid:false; }
Variables
_getMessageHash
Defined in: src/primitives/Siwe/index.ts:78const_getMessageHash:GetMessageHashFn
_verify
Defined in: src/primitives/Siwe/index.ts:79const_verify:VerifyFn
_verifyMessage
Defined in: src/primitives/Siwe/index.ts:84const_verifyMessage:VerifyMessageFn
BrandedSiwe
Defined in: src/primitives/Siwe/index.ts:156constBrandedSiwe:object
Type Declaration
create()
create: <TDomain,TAddress,TUri,TChainId>(params) =>SiweMessageType<TDomain,TAddress,TUri,"1",TChainId>
Type Parameters
TDomain
TDomain extends string = string
TAddress
TAddress extends AddressType = AddressType
TUri
TUri extends string = string
TChainId
TChainId extends number = number
Parameters
params
CreateParams<TDomain, TAddress, TUri, TChainId>
Returns
SiweMessageType<TDomain, TAddress, TUri, "1", TChainId>
format()
format: (message) =>string
Parameters
message
SiweMessageType
Returns
string
generateNonce()
generateNonce: (length?) =>string
Parameters
length?
number
Returns
string
getMessageHash
getMessageHash: GetMessageHashFn
parse()
parse: (text) =>SiweMessageType
Parameters
text
string
Returns
SiweMessageType
validate()
validate: (message,options?) =>ValidationResult
Parameters
message
SiweMessageType
options?
now?
Date
Returns
ValidationResult
verify
verify: VerifyFn
verifyMessage
verifyMessage: VerifyMessageFn
GetMessageHash()
Defined in: src/primitives/Siwe/index.ts:46constGetMessageHash: (deps) =>GetMessageHashFn
Parameters
deps
keccak256
(data) => Uint8Array
Returns
GetMessageHashFn
Verify()
Defined in: src/primitives/Siwe/index.ts:50constVerify: (deps) =>VerifyFn
Parameters
deps
addressFromPublicKey
(x, y) => AddressType
keccak256
(data) => Uint8Array
secp256k1RecoverPublicKey
(signature, hash) => Secp256k1PublicKeyType
Returns
VerifyFn
VerifyMessage()
Defined in: src/primitives/Siwe/index.ts:59constVerifyMessage: (deps) =>VerifyMessageFn
Parameters
deps
addressFromPublicKey
(x, y) => AddressType
keccak256
(data) => Uint8Array
secp256k1RecoverPublicKey
(signature, hash) => Secp256k1PublicKeyType
Returns
VerifyMessageFn
Functions
_create()
_create<Defined in: src/primitives/Siwe/create.js:40 Create a new SIWE message with default valuesTDomain,TAddress,TUri,TChainId>(params):SiweMessageType<TDomain,TAddress,TUri,"1",TChainId>
Type Parameters
TDomain
TDomain extends string
TAddress
TAddress extends AddressType
TUri
TUri extends string
TChainId
TChainId extends number
Parameters
params
Message parameters (domain, address, uri, chainId are required)address
TAddress
Ethereum address performing the signing
chainId
TChainId
EIP-155 Chain ID
domain
TDomain
RFC 4501 dns authority requesting the signing
expirationTime?
string
ISO 8601 datetime string for expiration
issuedAt?
string
Custom issued at (current time if not provided)
nonce?
string
Custom nonce (auto-generated if not provided)
notBefore?
string
ISO 8601 datetime string for not before
requestId?
string
System-specific identifier
resources?
string[]
List of resources
statement?
string
Human-readable ASCII assertion
uri
TUri
RFC 3986 URI referring to the subject of signing
Returns
SiweMessageType<TDomain, TAddress, TUri, "1", TChainId>
New SIWE message with defaults
See
https://voltaire.tevm.sh/primitives/siwe for SIWE documentationSince
0.0.0Throws
Example
_format()
_format(Defined in: src/primitives/Siwe/format.js:26 Format a SIWE message into a string for signing (EIP-4361)message):string
Parameters
message
SiweMessageType<string, AddressType, string, string, number>
Message to format
Returns
string
Formatted string according to EIP-4361 specification
See
https://voltaire.tevm.sh/primitives/siwe for SIWE documentationSince
0.0.0Throws
Example
_generateNonce()
_generateNonce(Defined in: src/primitives/Siwe/generateNonce.js:22 Generate a cryptographically secure random nonce for SIWE messageslength?):string
Parameters
length?
number = 11
Length of nonce (minimum 8)
Returns
string
Random alphanumeric nonce string
See
https://voltaire.tevm.sh/primitives/siwe for SIWE documentationSince
0.0.0Throws
if length is less than 8Example
_parse()
_parse(Defined in: src/primitives/Siwe/parse.js:39 Parse a SIWE message from a formatted stringtext):SiweMessageType<string,AddressType,string,string,number>
Parameters
text
string
Formatted SIWE message string
Returns
SiweMessageType<string, AddressType, string, string, number>
Parsed Message object
See
https://voltaire.tevm.sh/primitives/siwe for SIWE documentationSince
0.0.0Throws
if message format is invalidThrows
if required field is missingThrows
if field value is invalidThrows
if parsing failsExample
_validate()
_validate(Defined in: src/primitives/Siwe/validate.js:20 Validate a SIWE message structure and timestampsmessage,options?):ValidationResult
Parameters
message
SiweMessageType<string, AddressType, string, string, number>
Message to validate
options?
Validation optionsnow?
Date
Current time for timestamp checks (defaults to now)
Returns
ValidationResult
Validation result with error details if invalid
See
https://voltaire.tevm.sh/primitives/siwe for SIWE documentationSince
0.0.0Throws
Example
create()
create<Defined in: src/primitives/Siwe/index.ts:110TDomain,TAddress,TUri,TChainId>(params):SiweMessageType<TDomain,TAddress,TUri,"1",TChainId>
Type Parameters
TDomain
TDomain extends string = string
TAddress
TAddress extends AddressType = AddressType
TUri
TUri extends string = string
TChainId
TChainId extends number = number
Parameters
params
CreateParams<TDomain, TAddress, TUri, TChainId>
Returns
SiweMessageType<TDomain, TAddress, TUri, "1", TChainId>
format()
format(Defined in: src/primitives/Siwe/index.ts:121message):string
Parameters
message
SiweMessageType
Returns
string
generateNonce()
generateNonce(Defined in: src/primitives/Siwe/index.ts:125length?):string
Parameters
length?
number
Returns
string
parse()
parse(Defined in: src/primitives/Siwe/index.ts:129text):SiweMessageType
Parameters
text
string
Returns
SiweMessageType
Siwe()
Siwe<Defined in: src/primitives/Siwe/index.ts:170 Factory function for creating SIWE Message instancesTDomain,TAddress,TUri,TChainId>(params):SiweMessageType<TDomain,TAddress,TUri,"1",TChainId>
Type Parameters
TDomain
TDomain extends string = string
TAddress
TAddress extends AddressType = AddressType
TUri
TUri extends string = string
TChainId
TChainId extends number = number
Parameters
params
CreateParams<TDomain, TAddress, TUri, TChainId>
Returns
SiweMessageType<TDomain, TAddress, TUri, "1", TChainId>
validate()
validate(Defined in: src/primitives/Siwe/index.ts:133message,options?):ValidationResult
Parameters
message
SiweMessageType
options?
now?
Date
Returns
ValidationResult

