0.23.4 • Published 21 hours ago

@sphereon/ssi-sdk.kv-store-temp v0.23.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
21 hours ago

Veramo Key Value store

A simple typed Key Value store with out of the box support for in memory/maps, sqlite and typeorm implementations for usage in browser, NodeJS and React-Native. It includes a tiered local/remote implementation that support all environments.

Usage in your application or module

setup

Veramo provides 3 store adapters out of the box. The first is an in memory Map based store, the second is a TypeORM based store, meaning we support multiple databases. Lastly there is a tiered store, which allows you to use a local and remote store together.

You should also be able to use store adapters from the keyv project. Be aware that Veramo uses an internal fork of that project, as we have several constraints not present in the upstream project. As a result the adapters are not guaranteed to work in your environment. See Keyv project relationship for more information.

Map based in memory store

This is the simplest implementation where a Map is being used to store the Keys and Values

import { IKeyValueStore, IKeyValueStoreOptions, KeyValueStore } from '@veramo/key-value-store'

const options: IKeyValueStoreOptions<MyValueType> = {
  namespace: 'example',
  store: new Map<string, MyValueType>(),
}
const kvStore: IKeyValueStore<MyValueType> = new KeyValueStore({ options })

TypeORM store

This implementation uses TypeORM using a simple entity to store the namespace prefixed key, an expiration value and the value itself. It supports multiple database backends.

import { IKeyValueStore, IKeyValueStoreOptions, KeyValueStore, KeyValueStoreEntity, KeyValueTypeORMStoreAdapter } from '@veramo/key-value-store'
import { DataSource } from 'typeorm'

const dbConnection: DataSource = await new DataSource({
  type: 'sqlite',
  database: ':memory:',
  logging: 'all',
  migrationsRun: true,
  synchronize: false,
  entities: [KeyValueStoreEntity],
}).initialize()

const options: IKeyValueStoreOptions<MyValueType> = {
  namespace: 'example',
  store: new KeyValueTypeORMStoreAdapter({ dbConnection }),
}
const kvStore: IKeyValueStore<MyValueType> = new KeyValueStore({ options })

Tiered store

The tiered store expects a local store and a remote store. Obviously it makes most sense to have a memory based local store and potentially more expensive/slower remote store

import {
  kvStoreMigrations,
  IKeyValueStore,
  IKeyValueStoreOptions,
  KeyValueStore,
  KeyValueStoreEntity,
  KeyValueTieredStoreAdapter,
  KeyValueTypeORMStoreAdapter,
} from '@veramo/key-value-store'
import { DataSource } from 'typeorm'

dbConnection = await new DataSource({
  type: 'sqlite',
  database: ':memory:',
  logging: 'all',
  migrationsRun: true,
  synchronize: false,
  migrations: [...kvStoreMigrations],
  entities: [KeyValueStoreEntity],
}).initialize()

const local: Map<string, MyValueType> = new Map()
const remote = new KeyValueTypeORMStoreAdapter({ dbConnection })

const options: IKeyValueStoreOptions<MyValueType> = {
  namespace: 'example',
  store: new KeyValueTieredStoreAdapter({ local, remote }),
}
const kvStore: IKeyValueStore<MyValueType> = new KeyValueStore<MyValueType>({ options })

Usage

After you have setup the Key Value Store as described above in your agent, it will be available in your agent.

kvStore.set('hello', { example: world }) // Stores the value object by key untill deleted
kvStore.set('expiring', { example: 'expiration' }, 1000) // Stores the value object by key for 1 second
const value = await kvStore.get('hello') // { example: world }
const values = await kvStore.getMany(['hello', 'expiring']) // [{ example: world }, {example: expiring}]

if (await kvStore.has('hello')) {
  await kvStore.delete('hello') // return a boolean for success. You can also call it on non existing keys, which will return false
}

