@mindconnect/mindconnect-nodejs
Version:
NodeJS Library for Siemens Insights Hub Connectivity - TypeScript SDK for Insights Hub and Industrial IoT - Command Line Interface - Insights Hub Development Proxy (Siemens Insights Hub was formerly known as MindSphere)
54 lines • 2.57 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdvancedTokenExchangeClient = void 0;
const sdk_client_1 = require("../common/sdk-client");
class AdvancedTokenExchangeClient extends sdk_client_1.SdkClient {
constructor() {
super(...arguments);
this._baseUrl = "/api/ate/v3";
}
/**
*
* In order to access the ATE /token endpoint, extract the access token from the access_token field in the response
* from the above Technical Token Manager request and send it as Bearer token in the Authorization header of HTTP requests.
* The subject_token is provided through the technical token.
*
* @see https://developer.mindsphere.io/howto/howto-local-development.html#procedure
*
* @param {AdvancedTokenExchangeModels.AdvancedTokenExchangeRequest} request
* @returns {Promise<AdvancedTokenExchangeModels.AdvancedTokenExchangeResponse>}
*
* @memberOf AdvancedTokenExchangeClient
*/
ExchangeToken(request) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof request === "string") {
request = {
subject_token: yield this.GetToken(),
subject_token_type: "urn:ietf:params:oauth:token-type:jwt",
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
resource: request,
};
}
const result = yield this.HttpAction({
verb: "POST",
gateway: this.GetGateway(),
authorization: yield this.GetToken(),
baseUrl: `${this._baseUrl}/token`,
body: request,
});
return result;
});
}
}
exports.AdvancedTokenExchangeClient = AdvancedTokenExchangeClient;
//# sourceMappingURL=advanced-token.js.map