taler-typescript-core

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

commit eba882f7a8ba65d6159e1bd4355f388535268612
parent 5bc4e9bd9d53c3aff27fbe445583cf95378fa189
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu, 17 Apr 2025 12:21:18 -0300

fix spec compat

Diffstat:
Mpackages/taler-util/src/http-client/bank-core.ts | 2++
Mpackages/taler-util/src/http-client/challenger.ts | 6+-----
Mpackages/taler-util/src/http-client/exchange.ts | 2+-
Mpackages/taler-util/src/types-taler-challenger.ts | 8++++++++
Mpackages/taler-util/src/types-taler-exchange.ts | 7+++++--
5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/packages/taler-util/src/http-client/bank-core.ts b/packages/taler-util/src/http-client/bank-core.ts @@ -1066,6 +1066,7 @@ export class TalerCoreBankHttpClient { */ async sendChallenge(auth: UserAndToken, cid: string) { // Should have the same argument and response type than sendLoginChallenge + // but it uses a different auth header return this.__interal_sendChallenge( auth.username, makeBearerTokenAuthHeader(auth.token), @@ -1079,6 +1080,7 @@ export class TalerCoreBankHttpClient { */ async sendLoginChallenge(auth: UserAndPassword, cid: string) { // Should have the same argument and response type than sendChallenge + // but it uses a different auth header return this.__interal_sendChallenge( auth.username, makeBasicAuthHeader(auth.username, auth.password), diff --git a/packages/taler-util/src/http-client/challenger.ts b/packages/taler-util/src/http-client/challenger.ts @@ -172,11 +172,7 @@ export class ChallengerHttpClient { const resp = await this.httpLib.fetch(url.href, { method: "POST", - body: new URLSearchParams(Object.entries(body)).toString(), - headers: { - "Content-Type": "application/x-www-form-urlencoded", - }, - redirect: "manual", + body, }); switch (resp.status) { case HttpStatusCode.Ok: { diff --git a/packages/taler-util/src/http-client/exchange.ts b/packages/taler-util/src/http-client/exchange.ts @@ -741,7 +741,7 @@ export class TalerExchangeHttpClient { * https://docs.taler.net/core/api-exchange.html#post--kyc-upload-$ID * */ - async uploadKycForm(requirement: KycRequirementInformationId, body: ExchangeKycUploadFormRequest) { + async uploadKycForm<T extends ExchangeKycUploadFormRequest>(requirement: KycRequirementInformationId, body: T) { const url = new URL(`kyc-upload/${requirement}`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { diff --git a/packages/taler-util/src/types-taler-challenger.ts b/packages/taler-util/src/types-taler-challenger.ts @@ -130,6 +130,9 @@ export interface ChallengeCreateResponse { // might make a useful hint to the user transmitted: boolean; + // FIXME: not in the spec + nonce?: string; + // timestamp explaining when we would re-transmit the challenge the next // time (at the earliest) if requested by the user retransmission_time: TalerProtocolTimestamp; @@ -144,6 +147,9 @@ export interface InvalidPinResponse { // compactly for reporting to developers ec?: number; + // FIXME: not documented + code?: number; + // human-readable Taler error code, should be shown for the user to // understand the error hint: string; @@ -245,6 +251,7 @@ export const codecForChallengeCreateResponse = buildCodecForObject<ChallengeCreateResponse>() .property("attempts_left", codecForNumber()) .property("type", codecForConstString("created")) + .property("nonce", codecOptional(codecForString())) .property("address", codecForAny()) .property("transmitted", codecForBoolean()) .property("retransmission_time", codecForTimestamp) @@ -260,6 +267,7 @@ export const codecForChallengeInvalidPinResponse = (): Codec<InvalidPinResponse> => buildCodecForObject<InvalidPinResponse>() .property("ec", codecOptional(codecForNumber())) + .property("code", codecOptional(codecForNumber())) .property("hint", codecForAny()) .property("type", codecForConstString("pending")) .property("addresses_left", codecForNumber()) diff --git a/packages/taler-util/src/types-taler-exchange.ts b/packages/taler-util/src/types-taler-exchange.ts @@ -38,6 +38,7 @@ import { codecForURN, codecOptionalDefault, strcmp, + TalerFormAttributes, } from "./index.js"; import { Edx25519PublicKeyEnc } from "./taler-crypto.js"; import { @@ -1839,10 +1840,12 @@ export interface KycRequirementInformation { id?: KycRequirementInformationId; } -export interface ExchangeKycUploadFormRequest { +export type ExchangeKycUploadFormRequest = { // Which form is being submitted. Further details depend on the form. // @since protocol v26. - form_id: string; + // form_id: string; + [TalerFormAttributes.FORM_ID] : string; + [TalerFormAttributes.FORM_VERSION] : number; } // Since **vATTEST**.