open-index/open-npm huggingface dataset:
npm package: @infinex/wallet
Description: iframe hosted web wallet for ethereum
Latest version: 0.0.1

# @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

```json
// 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

```json
// 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

```json
// 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

```json
// 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

```json
// 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" } }
```
npm package: @infinex/wallet-sdk
Description: SDK to set up and communicate with an instance of @infinex/wallet
Latest version: 0.0.1

# @infinex/wallet-sdk

SDK to create and communicate with an instance of the `@infinex/wallet`.

## Example

```typescript
const sdk = new WalletSDK("#sdk", {
  url: "http://my-key-app/",
});

// Unlock with a JWT
const jwt = "eyJhbG...";
const { address } = await sdk.unlock(jwt);

// Get an ethers wallet/signer
const provider = getEthersProvider();
const signer = sdk.ethersSigner(provider);

// Sign a message string with the wallet
const signature = await signer.signMessage(`A message from ${address}`);

// Lock the wallet
await lock();

console.log(address, signature);
```