@@ -39,21 +39,23 @@ def __init__(self, hby, msgs=None, gets=None, cues=None):
39
39
40
40
super (Receiptor , self ).__init__ (doers = doers )
41
41
42
- def receipt (self , pre , sn = None ):
42
+ def receipt (self , pre , sn = None , auths = None ):
43
43
""" Returns a generator for witness receipting
44
44
45
45
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.
47
47
48
48
49
49
Parameters:
50
50
pre (str): qualified base64 identifier to gather receipts for
51
51
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
52
53
53
54
Returns:
54
55
list: identifiers of witnesses that returned receipts.
55
56
56
57
"""
58
+ auths = auths if auths is not None else dict ()
57
59
if pre not in self .hby .prefixes :
58
60
raise kering .MissingEntryError (f"{ pre } not a valid AID" )
59
61
@@ -86,7 +88,11 @@ def receipt(self, pre, sn=None):
86
88
87
89
rcts = dict ()
88
90
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 )
90
96
while not client .responses :
91
97
yield self .tock
92
98
@@ -101,7 +107,7 @@ def receipt(self, pre, sn=None):
101
107
coring .Counter (qb64b = rct , strip = True )
102
108
rcts [wit ] = rct
103
109
else :
104
- logger . error (f"invalid response { rep .status } from witnesses { wit } " )
110
+ print (f"invalid response { rep .status } from witnesses { wit } " )
105
111
106
112
for wit in rcts :
107
113
ewits = [w for w in rcts if w != wit ]
@@ -1057,7 +1063,7 @@ def httpClient(hab, wit):
1057
1063
1058
1064
url = urls [kering .Schemes .http ] if kering .Schemes .http in urls else urls [kering .Schemes .https ]
1059
1065
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 )
1061
1067
clientDoer = http .clienting .ClientDoer (client = client )
1062
1068
1063
1069
return client , clientDoer
0 commit comments