@aws-amplify/pubsub 6.0.1-api-v6-models.9351bcf.0 → 6.0.1-api-v6-models.891fe0d.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,56 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AWSIoT = void 0;
4
- var tslib_1 = require("tslib");
5
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
5
  // SPDX-License-Identifier: Apache-2.0
7
- var MqttOverWS_1 = require("./MqttOverWS");
8
- var utils_1 = require("@aws-amplify/core/internals/utils");
9
- var core_1 = require("@aws-amplify/core");
10
- var SERVICE_NAME = 'iotdevicegateway';
11
- var AWSIoT = /** @class */ (function (_super) {
12
- tslib_1.__extends(AWSIoT, _super);
13
- function AWSIoT(options) {
14
- if (options === void 0) { options = {}; }
15
- return _super.call(this, options) || this;
6
+ const MqttOverWS_1 = require("./MqttOverWS");
7
+ const utils_1 = require("@aws-amplify/core/internals/utils");
8
+ const core_1 = require("@aws-amplify/core");
9
+ const SERVICE_NAME = 'iotdevicegateway';
10
+ class AWSIoT extends MqttOverWS_1.MqttOverWS {
11
+ constructor(options = {}) {
12
+ super(options);
16
13
  }
17
- Object.defineProperty(AWSIoT.prototype, "region", {
18
- get: function () {
19
- var _a;
20
- return (_a = this.options) === null || _a === void 0 ? void 0 : _a.region;
21
- },
22
- enumerable: false,
23
- configurable: true
24
- });
25
- Object.defineProperty(AWSIoT.prototype, "endpoint", {
26
- get: function () {
27
- var _this = this;
28
- return (function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
29
- var endpoint, serviceInfo, session, _a, access_key, secret_key, session_token, result;
30
- return tslib_1.__generator(this, function (_b) {
31
- switch (_b.label) {
32
- case 0:
33
- endpoint = this.options.endpoint;
34
- serviceInfo = {
35
- service: SERVICE_NAME,
36
- region: this.region,
37
- };
38
- return [4 /*yield*/, (0, core_1.fetchAuthSession)()];
39
- case 1:
40
- session = _b.sent();
41
- if (!session.credentials) {
42
- throw new Error('No auth session credentials');
43
- }
44
- _a = session.credentials, access_key = _a.accessKeyId, secret_key = _a.secretAccessKey, session_token = _a.sessionToken;
45
- result = utils_1.Signer.signUrl(endpoint, { access_key: access_key, secret_key: secret_key, session_token: session_token }, serviceInfo);
46
- return [2 /*return*/, result];
47
- }
48
- });
49
- }); })();
50
- },
51
- enumerable: false,
52
- configurable: true
53
- });
54
- return AWSIoT;
55
- }(MqttOverWS_1.MqttOverWS));
14
+ get region() {
15
+ return this.options?.region;
16
+ }
17
+ get endpoint() {
18
+ return (async () => {
19
+ const endpoint = this.options.endpoint;
20
+ const serviceInfo = {
21
+ service: SERVICE_NAME,
22
+ region: this.region,
23
+ };
24
+ const session = await (0, core_1.fetchAuthSession)();
25
+ if (!session.credentials) {
26
+ throw new Error('No auth session credentials');
27
+ }
28
+ const { accessKeyId: access_key, secretAccessKey: secret_key, sessionToken: session_token, } = session.credentials;
29
+ const result = utils_1.Signer.signUrl(endpoint, { access_key, secret_key, session_token }, serviceInfo);
30
+ return result;
31
+ })();
32
+ }
33
+ }
56
34
  exports.AWSIoT = AWSIoT;
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { AbstractPubSub } from './PubSub';
3
- import { PubSubContentObserver, PubSubContent, PubSubOptions } from '../types/PubSub';
3
+ import { PubSubContentObserver, PubSubContent, PubSubOptions, PublishInput, SubscribeInput } from '../types/PubSub';
4
4
  export declare function mqttTopicMatch(filter: string, topic: string): boolean;
5
5
  export interface MqttOptions extends PubSubOptions {
6
6
  clientId?: string;
@@ -47,10 +47,12 @@ export declare class MqttOverWS extends AbstractPubSub<MqttOptions> {
47
47
  newClient({ url, clientId }: MqttOptions): Promise<PahoClient>;
48
48
  protected connect(clientId: string, options?: MqttOptions): Promise<PahoClient | undefined>;
49
49
  protected disconnect(clientId: string): Promise<void>;
50
- publish(topics: string[] | string, msg: PubSubContent): Promise<void>;
50
+ publish({ topics, message }: PublishInput): Promise<void>;
51
51
  protected _topicObservers: Map<string, Set<PubSubContentObserver>>;
52
52
  protected _clientIdObservers: Map<string, Set<PubSubContentObserver>>;
53
53
  private _onMessage;
54
- subscribe(topics: string[] | string, options?: MqttOptions): Observable<PubSubContent>;
54
+ subscribe({ topics, options, }: SubscribeInput & {
55
+ options?: MqttOptions;
56
+ }): Observable<PubSubContent>;
55
57
  }
56
58
  export {};