Skip to content

Commit 230bb3e

Browse files
[paritetbank-by] sanitize logs
1 parent 2f32697 commit 230bb3e

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/plugins/paritetbank-by/fetchApi.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
import { BASE_API_URL } from './models'
2-
import { fetchJson } from '../../common/network'
2+
import { fetchJson, FetchOptions, FetchResponse } from '../../common/network'
33
import type * as T from './types/fetch'
44
import { FetchError, FetchOutput } from './types/base'
55
import { isNonEmptyString } from './helpers'
66

77
const makeUrl = (domain: 'auth' | 'core', url: string): string =>
88
`${BASE_API_URL}/${domain}/services/v3${url}`
99

10+
async function fetchApi (url: string, options: FetchOptions): Promise<FetchResponse> {
11+
return await fetchJson(url, {
12+
...options,
13+
sanitizeRequestLog: {
14+
headers: {
15+
Authorization: true
16+
},
17+
body: {
18+
login: true,
19+
password: true
20+
}
21+
},
22+
sanitizeResponseLog: {
23+
body: {
24+
sessionToken: true
25+
}
26+
}
27+
})
28+
}
29+
1030
/**
1131
* Login using a new deviceId created a device listed in the user's account
1232
* Device name is usually `{platform} {browser}`
1333
* **/
1434
export const fetchLogin = async ({ login, password, deviceId }: T.AuthenticateInput): Promise<FetchOutput<T.AuthenticateOutput>> => {
15-
const { status, body } = await fetchJson(makeUrl('auth', '/authentication/login'), {
35+
const { status, body } = await fetchApi(makeUrl('auth', '/authentication/login'), {
1636
method: 'POST',
1737
body: {
1838
login,
@@ -35,7 +55,7 @@ export const fetchLogin = async ({ login, password, deviceId }: T.AuthenticateIn
3555
}
3656

3757
export const fetchAccounts = async ({ sessionToken }: T.FetchAccountsInput): Promise<FetchOutput<T.FetchAccountsOutput>> => {
38-
const { status, body } = await fetchJson(makeUrl('core', '/product/get-products?getCreditDetail=false'), {
58+
const { status, body } = await fetchApi(makeUrl('core', '/product/get-products?getCreditDetail=false'), {
3959
headers: {
4060
Authorization: `Bearer ${sessionToken}`
4161
}
@@ -49,7 +69,7 @@ export const fetchAccounts = async ({ sessionToken }: T.FetchAccountsInput): Pro
4969
}
5070

5171
export const fetchTransactions = async ({ sessionToken, from, to, account }: T.FetchTransactionsInput): Promise<FetchOutput<T.FetchTransactionsOutput>> => {
52-
const { status, body } = await fetchJson(makeUrl('core', '/operation/history/get-operations-history'), {
72+
const { status, body } = await fetchApi(makeUrl('core', '/operation/history/get-operations-history'), {
5373
method: 'POST',
5474
headers: {
5575
Authorization: `Bearer ${sessionToken}`

src/plugins/paritetbank-by/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { generateUUID } from '../../common/utils'
55
import { isNonEmptyString } from './helpers'
66

77
export const scrape: ScrapeFunc<PreferenceInput> = async ({ preferences, fromDate, toDate }) => {
8-
console.log('SCRAPE', preferences, fromDate, toDate)
8+
// console.log('SCRAPE', preferences, fromDate, toDate)
99
const { login, password } = preferences
1010

1111
const pluginData = {
@@ -20,11 +20,11 @@ export const scrape: ScrapeFunc<PreferenceInput> = async ({ preferences, fromDat
2020

2121
const { sessionToken } = await authenticate(login, password, pluginData.deviceId)
2222

23-
console.log('SUCCESSFUL LOGIN', sessionToken)
23+
// console.log('SUCCESSFUL LOGIN', sessionToken)
2424

2525
const accounts = await getAccounts({ sessionToken })
2626

27-
console.log('SUCCESSFUL ACCOUNTS FETCH', accounts)
27+
// console.log('SUCCESSFUL ACCOUNTS FETCH', accounts)
2828

2929
const transactions = []
3030

0 commit comments

Comments
 (0)