UNPKG

@pagopa/io-spid-commons

Version:

Common code for integrating SPID authentication

20 lines (19 loc) 1.34 kB
import { Second } from "@pagopa/ts-commons/lib/units"; import { TaskEither } from "fp-ts/lib/TaskEither"; import * as t from "io-ts"; import { CacheProvider, SamlConfig } from "passport-saml"; import * as redis from "redis"; export type SAMLRequestCacheItem = t.TypeOf<typeof SAMLRequestCacheItem>; declare const SAMLRequestCacheItem: t.TypeC<{ RequestXML: t.StringC; createdAt: t.UnionC<[t.Type<Date, string, unknown>, t.Type<Date, string, unknown>]>; idpIssuer: t.StringC; }>; export interface IExtendedCacheProvider<T extends Record<string, unknown>> { readonly save: (RequestXML: string, samlConfig: SamlConfig, extraLoginRequestParams: T | undefined) => TaskEither<Error, SAMLRequestCacheItem | (SAMLRequestCacheItem & T)>; readonly get: (AuthnRequestID: string) => TaskEither<Error, SAMLRequestCacheItem | (SAMLRequestCacheItem & T)>; readonly remove: (AuthnRequestID: string) => TaskEither<Error, string>; } export declare const noopCacheProvider: () => CacheProvider; export declare const getExtendedRedisCacheProvider: <T extends Record<string, unknown> = Record<string, never>>(redisClient: redis.RedisClientType | redis.RedisClusterType, extraLoginRequestParamsCodec?: t.Type<T, T, unknown> | undefined, keyExpirationPeriodSeconds?: Second, keyPrefix?: string) => IExtendedCacheProvider<T>; export {};