diff --git a/app/apps/evenhub/even-api.ts b/app/apps/evenhub/even-api.ts index 7ac6ce29..47dadce4 100644 --- a/app/apps/evenhub/even-api.ts +++ b/app/apps/evenhub/even-api.ts @@ -5,11 +5,8 @@ * it only discovers and downloads public .ehpk packages. Authentication is * the same signed-header scheme used by the firmware API. */ -import { - evenHubEmailSetting, - evenHubOpenUdidSetting, - evenHubPasswordSetting, -} from "../../ui/dashboard-settings"; +import { Application } from "@nativescript/core"; +import { evenHubEmailSetting, evenHubPasswordSetting } from "../../ui/dashboard-settings"; declare const android: any; @@ -56,11 +53,7 @@ type DownloadMetadata = { }; export function isEvenHubStoreConfigured(): boolean { - return Boolean( - evenHubEmailSetting.get().trim() && - evenHubPasswordSetting.get() && - evenHubOpenUdidSetting.get().trim(), - ); + return Boolean(evenHubEmailSetting.get().trim() && evenHubPasswordSetting.get()); } export class EvenHubApiClient { @@ -153,7 +146,7 @@ export class EvenHubApiClient { private ensureLogin(): Promise { if (this.token) return Promise.resolve(this.token); if (!isEvenHubStoreConfigured()) { - return Promise.reject(new Error("Set the EvenHub email, password, and phone openUdid in Settings > EvenHub.")); + return Promise.reject(new Error("Set the EvenHub email and password in Settings > EvenHub.")); } if (!this.loginPromise) { this.loginPromise = this.login().finally(() => { @@ -243,7 +236,10 @@ function buildCommon(version: 1 | 3): string { buildTime: "26060821", appId: "1001", v: version, - openUdid: evenHubOpenUdidSetting.get().trim(), + // This is Android's app-scoped SSAID. Even's login endpoint registers a + // previously unseen value as a terminal, so Faceclaw does not need the + // official Even app's differently-scoped ID. + openUdid: getPhoneOpenUdid(), os: "1", sn: "", verL: "", @@ -309,7 +305,7 @@ async function fetchWithTimeout(url: string, init: RequestInit, timeoutMs = REQU function unwrap(envelope: ApiEnvelope, httpStatus: number, path: string): unknown { if (httpStatus === 401) { - throw new Error("Even rejected the login session or phone openUdid. Check Settings > EvenHub."); + throw new Error("Even rejected the login session. Check Settings > EvenHub."); } if (httpStatus < 200 || httpStatus >= 300) { throw new Error(`EvenHub request failed (HTTP ${httpStatus}, ${path}).`); @@ -321,6 +317,17 @@ function unwrap(envelope: ApiEnvelope, httpStatus: number, path: string): unknow return envelope.data; } +/** Return this installation's Android ID, which Even calls `openUdid`. */ +export function getPhoneOpenUdid(): string { + if (!global.isAndroid) throw new Error("The EvenHub storefront is currently available only on Android."); + const resolver = Application.android.context?.getContentResolver(); + const openUdid = resolver + ? String(android.provider.Settings.Secure.getString(resolver, android.provider.Settings.Secure.ANDROID_ID) ?? "") + : ""; + if (!openUdid) throw new Error("Android did not provide a device ID for EvenHub authentication."); + return openUdid; +} + function parseStoreApp(value: unknown): EvenHubStoreApp | null { const item = asRecord(value); const version = asRecord(item.version); diff --git a/app/ui/dashboard-settings.ts b/app/ui/dashboard-settings.ts index 4f536dc7..ea8b98db 100644 --- a/app/ui/dashboard-settings.ts +++ b/app/ui/dashboard-settings.ts @@ -522,19 +522,6 @@ export const evenHubPasswordSetting = new ConfigSettingString({ "Password used to mint a short-lived Even API session. Faceclaw stores it in the same private settings store as other API credentials and never logs it.", }); -export const evenHubOpenUdidSetting = new ConfigSettingString({ - id: "evenhub-openudid", - label: "Even phone openUdid", - storageKey: "integrations.evenhub.openUdid", - defaultValue: "", - editorTitle: "Official Even app Android openUdid", - glassesEditTitle: "Edit Even openUdid", - normalize: (value) => (value ?? "").replace(/[^A-Za-z0-9_-]+/g, "").trim(), - formatValue: maskToken, - description: - "Android ID already bound to this account by the official Even app. The private API rejects a valid login token when this value is missing or belongs to another app/device.", -}); - /** * Staging buffer for the Terminal app's "Add connection" flow: the worker * asks the shell to open the phone text editor on this setting, the user diff --git a/app/ui/dashboard/settings-menus.ts b/app/ui/dashboard/settings-menus.ts index a9e4e8c8..08abfc12 100644 --- a/app/ui/dashboard/settings-menus.ts +++ b/app/ui/dashboard/settings-menus.ts @@ -27,7 +27,6 @@ import { batteryDisplayModeSetting, brightnessSetting, evenHubEmailSetting, - evenHubOpenUdidSetting, evenHubPasswordSetting, elevenLabsApiKeySetting, mapboxApiKeySetting, @@ -139,7 +138,6 @@ function settingsSections(): SettingsSection[] { items: [ textSettingMenuItem(evenHubEmailSetting), textSettingMenuItem(evenHubPasswordSetting), - textSettingMenuItem(evenHubOpenUdidSetting), ], }, {