Add provision_printer and remove_printer to the gateway protocol

Adding a printer from the console has to put its LAN credential on the
gateway without the cloud keeping it. The new server messages carry it once
(documented as never-log) and are answered through the existing
command_result with the request id. The message cannot name a certificate
path or serial port: those are on the gateway's own disk and USB bus.
This commit is contained in:
2026-10-29 15:03:27 +00:00
parent 6ad400d44c
commit d355955fb6
2 changed files with 124 additions and 0 deletions
+40
View File
@@ -374,5 +374,45 @@ export const EdgeServerMessageSchema = Type.Union([
printer_id: Type.String(),
command: PrinterCommandSchema,
}),
/**
* Add a printer to this gateway. Relayed by the cloud, which keeps nothing:
* it carries the printer's LAN credential, and printer credentials never
* rest in the cloud. The gateway verifies them by connecting, stores them
* in its own database, and answers with a `command_result` whose
* `command_id` is `request_id`. **Never log this message.**
*
* No `ca_cert_path` and no serial port on purpose: both name things on the
* gateway's own disk and USB bus, which the cloud does not get to choose.
*/
Type.Object(
{
type: Type.Literal("provision_printer"),
request_id: Type.String(),
printer: Type.Object(
{
/** The gateway's own printer id, chosen by the cloud. */
id: Type.String({ pattern: "^[A-Za-z0-9_-]{1,64}$" }),
name: Type.String({ minLength: 1, maxLength: 200 }),
vendor: Type.String(),
host: Type.Optional(Type.String({ maxLength: 255 })),
access_code: Type.Optional(Type.String({ maxLength: 128 })),
sn: Type.Optional(Type.String({ maxLength: 64 })),
api_key: Type.Optional(Type.String({ maxLength: 256 })),
},
{ additionalProperties: false },
),
},
{ additionalProperties: false },
),
/** Forget a printer: leave the running fleet and delete its stored credential. */
Type.Object(
{
type: Type.Literal("remove_printer"),
request_id: Type.String(),
/** The gateway's own printer id. */
printer_id: Type.String(),
},
{ additionalProperties: false },
),
]);
export type EdgeServerMessage = Static<typeof EdgeServerMessageSchema>;