import { Request } from '@hapi/hapi' ; import uuid from 'uuid' ; export function getRequestId ( request , { allowFromAnyIp , ipAllowlist } ) { const remoteAddress = request . raw . req . socket ?. remoteAddress ; return allowFromAnyIp || ( remoteAddress && ipAllowlist . includes ( remoteAddress ) ) ? request . headers [ 'x-opaque-id' ] ?? uuid . v4 ( ) : uuid . v4 ( ) ; }