Package-level declarations

The kotlinx.serialization backend for Ihawu masking — the write half of the engine for kotlinx.serialization, and the multiplatform one (JVM + JS). It executes the decisions the serialization-neutral ihawu-core engine makes, at kotlinx's serialization boundary.

Because kotlinx generates serializers at compile time (no per-property hook), masking works by letting a value serialize to a JsonElement and rewriting it per the engine's decision, recursing into nested @IhawuResource objects, lists, and map values through an explicit registry. See ADR 0008.

Entry point

  • maskingRegistry — build the serialName → resourceName registry from resource serializers.

  • maskingSerializer — wrap a resource serializer so it masks through the engine, recursing via the registry.

  • IhawuKotlinxJson — encode a value for a given IhawuPrincipal; a missing principal fails closed to {}.

Limitations (v1)

  • Polymorphic / sealed @IhawuResource hierarchies are not masked (their elements pass through) — a documented follow-up.

The kotlinx.serialization backend for Ihawu masking — the write half of the engine for kotlinx.serialization, and the multiplatform one (JVM + JS). It executes the decisions the serialization-neutral ihawu-core engine makes, at kotlinx's serialization boundary.

Because kotlinx generates serializers at compile time (no per-property hook), masking works by letting a value serialize to a JsonElement and rewriting it per the engine's decision, recursing into nested @IhawuResource objects, lists, and map values through an explicit registry. See ADR 0008.

Entry point

  • maskingRegistry — build the serialName → resourceName registry from resource serializers.

  • maskingSerializer — wrap a resource serializer so it masks through the engine, recursing via the registry.

  • IhawuKotlinxJson — encode a value for a given IhawuPrincipal; a missing principal fails closed to {}.

Limitations (v1)

  • Polymorphic / sealed @IhawuResource hierarchies are not masked (their elements pass through) — a documented follow-up.

Types

Link copied to clipboard

Encodes masked values with kotlinx.serialization, supplying the caller per encode.

Functions

Link copied to clipboard

A coroutine context element that installs principal's MaskingContext on whichever thread runs the (synchronous) encode — the bridge for coroutine callers such as Ktor (#82):

Link copied to clipboard
fun maskingRegistry(vararg entries: Pair<KSerializer<*>, String>): Map<String, String>

Builds the resource registry (serialName -> resourceName) that drives masking recursion, from each resource serializer and its @IhawuResource name. Register every resource type — including nested ones and collection element types — so they mask themselves when reached.

Link copied to clipboard
fun <T> maskingSerializer(delegate: KSerializer<T>, engine: MaskingEngine, registry: Map<String, String>, classDiscriminator: String = "type", serializersModule: SerializersModule = EmptySerializersModule()): KSerializer<T>

Wraps a resource serializer so it masks through engine, recursing via registry.