taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit f11d649f0ec485ad10400db0b1786e7718f7d6d3
parent e10b2907606a01ebb71bfd44a517a84af5cd06c1
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu, 17 Apr 2025 13:24:49 -0300

remove async if not needed

Diffstat:
Mpackages/taler-util/src/http-client/challenger.ts | 3++-
Mpackages/taler-util/src/operation.ts | 23+++++++++++------------
2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/packages/taler-util/src/http-client/challenger.ts b/packages/taler-util/src/http-client/challenger.ts @@ -103,10 +103,11 @@ export class ChallengerHttpClient { * https://docs.taler.net/core/api-challenger.html#post--setup-$CLIENT_ID * */ - async setup(clientId: string, token: AccessToken) { + async setup(clientId: string, token: AccessToken, body?: object) { const url = new URL(`setup/${clientId}`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "POST", + body, headers: { Authorization: makeBearerTokenAuthHeader(token), }, diff --git a/packages/taler-util/src/operation.ts b/packages/taler-util/src/operation.ts @@ -115,14 +115,14 @@ export function opEmptySuccess(resp: HttpResponse): OperationOk<void> { return { type: "ok" as const, body: void 0 }; } -export async function opKnownFailure<T>(case_: T): Promise<OperationFail<T>> { +export function opKnownFailure<T>(case_: T): OperationFail<T> { return { type: "fail", case: case_ }; } -export async function opKnownFailureWithBody<T, B>( +export function opKnownFailureWithBody<T, B>( case_: T, body: B, -): Promise<OperationAlternative<T, B>> { +): OperationAlternative<T, B> { return { type: "fail", case: case_, body }; } @@ -177,13 +177,13 @@ export function succeedOrThrow<R>(resp: OperationResult<R, unknown>): R { throw TalerError.fromException(resp); } -export async function alternativeOrThrow<Error, Body, Alt>( +export function alternativeOrThrow<Error, Body, Alt>( + resp: + | OperationOk<Body> + | OperationAlternative<Error, Alt> + | OperationFail<Error>, s: Error, - promise: Promise< - OperationOk<Body> | OperationAlternative<Error, Alt> | OperationFail<Error> - >, ): Promise<Alt> { - const resp = await promise; if (isOperationOk(resp)) { throw TalerError.fromException( new Error(`request succeed but failure "${s}" was expected`), @@ -201,11 +201,10 @@ export async function alternativeOrThrow<Error, Body, Alt>( return (resp as any).body; } -export async function failOrThrow<E>( +export function failOrThrow<E>( + resp: OperationResult<unknown, E>, s: E, - promise: Promise<OperationResult<unknown, E>>, -): Promise<TalerErrorDetail | undefined> { - const resp = await promise; +): TalerErrorDetail | undefined { if (isOperationOk(resp)) { throw TalerError.fromException( new Error(`request succeed but failure "${s}" was expected`),