diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bd6e50dbe..7dcec2f428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Improved the content of the pricing page - Changed the viewport to resize the content when the on-screen keyboard opens on _Android_ (`interactive-widget=resizes-content`) +- Disabled the biometric authentication on all devices when generating a new _Security Token_ +- Improved the language localization for German (`de`) ### Fixed +- Fixed the flickering of the navigation items in the header for logged-in users - Fixed the height of the dialogs on mobile +- Fixed the description of the `ROOT_URL` requirement for the server of the Model Context Protocol (MCP) (experimental) ## 3.97.0 - 2026-11-02 diff --git a/README.md b/README.md index 00ae13e290..f8c3c92b89 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Find answers to commonly asked questions about self-hosting Ghostfolio in our [F | `REDIS_PORT` | `number` | | The port where _Redis_ is running | | `REDIS_TLS` | `boolean` (optional) | `false` | Enables TLS/SSL connection to _Redis_ | | `REQUEST_TIMEOUT` | `number` (optional) | `3000` | The timeout of network requests to data providers in milliseconds | -| `ROOT_URL` | `string` (optional) | `http://0.0.0.0:3333` | The root URL of the Ghostfolio application, used for generating callback URLs and external links. | +| `ROOT_URL` | `string` (optional) | `http://0.0.0.0:3333` | The root URL of the Ghostfolio application, used for generating callback URLs and external links. The endpoint of the _Model Context Protocol_ (MCP) accepts only requests to the host name of this URL. | | `TRUST_PROXY` | `string` (optional) | | The [trust proxy](https://expressjs.com/en/guide/behind-proxies.html) setting of _Express.js_ to determine the client IP address for rate limiting, e.g. `1` if the Ghostfolio application runs behind a single reverse proxy | #### OpenID Connect OIDC (experimental) @@ -405,7 +405,7 @@ The _Model Context Protocol_ (MCP) server lets an AI client read your portfolio, ### Prerequisites - Set `ENABLE_FEATURE_MCP` to `true` -- Set `ROOT_URL` to the public URL of your instance if a client calls the endpoint from a browser page. The host name of `ROOT_URL` is the only accepted origin. +- Set `ROOT_URL` to the public URL of your instance. The clients must use the host name of this URL: the endpoint accepts only requests to this host name, and a request from a browser page only with this host name as origin. If a reverse proxy is in front of your instance, it must send the original `Host` header. - Grant an access of the type _MCP_ in _My Ghostfolio_ under _Access_ and copy its token An _MCP_ access with the _Restricted view_ permission reads the portfolio without the monetary values. Grant the _View_ permission to let the client also read the monetary values. Grant the _Restricted view and manage_ or the _View and manage_ permission to let the client also import activities and update the cash balances of your accounts. @@ -415,7 +415,7 @@ An _MCP_ access with the _Restricted view_ permission reads the portfolio withou Point the client to the endpoint below and set the MCP access token as the _Bearer Token_. ``` -POST http://localhost:3333/mcp +POST /mcp "Authorization": "Bearer " ``` diff --git a/apps/api/src/app/endpoints/auth/api-key.strategy.ts b/apps/api/src/app/endpoints/auth/api-key.strategy.ts index c84d3ccd2d..fa979822a2 100644 --- a/apps/api/src/app/endpoints/auth/api-key.strategy.ts +++ b/apps/api/src/app/endpoints/auth/api-key.strategy.ts @@ -53,11 +53,14 @@ export class ApiKeyStrategy extends PassportStrategy( private async validateApiKey(apiKey: string) { if (apiKey) { try { - const { id } = await this.apiKeyService.getUserByApiKey(apiKey); - const user = await this.userService.user({ id }); + const userOfApiKey = await this.apiKeyService.getUserByApiKey(apiKey); - if (user) { - return user; + if (userOfApiKey) { + const user = await this.userService.user({ id: userOfApiKey.id }); + + if (user) { + return user; + } } } catch {} } diff --git a/apps/api/src/app/endpoints/info/info.service.ts b/apps/api/src/app/endpoints/info/info.service.ts index ecff1c16b5..80f2224d6a 100644 --- a/apps/api/src/app/endpoints/info/info.service.ts +++ b/apps/api/src/app/endpoints/info/info.service.ts @@ -49,7 +49,7 @@ export class InfoService { const info: Partial = {}; let isReadOnlyMode: boolean | undefined; let latestFearAndGreedStocksMarketDataPromise: - Promise | undefined; + Promise | undefined; const globalPermissions: string[] = []; diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 8139feea45..6b60d49c05 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -151,7 +151,7 @@ async function bootstrap() { const { hostname } = new URL(configurationService.get('ROOT_URL')); logger.warn( - `The Model Context Protocol (MCP) is enabled, but ROOT_URL is not set. A client which calls the endpoint from a browser page is accepted only with the origin ${hostname}.` + `The Model Context Protocol (MCP) is enabled, but ROOT_URL is not set. The endpoint accepts only requests to the host name ${hostname}. Set ROOT_URL to the public URL of the instance.` ); } diff --git a/apps/api/src/services/api-key/api-key.service.ts b/apps/api/src/services/api-key/api-key.service.ts index b911191dc2..e42d924d79 100644 --- a/apps/api/src/services/api-key/api-key.service.ts +++ b/apps/api/src/services/api-key/api-key.service.ts @@ -32,12 +32,12 @@ export class ApiKeyService { public async getUserByApiKey(apiKey: string) { const hashedKey = this.hashApiKey(apiKey); - const { user } = await this.prismaService.apiKey.findUnique({ + const apiKeyFromDatabase = await this.prismaService.apiKey.findUnique({ include: { user: true }, where: { hashedKey } }); - return user; + return apiKeyFromDatabase?.user; } public hashApiKey(apiKey: string): string { @@ -53,7 +53,7 @@ export class ApiKeyService { private generateApiKey(): string { return getRandomString(32) .split('') - .reduce((acc, char, index) => { + .reduce((acc, char, index) => { const chunkIndex = Math.floor(index / 4); acc[chunkIndex] = (acc[chunkIndex] || '') + char; return acc; diff --git a/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts b/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts index b68ed2fb15..d547de0233 100644 --- a/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts +++ b/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts @@ -88,7 +88,7 @@ export class ExchangeRateDataService { ); const lastDateString = dateStrings.reduce((a, b) => { return a > b ? a : b; - }, undefined); + }, ''); let previousExchangeRate = exchangeRatesByCurrency[`${currency}${targetCurrency}`]?.[ @@ -214,7 +214,7 @@ export class ExchangeRateDataService { const resultExtended = result; for (const symbol of Object.keys(result)) { - const [currency1, currency2] = symbol.match(/.{1,3}/g); + const [currency1, currency2] = symbol.match(/.{1,3}/g) ?? []; const [date] = Object.keys(result[symbol]); // Calculate the opposite direction @@ -226,7 +226,7 @@ export class ExchangeRateDataService { } for (const symbol of Object.keys(resultExtended)) { - const [currency1, currency2] = symbol.match(/.{1,3}/g); + const [currency1, currency2] = symbol.match(/.{1,3}/g) ?? []; this.exchangeRates[symbol] = resultExtended[symbol]?.[dateStringOfYesterday]?.marketPrice; @@ -302,7 +302,7 @@ export class ExchangeRateDataService { const derivedCurrencyFactor = this.derivedCurrencyFactors[`${aFromCurrency}${aToCurrency}`]; - let factor: number; + let factor: number | undefined; if (aFromCurrency === aToCurrency) { factor = 1; @@ -324,8 +324,8 @@ export class ExchangeRateDataService { } else { // Calculate indirectly via base currency - let marketPriceBaseCurrencyFromCurrency: number; - let marketPriceBaseCurrencyToCurrency: number; + let marketPriceBaseCurrencyFromCurrency: number | undefined; + let marketPriceBaseCurrencyToCurrency: number | undefined; try { if (aFromCurrency === DEFAULT_CURRENCY) { @@ -355,10 +355,15 @@ export class ExchangeRateDataService { } } catch {} - // Calculate the opposite direction - factor = - (1 / marketPriceBaseCurrencyFromCurrency) * - marketPriceBaseCurrencyToCurrency; + if ( + isNumber(marketPriceBaseCurrencyFromCurrency) && + isNumber(marketPriceBaseCurrencyToCurrency) + ) { + // Calculate the opposite direction + factor = + (1 / marketPriceBaseCurrencyFromCurrency) * + marketPriceBaseCurrencyToCurrency; + } } } @@ -530,7 +535,9 @@ export class ExchangeRateDataService { } }) ).forEach(({ currency }) => { - currencies.push(currency); + if (currency) { + currencies.push(currency); + } }); ( diff --git a/apps/api/src/services/impersonation/impersonation.service.ts b/apps/api/src/services/impersonation/impersonation.service.ts index 97c3295f02..e8448d7f2c 100644 --- a/apps/api/src/services/impersonation/impersonation.service.ts +++ b/apps/api/src/services/impersonation/impersonation.service.ts @@ -50,7 +50,7 @@ export class ImpersonationService { authenticatedUserSubscription: user?.subscription, isActive: false, scopes: getScopesOfOwnAccess(), - userId: user?.id, + userId: user?.id as string, userSettings: user?.settings?.settings ?? {}, userSubscription: user?.subscription }; diff --git a/apps/api/src/services/market-data/market-data.service.ts b/apps/api/src/services/market-data/market-data.service.ts index c1a31ce815..0e67079a05 100644 --- a/apps/api/src/services/market-data/market-data.service.ts +++ b/apps/api/src/services/market-data/market-data.service.ts @@ -30,7 +30,7 @@ export class MarketDataService { dataSource, date = new Date(), symbol - }: DataGatheringItem): Promise { + }: DataGatheringItem): Promise { return await this.prismaService.marketData.findFirst({ where: { dataSource, @@ -43,7 +43,7 @@ export class MarketDataService { public async getLatest({ dataSource, symbol - }: AssetProfileIdentifier): Promise { + }: AssetProfileIdentifier): Promise { return this.prismaService.marketData.findFirst({ orderBy: [{ date: 'desc' }], where: { diff --git a/apps/api/src/services/platform/platform.service.ts b/apps/api/src/services/platform/platform.service.ts index 56da19b2a5..f13be12c7a 100644 --- a/apps/api/src/services/platform/platform.service.ts +++ b/apps/api/src/services/platform/platform.service.ts @@ -21,7 +21,7 @@ export class PlatformService { public async getPlatform( platformWhereUniqueInput: Prisma.PlatformWhereUniqueInput - ): Promise { + ): Promise { return this.prismaService.platform.findUnique({ where: platformWhereUniqueInput }); diff --git a/apps/api/src/services/portfolio-table/portfolio-table.service.spec.ts b/apps/api/src/services/portfolio-table/portfolio-table.service.spec.ts index 4a213684b8..ecb09b2093 100644 --- a/apps/api/src/services/portfolio-table/portfolio-table.service.spec.ts +++ b/apps/api/src/services/portfolio-table/portfolio-table.service.spec.ts @@ -121,6 +121,7 @@ function createHolding({ assetSubClass = AssetSubClass.STOCK, dataSource = DataSource.YAHOO, isin, + name, symbol = 'AAPL' }: { allocationInPercentage?: number; @@ -128,6 +129,7 @@ function createHolding({ assetSubClass?: AssetSubClass; dataSource?: DataSource; isin?: string | null; + name?: string | null; symbol?: string; } = {}) { return { @@ -140,7 +142,7 @@ function createHolding({ isin, symbol, currency: 'CHF', - name: `Name of ${symbol}` + name: name === undefined ? `Name of ${symbol}` : name }, dateOfFirstActivity: new Date('2024-01-01'), grossPerformance: 100, @@ -631,6 +633,16 @@ describe('PortfolioTableService', () => { expect(row).toContain('| Name of AAPL | | AAPL |'); }); + it('gives an empty name if the asset profile has none', async () => { + const result = await getHoldingsTable([createHolding({ name: null })]); + + const [row] = result.split('\n').filter((line) => { + return line.includes('| AAPL |'); + }); + + expect(row).toContain('| | | AAPL |'); + }); + it('gives the translation of the asset class and of the asset sub class', async () => { const result = await getHoldingsTable([createHolding()]); diff --git a/apps/api/src/services/portfolio-table/portfolio-table.service.ts b/apps/api/src/services/portfolio-table/portfolio-table.service.ts index bcf2839fba..1f51bd5b9b 100644 --- a/apps/api/src/services/portfolio-table/portfolio-table.service.ts +++ b/apps/api/src/services/portfolio-table/portfolio-table.service.ts @@ -52,7 +52,10 @@ function getDataSourceColumnDefinition( const dataSource = getDataSource(row); return dataSource - ? transformDataSourceInResponse({ configurationService, dataSource }) + ? (transformDataSourceInResponse({ + configurationService, + dataSource + }) ?? '') : ''; }, name: DATA_SOURCE_COLUMN_NAME @@ -176,7 +179,7 @@ export class PortfolioTableService { }), { getValue: ({ assetProfile, currency }) => { - return currency ?? assetProfile.currency; + return currency ?? assetProfile.currency ?? ''; }, name: 'Currency' }, @@ -226,7 +229,7 @@ export class PortfolioTableService { [ { getValue: ({ assetProfile }) => { - return assetProfile.name; + return assetProfile.name ?? ''; }, name: 'Name' }, @@ -249,7 +252,7 @@ export class PortfolioTableService { }), { getValue: ({ assetProfile }) => { - return assetProfile.currency; + return assetProfile.currency ?? ''; }, name: 'Currency' }, @@ -696,7 +699,7 @@ export class PortfolioTableService { const performanceSection = ['## Performance', '']; - if (chart?.length > 0) { + if (chart && chart.length > 0) { performanceSection.push( await getMarkdownTable({ columnDefinitions: this.getColumnDefinitions({ diff --git a/apps/api/src/services/symbol/symbol.service.ts b/apps/api/src/services/symbol/symbol.service.ts index 69d9d54f32..856ed4bf01 100644 --- a/apps/api/src/services/symbol/symbol.service.ts +++ b/apps/api/src/services/symbol/symbol.service.ts @@ -50,7 +50,7 @@ export class SymbolService { symbol: dataGatheringItem.symbol }); - marketPrice = latestMarketData?.marketPrice; + marketPrice = latestMarketData?.marketPrice as number; } else { const quotes = await this.dataProviderService.getQuotes({ items: [dataGatheringItem] diff --git a/apps/api/src/services/user/user.service.ts b/apps/api/src/services/user/user.service.ts index b566332f40..b3d7ea89bb 100644 --- a/apps/api/src/services/user/user.service.ts +++ b/apps/api/src/services/user/user.service.ts @@ -708,6 +708,8 @@ export class UserService { userId }); + await this.prismaService.authDevice.deleteMany({ where: { userId } }); + await this.prismaService.user.update({ data: { accessToken: hashedAccessToken }, where: { id: userId } diff --git a/apps/client/src/app/components/header/header.component.html b/apps/client/src/app/components/header/header.component.html index 05dacf8d37..0d35d7e23a 100644 --- a/apps/client/src/app/components/header/header.component.html +++ b/apps/client/src/app/components/header/header.component.html @@ -339,7 +339,10 @@ -