node-miio 0.3.0 → 0.4.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/.claude/settings.json +5 -0
- package/.claude/skills/release/SKILL.md +62 -0
- package/AGENTS.md +8 -0
- package/LICENSE.md +28 -0
- package/README.md +43 -37
- package/dist/cli/commands/cloud/devices.js +71 -0
- package/dist/cli/commands/cloud/devices.js.map +1 -0
- package/dist/cli/commands/cloud/login.js +63 -0
- package/dist/cli/commands/cloud/login.js.map +1 -0
- package/dist/cli/commands/cloud/logout.js +14 -0
- package/dist/cli/commands/cloud/logout.js.map +1 -0
- package/dist/cli/commands/cloud.js +49 -0
- package/dist/cli/commands/cloud.js.map +1 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/prompt.js +42 -0
- package/dist/cli/prompt.js.map +1 -0
- package/dist/cli/terminal_qr.js +14 -0
- package/dist/cli/terminal_qr.js.map +1 -0
- package/dist/lib/cloud/client.js +285 -0
- package/dist/lib/cloud/client.js.map +1 -0
- package/dist/lib/cloud/crypto.js +128 -0
- package/dist/lib/cloud/crypto.js.map +1 -0
- package/dist/lib/cloud/errors.js +50 -0
- package/dist/lib/cloud/errors.js.map +1 -0
- package/dist/lib/cloud/http.js +159 -0
- package/dist/lib/cloud/http.js.map +1 -0
- package/dist/lib/cloud/index.js +22 -0
- package/dist/lib/cloud/index.js.map +1 -0
- package/dist/lib/cloud/login.js +352 -0
- package/dist/lib/cloud/login.js.map +1 -0
- package/dist/lib/cloud/session_store.js +71 -0
- package/dist/lib/cloud/session_store.js.map +1 -0
- package/dist/lib/devices/vacuums/vacuum.js +80 -0
- package/dist/lib/devices/vacuums/vacuum.js.map +1 -1
- package/dist/lib/index.js +14 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/maps/map_watcher.js +130 -0
- package/dist/lib/maps/map_watcher.js.map +1 -0
- package/dist/lib/maps/roborock_map.js +269 -0
- package/dist/lib/maps/roborock_map.js.map +1 -0
- package/docs/cloud.md +74 -0
- package/docs/devices/vacuum.md +9 -1
- package/package.json +2 -1
- package/snapshots/vacuum-specs.json.gz +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: release
|
|
3
|
+
description: Prepare and publish a new version of node-miio (version bump on main, GitHub release with generated notes, which publishes to npm with a fresh MIoT spec snapshot). Use when asked to release, cut, or prepare a new version (patch, minor, major or a beta).
|
|
4
|
+
argument-hint: "[patch|minor|major|prerelease|preminor --preid beta]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Release a new version
|
|
8
|
+
|
|
9
|
+
Argument: the `npm version` level: `patch`, `minor`, `major`, or a beta (`preminor --preid beta` for the first beta of
|
|
10
|
+
the next minor, `prerelease` for the next beta). If it's missing, propose one from the PRs merged since the last tag
|
|
11
|
+
(`git log v$PREV..main --oneline`: new features → `minor`, only fixes → `patch`; betas while a feature set is being
|
|
12
|
+
tested by users) and ask before going on.
|
|
13
|
+
|
|
14
|
+
There's no CHANGELOG: the release notes are generated from the PR labels (`.github/release.yml`). Before releasing,
|
|
15
|
+
check that every PR merged since the last tag has a label (`enhancement`, `bug`, `dependencies`, `documentation`…),
|
|
16
|
+
or it lands in "Other Changes".
|
|
17
|
+
|
|
18
|
+
## Before starting
|
|
19
|
+
|
|
20
|
+
- Start from an up-to-date, clean `main`: `git checkout main && git pull --ff-only`, `git status` clean.
|
|
21
|
+
- Work out:
|
|
22
|
+
- `PREV`: the current version in `package.json`.
|
|
23
|
+
- `NEXT`: the version after applying the level to `PREV`.
|
|
24
|
+
- `DATE`: today, as `YYYY-MM-DD`.
|
|
25
|
+
- `START`: the tag the release notes start from. For a beta: the previous tag (`v$PREV`). For a stable release: the
|
|
26
|
+
previous **stable** tag (e.g. `v0.3.0` for `0.4.0`), so the notes cover all the betas.
|
|
27
|
+
|
|
28
|
+
## 1. Version bump (directly on `main`)
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm version <level>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- `preversion` runs lint, build and tests. If they fail, fix that first (in a PR): don't skip them.
|
|
35
|
+
- It creates the `$NEXT` commit and the `v$NEXT` tag on `main`, and `postversion` pushes both.
|
|
36
|
+
|
|
37
|
+
## 2. GitHub release (publishes to npm)
|
|
38
|
+
|
|
39
|
+
Creating the release triggers `.github/workflows/publish-release-to-npm.yml` (on `release: created`, so **never create
|
|
40
|
+
a draft**: it would publish too). The workflow checks the tag matches `package.json`, lints, tests, builds, refreshes
|
|
41
|
+
the bundled MIoT spec snapshot (`npm run snapshot`) and publishes with npm Trusted Publishing. Betas go to the `beta`
|
|
42
|
+
dist-tag, stable releases to `latest`.
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
gh release create v$NEXT --title "v$NEXT - $DATE" --generate-notes --notes-start-tag $START --verify-tag
|
|
46
|
+
# betas: add --prerelease
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Check the notes: `gh release view v$NEXT` should list only the PRs merged since `$START`.
|
|
50
|
+
|
|
51
|
+
## 3. Check the publish
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
gh run list --repo afharo/node-miio --workflow publish-release-to-npm.yml --limit 1
|
|
55
|
+
gh run watch <id> --repo afharo/node-miio --exit-status
|
|
56
|
+
npm view node-miio dist-tags
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If it fails, report it: don't publish by hand without asking. Once a version is on npm, the plugins'
|
|
60
|
+
Renovate (no cooldown for node-miio) opens their update PRs.
|
|
61
|
+
|
|
62
|
+
Report the release and npm links to the user.
|
package/AGENTS.md
CHANGED
|
@@ -115,3 +115,11 @@ Implementation (`src/lib/miot/`):
|
|
|
115
115
|
reference only (which commands exist, what they do). **Never copy or translate its code, mappings or tables.**
|
|
116
116
|
Implement from the miot-spec data, protocol documentation (e.g. marcelrv/XiaomiRobotVacuumProtocol) and captured traffic.
|
|
117
117
|
Other projects (openHAB: EPL-2.0; hass-xiaomi-miot: Apache-2.0) need attribution if anything is reused. Prefer reimplementing.
|
|
118
|
+
Piotr Machowski's Xiaomi-cloud-tokens-extractor and Xiaomi-Cloud-Map-Extractor are **MIT**: they may be ported, keeping the
|
|
119
|
+
attribution header in the ported files (`src/lib/cloud/`) and the notice in `LICENSE.md`.
|
|
120
|
+
|
|
121
|
+
## Xiaomi Cloud (`src/lib/cloud/`)
|
|
122
|
+
|
|
123
|
+
Opt-in only: nothing in the local control paths may require the cloud. Tests use the fake server in
|
|
124
|
+
`cloud.test.mock.ts` (no network); the crypto is checked against vectors generated by the Python reference
|
|
125
|
+
(`__fixtures__/cloud/crypto-vectors.json`). Never log passwords, tokens, `ssecurity` or `serviceToken`.
|
package/LICENSE.md
CHANGED
|
@@ -18,3 +18,31 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
20
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
Parts of `src/lib/cloud/` are ported from Xiaomi-cloud-tokens-extractor
|
|
25
|
+
(https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor) and
|
|
26
|
+
Xiaomi-Cloud-Map-Extractor
|
|
27
|
+
(https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor),
|
|
28
|
+
licensed under the MIT License:
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2020 Piotr Machowski
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
in the Software without restriction, including without limitation the rights
|
|
35
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
furnished to do so, subject to the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -34,15 +34,15 @@ them.
|
|
|
34
34
|
|
|
35
35
|
Currently supported devices are:
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
- Air Purifiers (1, 2 and Pro)
|
|
38
|
+
- Mi Humidifier
|
|
39
|
+
- Mi Smart Socket Plug and Power Strips
|
|
40
|
+
- Robot vacuums:
|
|
41
|
+
- Roborock / Mi Robot Vacuum (legacy miIO protocol), Viomi and Dreame (mc1808)
|
|
42
|
+
- **Any MIoT vacuum** (Xiaomi, Dreame, Mijia, ijai, …), driven by its spec from [miot-spec.org](https://home.miot-spec.com) (see [MIoT devices](#miot-devices))
|
|
43
|
+
- Mi Smart Home Gateway (Aqara) and accessories - switches, sensors, etc
|
|
44
|
+
- Philips Light Bulb and Eyecare Lamp
|
|
45
|
+
- Yeelights (White Bulb, Color Bulb, Desk Lamp and Strip)
|
|
46
46
|
|
|
47
47
|
See [documentation for devices](docs/devices/README.md) for information about
|
|
48
48
|
the types, their API and supported device models. You can also check
|
|
@@ -93,30 +93,33 @@ npm install -g node-miio
|
|
|
93
93
|
## Usage
|
|
94
94
|
|
|
95
95
|
```javascript
|
|
96
|
-
const miio = require(
|
|
96
|
+
const miio = require("node-miio");
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
Resolve a handle to the device:
|
|
100
100
|
|
|
101
101
|
```javascript
|
|
102
102
|
// Resolve a device, resolving the token automatically or from storage
|
|
103
|
-
miio
|
|
104
|
-
.
|
|
105
|
-
.
|
|
103
|
+
miio
|
|
104
|
+
.device({ address: "192.168.100.8" })
|
|
105
|
+
.then((device) => console.log("Connected to", device))
|
|
106
|
+
.catch((err) => handleErrorHere);
|
|
106
107
|
|
|
107
108
|
// Resolve a device, specifying the token (see below for how to get the token)
|
|
108
|
-
miio
|
|
109
|
-
.
|
|
110
|
-
.
|
|
109
|
+
miio
|
|
110
|
+
.device({ address: "192.168.100.8", token: "token-as-hex" })
|
|
111
|
+
.then((device) => console.log("Connected to", device))
|
|
112
|
+
.catch((err) => handleErrorHere);
|
|
111
113
|
```
|
|
112
114
|
|
|
113
115
|
Call methods to interact with the device:
|
|
114
116
|
|
|
115
117
|
```javascript
|
|
116
118
|
// Switch the power of the device
|
|
117
|
-
device
|
|
118
|
-
.
|
|
119
|
-
.
|
|
119
|
+
device
|
|
120
|
+
.togglePower()
|
|
121
|
+
.then((on) => console.log("Power is now", on))
|
|
122
|
+
.catch((err) => handleErrorHere);
|
|
120
123
|
|
|
121
124
|
// Using async/await
|
|
122
125
|
await device.togglePower();
|
|
@@ -126,25 +129,24 @@ Listen to events such as property changes and actions:
|
|
|
126
129
|
|
|
127
130
|
```javascript
|
|
128
131
|
// Listen for power changes
|
|
129
|
-
device.on(
|
|
132
|
+
device.on("power", (power) => console.log("Power changed to", power));
|
|
130
133
|
|
|
131
134
|
// The device is available for event handlers
|
|
132
|
-
const handler = ({ action }, device) =>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
const handler = ({ action }, device) =>
|
|
136
|
+
console.log("Action", action, "performed on", device);
|
|
137
|
+
device1.on("action", handler);
|
|
138
|
+
device2.on("action", handler);
|
|
135
139
|
```
|
|
136
140
|
|
|
137
141
|
Capabilities and types are used to hint about what a device can do:
|
|
138
142
|
|
|
139
143
|
```javascript
|
|
140
|
-
if(device.matches(
|
|
144
|
+
if (device.matches("cap:temperature")) {
|
|
141
145
|
console.log(await device.temperature());
|
|
142
146
|
}
|
|
143
147
|
|
|
144
|
-
if(device.matches(
|
|
145
|
-
device.setPower(false)
|
|
146
|
-
.then(console.log)
|
|
147
|
-
.catch(console.error);
|
|
148
|
+
if (device.matches("cap:switchable-power")) {
|
|
149
|
+
device.setPower(false).then(console.log).catch(console.error);
|
|
148
150
|
}
|
|
149
151
|
```
|
|
150
152
|
|
|
@@ -164,6 +166,10 @@ There is a command line tool named `miio` that helps with finding and storing
|
|
|
164
166
|
tokens. See [Device management](docs/management.md) for details
|
|
165
167
|
and common use cases.
|
|
166
168
|
|
|
169
|
+
The easiest way to get the tokens is from your Xiaomi account (opt-in):
|
|
170
|
+
`npx node-miio cloud login --qr` (scan the QR code with the Mi Home app), then
|
|
171
|
+
`npx node-miio cloud devices`. See [Xiaomi Cloud](docs/cloud.md).
|
|
172
|
+
|
|
167
173
|
## Discovering devices
|
|
168
174
|
|
|
169
175
|
Use `miio.devices()` to look for and connect to devices on the local network.
|
|
@@ -175,29 +181,29 @@ Example using `miio.devices()`:
|
|
|
175
181
|
|
|
176
182
|
```javascript
|
|
177
183
|
const devices = miio.devices({
|
|
178
|
-
cacheTime: 300 // 5 minutes. Default is 1800 seconds (30 minutes)
|
|
184
|
+
cacheTime: 300, // 5 minutes. Default is 1800 seconds (30 minutes)
|
|
179
185
|
});
|
|
180
186
|
|
|
181
|
-
devices.on(
|
|
182
|
-
if(device.matches(
|
|
187
|
+
devices.on("available", (device) => {
|
|
188
|
+
if (device.matches("placeholder")) {
|
|
183
189
|
// This device is either missing a token or could not be connected to
|
|
184
190
|
} else {
|
|
185
191
|
// Do something useful with device
|
|
186
192
|
}
|
|
187
193
|
});
|
|
188
194
|
|
|
189
|
-
devices.on(
|
|
195
|
+
devices.on("unavailable", (device) => {
|
|
190
196
|
// Device is no longer available and is destroyed
|
|
191
197
|
});
|
|
192
198
|
```
|
|
193
199
|
|
|
194
200
|
`miio.devices()` supports these options:
|
|
195
201
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
202
|
+
- `cacheTime`, the maximum amount of seconds a device can be unreachable before it becomes unavailable. Default: `1800`
|
|
203
|
+
- `filter`, function used to filter what devices are connected to. Default: `reg => true`
|
|
204
|
+
- `skipSubDevices`, if sub devices on Aqara gateways should be skipped. Default: `false`
|
|
205
|
+
- `useTokenStorage`, if tokens should be fetched from storage (see device management). Default: `true`
|
|
206
|
+
- `tokens`, object with manual mapping between ids and tokens (advanced, use [Device management](docs/management.md) if possible)
|
|
201
207
|
|
|
202
208
|
See [Advanced API](docs/advanced-api.md) for details about `miio.browse()`.
|
|
203
209
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = exports.builder = exports.description = exports.command = void 0;
|
|
4
|
+
const index_1 = require("../../../lib/cloud/index");
|
|
5
|
+
const tokens_1 = require("../../../lib/tokens");
|
|
6
|
+
const log_1 = require("../../log");
|
|
7
|
+
exports.command = "devices";
|
|
8
|
+
exports.description = "List the devices of your Xiaomi account, with their tokens";
|
|
9
|
+
exports.builder = {
|
|
10
|
+
server: {
|
|
11
|
+
type: "string",
|
|
12
|
+
choices: [...index_1.CLOUD_SERVERS],
|
|
13
|
+
description: "Only check this server (all of them by default)",
|
|
14
|
+
},
|
|
15
|
+
json: { type: "boolean", description: "Print the devices as JSON" },
|
|
16
|
+
save: {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
description: "Save the tokens, so other node-miio commands can use them",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const handler = async (argv) => {
|
|
22
|
+
const session = await (0, index_1.loadSession)();
|
|
23
|
+
if (!session) {
|
|
24
|
+
log_1.log.error("Not logged in. Run: node-miio cloud login");
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const cloud = new index_1.XiaomiCloud(session);
|
|
30
|
+
const devices = await cloud.getDevices({
|
|
31
|
+
servers: argv.server ? [argv.server] : undefined,
|
|
32
|
+
});
|
|
33
|
+
if (argv.save) {
|
|
34
|
+
for (const device of devices) {
|
|
35
|
+
if (/^[0-9a-f]{32}$/i.test(device.token)) {
|
|
36
|
+
await tokens_1.tokens.update(device.did, Buffer.from(device.token, "hex"));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (argv.json) {
|
|
41
|
+
console.log(JSON.stringify(devices, null, 2));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (devices.length === 0) {
|
|
45
|
+
log_1.log.info("No devices found in this account.");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (const device of devices) {
|
|
49
|
+
log_1.log.plain(device.name);
|
|
50
|
+
log_1.log.plain(` Model: ${device.model}`);
|
|
51
|
+
log_1.log.plain(` IP: ${device.localip ?? "-"}`);
|
|
52
|
+
log_1.log.plain(` ID: ${device.did}`);
|
|
53
|
+
log_1.log.plain(` Token: ${device.token || "-"}`);
|
|
54
|
+
log_1.log.plain(` Server: ${device.server}`);
|
|
55
|
+
log_1.log.plain();
|
|
56
|
+
}
|
|
57
|
+
if (argv.save)
|
|
58
|
+
log_1.log.info("Tokens saved.");
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (err instanceof index_1.CloudSessionExpiredError) {
|
|
62
|
+
log_1.log.error("The session expired. Run: node-miio cloud login");
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
log_1.log.error(err instanceof index_1.CloudError ? err.message : String(err));
|
|
66
|
+
}
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.handler = handler;
|
|
71
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.js","sourceRoot":"","sources":["../../../../src/cli/commands/cloud/devices.ts"],"names":[],"mappings":";;;AAEA,oDAOkC;AAClC,gDAA6C;AAC7C,mCAAgC;AAEnB,QAAA,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,WAAW,GACtB,4DAA4D,CAAC;AAClD,QAAA,OAAO,GAAmB;IACrC,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,GAAG,qBAAa,CAAC;QAC3B,WAAW,EAAE,iDAAiD;KAC/D;IACD,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,2BAA2B,EAAE;IACnE,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,2DAA2D;KACzE;CACF,CAAC;AAEK,MAAM,OAAO,GAAG,KAAK,EAAE,IAI7B,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAW,GAAE,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,SAAG,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACvD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,mBAAW,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC;YACrC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;SACjD,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,IAAI,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzC,MAAM,eAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC9C,OAAO;QACT,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,SAAG,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;YAC9C,OAAO;QACT,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,SAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,SAAG,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACvC,SAAG,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;YAChD,SAAG,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YACrC,SAAG,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;YAC9C,SAAG,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YACxC,SAAG,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;QACD,IAAI,IAAI,CAAC,IAAI;YAAE,SAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,gCAAwB,EAAE,CAAC;YAC5C,SAAG,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,SAAG,CAAC,KAAK,CAAC,GAAG,YAAY,kBAAU,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC;AAnDW,QAAA,OAAO,WAmDlB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handler = exports.builder = exports.description = exports.command = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const index_1 = require("../../../lib/cloud/index");
|
|
11
|
+
const log_1 = require("../../log");
|
|
12
|
+
const prompt_1 = require("../../prompt");
|
|
13
|
+
const terminal_qr_1 = require("../../terminal_qr");
|
|
14
|
+
exports.command = "login";
|
|
15
|
+
exports.description = "Log in to the Xiaomi Cloud (the session is saved, your password is not)";
|
|
16
|
+
exports.builder = {
|
|
17
|
+
qr: {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
description: "Log in by scanning a QR code with the Mi Home app (no password)",
|
|
20
|
+
},
|
|
21
|
+
username: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Email, phone number or Xiaomi user ID (asked if not given)",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const handler = async (argv) => {
|
|
27
|
+
try {
|
|
28
|
+
const cloud = argv.qr
|
|
29
|
+
? await index_1.XiaomiCloud.loginWithQrCode({
|
|
30
|
+
onQrCode: ({ imageUrl, loginUrl, timeoutMs }) => {
|
|
31
|
+
log_1.log.info("Scan this QR code with the Mi Home app (Profile → Scan):");
|
|
32
|
+
// The QR code image encodes the login URL
|
|
33
|
+
console.log((0, terminal_qr_1.terminalQr)(loginUrl));
|
|
34
|
+
log_1.log.plain("If it doesn't scan, open this image and scan it instead:");
|
|
35
|
+
log_1.log.plain(` ${imageUrl}`);
|
|
36
|
+
log_1.log.plain(`Waiting up to ${Math.round(timeoutMs / 60000)} minutes…`);
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
: await index_1.XiaomiCloud.loginWithPassword(argv.username ||
|
|
40
|
+
(await (0, prompt_1.prompt)("Username (email, phone or user ID): ")), await (0, prompt_1.prompt)("Password (not displayed): ", { hidden: true }), {
|
|
41
|
+
solveCaptcha: async (image) => {
|
|
42
|
+
const file = node_path_1.default.join(node_os_1.default.tmpdir(), `node-miio-captcha-${Date.now()}.jpg`);
|
|
43
|
+
await promises_1.default.writeFile(file, image);
|
|
44
|
+
log_1.log.warn(`Xiaomi asks to solve a captcha. Open ${file}`);
|
|
45
|
+
return (0, prompt_1.prompt)("Captcha (case-sensitive): ");
|
|
46
|
+
},
|
|
47
|
+
getVerificationCode: () => {
|
|
48
|
+
log_1.log.warn("Xiaomi sent a verification code to your email.");
|
|
49
|
+
return (0, prompt_1.prompt)("Verification code: ");
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
await (0, index_1.saveSession)(cloud.session);
|
|
53
|
+
log_1.log.info(`Logged in as user ${cloud.session.userId}.`);
|
|
54
|
+
log_1.log.plain(`Session saved to ${(0, index_1.defaultSessionFile)()} (readable only by you).`);
|
|
55
|
+
log_1.log.plain("Next: node-miio cloud devices");
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
log_1.log.error(err instanceof index_1.CloudError ? err.message : String(err));
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
exports.handler = handler;
|
|
63
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../../src/cli/commands/cloud/login.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAkC;AAClC,sDAAyB;AACzB,0DAA6B;AAI7B,oDAKkC;AAClC,mCAAgC;AAChC,yCAAsC;AACtC,mDAA+C;AAElC,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,WAAW,GACtB,yEAAyE,CAAC;AAC/D,QAAA,OAAO,GAAmB;IACrC,EAAE,EAAE;QACF,IAAI,EAAE,SAAS;QACf,WAAW,EACT,iEAAiE;KACpE;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,4DAA4D;KAC1E;CACF,CAAC;AAEK,MAAM,OAAO,GAAG,KAAK,EAAE,IAAyC,EAAE,EAAE;IACzE,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE;YACnB,CAAC,CAAC,MAAM,mBAAW,CAAC,eAAe,CAAC;gBAChC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;oBAC9C,SAAG,CAAC,IAAI,CACN,0DAA0D,CAC3D,CAAC;oBACF,0CAA0C;oBAC1C,OAAO,CAAC,GAAG,CAAC,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,CAAC;oBAClC,SAAG,CAAC,KAAK,CACP,0DAA0D,CAC3D,CAAC;oBACF,SAAG,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC;oBAC3B,SAAG,CAAC,KAAK,CACP,iBAAiB,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,WAAW,CAC1D,CAAC;gBACJ,CAAC;aACF,CAAC;YACJ,CAAC,CAAC,MAAM,mBAAW,CAAC,iBAAiB,CACjC,IAAI,CAAC,QAAQ;gBACX,CAAC,MAAM,IAAA,eAAM,EAAC,sCAAsC,CAAC,CAAC,EACxD,MAAM,IAAA,eAAM,EAAC,4BAA4B,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAC5D;gBACE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;oBAC5B,MAAM,IAAI,GAAG,mBAAI,CAAC,IAAI,CACpB,iBAAE,CAAC,MAAM,EAAE,EACX,qBAAqB,IAAI,CAAC,GAAG,EAAE,MAAM,CACtC,CAAC;oBACF,MAAM,kBAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;oBAChC,SAAG,CAAC,IAAI,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;oBACzD,OAAO,IAAA,eAAM,EAAC,4BAA4B,CAAC,CAAC;gBAC9C,CAAC;gBACD,mBAAmB,EAAE,GAAG,EAAE;oBACxB,SAAG,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;oBAC3D,OAAO,IAAA,eAAM,EAAC,qBAAqB,CAAC,CAAC;gBACvC,CAAC;aACF,CACF,CAAC;QACN,MAAM,IAAA,mBAAW,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,SAAG,CAAC,IAAI,CAAC,qBAAqB,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACvD,SAAG,CAAC,KAAK,CACP,oBAAoB,IAAA,0BAAkB,GAAE,0BAA0B,CACnE,CAAC;QACF,SAAG,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,SAAG,CAAC,KAAK,CAAC,GAAG,YAAY,kBAAU,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACjE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC;AAjDW,QAAA,OAAO,WAiDlB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = exports.builder = exports.description = exports.command = void 0;
|
|
4
|
+
const index_1 = require("../../../lib/cloud/index");
|
|
5
|
+
const log_1 = require("../../log");
|
|
6
|
+
exports.command = "logout";
|
|
7
|
+
exports.description = "Delete the saved Xiaomi Cloud session";
|
|
8
|
+
exports.builder = {};
|
|
9
|
+
const handler = async () => {
|
|
10
|
+
await (0, index_1.deleteSession)();
|
|
11
|
+
log_1.log.info(`Deleted ${(0, index_1.defaultSessionFile)()}`);
|
|
12
|
+
};
|
|
13
|
+
exports.handler = handler;
|
|
14
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../../src/cli/commands/cloud/logout.ts"],"names":[],"mappings":";;;AAAA,oDAA6E;AAC7E,mCAAgC;AAEnB,QAAA,OAAO,GAAG,QAAQ,CAAC;AACnB,QAAA,WAAW,GAAG,uCAAuC,CAAC;AACtD,QAAA,OAAO,GAAG,EAAE,CAAC;AAEnB,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;IAChC,MAAM,IAAA,qBAAa,GAAE,CAAC;IACtB,SAAG,CAAC,IAAI,CAAC,WAAW,IAAA,0BAAkB,GAAE,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.handler = exports.builder = exports.description = exports.command = void 0;
|
|
37
|
+
const devices = __importStar(require("./cloud/devices"));
|
|
38
|
+
const login = __importStar(require("./cloud/login"));
|
|
39
|
+
const logout = __importStar(require("./cloud/logout"));
|
|
40
|
+
exports.command = "cloud <command>";
|
|
41
|
+
exports.description = "Use the Xiaomi Cloud (opt-in): log in and list your devices with their tokens";
|
|
42
|
+
const builder = (yargs) => yargs
|
|
43
|
+
.command(login)
|
|
44
|
+
.command(devices)
|
|
45
|
+
.command(logout);
|
|
46
|
+
exports.builder = builder;
|
|
47
|
+
const handler = () => { };
|
|
48
|
+
exports.handler = handler;
|
|
49
|
+
//# sourceMappingURL=cloud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../src/cli/commands/cloud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yDAA2C;AAC3C,qDAAuC;AACvC,uDAAyC;AAE5B,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAC5B,QAAA,WAAW,GACtB,+EAA+E,CAAC;AAC3E,MAAM,OAAO,GAAmB,CAAC,KAAW,EAAE,EAAE,CACrD,KAAK;KACF,OAAO,CAAC,KAAiC,CAAC;KAC1C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,MAAkC,CAAC,CAAC;AAJpC,QAAA,OAAO,WAI6B;AAC1C,MAAM,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAAnB,QAAA,OAAO,WAAY"}
|
package/dist/cli/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
const yargs_1 = __importDefault(require("yargs"));
|
|
41
41
|
const helpers_1 = require("yargs/helpers");
|
|
42
|
+
const cloud = __importStar(require("./commands/cloud"));
|
|
42
43
|
const configure = __importStar(require("./commands/configure"));
|
|
43
44
|
const control = __importStar(require("./commands/control"));
|
|
44
45
|
const discover = __importStar(require("./commands/discover"));
|
|
@@ -50,6 +51,7 @@ const tokens = __importStar(require("./commands/tokens"));
|
|
|
50
51
|
// `commandDir` is not supported when yargs is loaded as an ES module.
|
|
51
52
|
void (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
52
53
|
.scriptName("node-miio")
|
|
54
|
+
.command(cloud)
|
|
53
55
|
.command(configure)
|
|
54
56
|
.command(control)
|
|
55
57
|
.command(discover)
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,kDAAkD;AAClD,2CAAwC;AAExC,gEAAkD;AAClD,4DAA8C;AAC9C,8DAAgD;AAChD,4DAA8C;AAC9C,8DAAgD;AAChD,2DAA6C;AAC7C,0DAA4C;AAE5C,uEAAuE;AACvE,sEAAsE;AACtE,KAAK,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9B,UAAU,CAAC,WAAW,CAAC;KACvB,OAAO,CAAC,SAAqC,CAAC;KAC9C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,IAAgC,CAAC;KACzC,OAAO,CAAC,MAAkC,CAAC;KAC3C,iBAAiB,EAAE;KACnB,aAAa,EAAE;KACf,MAAM,EAAE;KACR,KAAK,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,kDAAkD;AAClD,2CAAwC;AAExC,wDAA0C;AAC1C,gEAAkD;AAClD,4DAA8C;AAC9C,8DAAgD;AAChD,4DAA8C;AAC9C,8DAAgD;AAChD,2DAA6C;AAC7C,0DAA4C;AAE5C,uEAAuE;AACvE,sEAAsE;AACtE,KAAK,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9B,UAAU,CAAC,WAAW,CAAC;KACvB,OAAO,CAAC,KAAiC,CAAC;KAC1C,OAAO,CAAC,SAAqC,CAAC;KAC9C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,IAAgC,CAAC;KACzC,OAAO,CAAC,MAAkC,CAAC;KAC3C,iBAAiB,EAAE;KACnB,aAAa,EAAE;KACf,MAAM,EAAE;KACR,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.prompt = prompt;
|
|
7
|
+
const node_readline_1 = __importDefault(require("node:readline"));
|
|
8
|
+
const node_stream_1 = require("node:stream");
|
|
9
|
+
/**
|
|
10
|
+
* Asks a question in the terminal.
|
|
11
|
+
*
|
|
12
|
+
* @param question The question
|
|
13
|
+
* @param options The options
|
|
14
|
+
* @param options.hidden Don't echo the answer (passwords)
|
|
15
|
+
* @returns The answer
|
|
16
|
+
*/
|
|
17
|
+
function prompt(question, options = {}) {
|
|
18
|
+
let muted = false;
|
|
19
|
+
const output = new node_stream_1.Writable({
|
|
20
|
+
write(chunk, encoding, callback) {
|
|
21
|
+
if (!muted)
|
|
22
|
+
process.stdout.write(chunk, encoding);
|
|
23
|
+
callback();
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const rl = node_readline_1.default.createInterface({
|
|
27
|
+
input: process.stdin,
|
|
28
|
+
output,
|
|
29
|
+
terminal: process.stdin.isTTY,
|
|
30
|
+
});
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
rl.question(question, (answer) => {
|
|
33
|
+
if (options.hidden)
|
|
34
|
+
process.stdout.write("\n");
|
|
35
|
+
rl.close();
|
|
36
|
+
resolve(answer.trim());
|
|
37
|
+
});
|
|
38
|
+
// Mute the echo of the answer (the question is already written)
|
|
39
|
+
muted = !!options.hidden;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/cli/prompt.ts"],"names":[],"mappings":";;;;;AAWA,wBAyBC;AApCD,kEAAqC;AACrC,6CAAuC;AAEvC;;;;;;;GAOG;AACH,SAAgB,MAAM,CACpB,QAAgB,EAChB,UAAgC,EAAE;IAElC,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,MAAM,MAAM,GAAG,IAAI,sBAAQ,CAAC;QAC1B,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ;YAC7B,IAAI,CAAC,KAAK;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAClD,QAAQ,EAAE,CAAC;QACb,CAAC;KACF,CAAC,CAAC;IACH,MAAM,EAAE,GAAG,uBAAQ,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM;QACN,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK;KAC9B,CAAC,CAAC;IACH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/B,IAAI,OAAO,CAAC,MAAM;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/C,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,gEAAgE;QAChE,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.terminalQr = terminalQr;
|
|
4
|
+
const uqr_1 = require("uqr");
|
|
5
|
+
/**
|
|
6
|
+
* Draws a QR code in the terminal (2 rows of modules per line), for dark terminal themes.
|
|
7
|
+
*
|
|
8
|
+
* @param text The text to encode
|
|
9
|
+
* @returns The QR code, ready to print
|
|
10
|
+
*/
|
|
11
|
+
function terminalQr(text) {
|
|
12
|
+
return (0, uqr_1.renderUnicodeCompact)(text, { border: 2 });
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=terminal_qr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal_qr.js","sourceRoot":"","sources":["../../src/cli/terminal_qr.ts"],"names":[],"mappings":";;AAQA,gCAEC;AAVD,6BAA2C;AAE3C;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAA,0BAAoB,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AACnD,CAAC"}
|