import type { RacComparison as NodeSamlRacComparison } from '@node-saml/node-saml/lib/types'; import type { Profile, SamlConfig } from '@node-saml/passport-saml'; import type { Request } from 'express'; import type { SPID_FORCED_SAML_CONFIG, SPID_LEVELS } from './const'; export type SpidLevel = keyof typeof SPID_LEVELS; export interface SpidProfile { spidCode: string; email: string; digitalAddress: string; fiscalNumber: string; name: string; familyName: string; mobilePhone: string; gender: string; dateOfBirth: Date; placeOfBirth: string; address: string; companyName: string; idCard: string; ivaCode: string; registeredOffice: string; } export type SpidAttribute = keyof SpidProfile; export interface IDPConfig extends Required> { entityId: string; } export interface ContactPerson { email: string; telephone?: string; VATNumber?: string; fiscalCode?: string; IPACode?: string; } export interface BillingContactPerson { fiscalCode?: string; VAT?: { countryId?: string; code?: string; name?: string; }; personalData: { fullName: string; title?: string; EORICode?: string; }; headquarters: { address: string; streetNumber?: string; postalCode: string; city: string; state?: string; country: string; }; email: string; company?: string; thirdPartyIntermediary?: string; } export interface ServiceProviderOrganization { url: string; displayName: string; name: string; } export interface AttributeConsumingService { name?: string; attributes: ReadonlyArray; } export interface CommonServiceProvider { type: string; entityId: string; certificate: string; acs: AttributeConsumingService[]; organization: { it: ServiceProviderOrganization; [lang: string]: ServiceProviderOrganization; }; contactPerson: ContactPerson; billingContactPerson?: BillingContactPerson; } export interface PrivateServiceProvider extends CommonServiceProvider { type: 'private'; billingContactPerson: BillingContactPerson; } export interface PublicContactPerson extends ContactPerson { IPACode: string; } export interface PublicServiceProvider extends CommonServiceProvider { type: 'public'; contactPerson: PublicContactPerson; } export type ServiceProvider = PrivateServiceProvider | PublicServiceProvider; export type SignatureAlgorithm = 'sha256' | 'sha512'; export type DigestAlgorithm = 'sha256' | 'sha512'; export type Binding = 'HTTP-Redirect' | 'HTTP-POST'; export type RacComparison = Exclude; export type ForcedSamlConfig = keyof typeof SPID_FORCED_SAML_CONFIG; export type DynamicSamlConfig = 'idpCert' | 'entryPoint' | 'logoutUrl' | 'issuer' | 'idpIssuer' | 'authnContext' | 'forceAuthn' | 'skipRequestCompression'; export type OmitSamlConfig = ForcedSamlConfig | DynamicSamlConfig; export interface StrategyOptions { name?: string; passReqToCallback?: boolean; } export interface SpidSamlConfig extends Omit { callbackUrl: string; authnRequestBinding: Binding; privateKey: string | Buffer; digestAlgorithm: DigestAlgorithm; signatureAlgorithm: SignatureAlgorithm; attributeConsumingServiceIndex: string; logoutCallbackUrl: string; racComparison: RacComparison; } export interface Cache { get(key: string): Promise | string | undefined; set(key: string, value: string): any; delete(key: string): any; expire?(key: string, ms: number): any; } export interface SpidConfig extends StrategyOptions { saml: SpidSamlConfig; spid: { serviceProvider: ServiceProvider; IDPRegistryMetadata: string; getIDPEntityIdFromRequest: (req: Request) => string | Promise; authnContext: SpidLevel; }; cache: Cache; } export interface SamlSpidProfile extends Profile { getSamlRequestXml(): string; attributes: Partial; }