@infinex/wallet
v0.0.1
Published
iframe hosted web wallet for ethereum
Downloads
2
Keywords
Readme
@infinex/wallet - Wallet App
iframe-hosted web wallet for ethereum
Usage
npx @infinex/wallet [serve|build] \
--output-directory=dist-wallet \
--identifier-strategy=jwt \
--identifier-strategy-jwt-claim=id \
--identifier-strategy-jwt-jwks={} \
--redirect-url=http://localhost
- Run
build
and upload the resulting HTML/JS output to a static web host. - Use
@infinex/wallet-sdk
to communicate with the wallet. - For security, both the wallet and the parent app must be on separate origins.
- These can be different ports and/or different domains or subdomains.
postMessage API
Unlock Wallet
// Send 'unlock' method to iframe
{ "id": 1234, "method": "unlock", "args": { "identifier": "jwt_or_other_identifier..." } }
// Return message - Unlock was successful
{ "id": 1234, "result": { "address": "0xabc123bef987" } }
// Return message - Error while unlocking
{ "id": 1234, "error": { "message": "No wallet with the provided identifier" } }
Sign Message
// Send 'signmessage' method to iframe
{ "id": 5678, "method": "signMessage", "args": { "message": "my message" } }<
// Return message - Message signing was successful
{ "id": 5678, "result": { "signature": "abc123bef987" } }
// Return message - Error while signing message
{ "id": 5678, "error": { "message": "Wallet is locked" } }
Sign Transaction
// Send 'signTransaction' method to iframe - `transaction` should be a raw transaction string.
// for ethers, use `transaction.unsignedSerialized`
{
"id": 9012,
"method": "signTransaction",
"args": { "transaction": "raw-transaction" }
}
Lock Wallet
// Send 'lock' method to iframe
{ "id": 3456, "method": "lock" }
// Return message - Wallet lock was successful
{ "id": 3456, "result": {} }
// Return message - Error while locking wallet
{ "id": 3456, "error": { "message": "Wallet is already locked" } }
Clear Wallet Storage
// Send 'clearStorage' method to iframe
{ "id": 7890, "method": "clearStorage" }
// Return mesage - wallet lock was successful
{ "id": 7890, "result": {} }
// Return message - Error while clearing storage
{ "id": 7890, "error": { "message": "Wallet app is not initialised" } }