Enough of @agoric/store's MapStore and @endo/patterns' M for the
credential-rotation design: makeMapStore(label, { keyShape, valueShape },
kv) keeps entries in a DO's sync KV under store:<label>:, and readOnly()
hands out the queries alone. Facets are workerd RpcTargets in place of
endo's Far.
Unlike endo, error messages never include keys or values: the values
here are credentials, and messages cross RPC into logs.
Generated-by: Claude Opus 5.5
16 lines
588 B
TypeScript
16 lines
588 B
TypeScript
/** @file the tests' main module: a DO that hosts stores on its own storage. */
|
|
import { DurableObject } from "cloudflare:workers";
|
|
import { M } from "../src/patterns.js";
|
|
import { makeMapStore, type MapStore } from "../src/store.js";
|
|
|
|
/** hosts the store from the credential-rotation sketch: one key, `cookie` */
|
|
export class StoreHost extends DurableObject {
|
|
cookies(): MapStore<string> {
|
|
return makeMapStore<string>("cookie", { keyShape: "cookie", valueShape: M.string() }, this.ctx.storage.kv);
|
|
}
|
|
}
|
|
|
|
export default {
|
|
fetch: () => new Response("store tests", { status: 404 }),
|
|
};
|