Ethereum Address Authentication
Build an authentication workflow with using Ethereum address and EIP712.
token is stored as base64 encoded string of an object of following interface:
interface TokenInterface {
address: string;
deadline: number;
signature: string;
}
Deadline is stored as number (in seconds).
install:
yarn add @peersky/eth-auth
Frontend
API:
function signAccessToken(
signer: Wallet | JsonRpcSigner | HDNodeWallet,
duration: number,
domain?: TypedDataDomain
): Promise<string>;
function parseToken(token: string): TokenInterface;
function isOutdated(deadline: number | string): boolean;
function validateToken(token: string, domain?: TypedDataDomain): boolean;
function tryGetAuthenticated(token: string, domain?: TypedDataDomain): string;