From 2d893f6a97ed31bd84a823b51bac9a589faa915a Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 16 Jul 2025 19:01:40 +0200 Subject: [PATCH] Remove need for bridge URL. --- .../Controllers/Import/UploadController.php | 10 +------ app/Services/Session/Constants.php | 1 - .../SimpleFIN/Conversion/RoutineManager.php | 4 +-- .../SimpleFIN/Request/SimpleFINRequest.php | 7 ----- app/Services/SimpleFIN/SimpleFINService.php | 21 ++------------ .../v2/import/003-upload/index.blade.php | 28 ------------------- 6 files changed, 4 insertions(+), 67 deletions(-) diff --git a/app/Http/Controllers/Import/UploadController.php b/app/Http/Controllers/Import/UploadController.php index 21539492..3b51c110 100644 --- a/app/Http/Controllers/Import/UploadController.php +++ b/app/Http/Controllers/Import/UploadController.php @@ -307,23 +307,17 @@ class UploadController extends Controller Log::debug('UploadController::handleSimpleFINFlow() INVOKED'); // Unique entry marker $setupToken = (string)$request->get('simplefin_token'); - $bridgeUrl = (string)$request->get('simplefin_bridge_url'); $isDemo = $request->boolean('use_demo'); $accessToken = $configuration->getAccessToken(); - Log::debug(sprintf('handleSimpleFINFlow("%s", "%s")', $bridgeUrl, $setupToken)); + Log::debug(sprintf('handleSimpleFINFlow("%s")', $setupToken)); if ($isDemo) { Log::debug('Overrule info with demo info.'); $setupToken = (string)config('simplefin.demo_token'); - $bridgeUrl = (string)config('simplefin.demo_url'); } if ('' === $setupToken && '' === $accessToken) { $errors->add('simplefin_token', 'SimpleFIN token is required.'); } - if ('' !== $bridgeUrl && false === filter_var($bridgeUrl, FILTER_VALIDATE_URL) && '' === $accessToken) { - $errors->add('simplefin_bridge_url', 'Bridge URL must be a valid URL.'); - } - if ($errors->count() > 0) { Log::debug('Errors in SimpleFIN flow, return to upload form.'); @@ -331,13 +325,11 @@ class UploadController extends Controller } // Store data in session (may be empty). - session()->put(Constants::SIMPLEFIN_BRIDGE_URL, $bridgeUrl); session()->put(Constants::SIMPLEFIN_TOKEN, $setupToken); // create service: /** @var SimpleFINService $simpleFINService */ $simpleFINService = app(SimpleFINService::class); - $simpleFINService->setBridgeUrl($bridgeUrl); $simpleFINService->setSetupToken($setupToken); $simpleFINService->setConfiguration($configuration); $simpleFINService->setAccessToken($accessToken); diff --git a/app/Services/Session/Constants.php b/app/Services/Session/Constants.php index f705a51a..0491e798 100644 --- a/app/Services/Session/Constants.php +++ b/app/Services/Session/Constants.php @@ -93,7 +93,6 @@ class Constants // SimpleFIN specific constants public const string SIMPLEFIN_TOKEN = 'simplefin_token'; - public const string SIMPLEFIN_BRIDGE_URL = 'simplefin_bridge_url'; public const string SIMPLEFIN_ACCOUNTS_DATA = 'simplefin_accounts_data'; public const string SIMPLEFIN_IS_DEMO = 'simplefin_is_demo'; public const string SIMPLEFIN_ACCESS_TOKEN = 'simplefin_access_token'; diff --git a/app/Services/SimpleFIN/Conversion/RoutineManager.php b/app/Services/SimpleFIN/Conversion/RoutineManager.php index e169e101..7f49e1dc 100644 --- a/app/Services/SimpleFIN/Conversion/RoutineManager.php +++ b/app/Services/SimpleFIN/Conversion/RoutineManager.php @@ -92,17 +92,15 @@ class RoutineManager implements RoutineManagerInterface Log::debug(sprintf('[%s] Now in %s', config('importer.version'), __METHOD__)); $token = (string)session()->get(Constants::SIMPLEFIN_TOKEN); // Retained for general session validation - $bridgeUrl = (string)session()->get(Constants::SIMPLEFIN_BRIDGE_URL); // Retained for general session validation $allAccountsSimpleFINData = session()->get(Constants::SIMPLEFIN_ACCOUNTS_DATA, []); $accessToken = $this->configuration->getAccessToken(); - if ('' === $accessToken && ('' === $token || '' === $bridgeUrl || 0 === count($allAccountsSimpleFINData))) { + if ('' === $accessToken && ('' === $token || 0 === count($allAccountsSimpleFINData))) { Log::error( 'SimpleFIN session data incomplete for conversion.', [ 'access_token' => '' !== $accessToken, 'has_token' => '' !== $token, - 'has_bridge_url' => '' !== $bridgeUrl, 'has_accounts_data' => 0 !== count($allAccountsSimpleFINData), ] ); diff --git a/app/Services/SimpleFIN/Request/SimpleFINRequest.php b/app/Services/SimpleFIN/Request/SimpleFINRequest.php index 5552fe51..aee1fb99 100644 --- a/app/Services/SimpleFIN/Request/SimpleFINRequest.php +++ b/app/Services/SimpleFIN/Request/SimpleFINRequest.php @@ -45,7 +45,6 @@ abstract class SimpleFINRequest private array $parameters = []; private float $timeOut; - private string $bridgeUrl = ''; private string $accessToken = ''; /** @@ -86,7 +85,6 @@ abstract class SimpleFINRequest 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', - 'Origin' => $this->bridgeUrl, ], ]; @@ -160,11 +158,6 @@ abstract class SimpleFINRequest return $this->timeOut; } - public function setBridgeUrl(string $bridgeUrl): void - { - $this->bridgeUrl = $bridgeUrl; - } - public function setAccessToken(string $accessToken): void { Log::debug(sprintf('Access token is now: %s', $accessToken)); diff --git a/app/Services/SimpleFIN/SimpleFINService.php b/app/Services/SimpleFIN/SimpleFINService.php index 86b454b6..f3710d11 100644 --- a/app/Services/SimpleFIN/SimpleFINService.php +++ b/app/Services/SimpleFIN/SimpleFINService.php @@ -44,7 +44,6 @@ class SimpleFINService { private string $accessToken = ''; private string $accessUrl = ''; - private string $bridgeUrl = ''; private string $setupToken = ''; private Configuration $configuration; @@ -66,11 +65,9 @@ class SimpleFINService Log::debug(sprintf('Successfully exchanged claim URL for access token: %s', $this->accessToken)); } if (!$isValid) { - Log::debug('Token is not a base64-encoded claim URL, using provided bridge URL'); + Log::error('Token is not a base64-encoded claim URL.'); // Token is not a base64 claim URL, we need an API URL - if ('' === $this->bridgeUrl) { - throw new ImporterErrorException('SimpleFIN API URL is required when token is not a base64-encoded claim URL'); - } + throw new ImporterErrorException('Token is not a base64-encoded claim URL.'); } } @@ -81,7 +78,6 @@ class SimpleFINService Log::debug(sprintf('SimpleFIN fetching transactions from: %s for account %s', $this->accessToken, $accountId)); $request = new AccountsRequest(); - $request->setBridgeUrl($this->bridgeUrl); $request->setAccessToken($this->accessToken); $request->setTimeOut($this->getTimeout()); @@ -132,7 +128,6 @@ class SimpleFINService Log::debug(sprintf('SimpleFIN fetching accounts from: %s', $this->accessToken)); $request = new AccountsRequest(); - $request->setBridgeUrl($this->bridgeUrl); $request->setAccessToken($this->accessToken); $request->setTimeOut($this->getTimeout()); @@ -298,7 +293,6 @@ class SimpleFINService Log::debug(sprintf('SimpleFIN download transactions for account ID: "%s" from provided data structure.', $accountId)); $request = new AccountsRequest(); - $request->setBridgeUrl($this->bridgeUrl); $request->setAccessToken($this->accessToken); $request->setTimeOut($this->getTimeout()); @@ -423,12 +417,6 @@ class SimpleFINService 'verify' => config('importer.connection.verify'), ]); - // Make POST request to claim URL with empty body - // Use user-provided bridge URL as Origin header for CORS - if ('' === $this->bridgeUrl) { - // throw new ImporterErrorException('SimpleFIN bridge URL not found. Please provide a valid bridge URL.'); - } - Log::debug(sprintf('SimpleFIN using user-provided origin: "%s"', $this->bridgeUrl)); $parts = parse_url($claimUrl); Log::debug(sprintf('Parsed $claimUrl parts: %s', json_encode($parts))); @@ -436,7 +424,6 @@ class SimpleFINService 'headers' => [ 'Content-Length' => '0', 'Origin' => sprintf('%s://%s', $parts['scheme'] ?? 'https', $parts['host'] ?? 'localhost'), - // 'Origin' => $this->bridgeUrl, ], ]); @@ -511,10 +498,6 @@ class SimpleFINService return $this->accessToken; } - public function setBridgeUrl(string $bridgeUrl): void - { - $this->bridgeUrl = $bridgeUrl; - } public function setSetupToken(string $setupToken): void { diff --git a/resources/views/v2/import/003-upload/index.blade.php b/resources/views/v2/import/003-upload/index.blade.php index 3dd92260..9c26f8bb 100644 --- a/resources/views/v2/import/003-upload/index.blade.php +++ b/resources/views/v2/import/003-upload/index.blade.php @@ -93,43 +93,15 @@ - -
- -
- - - Enter the URL where you access this Firefly III Data Importer (e.g., https://your-domain.com). Leave blank if unsure. - - @if($errors->has('simplefin_bridge_url')) -
- {{ $errors->first('simplefin_bridge_url') }} -
- @endif -
-
-