[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 05/08: use stringify taler util
From: |
gnunet |
Subject: |
[taler-wallet-core] 05/08: use stringify taler util |
Date: |
Mon, 07 Aug 2023 13:14:55 +0200 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit ef148b1501e6820a75e4e5c8b29ce88d54fd2783
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Mon Aug 7 06:51:45 2023 -0300
use stringify taler util
---
.../src/paths/instance/templates/qr/QrPage.tsx | 40 ++++++++++++----------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git
a/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx
b/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx
index 90084f113..0f30efafd 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx
@@ -34,6 +34,7 @@ import { useBackendContext } from
"../../../../context/backend.js";
import { useConfigContext } from "../../../../context/config.js";
import { useInstanceContext } from "../../../../context/instance.js";
import { MerchantBackend } from "../../../../declaration.js";
+import { stringifyPayTemplateUri } from "@gnu-taler/taler-util";
type Entity = MerchantBackend.Template.UsingTemplateDetails;
@@ -64,46 +65,47 @@ export function QrPage({ template, id: templateId, onBack
}: Props): VNode {
const fixedAmount = !!template.template_contract.amount;
const fixedSummary = !!template.template_contract.summary;
- const params = new URLSearchParams();
+ const templateParams: Record<string, string> = {}
if (!fixedAmount) {
if (state.amount) {
- params.append("amount", state.amount);
+ templateParams.amount = state.amount
} else {
- params.append("amount", config.currency);
+ templateParams.amount = config.currency
}
}
+
if (!fixedSummary) {
- params.append("summary", state.summary ?? "");
+ templateParams.summary = state.summary ?? ""
}
- const paramsStr = fixedAmount && fixedSummary ? "" : "?" + params.toString();
- const merchantURL = new URL(backendUrl);
-
- const talerProto =
- merchantURL.protocol === "http:" ? "taler+http:" : "taler:";
+ const merchantBaseUrl = new URL(backendUrl).href;
- const payTemplateUri =
`${talerProto}//pay-template/${merchantURL.hostname}/${templateId}${paramsStr}`;
+ const payTemplateUri = stringifyPayTemplateUri({
+ merchantBaseUrl,
+ templateId,
+ templateParams
+ })
const issuer = encodeURIComponent(
- `${new URL(backendUrl).hostname}/${instanceId}`,
+ `${new URL(backendUrl).host}/${instanceId}`,
);
const oauthUri = !template.pos_algorithm
? undefined
: template.pos_algorithm === 1
- ?
`otpauth://totp/${issuer}:${templateId}?secret=${template.pos_key}&issuer=${issuer}&algorithm=SHA1&digits=8&period=30`
- : template.pos_algorithm === 2
- ?
`otpauth://totp/${issuer}:${templateId}?secret=${template.pos_key}&issuer=${issuer}&algorithm=SHA1&digits=8&period=30`
- : undefined;
+ ?
`otpauth://totp/${issuer}:${templateId}?secret=${template.pos_key}&issuer=${issuer}&algorithm=SHA1&digits=8&period=30`
+ : template.pos_algorithm === 2
+ ?
`otpauth://totp/${issuer}:${templateId}?secret=${template.pos_key}&issuer=${issuer}&algorithm=SHA1&digits=8&period=30`
+ : undefined;
const keySlice = template.pos_key?.substring(0, 4);
const oauthUriWithoutSecret = !template.pos_algorithm
? undefined
: template.pos_algorithm === 1
- ?
`otpauth://totp/${issuer}:${templateId}?secret=${keySlice}...&issuer=${issuer}&algorithm=SHA1&digits=8&period=30`
- : template.pos_algorithm === 2
- ?
`otpauth://totp/${issuer}:${templateId}?secret=${keySlice}...&issuer=${issuer}&algorithm=SHA1&digits=8&period=30`
- : undefined;
+ ?
`otpauth://totp/${issuer}:${templateId}?secret=${keySlice}...&issuer=${issuer}&algorithm=SHA1&digits=8&period=30`
+ : template.pos_algorithm === 2
+ ?
`otpauth://totp/${issuer}:${templateId}?secret=${keySlice}...&issuer=${issuer}&algorithm=SHA1&digits=8&period=30`
+ : undefined;
return (
<div>
{oauthUri && (
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-wallet-core] branch master updated (44aeaba7b -> a204105b5), gnunet, 2023/08/07
- [taler-wallet-core] 03/08: ui settings view, gnunet, 2023/08/07
- [taler-wallet-core] 06/08: show simple order creation unless advance mode is selected, gnunet, 2023/08/07
- [taler-wallet-core] 07/08: show next expiration, gnunet, 2023/08/07
- [taler-wallet-core] 02/08: fix: support for empty strings, gnunet, 2023/08/07
- [taler-wallet-core] 01/08: accesstoken in memory and better login when switching between accounts, gnunet, 2023/08/07
- [taler-wallet-core] 04/08: fix date query parameter, gnunet, 2023/08/07
- [taler-wallet-core] 05/08: use stringify taler util,
gnunet <=
- [taler-wallet-core] 08/08: show advance mode in settings view, gnunet, 2023/08/07