diegosouzapw/OmniRoute · error · ServiceApiKeyDecryptError

ServiceApiKeyDecryptError

Error message

ServiceApiKeyDecryptError

What it means

Error "ServiceApiKeyDecryptError" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/lib/services/apiKey.ts:29

    super(
      `Stored API key for service '${tool}' could not be decrypted. ` +
        `STORAGE_ENCRYPTION_KEY may have changed, the row may be corrupted, ` +
        `or it was written on a different machine. Reinstall the service ` +
        `or rotate the key via POST /api/services/${tool}/rotate-key.`
    );
    this.name = "ServiceApiKeyDecryptError";
  }
}

export async function getOrCreateApiKey(tool: string): Promise<string> {
  const row = await getServiceRow(tool);
  if (row?.apiKey) {
    const decrypted = decrypt(row.apiKey);
    if (decrypted) return decrypted;
    // Fail loud: silently regenerating would mint a new key the embedded
    // service has never been told, causing every request to 401 with no
    // operator-facing signal.
    throw new ServiceApiKeyDecryptError(tool);
  }
  // Dario reuses this mechanism to generate+persist its DARIO_ADMIN_TOKEN
  // (any long random string works — it gates the /admin/* control plane).
  const prefix =
    tool === "9router" ? "nr" : tool === "mux" ? "mx" : tool === "dario" ? "da" : "cp";
  const key = generateServiceApiKey(prefix);
  await updateServiceField(tool, "apiKey", encrypt(key) ?? key);
  return key;
}

export function maskApiKey(plainKey: string): string {
  const last4 = plainKey.slice(-4);
  return `nr_••••••••${last4}`;
}

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/lib/services/apiKey.ts:29 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/37ba9d944cbf86cf. Report an issue: GitHub.