Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
fix: harden identifier validation, install warning, blob download, zoom repaint
Tw9305491e210764
diff --git a/bin/builders/BaseBuilder.ts b/bin/builders/BaseBuilder.tsindex 62c03feb..1a48f504 100644--- a/bin/builders/BaseBuilder.ts+++ b/bin/builders/BaseBuilder.ts@@ -316,6 +316,12 @@ export default abstract class BaseBuilder {const appBundleName = path.basename(appBundlePath);const appDest = path.join('/Applications', appBundleName);+ if (await fsExtra.pathExists(appDest)) {+ logger.warn(+ ` Existing ${appBundleName} in /Applications will be replaced.`,+ );+ }+// fsExtra.move uses fs.rename (atomic on same filesystem) and falls back// to copy+remove only when moving across volumes.await fsExtra.move(appBundlePath, appDest, { overwrite: true });diff --git a/bin/utils/info.ts b/bin/utils/info.tsindex 13298f9d..6c15828b 100644--- a/bin/utils/info.ts+++ b/bin/utils/info.ts@@ -14,7 +14,7 @@ export function getIdentifier(url: string, name?: string) {.update(hashInput).digest('hex').substring(0, 6);- return `com.pake.${postFixHash}`;+ return `com.pake.a${postFixHash}`;}export function resolveIdentifier(@@ -24,6 +24,12 @@ export function resolveIdentifier() {const trimmedIdentifier = customIdentifier?.trim();if (trimmedIdentifier) {+ if (!/^[a-zA-Z][a-zA-Z0-9.-]*[a-zA-Z0-9]$/.test(trimmedIdentifier)) {+ throw new Error(+ `Invalid identifier "${trimmedIdentifier}". Must start with a letter, ` ++ `contain only letters, digits, hyphens, and dots, and end with a letter or digit.`,+ );+ }return trimmedIdentifier;}diff --git a/dist/cli.js b/dist/cli.jsindex 9c32c1aa..395cca3e 100644--- a/dist/cli.js+++ b/dist/cli.js@@ -182,11 +182,15 @@ function getIdentifier(url, name) {.update(hashInput).digest('hex').substring(0, 6);- return `com.pake.${postFixHash}`;+ return `com.pake.a${postFixHash}`;}function resolveIdentifier(url, explicitName, customIdentifier) {const trimmedIdentifier = customIdentifier?.trim();if (trimmedIdentifier) {+ if (!/^[a-zA-Z][a-zA-Z0-9.-]*[a-zA-Z0-9]$/.test(trimmedIdentifier)) {+ throw new Error(`Invalid identifier "${trimmedIdentifier}". Must start with a letter, ` ++ `contain only letters, digits, hyphens, and dots, and end with a letter or digit.`);+ }return trimmedIdentifier;}return getIdentifier(url, explicitName);@@ -1002,6 +1006,9 @@ class BaseBuilder {logger.info(`- Installing ${appName} to /Applications...`);const appBundleName = path.basename(appBundlePath);const appDest = path.join('/Applications', appBundleName);+ if (await fsExtra.pathExists(appDest)) {+ logger.warn(` Existing ${appBundleName} in /Applications will be replaced.`);+ }// fsExtra.move uses fs.rename (atomic on same filesystem) and falls back// to copy+remove only when moving across volumes.await fsExtra.move(appBundlePath, appDest, { overwrite: true });@@ -1855,6 +1862,23 @@ function generateIconServiceUrls(domain) {`https://www.${domain}/favicon.ico`,];}+/**+ * Generates dashboard-icons URLs for an app name.+ * Uses walkxcode/dashboard-icons as a final fallback for selfhosted apps.+ * Keeps matching conservative to avoid overriding valid site-specific icons.+ */+function generateDashboardIconUrls(appName) {+ const baseUrl = 'https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png';+ const name = appName.toLowerCase().trim();+ const slugs = new Set();+ // Exact name+ slugs.add(name);+ // Replace spaces with hyphens+ slugs.add(name.replace(/\s+/g, '-'));+ return [...slugs]+ .filter((s) => s.length > 0)+ .map((slug) => `${baseUrl}/${slug}.png`);+}/*** Attempts to fetch favicon from website*/@@ -1862,11 +1886,11 @@ async function tryGetFavicon(url, appName) {try {const domain = new URL(url).hostname;const spinner = getSpinner(`Fetching icon from ${domain}...`);- const serviceUrls = generateIconServiceUrls(domain);const isCI = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';const downloadTimeout = isCI? ICON_CONFIG.downloadTimeout.ci: ICON_CONFIG.downloadTimeout.default;+ const serviceUrls = generateIconServiceUrls(domain);for (const serviceUrl of serviceUrls) {try {const faviconPath = await downloadIcon(serviceUrl, false, downloadTimeout);@@ -1886,6 +1910,30 @@ async function tryGetFavicon(url, appName) {continue;}}+ // Final fallback for selfhosted apps behind auth where domain-based+ // services cannot access the site favicon.+ if (appName) {+ const dashboardIconUrls = generateDashboardIconUrls(appName);+ for (const iconUrl of dashboardIconUrls) {+ try {+ const iconPath = await downloadIcon(iconUrl, false, downloadTimeout);+ if (!iconPath)+ continue;+ const convertedPath = await convertIconFormat(iconPath, appName);+ if (convertedPath) {+ const finalPath = await copyWindowsIconIfNeeded(convertedPath, appName);+ spinner.succeed(chalk.green(`Icon found via dashboard-icons fallback for "${appName}"!`));+ return finalPath;+ }+ }+ catch (error) {+ if (error instanceof Error) {+ logger.debug(`Dashboard icon ${iconUrl} failed: ${error.message}`);+ }+ continue;+ }+ }+ }spinner.warn(`No favicon found for ${domain}. Using default.`);return null;}diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.jsindex cac8725c..5e0faf54 100644--- a/src-tauri/src/inject/event.js+++ b/src-tauri/src/inject/event.js@@ -23,6 +23,7 @@ function setZoom(zoom) {body.style.height = `${100 / zoomValue}%`;} else {html.style.zoom = zoom;+ window.dispatchEvent(new Event("resize"));}window.localStorage.setItem("htmlZoom", zoom);@@ -336,14 +337,21 @@ document.addEventListener("DOMContentLoaded", () => {}function convertBlobUrlToBinary(blobUrl) {- return new Promise((resolve) => {+ return new Promise((resolve, reject) => {const blob = window.blobToUrlCaches.get(blobUrl);+ if (!blob) {+ fetch(blobUrl)+ .then((res) => res.arrayBuffer())+ .then((buffer) => resolve(Array.from(new Uint8Array(buffer))))+ .catch(reject);+ return;+ }const reader = new FileReader();-reader.readAsArrayBuffer(blob);reader.onload = () => {resolve(Array.from(new Uint8Array(reader.result)));};+ reader.onerror = () => reject(reader.error);});}diff --git a/tests/unit/identifier.test.ts b/tests/unit/identifier.test.tsindex a0676a48..33e139fd 100644--- a/tests/unit/identifier.test.ts+++ b/tests/unit/identifier.test.ts@@ -21,4 +21,46 @@ describe('identifier generation', () => {'com.example.work-gmail',);});++ it('accepts valid custom identifier formats', () => {+ expect(resolveIdentifier(url, undefined, 'com.example.myapp')).toBe(+ 'com.example.myapp',+ );+ expect(resolveIdentifier(url, undefined, 'io.github.myapp')).toBe(+ 'io.github.myapp',+ );+ expect(resolveIdentifier(url, undefined, 'com.my-company.app2')).toBe(+ 'com.my-company.app2',+ );+ });++ it('rejects invalid custom identifiers', () => {+ expect(() => resolveIdentifier(url, undefined, '123.invalid')).toThrow(+ 'Invalid identifier',+ );+ expect(() => resolveIdentifier(url, undefined, 'has spaces')).toThrow(+ 'Invalid identifier',+ );+ expect(() => resolveIdentifier(url, undefined, 'bad!chars')).toThrow(+ 'Invalid identifier',+ );+ });++ it('generated identifier segments never start with a digit (D-Bus compliance)', () => {+ const inputs = [+ ['https://chatgpt.com/', 'chatgpt'],+ ['https://gmail.com', 'Work Gmail'],+ ['https://github.com', undefined],+ ['https://notion.so', 'Notion'],+ ['https://figma.com', 'Figma'],+ ['https://linear.app', 'Linear'],+ ];+ for (const [testUrl, name] of inputs) {+ const id = getIdentifier(testUrl, name);+ const segments = id.split('.');+ for (const seg of segments) {+ expect(seg).toMatch(/^[a-zA-Z_]/);+ }+ }+ });});