aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r--packages/taler-util/src/backup-types.ts4
-rw-r--r--packages/taler-util/src/http-impl.node.ts22
-rw-r--r--packages/taler-util/src/merchant-api-types.ts14
-rw-r--r--packages/taler-util/src/taleruri.test.ts10
-rw-r--r--packages/taler-util/src/taleruri.ts28
-rw-r--r--packages/taler-util/src/transactions-types.ts8
-rw-r--r--packages/taler-util/src/wallet-types.ts41
7 files changed, 74 insertions, 53 deletions
diff --git a/packages/taler-util/src/backup-types.ts b/packages/taler-util/src/backup-types.ts
index 2920838dd..0211ff740 100644
--- a/packages/taler-util/src/backup-types.ts
+++ b/packages/taler-util/src/backup-types.ts
@@ -499,7 +499,7 @@ export interface BackupRecoupGroup {
export enum BackupCoinSourceType {
Withdraw = "withdraw",
Refresh = "refresh",
- Tip = "tip",
+ Reward = "reward",
}
/**
@@ -546,7 +546,7 @@ export interface BackupRefreshCoinSource {
* Metadata about a coin obtained from a tip.
*/
export interface BackupTipCoinSource {
- type: BackupCoinSourceType.Tip;
+ type: BackupCoinSourceType.Reward;
/**
* Wallet's identifier for the tip that this coin
diff --git a/packages/taler-util/src/http-impl.node.ts b/packages/taler-util/src/http-impl.node.ts
index 639043201..07648a28d 100644
--- a/packages/taler-util/src/http-impl.node.ts
+++ b/packages/taler-util/src/http-impl.node.ts
@@ -183,7 +183,16 @@ export class HttpLibImpl implements HttpRequestLibrary {
resolve(resp);
});
res.on("error", (e) => {
- reject(e);
+ const err = TalerError.fromDetail(
+ TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR,
+ {
+ requestUrl: url,
+ requestMethod: method,
+ httpStatusCode: 0,
+ },
+ `Error in HTTP response handler: ${e.message}`,
+ );
+ reject(err);
});
};
@@ -197,7 +206,16 @@ export class HttpLibImpl implements HttpRequestLibrary {
}
req.on("error", (e: Error) => {
- reject(e);
+ const err = TalerError.fromDetail(
+ TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR,
+ {
+ requestUrl: url,
+ requestMethod: method,
+ httpStatusCode: 0,
+ },
+ `Error in HTTP request: ${e.message}`,
+ );
+ reject(err);
});
if (reqBody) {
diff --git a/packages/taler-util/src/merchant-api-types.ts b/packages/taler-util/src/merchant-api-types.ts
index d7a5cf576..9f00173f2 100644
--- a/packages/taler-util/src/merchant-api-types.ts
+++ b/packages/taler-util/src/merchant-api-types.ts
@@ -290,22 +290,22 @@ export interface ReserveStatusEntry {
active: boolean;
}
-export interface TipCreateConfirmation {
+export interface RewardCreateConfirmation {
// Unique tip identifier for the tip that was created.
- tip_id: string;
+ reward_id: string;
// taler://tip URI for the tip
- taler_tip_uri: string;
+ taler_reward_uri: string;
// URL that will directly trigger processing
// the tip when the browser is redirected to it
- tip_status_url: string;
+ reward_status_url: string;
- // when does the tip expire
- tip_expiration: AbsoluteTime;
+ // when does the reward expire
+ reward_expiration: AbsoluteTime;
}
-export interface TipCreateRequest {
+export interface RewardCreateRequest {
// Amount that the customer should be tipped
amount: AmountString;
diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts
index eb74436cb..0dcf92252 100644
--- a/packages/taler-util/src/taleruri.test.ts
+++ b/packages/taler-util/src/taleruri.test.ts
@@ -21,7 +21,7 @@ import {
parsePayUri,
parseRefundUri,
parseRestoreUri,
- parseTipUri,
+ parseRewardUri,
parseWithdrawExchangeUri,
parseWithdrawUri,
stringifyPayPushUri,
@@ -161,7 +161,7 @@ test("taler refund uri parsing with instance", (t) => {
test("taler tip pickup uri", (t) => {
const url1 = "taler://tip/merchant.example.com/tipid";
- const r1 = parseTipUri(url1);
+ const r1 = parseRewardUri(url1);
if (!r1) {
t.fail();
return;
@@ -171,7 +171,7 @@ test("taler tip pickup uri", (t) => {
test("taler tip pickup uri with instance", (t) => {
const url1 = "taler://tip/merchant.example.com/instances/tipm/tipid";
- const r1 = parseTipUri(url1);
+ const r1 = parseRewardUri(url1);
if (!r1) {
t.fail();
return;
@@ -182,7 +182,7 @@ test("taler tip pickup uri with instance", (t) => {
test("taler tip pickup uri with instance and prefix", (t) => {
const url1 = "taler://tip/merchant.example.com/my/pfx/tipm/tipid";
- const r1 = parseTipUri(url1);
+ const r1 = parseRewardUri(url1);
if (!r1) {
t.fail();
return;
@@ -367,6 +367,6 @@ test("taler withdraw exchange URI with amount (stringify)", (t) => {
});
t.deepEqual(
url,
- "taler://withdraw-exchange/exchange.demo.taler.net/JFX1NE38C65A5XT8VSNQXX7R7BBG4GNZ63F5T7Y6859V4J8KBKF0?a=KUDOS%3A19",
+ "taler://withdraw-exchange/exchange.demo.taler.net/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0?a=KUDOS%3A19",
);
});
diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts
index fc140811b..777cb5245 100644
--- a/packages/taler-util/src/taleruri.ts
+++ b/packages/taler-util/src/taleruri.ts
@@ -26,7 +26,7 @@ export type TalerUri =
| PayPushUriResult
| BackupRestoreUri
| RefundUriResult
- | TipUriResult
+ | RewardUriResult
| WithdrawUriResult
| ExchangeUri
| WithdrawExchangeUri
@@ -60,8 +60,8 @@ export interface RefundUriResult {
orderId: string;
}
-export interface TipUriResult {
- type: TalerUriAction.Tip;
+export interface RewardUriResult {
+ type: TalerUriAction.Reward;
merchantBaseUrl: string;
merchantTipId: string;
}
@@ -167,7 +167,7 @@ export enum TalerUriAction {
Pay = "pay",
Withdraw = "withdraw",
Refund = "refund",
- Tip = "tip",
+ Reward = "reward",
PayPull = "pay-pull",
PayPush = "pay-push",
PayTemplate = "pay-template",
@@ -212,7 +212,7 @@ const parsers: { [A in TalerUriAction]: Parser } = {
[TalerUriAction.PayTemplate]: parsePayTemplateUri,
[TalerUriAction.Restore]: parseRestoreUri,
[TalerUriAction.Refund]: parseRefundUri,
- [TalerUriAction.Tip]: parseTipUri,
+ [TalerUriAction.Reward]: parseRewardUri,
[TalerUriAction.Withdraw]: parseWithdrawUri,
[TalerUriAction.DevExperiment]: parseDevExperimentUri,
[TalerUriAction.Exchange]: parseExchangeUri,
@@ -255,8 +255,8 @@ export function stringifyTalerUri(uri: TalerUri): string {
case TalerUriAction.Refund: {
return stringifyRefundUri(uri);
}
- case TalerUriAction.Tip: {
- return stringifyTipUri(uri);
+ case TalerUriAction.Reward: {
+ return stringifyRewardUri(uri);
}
case TalerUriAction.Withdraw: {
return stringifyWithdrawUri(uri);
@@ -394,11 +394,11 @@ export function parsePayPullUri(s: string): PayPullUriResult | undefined {
}
/**
- * Parse a taler[+http]://tip URI.
+ * Parse a taler[+http]://reward URI.
* Return undefined if not passed a valid URI.
*/
-export function parseTipUri(s: string): TipUriResult | undefined {
- const pi = parseProtoInfo(s, "tip");
+export function parseRewardUri(s: string): RewardUriResult | undefined {
+ const pi = parseProtoInfo(s, "reward");
if (!pi) {
return undefined;
}
@@ -416,7 +416,7 @@ export function parseTipUri(s: string): TipUriResult | undefined {
);
return {
- type: TalerUriAction.Tip,
+ type: TalerUriAction.Reward,
merchantBaseUrl,
merchantTipId: tipId,
};
@@ -699,12 +699,12 @@ export function stringifyRefundUri({
const { proto, path } = getUrlInfo(merchantBaseUrl);
return `${proto}://refund/${path}${orderId}`;
}
-export function stringifyTipUri({
+export function stringifyRewardUri({
merchantBaseUrl,
merchantTipId,
-}: Omit<TipUriResult, "type">): string {
+}: Omit<RewardUriResult, "type">): string {
const { proto, path } = getUrlInfo(merchantBaseUrl);
- return `${proto}://tip/${path}${merchantTipId}`;
+ return `${proto}://reward/${path}${merchantTipId}`;
}
export function stringifyExchangeUri({
diff --git a/packages/taler-util/src/transactions-types.ts b/packages/taler-util/src/transactions-types.ts
index a498d3471..2d278e3e8 100644
--- a/packages/taler-util/src/transactions-types.ts
+++ b/packages/taler-util/src/transactions-types.ts
@@ -186,7 +186,7 @@ export type Transaction =
| TransactionWithdrawal
| TransactionPayment
| TransactionRefund
- | TransactionTip
+ | TransactionReward
| TransactionRefresh
| TransactionDeposit
| TransactionPeerPullCredit
@@ -201,7 +201,7 @@ export enum TransactionType {
Payment = "payment",
Refund = "refund",
Refresh = "refresh",
- Tip = "tip",
+ Reward = "reward",
Deposit = "deposit",
PeerPushDebit = "peer-push-debit",
PeerPushCredit = "peer-push-credit",
@@ -591,8 +591,8 @@ export interface TransactionRefund extends TransactionCommon {
paymentInfo: RefundPaymentInfo | undefined;
}
-export interface TransactionTip extends TransactionCommon {
- type: TransactionType.Tip;
+export interface TransactionReward extends TransactionCommon {
+ type: TransactionType.Reward;
// Raw amount of the tip, without extra fees that apply
amountRaw: AmountString;
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index 93653240b..38e5787ba 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -605,7 +605,7 @@ export interface PrepareTipResult {
*
* @deprecated use transactionId instead
*/
- walletTipId: string;
+ walletRewardId: string;
/**
* Tip transaction ID.
@@ -620,13 +620,13 @@ export interface PrepareTipResult {
/**
* Amount that the merchant gave.
*/
- tipAmountRaw: AmountString;
+ rewardAmountRaw: AmountString;
/**
* Amount that arrived at the wallet.
* Might be lower than the raw amount due to fees.
*/
- tipAmountEffective: AmountString;
+ rewardAmountEffective: AmountString;
/**
* Base URL of the merchant backend giving then tip.
@@ -654,14 +654,14 @@ export interface AcceptTipResponse {
export const codecForPrepareTipResult = (): Codec<PrepareTipResult> =>
buildCodecForObject<PrepareTipResult>()
.property("accepted", codecForBoolean())
- .property("tipAmountRaw", codecForAmountString())
- .property("tipAmountEffective", codecForAmountString())
+ .property("rewardAmountRaw", codecForAmountString())
+ .property("rewardAmountEffective", codecForAmountString())
.property("exchangeBaseUrl", codecForString())
.property("merchantBaseUrl", codecForString())
.property("expirationTimestamp", codecForTimestamp)
- .property("walletTipId", codecForString())
+ .property("walletRewardId", codecForString())
.property("transactionId", codecForString())
- .build("PrepareTipResult");
+ .build("PrepareRewardResult");
export interface BenchmarkResult {
time: { [s: string]: number };
@@ -994,6 +994,9 @@ export interface ExchangeDetailedResponse {
}
export interface WalletCoreVersion {
+ /**
+ * @deprecated
+ */
hash: string | undefined;
version: string;
exchange: string;
@@ -1930,23 +1933,23 @@ export const codecForStartRefundQueryRequest =
.property("transactionId", codecForTransactionIdStr())
.build("StartRefundQueryRequest");
-export interface PrepareTipRequest {
- talerTipUri: string;
+export interface PrepareRewardRequest {
+ talerRewardUri: string;
}
-export const codecForPrepareTipRequest = (): Codec<PrepareTipRequest> =>
- buildCodecForObject<PrepareTipRequest>()
- .property("talerTipUri", codecForString())
- .build("PrepareTipRequest");
+export const codecForPrepareRewardRequest = (): Codec<PrepareRewardRequest> =>
+ buildCodecForObject<PrepareRewardRequest>()
+ .property("talerRewardUri", codecForString())
+ .build("PrepareRewardRequest");
-export interface AcceptTipRequest {
- walletTipId: string;
+export interface AcceptRewardRequest {
+ walletRewardId: string;
}
-export const codecForAcceptTipRequest = (): Codec<AcceptTipRequest> =>
- buildCodecForObject<AcceptTipRequest>()
- .property("walletTipId", codecForString())
- .build("AcceptTipRequest");
+export const codecForAcceptTipRequest = (): Codec<AcceptRewardRequest> =>
+ buildCodecForObject<AcceptRewardRequest>()
+ .property("walletRewardId", codecForString())
+ .build("AcceptRewardRequest");
export interface FailTransactionRequest {
transactionId: TransactionIdStr;