From f8d12f7b0d4af1b1769b89e80c87f9c169678564 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 18 Mar 2022 15:32:41 +0100 Subject: wallet: t_s/d_us migration --- packages/anastasis-core/src/index.ts | 28 ++++++++++++++++------------ packages/anastasis-core/src/reducer-types.ts | 11 ++++++----- 2 files changed, 22 insertions(+), 17 deletions(-) (limited to 'packages/anastasis-core') 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 { - 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 { - 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 { - 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 { - 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 { -- cgit v1.2.3