summaryrefslogtreecommitdiff
path: root/packages/anastasis-core
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-03-18 15:32:41 +0100
committerFlorian Dold <florian@dold.me>2022-03-21 19:20:48 +0100
commitf8d12f7b0d4af1b1769b89e80c87f9c169678564 (patch)
tree2478696c7bc1efc6d090b93aa340de542a7dccd9 /packages/anastasis-core
parent32cd54e11d80bde0274b3c0238f8f5bd00ff83cb (diff)
downloadwallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.tar.gz
wallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.tar.bz2
wallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.zip
wallet: t_s/d_us migration
Diffstat (limited to 'packages/anastasis-core')
-rw-r--r--packages/anastasis-core/src/index.ts28
-rw-r--r--packages/anastasis-core/src/reducer-types.ts11
2 files changed, 22 insertions, 17 deletions
diff --git a/packages/anastasis-core/src/index.ts b/packages/anastasis-core/src/index.ts
index 15e1e5d97..d1afc706b 100644
--- a/packages/anastasis-core/src/index.ts
+++ b/packages/anastasis-core/src/index.ts
@@ -19,8 +19,9 @@ import {
parsePayUri,
stringToBytes,
TalerErrorCode,
+ TalerProtocolTimestamp,
TalerSignaturePurpose,
- Timestamp,
+ AbsoluteTime,
} from "@gnu-taler/taler-util";
import { anastasisData } from "./anastasis-data.js";
import {
@@ -631,15 +632,13 @@ async function uploadSecret(
logger.info(`got response for policy upload (http status ${resp.status})`);
if (resp.status === HttpStatusCode.NoContent) {
let policyVersion = 0;
- let policyExpiration: Timestamp = { t_ms: 0 };
+ let policyExpiration: TalerProtocolTimestamp = { t_s: 0 };
try {
policyVersion = Number(resp.headers.get("Anastasis-Version") ?? "0");
} catch (e) {}
try {
policyExpiration = {
- t_ms:
- 1000 *
- Number(resp.headers.get("Anastasis-Policy-Expiration") ?? "0"),
+ t_s: Number(resp.headers.get("Anastasis-Policy-Expiration") ?? "0"),
};
} catch (e) {}
successDetails[prov.provider_url] = {
@@ -1187,7 +1186,7 @@ async function addProviderBackup(
state: ReducerStateBackup,
args: ActionArgsAddProvider,
): Promise<ReducerStateBackup> {
- const info = await getProviderInfo(args.provider_url)
+ const info = await getProviderInfo(args.provider_url);
return {
...state,
authentication_providers: {
@@ -1202,8 +1201,10 @@ async function deleteProviderBackup(
state: ReducerStateBackup,
args: ActionArgsDeleteProvider,
): Promise<ReducerStateBackup> {
- const authentication_providers = {... state.authentication_providers ?? {} }
- delete authentication_providers[args.provider_url]
+ const authentication_providers = {
+ ...(state.authentication_providers ?? {}),
+ };
+ delete authentication_providers[args.provider_url];
return {
...state,
authentication_providers,
@@ -1214,7 +1215,7 @@ async function addProviderRecovery(
state: ReducerStateRecovery,
args: ActionArgsAddProvider,
): Promise<ReducerStateRecovery> {
- const info = await getProviderInfo(args.provider_url)
+ const info = await getProviderInfo(args.provider_url);
return {
...state,
authentication_providers: {
@@ -1228,8 +1229,10 @@ async function deleteProviderRecovery(
state: ReducerStateRecovery,
args: ActionArgsDeleteProvider,
): Promise<ReducerStateRecovery> {
- const authentication_providers = {... state.authentication_providers ?? {} }
- delete authentication_providers[args.provider_url]
+ const authentication_providers = {
+ ...(state.authentication_providers ?? {}),
+ };
+ delete authentication_providers[args.provider_url];
return {
...state,
authentication_providers,
@@ -1347,7 +1350,8 @@ async function updateUploadFees(
x,
).amount;
};
- const years = Duration.toIntegerYears(Duration.getRemaining(expiration));
+ const expirationTime = AbsoluteTime.fromTimestamp(expiration);
+ const years = Duration.toIntegerYears(Duration.getRemaining(expirationTime));
logger.info(`computing fees for ${years} years`);
// For now, we compute fees for *all* available providers.
for (const provUrl in state.authentication_providers ?? {}) {
diff --git a/packages/anastasis-core/src/reducer-types.ts b/packages/anastasis-core/src/reducer-types.ts
index 8d375552f..2a869fe47 100644
--- a/packages/anastasis-core/src/reducer-types.ts
+++ b/packages/anastasis-core/src/reducer-types.ts
@@ -7,7 +7,8 @@ import {
codecForString,
codecForTimestamp,
Duration,
- Timestamp,
+ TalerProtocolTimestamp,
+ AbsoluteTime,
} from "@gnu-taler/taler-util";
import { ChallengeFeedback } from "./challenge-feedback-types.js";
import { KeyShare } from "./crypto.js";
@@ -43,7 +44,7 @@ export interface PolicyProvider {
export interface SuccessDetails {
[provider_url: string]: {
policy_version: number;
- policy_expiration: Timestamp;
+ policy_expiration: TalerProtocolTimestamp;
};
}
@@ -112,7 +113,7 @@ export interface ReducerStateBackup {
core_secret?: CoreSecret;
- expiration?: Timestamp;
+ expiration?: TalerProtocolTimestamp;
upload_fees?: { fee: AmountString }[];
@@ -369,7 +370,7 @@ export interface ActionArgsEnterSecret {
value: string;
mime?: string;
};
- expiration: Timestamp;
+ expiration: TalerProtocolTimestamp;
}
export interface ActionArgsSelectContinent {
@@ -438,7 +439,7 @@ export interface ActionArgsAddPolicy {
}
export interface ActionArgsUpdateExpiration {
- expiration: Timestamp;
+ expiration: TalerProtocolTimestamp;
}
export interface ActionArgsChangeVersion {