Skip to content

Commit bfcf250

Browse files
committed
chore: updated return type of usePairingApi
Signed-off-by: Mac Deluca <Mac.Deluca@quartech.com>
1 parent 61c636d commit bfcf250

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

app/src/bcsc-theme/api/hooks/usePairingApi.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,38 @@ import { signPairingCode } from 'react-native-bcsc-core'
44
import BCSCApiClient from '../client'
55
import { withAccount } from './withAccountGuard'
66

7-
// There is no actual data response (just a 200) from the pairing code login endpoint, so we
8-
// define a minimal response for DX and and TypeScript
9-
export interface PairingCodeLoginResponseData {
10-
success: boolean
7+
export interface PairingCodeLoginClientMetadata {
8+
transaction_id: string
9+
client_ref_id: string
10+
client_name: string
11+
client_uri: string
12+
initiate_login_uri: string
13+
policy_uri: string
14+
aaplication_type: string
15+
useage_date: string
1116
}
1217

1318
const usePairingApi = (apiClient: BCSCApiClient) => {
19+
/**
20+
* Logs in a user using a pairing code and returns the client metadata.
21+
*
22+
* @param {string} code - The pairing code to use for login.
23+
* @returns {*} {Promise<PairingCodeLoginClientMetadata>} A promise that resolves to the client metadata.
24+
*/
1425
const loginByPairingCode = useCallback(
1526
async (code: string) => {
16-
return withAccount<PairingCodeLoginResponseData>(async (account) => {
27+
return withAccount<PairingCodeLoginClientMetadata>(async (account) => {
1728
const { issuer, clientID } = account
1829
const { fcmDeviceToken, apnsToken } = await getNotificationTokens()
1930
const signedCode = await signPairingCode(code, issuer, clientID, fcmDeviceToken, apnsToken)
20-
await apiClient.post<PairingCodeLoginResponseData>(
31+
const response = await apiClient.post<PairingCodeLoginClientMetadata>(
2132
// this endpoint is not available through the .well-known/openid-configuration so it needs to be hardcoded
2233
`${apiClient.baseURL}/cardtap/v3/mobile/assertion`,
2334
{ assertion: signedCode },
2435
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
2536
)
26-
return { success: true }
37+
38+
return response.data
2739
})
2840
},
2941
[apiClient]

0 commit comments

Comments
 (0)