Security overview
Authentication and authorization.
Added in v1.0.0
Table of contents
combinators
and
Signature
export declare const and: {
<A1, A2, E2, R2>(
that: Security<A2, E2, R2>
): <E1, R1>(self: Security<A1, E1, R1>) => Security<[A1, A2], E1 | E2, R1 | R2>
<A1, E1, R1, A2, E2, R2>(self: Security<A1, E1, R1>, that: Security<A2, E2, R2>): Security<[A1, A2], E1 | E2, R1 | R2>
}
Added in v1.0.0
as
Signature
export declare const as: {
<B>(value: B): <A, E, R>(self: Security<A, E, R>) => Security<B, E, R>
<A, B, E, R>(self: Security<A, E, R>, value: B): Security<B, E, R>
}
Added in v1.0.0
asSome
Signature
export declare const asSome: <A, E, R>(self: Security<A, E, R>) => Security<Option.Option<A>, E, R>
Added in v1.0.0
map
Signature
export declare const map: {
<A, B>(f: (a: A) => B): <E, R>(self: Security<A, E, R>) => Security<B, E, R>
<A, B, E, R>(self: Security<A, E, R>, f: (a: A) => B): Security<B, E, R>
}
Added in v1.0.0
mapEffect
Signature
export declare const mapEffect: {
<A1, A2, E2, R2>(
f: (a: A1) => Effect.Effect<A2, E2, R2>
): <E1, R1>(
self: Security<A1, E1, R1>
) => Security<
A2,
E1 | Exclude<E2, HttpError.HttpError>,
R1 | Exclude<R2, HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams>
>
<A1, E1, R1, A2, E2, R2>(
self: Security<A1, E1, R1>,
f: (a: A1) => Effect.Effect<A2, E2, R2>
): Security<
A2,
E1 | Exclude<E2, HttpError.HttpError>,
R1 | Exclude<R2, HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams>
>
}
Added in v1.0.0
mapHandler
Signature
export declare const mapHandler: {
<A, B, E1, E2, R1, R2>(
f: (handler: Security.Handler<A, E1, R1>) => Security.Handler<B, E2, R2>
): (security: Security<A, E1, R1>) => Security<B, E2, R2>
<A, B, E1, E2, R1, R2>(
security: Security<A, E1, R1>,
f: (handler: Security.Handler<A, E1, R1>) => Security.Handler<B, E2, R2>
): Security<B, E2, R2>
}
Added in v1.0.0
mapSchema
Signature
export declare const mapSchema: {
<A, B>(schema: Schema.Schema<B, A>): <E, R>(self: Security<A, E, R>) => Security<B, E, R>
<A, B, E, R>(self: Security<A, E, R>, schema: Schema.Schema<B, A>): Security<B, E, R>
}
Added in v1.0.0
or
Signature
export declare const or: {
<A1, A2, E2, R2>(
that: Security<A2, E2, R2>
): <E1, R1>(self: Security<A1, E1, R1>) => Security<A1 | A2, E1 | E2, R1 | R2>
<A1, E1, R1, A2, E2, R2>(self: Security<A1, E1, R1>, that: Security<A2, E2, R2>): Security<A1 | A2, E1 | E2, R1 | R2>
}
Added in v1.0.0
constructors
apiKey
Creates basic http security
Signature
export declare const apiKey: (options: ApiKeyOptions) => Security<string>
Added in v1.0.0
basic
Creates basic http security
Signature
export declare const basic: (options?: BasicOptions) => Security<BasicCredentials>
Added in v1.0.0
bearer
Creates bearer http security
Signature
export declare const bearer: (options?: BearerOptions) => Security<string>
Added in v1.0.0
make
Signature
export declare const make: <A, E, R>(
parser: Security.Handler<A, E, R>,
openapi?: Record.ReadonlyRecord<string, unknown>
) => Security<
A,
Exclude<E, HttpError.HttpError>,
Exclude<R, HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams>
>
Added in v1.0.0
never
Creates always failing security without a security scheme
Signature
export declare const never: Security<never, never, never>
Added in v1.0.0
unit
Creates always allowing security without a security scheme
Signature
export declare const unit: Security<void, never, never>
Added in v1.0.0
getters
getOpenApi
Signature
export declare const getOpenApi: <A, E, R>(security: Security<A, E, R>) => Record.ReadonlyRecord<string, unknown>
Added in v1.0.0
handleRequest
Signature
export declare const handleRequest: <A, E, R>(security: Security<A, E, R>) => Security.Handler<A, E, R>
Added in v1.0.0
models
ApiKeyOptions (interface)
Signature
export interface ApiKeyOptions {
key: string
in: "header" | "query" // TODO: support cookie
name?: string
description?: string
}
Added in v1.0.0
BasicCredentials (interface)
Signature
export interface BasicCredentials {
user: string
pass: string
}
Added in v1.0.0
BasicOptions (interface)
Signature
export interface BasicOptions {
name?: string
description?: string
}
Added in v1.0.0
BearerOptions (interface)
Signature
export interface BearerOptions {
name?: string
description?: string
bearerFormat?: string
}
Added in v1.0.0
Security (interface)
Signature
export interface Security<A, E = never, R = never> extends Security.Variance<A, E, R>, Pipeable.Pipeable {}
Added in v1.0.0
Security (namespace)
Added in v1.0.0
Variance (interface)
Signature
export interface Variance<A, E, R> {
readonly [TypeId]: {
readonly _A: Types.Covariant<A>
readonly _E: Types.Covariant<E>
readonly _R: Types.Covariant<R>
}
}
Added in v1.0.0
Any (type alias)
Signature
export type Any = Security<any, any, any>
Added in v1.0.0
Context (type alias)
Signature
export type Context<T extends Any> = [T] extends [Security<any, any, infer R>] ? R : never
Added in v1.0.0
Default (type alias)
Signature
export type Default = Security<void, never, never>
Added in v1.0.0
Error (type alias)
Signature
export type Error<T extends Any> = [T] extends [Security<any, infer E, any>] ? E : never
Added in v1.0.0
Handler (type alias)
Signature
export type Handler<A, E, R> = Effect.Effect<
A,
E,
R | HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams
>
Added in v1.0.0
Success (type alias)
Signature
export type Success<T extends Any> = [T] extends [Security<infer A, any, any>] ? A : never
Added in v1.0.0
type id
TypeId
Signature
export declare const TypeId: typeof TypeId
Added in v1.0.0
TypeId (type alias)
Signature
export type TypeId = typeof TypeId
Added in v1.0.0