Wallet
A cloud wallet holds a user's credentials on Hovi's servers. This page covers creating, listing and deleting wallets. Creating and listing wallets use your Cloud Wallet API key; deleting a wallet uses the wallet's access token (see Authentication).
Create wallet
Creates a new wallet.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
apiKey: '<YOUR_CLOUD_WALLET_API_KEY>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.createWallet({
label: 'Jane Doe',
secret: '<WALLET_SECRET>',
});
const walletAccessToken = result.response.accessToken;
Params
| Parameter | Type | Description |
|---|---|---|
| label | string (Required) | A name for the wallet. |
| secret | string (Required) | A secret that protects the wallet. |
| apiKey | string (Optional) | Your Cloud Wallet API key, if you did not pass it to the constructor. |
The response contains the wallet's id, its accessToken and its did. Use the accessToken for every call on this wallet.
note
- Store the
secretsecurely and never expose it.
Get wallet
Lists the wallets created with your Cloud Wallet API key.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
apiKey: '<YOUR_CLOUD_WALLET_API_KEY>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.getWallet({});
Params
| Parameter | Type | Description |
|---|---|---|
| apiKey | string (Optional) | Your Cloud Wallet API key, if you did not pass it to the constructor. |
Delete wallet
Deletes the wallet whose access token you use.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
walletAccessToken: '<WALLET_ACCESS_TOKEN>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.deleteWallet();
note
- This can't be undone. All the wallet's data, including its credentials, is deleted.