UNPKG

2.29 kBJavaScriptView Raw
1import { __awaiter, __extends, __generator } from "tslib";
2// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3// SPDX-License-Identifier: Apache-2.0
4import { MqttOverWSProvider } from './MqttOverWSProvider';
5import { Signer, Credentials } from '@aws-amplify/core';
6var SERVICE_NAME = 'iotdevicegateway';
7var AWSIoTProvider = /** @class */ (function (_super) {
8 __extends(AWSIoTProvider, _super);
9 function AWSIoTProvider(options) {
10 if (options === void 0) { options = {}; }
11 return _super.call(this, options) || this;
12 }
13 Object.defineProperty(AWSIoTProvider.prototype, "region", {
14 get: function () {
15 return this.options['aws_pubsub_region'];
16 },
17 enumerable: true,
18 configurable: true
19 });
20 AWSIoTProvider.prototype.getProviderName = function () {
21 return 'AWSIoTProvider';
22 };
23 Object.defineProperty(AWSIoTProvider.prototype, "endpoint", {
24 get: function () {
25 var _this = this;
26 return (function () { return __awaiter(_this, void 0, void 0, function () {
27 var endpoint, serviceInfo, _a, access_key, secret_key, session_token, result;
28 return __generator(this, function (_b) {
29 switch (_b.label) {
30 case 0:
31 endpoint = this.options.aws_pubsub_endpoint;
32 serviceInfo = {
33 service: SERVICE_NAME,
34 region: this.region,
35 };
36 return [4 /*yield*/, Credentials.get()];
37 case 1:
38 _a = _b.sent(), access_key = _a.accessKeyId, secret_key = _a.secretAccessKey, session_token = _a.sessionToken;
39 result = Signer.signUrl(endpoint, { access_key: access_key, secret_key: secret_key, session_token: session_token }, serviceInfo);
40 return [2 /*return*/, result];
41 }
42 });
43 }); })();
44 },
45 enumerable: true,
46 configurable: true
47 });
48 return AWSIoTProvider;
49}(MqttOverWSProvider));
50export { AWSIoTProvider };
51//# sourceMappingURL=AWSIotProvider.js.map
\No newline at end of file