import { renameKeys , ErrorWithCause } from '@sap-cloud-sdk/util' ; import axios , { AxiosRequestConfig } from 'axios' ; import { TokenKey } from './xsuaa-service-types' ; param url returns internal export function fetchVerificationKeys ( url ) { if ( typeof url !== 'string' ) { throw Error ( 'No URL of the XUSAA service instance was provided' ) ; } const config = { url , method : 'GET' } ; return axios . request < { keys : Record < string , any > ; } > ( config ) . then ( resp => resp . data . keys . map ( k => renameKeys ( tokenKeyKeyMapping , k ) ) ) . catch ( error => { throw new ErrorWithCause ( `Failed to fetch verification keys from XSUAA service instance "${ url }".` , error ) ; } ) ; } const tokenKeyKeyMapping = { kty : 'keyType' , e : 'publicKeyExponent' , use : 'use' , kid : 'keyId' , alg : 'algorithm' , value : 'value' , n : 'publicKeyModulus' } ;