await kvStore.clear() // Removes all keys/values from the store
kvStore.disconnect() // disconnects the store from it backing adapter. You cannot reuse the store afterwards unlesss you initialize a new store.

Keyv project relationship

Please note that a large portion of the Veramo Key Value Store code is a port of the keyv project, adding support for Typescript and ESM, so it can be used Veramo

The ported code should support the storage plugins available for the keyv project, although testing has been limited Veramo itself has a requirement to support NodeJS, Browser and React-Native environments. The port and the store adapters included in Veramo run in these environments. Please be aware that these requirements probably aren't true for any keyv storage plugins.

One of the big changes compared to the upstream project is that this port does not have dynamic loading of adapters based on URIs. We believe that any Veramo Key Value store should use explicit defined adapters.

The keyv port is part of the Veramo Key Value Store module code itself, as we do not want to make an official maintained port at this point.

Veramo exposes its own API/interfaces for the Key Value store, meaning we could also support any other implementation in the future

We welcome any new storage modules

0.23.5-unstable.17

21 hours ago

0.23.5-next.12

6 days ago

0.23.5-next.11

7 days ago

0.23.5-next.10

9 days ago

0.23.1-next.7

14 days ago

0.23.3-next.3

13 days ago

0.23.4

13 days ago

0.23.2-next.4

14 days ago

0.23.1-next.2

14 days ago

0.23.0

14 days ago

0.21.2-next.25

14 days ago

0.21.2-next.23

27 days ago

0.21.2-next.8

29 days ago

0.21.2-next.7

29 days ago

0.21.2-next.6

29 days ago

0.21.2-next.17

28 days ago

0.22.0

1 month ago

0.21.1-next.8

1 month ago

0.21.1-next.4

1 month ago

0.21.1-unstable.5

2 months ago

0.19.1-next.125

2 months ago

0.19.1-next.126

2 months ago

0.21.0

2 months ago

0.19.1-next.119

2 months ago

0.19.1-next.135

2 months ago

0.21.1-next.2

2 months ago

0.19.1-next.117

2 months ago

0.19.1-next.113

2 months ago

0.19.1-next.114

2 months ago

0.19.1-next.115

2 months ago

0.19.1-next.116

2 months ago

0.19.1-next.111

2 months ago

0.19.1-next.112

2 months ago

0.19.1-next.105

2 months ago

0.19.1-next.110

2 months ago

0.19.1-next.106

2 months ago

0.19.1-next.108

2 months ago

0.19.1-next.109

2 months ago

0.19.1-next.98

2 months ago

0.19.1-next.99

2 months ago

0.19.1-next.102

2 months ago

0.19.1-next.100

2 months ago

0.19.1-next.101

2 months ago

0.19.1-next.96

2 months ago

0.19.1-unstable.88

2 months ago

0.19.1-unstable.89

2 months ago

0.19.1-unstable.86

2 months ago

0.19.1-unstable.87

2 months ago

0.19.1-unstable.93

2 months ago

0.19.1-unstable.94

2 months ago

0.19.1-unstable.91

2 months ago

0.19.1-unstable.92

2 months ago

0.19.1-unstable.90

2 months ago

0.19.1-unstable.84

2 months ago

0.19.1-unstable.85

2 months ago

0.19.1-unstable.82

2 months ago

0.19.1-unstable.80

2 months ago

0.19.1-unstable.81

2 months ago

0.19.1-unstable.78

2 months ago

0.19.1-unstable.77

2 months ago

0.19.1-unstable.75

2 months ago

0.19.1-next.75

2 months ago

0.19.1-unstable.73

2 months ago

0.19.1-unstable.74

2 months ago

0.19.1-unstable.69

2 months ago

0.19.1-unstable.67

2 months ago

0.19.1-unstable.65

2 months ago

0.19.1-unstable.63

2 months ago

0.19.1-next.2

2 months ago

0.18.2-unstable.98

2 months ago

0.19.1-next.24

