diff options
Diffstat (limited to 'packages/taler-util/src/http-client/exchange.ts')
-rw-r--r-- | packages/taler-util/src/http-client/exchange.ts | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/packages/taler-util/src/http-client/exchange.ts b/packages/taler-util/src/http-client/exchange.ts index f55be0043..36adb5a1a 100644 --- a/packages/taler-util/src/http-client/exchange.ts +++ b/packages/taler-util/src/http-client/exchange.ts @@ -3,7 +3,7 @@ import { HttpStatusCode } from "../http-status-codes.js"; import { createPlatformHttpLib } from "../http.js"; import { LibtoolVersion } from "../libtool-version.js"; import { hash } from "../nacl-fast.js"; -import { FailCasesByMethod, ResultByMethod, opEmptySuccess, opFixedSuccess, opKnownFailure, opSuccess, opUnknownFailure } from "../operation.js"; +import { FailCasesByMethod, ResultByMethod, opEmptySuccess, opFixedSuccess, opKnownHttpFailure, opSuccess, opUnknownFailure } from "../operation.js"; import { TalerSignaturePurpose, amountToBuffer, bufferForUint32, buildSigPS, decodeCrock, eddsaSign, encodeCrock, stringToBytes, timestampRoundedToBuffer } from "../taler-crypto.js"; import { OfficerAccount, PaginationParams, SigningKey, TalerExchangeApi, codecForAmlDecisionDetails, codecForAmlRecords, codecForExchangeConfig } from "./types.js"; import { addPaginationParams } from "./utils.js"; @@ -15,7 +15,7 @@ export type TalerExchangeErrorsByMethod<prop extends keyof TalerExchangeHttpClie */ export class TalerExchangeHttpClient { httpLib: HttpRequestLibrary; - public readonly PROTOCOL_VERSION = "17:0:0"; + public readonly PROTOCOL_VERSION = "18:0:1"; constructor( readonly baseUrl: string, @@ -43,6 +43,9 @@ export class TalerExchangeHttpClient { } } + // TERMS + + // // AML operations // @@ -66,10 +69,10 @@ export class TalerExchangeHttpClient { case HttpStatusCode.Ok: return opSuccess(resp, codecForAmlRecords()) case HttpStatusCode.NoContent: return opFixedSuccess({ records: [] }) //this should be unauthorized - case HttpStatusCode.Forbidden: return opKnownFailure("unauthorized", resp); - case HttpStatusCode.Unauthorized: return opKnownFailure("unauthorized", resp); - case HttpStatusCode.NotFound: return opKnownFailure("officer-not-found", resp); - case HttpStatusCode.Conflict: return opKnownFailure("officer-disabled", resp); + case HttpStatusCode.Forbidden: return opKnownHttpFailure(resp.status, resp); + case HttpStatusCode.Unauthorized: return opKnownHttpFailure(resp.status, resp); + case HttpStatusCode.NotFound: return opKnownHttpFailure(resp.status, resp); + case HttpStatusCode.Conflict: return opKnownHttpFailure(resp.status, resp); default: return opUnknownFailure(resp, await resp.text()) } } @@ -92,10 +95,10 @@ export class TalerExchangeHttpClient { case HttpStatusCode.Ok: return opSuccess(resp, codecForAmlDecisionDetails()) case HttpStatusCode.NoContent: return opFixedSuccess({ aml_history: [], kyc_attributes: [] }) //this should be unauthorized - case HttpStatusCode.Forbidden: return opKnownFailure("unauthorized", resp); - case HttpStatusCode.Unauthorized: return opKnownFailure("unauthorized", resp); - case HttpStatusCode.NotFound: return opKnownFailure("officer-not-found", resp); - case HttpStatusCode.Conflict: return opKnownFailure("officer-disabled", resp); + case HttpStatusCode.Forbidden: return opKnownHttpFailure(resp.status, resp); + case HttpStatusCode.Unauthorized: return opKnownHttpFailure(resp.status, resp); + case HttpStatusCode.NotFound: return opKnownHttpFailure(resp.status, resp); + case HttpStatusCode.Conflict: return opKnownHttpFailure(resp.status, resp); default: return opUnknownFailure(resp, await resp.text()) } } @@ -116,11 +119,11 @@ export class TalerExchangeHttpClient { switch (resp.status) { case HttpStatusCode.NoContent: return opEmptySuccess() //FIXME: this should be unauthorized - case HttpStatusCode.Forbidden: return opKnownFailure("unauthorized", resp); - case HttpStatusCode.Unauthorized: return opKnownFailure("unauthorized", resp); + case HttpStatusCode.Forbidden: return opKnownHttpFailure(resp.status, resp); + case HttpStatusCode.Unauthorized: return opKnownHttpFailure(resp.status, resp); //FIXME: this two need to be splitted by error code - case HttpStatusCode.NotFound: return opKnownFailure("officer-or-account-not-found", resp); - case HttpStatusCode.Conflict: return opKnownFailure("officer-disabled-or-recent-decision", resp); + case HttpStatusCode.NotFound: return opKnownHttpFailure(resp.status, resp); + case HttpStatusCode.Conflict: return opKnownHttpFailure(resp.status, resp); default: return opUnknownFailure(resp, await resp.text()) } } |