Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions launcher/src/backend/NodeConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,15 +728,13 @@ export class NodeConnection {
}
let private_key_data;
try {
private_key_data = JSON.parse(private_key);
private_key_data = this.normalizeSSVKeystoreData(JSON.parse(private_key));
} catch (e) {
throw new Error("Given encrypted SSV private_key (keystore) is invalid (not JSON format)");
}
// SSV generated keystore uses "pubKey" since v1.3.3, previously it was "publicKey"
if (!private_key_data?.publicKey && !private_key_data?.pubKey) {
if (!private_key_data?.publicKey) {
throw new Error("Given encrypted SSV private_key (keystore) is invalid (no public key available)");
}
private_key_data.publicKey = private_key_data?.publicKey ? private_key_data.publicKey : private_key_data?.pubKey;
const newPubKey = private_key_data.publicKey;

// Add password_file and keystore_file to secrets dir
Expand Down Expand Up @@ -993,8 +991,7 @@ export class NodeConnection {
throw new Error(SSHService.extractExecError(keystore_read));
}
const keystore_content = keystore_read.stdout;
const keystore_data = JSON.parse(keystore_content);
keystore_data.publicKey = keystore_data?.publicKey ? keystore_data.publicKey : keystore_data?.pubKey;
const keystore_data = this.normalizeSSVKeystoreData(JSON.parse(keystore_content));
const newPubKey = keystore_data.publicKey;

// Write network config
Expand Down Expand Up @@ -1104,8 +1101,7 @@ export class NodeConnection {
throw new Error(SSHService.extractExecError(keystore_read));
}
const keystore_content = keystore_read.stdout;
const keystore_data = JSON.parse(keystore_content);
keystore_data.publicKey = keystore_data?.publicKey ? keystore_data.publicKey : keystore_data?.pubKey;
const keystore_data = this.normalizeSSVKeystoreData(JSON.parse(keystore_content));
const newPubKey = keystore_data.publicKey;

// Write network config
Expand Down Expand Up @@ -1362,8 +1358,7 @@ export class NodeConnection {
privateKeyFilePath: keyStorePrivateKeyFile,
privateKeyFileData: (() => {
try {
let pkfdata = JSON.parse(keyStorePrivateKeyFileContent);
pkfdata.publicKey = pkfdata?.publicKey ? pkfdata.publicKey : pkfdata?.pubKey;
let pkfdata = this.normalizeSSVKeystoreData(JSON.parse(keyStorePrivateKeyFileContent));
return pkfdata;
} catch (e) {
return keyStorePrivateKeyFileContent;
Expand Down Expand Up @@ -1552,8 +1547,7 @@ export class NodeConnection {
privateKeyFilePath: keyStorePrivateKeyFile,
privateKeyFileData: (() => {
try {
let pkfdata = JSON.parse(keyStorePrivateKeyFileContent);
pkfdata.publicKey = pkfdata?.publicKey ? pkfdata.publicKey : pkfdata?.pubKey;
let pkfdata = this.normalizeSSVKeystoreData(JSON.parse(keyStorePrivateKeyFileContent));
return pkfdata;
} catch (e) {
return keyStorePrivateKeyFileContent;
Expand Down Expand Up @@ -1627,7 +1621,26 @@ export class NodeConnection {
return;
}

// <-------- NEW SSVDKGMODAL END --------->
// <-------- NEW SSVMODAL & SSVDKGMODAL HELPERS START --------->

// SSV keystore field naming for the public key has changed over time:
// - v1.3.3 used "pubKey"
// - v2.3.5 used "pubkey"
// - originally it was "publicKey".
// This method ensures that an additional "publicKey" property
// is always set, copying from whichever variant is present.
normalizeSSVKeystoreData(keystore_data) {
keystore_data.publicKey = keystore_data?.publicKey
? keystore_data.publicKey
: keystore_data?.publickey
? keystore_data.publickey
: keystore_data?.pubKey
? keystore_data.pubKey
: keystore_data?.pubkey;
return keystore_data;
}

// <-------- NNEW SSVMODAL & SSVDKGMODAL HELPERS END --------->

async readPrometheusConfig(serviceID) {
let prometheusConfig;
Expand Down
Loading