Auth / foldkit-auth/server

HostConfig

interface · packages/auth/src/server.ts:194

interface HostConfig<
  I,
  S extends Sessions.SessionMetadata,
  Api extends Auth.SessionApi<S, unknown>,
  Actions extends AuthContract.AuthActions,
  User,
  R,
> {
  readonly auth: YieldedAuth<I, S, Api, Actions>
  readonly http: Omit<Http.AuthHttpOptions, 'oauth'>
  readonly services: Context.Context<I>
  readonly principal: (
    session: S,
  ) => Effect.Effect<User, RemoteUnauthenticated, R>
  readonly key?: ((user: User) => string) | undefined
}

What AuthServer.host takes.

Members

HostConfig.auth

property · packages/auth/src/server.ts:203

readonly auth: YieldedAuth<I, S, Api, Actions>

The Auth.make(…) application: its routes are mounted, its sessions verified.

HostConfig.http

property · packages/auth/src/server.ts:209

readonly http: Omit<Http.AuthHttpOptions, 'oauth'>

The options for Http.make, given to Yielded's routes and to both resolvers, so the cookie the routes set is the one the resolvers read. No oauth: its callbacks need services this does not provide.

HostConfig.services

property · packages/auth/src/server.ts:215

readonly services: Context.Context<I>

The built Auth service and what it stands on (its store, its hashing), shared by the routes and the resolvers: build them once per isolate, as a ManagedRuntime's context(), never per request.

HostConfig.principal

property · packages/auth/src/server.ts:217

readonly principal: (
  session: S,
) => Effect.Effect<User, RemoteUnauthenticated, R>

The application's principal for a verified session, read per request; it may refuse it.

HostConfig.key

property · packages/auth/src/server.ts:219

readonly key?: ((user: User) => string) | undefined

Who the principal is, for the x-foldkit-subject check and the answer's header; see ResolverConfig.