Add protocol
This commit is contained in:
@@ -6,6 +6,9 @@ files:
|
||||
extraFiles:
|
||||
- from: build
|
||||
to: resources
|
||||
protocols:
|
||||
- name: Ente
|
||||
schemes: ["ente"]
|
||||
win:
|
||||
target:
|
||||
- target: nsis
|
||||
|
||||
@@ -137,6 +137,22 @@ const registerPrivilegedSchemes = () => {
|
||||
]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a handler for deeplinks, for the "ente://" protocol.
|
||||
*
|
||||
* See: [Note: Passkey verification in the desktop app].
|
||||
*
|
||||
* Implementation notes:
|
||||
* - https://www.electronjs.org/docs/latest/tutorial/launch-app-from-url-in-another-app
|
||||
* - This works only when the app is packaged.
|
||||
*/
|
||||
const handleEnteLinks = () => {
|
||||
app.setAsDefaultProtocolClient("ente");
|
||||
app.on("open-url", (_, url) => {
|
||||
log.info(`open-url: ${url}`);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create an return the {@link BrowserWindow} that will form our app's UI.
|
||||
*
|
||||
@@ -451,6 +467,7 @@ const main = () => {
|
||||
|
||||
initLogging();
|
||||
logStartupBanner();
|
||||
handleEnteLinks();
|
||||
// The order of the next two calls is important
|
||||
setupRendererServer();
|
||||
registerPrivilegedSchemes();
|
||||
|
||||
@@ -29,13 +29,6 @@ export const redirectUserToPasskeyVerificationFlow = (
|
||||
passkeySessionID: string,
|
||||
) => {
|
||||
const clientPackage = clientPackageName[appName];
|
||||
const redirect = `${window.location.origin}/passkeys/finish`;
|
||||
const params = new URLSearchParams({
|
||||
clientPackage,
|
||||
passkeySessionID,
|
||||
redirect,
|
||||
});
|
||||
const url = `${accountsAppURL()}/passkeys/verify?${params.toString()}`;
|
||||
// [Note: Passkey verification in the desktop app]
|
||||
//
|
||||
// Our desktop app bundles the web app and serves it over a custom protocol.
|
||||
@@ -54,11 +47,18 @@ export const redirectUserToPasskeyVerificationFlow = (
|
||||
// protocol and provide that as a return path redirect. Passkey
|
||||
// authentication happens at accounts.ente.io, and on success there is
|
||||
// redirected back to the desktop app.
|
||||
if (globalThis.electron) {
|
||||
window.open(url);
|
||||
} else {
|
||||
window.location.href = url;
|
||||
}
|
||||
const redirectOrigin = globalThis.electron
|
||||
? "ente://"
|
||||
: window.location.origin;
|
||||
const redirect = `${redirectOrigin}/passkeys/finish`;
|
||||
const params = new URLSearchParams({
|
||||
clientPackage,
|
||||
passkeySessionID,
|
||||
redirect,
|
||||
});
|
||||
const url = `${accountsAppURL()}/passkeys/verify?${params.toString()}`;
|
||||
if (globalThis.electron) window.open(url);
|
||||
else window.location.href = url;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user