@stellar/typescript-wallet-sdk-km
v1.7.0
Published
The Typescript Wallet Key Manager SDK is a library that allows developers to use key managing functionality in their wallet applications. It works in conjuction with the main [Typescript Wallet SDK](https://github.com/stellar/typescript-wallet-sdk) to hol
Downloads
558
Keywords
Readme
Stellar Typescript Wallet Key Manager SDK
The Typescript Wallet Key Manager SDK is a library that allows developers to use key managing functionality in their wallet applications. It works in conjuction with the main Typescript Wallet SDK to hold all the functionality a developer would need to create a wallet for the stellar network.
Dependency
The library is available via npm. To import typescript-wallet-sdk-km
you need
to add it as a dependency to your code:
yarn:
yarn add @stellar/typescript-wallet-sdk-km
npm:
npm install @stellar/typescript-wallet-sdk-km
Introduction
Here's a small example on how to use the KeyManager to store and retrieve a key:
Import the package:
import { KeyManager, MemoryKeyStore } from "@stellar/typescript-wallet-sdk-km";
Creating a KeyManager class using simple memory key storage:
const testStore = new MemoryKeyStore();
const testKeyManager = new KeyManager({ keyStore: testStore });
Store an encrypted key:
const id = "this is a my test id";
testKeyManager.registerEncrypter(IdentityEncrypter);
await testKeyManager.storeKey({
key: {
id,
type: KeyType.plaintextKey,
publicKey: "TestPublicKey",
privateKey: "TestPrivateKey",
},
password: "test",
encrypterName: "IdentityEncrypter",
});
Retrieve the stored key:
const keyData = await testKeyManager.loadKey(id, password);