diff options
Diffstat (limited to 'packages/taler-util/src/taleruri.ts')
-rw-r--r-- | packages/taler-util/src/taleruri.ts | 80 |
1 files changed, 18 insertions, 62 deletions
diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts index ff164dbbd..8f37dfe76 100644 --- a/packages/taler-util/src/taleruri.ts +++ b/packages/taler-util/src/taleruri.ts @@ -14,11 +14,23 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ +/** + * @fileoverview + * Construction and parsing of taler:// URIs. + * Specification: https://lsd.gnunet.org/lsd0006/ + */ + +/** + * Imports. + */ import { Codec, Context, DecodingError, renderContext } from "./codec.js"; import { canonicalizeBaseUrl } from "./helpers.js"; import { AmountString } from "./taler-types.js"; -import { URLSearchParams, URL } from "./url.js"; +import { URL, URLSearchParams } from "./url.js"; +/** + * A parsed taler URI. + */ export type TalerUri = | PayUriResult | PayTemplateUriResult @@ -181,10 +193,6 @@ export enum TalerUriType { Unknown = "unknown", } -const talerActionPayPull = "pay-pull"; -const talerActionPayPush = "pay-push"; -const talerActionPayTemplate = "pay-template"; - export enum TalerUriAction { Pay = "pay", Withdraw = "withdraw", @@ -332,7 +340,7 @@ export function parsePayUri(s: string): PayUriResult | undefined { export function parsePayTemplateUri( uriString: string, ): PayTemplateUriResult | undefined { - const pi = parseProtoInfo(uriString, talerActionPayTemplate); + const pi = parseProtoInfo(uriString, TalerUriAction.PayTemplate); if (!pi) { return undefined; } @@ -366,7 +374,7 @@ export function parsePayTemplateUri( } export function parsePayPushUri(s: string): PayPushUriResult | undefined { - const pi = parseProtoInfo(s, talerActionPayPush); + const pi = parseProtoInfo(s, TalerUriAction.PayPush); if (!pi) { return undefined; } @@ -391,7 +399,7 @@ export function parsePayPushUri(s: string): PayPushUriResult | undefined { } export function parsePayPullUri(s: string): PayPullUriResult | undefined { - const pi = parseProtoInfo(s, talerActionPayPull); + const pi = parseProtoInfo(s, TalerUriAction.PayPull); if (!pi) { return undefined; } @@ -598,56 +606,6 @@ export function parseRestoreUri(uri: string): BackupRestoreUri | undefined { // To string functions // ================================================ -/** - * @deprecated use stringifyRecoveryUri - */ -export function constructRecoveryUri(args: { - walletRootPriv: string; - providers: string[]; -}): string { - return stringifyRestoreUri(args); -} - -/** - * @deprecated stringifyPayPullUri - */ -export function constructPayPullUri(args: { - exchangeBaseUrl: string; - contractPriv: string; -}): string { - return stringifyPayPullUri(args); -} - -/** - * @deprecated use stringifyPayPushUri - */ -export function constructPayPushUri(args: { - exchangeBaseUrl: string; - contractPriv: string; -}): string { - return stringifyPayPushUri(args); -} - -/** - * - * @deprecated use stringifyPayUri - */ -export function constructPayUri( - merchantBaseUrl: string, - orderId: string, - sessionId: string, - claimToken?: string, - noncePriv?: string, -): string { - return stringifyPayUri({ - merchantBaseUrl, - orderId, - sessionId, - claimToken, - noncePriv, - }); -} - export function stringifyPayUri({ merchantBaseUrl, orderId, @@ -714,6 +672,7 @@ export function stringifyPayTemplateUri({ const { proto, path, query } = getUrlInfo(merchantBaseUrl, templateParams); return `${proto}://pay-template/${path}${templateId}${query}`; } + export function stringifyRefundUri({ merchantBaseUrl, orderId, @@ -721,6 +680,7 @@ export function stringifyRefundUri({ const { proto, path } = getUrlInfo(merchantBaseUrl); return `${proto}://refund/${path}${orderId}/`; } + export function stringifyRewardUri({ merchantBaseUrl, merchantRewardId, @@ -757,10 +717,6 @@ export function stringifyWithdrawUri({ * Use baseUrl to defined http or https * create path using host+port+pathname * use params to create a query parameter string or empty - * - * @param baseUrl - * @param params - * @returns */ function getUrlInfo( baseUrl: string, |