Files
ak47 573d15d7b4 Add Remote session foundations and feasibility checks
Add opt-in Tentacle protocol 1.1, explicit remote grants, lifecycle IPC and expiring core leases in both SDKs. Revoke access before update preparation, including failed updates.

Add transient secret entries, shared Braille cell export and isolated Xorg recovery experiments with focused tests and documented limitations. Production consent, desktop services and live interoperability remain pending.
2026-11-03 22:33:26 -05:00

40 lines
1.0 KiB
Go

// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
package interaction
import (
"bytes"
"encoding/json"
"errors"
"strings"
)
// UnmarshalJSON keeps a malformed secret flag from silently becoming an
// ordinary entry (encoding/json otherwise accepts null for a boolean). The
// wire decoder separately rejects duplicate keys and bounds nesting/framing.
func (element *Element) UnmarshalJSON(data []byte) error {
type plain Element
var value plain
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
if err := decoder.Decode(&value); err != nil {
return err
}
var fields map[string]json.RawMessage
if err := json.Unmarshal(data, &fields); err != nil {
return err
}
for name, raw := range fields {
if strings.EqualFold(name, "secret") {
flag := string(bytes.TrimSpace(raw))
if name != "secret" || flag != "true" && flag != "false" {
return errors.New("secret must be a boolean")
}
}
}
*element = Element(value)
return nil
}