mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-07 07:42:13 +03:00
feat(settings): unify routing rules and model aliases controls
Move model routing management into Settings and add a unified model alias editor for exact and wildcard remaps. Sync combo defaults with global routing strategy settings, add localized combo onboarding copy, and expand routing i18n across supported locales. Also fix supporting routing behavior by accepting all strategy values in settings schemas, preserving connection ids in combo tests, honoring non-stream JSON requests for CC-compatible providers, and handling hashed external package subpaths.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { execSync, execFileSync } from "child_process";
|
||||
import { existsSync } from "fs";
|
||||
import { execFileSync, execSync } from "child_process";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
|
||||
/**
|
||||
* Get raw machine ID using OS-specific methods.
|
||||
@@ -59,12 +59,7 @@ function getMachineIdRaw(): string {
|
||||
try {
|
||||
for (const filePath of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
|
||||
try {
|
||||
const content = execFileSync("cat", [filePath], {
|
||||
encoding: "utf8",
|
||||
timeout: 5000,
|
||||
})
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
const content = readFileSync(filePath, "utf8").trim().toLowerCase();
|
||||
if (content.length > 8) return content;
|
||||
} catch {
|
||||
// Try the next candidate file
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
/**
|
||||
* maskEmail — Privacy display utility for email addresses.
|
||||
*
|
||||
* Masks the username and domain name portions of an email address
|
||||
* to prevent identity exposure in dashboards and logs.
|
||||
* Masks both username and domain portions of an email address.
|
||||
* - Username: keep the first `visibleChars`, mask the rest
|
||||
* - Domain: mask everything except the final `visibleChars`
|
||||
*
|
||||
* @example
|
||||
* maskEmail("diego.souza@gmail.com") // "die********@gmail.com"
|
||||
* maskEmail("a@b.com") // "a@b.com" (too short to mask)
|
||||
* maskEmail("diego.souza@outlook.com.br") // "die********@***********.br"
|
||||
* maskEmail("user@gmail.com") // "use*@******.com"
|
||||
* maskEmail("a@b.com") // "a@b.com" (too short to mask)
|
||||
*/
|
||||
export function maskEmail(email: string | null | undefined, visibleChars = 3): string {
|
||||
if (!email) return "";
|
||||
@@ -14,21 +16,20 @@ export function maskEmail(email: string | null | undefined, visibleChars = 3): s
|
||||
|
||||
const atIndex = email.lastIndexOf("@");
|
||||
const username = email.slice(0, atIndex);
|
||||
const rest = email.slice(atIndex + 1); // "gmail.com", "co.uk", etc.
|
||||
|
||||
const dotIndex = rest.indexOf(".");
|
||||
const domainName = dotIndex !== -1 ? rest.slice(0, dotIndex) : rest;
|
||||
const tld = dotIndex !== -1 ? rest.slice(dotIndex) : ""; // ".com", ".co.uk"
|
||||
const domain = email.slice(atIndex + 1);
|
||||
|
||||
// If username is too short to mask meaningfully, return as-is
|
||||
if (username.length <= visibleChars) return email;
|
||||
|
||||
const maskedUser = username.slice(0, visibleChars) + "*".repeat(username.length - visibleChars);
|
||||
if (domain.length <= visibleChars) {
|
||||
return `${maskedUser}@${domain}`;
|
||||
}
|
||||
|
||||
// Preserve the full domain name to maintain clear provider account differentiation
|
||||
const maskedDomain = domainName;
|
||||
const maskedDomain =
|
||||
"*".repeat(domain.length - visibleChars) + domain.slice(domain.length - visibleChars);
|
||||
|
||||
return `${maskedUser}@${maskedDomain}${tld}`;
|
||||
return `${maskedUser}@${maskedDomain}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user