Files
outline/app/utils/Desktop.ts
T
Tom Moor e0db189e53 feat: Run passkey login inside the desktop app (#14180)
* Run passkey login inside the desktop app when supported

Desktop apps that configure a platform authenticator expose
isPasskeySupported on the bridge. When available, the WebAuthn ceremony
runs in the app instead of the system browser. If it fails, the user can
still use a passkey from their browser.

* Name passkeys registered in the desktop app

The Chromium Touch ID authenticator reports the same AAGUID as any
Chromium browser, so passkeys from the desktop app were named
"Chromium Browser".

* Allow more than one passkey from the Chromium authenticator

The Chromium Touch ID authenticator reports the same AAGUID on every
device, so users could not register the desktop app on a second Mac.

* Disable adding passkeys in desktop apps without passkey support
2026-10-20 22:57:37 -04:00

65 lines
1.6 KiB
TypeScript

import { isMac, isWindows } from "@shared/utils/browser";
import env from "~/env";
/**
* Helper methods for detecting and interacting with the desktop application
* wrapper.
*/
export default class Desktop {
/**
* The custom protocol scheme registered by the desktop application.
*/
static protocol = env.isDevelopment ? "outline-dev" : "outline";
/**
* Returns true if the client has inset/floating window controls.
*/
static hasInsetTitlebar() {
return this.isMacApp();
}
/**
* Returns true if the client is running in the macOS app.
*/
static isMacApp() {
return this.isElectron() && isMac;
}
/**
* Returns true if the client is running in the Windows app.
*/
static isWindowsApp() {
return this.isElectron() && isWindows;
}
/**
* Returns true if the client is running in a desktop app.
*/
static isElectron() {
return navigator?.userAgent?.includes("Electron");
}
/**
* Returns true when the desktop app can run the WebAuthn ceremony itself. This
* requires a desktop app that has configured a platform authenticator, and a
* device that supports it.
*
* @returns a promise that resolves to true if passkeys work inside the app.
*/
static async isPasskeySupported(): Promise<boolean> {
try {
if (!(await this.bridge?.isPasskeySupported?.())) {
return false;
}
return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
} catch (_err) {
return false;
}
}
/**
* The bridge provides secure access to API's in desktop wrapper.
*/
static bridge = window.DesktopBridge;
}