summaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-07-22 14:22:03 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-07-22 14:22:03 +0530
commite60563fb540c04d9ba751fea69c1fc0f1de598b5 (patch)
tree45f7c86b66dc150d413f9855efaa6341e4a44624 /src/types
parentf4a8702b3cf93f9edf96d1d1c8cb88baa309e301 (diff)
downloadwallet-core-e60563fb540c04d9ba751fea69c1fc0f1de598b5.tar.gz
wallet-core-e60563fb540c04d9ba751fea69c1fc0f1de598b5.tar.bz2
wallet-core-e60563fb540c04d9ba751fea69c1fc0f1de598b5.zip
consistent error handling for HTTP request (and some other things)
Diffstat (limited to 'src/types')
-rw-r--r--src/types/dbTypes.ts29
-rw-r--r--src/types/notifications.ts23
-rw-r--r--src/types/pending.ts16
-rw-r--r--src/types/talerTypes.ts68
-rw-r--r--src/types/transactions.ts2
-rw-r--r--src/types/walletTypes.ts9
6 files changed, 113 insertions, 34 deletions
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index b085f83db..252649b07 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -28,7 +28,6 @@ import {
Auditor,
CoinDepositPermission,
MerchantRefundDetails,
- PayReq,
TipResponse,
ExchangeSignKeyJson,
MerchantInfo,
@@ -36,7 +35,7 @@ import {
} from "./talerTypes";
import { Index, Store } from "../util/query";
-import { OperationError, RefreshReason } from "./walletTypes";
+import { OperationErrorDetails, RefreshReason } from "./walletTypes";
import {
ReserveTransaction,
ReserveCreditTransaction,
@@ -319,7 +318,7 @@ export interface ReserveRecord {
* Last error that happened in a reserve operation
* (either talking to the bank or the exchange).
*/
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
}
/**
@@ -633,7 +632,7 @@ export interface ExchangeRecord {
*/
updateDiff: ExchangeUpdateDiff | undefined;
- lastError?: OperationError;
+ lastError?: OperationErrorDetails;
}
/**
@@ -890,14 +889,14 @@ export interface ProposalRecord {
*/
retryInfo: RetryInfo;
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
}
/**
* Status of a tip we got from a merchant.
*/
export interface TipRecord {
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
/**
* Has the user accepted the tip? Only after the tip has been accepted coins
@@ -982,9 +981,9 @@ export interface RefreshGroupRecord {
*/
retryInfo: RetryInfo;
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
- lastErrorPerCoin: { [coinIndex: number]: OperationError };
+ lastErrorPerCoin: { [coinIndex: number]: OperationErrorDetails };
refreshGroupId: string;
@@ -1012,7 +1011,7 @@ export interface RefreshGroupRecord {
* Ongoing refresh
*/
export interface RefreshSessionRecord {
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
/**
* Public key that's being melted in this session.
@@ -1330,7 +1329,7 @@ export interface PurchaseRecord {
payRetryInfo: RetryInfo;
- lastPayError: OperationError | undefined;
+ lastPayError: OperationErrorDetails | undefined;
/**
* Retry information for querying the refund status with the merchant.
@@ -1340,7 +1339,7 @@ export interface PurchaseRecord {
/**
* Last error (or undefined) for querying the refund status with the merchant.
*/
- lastRefundStatusError: OperationError | undefined;
+ lastRefundStatusError: OperationErrorDetails | undefined;
/**
* Continue querying the refund status until this deadline has expired.
@@ -1448,7 +1447,7 @@ export interface DenomSelectionState {
/**
* Group of withdrawal operations that need to be executed.
* (Either for a normal withdrawal or from a tip.)
- *
+ *
* The withdrawal group record is only created after we know
* the coin selection we want to withdraw.
*/
@@ -1492,9 +1491,9 @@ export interface WithdrawalGroupRecord {
* Last error per coin/planchet, or undefined if no error occured for
* the coin/planchet.
*/
- lastErrorPerCoin: { [coinIndex: number]: OperationError };
+ lastErrorPerCoin: { [coinIndex: number]: OperationErrorDetails };
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
}
export interface BankWithdrawUriRecord {
@@ -1559,7 +1558,7 @@ export interface RecoupGroupRecord {
/**
* Last error that occured, if any.
*/
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
}
export const enum ImportPayloadType {
diff --git a/src/types/notifications.ts b/src/types/notifications.ts
index ac30b6fe2..5d6d2ee11 100644
--- a/src/types/notifications.ts
+++ b/src/types/notifications.ts
@@ -22,7 +22,7 @@
/**
* Imports.
*/
-import { OperationError } from "./walletTypes";
+import { OperationErrorDetails } from "./walletTypes";
import { WithdrawalSource } from "./dbTypes";
export const enum NotificationType {
@@ -54,6 +54,7 @@ export const enum NotificationType {
TipOperationError = "tip-error",
PayOperationError = "pay-error",
WithdrawOperationError = "withdraw-error",
+ ReserveNotYetFound = "reserve-not-yet-found",
ReserveOperationError = "reserve-error",
InternalError = "internal-error",
PendingOperationProcessed = "pending-operation-processed",
@@ -72,6 +73,11 @@ export interface InternalErrorNotification {
exception: any;
}
+export interface ReserveNotYetFoundNotification {
+ type: NotificationType.ReserveNotYetFound;
+ reservePub: string;
+}
+
export interface CoinWithdrawnNotification {
type: NotificationType.CoinWithdrawn;
}
@@ -148,27 +154,32 @@ export interface RefundFinishedNotification {
export interface ExchangeOperationErrorNotification {
type: NotificationType.ExchangeOperationError;
+ error: OperationErrorDetails;
}
export interface RefreshOperationErrorNotification {
type: NotificationType.RefreshOperationError;
+ error: OperationErrorDetails;
}
export interface RefundStatusOperationErrorNotification {
type: NotificationType.RefundStatusOperationError;
+ error: OperationErrorDetails;
}
export interface RefundApplyOperationErrorNotification {
type: NotificationType.RefundApplyOperationError;
+ error: OperationErrorDetails;
}
export interface PayOperationErrorNotification {
type: NotificationType.PayOperationError;
+ error: OperationErrorDetails;
}
export interface ProposalOperationErrorNotification {
type: NotificationType.ProposalOperationError;
- error: OperationError;
+ error: OperationErrorDetails;
}
export interface TipOperationErrorNotification {
@@ -177,16 +188,17 @@ export interface TipOperationErrorNotification {
export interface WithdrawOperationErrorNotification {
type: NotificationType.WithdrawOperationError;
- error: OperationError,
+ error: OperationErrorDetails;
}
export interface RecoupOperationErrorNotification {
type: NotificationType.RecoupOperationError;
+ error: OperationErrorDetails;
}
export interface ReserveOperationErrorNotification {
type: NotificationType.ReserveOperationError;
- operationError: OperationError;
+ error: OperationErrorDetails;
}
export interface ReserveCreatedNotification {
@@ -238,4 +250,5 @@ export type WalletNotification =
| InternalErrorNotification
| PendingOperationProcessedNotification
| ProposalRefusedNotification
- | ReserveRegisteredWithBankNotification; \ No newline at end of file
+ | ReserveRegisteredWithBankNotification
+ | ReserveNotYetFoundNotification;
diff --git a/src/types/pending.ts b/src/types/pending.ts
index f949b7c16..8a1e84362 100644
--- a/src/types/pending.ts
+++ b/src/types/pending.ts
@@ -21,7 +21,7 @@
/**
* Imports.
*/
-import { OperationError, WalletBalance } from "./walletTypes";
+import { OperationErrorDetails, WalletBalance } from "./walletTypes";
import { WithdrawalSource, RetryInfo, ReserveRecordStatus } from "./dbTypes";
import { Timestamp, Duration } from "../util/time";
import { ReserveType } from "./history";
@@ -68,7 +68,7 @@ export interface PendingExchangeUpdateOperation {
stage: ExchangeUpdateOperationStage;
reason: string;
exchangeBaseUrl: string;
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
}
/**
@@ -112,7 +112,7 @@ export interface PendingReserveOperation {
*/
export interface PendingRefreshOperation {
type: PendingOperationType.Refresh;
- lastError?: OperationError;
+ lastError?: OperationErrorDetails;
refreshGroupId: string;
finishedPerCoin: boolean[];
retryInfo: RetryInfo;
@@ -127,7 +127,7 @@ export interface PendingProposalDownloadOperation {
proposalTimestamp: Timestamp;
proposalId: string;
orderId: string;
- lastError?: OperationError;
+ lastError?: OperationErrorDetails;
retryInfo: RetryInfo;
}
@@ -172,7 +172,7 @@ export interface PendingPayOperation {
proposalId: string;
isReplay: boolean;
retryInfo: RetryInfo;
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
}
/**
@@ -183,14 +183,14 @@ export interface PendingRefundQueryOperation {
type: PendingOperationType.RefundQuery;
proposalId: string;
retryInfo: RetryInfo;
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
}
export interface PendingRecoupOperation {
type: PendingOperationType.Recoup;
recoupGroupId: string;
retryInfo: RetryInfo;
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
}
/**
@@ -199,7 +199,7 @@ export interface PendingRecoupOperation {
export interface PendingWithdrawOperation {
type: PendingOperationType.Withdraw;
source: WithdrawalSource;
- lastError: OperationError | undefined;
+ lastError: OperationErrorDetails | undefined;
withdrawalGroupId: string;
numCoinsWithdrawn: number;
numCoinsTotal: number;
diff --git a/src/types/talerTypes.ts b/src/types/talerTypes.ts
index 232f5f314..ef14684f9 100644
--- a/src/types/talerTypes.ts
+++ b/src/types/talerTypes.ts
@@ -433,7 +433,6 @@ export class ContractTerms {
extra: any;
}
-
/**
* Refund permission in the format that the merchant gives it to us.
*/
@@ -788,6 +787,53 @@ export interface MerchantPayResponse {
sig: string;
}
+export interface ExchangeMeltResponse {
+ /**
+ * Which of the kappa indices does the client not have to reveal.
+ */
+ noreveal_index: number;
+
+ /**
+ * Signature of TALER_RefreshMeltConfirmationPS whereby the exchange
+ * affirms the successful melt and confirming the noreveal_index
+ */
+ exchange_sig: EddsaSignatureString;
+
+ /*
+ * public EdDSA key of the exchange that was used to generate the signature.
+ * Should match one of the exchange's signing keys from /keys. Again given
+ * explicitly as the client might otherwise be confused by clock skew as to
+ * which signing key was used.
+ */
+ exchange_pub: EddsaPublicKeyString;
+
+ /*
+ * Base URL to use for operations on the refresh context
+ * (so the reveal operation). If not given,
+ * the base URL is the same as the one used for this request.
+ * Can be used if the base URL for /refreshes/ differs from that
+ * for /coins/, i.e. for load balancing. Clients SHOULD
+ * respect the refresh_base_url if provided. Any HTTP server
+ * belonging to an exchange MUST generate a 307 or 308 redirection
+ * to the correct base URL should a client uses the wrong base
+ * URL, or if the base URL has changed since the melt.
+ *
+ * When melting the same coin twice (technically allowed
+ * as the response might have been lost on the network),
+ * the exchange may return different values for the refresh_base_url.
+ */
+ refresh_base_url?: string;
+}
+
+export interface ExchangeRevealItem {
+ ev_sig: string;
+}
+
+export interface ExchangeRevealResponse {
+ // List of the exchange's blinded RSA signatures on the new coins.
+ ev_sigs: ExchangeRevealItem[];
+}
+
export type AmountString = string;
export type Base32String = string;
export type EddsaSignatureString = string;
@@ -1028,3 +1074,23 @@ export const codecForMerchantPayResponse = (): Codec<MerchantPayResponse> =>
makeCodecForObject<MerchantPayResponse>()
.property("sig", codecForString)
.build("MerchantPayResponse");
+
+export const codecForExchangeMeltResponse = (): Codec<ExchangeMeltResponse> =>
+ makeCodecForObject<ExchangeMeltResponse>()
+ .property("exchange_pub", codecForString)
+ .property("exchange_sig", codecForString)
+ .property("noreveal_index", codecForNumber)
+ .property("refresh_base_url", makeCodecOptional(codecForString))
+ .build("ExchangeMeltResponse");
+
+export const codecForExchangeRevealItem = (): Codec<ExchangeRevealItem> =>
+ makeCodecForObject<ExchangeRevealItem>()
+ .property("ev_sig", codecForString)
+ .build("ExchangeRevealItem");
+
+export const codecForExchangeRevealResponse = (): Codec<
+ ExchangeRevealResponse
+> =>
+ makeCodecForObject<ExchangeRevealResponse>()
+ .property("ev_sigs", makeCodecForList(codecForExchangeRevealItem()))
+ .build("ExchangeRevealResponse");
diff --git a/src/types/transactions.ts b/src/types/transactions.ts
index b87726bad..d62622648 100644
--- a/src/types/transactions.ts
+++ b/src/types/transactions.ts
@@ -119,7 +119,7 @@ interface WithdrawalDetailsForManualTransfer {
/**
* Payto URIs that the exchange supports.
- *
+ *
* Already contains the amount and message.
*/
exchangePaytoUris: string[];
diff --git a/src/types/walletTypes.ts b/src/types/walletTypes.ts
index ee7d071c6..95ec47b67 100644
--- a/src/types/walletTypes.ts
+++ b/src/types/walletTypes.ts
@@ -303,7 +303,7 @@ export class ReturnCoinsRequest {
* Wire details for the bank account of the customer that will
* receive the funds.
*/
- senderWire?: object;
+ senderWire?: string;
/**
* Verify that a value matches the schema of this class and convert it into a
@@ -406,10 +406,11 @@ export interface WalletDiagnostics {
dbOutdated: boolean;
}
-export interface OperationError {
- type: string;
+export interface OperationErrorDetails {
+ talerErrorCode: number;
+ talerErrorHint: string;
message: string;
- details: any;
+ details: unknown;
}
export interface PlanchetCreationResult {