mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
docs: Describe keystore and the alternative ways to set its location.
This commit is contained in:
@@ -36,7 +36,13 @@ const orbitdb = await OrbitDB({ identities, id: 'userA' })
|
||||
|
||||
This identity can now be used by OrbitDB to control access to database actions such as write.
|
||||
|
||||
## Specifying a keystore
|
||||
## Key Store
|
||||
|
||||
The key store is a local key manager for OrbitDB and is used to store the private keys generated by `Identities.createIdentity`.
|
||||
|
||||
[PublicKeyIdentityProvider](https://api.orbitdb.org/PublicKeyIdentityProvider) also uses key store to store the root key which is used to sign the identities created with `Identities.createIdentity`.
|
||||
|
||||
### Specifying a keystore
|
||||
|
||||
An existing keystore can be passed to `Identities`:
|
||||
|
||||
@@ -49,6 +55,34 @@ const identities = await Identities({ keystore })
|
||||
const identity = identities.createIdentity({ id })
|
||||
```
|
||||
|
||||
### Customizing the key store path
|
||||
|
||||
There are different ways to customize the location of the key store.
|
||||
|
||||
To change the keystore using `OrbitDB`, pass a custom directory:
|
||||
```
|
||||
// This will create a key store under ./different-path/key-store
|
||||
const orbitdb = await OrbitDB({ directory: './different-path' })
|
||||
// Be aware that this will change the base path to the database as well.
|
||||
```
|
||||
|
||||
To change the keystore using the KeyStore function, pass a custom path to the `KeyStore` function:
|
||||
```
|
||||
// This will create a key store under ./different-key-store.
|
||||
const path = ./different-key-store
|
||||
const keystore = await KeyStore({ path })
|
||||
|
||||
// keystore can now be used with other functions, for example:
|
||||
const identities = await Identities({ keystore })
|
||||
```
|
||||
|
||||
To specify a different keystore path using `Identities`, pass a custom path to the `Identities` function:
|
||||
```
|
||||
/// This will create a KeyStore under ./different-identities-path
|
||||
const path = ./different-identities-path
|
||||
const identities = await Identities({ path })
|
||||
```
|
||||
|
||||
## Identity as a linked data object
|
||||
|
||||
The identity object is stored just like any other [IPLD data structure](https://ipld.io/docs/) and can therefore be retrieved from IPFS using the identity's hash:
|
||||
|
||||
Reference in New Issue
Block a user