2 months ago

0.19.0

2 months ago

0.18.2-next.96

2 months ago

0.18.2-unstable.57

2 months ago

0.18.2-unstable.97

2 months ago

0.18.2-next.95

2 months ago

0.18.2-next.94

2 months ago

0.18.2-next.92

2 months ago

0.18.2-unstable.96

2 months ago

0.18.2-unstable.95

2 months ago

0.18.2-unstable.55

2 months ago

0.18.2-unstable.89

2 months ago

0.18.2-unstable.88

2 months ago

0.18.2-unstable.90

2 months ago

0.18.2-unstable.87

2 months ago

0.18.2-unstable.85

2 months ago

0.18.2-next.58

3 months ago

0.18.2-next.62

3 months ago

0.18.2-unstable.12

3 months ago

0.18.2-unstable.61

3 months ago

0.18.2-next.77

3 months ago

0.18.2-unstable.56

3 months ago

0.18.2-unstable.53

3 months ago

0.18.2-unstable.67

3 months ago

0.18.2-unstable.64

3 months ago

0.18.2-next.57

3 months ago

0.18.2-unstable.59

3 months ago

0.18.2-unstable.60

3 months ago

0.18.2-next.47

3 months ago

0.18.2-next.15

3 months ago

0.18.2-next.17

3 months ago

0.18.2-unstable.54

3 months ago

0.18.2-unstable.51

3 months ago

0.18.2-unstable.50

3 months ago

0.18.2-next.14

3 months ago

0.18.2-unstable.22

3 months ago

0.18.2-next.12

3 months ago

0.18.2-unstable.46

3 months ago

0.18.2-next.9

3 months ago

0.18.2-unstable.14

3 months ago

0.18.2-unstable.13

3 months ago

0.18.2-unstable.44

3 months ago

0.18.2-unstable.34

3 months ago

0.18.2-unstable.36

3 months ago

0.18.2-unstable.35

3 months ago

0.18.2-unstable.33

3 months ago

0.18.2-unstable.32

3 months ago

0.18.2-unstable.30

3 months ago

0.18.2-unstable.5

3 months ago

0.18.2-unstable.6

3 months ago

0.18.2-unstable.7

3 months ago

0.18.2-unstable.8

3 months ago

0.18.2-unstable.10

3 months ago

0.17.6-unstable.80

3 months ago

0.17.6-unstable.79

3 months ago

0.18.2-next.3

4 months ago

0.18.2-unstable.25

4 months ago

0.18.2-unstable.24

4 months ago

0.18.1

4 months ago

0.18.1-next.8

4 months ago

0.18.1-next.3

4 months ago

0.18.1-next.2

4 months ago

0.18.1-next.4

4 months ago

0.17.6-next.61

4 months ago

0.18.0

4 months ago

0.17.6-next.58

4 months ago

0.17.6-unstable.74

4 months ago

0.17.6-unstable.72

4 months ago

0.17.6-unstable.73

4 months ago

0.17.6-unstable.71

4 months ago

0.17.6-next.57

4 months ago

0.17.6-next.56

5 months ago

0.17.6-next.52

5 months ago

0.17.6-unstable.69

5 months ago

0.17.6-unstable.54

5 months ago

0.17.6-unstable.55

5 months ago

0.17.6-unstable.23

5 months ago

0.17.2

7 months ago

0.14.2-unstable.13

9 months ago

0.17.3

7 months ago

0.17.4

7 months ago

0.17.5

7 months ago

0.16.1-next.3

7 months ago

0.17.0

7 months ago

0.17.1

7 months ago

0.17.2-next.2

7 months ago

0.17.2-next.4

7 months ago

0.14.2-unstable.31

9 months ago

0.14.2-unstable.32

9 months ago

0.17.6-unstable.4

7 months ago

0.15.2-next.96

8 months ago

0.17.6-unstable.3

7 months ago

