v2.0 Beta
TypeScript v2.0 beta
This version is currently in beta and can be installed by using
[email protected]
instead of siwe
The function
validate(sig, provider)
is now deprecated and will be replaced by verify(VerifyParams, VerifyOpts)
. These two new parameters accept the following fields:export interface VerifyParams {
/** Signature of the message signed by the wallet */
signature: string;
/** RFC 4501 dns authority that is requesting the signing. */
domain?: string;
/** Randomized token used to prevent replay attacks, at least 8 alphanumeric characters. */
nonce?: string;
/**ISO 8601 datetime string of the current time. */
time?: string;
}
export interface VerifyOpts {
/** ethers provider to be used for EIP-1271 validation */
provider?: providers.Provider;
/** If the library should reject promises on errors, defaults to false */
suppressExceptions?: boolean;
}
To make transitioning easier, the previous
validate(sig, provider)
function was mapped to verify({ signature: sig }, { provider: provider })
. Migrating is advised since the function may eventually be removed.The new function makes it easier to match fields automatically - like
domain
, nonce
and match against other TimeDate instead of now (time
).The return type was also modified. It now returns a
SiweResponse
instead of a SiweMessage
, and this new object is defined by the following interface:export interface SiweResponse {
/** Boolean representing if the message was verified with success. */
success: boolean;
/** If present `success` MUST be false and will provide extra information on the failure reason. */
error?: SiweError;
/** Original message that was verified. */
data: SiweMessage;
}
As part of the new API, new error types were also introduced to further clarify when a message fails verification. These errors are defined at:

siwe/types.ts at main · spruceid/siwe
GitHub
SIWE type definitions
More information regarding the rationale behind the API Harmonization and TypeScript v2.0 beta release can be found here:
Last modified 8mo ago