From 983d14761eb1c33f4a59211b132f8485b7998bda Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 7 Mar 2024 19:27:41 +0100 Subject: -rewards are gone! --- packages/taler-util/src/taleruri.test.ts | 46 ----------------------------- packages/taler-util/src/taleruri.ts | 50 -------------------------------- 2 files changed, 96 deletions(-) (limited to 'packages/taler-util') diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts index 2ff401abc..ab7a27af6 100644 --- a/packages/taler-util/src/taleruri.test.ts +++ b/packages/taler-util/src/taleruri.test.ts @@ -24,7 +24,6 @@ import { parsePayUri, parseRefundUri, parseRestoreUri, - parseRewardUri, parseWithdrawExchangeUri, parseWithdrawUri, stringifyDevExperimentUri, @@ -34,7 +33,6 @@ import { stringifyPayUri, stringifyRefundUri, stringifyRestoreUri, - stringifyRewardUri, stringifyWithdrawExchange, stringifyWithdrawUri, } from "./taleruri.js"; @@ -218,50 +216,6 @@ test("taler refund URI (stringify)", (t) => { t.deepEqual(url, "taler://refund/merchant.test/instance/pepe/123/"); }); -/** - * 5.4 action: reward https://lsd.gnunet.org/lsd0006/#name-action-tip - */ - -test("taler reward pickup uri", (t) => { - const url1 = "taler://reward/merchant.example.com/tipid"; - const r1 = parseRewardUri(url1); - if (!r1) { - t.fail(); - return; - } - t.is(r1.merchantBaseUrl, "https://merchant.example.com/"); -}); - -test("taler reward pickup uri with instance", (t) => { - const url1 = "taler://reward/merchant.example.com/instances/tipm/tipid/"; - const r1 = parseRewardUri(url1); - if (!r1) { - t.fail(); - return; - } - t.is(r1.merchantBaseUrl, "https://merchant.example.com/instances/tipm/"); - t.is(r1.merchantRewardId, "tipid"); -}); - -test("taler reward pickup uri with instance and prefix", (t) => { - const url1 = "taler://reward/merchant.example.com/my/pfx/tipm/tipid/"; - const r1 = parseRewardUri(url1); - if (!r1) { - t.fail(); - return; - } - t.is(r1.merchantBaseUrl, "https://merchant.example.com/my/pfx/tipm/"); - t.is(r1.merchantRewardId, "tipid"); -}); - -test("taler reward URI (stringify)", (t) => { - const url = stringifyRewardUri({ - merchantBaseUrl: "https://merchant.test/instance/pepe/", - merchantRewardId: "123", - }); - t.deepEqual(url, "taler://reward/merchant.test/instance/pepe/123/"); -}); - /** * 5.5 action: pay-push https://lsd.gnunet.org/lsd0006/#name-action-pay-push */ diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts index 15464b981..9717a7d71 100644 --- a/packages/taler-util/src/taleruri.ts +++ b/packages/taler-util/src/taleruri.ts @@ -39,7 +39,6 @@ export type TalerUri = | PayPushUriResult | BackupRestoreUri | RefundUriResult - | RewardUriResult | WithdrawUriResult | WithdrawExchangeUri; @@ -97,12 +96,6 @@ export interface RefundUriResult { orderId: string; } -export interface RewardUriResult { - type: TalerUriAction.Reward; - merchantBaseUrl: string; - merchantRewardId: string; -} - export interface PayPushUriResult { type: TalerUriAction.PayPush; exchangeBaseUrl: string; @@ -188,7 +181,6 @@ export enum TalerUriAction { Pay = "pay", Withdraw = "withdraw", Refund = "refund", - Reward = "reward", PayPull = "pay-pull", PayPush = "pay-push", PayTemplate = "pay-template", @@ -231,7 +223,6 @@ const parsers: { [A in TalerUriAction]: Parser } = { [TalerUriAction.PayTemplate]: parsePayTemplateUri, [TalerUriAction.Restore]: parseRestoreUri, [TalerUriAction.Refund]: parseRefundUri, - [TalerUriAction.Reward]: parseRewardUri, [TalerUriAction.Withdraw]: parseWithdrawUri, [TalerUriAction.DevExperiment]: parseDevExperimentUri, [TalerUriAction.WithdrawExchange]: parseWithdrawExchangeUri, @@ -272,9 +263,6 @@ export function stringifyTalerUri(uri: TalerUri): string { case TalerUriAction.Refund: { return stringifyRefundUri(uri); } - case TalerUriAction.Reward: { - return stringifyRewardUri(uri); - } case TalerUriAction.Withdraw: { return stringifyWithdrawUri(uri); } @@ -404,36 +392,6 @@ export function parsePayPullUri(s: string): PayPullUriResult | undefined { }; } -/** - * Parse a taler[+http]://reward URI. - * Return undefined if not passed a valid URI. - */ -export function parseRewardUri(s: string): RewardUriResult | undefined { - const pi = parseProtoInfo(s, "reward"); - if (!pi) { - return undefined; - } - const c = pi?.rest.split("?"); - const parts = c[0].split("/"); - if (parts.length < 2) { - return undefined; - } - const host = parts[0].toLowerCase(); - const unused = parts[parts.length - 1]; - const rewardId = parts[parts.length - 2]; - const pathSegments = parts.slice(1, parts.length - 2); - const hostAndSegments = [host, ...pathSegments].join("/"); - const merchantBaseUrl = canonicalizeBaseUrl( - `${pi.innerProto}://${hostAndSegments}/`, - ); - - return { - type: TalerUriAction.Reward, - merchantBaseUrl, - merchantRewardId: rewardId, - }; -} - export function parseWithdrawExchangeUri( s: string, ): WithdrawExchangeUri | undefined { @@ -613,14 +571,6 @@ export function stringifyRefundUri({ return `${proto}://refund/${path}${orderId}/`; } -export function stringifyRewardUri({ - merchantBaseUrl, - merchantRewardId, -}: Omit): string { - const { proto, path } = getUrlInfo(merchantBaseUrl); - return `${proto}://reward/${path}${merchantRewardId}/`; -} - export function stringifyWithdrawUri({ bankIntegrationApiBaseUrl, withdrawalOperationId, -- cgit v1.2.3