@homelib/xiaomi 0.0.0-wip.01265bf1cc90
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/LICENSE +19 -0
- package/README.md +26 -0
- package/bld/library/backend/client.d.ts +73 -0
- package/bld/library/backend/client.js +490 -0
- package/bld/library/backend/client.js.map +1 -0
- package/bld/library/backend/constants.d.ts +7 -0
- package/bld/library/backend/constants.js +11 -0
- package/bld/library/backend/constants.js.map +1 -0
- package/bld/library/backend/index.d.ts +3 -0
- package/bld/library/backend/index.js +4 -0
- package/bld/library/backend/index.js.map +1 -0
- package/bld/library/backend/oauth.d.ts +24 -0
- package/bld/library/backend/oauth.js +121 -0
- package/bld/library/backend/oauth.js.map +1 -0
- package/bld/library/binding.d.ts +44 -0
- package/bld/library/binding.js +212 -0
- package/bld/library/binding.js.map +1 -0
- package/bld/library/cloud/client.d.ts +27 -0
- package/bld/library/cloud/client.js +109 -0
- package/bld/library/cloud/client.js.map +1 -0
- package/bld/library/cloud/constants.d.ts +9 -0
- package/bld/library/cloud/constants.js +11 -0
- package/bld/library/cloud/constants.js.map +1 -0
- package/bld/library/cloud/device.d.ts +84 -0
- package/bld/library/cloud/device.js +686 -0
- package/bld/library/cloud/device.js.map +1 -0
- package/bld/library/cloud/index.d.ts +5 -0
- package/bld/library/cloud/index.js +6 -0
- package/bld/library/cloud/index.js.map +1 -0
- package/bld/library/cloud/mqtt.d.ts +69 -0
- package/bld/library/cloud/mqtt.js +517 -0
- package/bld/library/cloud/mqtt.js.map +1 -0
- package/bld/library/cloud/transport.d.ts +8 -0
- package/bld/library/cloud/transport.js +34 -0
- package/bld/library/cloud/transport.js.map +1 -0
- package/bld/library/command.d.ts +6 -0
- package/bld/library/command.js +6 -0
- package/bld/library/command.js.map +1 -0
- package/bld/library/configuration.d.ts +62 -0
- package/bld/library/configuration.js +303 -0
- package/bld/library/configuration.js.map +1 -0
- package/bld/library/device.d.ts +69 -0
- package/bld/library/device.js +266 -0
- package/bld/library/device.js.map +1 -0
- package/bld/library/devices/air-conditioner.d.ts +48 -0
- package/bld/library/devices/air-conditioner.js +155 -0
- package/bld/library/devices/air-conditioner.js.map +1 -0
- package/bld/library/devices/command-effect.d.ts +35 -0
- package/bld/library/devices/command-effect.js +269 -0
- package/bld/library/devices/command-effect.js.map +1 -0
- package/bld/library/devices/dehumidifier.d.ts +41 -0
- package/bld/library/devices/dehumidifier.js +124 -0
- package/bld/library/devices/dehumidifier.js.map +1 -0
- package/bld/library/devices/fan.d.ts +37 -0
- package/bld/library/devices/fan.js +135 -0
- package/bld/library/devices/fan.js.map +1 -0
- package/bld/library/devices/index.d.ts +9 -0
- package/bld/library/devices/index.js +10 -0
- package/bld/library/devices/index.js.map +1 -0
- package/bld/library/devices/light.d.ts +22 -0
- package/bld/library/devices/light.js +112 -0
- package/bld/library/devices/light.js.map +1 -0
- package/bld/library/devices/pet-feeder.d.ts +36 -0
- package/bld/library/devices/pet-feeder.js +116 -0
- package/bld/library/devices/pet-feeder.js.map +1 -0
- package/bld/library/devices/placeholder.d.ts +3 -0
- package/bld/library/devices/placeholder.js +4 -0
- package/bld/library/devices/placeholder.js.map +1 -0
- package/bld/library/devices/temperature-humidity-sensor.d.ts +14 -0
- package/bld/library/devices/temperature-humidity-sensor.js +56 -0
- package/bld/library/devices/temperature-humidity-sensor.js.map +1 -0
- package/bld/library/devices/value-range.d.ts +2 -0
- package/bld/library/devices/value-range.js +6 -0
- package/bld/library/devices/value-range.js.map +1 -0
- package/bld/library/endpoint-connection.d.ts +168 -0
- package/bld/library/endpoint-connection.js +510 -0
- package/bld/library/endpoint-connection.js.map +1 -0
- package/bld/library/index.d.ts +26 -0
- package/bld/library/index.js +33 -0
- package/bld/library/index.js.map +1 -0
- package/bld/library/local/certificate.d.ts +31 -0
- package/bld/library/local/certificate.js +298 -0
- package/bld/library/local/certificate.js.map +1 -0
- package/bld/library/local/controller.d.ts +70 -0
- package/bld/library/local/controller.js +498 -0
- package/bld/library/local/controller.js.map +1 -0
- package/bld/library/local/discovery.d.ts +29 -0
- package/bld/library/local/discovery.js +321 -0
- package/bld/library/local/discovery.js.map +1 -0
- package/bld/library/local/index.d.ts +6 -0
- package/bld/library/local/index.js +7 -0
- package/bld/library/local/index.js.map +1 -0
- package/bld/library/local/message.d.ts +11 -0
- package/bld/library/local/message.js +128 -0
- package/bld/library/local/message.js.map +1 -0
- package/bld/library/local/mqtt.d.ts +113 -0
- package/bld/library/local/mqtt.js +1074 -0
- package/bld/library/local/mqtt.js.map +1 -0
- package/bld/library/local/routed-message-client.d.ts +49 -0
- package/bld/library/local/routed-message-client.js +326 -0
- package/bld/library/local/routed-message-client.js.map +1 -0
- package/bld/library/miot/index.d.ts +4 -0
- package/bld/library/miot/index.js +5 -0
- package/bld/library/miot/index.js.map +1 -0
- package/bld/library/miot/matcher.d.ts +84 -0
- package/bld/library/miot/matcher.js +326 -0
- package/bld/library/miot/matcher.js.map +1 -0
- package/bld/library/miot/request.d.ts +33 -0
- package/bld/library/miot/request.js +57 -0
- package/bld/library/miot/request.js.map +1 -0
- package/bld/library/miot/result.d.ts +8 -0
- package/bld/library/miot/result.js +5 -0
- package/bld/library/miot/result.js.map +1 -0
- package/bld/library/miot/spec.d.ts +96 -0
- package/bld/library/miot/spec.js +86 -0
- package/bld/library/miot/spec.js.map +1 -0
- package/bld/library/provider.d.ts +78 -0
- package/bld/library/provider.js +600 -0
- package/bld/library/provider.js.map +1 -0
- package/bld/library/session-manager.d.ts +34 -0
- package/bld/library/session-manager.js +177 -0
- package/bld/library/session-manager.js.map +1 -0
- package/bld/library/session.d.ts +36 -0
- package/bld/library/session.js +370 -0
- package/bld/library/session.js.map +1 -0
- package/bld/library/storage.d.ts +2 -0
- package/bld/library/storage.js +66 -0
- package/bld/library/storage.js.map +1 -0
- package/bld/library/terminal/bindings.d.ts +3 -0
- package/bld/library/terminal/bindings.js +306 -0
- package/bld/library/terminal/bindings.js.map +1 -0
- package/bld/library/terminal/index.d.ts +2 -0
- package/bld/library/terminal/index.js +3 -0
- package/bld/library/terminal/index.js.map +1 -0
- package/bld/library/terminal/provider-details.d.ts +3 -0
- package/bld/library/terminal/provider-details.js +477 -0
- package/bld/library/terminal/provider-details.js.map +1 -0
- package/package.json +29 -0
- package/src/library/backend/client.ts +737 -0
- package/src/library/backend/constants.ts +17 -0
- package/src/library/backend/index.ts +3 -0
- package/src/library/backend/oauth.ts +170 -0
- package/src/library/binding.ts +387 -0
- package/src/library/cloud/client.ts +155 -0
- package/src/library/cloud/constants.ts +19 -0
- package/src/library/cloud/device.ts +938 -0
- package/src/library/cloud/index.ts +5 -0
- package/src/library/cloud/mqtt.ts +671 -0
- package/src/library/cloud/transport.ts +46 -0
- package/src/library/command.ts +7 -0
- package/src/library/configuration.ts +480 -0
- package/src/library/device.ts +601 -0
- package/src/library/devices/air-conditioner.ts +171 -0
- package/src/library/devices/command-effect.ts +425 -0
- package/src/library/devices/dehumidifier.ts +131 -0
- package/src/library/devices/fan.ts +140 -0
- package/src/library/devices/index.ts +9 -0
- package/src/library/devices/light.ts +119 -0
- package/src/library/devices/pet-feeder.ts +129 -0
- package/src/library/devices/placeholder.ts +3 -0
- package/src/library/devices/temperature-humidity-sensor.ts +49 -0
- package/src/library/devices/value-range.ts +14 -0
- package/src/library/endpoint-connection.ts +841 -0
- package/src/library/index.ts +71 -0
- package/src/library/local/certificate.ts +401 -0
- package/src/library/local/controller.ts +693 -0
- package/src/library/local/discovery.ts +485 -0
- package/src/library/local/index.ts +6 -0
- package/src/library/local/message.ts +174 -0
- package/src/library/local/mqtt.ts +1555 -0
- package/src/library/local/routed-message-client.ts +377 -0
- package/src/library/miot/index.ts +4 -0
- package/src/library/miot/matcher.ts +683 -0
- package/src/library/miot/request.ts +70 -0
- package/src/library/miot/result.ts +14 -0
- package/src/library/miot/spec.ts +114 -0
- package/src/library/provider.ts +745 -0
- package/src/library/session-manager.ts +224 -0
- package/src/library/session.ts +528 -0
- package/src/library/storage.ts +83 -0
- package/src/library/terminal/bindings.tsx +692 -0
- package/src/library/terminal/index.ts +2 -0
- package/src/library/terminal/provider-details.tsx +871 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type Device, type DeviceConstructor, type EndpointConnectionBindingPlan, type EndpointReference, Provider } from '@homelib/core';
|
|
2
|
+
import { MiotProviderConfiguration } from './configuration.js';
|
|
3
|
+
import { type MiotEndpointConnection, MiotEndpointConnectionMetadata } from './endpoint-connection.js';
|
|
4
|
+
export declare const MIOT_NAMESPACE = "miot";
|
|
5
|
+
export declare class MiotProvider extends Provider<MiotEndpointConnectionMetadata> {
|
|
6
|
+
readonly EndpointConnectionMetadata: import("x-value").RefinedType<import("x-value").ObjectType<{
|
|
7
|
+
device: import("x-value").ObjectType<{
|
|
8
|
+
did: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
9
|
+
model: import("x-value").OptionalType<import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>>;
|
|
10
|
+
urn: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
11
|
+
}>;
|
|
12
|
+
resources: import("x-value").ArrayType<import("x-value").ObjectType<{
|
|
13
|
+
service: import("x-value").ObjectType<{
|
|
14
|
+
iid: import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>;
|
|
15
|
+
type: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
16
|
+
description: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
17
|
+
properties: import("x-value").OptionalType<import("x-value").ArrayType<import("x-value").ObjectType<{
|
|
18
|
+
iid: import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>;
|
|
19
|
+
type: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
20
|
+
description: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
21
|
+
format: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
22
|
+
access: import("x-value").ArrayType<import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>>;
|
|
23
|
+
unit: import("x-value").OptionalType<import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>>;
|
|
24
|
+
'value-range': import("x-value").OptionalType<import("x-value").TupleType<[import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>, import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>, import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>]>>;
|
|
25
|
+
'value-list': import("x-value").OptionalType<import("x-value").ArrayType<import("x-value").ObjectType<{
|
|
26
|
+
value: import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>;
|
|
27
|
+
description: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
28
|
+
}>>>;
|
|
29
|
+
}>>>;
|
|
30
|
+
actions: import("x-value").OptionalType<import("x-value").ArrayType<import("x-value").ObjectType<{
|
|
31
|
+
iid: import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>;
|
|
32
|
+
type: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
33
|
+
description: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
34
|
+
in: import("x-value").ArrayType<import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>>;
|
|
35
|
+
out: import("x-value").ArrayType<import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>>;
|
|
36
|
+
}>>>;
|
|
37
|
+
}>;
|
|
38
|
+
}>>;
|
|
39
|
+
}>, never, unknown, false>;
|
|
40
|
+
readonly configuration: MiotProviderConfiguration;
|
|
41
|
+
private accessor endpointConnectionValues;
|
|
42
|
+
private readonly endpointConnectionSubscriptionMap;
|
|
43
|
+
private readonly endpointConnectionRuntimeMap;
|
|
44
|
+
private endpointConnectionCreationCount;
|
|
45
|
+
private endpointConnectionDisposalCount;
|
|
46
|
+
private cloudPromise;
|
|
47
|
+
private cloudValue;
|
|
48
|
+
private readonly discoveryBackendClientSet;
|
|
49
|
+
private authorizationInProgress;
|
|
50
|
+
private authorization;
|
|
51
|
+
private authorizationSetupPromise;
|
|
52
|
+
private authorizationGeneration;
|
|
53
|
+
private forgetAuthorizationPromise;
|
|
54
|
+
private readonly sessionPath;
|
|
55
|
+
private readonly oauthUuidPath;
|
|
56
|
+
private readonly localCertificateDirectory;
|
|
57
|
+
private readonly providerDirectory;
|
|
58
|
+
private readonly sessionManager;
|
|
59
|
+
constructor(name: string);
|
|
60
|
+
get endpointConnections(): readonly MiotEndpointConnection<never>[];
|
|
61
|
+
protected createEndpointConnectionBindingPlanFromMetadata(endpoint: EndpointReference, deviceConstructors: readonly DeviceConstructor<Device>[], metadata: MiotEndpointConnectionMetadata): EndpointConnectionBindingPlan;
|
|
62
|
+
private createEndpointConnectionBinding;
|
|
63
|
+
private getCloud;
|
|
64
|
+
private createCloud;
|
|
65
|
+
private loadLocalControllerDiscovery;
|
|
66
|
+
private discoverConfigurationDevices;
|
|
67
|
+
private beginConfigurationAuthorization;
|
|
68
|
+
private forgetConfigurationAuthorization;
|
|
69
|
+
private performForgetConfigurationAuthorization;
|
|
70
|
+
private completeForgetConfigurationAuthorization;
|
|
71
|
+
private assertAuthorizationGeneration;
|
|
72
|
+
private subscribeEndpointConnection;
|
|
73
|
+
private disposeEndpointConnection;
|
|
74
|
+
private disposeCloudIfUnused;
|
|
75
|
+
private addEndpointConnection;
|
|
76
|
+
private removeEndpointConnection;
|
|
77
|
+
}
|
|
78
|
+
export declare const $xiaomi: import("@homelib/core").ExtendedConstructorWithNameParameter<[], MiotProvider>;
|
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { rm } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { $constructor, ExponentialBackoff, Provider, getEnvironmentDirectory, register, uniqueName, } from '@homelib/core';
|
|
5
|
+
import { action, observable } from 'mobx';
|
|
6
|
+
import { BackendClient } from './backend/index.js';
|
|
7
|
+
import { CloudClient, CloudMqttClient, MiotEndpointConnectionCloudTransport, } from './cloud/index.js';
|
|
8
|
+
import { MiotProviderConfiguration, } from './configuration.js';
|
|
9
|
+
import { createMiotDeviceEndpointConnectionBinding, getMiotEndpointConnectionConstructor, resolveMiotEndpointConnectionMetadata, } from './device.js';
|
|
10
|
+
import { MiotEndpointConnectionMetadata, getMiotEndpointConnectionResourceKeys, normalizeMiotEndpointConnectionMetadata, } from './endpoint-connection.js';
|
|
11
|
+
import { LocalController, RoutedDeviceMessageClient, } from './local/index.js';
|
|
12
|
+
import { OAuthSessionManager } from './session-manager.js';
|
|
13
|
+
import { OAuthSessionMissingError, beginOAuthSessionAuthorization, } from './session.js';
|
|
14
|
+
export const MIOT_NAMESPACE = 'miot';
|
|
15
|
+
let MiotProvider = (() => {
|
|
16
|
+
var _a, _MiotProvider_endpointConnectionValues_accessor_storage;
|
|
17
|
+
var _b;
|
|
18
|
+
let _classSuper = Provider;
|
|
19
|
+
let _instanceExtraInitializers = [];
|
|
20
|
+
let _endpointConnectionValues_decorators;
|
|
21
|
+
let _endpointConnectionValues_initializers = [];
|
|
22
|
+
let _endpointConnectionValues_extraInitializers = [];
|
|
23
|
+
let _addEndpointConnection_decorators;
|
|
24
|
+
let _removeEndpointConnection_decorators;
|
|
25
|
+
return _a = class MiotProvider extends _classSuper {
|
|
26
|
+
get endpointConnectionValues() { return __classPrivateFieldGet(this, _MiotProvider_endpointConnectionValues_accessor_storage, "f"); }
|
|
27
|
+
set endpointConnectionValues(value) { __classPrivateFieldSet(this, _MiotProvider_endpointConnectionValues_accessor_storage, value, "f"); }
|
|
28
|
+
constructor(name) {
|
|
29
|
+
super(name);
|
|
30
|
+
Object.defineProperty(this, "EndpointConnectionMetadata", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: (__runInitializers(this, _instanceExtraInitializers), MiotEndpointConnectionMetadata)
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(this, "configuration", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
_MiotProvider_endpointConnectionValues_accessor_storage.set(this, __runInitializers(this, _endpointConnectionValues_initializers, []));
|
|
43
|
+
Object.defineProperty(this, "endpointConnectionSubscriptionMap", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: (__runInitializers(this, _endpointConnectionValues_extraInitializers), new Map())
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(this, "endpointConnectionRuntimeMap", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: new Map()
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(this, "endpointConnectionCreationCount", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: 0
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(this, "endpointConnectionDisposalCount", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true,
|
|
65
|
+
value: 0
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(this, "cloudPromise", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true,
|
|
71
|
+
value: void 0
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(this, "cloudValue", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
value: void 0
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(this, "discoveryBackendClientSet", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: new Set()
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(this, "authorizationInProgress", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
configurable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
value: false
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(this, "authorization", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
configurable: true,
|
|
94
|
+
writable: true,
|
|
95
|
+
value: void 0
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(this, "authorizationSetupPromise", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: void 0
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(this, "authorizationGeneration", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: 0
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(this, "forgetAuthorizationPromise", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
configurable: true,
|
|
112
|
+
writable: true,
|
|
113
|
+
value: void 0
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(this, "sessionPath", {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
configurable: true,
|
|
118
|
+
writable: true,
|
|
119
|
+
value: void 0
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(this, "oauthUuidPath", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
configurable: true,
|
|
124
|
+
writable: true,
|
|
125
|
+
value: void 0
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(this, "localCertificateDirectory", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
configurable: true,
|
|
130
|
+
writable: true,
|
|
131
|
+
value: void 0
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(this, "providerDirectory", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
writable: true,
|
|
137
|
+
value: void 0
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(this, "sessionManager", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
configurable: true,
|
|
142
|
+
writable: true,
|
|
143
|
+
value: void 0
|
|
144
|
+
});
|
|
145
|
+
const environmentDirectory = getEnvironmentDirectory();
|
|
146
|
+
this.providerDirectory = join(environmentDirectory, 'providers', MIOT_NAMESPACE);
|
|
147
|
+
this.sessionPath = join(this.providerDirectory, `${name}.json`);
|
|
148
|
+
this.oauthUuidPath = join(this.providerDirectory, 'identity', `${name}.json`);
|
|
149
|
+
this.localCertificateDirectory = join(this.providerDirectory, 'certificates', name);
|
|
150
|
+
this.sessionManager = new OAuthSessionManager({
|
|
151
|
+
sessionPath: this.sessionPath,
|
|
152
|
+
applyAccessToken: accessToken => {
|
|
153
|
+
var _b;
|
|
154
|
+
(_b = this.cloudValue) === null || _b === void 0 ? void 0 : _b.client.updateAccessToken(accessToken);
|
|
155
|
+
for (const backendClient of this.discoveryBackendClientSet) {
|
|
156
|
+
backendClient.updateAccessToken(accessToken);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
this.configuration = new MiotProviderConfiguration({
|
|
161
|
+
providerName: name,
|
|
162
|
+
environmentDirectory,
|
|
163
|
+
dependencies: {
|
|
164
|
+
discoverDevices: () => this.discoverConfigurationDevices(),
|
|
165
|
+
beginAuthorization: cloudServer => this.beginConfigurationAuthorization(cloudServer),
|
|
166
|
+
forgetAuthorization: () => this.forgetConfigurationAuthorization(),
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
get endpointConnections() {
|
|
171
|
+
return this.endpointConnectionValues;
|
|
172
|
+
}
|
|
173
|
+
createEndpointConnectionBindingPlanFromMetadata(endpoint, deviceConstructors, metadata) {
|
|
174
|
+
const Connection = getMiotEndpointConnectionConstructor(deviceConstructors, endpoint);
|
|
175
|
+
if (Connection === undefined) {
|
|
176
|
+
throw new TypeError('Unsupported MIoT endpoint.');
|
|
177
|
+
}
|
|
178
|
+
const normalizedMetadata = normalizeMiotEndpointConnectionMetadata(metadata);
|
|
179
|
+
const resolvedMetadata = resolveMiotEndpointConnectionMetadata(Connection, normalizedMetadata);
|
|
180
|
+
return {
|
|
181
|
+
resourceKeys: getMiotEndpointConnectionResourceKeys(normalizedMetadata),
|
|
182
|
+
create: () => this.createEndpointConnectionBinding(Connection, endpoint, resolvedMetadata),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
async createEndpointConnectionBinding(Connection, endpoint, metadata) {
|
|
186
|
+
this.endpointConnectionCreationCount++;
|
|
187
|
+
let cloud;
|
|
188
|
+
let outcome;
|
|
189
|
+
try {
|
|
190
|
+
cloud = await this.getCloud();
|
|
191
|
+
await cloud.client.connect();
|
|
192
|
+
const { connection, binding } = createMiotDeviceEndpointConnectionBinding(Connection, this, endpoint, metadata, [cloud.localController, cloud.transport], value => this.disposeEndpointConnection(value));
|
|
193
|
+
const stateProperties = connection.stateProperties;
|
|
194
|
+
const runtime = {
|
|
195
|
+
active: true,
|
|
196
|
+
backoff: new ExponentialBackoff(1000, 60000),
|
|
197
|
+
};
|
|
198
|
+
this.addEndpointConnection(connection);
|
|
199
|
+
this.endpointConnectionRuntimeMap.set(connection, runtime);
|
|
200
|
+
const subscriptionPromise = this.subscribeEndpointConnection(connection, stateProperties, cloud.client, runtime);
|
|
201
|
+
runtime.subscriptionPromise = subscriptionPromise;
|
|
202
|
+
void subscriptionPromise.catch(console.error);
|
|
203
|
+
outcome = { type: 'success', binding };
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
outcome = { type: 'error', error };
|
|
207
|
+
}
|
|
208
|
+
this.endpointConnectionCreationCount--;
|
|
209
|
+
if (outcome.type === 'success') {
|
|
210
|
+
return outcome.binding;
|
|
211
|
+
}
|
|
212
|
+
const errors = [outcome.error];
|
|
213
|
+
if (cloud !== undefined) {
|
|
214
|
+
try {
|
|
215
|
+
await this.disposeCloudIfUnused(cloud);
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
errors.push(error);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (errors.length === 1) {
|
|
222
|
+
throw errors[0];
|
|
223
|
+
}
|
|
224
|
+
throw new AggregateError(errors, 'Failed to create MIoT connection.');
|
|
225
|
+
}
|
|
226
|
+
getCloud() {
|
|
227
|
+
if (this.authorizationInProgress) {
|
|
228
|
+
throw new Error('Cannot start MIoT connections while authorization is in progress.');
|
|
229
|
+
}
|
|
230
|
+
let cloudPromise = this.cloudPromise;
|
|
231
|
+
if (cloudPromise === undefined) {
|
|
232
|
+
cloudPromise = this.createCloud();
|
|
233
|
+
this.cloudPromise = cloudPromise;
|
|
234
|
+
void cloudPromise.catch(() => {
|
|
235
|
+
if (this.cloudPromise === cloudPromise) {
|
|
236
|
+
this.cloudPromise = undefined;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return cloudPromise;
|
|
241
|
+
}
|
|
242
|
+
async createCloud() {
|
|
243
|
+
const authorizationGeneration = this.authorizationGeneration;
|
|
244
|
+
const session = await this.sessionManager.getSession();
|
|
245
|
+
this.assertAuthorizationGeneration(authorizationGeneration);
|
|
246
|
+
const backendClient = createBackendClient(session);
|
|
247
|
+
const localController = new LocalController({
|
|
248
|
+
session,
|
|
249
|
+
backendClient,
|
|
250
|
+
certificateDirectory: this.localCertificateDirectory,
|
|
251
|
+
loadDiscovery: () => this.loadLocalControllerDiscovery(),
|
|
252
|
+
});
|
|
253
|
+
const cloudMqttClient = new CloudMqttClient({
|
|
254
|
+
uuid: backendClient.uuid,
|
|
255
|
+
accessToken: backendClient.accessToken,
|
|
256
|
+
cloudServer: backendClient.cloudServer,
|
|
257
|
+
});
|
|
258
|
+
const messageClient = new RoutedDeviceMessageClient(cloudMqttClient, localController);
|
|
259
|
+
const cloud = {
|
|
260
|
+
client: new CloudClient(backendClient, messageClient, localController),
|
|
261
|
+
localController,
|
|
262
|
+
transport: new MiotEndpointConnectionCloudTransport(backendClient),
|
|
263
|
+
};
|
|
264
|
+
this.cloudValue = cloud;
|
|
265
|
+
return cloud;
|
|
266
|
+
}
|
|
267
|
+
async loadLocalControllerDiscovery() {
|
|
268
|
+
const discovery = await this.configuration.discoverDevices();
|
|
269
|
+
if (discovery === undefined || discovery.account.userId === null) {
|
|
270
|
+
return { candidates: [] };
|
|
271
|
+
}
|
|
272
|
+
const candidates = discovery.devices.flatMap(device => {
|
|
273
|
+
if (device.source !== 'owned' ||
|
|
274
|
+
device.homeId === undefined ||
|
|
275
|
+
device.homeName === undefined ||
|
|
276
|
+
!isCentralGatewayCandidateModel(device.model) ||
|
|
277
|
+
!isUnsignedDecimal(device.did)) {
|
|
278
|
+
return [];
|
|
279
|
+
}
|
|
280
|
+
return [
|
|
281
|
+
{
|
|
282
|
+
did: device.did,
|
|
283
|
+
homeId: device.homeId,
|
|
284
|
+
homeName: device.homeName,
|
|
285
|
+
},
|
|
286
|
+
];
|
|
287
|
+
});
|
|
288
|
+
return { userId: discovery.account.userId, candidates };
|
|
289
|
+
}
|
|
290
|
+
async discoverConfigurationDevices() {
|
|
291
|
+
var _b;
|
|
292
|
+
if (this.authorizationInProgress) {
|
|
293
|
+
throw new Error('Cannot discover MIoT devices while authorization is in progress.');
|
|
294
|
+
}
|
|
295
|
+
const authorizationGeneration = this.authorizationGeneration;
|
|
296
|
+
let session;
|
|
297
|
+
try {
|
|
298
|
+
session = await this.sessionManager.getSession();
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
if (error instanceof OAuthSessionMissingError) {
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
this.assertAuthorizationGeneration(authorizationGeneration);
|
|
307
|
+
const backendClient = createBackendClient(session);
|
|
308
|
+
this.discoveryBackendClientSet.add(backendClient);
|
|
309
|
+
let discovery;
|
|
310
|
+
try {
|
|
311
|
+
discovery = await backendClient.discoverDevices();
|
|
312
|
+
}
|
|
313
|
+
finally {
|
|
314
|
+
this.discoveryBackendClientSet.delete(backendClient);
|
|
315
|
+
}
|
|
316
|
+
this.assertAuthorizationGeneration(authorizationGeneration);
|
|
317
|
+
return {
|
|
318
|
+
account: {
|
|
319
|
+
cloudServer: session.cloudServer,
|
|
320
|
+
userId: (_b = discovery.userId) !== null && _b !== void 0 ? _b : null,
|
|
321
|
+
},
|
|
322
|
+
homes: discovery.homes,
|
|
323
|
+
devices: discovery.devices,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
async beginConfigurationAuthorization(cloudServer) {
|
|
327
|
+
if (this.authorizationInProgress) {
|
|
328
|
+
throw new Error('MIoT provider authorization is already in progress.');
|
|
329
|
+
}
|
|
330
|
+
else if (this.cloudPromise !== undefined ||
|
|
331
|
+
this.endpointConnectionValues.length > 0) {
|
|
332
|
+
throw new Error('Cannot authorize a MIoT provider after its connections have started.');
|
|
333
|
+
}
|
|
334
|
+
const generation = ++this.authorizationGeneration;
|
|
335
|
+
this.authorizationInProgress = true;
|
|
336
|
+
let authorization;
|
|
337
|
+
try {
|
|
338
|
+
await this.sessionManager.reset();
|
|
339
|
+
if (this.authorizationGeneration !== generation) {
|
|
340
|
+
throw new Error('MIoT provider authorization was cancelled.');
|
|
341
|
+
}
|
|
342
|
+
const setupPromise = beginOAuthSessionAuthorization({
|
|
343
|
+
sessionPath: this.sessionPath,
|
|
344
|
+
uuidPath: this.oauthUuidPath,
|
|
345
|
+
cloudServer,
|
|
346
|
+
});
|
|
347
|
+
this.authorizationSetupPromise = setupPromise;
|
|
348
|
+
try {
|
|
349
|
+
authorization = await setupPromise;
|
|
350
|
+
}
|
|
351
|
+
finally {
|
|
352
|
+
if (this.authorizationSetupPromise === setupPromise) {
|
|
353
|
+
this.authorizationSetupPromise = undefined;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (this.authorizationGeneration !== generation) {
|
|
357
|
+
await authorization.cancel();
|
|
358
|
+
throw new Error('MIoT provider authorization was cancelled.');
|
|
359
|
+
}
|
|
360
|
+
this.authorization = authorization;
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
if (this.authorizationGeneration === generation) {
|
|
364
|
+
this.authorizationInProgress = false;
|
|
365
|
+
}
|
|
366
|
+
throw error;
|
|
367
|
+
}
|
|
368
|
+
const completion = (async () => {
|
|
369
|
+
try {
|
|
370
|
+
const session = await authorization.wait();
|
|
371
|
+
if (this.authorization === authorization) {
|
|
372
|
+
this.sessionManager.useSession(session);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
finally {
|
|
376
|
+
if (this.authorization === authorization) {
|
|
377
|
+
this.authorization = undefined;
|
|
378
|
+
this.authorizationInProgress = false;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
})();
|
|
382
|
+
void completion.catch(() => undefined);
|
|
383
|
+
return {
|
|
384
|
+
url: authorization.url,
|
|
385
|
+
wait: () => completion,
|
|
386
|
+
submitCallbackUrl: callbackUrl => authorization.submitCallbackUrl(callbackUrl),
|
|
387
|
+
cancel: () => authorization.cancel(),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
forgetConfigurationAuthorization() {
|
|
391
|
+
if (this.cloudPromise !== undefined ||
|
|
392
|
+
this.endpointConnectionValues.length > 0) {
|
|
393
|
+
throw new Error('Cannot forget a MIoT provider after its connections have started.');
|
|
394
|
+
}
|
|
395
|
+
let forgetPromise = this.forgetAuthorizationPromise;
|
|
396
|
+
if (forgetPromise === undefined) {
|
|
397
|
+
const newForgetPromise = this.performForgetConfigurationAuthorization();
|
|
398
|
+
forgetPromise = newForgetPromise;
|
|
399
|
+
this.forgetAuthorizationPromise = newForgetPromise;
|
|
400
|
+
void newForgetPromise.then(() => {
|
|
401
|
+
this.completeForgetConfigurationAuthorization(newForgetPromise);
|
|
402
|
+
}, () => {
|
|
403
|
+
this.completeForgetConfigurationAuthorization(newForgetPromise);
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
return forgetPromise;
|
|
407
|
+
}
|
|
408
|
+
async performForgetConfigurationAuthorization() {
|
|
409
|
+
const generation = ++this.authorizationGeneration;
|
|
410
|
+
let authorization = this.authorization;
|
|
411
|
+
const authorizationSetupPromise = this.authorizationSetupPromise;
|
|
412
|
+
this.authorization = undefined;
|
|
413
|
+
this.authorizationInProgress = true;
|
|
414
|
+
try {
|
|
415
|
+
await this.sessionManager.reset();
|
|
416
|
+
if (authorization === undefined &&
|
|
417
|
+
authorizationSetupPromise !== undefined) {
|
|
418
|
+
authorization = await authorizationSetupPromise.catch(() => undefined);
|
|
419
|
+
}
|
|
420
|
+
if (authorization !== undefined) {
|
|
421
|
+
await authorization.cancel();
|
|
422
|
+
await authorization.wait().catch(() => undefined);
|
|
423
|
+
await this.sessionManager.reset();
|
|
424
|
+
}
|
|
425
|
+
await rm(this.sessionPath, { force: true });
|
|
426
|
+
await rm(this.localCertificateDirectory, {
|
|
427
|
+
recursive: true,
|
|
428
|
+
force: true,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
finally {
|
|
432
|
+
if (this.authorizationGeneration === generation) {
|
|
433
|
+
this.authorizationInProgress = false;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
completeForgetConfigurationAuthorization(forgetPromise) {
|
|
438
|
+
if (this.forgetAuthorizationPromise === forgetPromise) {
|
|
439
|
+
this.forgetAuthorizationPromise = undefined;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
assertAuthorizationGeneration(generation) {
|
|
443
|
+
if (this.authorizationInProgress ||
|
|
444
|
+
this.authorizationGeneration !== generation) {
|
|
445
|
+
throw new Error('MIoT provider authorization changed during operation.');
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
async subscribeEndpointConnection(connection, properties, cloudClient, runtime) {
|
|
449
|
+
while (runtime.active) {
|
|
450
|
+
try {
|
|
451
|
+
const subscription = await cloudClient.subscribeDevice(connection.metadata.device.did, properties, {
|
|
452
|
+
onStateChanged: state => {
|
|
453
|
+
connection.handleStateUpdate(state);
|
|
454
|
+
},
|
|
455
|
+
onPropertyChanged: update => {
|
|
456
|
+
connection.handlePropertyUpdate(update);
|
|
457
|
+
},
|
|
458
|
+
onError: console.error,
|
|
459
|
+
});
|
|
460
|
+
if (!runtime.active) {
|
|
461
|
+
await subscription.dispose();
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
this.endpointConnectionSubscriptionMap.set(connection, subscription);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
catch (error) {
|
|
468
|
+
if (!runtime.active) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
console.error(error);
|
|
472
|
+
await runtime.backoff;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
async disposeEndpointConnection(connection) {
|
|
477
|
+
const runtime = this.endpointConnectionRuntimeMap.get(connection);
|
|
478
|
+
if (runtime === undefined) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
this.endpointConnectionDisposalCount++;
|
|
482
|
+
runtime.active = false;
|
|
483
|
+
runtime.backoff.reset();
|
|
484
|
+
const errors = [];
|
|
485
|
+
try {
|
|
486
|
+
await runtime.subscriptionPromise;
|
|
487
|
+
}
|
|
488
|
+
catch (error) {
|
|
489
|
+
errors.push(error);
|
|
490
|
+
}
|
|
491
|
+
const subscription = this.endpointConnectionSubscriptionMap.get(connection);
|
|
492
|
+
this.endpointConnectionSubscriptionMap.delete(connection);
|
|
493
|
+
try {
|
|
494
|
+
await (subscription === null || subscription === void 0 ? void 0 : subscription.dispose());
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
errors.push(error);
|
|
498
|
+
}
|
|
499
|
+
this.endpointConnectionRuntimeMap.delete(connection);
|
|
500
|
+
try {
|
|
501
|
+
this.removeEndpointConnection(connection);
|
|
502
|
+
}
|
|
503
|
+
catch (error) {
|
|
504
|
+
errors.push(error);
|
|
505
|
+
}
|
|
506
|
+
this.endpointConnectionDisposalCount--;
|
|
507
|
+
try {
|
|
508
|
+
await this.disposeCloudIfUnused();
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
errors.push(error);
|
|
512
|
+
}
|
|
513
|
+
if (errors.length === 1) {
|
|
514
|
+
throw errors[0];
|
|
515
|
+
}
|
|
516
|
+
else if (errors.length > 1) {
|
|
517
|
+
throw new AggregateError(errors, 'Failed to dispose MIoT connection.');
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
async disposeCloudIfUnused(expectedCloud) {
|
|
521
|
+
if (this.endpointConnectionCreationCount > 0 ||
|
|
522
|
+
this.endpointConnectionDisposalCount > 0 ||
|
|
523
|
+
this.endpointConnectionRuntimeMap.size > 0 ||
|
|
524
|
+
(expectedCloud !== undefined && this.cloudValue !== expectedCloud)) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const cloud = this.cloudValue;
|
|
528
|
+
this.cloudValue = undefined;
|
|
529
|
+
this.cloudPromise = undefined;
|
|
530
|
+
const errors = [];
|
|
531
|
+
try {
|
|
532
|
+
await (cloud === null || cloud === void 0 ? void 0 : cloud.client.disconnect());
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
errors.push(error);
|
|
536
|
+
}
|
|
537
|
+
if (this.endpointConnectionCreationCount === 0 &&
|
|
538
|
+
this.endpointConnectionDisposalCount === 0 &&
|
|
539
|
+
this.endpointConnectionRuntimeMap.size === 0 &&
|
|
540
|
+
this.cloudValue === undefined &&
|
|
541
|
+
this.cloudPromise === undefined) {
|
|
542
|
+
try {
|
|
543
|
+
await this.sessionManager.reset();
|
|
544
|
+
}
|
|
545
|
+
catch (error) {
|
|
546
|
+
errors.push(error);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (errors.length === 1) {
|
|
550
|
+
throw errors[0];
|
|
551
|
+
}
|
|
552
|
+
else if (errors.length > 1) {
|
|
553
|
+
throw new AggregateError(errors, 'Failed to dispose MIoT cloud.');
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
addEndpointConnection(connection) {
|
|
557
|
+
this.endpointConnectionValues.push(connection);
|
|
558
|
+
}
|
|
559
|
+
removeEndpointConnection(connection) {
|
|
560
|
+
const index = this.endpointConnectionValues.indexOf(connection);
|
|
561
|
+
if (index >= 0) {
|
|
562
|
+
this.endpointConnectionValues.splice(index, 1);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
_MiotProvider_endpointConnectionValues_accessor_storage = new WeakMap(),
|
|
567
|
+
(() => {
|
|
568
|
+
var _b;
|
|
569
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
570
|
+
_endpointConnectionValues_decorators = [(_b = observable).shallow.bind(_b)];
|
|
571
|
+
_addEndpointConnection_decorators = [action];
|
|
572
|
+
_removeEndpointConnection_decorators = [action];
|
|
573
|
+
__esDecorate(_a, null, _endpointConnectionValues_decorators, { kind: "accessor", name: "endpointConnectionValues", static: false, private: false, access: { has: obj => "endpointConnectionValues" in obj, get: obj => obj.endpointConnectionValues, set: (obj, value) => { obj.endpointConnectionValues = value; } }, metadata: _metadata }, _endpointConnectionValues_initializers, _endpointConnectionValues_extraInitializers);
|
|
574
|
+
__esDecorate(_a, null, _addEndpointConnection_decorators, { kind: "method", name: "addEndpointConnection", static: false, private: false, access: { has: obj => "addEndpointConnection" in obj, get: obj => obj.addEndpointConnection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
575
|
+
__esDecorate(_a, null, _removeEndpointConnection_decorators, { kind: "method", name: "removeEndpointConnection", static: false, private: false, access: { has: obj => "removeEndpointConnection" in obj, get: obj => obj.removeEndpointConnection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
576
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
577
|
+
})(),
|
|
578
|
+
_a;
|
|
579
|
+
})();
|
|
580
|
+
export { MiotProvider };
|
|
581
|
+
export const $xiaomi = $constructor(MiotProvider)
|
|
582
|
+
.build(uniqueName('provider'))
|
|
583
|
+
.build(provider => {
|
|
584
|
+
register(MIOT_NAMESPACE, provider);
|
|
585
|
+
});
|
|
586
|
+
function createBackendClient(session) {
|
|
587
|
+
return new BackendClient({
|
|
588
|
+
uuid: session.uuid,
|
|
589
|
+
accessToken: session.token.accessToken,
|
|
590
|
+
cloudServer: session.cloudServer,
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
function isUnsignedDecimal(value) {
|
|
594
|
+
return /^(?:0|[1-9]\d*)$/u.test(value);
|
|
595
|
+
}
|
|
596
|
+
function isCentralGatewayCandidateModel(model) {
|
|
597
|
+
var _a;
|
|
598
|
+
return ((_a = model === null || model === void 0 ? void 0 : model.split('.').some(part => part === 'controller' || part === 'gateway' || part === 'router')) !== null && _a !== void 0 ? _a : false);
|
|
599
|
+
}
|
|
600
|
+
//# sourceMappingURL=provider.js.map
|