🔑 Store tokens in Sqllite, moved queries, other fixes

- Create cache dir if missing
- Moved Sqlite queries to queries.ts
- Updated dependencies
- Added pino-pretty to dev-dependencies
- Changed Sqlite to store tokens as separate rows
- Removed in-memory storage of tokens
- isValidToken function
- Throw Exception if refresh token is present but invalid
- Fixed fetch query in smn http file
This commit is contained in:
2025-01-22 21:00:04 +01:00
parent 3bf354b4bf
commit 4a773e4b43
6 changed files with 2326 additions and 1839 deletions

View File

@ -11,13 +11,12 @@ GET {{oauthBaseUrl}}/authorize?client_id={{sparebank1OauthClientId}}&
### OAuth2 Access Token Request
# Refresh token is valid for 365 days
# Access token is valid for 10 minutes
@authenticationCode=<insert code here>
POST {{oauthBaseUrl}}/token
Content-Type: application/x-www-form-urlencoded
client_id = {{sparebank1OauthClientId}} &
client_secret = {{sparebank1OauthClientSecret}} &
code = {{authenticationCode}} &
code = {{sparebank1OauthAuthCode}} &
grant_type = authorization_code &
state = {{sparebank1OauthState}} &
redirect_uri = {{sparebank1OauthRedirectUri}}
@ -43,7 +42,6 @@ grant_type = refresh_token
%}
### Hello World from Sparebank1
GET https://api.sparebank1.no/common/helloworld
Authorization: Bearer {{ACCESS_TOKEN}}
Accept: application/vnd.sparebank1.v1+json; charset=utf-8
@ -52,9 +50,7 @@ Accept: application/vnd.sparebank1.v1+json; charset=utf-8
GET {{bankingBaseUrl}}/accounts
Authorization: Bearer {{ACCESS_TOKEN}}
### Fetch all transactions of the previous day
# TODO date search not working?
GET {{bankingBaseUrl}}/transactions?accountKey={{brukskontoAccountKey}}&fromDate=2024-11-14&
toDate=2024-11-15
### Fetch all transactions of specific days (inclusive)
GET {{bankingBaseUrl}}/transactions?accountKey={{brukskontoAccountKey}}&fromDate=2025-01-20&toDate=2025-01-22
Authorization: Bearer {{ACCESS_TOKEN}}
Accept: application/vnd.sparebank1.v1+json; charset=utf-8