diff options
Diffstat (limited to 'packages/taler-util/src/taleruri.ts')
-rw-r--r-- | packages/taler-util/src/taleruri.ts | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts index b4f9db6ef..54b7525e3 100644 --- a/packages/taler-util/src/taleruri.ts +++ b/packages/taler-util/src/taleruri.ts @@ -83,7 +83,6 @@ export interface PayTemplateUriResult { type: TalerUriAction.PayTemplate; merchantBaseUrl: string; templateId: string; - templateParams: TemplateParams; } export interface WithdrawUriResult { @@ -124,7 +123,6 @@ export interface BackupRestoreUri { export interface WithdrawExchangeUri { type: TalerUriAction.WithdrawExchange; exchangeBaseUrl: string; - exchangePub?: string; amount?: AmountString; } @@ -212,9 +210,7 @@ export function parseAddExchangeUriWithError(s: string) { const result: AddExchangeUri = { type: TalerUriAction.AddExchange, - exchangeBaseUrl: canonicalizeBaseUrl( - `${pi.body.innerProto}://${p}/`, - ), + exchangeBaseUrl: canonicalizeBaseUrl(`${pi.body.innerProto}://${p}/`), }; return opFixedSuccess(result); } @@ -440,7 +436,6 @@ export function parsePayTemplateUri( type: TalerUriAction.PayTemplate, merchantBaseUrl, templateId, - templateParams: params, }; } @@ -507,7 +502,14 @@ export function parseWithdrawExchangeUri( return undefined; } const host = parts[0].toLowerCase(); - const exchangePub = parts.length > 1 ? parts[parts.length - 1] : undefined; + // Used to be the reserve public key, now it's empty! + const lastPathComponent = + parts.length > 1 ? parts[parts.length - 1] : undefined; + + if (lastPathComponent) { + // invalid taler://withdraw-exchange URI, must end with a slash + return undefined; + } const pathSegments = parts.slice(1, parts.length - 1); const hostAndSegments = [host, ...pathSegments].join("/"); const exchangeBaseUrl = canonicalizeBaseUrl( @@ -519,7 +521,6 @@ export function parseWithdrawExchangeUri( return { type: TalerUriAction.WithdrawExchange, exchangeBaseUrl, - exchangePub: exchangePub != "" ? exchangePub : undefined, amount, }; } @@ -641,13 +642,12 @@ export function stringifyRestoreUri({ export function stringifyWithdrawExchange({ exchangeBaseUrl, - exchangePub, amount, }: Omit<WithdrawExchangeUri, "type">): string { const { proto, path, query } = getUrlInfo(exchangeBaseUrl, { a: amount, }); - return `${proto}://withdraw-exchange/${path}${exchangePub ?? ""}${query}`; + return `${proto}://withdraw-exchange/${path}${query}`; } export function stringifyAddExchange({ @@ -666,9 +666,8 @@ export function stringifyDevExperimentUri({ export function stringifyPayTemplateUri({ merchantBaseUrl, templateId, - templateParams, }: Omit<PayTemplateUriResult, "type">): string { - const { proto, path, query } = getUrlInfo(merchantBaseUrl, templateParams); + const { proto, path, query } = getUrlInfo(merchantBaseUrl); return `${proto}://pay-template/${path}${templateId}${query}`; } |