Siwe (siwe v0.1.0)

Siwe provides validation and parsing for Sign-In with Ethereum messages and signatures. Exposes the verify!(message, signature) which raises if invalid and returns a Message if valid.

Link to this section Summary

Functions

Tests that a message and signature pair correspond and that the current time is valid (after not_before, and before expiration_time) any validation of other fields to server's expectation are left to the calling application. Just a wrapper around the Rustler NIF

Link to this section Functions

Link to this function

verify!(message, signature)

Specs

verify!(String.t(), String.t()) :: Siwe.Message.t()

Tests that a message and signature pair correspond and that the current time is valid (after not_before, and before expiration_time) any validation of other fields to server's expectation are left to the calling application. Just a wrapper around the Rustler NIF

Returns a Message structure based on the passed message

## Examples iex> Siwe.verify!(Enum.join(["login.xyz wants you to sign in with your Ethereum account:", ...> "0xfA151B5453CE69ABf60f0dbdE71F6C9C5868800E", ...> "", ...> "Sign-In With Ethereum Example Statement", ...> "", ...> "URI: https://login.xyz", ...> "Version: 1", ...> "Chain ID: 1", ...> "Nonce: ToTaLLyRanDOM", ...> "Issued At: 2021-12-17T00:38:39.834Z", ...> ], "\n"), ...> "0x8d1327a1abbdf172875e5be41706c50fc3bede8af363b67aefbb543d6d082fb76a22057d7cb6d668ceba883f7d70ab7f1dc015b76b51d226af9d610fa20360ad1c") ...> %{ ...> struct: Siwe, ...> address: "0xfA151B5453CE69ABf60f0dbdE71F6C9C5868800E", ...> chain_id: "1", ...> domain: "login.xyz", ...> expiration_time: "2021-12-18T20:21:39.907Z", ...> issued_at: "2021-12-16T20:21:39.911Z", ...> nonce: "ToTaLLyRanDOM", ...> not_before: nil, ...> request_id: nil, ...> resources: [], ...> statement: "Sign-In With Ethereum Example Statement", ...> uri: "https://login.xyz", ...> version: "1" ...> }