import type { Cookie as ToughCookie } from 'tough-cookie' ; import type { AccessTokenData } from '../auth' ; const obfuscationLengthLimit = 20 ; const obfuscateAccessToken = ( accessToken , enabled = true ) : AccessTokenData => { if ( enabled ) { return { ... accessToken , access_token : `${ accessToken . access_token . substr ( 0 , obfuscationLengthLimit ) }...` , } ; } return accessToken ; } ; const obfuscateCookie = ( cookie , enabled = true ) : ToughCookie => { if ( enabled ) { const obfuscatedCookie = cookie . clone ( ) ; obfuscatedCookie . value = `${ cookie . value . substr ( 0 , obfuscationLengthLimit ) }...` ; return obfuscatedCookie ; } return cookie ; } ; export const ObfuscationUtil = { obfuscateAccessToken , obfuscateCookie , } ;