0.15.2-next.95

8 months ago

0.15.2-next.97

8 months ago

0.17.6-unstable.8

6 months ago

0.15.2-unstable.24

9 months ago

0.17.6-unstable.6

7 months ago

0.15.2-unstable.26

9 months ago

0.17.6-unstable.5

7 months ago

0.15.2-unstable.25

9 months ago

0.13.1-next.3

10 months ago

0.13.1-next.4

10 months ago

0.13.1-next.5

10 months ago

0.13.1-next.6

10 months ago

0.13.1-next.7

10 months ago

0.13.1-next.8

10 months ago

0.15.2-unstable.17

9 months ago

0.15.2-unstable.16

9 months ago

0.15.2-unstable.11

9 months ago

0.15.2-unstable.10

9 months ago

0.15.2-unstable.13

9 months ago

0.15.2-unstable.15

9 months ago

0.13.1-next.32

9 months ago

0.17.1-next.2

7 months ago

0.13.1-next.33

9 months ago

0.15.0

9 months ago

0.15.1

9 months ago

0.13.1-next.17

10 months ago

0.13.1-next.14

10 months ago

0.13.1-next.15

10 months ago

0.13.1-next.10

10 months ago

0.13.1-next.18

10 months ago

0.16.0

7 months ago

0.13.1-next.27

10 months ago

0.13.1-next.28

9 months ago

0.13.1-next.25

10 months ago

0.13.1-next.26

10 months ago

0.13.1-next.23

10 months ago

0.13.1-next.24

10 months ago

0.15.1-next.2

9 months ago

0.17.3-next.2

7 months ago

0.15.2-next.39

8 months ago

0.15.2-next.32

8 months ago

0.15.2-next.33

8 months ago

0.15.2-unstable.8

9 months ago

0.15.2-unstable.7

9 months ago

0.15.2-unstable.9

9 months ago

0.13.1-unstable.10

10 months ago

0.13.1-unstable.13

10 months ago

0.13.1-unstable.12

10 months ago

0.13.1-unstable.11

10 months ago

0.13.1-unstable.18

9 months ago

0.13.1-unstable.15

10 months ago

0.15.2-unstable.76

8 months ago

0.15.2-next.113

8 months ago

0.15.2-next.110

8 months ago

0.15.2-next.111

8 months ago

0.17.6-next.7

7 months ago

0.17.6-next.6

7 months ago

0.17.6-next.9

6 months ago

0.17.6-next.3

7 months ago

0.17.6-next.2

7 months ago

0.17.6-next.5

7 months ago

0.17.6-next.4

7 months ago

0.14.2-next.28

9 months ago

0.14.2-next.27

9 months ago

0.14.2-next.29

9 months ago

0.14.2-next.23

9 months ago

0.15.2-next.103

8 months ago

0.14.2-next.26

9 months ago

0.15.2-next.104

8 months ago

0.14.2-next.25

9 months ago

0.14.0

9 months ago

0.15.2-next.109

8 months ago

0.14.1

9 months ago

0.15.2-unstable.91

8 months ago

0.15.2-unstable.93

8 months ago

0.15.2-next.124

7 months ago

0.15.2-unstable.92

8 months ago

0.15.2-next.121

7 months ago

0.15.2-next.29

8 months ago

0.14.2-next.18

9 months ago

0.15.2-next.116

8 months ago

0.15.2-unstable.97

8 months ago

0.15.2-next.117

8 months ago

0.15.2-next.114

8 months ago

0.15.2-unstable.99

8 months ago

0.15.2-unstable.98

8 months ago

0.14.2-next.14

9 months ago

0.15.2-next.118

8 months ago

0.14.2-next.40

9 months ago

0.17.6-unstable.18

6 months ago

0.15.2-next.4

9 months ago

0.15.2-next.5

9 months ago

0.15.2-next.6

9 months ago

0.14.2-unstable.57

