when as number instead of string, fix codec used before declaration, pretty
This commit is contained in:
parent
52be8c9158
commit
335d22b12b
@ -71,11 +71,20 @@ interface NativeTartLib {
|
|||||||
ecdheGetPublic(buf: Uint8Array): Uint8Array;
|
ecdheGetPublic(buf: Uint8Array): Uint8Array;
|
||||||
eddsaSign(msg: Uint8Array, priv: Uint8Array): Uint8Array;
|
eddsaSign(msg: Uint8Array, priv: Uint8Array): Uint8Array;
|
||||||
eddsaVerify(msg: Uint8Array, sig: Uint8Array, pub: Uint8Array): boolean;
|
eddsaVerify(msg: Uint8Array, sig: Uint8Array, pub: Uint8Array): boolean;
|
||||||
kdf(outLen: number, ikm: Uint8Array, salt?: Uint8Array, info?: Uint8Array): Uint8Array;
|
kdf(
|
||||||
|
outLen: number,
|
||||||
|
ikm: Uint8Array,
|
||||||
|
salt?: Uint8Array,
|
||||||
|
info?: Uint8Array,
|
||||||
|
): Uint8Array;
|
||||||
keyExchangeEcdhEddsa(ecdhPriv: Uint8Array, eddsaPub: Uint8Array): Uint8Array;
|
keyExchangeEcdhEddsa(ecdhPriv: Uint8Array, eddsaPub: Uint8Array): Uint8Array;
|
||||||
keyExchangeEddsaEcdh(eddsaPriv: Uint8Array, ecdhPub: Uint8Array): Uint8Array;
|
keyExchangeEddsaEcdh(eddsaPriv: Uint8Array, ecdhPub: Uint8Array): Uint8Array;
|
||||||
rsaBlind(hmsg: Uint8Array, bks: Uint8Array, rsaPub: Uint8Array): Uint8Array;
|
rsaBlind(hmsg: Uint8Array, bks: Uint8Array, rsaPub: Uint8Array): Uint8Array;
|
||||||
rsaUnblind(blindSig: Uint8Array, rsaPub: Uint8Array, bks: Uint8Array): Uint8Array;
|
rsaUnblind(
|
||||||
|
blindSig: Uint8Array,
|
||||||
|
rsaPub: Uint8Array,
|
||||||
|
bks: Uint8Array,
|
||||||
|
): Uint8Array;
|
||||||
rsaVerify(hmsg: Uint8Array, rsaSig: Uint8Array, rsaPub: Uint8Array): boolean;
|
rsaVerify(hmsg: Uint8Array, rsaSig: Uint8Array, rsaPub: Uint8Array): boolean;
|
||||||
hashStateInit(): any;
|
hashStateInit(): any;
|
||||||
hashStateUpdate(st: any, data: Uint8Array): any;
|
hashStateUpdate(st: any, data: Uint8Array): any;
|
||||||
@ -168,7 +177,7 @@ export function kdf(
|
|||||||
info?: Uint8Array,
|
info?: Uint8Array,
|
||||||
): Uint8Array {
|
): Uint8Array {
|
||||||
if (tart) {
|
if (tart) {
|
||||||
return tart.kdf(outputLength, ikm, salt, info)
|
return tart.kdf(outputLength, ikm, salt, info);
|
||||||
}
|
}
|
||||||
salt = salt ?? new Uint8Array(64);
|
salt = salt ?? new Uint8Array(64);
|
||||||
// extract
|
// extract
|
||||||
@ -199,7 +208,6 @@ export function kdf(
|
|||||||
return output.slice(0, outputLength);
|
return output.slice(0, outputLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HMAC-SHA512-SHA256 (see RFC 5869).
|
* HMAC-SHA512-SHA256 (see RFC 5869).
|
||||||
*/
|
*/
|
||||||
@ -460,7 +468,7 @@ export function rsaUnblind(
|
|||||||
bks: Uint8Array,
|
bks: Uint8Array,
|
||||||
): Uint8Array {
|
): Uint8Array {
|
||||||
if (tart) {
|
if (tart) {
|
||||||
return tart.rsaUnblind(sig, rsaPubEnc, bks)
|
return tart.rsaUnblind(sig, rsaPubEnc, bks);
|
||||||
}
|
}
|
||||||
const rsaPub = rsaPubDecode(rsaPubEnc);
|
const rsaPub = rsaPubDecode(rsaPubEnc);
|
||||||
const blinded_s = loadBigInt(sig);
|
const blinded_s = loadBigInt(sig);
|
||||||
@ -839,7 +847,7 @@ export function createHashContext(): TalerHashState {
|
|||||||
return {
|
return {
|
||||||
finish: () => t.hashStateFinish(st),
|
finish: () => t.hashStateFinish(st),
|
||||||
update: (d) => t.hashStateUpdate(st, d),
|
update: (d) => t.hashStateUpdate(st, d),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
return new nacl.HashState();
|
return new nacl.HashState();
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -249,7 +249,7 @@ export interface ConfirmPayResultPending {
|
|||||||
export const codecForTalerErrorDetail = (): Codec<TalerErrorDetail> =>
|
export const codecForTalerErrorDetail = (): Codec<TalerErrorDetail> =>
|
||||||
buildCodecForObject<TalerErrorDetail>()
|
buildCodecForObject<TalerErrorDetail>()
|
||||||
.property("code", codecForNumber())
|
.property("code", codecForNumber())
|
||||||
.property("when", codecForString())
|
.property("when", codecForAbsoluteTime)
|
||||||
.property("hint", codecOptional(codecForString()))
|
.property("hint", codecOptional(codecForString()))
|
||||||
.build("TalerErrorDetail");
|
.build("TalerErrorDetail");
|
||||||
|
|
||||||
@ -408,6 +408,64 @@ export const codecForPreparePayResultPaymentPossible =
|
|||||||
)
|
)
|
||||||
.build("PreparePayResultPaymentPossible");
|
.build("PreparePayResultPaymentPossible");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detailed reason for why the wallet's balance is insufficient.
|
||||||
|
*/
|
||||||
|
export interface PayMerchantInsufficientBalanceDetails {
|
||||||
|
/**
|
||||||
|
* Amount requested by the merchant.
|
||||||
|
*/
|
||||||
|
amountRequested: AmountString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Balance of type "available" (see balance.ts for definition).
|
||||||
|
*/
|
||||||
|
balanceAvailable: AmountString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Balance of type "material" (see balance.ts for definition).
|
||||||
|
*/
|
||||||
|
balanceMaterial: AmountString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Balance of type "age-acceptable" (see balance.ts for definition).
|
||||||
|
*/
|
||||||
|
balanceAgeAcceptable: AmountString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Balance of type "merchant-acceptable" (see balance.ts for definition).
|
||||||
|
*/
|
||||||
|
balanceMerchantAcceptable: AmountString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Balance of type "merchant-depositable" (see balance.ts for definition).
|
||||||
|
*/
|
||||||
|
balanceMerchantDepositable: AmountString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the payment would succeed without fees
|
||||||
|
* (i.e. balanceMechantWireable >= amountRequested),
|
||||||
|
* this field contains an estimate of the amount that would additionally
|
||||||
|
* be required to cover the fees.
|
||||||
|
*
|
||||||
|
* It is not possible to give an exact value here, since it depends
|
||||||
|
* on the coin selection for the amount that would be additionally withdrawn.
|
||||||
|
*/
|
||||||
|
feeGapEstimate: AmountString;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const codecForPayMerchantInsufficientBalanceDetails =
|
||||||
|
(): Codec<PayMerchantInsufficientBalanceDetails> =>
|
||||||
|
buildCodecForObject<PayMerchantInsufficientBalanceDetails>()
|
||||||
|
.property("amountRequested", codecForAmountString())
|
||||||
|
.property("balanceAgeAcceptable", codecForAmountString())
|
||||||
|
.property("balanceAvailable", codecForAmountString())
|
||||||
|
.property("balanceMaterial", codecForAmountString())
|
||||||
|
.property("balanceMerchantAcceptable", codecForAmountString())
|
||||||
|
.property("balanceMerchantDepositable", codecForAmountString())
|
||||||
|
.property("feeGapEstimate", codecForAmountString())
|
||||||
|
.build("PayMerchantInsufficientBalanceDetails");
|
||||||
|
|
||||||
export const codecForPreparePayResultInsufficientBalance =
|
export const codecForPreparePayResultInsufficientBalance =
|
||||||
(): Codec<PreparePayResultInsufficientBalance> =>
|
(): Codec<PreparePayResultInsufficientBalance> =>
|
||||||
buildCodecForObject<PreparePayResultInsufficientBalance>()
|
buildCodecForObject<PreparePayResultInsufficientBalance>()
|
||||||
@ -538,7 +596,7 @@ export interface WalletDiagnostics {
|
|||||||
|
|
||||||
export interface TalerErrorDetail {
|
export interface TalerErrorDetail {
|
||||||
code: TalerErrorCode;
|
code: TalerErrorCode;
|
||||||
when?: string;
|
when: AbsoluteTime;
|
||||||
hint?: string;
|
hint?: string;
|
||||||
[x: string]: unknown;
|
[x: string]: unknown;
|
||||||
}
|
}
|
||||||
@ -2099,64 +2157,6 @@ export interface InitiatePeerPullPaymentResponse {
|
|||||||
transactionId: string;
|
transactionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Detailed reason for why the wallet's balance is insufficient.
|
|
||||||
*/
|
|
||||||
export interface PayMerchantInsufficientBalanceDetails {
|
|
||||||
/**
|
|
||||||
* Amount requested by the merchant.
|
|
||||||
*/
|
|
||||||
amountRequested: AmountString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Balance of type "available" (see balance.ts for definition).
|
|
||||||
*/
|
|
||||||
balanceAvailable: AmountString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Balance of type "material" (see balance.ts for definition).
|
|
||||||
*/
|
|
||||||
balanceMaterial: AmountString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Balance of type "age-acceptable" (see balance.ts for definition).
|
|
||||||
*/
|
|
||||||
balanceAgeAcceptable: AmountString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Balance of type "merchant-acceptable" (see balance.ts for definition).
|
|
||||||
*/
|
|
||||||
balanceMerchantAcceptable: AmountString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Balance of type "merchant-depositable" (see balance.ts for definition).
|
|
||||||
*/
|
|
||||||
balanceMerchantDepositable: AmountString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the payment would succeed without fees
|
|
||||||
* (i.e. balanceMechantWireable >= amountRequested),
|
|
||||||
* this field contains an estimate of the amount that would additionally
|
|
||||||
* be required to cover the fees.
|
|
||||||
*
|
|
||||||
* It is not possible to give an exact value here, since it depends
|
|
||||||
* on the coin selection for the amount that would be additionally withdrawn.
|
|
||||||
*/
|
|
||||||
feeGapEstimate: AmountString;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const codecForPayMerchantInsufficientBalanceDetails =
|
|
||||||
(): Codec<PayMerchantInsufficientBalanceDetails> =>
|
|
||||||
buildCodecForObject<PayMerchantInsufficientBalanceDetails>()
|
|
||||||
.property("amountRequested", codecForAmountString())
|
|
||||||
.property("balanceAgeAcceptable", codecForAmountString())
|
|
||||||
.property("balanceAvailable", codecForAmountString())
|
|
||||||
.property("balanceMaterial", codecForAmountString())
|
|
||||||
.property("balanceMerchantAcceptable", codecForAmountString())
|
|
||||||
.property("balanceMerchantDepositable", codecForAmountString())
|
|
||||||
.property("feeGapEstimate", codecForAmountString())
|
|
||||||
.build("PayMerchantInsufficientBalanceDetails");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detailed reason for why the wallet's balance is insufficient.
|
* Detailed reason for why the wallet's balance is insufficient.
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { AbsoluteTime } from "@gnu-taler/taler-util";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { CryptoDispatcher, CryptoWorkerFactory } from "./crypto-dispatcher.js";
|
import { CryptoDispatcher, CryptoWorkerFactory } from "./crypto-dispatcher.js";
|
||||||
import {
|
import {
|
||||||
@ -74,7 +75,7 @@ export class MyCryptoWorker implements CryptoWorker {
|
|||||||
type: "error",
|
type: "error",
|
||||||
error: {
|
error: {
|
||||||
code: 42,
|
code: 42,
|
||||||
when: "now",
|
when: AbsoluteTime.now(),
|
||||||
hint: "bla",
|
hint: "bla",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
|
AbsoluteTime,
|
||||||
PayMerchantInsufficientBalanceDetails,
|
PayMerchantInsufficientBalanceDetails,
|
||||||
PayPeerInsufficientBalanceDetails,
|
PayPeerInsufficientBalanceDetails,
|
||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
@ -103,7 +104,7 @@ export function makeErrorDetail<C extends TalerErrorCode>(
|
|||||||
if (!hint && !(detail as any).hint) {
|
if (!hint && !(detail as any).hint) {
|
||||||
hint = getDefaultHint(code);
|
hint = getDefaultHint(code);
|
||||||
}
|
}
|
||||||
const when = new Date().toISOString();
|
const when = AbsoluteTime.now();
|
||||||
return { code, when, hint, ...detail };
|
return { code, when, hint, ...detail };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ export class TalerError<T = any> extends Error {
|
|||||||
if (!hint) {
|
if (!hint) {
|
||||||
hint = getDefaultHint(code);
|
hint = getDefaultHint(code);
|
||||||
}
|
}
|
||||||
const when = new Date().toISOString();
|
const when = AbsoluteTime.now();
|
||||||
return new TalerError<unknown>({ code, when, hint, ...detail });
|
return new TalerError<unknown>({ code, when, hint, ...detail });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1822,7 +1822,7 @@ export async function processPurchase(
|
|||||||
errorDetail: {
|
errorDetail: {
|
||||||
// FIXME: allocate more specific error code
|
// FIXME: allocate more specific error code
|
||||||
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
||||||
when: new Date().toISOString(),
|
when: AbsoluteTime.now(),
|
||||||
hint: `trying to pay for purchase that is not in the database`,
|
hint: `trying to pay for purchase that is not in the database`,
|
||||||
proposalId: proposalId,
|
proposalId: proposalId,
|
||||||
},
|
},
|
||||||
@ -1873,7 +1873,7 @@ export async function processPurchasePay(
|
|||||||
errorDetail: {
|
errorDetail: {
|
||||||
// FIXME: allocate more specific error code
|
// FIXME: allocate more specific error code
|
||||||
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
||||||
when: new Date().toISOString(),
|
when: AbsoluteTime.now(),
|
||||||
hint: `trying to pay for purchase that is not in the database`,
|
hint: `trying to pay for purchase that is not in the database`,
|
||||||
proposalId: proposalId,
|
proposalId: proposalId,
|
||||||
},
|
},
|
||||||
@ -1952,7 +1952,7 @@ export async function processPurchasePay(
|
|||||||
|
|
||||||
await scheduleRetry(ws, RetryTags.forPay(purchase), {
|
await scheduleRetry(ws, RetryTags.forPay(purchase), {
|
||||||
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
||||||
when: new Date().toISOString(),
|
when: AbsoluteTime.now(),
|
||||||
message: "unexpected exception",
|
message: "unexpected exception",
|
||||||
hint: "unexpected exception",
|
hint: "unexpected exception",
|
||||||
details: {
|
details: {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* @author Sebastian Javier Marchano (sebasjm)
|
* @author Sebastian Javier Marchano (sebasjm)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TalerProtocolTimestamp } from "@gnu-taler/taler-util";
|
import { AbsoluteTime, TalerProtocolTimestamp } from "@gnu-taler/taler-util";
|
||||||
import { ProviderPaymentType } from "@gnu-taler/taler-wallet-core";
|
import { ProviderPaymentType } from "@gnu-taler/taler-wallet-core";
|
||||||
import { tests } from "@gnu-taler/web-util/lib/index.browser";
|
import { tests } from "@gnu-taler/web-util/lib/index.browser";
|
||||||
import { ProviderView as TestedComponent } from "./ProviderDetailPage.js";
|
import { ProviderView as TestedComponent } from "./ProviderDetailPage.js";
|
||||||
@ -79,7 +79,7 @@ export const ActiveErrorSync = tests.createExample(TestedComponent, {
|
|||||||
lastError: {
|
lastError: {
|
||||||
code: 2002,
|
code: 2002,
|
||||||
details: "details",
|
details: "details",
|
||||||
when: new Date().toISOString(),
|
when: AbsoluteTime.now(),
|
||||||
hint: "error hint from the server",
|
hint: "error hint from the server",
|
||||||
message: "message",
|
message: "message",
|
||||||
},
|
},
|
||||||
|
@ -216,7 +216,7 @@ const transactionError = {
|
|||||||
hint: "The payment is too late, the offer has expired.",
|
hint: "The payment is too late, the offer has expired.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
when: new Date().toISOString(),
|
when: AbsoluteTime.now(),
|
||||||
hint: "Error: WALLET_UNEXPECTED_REQUEST_ERROR",
|
hint: "Error: WALLET_UNEXPECTED_REQUEST_ERROR",
|
||||||
message: "Unexpected error code in response",
|
message: "Unexpected error code in response",
|
||||||
};
|
};
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
|
AbsoluteTime,
|
||||||
CoreApiResponse,
|
CoreApiResponse,
|
||||||
Logger,
|
Logger,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
@ -125,7 +126,7 @@ class BackgroundApiClientImpl implements BackgroundApiClient {
|
|||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
throw new BackgroundError(operation, {
|
throw new BackgroundError(operation, {
|
||||||
code: TalerErrorCode.GENERIC_UNEXPECTED_REQUEST_ERROR,
|
code: TalerErrorCode.GENERIC_UNEXPECTED_REQUEST_ERROR,
|
||||||
when: new Date().toISOString(),
|
when: AbsoluteTime.now(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
Loading…
Reference in New Issue
Block a user