taler-util: remove deprecated function

This commit is contained in:
Florian Dold 2023-05-11 14:16:48 +02:00
parent 1d718dda1d
commit edd3a39a0c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 49 additions and 110 deletions

View File

@ -19,11 +19,9 @@
* @author Sebastian Javier Marchano (sebasjm) * @author Sebastian Javier Marchano (sebasjm)
*/ */
import { buildPayto, classifyTalerUri } from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { h, VNode } from "preact"; import { h, VNode } from "preact";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { AsyncButton } from "../../../../components/exception/AsyncButton.js";
import { QR } from "../../../../components/exception/QR.js"; import { QR } from "../../../../components/exception/QR.js";
import { import {
FormErrors, FormErrors,

View File

@ -168,66 +168,6 @@ export enum TalerUriAction {
DevExperiment = "dev-experiment", DevExperiment = "dev-experiment",
} }
/**
* Classify a taler:// URI.
* @deprecated use parseTalerUri
*/
export function classifyTalerUri(s: string): TalerUriType {
const sl = s.toLowerCase();
if (sl.startsWith("taler://restore/")) {
return TalerUriType.TalerRecovery;
}
if (sl.startsWith("taler+http://restore/")) {
return TalerUriType.TalerRecovery;
}
if (sl.startsWith("taler://pay/")) {
return TalerUriType.TalerPay;
}
if (sl.startsWith("taler+http://pay/")) {
return TalerUriType.TalerPay;
}
if (sl.startsWith("taler://pay-template/")) {
return TalerUriType.TalerPayTemplate;
}
if (sl.startsWith("taler+http://pay-template/")) {
return TalerUriType.TalerPayTemplate;
}
if (sl.startsWith("taler://tip/")) {
return TalerUriType.TalerTip;
}
if (sl.startsWith("taler+http://tip/")) {
return TalerUriType.TalerTip;
}
if (sl.startsWith("taler://refund/")) {
return TalerUriType.TalerRefund;
}
if (sl.startsWith("taler+http://refund/")) {
return TalerUriType.TalerRefund;
}
if (sl.startsWith("taler://withdraw/")) {
return TalerUriType.TalerWithdraw;
}
if (sl.startsWith("taler+http://withdraw/")) {
return TalerUriType.TalerWithdraw;
}
if (sl.startsWith(`taler://${talerActionPayPush}/`)) {
return TalerUriType.TalerPayPush;
}
if (sl.startsWith(`taler+http://${talerActionPayPush}/`)) {
return TalerUriType.TalerPayPush;
}
if (sl.startsWith(`taler://${talerActionPayPull}/`)) {
return TalerUriType.TalerPayPull;
}
if (sl.startsWith(`taler+http://${talerActionPayPull}/`)) {
return TalerUriType.TalerPayPull;
}
if (sl.startsWith("taler://dev-experiment/")) {
return TalerUriType.TalerDevExperiment;
}
return TalerUriType.Unknown;
}
interface TalerUriProtoInfo { interface TalerUriProtoInfo {
innerProto: "http" | "https"; innerProto: "http" | "https";
rest: string; rest: string;

View File

@ -21,7 +21,6 @@ import {
AbsoluteTime, AbsoluteTime,
addPaytoQueryParams, addPaytoQueryParams,
AgeRestriction, AgeRestriction,
classifyTalerUri,
codecForList, codecForList,
codecForString, codecForString,
CoreApiResponse, CoreApiResponse,
@ -32,13 +31,14 @@ import {
j2s, j2s,
Logger, Logger,
parsePaytoUri, parsePaytoUri,
parseTalerUri,
PreparePayResultType, PreparePayResultType,
RecoveryMergeStrategy, RecoveryMergeStrategy,
sampleWalletCoreTransactions, sampleWalletCoreTransactions,
setDangerousTimetravel, setDangerousTimetravel,
setGlobalLogLevelFromString, setGlobalLogLevelFromString,
summarizeTalerErrorDetail, summarizeTalerErrorDetail,
TalerUriType, TalerUriAction,
WalletNotification, WalletNotification,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { clk } from "@gnu-taler/taler-util/clk"; import { clk } from "@gnu-taler/taler-util/clk";
@ -639,34 +639,32 @@ walletCli
} else { } else {
uri = await readlinePrompt("Taler URI: "); uri = await readlinePrompt("Taler URI: ");
} }
const uriType = classifyTalerUri(uri); const parsedTalerUri = parseTalerUri(uri);
switch (uriType) { if (!parsedTalerUri) {
case TalerUriType.TalerPay: throw Error("invalid taler URI");
}
switch (parsedTalerUri.type) {
case TalerUriAction.Pay:
await doPay(wallet.client, uri, { await doPay(wallet.client, uri, {
alwaysYes: args.handleUri.autoYes, alwaysYes: args.handleUri.autoYes,
}); });
break; break;
case TalerUriType.TalerTip: case TalerUriAction.Tip: {
{ const res = await wallet.client.call(WalletApiOperation.PrepareTip, {
const res = await wallet.client.call(
WalletApiOperation.PrepareTip,
{
talerTipUri: uri, talerTipUri: uri,
}, });
);
console.log("tip status", res); console.log("tip status", res);
await wallet.client.call(WalletApiOperation.AcceptTip, { await wallet.client.call(WalletApiOperation.AcceptTip, {
walletTipId: res.walletTipId, walletTipId: res.walletTipId,
}); });
}
break; break;
case TalerUriType.TalerRefund: }
case TalerUriAction.Refund:
await wallet.client.call(WalletApiOperation.StartRefundQueryForUri, { await wallet.client.call(WalletApiOperation.StartRefundQueryForUri, {
talerRefundUri: uri, talerRefundUri: uri,
}); });
break; break;
case TalerUriType.TalerWithdraw: case TalerUriAction.Withdraw: {
{
const withdrawInfo = await wallet.client.call( const withdrawInfo = await wallet.client.call(
WalletApiOperation.GetWithdrawalDetailsForUri, WalletApiOperation.GetWithdrawalDetailsForUri,
{ {
@ -693,16 +691,16 @@ walletCli
}, },
); );
console.log("accept withdrawal response", res); console.log("accept withdrawal response", res);
}
break; break;
case TalerUriType.TalerDevExperiment: { }
case TalerUriAction.DevExperiment: {
await wallet.client.call(WalletApiOperation.ApplyDevExperiment, { await wallet.client.call(WalletApiOperation.ApplyDevExperiment, {
devExperimentUri: uri, devExperimentUri: uri,
}); });
break; break;
} }
default: default:
console.log(`URI type (${uriType}) not handled`); console.log(`URI type (${parsedTalerUri}) not handled`);
break; break;
} }
return; return;
@ -1683,3 +1681,6 @@ async function read(stream: NodeJS.ReadStream) {
export function main() { export function main() {
walletCli.run(); walletCli.run();
} }
function classifyTalerUri(uri: string) {
throw new Error("Function not implemented.");
}