1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//! Injected broker callbacks and the signed ML grant they verify.
use Arc;
use Uuid;
use SignalEnvelope;
use ;
use crate;
/// Widget signal listener.
/// # Examples
/// ```
/// use std::sync::Arc;
/// use drishti::native_host::broker::SignalListener;
/// let listener: SignalListener = Arc::new(|envelope| drop(envelope));
/// assert_eq!(Arc::strong_count(&listener), 1);
/// ```
pub type SignalListener = ;
/// Tap event listener.
/// # Examples
/// ```
/// use std::sync::Arc;
/// use drishti::native_host::broker::TapListener;
/// let listener: TapListener = Arc::new(|event| drop(event));
/// assert_eq!(Arc::strong_count(&listener), 1);
/// ```
pub type TapListener = ;
/// Injected millisecond clock (frozen in tests, wall time in production).
/// # Examples
/// ```
/// use std::sync::Arc;
/// use drishti::native_host::broker::ClockFn;
/// let frozen: ClockFn = Arc::new(|| 1_000);
/// assert_eq!((frozen(), frozen()), (1_000, 1_000));
/// ```
pub type ClockFn = ;
/// Injected envelope identity (counter in tests, random v4 in production).
/// # Examples
/// ```
/// use std::sync::Arc;
/// use drishti::native_host::broker::IdFn;
/// let fixed: IdFn = Arc::new(|| lgwks_std::id::Uuid::from([7_u8; 16]));
/// assert_eq!(fixed(), fixed());
/// ```
pub type IdFn = ;
/// Injected ML grant verifier (tests decide; production verifies Ed25519).
/// # Examples
/// ```
/// use std::sync::Arc;
/// use drishti::canvas_protocol::Capability;
/// use drishti::native_host::broker::{GrantVerificationResult, SignedMlGrant, VerifyGrantFn};
/// let reject: VerifyGrantFn = Arc::new(|_| GrantVerificationResult::InvalidSignature);
/// let grant = SignedMlGrant::new(lgwks_std::id::Uuid::from([1_u8; 16]), "t".into(), vec![Capability::TapeRead], 9, 1, vec![]);
/// assert_eq!(reject(&grant), GrantVerificationResult::InvalidSignature);
/// ```
pub type VerifyGrantFn = ;
/// Injected grant store: does this session hold this permission? Asked at
/// every gated decision, so a flip between two calls decides the second.
/// # Examples
/// ```
/// use std::sync::Arc;
/// use drishti::canvas_protocol::Capability;
/// use drishti::native_host::broker::{GrantFn, Permission};
/// let deny_all: GrantFn = Arc::new(|_, _| false);
/// let session = drishti::cli::drive::session(&mut String::new(), "t")?;
/// assert!(!deny_all(&session, &Permission::Capability(Capability::IntentEmit)));
/// # Ok::<(), drishti::cli::Failure>(())
/// ```
pub type GrantFn = ;
/// Injected audit sink: sees every decision, required at construction.
/// # Examples
/// ```
/// use std::sync::Arc;
/// use drishti::native_host::broker::{AuditEvent, AuditFn};
/// let sink: AuditFn = Arc::new(|event: &AuditEvent| drop(event.seq()));
/// assert_eq!(Arc::strong_count(&sink), 1);
/// ```
pub type AuditFn = ;
/// ML grant verification outcome.
/// # Examples
/// ```
/// use drishti::native_host::broker::GrantVerificationResult;
/// assert_ne!(GrantVerificationResult::Valid, GrantVerificationResult::Expired);
/// ```
/// Signed ML grant. The signature covers the grant fields; verification is
/// injected so tests decide and production checks Ed25519.
///
/// Fields are private: construction runs through [`SignedMlGrant::new`] and
/// reads go through the accessors.
/// # Examples
/// ```
/// use drishti::canvas_protocol::Capability;
/// use drishti::native_host::broker::SignedMlGrant;
/// let grant = SignedMlGrant::new(lgwks_std::id::Uuid::from([1_u8; 16]), "t".into(), vec![Capability::TapeRead], 9, 1, vec![0xAA]);
/// assert_eq!(grant.tenant_id(), "t");
/// ```