UNPKG

@e280/authlocal

Version:

User-sovereign login system for everybody

36 lines 1.13 kB
import { Kv } from "@e280/kv"; import { signal } from "@benev/slate"; import { seedPack } from "../../../../trust/exports/authority.js"; export class IdentitiesDepot { kv; permits = signal([]); constructor(kv) { this.kv = kv; } async list() { const identities = await Kv.collect(this.kv.values()); this.permits.value = await Promise.all(identities.map(async (identity) => ({ identity, seed: await seedPack(identity) }))); return identities; } async #refreshAfter(fn) { const value = await fn(); await this.list(); return value; } async save(...identities) { this.#refreshAfter(async () => await this.kv.sets(...identities.map(p => [p.id, p]))); } async load(id) { return this.#refreshAfter(async () => await this.kv.require(id)); } async delete(...ids) { return this.#refreshAfter(async () => await this.kv.del(...ids)); } async wipe() { return this.#refreshAfter(async () => await this.kv.clear()); } } //# sourceMappingURL=identities.js.map