@manfred-kunze-dev/iot-cli 3.5.0-dev.27 → 3.5.0-dev.28

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.
@@ -2,7 +2,7 @@ import { Command } from "commander";
2
2
  import { getClient } from "../lib/client.js";
3
3
  import { isJsonOutput } from "../lib/config.js";
4
4
  import { printJson, printKeyValue, printSuccess } from "../lib/output.js";
5
- import { handleError } from "../lib/errors.js";
5
+ import { handleError, CLIError } from "../lib/errors.js";
6
6
  import { promptText, promptSecret } from "../lib/prompt.js";
7
7
  import { resolveFlashInputs } from "../lib/flash/resolve.js";
8
8
  import { inspectBootPartition, detectBootPartitions, writeBootstrapFile, } from "../lib/flash/boot-partition.js";
@@ -81,6 +81,17 @@ export function makeFlashCommand() {
81
81
  const mint = await mintRegistrationToken(client, resolved.deviceName);
82
82
  const hostname = resolved.hostnameOverride ??
83
83
  renderHostname(resolved.hostnamePattern, mint.deviceId);
84
+ // The device POSTs to provision_url on first boot, so it MUST be an
85
+ // absolute URL. A relative/blank value (a backend bug) would silently
86
+ // break enrolment — or, if the gateway fell back to its baked prod
87
+ // default, enrol a staging-flashed device into production. Refuse
88
+ // rather than write a broken [backend].provision_url.
89
+ if (!/^https?:\/\//i.test(mint.provisionEndpoint)) {
90
+ throw new CLIError(`The platform returned a non-absolute provision endpoint ` +
91
+ `("${mint.provisionEndpoint}"). Refusing to write a broken ` +
92
+ `[backend].provision_url — expected an absolute https URL. ` +
93
+ `This is a backend bug; fix it before flashing.`);
94
+ }
84
95
  // 4. Write. provision_url is carried from the mint response so a card
85
96
  // flashed against staging cannot silently enrol into production.
86
97
  const written = writeBootstrapFile(target, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manfred-kunze-dev/iot-cli",
3
- "version": "3.5.0-dev.27",
3
+ "version": "3.5.0-dev.28",
4
4
  "description": "Command-line interface for the iot platform by Manfred Kunze Development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",