9 months ago

0.14.2-next.49

9 months ago

0.14.2-unstable.56

9 months ago

0.14.2-next.45

9 months ago

0.14.2-next.48

9 months ago

0.14.2-next.47

9 months ago

0.14.2-next.42

9 months ago

0.15.2-next.77

8 months ago

0.14.2-next.41

9 months ago

0.14.2-next.43

9 months ago

0.15.2-next.101

8 months ago

0.15.2-unstable.38

8 months ago

0.14.2-next.39

9 months ago

0.14.2-next.38

9 months ago

0.14.1-next.2

9 months ago

0.17.6-unstable.16

7 months ago

0.14.2-next.35

9 months ago

0.14.2-next.34

9 months ago

0.17.6-unstable.14

5 months ago

0.14.2-next.37

9 months ago

0.17.6-unstable.15

7 months ago

0.14.2-next.36

9 months ago

0.17.6-unstable.12

7 months ago

0.14.2-next.31

9 months ago

0.17.6-unstable.13

5 months ago

0.14.2-next.30

9 months ago

0.17.6-unstable.10

6 months ago

0.15.2-unstable.37

8 months ago

0.14.2-next.33

9 months ago

0.17.6-unstable.11

7 months ago

0.15.2-unstable.36

8 months ago

0.14.2-next.32

9 months ago

0.14.2-next.51

9 months ago

0.14.2-next.50

9 months ago

0.17.6-next.16

5 months ago

0.15.2-next.3

9 months ago

0.13.1-unstable.6

10 months ago

0.13.1-unstable.7

10 months ago

0.13.1-unstable.8

10 months ago

0.14.2-next.58

9 months ago

0.13.1-unstable.9

10 months ago

0.13.0

11 months ago

0.12.1-unstable.18

11 months ago

0.12.1-unstable.19

11 months ago

0.12.1-unstable.17

11 months ago

0.12.1-next.21

11 months ago

0.12.1-next.20

11 months ago

0.12.1-next.19

11 months ago

0.12.1-unstable.16

11 months ago

0.12.1-unstable.15

11 months ago

0.12.1-unstable.14

11 months ago

0.12.0

11 months ago

0.11.1-next.154

11 months ago

0.11.1-next.153

11 months ago

0.11.1-unstable.163

11 months ago

0.11.1-next.152

11 months ago

0.11.1-next.162

11 months ago

0.11.1-unstable.161

11 months ago

0.11.1-unstable.160

11 months ago

0.11.1-next.151

11 months ago

0.11.1-unstable.153

11 months ago

0.11.1-unstable.152

11 months ago

0.11.1-unstable.151

11 months ago

0.11.1-unstable.150

11 months ago

0.11.1-next.150

11 months ago

0.11.1-next.149

11 months ago

0.11.1-next.148

11 months ago

0.11.1-next.147

11 months ago

0.11.1-next.146

11 months ago

0.11.1-unstable.149

11 months ago

0.11.1-next.145

11 months ago

0.11.1-next.144

11 months ago

0.11.1-next.142

11 months ago

0.11.1-next.141

11 months ago

0.11.1-next.140

11 months ago

0.11.1-next.131

11 months ago

0.11.1-unstable.130

11 months ago

0.11.1-unstable.121

11 months ago

0.11.1-unstable.117

11 months ago

0.11.1-next.112

11 months ago

0.11.1-unstable.111

11 months ago

0.11.1-unstable.110

11 months ago

0.11.1-unstable.109

11 months ago

0.11.1-unstable.73

11 months ago

0.11.1-next.106

11 months ago

0.11.1-unstable.105

11 months ago

0.11.1-unstable.104

11 months ago

0.11.1-unstable.103

11 months ago

0.11.1-unstable.102

11 months ago

0.11.1-unstable.101

11 months ago

0.11.1-next.72

12 months ago

0.11.1-next.70

12 months ago