apertodns 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +17 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -194,7 +194,8 @@ const txtSetArgs = txtSetIdx !== -1 ? {
194
194
  const txtDeleteIdx = args.indexOf("--txt-delete");
195
195
  const txtDeleteArgs = txtDeleteIdx !== -1 ? {
196
196
  hostname: args[txtDeleteIdx + 1],
197
- name: args[txtDeleteIdx + 2]
197
+ name: args[txtDeleteIdx + 2],
198
+ value: args[txtDeleteIdx + 3] // Optional: for selective multi-TXT deletion (wildcard certificates)
198
199
  } : null;
199
200
 
200
201
  // JSON output helper
@@ -229,7 +230,7 @@ ${chalk.bold("GESTIONE DOMINI:")}
229
230
 
230
231
  ${chalk.bold("TXT RECORDS (ACME DNS-01):")}
231
232
  ${cyan("--txt-set")} <host> <name> <val> Imposta record TXT
232
- ${cyan("--txt-delete")} <host> <name> Elimina record TXT
233
+ ${cyan("--txt-delete")} <host> <name> [val] Elimina record TXT (val opzionale per wildcard)
233
234
 
234
235
  ${chalk.bold("GESTIONE TOKEN:")}
235
236
  ${cyan("--enable")} <id> Attiva un token
@@ -724,24 +725,29 @@ const setTxtRecord = async (hostname, name, value) => {
724
725
  }
725
726
  };
726
727
 
727
- const deleteTxtRecord = async (hostname, name) => {
728
+ const deleteTxtRecord = async (hostname, name, value) => {
728
729
  if (!hostname || !name) {
729
730
  if (showJson) {
730
- console.log(JSON.stringify({ error: "Uso: --txt-delete <hostname> <name>" }));
731
+ console.log(JSON.stringify({ error: "Uso: --txt-delete <hostname> <name> [value]" }));
731
732
  } else {
732
- console.log(red("\n❌ Uso: --txt-delete <hostname> <name>"));
733
- console.log(gray(" Esempio: --txt-delete mio.apertodns.com _acme-challenge\n"));
733
+ console.log(red("\n❌ Uso: --txt-delete <hostname> <name> [value]"));
734
+ console.log(gray(" Esempio: --txt-delete mio.apertodns.com _acme-challenge"));
735
+ console.log(gray(" Con value: --txt-delete mio.apertodns.com _acme-challenge token123\n"));
734
736
  }
735
737
  return;
736
738
  }
737
739
 
738
740
  const token = await getAuthToken();
739
- const spin = !showJson ? spinner(`Eliminazione TXT ${name}.${hostname}...`).start() : null;
741
+ const spin = !showJson ? spinner(`Eliminazione TXT ${name}.${hostname}${value ? ` (value: ${value.substring(0,10)}...)` : ''}...`).start() : null;
740
742
 
741
743
  try {
742
744
  const controller = new AbortController();
743
745
  const timeout = setTimeout(() => controller.abort(), 15000);
744
746
 
747
+ // Build txt object - include value if provided for selective multi-TXT deletion
748
+ const txtObj = { name, action: "delete" };
749
+ if (value) txtObj.value = value;
750
+
745
751
  const res = await fetch(`${IETF_BASE}/update`, {
746
752
  method: "POST",
747
753
  headers: {
@@ -750,10 +756,7 @@ const deleteTxtRecord = async (hostname, name) => {
750
756
  },
751
757
  body: JSON.stringify({
752
758
  hostname,
753
- txt: {
754
- name,
755
- action: "delete"
756
- }
759
+ txt: txtObj
757
760
  }),
758
761
  signal: controller.signal
759
762
  });
@@ -762,9 +765,9 @@ const deleteTxtRecord = async (hostname, name) => {
762
765
  const data = await res.json();
763
766
 
764
767
  if (res.ok && data.success !== false) {
765
- spin?.succeed(`TXT record eliminato: ${name}.${hostname}`);
768
+ spin?.succeed(`TXT record eliminato: ${name}.${hostname}${value ? ' (selective)' : ''}`);
766
769
  if (showJson) {
767
- console.log(JSON.stringify({ success: true, hostname, txt: { name, action: "delete" }, response: data }, null, 2));
770
+ console.log(JSON.stringify({ success: true, hostname, txt: { name, value: value || undefined, action: "delete" }, response: data }, null, 2));
768
771
  }
769
772
  } else {
770
773
  spin?.fail(`Errore: ${data.error || data.message || 'TXT non supportato'}`);
@@ -1944,7 +1947,7 @@ const main = async () => {
1944
1947
  try {
1945
1948
  if (logout) await runLogout();
1946
1949
  else if (txtSetArgs) await setTxtRecord(txtSetArgs.hostname, txtSetArgs.name, txtSetArgs.value);
1947
- else if (txtDeleteArgs) await deleteTxtRecord(txtDeleteArgs.hostname, txtDeleteArgs.name);
1950
+ else if (txtDeleteArgs) await deleteTxtRecord(txtDeleteArgs.hostname, txtDeleteArgs.name, txtDeleteArgs.value);
1948
1951
  else if (showMyIp) await showMyIpCommand();
1949
1952
  else if (runDaemon) await runDaemonMode();
1950
1953
  else if (enableTokenId) await updateTokenState(enableTokenId, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apertodns",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "ApertoDNS CLI - Dynamic DNS management from your terminal. Manage domains, tokens, API keys and DNS updates with style.",
5
5
  "main": "index.js",
6
6
  "type": "module",