-
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Milestone
Description
We build a new KeychainProgram that extends Program and can be used by devs to handle keys for them.
How might this be implemented?
import { Keychain } from '@peerbit/keychain'
class KeychainDB extends Program implements Keychain, EncryptionProvider ?
{
@field({type: Documents<Key>}}
keys: Documents<Key>
async open() {
await this.keys.open({ encryption: new EncryptionProvider(this) }} // create a encryption provider from 'this' because 'this' implements Keychain interface
}
async addKey(key: Key) {
return this.keys.put(key, { encryption: { specific encryption options }}
}
}... And how could we possibly use it?
import { KeychainDB } from '@peerbit/keychain'
class MySpecialDBAndKeychain extends Program
{
@field({type: KeychainProgram}}
keychain: KeychainProgram
@field({type: Posts}}
posts: Posts
async open() {
await this.keychain.open()
await this.posts.open( { encryption: this.keychain.encryption } ) // use custom encryption provider (layer 1)
}
async createPost(content: string) {
return this.posts.put(new Post(content))
}
}And then the Posts Document can use the passed encryption and decryption provider to store encrypted data.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels