principal.ts
This file
Path
packages/protocol/src/principal.ts
33 lines · 900 bytes · TypeScript
Last changed by
Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
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 1–33why, one step back1import { Context, Schema } from "effect";2import { RpcMiddleware } from "effect/rpc";34import { Handle } from "./ids.ts";56export const Person = Schema.TaggedStruct("Person", { handle: Handle });78export type Person = typeof Person.Type;910export const Anonymous = Schema.TaggedStruct("Anonymous", {});1112export type Anonymous = typeof Anonymous.Type;1314export const Principal = Schema.Union([Person, Anonymous]).pipe(15 Schema.toTaggedUnion("_tag")16);1718export type Principal = typeof Principal.Type;1920export class CurrentPrincipal extends Context.Service<21 CurrentPrincipal,22 Principal23>()("protocol/CurrentPrincipal") {}2425export class Unauthenticated extends Schema.TaggedError<Unauthenticated>()(26 "Unauthenticated",27 {}28) {}2930export class Authenticated extends RpcMiddleware.Service<31 Authenticated,32 { provides: CurrentPrincipal }33>()("protocol/Authenticated", { error: Unauthenticated }) {}