diff --git a/index.html b/index.html
index a620da6..fb6e40b 100644
--- a/index.html
+++ b/index.html
@@ -92,6 +92,9 @@
+
@@ -119,6 +122,7 @@
Message
Set Path
Share (Zero Hop)
+ Export
Reset Path
Forget
@@ -341,6 +345,9 @@
async shareContact(contact) {
await this.connection.sendCommandShareContact(contact.publicKey);
},
+ async exportContact(contact) {
+ await this.connection.sendCommandExportContact(contact?.publicKey);
+ },
async setPath(contact) {
const newOutPath = [
diff --git a/src/connection/connection.js b/src/connection/connection.js
index 27f984b..747504f 100644
--- a/src/connection/connection.js
+++ b/src/connection/connection.js
@@ -154,6 +154,17 @@ class Connection extends EventEmitter {
await this.sendToRadioFrame(data.toBytes());
}
+ // provide a public key to export that contact
+ // not providing a public key will export local identity as a contact instead
+ async sendCommandExportContact(pubKey = null) {
+ const data = new BufferWriter();
+ data.writeByte(Constants.CommandCodes.ExportContact);
+ if(pubKey){
+ data.writeBytes(pubKey); // 32 bytes
+ }
+ await this.sendToRadioFrame(data.toBytes());
+ }
+
onFrameReceived(frame) {
// emit received frame
diff --git a/src/constants.js b/src/constants.js
index 28f3b45..482dc0b 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -28,6 +28,7 @@ class Constants {
SetAdvertLatLon: 14,
RemoveContact: 15,
ShareContact: 16,
+ ExportContact: 17,
}
static ResponseCodes = {
@@ -42,6 +43,7 @@ class Constants {
ChannelMsgRecv: 8,
CurrTime: 9,
NoMoreMessages: 10,
+ ExportContact: 11,
}
static PushCodes = {