add vault.get

This commit is contained in:
Matt Hill
2023-05-06 15:33:30 -06:00
parent 4c4435ae2c
commit 1d5357cfc7
2 changed files with 4 additions and 3 deletions

View File

@@ -392,6 +392,7 @@ export type Effects = {
vault: {
list(): Promise<string[]>
get(opt: { key: string }): Promise<string>
set(opt: { key: string; value: string }): Promise<void>
move(opt: { fromKey: string; toKey: string }): Promise<void>
delete(opt: { key: string }): Promise<void>

View File

@@ -101,14 +101,14 @@ export const utils = <WrapperData = never, WrapperOverWrite = { const: never }>(
generator: DefaultString
}) => {
if (value) {
await effects.vaultSet({ key, value })
await effects.vault.set({ key, value })
return value
}
if (await effects.vaultList().then((x) => x.includes(key))) {
if (await effects.vault.get({ key })) {
return null
}
const newValue = getDefaultString(generator)
await effects.vaultSet({ key, value: newValue })
await effects.vault.set({ key, value: newValue })
return newValue
},
getSystemSmtp: () =>