From 0b2c03dc5e1060cd229aeafb84263f171b5a9788 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 25 Sep 2023 09:31:17 -0300 Subject: new libeufin api --- packages/demobank-ui/src/hooks/useCredentialsChecker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'packages/demobank-ui/src/hooks/useCredentialsChecker.ts') diff --git a/packages/demobank-ui/src/hooks/useCredentialsChecker.ts b/packages/demobank-ui/src/hooks/useCredentialsChecker.ts index 05954348f..f66a4a7c6 100644 --- a/packages/demobank-ui/src/hooks/useCredentialsChecker.ts +++ b/packages/demobank-ui/src/hooks/useCredentialsChecker.ts @@ -23,13 +23,13 @@ export function useCredentialsChecker() { const response = await request(baseUrl, `accounts/${username}/token`, { method: "POST", basicAuth: { - username: username, + username, password, }, data, contentType: "json" }); - return { valid: true, token: response.data.token, expiration: response.data.expiration }; + return { valid: true, token: `secret-token:${response.data.access_token}` as AccessToken, expiration: response.data.expiration }; } catch (error) { if (error instanceof RequestError) { return { valid: false, cause: error.cause }; @@ -76,13 +76,13 @@ export function useCredentialsChecker() { } } - return requestNewLoginToken(baseUrl, token.token as AccessToken) + return requestNewLoginToken(baseUrl, token.token) } return { requestNewLoginToken, refreshLoginToken } } export interface LoginToken { - token: string, + token: AccessToken, expiration: Timestamp, } // token used to get loginToken @@ -95,7 +95,7 @@ export type AccessToken = string & { type YesOrNo = "yes" | "no"; export type LoginResult = { valid: true; - token: string; + token: AccessToken; expiration: Timestamp; } | { valid: false; @@ -121,7 +121,7 @@ export interface LoginTokenSuccessResponse { // that are in scope for some time. Must be prefixed // with "Bearer " when used in the "Authorization" HTTP header. // Will already begin with the RFC 8959 prefix. - token: string; + access_token: AccessToken; // Scope of the token (which kinds of operations it will allow) scope: "readonly" | "write"; -- cgit v1.2.3