Use correct app name
This commit is contained in:
@@ -25,7 +25,7 @@ const accountsAuthenticatedRequestHeaders = (
|
||||
): Record<string, string> => {
|
||||
return {
|
||||
"X-Auth-Token": token,
|
||||
"X-Client-Package": clientPackageName.accounts,
|
||||
"X-Client-Package": clientPackageName("accounts"),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
|
||||
logUnhandledErrorsAndRejections(true);
|
||||
setAppNameForAuthenticatedRequests(appName);
|
||||
HTTPService.setHeaders({
|
||||
"X-Client-Package": clientPackageName[appName],
|
||||
"X-Client-Package": clientPackageName(appName),
|
||||
});
|
||||
return () => logUnhandledErrorsAndRejections(false);
|
||||
}, []);
|
||||
|
||||
@@ -158,7 +158,7 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
logUnhandledErrorsAndRejections(true);
|
||||
setAppNameForAuthenticatedRequests(appName);
|
||||
HTTPService.setHeaders({
|
||||
"X-Client-Package": clientPackageName[appName],
|
||||
"X-Client-Package": clientPackageName(appName),
|
||||
});
|
||||
return () => logUnhandledErrorsAndRejections(false);
|
||||
}, []);
|
||||
|
||||
@@ -28,7 +28,7 @@ export const passkeyVerificationRedirectURL = (
|
||||
appName: AppName,
|
||||
passkeySessionID: string,
|
||||
) => {
|
||||
const clientPackage = clientPackageName[appName];
|
||||
const clientPackage = clientPackageName(appName);
|
||||
// Using `window.location.origin` will work both when we're running in a web
|
||||
// browser, and in our desktop app. See: [Note: Using deeplinks to navigate
|
||||
// in desktop app]
|
||||
|
||||
@@ -16,7 +16,7 @@ let _clientPackage: string | undefined;
|
||||
* @param appName The {@link AppName} of the current app.
|
||||
*/
|
||||
export const setAppNameForAuthenticatedRequests = (appName: AppName) => {
|
||||
_clientPackage = clientPackageName[appName];
|
||||
_clientPackage = clientPackageName(appName);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,12 +18,24 @@ export const appTitle: Record<AppName, string> = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Client "package names" for each of the apps.
|
||||
* Client "package names" for each of our apps.
|
||||
*
|
||||
* These are used as the identifier in the user agent strings that we send to
|
||||
* our own servers.
|
||||
*
|
||||
* In cases where this code works for both a web and a desktop app for the same
|
||||
* app (currently only photos), return the platform specific package name.
|
||||
*/
|
||||
export const clientPackageName: Record<AppName, string> = {
|
||||
export const clientPackageName = (appName: AppName): string => {
|
||||
if (globalThis.electron) {
|
||||
if (appName != "photos")
|
||||
throw new Error(`Unsupported desktop appName ${appName}`);
|
||||
return clientPackageNamePhotosDesktop;
|
||||
}
|
||||
return _clientPackageName[appName];
|
||||
};
|
||||
|
||||
export const _clientPackageName: Record<AppName, string> = {
|
||||
accounts: "io.ente.accounts.web",
|
||||
auth: "io.ente.auth.web",
|
||||
photos: "io.ente.photos.web",
|
||||
|
||||
Reference in New Issue
Block a user