UNPKG

@pagopa/io-spid-commons

Version:

Common code for integrating SPID authentication

40 lines (39 loc) 1.93 kB
import { NonEmptyString } from "@pagopa/ts-commons/lib/strings"; import { SPID_USER_ATTRIBUTES } from "../config"; import { EventTracker } from "../index"; import { PreValidateResponseT } from "../strategy/spid"; import { StrictResponseValidationOptions } from "./middleware"; import { TransformError } from "./samlUtils"; import { getAuthorizeRequestTamperer, getErrorCodeFromResponse, getIDFromRequest, getMetadataTamperer, getSamlIssuer, getSamlOptions, getXmlFromSamlResponse, logSamlCertExpiration, SAML_NAMESPACE } from "./samlUtils"; export { SAML_NAMESPACE, logSamlCertExpiration, getIDFromRequest, getMetadataTamperer, getXmlFromSamlResponse, getSamlOptions, getErrorCodeFromResponse, getAuthorizeRequestTamperer, getSamlIssuer, TransformError, }; export type SamlAttributeT = keyof typeof SPID_USER_ATTRIBUTES; export interface ISAMLError extends Error { readonly idpIssuer: string; readonly requestId: string; } interface IBaseOutput { readonly InResponseTo: NonEmptyString; readonly Assertion: Element; readonly IssueInstant: Date; readonly Response: Element; readonly AssertionIssueInstant: Date; } interface ISamlCacheType { readonly RequestXML: string; readonly createdAt: Date; readonly idpIssuer: string; } type IRequestAndResponseStep = IBaseOutput & { readonly SAMLRequestCache: ISamlCacheType; }; type ISAMLRequest = IRequestAndResponseStep & { readonly Request: Document; }; type IIssueInstant = ISAMLRequest & { readonly RequestIssueInstant: Date; readonly RequestAuthnRequest: Element; }; export type IIssueInstantWithAuthnContextCR = IIssueInstant & { readonly RequestAuthnContextClassRef: NonEmptyString; }; export declare const getPreValidateResponse: <T extends Record<string, unknown>>(strictValidationOptions?: StrictResponseValidationOptions, eventHandler?: EventTracker, hasClockSkewLoggingEvent?: boolean) => PreValidateResponseT<T>;