[FEAT] MeshCore: import/export MeshCore One contact-share tokens <pubkey:type:name>
Summary
Support the MeshCore One contact-share token <publicKeyHex:type:name> for import and export in MeshMonitor.
Requested by matt in Discord (#feature-requests › MeshCore Contact Import).
Token format (verified against MeshCore One source)
Source: Avi0n/MeshCoreOne → MC1Services/Sources/MC1Services/Utilities/ContactShareUtilities.swift
- Shape:
<64-hex-pubkey:type:name> - Regex:
<[0-9a-fA-F]{64}:\d+:[^>]+> - Public key: 32 bytes as 64 hex characters. Uppercase on emit, case-insensitive on parse.
- Type: firmware
ADV_TYPE_*value. 1 = Companion (chat), 2 = Repeater, 3 = Room. (Not 0 for Repeater. 0 isADV_TYPE_NONE, 4 isADV_TYPE_SENSOR— seeMeshCore/src/helpers/AdvertDataHelpers.h.) MC1 rejects unknown type values. - Name: split the interior on
:with max 2 splits, so the name may contain:. Strip>from the name on emit. Reject an empty name. - A message can hold more than one token (MC1
extractShares).
MC1 also has the matching UI: MC1/Views/Chats/Components/ChatShareMenu.swift and MC1/Views/Chats/Sheets/ShareContactPickerSheet.swift.
Import
- Detect tokens in MeshCore channel messages and DMs. Render a clickable 🪪 next to each token.
- Click opens a modal with name, type, and public key, plus Import and Cancel.
- Add the token format to the Import dialog on the MeshCore Map/Nodes page. Today
handleImportinsrc/components/MeshCore/MeshCoreNodesView.tsxonly accepts a hex signed advert blob (optionallymeshcore://-prefixed).
Backend note
The token carries no signature or advert, so the existing POST .../contacts/import (signed advert bytes) path does not fit. The existing .../contacts/:publicKey/add-to-device path needs the node to already exist in the DB. Import needs a new path that builds a contact from pubkey + type + name (empty/flood out-path) and writes it with CMD_ADD_UPDATE_CONTACT (addOrUpdateContact, already used in src/server/meshcoreNativeBackend.ts). It should reuse the existing contact-table-full / favourites-protection handling from add-to-device.
Import is Companion-only because only a Companion source holds a device contact table. Token detection and the 🪪 display should work on every MeshCore source type.
Export
- Add a + button between the "Type a message…" field and the Send button, in both MeshCore channel and DM composers.
- The + opens a small menu. The only option for now is Share contact (keep it extensible).
- Share contact opens a picker with all known contacts (Companions, Repeaters, Rooms) and a search box that filters the list.
- Clicking a contact closes the picker and inserts
<PUBKEYHEX:type:name>into the message box.
Acceptance
- Round-trip: a token emitted by MeshMonitor parses in MC1, and the reverse.
- Name with
:parses correctly. Name with>is stripped on emit. - Malformed tokens (wrong key length, unknown type, empty name) do not render a 🪪.
- Token length fits within the MeshCore message size limit when inserted (warn if the name pushes it over).
Authored by NodeZero 0️⃣
Scope addition: "Share my contact info"
Requested by matt in Discord. Add a second option to the composer + menu: Share my contact info.
- Clicking it inserts a token for the source's own Companion node into the message box:
<SELF_PUBKEY_HEX:1:self node name>. No picker. - Type is always
1(Companion / chat), because only a Companion source can send channel messages and DMs. - Disable the option when the source has no valid 32-byte public key or the node name is empty.
MeshCore One does the same thing: MC1/Views/Chats/Components/ChatShareMenu.swift → shareMyInfo() builds the token from the connected device's public key and name with type: .chat. canShareMyInfo() gates it on key length = 32 and a non-empty trimmed name.
Updated + menu:
- Share contact (picker, as above)
- Share my contact info (self token, direct insert)
Authored by NodeZero 0️⃣