Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bryopsida/redis-key-store
A redis backed implementation of bryopsida/key-store in typescript
https://github.com/bryopsida/redis-key-store
data-encryption-key keystore nodejs redis typescript
Last synced: 9 days ago
JSON representation
A redis backed implementation of bryopsida/key-store in typescript
- Host: GitHub
- URL: https://github.com/bryopsida/redis-key-store
- Owner: bryopsida
- License: unlicense
- Created: 2023-02-05T21:05:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-23T14:57:35.000Z (14 days ago)
- Last Synced: 2024-10-25T01:10:47.815Z (13 days ago)
- Topics: data-encryption-key, keystore, nodejs, redis, typescript
- Language: TypeScript
- Homepage:
- Size: 837 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Redis-Key-Store
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=bryopsida_redis-key-store&metric=coverage)](https://sonarcloud.io/summary/new_code?id=bryopsida_redis-key-store) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=bryopsida_redis-key-store&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=bryopsida_redis-key-store) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=bryopsida_redis-key-store&metric=bugs)](https://sonarcloud.io/summary/new_code?id=bryopsida_redis-key-store) [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=bryopsida_redis-key-store&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=bryopsida_redis-key-store)
## What is this?
This is a implenetation of [@bryopsida/key-store](http://github.com/bryopsida/key-store) using redis as a backing store for use in distributed systems.
## How do I use it?
```typescript
import { Redis } from 'ioredis'
import { describe, expect, it } from '@jest/globals'
import { randomBytes, randomUUID } from 'crypto'
import pino from 'pino'// create a redis client
const redisClient: Redis = new Redis(6379, 'localhost')// fetch your key for the store
let password: Buffer // 32 bytes
let salt: Buffer // 16 bytes
let context: Buffer // 32 bytes// create a logger
const logger: Logger = pino()
const keyPrefix: string = 'keys'// create the key store
const store = new RedisKeyStore(
logger,
redisClient,
keyPrefix,
() => Promise.resolve(password),
() => Promise.resolve(salt),
() => Promise.resolve(context)
)it('can manage a DEK', async () => {
// create random data to act as key store
const dek = randomBytes(32)
const id = randomUUID()// save it
await keyStore.saveSealedDataEncKey(id, dek)// ask for it back
const fetchedDek = await keyStore.fetchSealedDataEncKey(id)// should be the same
expect(fetchedDek).toEqual(dek)// delete it
await keyStore.destroySealedDataEncKey(id)
})
```