Skip to content

Commit

Permalink
Merge pull request #133 from dbluhm/taa-fixes
Browse files Browse the repository at this point in the history
TAA Fixes
  • Loading branch information
andrewwhitehead committed Aug 10, 2019
2 parents 5526456 + 0c2aaca commit dd8620a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion aries_cloudagent/config/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ async def ledger_config(
taa_info = await ledger.get_txn_author_agreement()
if taa_info["taa_required"] and public_did:
taa_accepted = await ledger.get_latest_txn_author_acceptance()
if not taa_accepted or taa_info["taa_digest"] != taa_accepted["taaDigest"]:
if not taa_accepted \
or taa_info["taa_record"]["digest"] != taa_accepted["digest"]:
if not await accept_taa(ledger, taa_info, provision):
return False

Expand Down
11 changes: 9 additions & 2 deletions aries_cloudagent/ledger/indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tempfile
from hashlib import sha256
from os import path
from time import time
from datetime import datetime, date
from typing import Sequence, Type

import indy.anoncreds
Expand Down Expand Up @@ -599,6 +599,13 @@ def get_indy_storage(self) -> IndyStorage:
"""Get an IndyStorage instance for the current wallet."""
return IndyStorage(self.wallet)

def taa_rough_timestamp(self) -> int:
"""Get a timestamp accurate to the day.
Anything more accurate is a privacy concern.
"""
return int(datetime.combine(date.today(), datetime.min.time()).timestamp())

async def accept_txn_author_agreement(
self,
taa_record: dict,
Expand All @@ -608,7 +615,7 @@ async def accept_txn_author_agreement(
):
"""Save a new record recording the acceptance of the TAA."""
if not accept_time:
accept_time = int(time())
accept_time = self.taa_rough_timestamp()
acceptance = {
"text": taa_record["text"],
"version": taa_record["version"],
Expand Down

0 comments on commit dd8620a

Please sign in to comment.