@kodama.page/core
v0.2.4
Published
Platform-independent Kodama Security Core — types, codecs, provider interfaces, validation.
Readme
@kodama.page/core
Platform-independent Kodama Security Core (KSC-1): types, ProtectionContext, deterministic CBOR codecs, compression policies, opaque KeyHandle, SecurityProvider interfaces, validation, stable errors, and test vectors.
Source of truth: docs/KODAMA_SECURITY_CORE.md
Product protocols must import only from this package. They must never detect browser vs Tauri vs Node.
import type { SecurityProvider } from "@kodama.page/core";
import { CompressionPolicy, createProtectionContext } from "@kodama.page/core";
export async function protect(security: SecurityProvider, plaintext: Uint8Array) {
const key = await security.keys.generateSymmetricKey("content-encryption");
const context = createProtectionContext({
productId: "note",
purpose: "content",
placeId: "place-1",
objectId: "obj-1",
schemaVersion: 1,
protocolVersion: 1,
objectVersion: 0,
epoch: 0,
});
// compression is optional (defaults to never); pass Auto/Always to opt in
return security.envelopes.create({
key,
plaintext,
context,
compression: CompressionPolicy.Auto,
});
}Platform adapters: @kodama.page/security-browser, @kodama.page/security-tauri. Architecture: ARCHITECTURE.md.
