summaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-client/exchange.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src/http-client/exchange.ts')
-rw-r--r--packages/taler-util/src/http-client/exchange.ts31
1 files changed, 30 insertions, 1 deletions
diff --git a/packages/taler-util/src/http-client/exchange.ts b/packages/taler-util/src/http-client/exchange.ts
index ea7f44cf9..68d68267f 100644
--- a/packages/taler-util/src/http-client/exchange.ts
+++ b/packages/taler-util/src/http-client/exchange.ts
@@ -33,7 +33,7 @@ import {
codecForExchangeConfig,
codecForExchangeKeys,
} from "./types.js";
-import { addPaginationParams } from "./utils.js";
+import { CacheEvictor, addPaginationParams, nullEvictor } from "./utils.js";
export type TalerExchangeResultByMethod<
prop extends keyof TalerExchangeHttpClient,
@@ -42,17 +42,25 @@ export type TalerExchangeErrorsByMethod<
prop extends keyof TalerExchangeHttpClient,
> = FailCasesByMethod<TalerExchangeHttpClient, prop>;
+export enum TalerExchangeCacheEviction {
+ CREATE_DESCISION,
+}
+
+
/**
*/
export class TalerExchangeHttpClient {
httpLib: HttpRequestLibrary;
public readonly PROTOCOL_VERSION = "18:0:1";
+ cacheEvictor: CacheEvictor<TalerExchangeCacheEviction>;
constructor(
readonly baseUrl: string,
httpClient?: HttpRequestLibrary,
+ cacheEvictor?: CacheEvictor<TalerExchangeCacheEviction>,
) {
this.httpLib = httpClient ?? createPlatformHttpLib();
+ this.cacheEvictor = cacheEvictor ?? nullEvictor;
}
isCompatible(version: string): boolean {
@@ -60,6 +68,27 @@ export class TalerExchangeHttpClient {
return compare?.compatible ?? false;
}
/**
+ * https://docs.taler.net/core/api-exchange.html#get--seed
+ *
+ */
+ async getSeed() {
+ const url = new URL(`seed`, this.baseUrl);
+ const resp = await this.httpLib.fetch(url.href, {
+ method: "GET",
+ });
+ switch (resp.status) {
+ case HttpStatusCode.Ok:
+ const buffer = await resp.bytes();
+ const uintar = new Uint8Array(buffer);
+
+ return opFixedSuccess(uintar);
+ case HttpStatusCode.NotFound:
+ return opKnownHttpFailure(resp.status, resp);
+ default:
+ return opUnknownFailure(resp, await readTalerErrorResponse(resp));
+ }
+ }
+ /**
* https://docs.taler.net/core/api-exchange.html#get--config
*
*/