Skip to content
Myr

vault.ts

This file

Path

packages/visibility/src/vault.ts

79 lines · 2.4 KiB · TypeScript

Last changed by

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 1why, one step back
1// Nobody reads a write-only value back, the maintainer and the platform's

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

line 2why, one step back
2// contracts included.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 3–7why, one step back
3import type { EnvKey } from "@repo/protocol/ids";
4import { ValueTooShort } from "@repo/protocol/refusal";5import { Context, Effect, Redacted, Schema } from "effect";67/**

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 8why, one step back
8 * The shortest value stored without the maintainer acknowledging it

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

line 9why, one step back
9 * (varlock's own threshold): masking cannot protect a shorter one, and it may

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 10–30why, one step back
10 * be guessed.
11 */12export const MIN_LENGTH = 12;1314/**15 * The shortest value stored at all, and the shortest the leak scan looks16 * for: below it a value matches ordinary text everywhere.17 */18export const HARD_MIN_LENGTH = 3;1920const Base64 = Schema.String.check(Schema.isBase64());2122export const SealedValue = Schema.Struct({23 ciphertext: Base64,24 iv: Base64,25 keyVersion: Schema.Int,26 wrappedKey: Base64,27});2829export type SealedValue = typeof SealedValue.Type;30

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

line 31why, one step back
31/** A defect, never a refusal: a stored row that will not open is the platform's fault. */

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 32–52why, one step back
32export class SealedValueUnopenable extends Schema.TaggedError<SealedValueUnopenable>()(
33 "SealedValueUnopenable",34 { step: Schema.Literals(["keyVersion", "unwrap", "decrypt"]) }35) {}3637export interface ValueToSeal {38 readonly acknowledgeShort: boolean;39 readonly key: EnvKey;40 readonly value: Redacted.Redacted;41}4243const graphemes = new Intl.Segmenter();4445/**46 * How many characters a value has, as a reader counts them (grapheme47 * clusters): an emoji or an accented letter is one, whatever its UTF-1648 * length.49 */50export const charactersIn = (value: string) =>51 [...graphemes.segment(value)].length;52

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

line 53why, one step back
53/** A refusal names the minimum, never the value or its length. */

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 54–61why, one step back
54export const admitLength = ({
55 acknowledgeShort,56 key,57 value,58}: ValueToSeal): Effect.Effect<void, ValueTooShort> => {59 const length = charactersIn(Redacted.value(value));6061 if (length < HARD_MIN_LENGTH) {

Tell stage 1 a pusher reads the layers only when they read every one, and give the no-oracle path rule one owner in the gateoscabrielbefore adoptionf9808ff

line 62why, one step back
62 return Effect.fail(ValueTooShort.belowFloor(key, HARD_MIN_LENGTH));

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 63–79why, one step back
63 }
6465 return length < MIN_LENGTH && !acknowledgeShort66 ? Effect.fail(ValueTooShort.of(key, MIN_LENGTH))67 : Effect.void;68};6970export class WriteOnlyValues extends Context.Service<71 WriteOnlyValues,72 {73 readonly put: (74 input: ValueToSeal75 ) => Effect.Effect<SealedValue, ValueTooShort>;76 /** Opens a sealed value, for a landed run only; never behind a contract. */77 readonly open: (sealed: SealedValue) => Effect.Effect<Redacted.Redacted>;78 }79>()("visibility/WriteOnlyValues") {}