UNPKG

@sap-cloud-sdk/connectivity

Version:

SAP Cloud SDK for JavaScript connectivity

28 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.exchangeToken = exchangeToken; exports.shouldExchangeToken = shouldExchangeToken; const jwt_1 = require("./jwt"); const token_accessor_1 = require("./token-accessor"); /** * @internal * Make a token exchange from IAS token to XSUAA token. * @param options - Configuration for how to retrieve destinations from the destination service. * @returns Exchanged token. */ async function exchangeToken(jwt) { return (0, token_accessor_1.jwtBearerToken)(jwt, 'xsuaa'); } /** * @internal * Checks whether the IAS token to XSUAA token exchange should be applied. * @param options - Configuration for how to retrieve destinations from the destination service. * @returns A boolean value, that indicates whether the token exchange should be applied. */ function shouldExchangeToken(options) { // iasToXsuaaTokenExchange is optional, token exchange is disabled by default return (options.iasToXsuaaTokenExchange === true && !!options.jwt && !(0, jwt_1.isXsuaaToken)((0, jwt_1.decodeJwt)(options.jwt))); } //# sourceMappingURL=identity-service.js.map