taler-typescript-core

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

commit bb3ff21d0ee61c0740cb4c396451ef98a065e5f1
parent a8efc6021208e48a4366c4e91e12515c1b5b1a3e
Author: Florian Dold <dold@taler.net>
Date:   Thu, 24 Sep 2026 22:27:45 +0200

taler-util: add DD98 fountain URIs and merchant HTTP endpoints

Define the public onboarding, metadata and withdrawal messages alongside
the merchant management endpoints. Document the optional
fountain_purpose values on the wire.

Diffstat:
Apackages/taler-util/src/fountain-uri.test.ts | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apackages/taler-util/src/http-client/merchant-fountain.test.ts | 157+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/taler-util/src/http-client/merchant.ts | 140+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mpackages/taler-util/src/index.ts | 1+
Mpackages/taler-util/src/taleruri.ts | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apackages/taler-util/src/types-taler-fountain.ts | 194+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 608 insertions(+), 3 deletions(-)

diff --git a/packages/taler-util/src/fountain-uri.test.ts b/packages/taler-util/src/fountain-uri.test.ts @@ -0,0 +1,64 @@ +/* + This file is part of GNU Taler + (C) 2026 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { encodeCrock } from "./taler-crypto.js"; +import { Result } from "./result.js"; +import { TalerUris, TalerUriAction } from "./taleruri.js"; +const secret = encodeCrock(new Uint8Array(32).fill(17)); +for (const scheme of ["taler", "taler+http"]) { + test(`${scheme} fountain round trip preserves instance path and credential`, () => { + const uri = `${scheme}://fountain/example.com:1234/shop/instances/default/campaign/${secret}`; + const parsed = Result.orUndefined( + TalerUris.parseRestricted(uri, TalerUriAction.Fountain), + ); + assert.ok(parsed); + assert.equal( + parsed.merchantBaseUrl, + `${scheme === "taler" ? "https" : "http"}://example.com:1234/shop/instances/default/`, + ); + assert.equal(parsed.fountainId, "campaign"); + assert.equal(TalerUris.stringify(parsed), uri); + }); +} +test("fountain rejects malformed credentials and IDs without returning the secret", () => { + for (const suffix of [ + "", + "id", + `id/${secret.slice(1)}`, + `../${secret}`, + `id/${"!".repeat(52)}`, + ]) { + const parsed = TalerUris.parse(`taler://fountain/example.com/${suffix}`); + assert.ok(Result.isError(parsed)); + assert.ok(!JSON.stringify(parsed).includes(secret)); + } +}); +test("pay-template preserves challenge, NFC flag and existing parameters", () => { + const uri = `taler://pay-template/example.com/template?challenge=${secret}&nfc=1&amount=KUDOS%3A1&summary=Coffee`; + const p = Result.orUndefined( + TalerUris.parseRestricted(uri, TalerUriAction.PayTemplate), + ); + assert.ok(p); + assert.equal(p.challenge, secret); + assert.equal(p.nfc, true); + assert.deepEqual( + Result.orUndefined(TalerUris.parse(TalerUris.stringify(p))), + p, + ); + assert.ok(Result.isError(TalerUris.parse(`${uri}&challenge=short`))); +}); diff --git a/packages/taler-util/src/http-client/merchant-fountain.test.ts b/packages/taler-util/src/http-client/merchant-fountain.test.ts @@ -0,0 +1,157 @@ +/* + This file is part of GNU Taler + (C) 2026 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + + SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { LongpollQueue } from "../longpoll-queue.js"; +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { CancellationToken } from "../CancellationToken.js"; +import { HttpRequestOptions } from "../http-common.js"; +import { FakeHttpLib } from "../http-fake.js"; +import { TalerMerchantInstanceHttpClient } from "./merchant.js"; +import { encodeCrock } from "../taler-crypto.js"; + +test("fountain HTTP credentials use header/body with redirects disabled and cancellation propagated", async () => { + const fake = new FakeHttpLib() + .on("GET", "/fountain/info", { + status: 200, + body: { poll_freq: { d_us: 1000 }, grants: [] }, + }) + .on("POST", "/fountain/withdraw", { status: 200, body: { grants: [] } }); + const options: HttpRequestOptions[] = []; + const cts = CancellationToken.create(); + const api = new TalerMerchantInstanceHttpClient( + "https://merchant.example/instances/student/", + { + longpollQueue: new LongpollQueue(), + httpClient: { + fetch: (url, opt) => { + options.push(opt!); + return fake.fetch(url, opt); + }, + }, + cancellationToken: cts.token, + }, + ); + const secret = encodeCrock(new Uint8Array(32).fill(17)); + assert.equal((await api.getFountainInfo(secret)).case, "ok"); + assert.equal( + (await api.withdrawFountain({ fountain_secret: secret, grants: [] })).case, + "ok", + ); + assert.equal(fake.requests[0].headers?.Authorization, `Bearer ${secret}`); + assert.deepEqual(fake.requests[1].body, { + fountain_secret: secret, + grants: [], + }); + for (let i = 0; i < options.length; i++) { + assert.ok(!fake.requests[i].url.includes(secret)); + assert.equal(options[i].cancellationToken, cts.token); + assert.equal(options[i].redirect, "error"); + assert.equal(options[i].sensitive, true); + } +}); + +test("fountain management reads authenticate, decode and escape fountain IDs", async () => { + const display = { name: "Students", name_i18n: { de: "Studierende" } }; + const entry = { fountain_id: "id", description: "Campus", ...display }; + const details = { + description: "Campus", + ...display, + extra_data: { campus: { locations: ["library"] } }, + poll_freq: { d_us: "forever" }, + grants: [ + { + token_family_slug: "student", + tokens_per_period_limit: 3, + tokens_per_period_stash: 1, + key_window_size: 2, + }, + ], + }; + const fake = new FakeHttpLib() + .on("GET", "/private/fountains", { + status: 200, + body: { fountains: [entry] }, + }) + .on("GET", "/private/fountains/a%2Fb", { status: 200, body: details }) + .on("PATCH", "/private/fountains/a%2Fb", { status: 204 }); + const options: HttpRequestOptions[] = []; + const cts = CancellationToken.create(); + const api = new TalerMerchantInstanceHttpClient( + "https://merchant.example/shop/instances/campus/", + { + longpollQueue: new LongpollQueue(), + httpClient: { + fetch(url, opt) { + options.push(opt!); + return fake.fetch(url, opt); + }, + }, + cancellationToken: cts.token, + }, + ); + const token = + "secret-token:admin" as import("../types-taler-common.js").AccessToken; + const list = await api.listFountains(token); + assert.equal(list.type, "ok"); + if (list.type === "ok") + assert.deepEqual(list.body.fountains[0], { + ...entry, + fountain_serial: undefined, + }); + const detail = await api.getFountainDetails(token, "a/b"); + assert.equal(detail.type, "ok"); + if (detail.type === "ok") assert.deepEqual(detail.body, details); + for (const opt of options) { + assert.equal(opt.headers?.Authorization, `Bearer ${token}`); + assert.equal(opt.cancellationToken, cts.token); + assert.equal(opt.readOnly, true); + } + assert.equal( + fake.requests[1].url, + "https://merchant.example/shop/instances/campus/private/fountains/a%2Fb", + ); + const clear = { name: null, name_i18n: null, extra_data: null }; + assert.equal((await api.updateFountain(token, "a/b", clear)).case, "ok"); + assert.deepEqual(fake.lastRequest?.body, clear); +}); + +test("fountain management rejects malformed successful responses and preserves HTTP failures", async () => { + const token = + "secret-token:admin" as import("../types-taler-common.js").AccessToken; + const fake = new FakeHttpLib().on("GET", "/private/fountains", { + status: 200, + body: { fountains: [{}] }, + }); + const api = new TalerMerchantInstanceHttpClient("https://merchant.example/", { + httpClient: fake, + longpollQueue: new LongpollQueue(), + }); + await assert.rejects(api.listFountains(token)); + const denied = new TalerMerchantInstanceHttpClient( + "https://merchant.example/", + { + longpollQueue: new LongpollQueue(), + httpClient: new FakeHttpLib().on("GET", "/private/fountains", { + status: 403, + body: { code: 21 }, + }), + }, + ); + assert.equal((await denied.listFountains(token)).case, 403); +}); diff --git a/packages/taler-util/src/http-client/merchant.ts b/packages/taler-util/src/http-client/merchant.ts @@ -16,6 +16,7 @@ import { LongpollQueue } from "../longpoll-queue.js"; import { fetchLongpoll, LongpollObserver } from "../longpoll-http.js"; +import * as FountainApi from "../types-taler-fountain.js"; import { AbsoluteTime, AccessToken, @@ -2606,9 +2607,142 @@ export class TalerMerchantInstanceHttpClient { } } - // - // OTP Devices - // + // Token fountains (DD98). Wallet credentials must stay out of URLs. + async listFountains( + token: AccessToken, + page: { limit?: number; offset?: number } = {}, + ) { + const url = new URL("private/fountains", this.baseUrl); + if (page.limit !== undefined) + url.searchParams.set("limit", String(page.limit)); + if (page.offset !== undefined) + url.searchParams.set("offset", String(page.offset)); + const resp = await this.httpLib.fetch(url.href, { + method: "GET", + readOnly: true, + cancellationToken: this.cancellationToken, + timeout: this.timeout, + headers: { Authorization: makeBearerTokenAuthHeader(token) }, + }); + if (resp.status === HttpStatusCode.Ok) + return opSuccessFromHttp( + resp, + FountainApi.codecForFountainsListResponse(), + ); + return opKnownHttpFailure(resp.status, resp); + } + + async getFountainDetails(token: AccessToken, fountainId: string) { + const resp = await this.httpLib.fetch( + new URL(`private/fountains/${pathSegment(fountainId)}`, this.baseUrl) + .href, + { + method: "GET", + readOnly: true, + cancellationToken: this.cancellationToken, + timeout: this.timeout, + headers: { Authorization: makeBearerTokenAuthHeader(token) }, + }, + ); + if (resp.status === HttpStatusCode.Ok) + return opSuccessFromHttp( + resp, + FountainApi.codecForMerchantFountainDetails(), + ); + return opKnownHttpFailure(resp.status, resp); + } + + async getFountainInfo(secret: string) { + const resp = await this.httpLib.fetch( + new URL("fountain/info", this.baseUrl).href, + { + method: "GET", + redirect: "error", + sensitive: true, + cancellationToken: this.cancellationToken, + timeout: this.timeout, + headers: { Authorization: `Bearer ${secret}` }, + }, + ); + if (resp.status === HttpStatusCode.Ok) + return opSuccessFromHttp( + resp, + FountainApi.codecForFountainInfoResponse(), + ); + return opKnownHttpFailure(resp.status, resp); + } + + async withdrawFountain(body: FountainApi.FountainWithdrawRequest) { + const resp = await this.httpLib.fetch( + new URL("fountain/withdraw", this.baseUrl).href, + { + method: "POST", + body, + redirect: "error", + sensitive: true, + cancellationToken: this.cancellationToken, + timeout: this.timeout, + }, + ); + if (resp.status === HttpStatusCode.Ok) + return opSuccessFromHttp( + resp, + FountainApi.codecForFountainWithdrawResponse(), + ); + return opKnownHttpFailure(resp.status, resp); + } + + async createFountain( + token: AccessToken, + body: FountainApi.FountainCreateRequest, + ) { + const resp = await this.httpLib.fetch( + new URL("private/fountains", this.baseUrl).href, + { + method: "POST", + body, + sensitive: true, + headers: { Authorization: makeBearerTokenAuthHeader(token) }, + }, + ); + if (resp.status === HttpStatusCode.Ok) + return opSuccessFromHttp( + resp, + FountainApi.codecForFountainCreateResponse(), + ); + return opKnownHttpFailure(resp.status, resp); + } + + async updateFountain( + token: AccessToken, + fountainId: string, + body: FountainApi.FountainPatchRequest, + ) { + const resp = await this.httpLib.fetch( + new URL(`private/fountains/${pathSegment(fountainId)}`, this.baseUrl) + .href, + { + method: "PATCH", + body, + headers: { Authorization: makeBearerTokenAuthHeader(token) }, + }, + ); + if (resp.status === HttpStatusCode.NoContent) return opEmptySuccess(resp); + return opKnownHttpFailure(resp.status, resp); + } + + async deleteFountain(token: AccessToken, fountainId: string) { + const resp = await this.httpLib.fetch( + new URL(`private/fountains/${pathSegment(fountainId)}`, this.baseUrl) + .href, + { + method: "DELETE", + headers: { Authorization: makeBearerTokenAuthHeader(token) }, + }, + ); + if (resp.status === HttpStatusCode.NoContent) return opEmptySuccess(resp); + return opKnownHttpFailure(resp.status, resp); + } /** * https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-otp-devices diff --git a/packages/taler-util/src/index.ts b/packages/taler-util/src/index.ts @@ -116,3 +116,4 @@ export * from "./result.js"; export * from "./user-attention.js"; export * from "./challenge-confirmation.js"; +export * from "./types-taler-fountain.js"; diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts @@ -62,6 +62,7 @@ export enum TalerUriAction { * https://lsd.gnunet.org/lsd0006/#section-5.6 */ PayTemplate = "pay-template", + Fountain = "fountain", /** * https://lsd.gnunet.org/lsd0006/#section-5.7 */ @@ -94,6 +95,7 @@ export enum TalerUriAction { */ export type TalerUri = | TalerPayUriResult + | TalerFountainUri | TalerPayTemplateUri | TalerDevExperimentUri | TalerPayPullUri @@ -217,6 +219,7 @@ export namespace TalerUris { pay: true, "pay-pull": true, "pay-template": true, + fountain: true, "pay-push": true, "withdraw-exchange": true, refund: true, @@ -298,6 +301,7 @@ export namespace TalerUris { return result; } case TalerUriAction.PayPull: + case TalerUriAction.Fountain: case TalerUriAction.Refund: case TalerUriAction.PayPush: case TalerUriAction.Restore: @@ -319,6 +323,7 @@ export namespace TalerUris { case TalerUriAction.Pay: case TalerUriAction.Refund: case TalerUriAction.PayTemplate: + case TalerUriAction.Fountain: return p.merchantBaseUrl.startsWith("http://") ? TALER_HTTP_PREFIX : TALER_PREFIX; @@ -357,6 +362,8 @@ export namespace TalerUris { case TalerUriAction.Refund: // refund should end with a / return `/${servicePrefix(p.merchantBaseUrl)}${encodeRequiredUriSegment(p.orderId)}/`; + case TalerUriAction.Fountain: + return `/${servicePrefix(p.merchantBaseUrl)}${encodeUriSegment(p.fountainId)}/${encodeUriSegment(p.fountainSecret)}`; case TalerUriAction.PayTemplate: return `/${servicePrefix(p.merchantBaseUrl)}${encodeRequiredUriSegment(p.templateId)}`; case TalerUriAction.PayPush: @@ -408,6 +415,7 @@ export namespace TalerUris { export type InvalidTargetPathDetail = | { uriType: TalerUriAction.Restore } | { uriType: TalerUriAction.AddExchange; pos: 0 } + | { uriType: TalerUriAction.Fountain; pos: 0 | 1 | 2 } | { uriType: | TalerUriAction.Pay @@ -508,6 +516,8 @@ export namespace TalerUris { case TalerUriAction.PayPull: case TalerUriAction.PayPush: return parsePeerPayment(scheme, uriType, segments, opts); + case TalerUriAction.Fountain: + return parseFountain(scheme, segments); case TalerUriAction.PayTemplate: return parsePayTemplate(scheme, uriType, segments, params, opts); case TalerUriAction.Restore: @@ -1085,6 +1095,13 @@ export type TemplateParams = { summary?: string; }; +export interface TalerFountainUri { + type: TalerUriAction.Fountain; + merchantBaseUrl: HostPortPath; + fountainId: string; + fountainSecret: string; +} + export interface TalerPayTemplateUri { challenge?: string; type: TalerUriAction.PayTemplate; @@ -1228,3 +1245,41 @@ function createSearchParams(paramList: [string, string][]): string { .map(([key, value]) => `${rfc3986(key)}=${rfc3986(value)}`) .join("&"); } + +function parseFountain( + scheme: "http" | "https", + cs: string[], +): TalerUris.ParseResult { + const uriType = TalerUriAction.Fountain; + if (cs.length < 3) + return Result.errorWithDetail(TalerUriParseError.COMPONENTS_LENGTH, { + uriType, + }); + const merchant = Paytos.parseServiceBaseUrl(cs.slice(0, -2), scheme); + if (!merchant) + return Result.errorWithDetail(TalerUriParseError.INVALID_TARGET_PATH, { + uriType, + pos: 0, + } as const); + const fountainId = decodeUriSegment(cs[cs.length - 2]); + if (!fountainId || !/^[a-zA-Z0-9_-]+$/.test(fountainId)) + return Result.errorWithDetail(TalerUriParseError.INVALID_TARGET_PATH, { + uriType, + pos: 1, + } as const); + const fountainSecret = decodeUriSegment(cs[cs.length - 1]); + try { + decodeCrockFixed(fountainSecret, 32); + } catch { + return Result.errorWithDetail(TalerUriParseError.INVALID_TARGET_PATH, { + uriType, + pos: 2, + } as const); + } + return Result.of({ + type: uriType, + merchantBaseUrl: canonicalizeMerchantInstanceUrl(merchant) as HostPortPath, + fountainId, + fountainSecret, + }); +} diff --git a/packages/taler-util/src/types-taler-fountain.ts b/packages/taler-util/src/types-taler-fountain.ts @@ -0,0 +1,194 @@ +/* + This file is part of GNU Taler + (C) 2026 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + + SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { + buildCodecForObject, + Codec, + codecForAny, + codecForList, + codecForMap, + codecForNumber, + codecOptional, + codecForString, +} from "./codec.js"; +import { + codecForInternationalizedString, + InternationalizedString, +} from "./types-taler-common.js"; +import { + codecForDuration, + TalerProtocolDuration, + TalerProtocolTimestamp, +} from "./time.js"; +import { + codecForMerchantContractTokenFamily, + codecForSignedTokenEnvelope, + MerchantContractTokenFamily, + SignedTokenEnvelope, + TokenEnvelope, +} from "./types-taler-merchant.js"; + +export interface FountainGrant { + token_family_slug: string; + tokens_per_period_limit: number; + tokens_per_period_stash: number; + key_window_size: number; +} +export interface FountainWalletGrant extends FountainGrant { + token_family: MerchantContractTokenFamily; +} +export enum FountainPurpose { + AccessCard = "access-card", + Promotion = "promotion", +} + +interface FountainDisplayMetadata { + name?: string; + name_i18n?: InternationalizedString; + extra_data?: Record<string, unknown>; +} +export interface FountainInfoResponse extends FountainDisplayMetadata { + poll_freq: TalerProtocolDuration; + grants: FountainWalletGrant[]; +} +export interface FountainGrantWithdrawal { + token_family_slug: string; + valid_at?: TalerProtocolTimestamp; + envelopes: TokenEnvelope[]; +} +export interface FountainWithdrawRequest { + fountain_secret: string; + grants: FountainGrantWithdrawal[]; +} +export interface FountainGrantWithdrawalResult { + token_family_slug: string; + h_issue: string; + token_sigs: SignedTokenEnvelope[]; +} +export interface FountainWithdrawResponse { + grants: FountainGrantWithdrawalResult[]; +} +export interface FountainCreateRequest extends FountainDisplayMetadata { + description: string; + poll_freq: TalerProtocolDuration; + grants: FountainGrant[]; +} +export interface FountainPatchRequest { + description?: string; + poll_freq?: TalerProtocolDuration; + grants?: FountainGrant[]; + name?: string | null; + name_i18n?: InternationalizedString | null; + extra_data?: Record<string, unknown> | null; +} +export interface FountainCreateResponse { + fountain_id: string; + fountain_secret: string; +} +export interface FountainEntry extends Pick< + FountainDisplayMetadata, + "name" | "name_i18n" +> { + /** Exclusive cursor, available since merchant protocol v44. */ + fountain_serial?: number; + fountain_id: string; + description: string; +} +export interface FountainsListResponse { + fountains: FountainEntry[]; +} +/** Configuration exposed to merchant administrators; never includes the secret. */ +export interface MerchantFountainDetails extends FountainCreateRequest {} + +export const codecForFountainsListResponse = (): Codec<FountainsListResponse> => + buildCodecForObject<FountainsListResponse>() + .property( + "fountains", + codecForList( + buildCodecForObject<FountainEntry>() + .property("fountain_serial", codecOptional(codecForNumber())) + .property("fountain_id", codecForString()) + .property("description", codecForString()) + .property("name", codecOptional(codecForString())) + .property( + "name_i18n", + codecOptional(codecForInternationalizedString()), + ) + .build("FountainEntry"), + ), + ) + .build("FountainsListResponse"); +export const codecForMerchantFountainDetails = + (): Codec<MerchantFountainDetails> => + buildCodecForObject<MerchantFountainDetails>() + .property("description", codecForString()) + .property("name", codecOptional(codecForString())) + .property("name_i18n", codecOptional(codecForInternationalizedString())) + .property("extra_data", codecOptional(codecForMap(codecForAny()))) + .property("poll_freq", codecForDuration) + .property( + "grants", + codecForList( + buildCodecForObject<FountainGrant>() + .property("token_family_slug", codecForString()) + .property("tokens_per_period_limit", codecForNumber()) + .property("tokens_per_period_stash", codecForNumber()) + .property("key_window_size", codecForNumber()) + .build("FountainGrant"), + ), + ) + .build("MerchantFountainDetails"); + +export const codecForFountainWalletGrant = (): Codec<FountainWalletGrant> => + buildCodecForObject<FountainWalletGrant>() + .property("token_family_slug", codecForString()) + .property("tokens_per_period_limit", codecForNumber()) + .property("tokens_per_period_stash", codecForNumber()) + .property("key_window_size", codecForNumber()) + .property("token_family", codecForMerchantContractTokenFamily()) + .build("FountainWalletGrant"); +export const codecForFountainInfoResponse = (): Codec<FountainInfoResponse> => + buildCodecForObject<FountainInfoResponse>() + // Some merchants also send their administrative description. + .deprecatedProperty("description") + .property("name", codecOptional(codecForString())) + .property("name_i18n", codecOptional(codecForInternationalizedString())) + .property("extra_data", codecOptional(codecForMap(codecForAny()))) + .property("poll_freq", codecForDuration) + .property("grants", codecForList(codecForFountainWalletGrant())) + .build("FountainInfoResponse"); +export const codecForFountainWithdrawResponse = + (): Codec<FountainWithdrawResponse> => + buildCodecForObject<FountainWithdrawResponse>() + .property( + "grants", + codecForList( + buildCodecForObject<FountainGrantWithdrawalResult>() + .property("token_family_slug", codecForString()) + .property("h_issue", codecForString()) + .property("token_sigs", codecForList(codecForSignedTokenEnvelope())) + .build("FountainGrantWithdrawalResult"), + ), + ) + .build("FountainWithdrawResponse"); +export const codecForFountainCreateResponse = + (): Codec<FountainCreateResponse> => + buildCodecForObject<FountainCreateResponse>() + .property("fountain_id", codecForString()) + .property("fountain_secret", codecForString()) + .build("FountainCreateResponse");