@@ -39,21 +39,23 @@ def __init__(self, hby, msgs=None, gets=None, cues=None):
3939
4040 super (Receiptor , self ).__init__ (doers = doers )
4141
42- def receipt (self , pre , sn = None ):
42+ def receipt (self , pre , sn = None , auths = None ):
4343 """ Returns a generator for witness receipting
4444
4545 The returns a generator that will submit the designated event to witnesses for receipts using
46- the synchronous witness API, the propogate the receipts to each of the other witnesses.
46+ the synchronous witness API, then propogate the receipts to each of the other witnesses.
4747
4848
4949 Parameters:
5050 pre (str): qualified base64 identifier to gather receipts for
5151 sn: (Optiona[int]): sequence number of event to gather receipts for, latest is used if not provided
52+ auths: (Options[dict]): map of witness AIDs to (time,auth) tuples for providing TOTP auth for witnessing
5253
5354 Returns:
5455 list: identifiers of witnesses that returned receipts.
5556
5657 """
58+ auths = auths if auths is not None else dict ()
5759 if pre not in self .hby .prefixes :
5860 raise kering .MissingEntryError (f"{ pre } not a valid AID" )
5961
@@ -86,7 +88,11 @@ def receipt(self, pre, sn=None):
8688
8789 rcts = dict ()
8890 for wit , client in clients .items ():
89- httping .streamCESRRequests (client = client , dest = wit , ims = bytearray (msg ), path = "/receipts" )
91+ headers = dict ()
92+ if wit in auths :
93+ headers ["Authorization" ] = auths [wit ]
94+
95+ httping .streamCESRRequests (client = client , dest = wit , ims = bytearray (msg ), path = "receipts" , headers = headers )
9096 while not client .responses :
9197 yield self .tock
9298
@@ -101,7 +107,7 @@ def receipt(self, pre, sn=None):
101107 coring .Counter (qb64b = rct , strip = True )
102108 rcts [wit ] = rct
103109 else :
104- logger . error (f"invalid response { rep .status } from witnesses { wit } " )
110+ print (f"invalid response { rep .status } from witnesses { wit } " )
105111
106112 for wit in rcts :
107113 ewits = [w for w in rcts if w != wit ]
@@ -1057,7 +1063,7 @@ def httpClient(hab, wit):
10571063
10581064 url = urls [kering .Schemes .http ] if kering .Schemes .http in urls else urls [kering .Schemes .https ]
10591065 up = urlparse (url )
1060- client = http .clienting .Client (scheme = up .scheme , hostname = up .hostname , port = up .port )
1066+ client = http .clienting .Client (scheme = up .scheme , hostname = up .hostname , port = up .port , path = up . path )
10611067 clientDoer = http .clienting .ClientDoer (client = client )
10621068
10631069 return client , clientDoer
0 commit comments