import * as xssec from '@sap/xssec' ; import { first } from '@sap-cloud-sdk/util' ; import { DestinationFetchOptions , DestinationOptions } from './destination' ; import { getServiceCredentialsList } from './environment-accessor' ; internal param options returns export async function exchangeToken ( options ) { const xsuaaServiceCredentials = first ( getServiceCredentialsList ( 'xsuaa' ) ) ; return new Promise ( ( resolve , reject ) => { xssec . createSecurityContext ( options . jwt , xsuaaServiceCredentials , ( err , context , tokenInfo ) => err ? reject ( err ) : resolve ( tokenInfo . getTokenValue ( ) ) ) ; } ) ; } internal param options returns export function isTokenExchangeEnabled ( options ) { return options . iasToXsuaaTokenExchange !== false && ! ! options . jwt ; }