Skip to content
Myr

sessions.ts

This file

Path

apps/web/src/dev/sessions.ts

25 lines · 998 bytes · TypeScript

Last changed by

Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248

History of this file

Take it

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

Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248

lines 1–2why, one step back
1// The tokens are literal and exist only under the `development` condition, which the production build never resolves.
2// Unlike the platform, the dev world does not refuse a credential an RPC message adds to its own headers.

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–25why, one step back
3import { authenticated } from "@repo/protocol/authenticate";
4import type { Handle } from "@repo/protocol/ids";5import { Person } from "@repo/protocol/principal";6import type { Authenticated } from "@repo/protocol/principal";7import { Effect, Option } from "effect";8import type { Layer } from "effect";910import { devPeople } from "./seed.ts";1112export const devToken = (handle: Handle) => `dev-${handle}`;1314const tokens: ReadonlyMap<string, Handle> = new Map(15 devPeople.map((handle) => [devToken(handle), handle])16);1718const personOf = (token: string) =>19 Option.map(Option.fromNullishOr(tokens.get(token)), (handle) =>20 Person.make({ handle })21 );2223export const devSessions: Layer.Layer<Authenticated> = authenticated((token) =>24 Effect.succeed(personOf(token))25);