/**
 * This file contains the CreatedMessageEventSenderMetadata and Notification models.
 */ import * as crypto from "crypto" ; import * as t from "io-ts" ; import { NonEmptyString } from "italia-ts-commons/lib/strings" ; import { FiscalCode } from "../../generated/backend/FiscalCode" ; /**
 * An hashed fiscal code.
 *
 * The fiscal code is used as a tag in the Notification Hub installation,
 * to avoid expose the fiscal code to a third party system we use an hash instead.
 */ const FiscalCodeHash = NonEmptyString ; type FiscalCodeHash = t . TypeOf < typeof FiscalCodeHash > ; /**
 * Compute the sha256 hash of a string.
 */ export const toFiscalCodeHash = ( fiscalCode ) : FiscalCodeHash => { const hash = crypto . createHash ( "sha256" ) ; hash . update ( fiscalCode ) ; return hash . digest ( "hex" ) as FiscalCodeHash ; } ;