committed by
GitHub
14 changed files with 212 additions and 35 deletions
@ -130,8 +130,8 @@ importers: |
|||||
specifier: ^1.8.2 |
specifier: ^1.8.2 |
||||
version: 1.8.2 |
version: 1.8.2 |
||||
'@buf/meshtastic_protobufs.bufbuild_es': |
'@buf/meshtastic_protobufs.bufbuild_es': |
||||
specifier: 1.10.0-20240613143006-244927bc441a.1 |
specifier: 1.10.0-20240820152623-fac6975bbc78.1 |
||||
version: 1.10.0-20240613143006-244927bc441a.1(@bufbuild/[email protected]) |
version: 1.10.0-20240820152623-fac6975bbc78.1(@bufbuild/[email protected]) |
||||
'@types/chrome': |
'@types/chrome': |
||||
specifier: ^0.0.263 |
specifier: ^0.0.263 |
||||
version: 0.0.263 |
version: 0.0.263 |
||||
@ -354,8 +354,8 @@ packages: |
|||||
cpu: [x64] |
cpu: [x64] |
||||
os: [win32] |
os: [win32] |
||||
|
|
||||
'@buf/[email protected]613143006-244927bc441a.1': |
'@buf/[email protected]820152623-fac6975bbc78.1': |
||||
resolution: {tarball: https://buf.build/gen/npm/v1/@buf/meshtastic_protobufs.bufbuild_es/-/meshtastic_protobufs.bufbuild_es-1.10.0-20240613143006-244927bc441a.1.tgz} |
resolution: {tarball: https://buf.build/gen/npm/v1/@buf/meshtastic_protobufs.bufbuild_es/-/meshtastic_protobufs.bufbuild_es-1.10.0-20240820152623-fac6975bbc78.1.tgz} |
||||
peerDependencies: |
peerDependencies: |
||||
'@bufbuild/protobuf': ^1.10.0 |
'@bufbuild/protobuf': ^1.10.0 |
||||
|
|
||||
@ -3306,7 +3306,7 @@ snapshots: |
|||||
'@biomejs/[email protected]': |
'@biomejs/[email protected]': |
||||
optional: true |
optional: true |
||||
|
|
||||
'@buf/[email protected]613143006-244927bc441a.1(@bufbuild/[email protected])': |
'@buf/[email protected]820152623-fac6975bbc78.1(@bufbuild/[email protected])': |
||||
dependencies: |
dependencies: |
||||
'@bufbuild/protobuf': 1.10.0 |
'@bufbuild/protobuf': 1.10.0 |
||||
|
|
||||
|
|||||
@ -0,0 +1,142 @@ |
|||||
|
import { DynamicForm } from "@app/components/Form/DynamicForm.js"; |
||||
|
import type { SecurityValidation } from "@app/validation/config/security.js"; |
||||
|
import { useDevice } from "@core/stores/deviceStore.js"; |
||||
|
import { Protobuf } from "@meshtastic/js"; |
||||
|
import { fromByteArray, toByteArray } from "base64-js"; |
||||
|
import { Eye, EyeOff } from "lucide-react"; |
||||
|
import { useState } from "react"; |
||||
|
|
||||
|
export const Security = (): JSX.Element => { |
||||
|
const { config, nodes, hardware, setWorkingConfig } = useDevice(); |
||||
|
|
||||
|
const [privateKey, setPrivateKey] = useState<string>( |
||||
|
fromByteArray(config.security?.privateKey ?? new Uint8Array(0)), |
||||
|
); |
||||
|
const [privateKeyVisible, setPrivateKeyVisible] = useState<boolean>(false); |
||||
|
const [publicKey, setPublicKey] = useState<string>( |
||||
|
fromByteArray(config.security?.publicKey ?? new Uint8Array(0)), |
||||
|
); |
||||
|
const [adminKey, setAdminKey] = useState<string>( |
||||
|
fromByteArray(config.security?.adminKey ?? new Uint8Array(0)), |
||||
|
); |
||||
|
const [adminKeyVisible, setAdminKeyVisible] = useState<boolean>(false); |
||||
|
|
||||
|
const onSubmit = (data: SecurityValidation) => { |
||||
|
setWorkingConfig( |
||||
|
new Protobuf.Config.Config({ |
||||
|
payloadVariant: { |
||||
|
case: "security", |
||||
|
value: { |
||||
|
...data, |
||||
|
adminKey: toByteArray(adminKey), |
||||
|
privateKey: toByteArray(privateKey), |
||||
|
publicKey: toByteArray(publicKey), |
||||
|
}, |
||||
|
}, |
||||
|
}), |
||||
|
); |
||||
|
}; |
||||
|
return ( |
||||
|
<DynamicForm<SecurityValidation> |
||||
|
onSubmit={onSubmit} |
||||
|
defaultValues={{ |
||||
|
...config.security, |
||||
|
adminKey: adminKey, |
||||
|
privateKey: privateKey, |
||||
|
publicKey: publicKey, |
||||
|
}} |
||||
|
fieldGroups={[ |
||||
|
{ |
||||
|
label: "Security Settings", |
||||
|
description: "Settings for the Security configuration", |
||||
|
fields: [ |
||||
|
{ |
||||
|
type: privateKeyVisible ? "text" : "password", |
||||
|
name: "privateKey", |
||||
|
label: "Private Key", |
||||
|
description: "Used to create a shared key with a remote device", |
||||
|
disabledBy: [ |
||||
|
{ |
||||
|
fieldName: "adminChannelEnabled", |
||||
|
invert: true, |
||||
|
}, |
||||
|
], |
||||
|
properties: { |
||||
|
action: { |
||||
|
icon: privateKeyVisible ? EyeOff : Eye, |
||||
|
onClick: () => setPrivateKeyVisible(!privateKeyVisible), |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
type: "text", |
||||
|
name: "publicKey", |
||||
|
label: "Public Key", |
||||
|
description: |
||||
|
"Sent out to other nodes on the mesh to allow them to compute a shared secret key", |
||||
|
disabledBy: [{ fieldName: "always" }], |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
label: "Admin Settings", |
||||
|
description: "Settings for Admin ", |
||||
|
fields: [ |
||||
|
{ |
||||
|
type: "toggle", |
||||
|
name: "adminChannelEnabled", |
||||
|
label: "Allow Legacy Admin", |
||||
|
description: |
||||
|
"Allow incoming device control over the insecure legacy admin channel", |
||||
|
}, |
||||
|
{ |
||||
|
type: "toggle", |
||||
|
name: "isManaged", |
||||
|
label: "Managed", |
||||
|
description: |
||||
|
'If true, device is considered to be "managed" by a mesh administrator via admin messages', |
||||
|
}, |
||||
|
{ |
||||
|
type: adminKeyVisible ? "text" : "password", |
||||
|
name: "adminKey", |
||||
|
label: "Admin Key", |
||||
|
disabledBy: [{ fieldName: "adminChannelEnabled" }], |
||||
|
properties: { |
||||
|
action: { |
||||
|
icon: adminKeyVisible ? EyeOff : Eye, |
||||
|
onClick: () => setAdminKeyVisible(!adminKeyVisible), |
||||
|
}, |
||||
|
}, |
||||
|
description: |
||||
|
"The public key authorized to send admin messages to this node", |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
label: "Logging Settings", |
||||
|
description: "Settings for Logging", |
||||
|
fields: [ |
||||
|
{ |
||||
|
type: "toggle", |
||||
|
name: "bluetoothLoggingEnabled", |
||||
|
label: "Allow Bluetooth Logging", |
||||
|
description: "Enables device (serial style logs) over Bluetooth", |
||||
|
}, |
||||
|
{ |
||||
|
type: "toggle", |
||||
|
name: "debugLogApiEnabled", |
||||
|
label: "Enable Debug Log API", |
||||
|
description: "Output live debug logging over serial", |
||||
|
}, |
||||
|
{ |
||||
|
type: "toggle", |
||||
|
name: "serialEnabled", |
||||
|
label: "Serial Output Enabled", |
||||
|
description: "Serial Console over the Stream API", |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
]} |
||||
|
/> |
||||
|
); |
||||
|
}; |
||||
@ -0,0 +1,35 @@ |
|||||
|
import type { Message } from "@bufbuild/protobuf"; |
||||
|
import type { Protobuf } from "@meshtastic/js"; |
||||
|
import { IsBoolean, IsString } from "class-validator"; |
||||
|
|
||||
|
export class SecurityValidation |
||||
|
implements |
||||
|
Omit< |
||||
|
Protobuf.Config.Config_SecurityConfig, |
||||
|
keyof Message | "adminKey" | "privateKey" | "publicKey" |
||||
|
> |
||||
|
{ |
||||
|
@IsBoolean() |
||||
|
adminChannelEnabled: boolean; |
||||
|
|
||||
|
@IsString() |
||||
|
adminKey: string; |
||||
|
|
||||
|
@IsBoolean() |
||||
|
bluetoothLoggingEnabled: boolean; |
||||
|
|
||||
|
@IsBoolean() |
||||
|
debugLogApiEnabled: boolean; |
||||
|
|
||||
|
@IsBoolean() |
||||
|
isManaged: boolean; |
||||
|
|
||||
|
@IsString() |
||||
|
privateKey: string; |
||||
|
|
||||
|
@IsString() |
||||
|
publicKey: string; |
||||
|
|
||||
|
@IsBoolean() |
||||
|
serialEnabled: boolean; |
||||
|
} |
||||
Loading…
Reference in new issue