@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.
- package/lib/Providers/AWSIot.js +27 -49
- package/lib/Providers/MqttOverWS.d.ts +5 -3
- package/lib/Providers/MqttOverWS.js +196 -320
- package/lib/Providers/PubSub.d.ts +3 -4
- package/lib/Providers/PubSub.js +12 -18
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/PubSub.d.ts +11 -2
- package/lib/utils/ConnectionStateMonitor.js +51 -64
- package/lib/utils/ReachabilityMonitor/index.js +2 -2
- package/lib/utils/ReachabilityMonitor/index.native.js +4 -6
- package/lib/utils/ReconnectionMonitor.js +20 -24
- package/lib-esm/Providers/AWSIot.js +24 -47
- package/lib-esm/Providers/MqttOverWS.d.ts +5 -3
- package/lib-esm/Providers/MqttOverWS.js +186 -312
- package/lib-esm/Providers/PubSub.d.ts +3 -4
- package/lib-esm/Providers/PubSub.js +11 -18
- package/lib-esm/Providers/constants.js +10 -10
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/PubSub.d.ts +11 -2
- package/lib-esm/utils/ConnectionStateMonitor.js +49 -63
- package/lib-esm/utils/ReachabilityMonitor/index.js +1 -1
- package/lib-esm/utils/ReachabilityMonitor/index.native.js +1 -3
- package/lib-esm/utils/ReconnectionMonitor.js +19 -24
- package/package.json +6 -10
- package/src/Providers/MqttOverWS.ts +9 -7
- package/src/Providers/PubSub.ts +10 -13
- package/src/types/PubSub.ts +13 -9
package/lib/Providers/AWSIot.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
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
|
|
54
|
+
subscribe({ topics, options, }: SubscribeInput & {
|
|
55
|
+
options?: MqttOptions;
|
|
56
|
+
}): Observable<PubSubContent>;
|
|
55
57
|
}
|
|
56
58
|
export {};
|