LoKey is a lightweight library that leverages ethers.js to securely delegate a signer and sign messages without prompting the user for each siging operation.
To install LoKey, use npm:
npm install @orbs-network/lokey
Initialise a new instance of LoKey.
Example:
const lokey = new LoKey(async (payload) => {
// Implement a function to sign the payload with your integrated EOA (e.g. MetaMask)
return await signTypedDataAsync(payload);
});
Inputs:
signTypedDataCallback
((payload) => Promise<string>
, required): The callback to sign typed data.
Outputs:
lokey
: A new instance of the LoKey SDK.
Create a new signer.
Example:
const { address, signature } = await lokey.createSigner();
Outputs:
address
(string): The hex string signer address.signature
(string): The hex encoded signature of the delegated signer payload that needs to be sent to your backend to verify signatures.
Sign a message using the LoKey signer.
Example:
const signature = await lokey.sign(payload);
Inputs:
payload
(TypedData, required): Typed data according to EIP-712 standards.
Outputs:
signature
(string): The hex encoded signature.
To run the included example, follow these steps:
cd example
npm install
npm run dev
This demonstrates how to integrate LoKey into a React application.
- LoKey leverages secure browser features like Web Workers for key management.
LoKey is licensed under the MIT License.