From c079b830b5c74fbaeb9956effa8eb10f80e8aff5 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 7 Mar 2025 15:16:36 +0100 Subject: [PATCH] Add browser specific client name (#581) --- browser-extension/src/utils/AppInfo.ts | 27 +++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/browser-extension/src/utils/AppInfo.ts b/browser-extension/src/utils/AppInfo.ts index 682142e7a..2868caca9 100644 --- a/browser-extension/src/utils/AppInfo.ts +++ b/browser-extension/src/utils/AppInfo.ts @@ -19,11 +19,32 @@ export class AppInfo { */ public static readonly MIN_VAULT_VERSION = '1.4.1'; - /* + /** * The client name to use in the X-AliasVault-Client header. - * TODO: make this configurable when adding other browser support (e.g. Firefox). + * Detects the specific browser being used. */ - public static readonly CLIENT_NAME = 'chrome'; + public static readonly CLIENT_NAME = (() : 'chrome' | 'firefox' | 'edge' | 'safari' | 'browser' => { + // This uses the WXT environment variables to detect the specific browser being used. + const env = import.meta.env; + + if (env.FIREFOX) { + return 'firefox'; + } + + if (env.CHROME) { + return 'chrome'; + } + + if (env.EDGE) { + return 'edge'; + } + + if (env.SAFARI) { + return 'safari'; + } + + return 'browser'; + })(); /** * The default AliasVault client URL.