1#![cfg_attr(rustfmt, rustfmt::skip)]
3#![allow(clippy::duplicated_attributes)]
4#![allow(clippy::enum_variant_names)]
5#![allow(missing_docs)]
6#![allow(non_camel_case_types)]
7#![allow(non_snake_case)]
8#![allow(unused_imports)]
9extern crate alloc;
10use alloc::vec::Vec;
11use aranya_policy_ifgen::{
12 macros::{action, actions, effect, effects, value},
13 BaseId, ClientError, Value, Text,
14};
15#[derive(Debug)]
16pub enum Persistent {}
17#[derive(Debug)]
18pub enum Ephemeral {}
19#[value]
21pub struct PublicKeyBundle {
22 pub ident_key: Vec<u8>,
23 pub sign_key: Vec<u8>,
24 pub enc_key: Vec<u8>,
25}
26#[value]
28pub enum ChanOp {
29 RecvOnly,
30 SendOnly,
31 SendRecv,
32}
33#[value]
35pub enum RoleManagementPerm {
36 CanAssignRole,
37 CanRevokeRole,
38 CanChangeRolePerms,
39}
40#[value]
42pub enum SimplePerm {
43 AddDevice,
44 RemoveDevice,
45 TerminateTeam,
46 CreateRole,
47 DeleteRole,
48 AssignRole,
49 RevokeRole,
50 ChangeRoleManagementPerms,
51 SetupDefaultRole,
52 ChangeRoleManagingRole,
53 CreateLabel,
54 DeleteLabel,
55 ChangeLabelManagingRole,
56 AssignLabel,
57 RevokeLabel,
58 CanUseAfc,
59 CreateAfcUniChannel,
60}
61#[effects]
63pub enum Effect {
64 AfcUniChannelCreated(AfcUniChannelCreated),
65 AfcUniChannelReceived(AfcUniChannelReceived),
66 AssignedLabelToDevice(AssignedLabelToDevice),
67 CheckValidAfcChannels(CheckValidAfcChannels),
68 DeviceAdded(DeviceAdded),
69 DeviceRemoved(DeviceRemoved),
70 LabelCreated(LabelCreated),
71 LabelDeleted(LabelDeleted),
72 LabelManagingRoleAdded(LabelManagingRoleAdded),
73 LabelManagingRoleRevoked(LabelManagingRoleRevoked),
74 LabelRevokedFromDevice(LabelRevokedFromDevice),
75 PermAddedToRole(PermAddedToRole),
76 PermRemovedFromRole(PermRemovedFromRole),
77 QueryAfcChannelIsValidResult(QueryAfcChannelIsValidResult),
78 QueryDeviceKeyBundleResult(QueryDeviceKeyBundleResult),
79 QueryDeviceRoleResult(QueryDeviceRoleResult),
80 QueryDevicesOnTeamResult(QueryDevicesOnTeamResult),
81 QueryLabelResult(QueryLabelResult),
82 QueryLabelsAssignedToDeviceResult(QueryLabelsAssignedToDeviceResult),
83 QueryLabelsResult(QueryLabelsResult),
84 QueryRoleOwnersResult(QueryRoleOwnersResult),
85 QueryTeamRolesResult(QueryTeamRolesResult),
86 RoleAssigned(RoleAssigned),
87 RoleChanged(RoleChanged),
88 RoleCreated(RoleCreated),
89 RoleDeleted(RoleDeleted),
90 RoleManagementPermAssigned(RoleManagementPermAssigned),
91 RoleManagementPermRevoked(RoleManagementPermRevoked),
92 RoleOwnerAdded(RoleOwnerAdded),
93 RoleOwnerRemoved(RoleOwnerRemoved),
94 RoleRevoked(RoleRevoked),
95 TeamCreated(TeamCreated),
96 TeamTerminated(TeamTerminated),
97}
98#[effect]
100pub struct AfcUniChannelCreated {
101 pub parent_cmd_id: BaseId,
102 pub receiver_id: BaseId,
103 pub author_enc_key_id: BaseId,
104 pub peer_enc_pk: Vec<u8>,
105 pub label_id: BaseId,
106 pub channel_key_id: BaseId,
107 pub encap: Vec<u8>,
108}
109#[effect]
111pub struct AfcUniChannelReceived {
112 pub parent_cmd_id: BaseId,
113 pub sender_id: BaseId,
114 pub author_enc_pk: Vec<u8>,
115 pub peer_enc_key_id: BaseId,
116 pub label_id: BaseId,
117 pub encap: Vec<u8>,
118}
119#[effect]
121pub struct AssignedLabelToDevice {
122 pub device: BaseId,
123 pub label_id: BaseId,
124 pub author_id: BaseId,
125}
126#[effect]
128pub struct CheckValidAfcChannels {}
129#[effect]
131pub struct DeviceAdded {
132 pub device_id: BaseId,
133 pub device_keys: PublicKeyBundle,
134}
135#[effect]
137pub struct DeviceRemoved {
138 pub device_id: BaseId,
139 pub author_id: BaseId,
140}
141#[effect]
143pub struct LabelCreated {
144 pub label_id: BaseId,
145 pub label_name: Text,
146 pub label_author_id: BaseId,
147 pub managing_role_id: BaseId,
148}
149#[effect]
151pub struct LabelDeleted {
152 pub label_name: Text,
153 pub label_author_id: BaseId,
154 pub label_id: BaseId,
155 pub author_id: BaseId,
156}
157#[effect]
159pub struct LabelManagingRoleAdded {
160 pub label_id: BaseId,
161 pub managing_role_id: BaseId,
162 pub author_id: BaseId,
163}
164#[effect]
166pub struct LabelManagingRoleRevoked {
167 pub label_id: BaseId,
168 pub managing_role_id: BaseId,
169 pub author_id: BaseId,
170}
171#[effect]
173pub struct LabelRevokedFromDevice {
174 pub device_id: BaseId,
175 pub label_id: BaseId,
176 pub label_name: Text,
177 pub label_author_id: BaseId,
178 pub author_id: BaseId,
179}
180#[effect]
182pub struct PermAddedToRole {
183 pub role_id: BaseId,
184 pub perm: SimplePerm,
185 pub author_id: BaseId,
186}
187#[effect]
189pub struct PermRemovedFromRole {
190 pub role_id: BaseId,
191 pub perm: SimplePerm,
192 pub author_id: BaseId,
193}
194#[effect]
196pub struct QueryAfcChannelIsValidResult {
197 pub sender_id: BaseId,
198 pub receiver_id: BaseId,
199 pub label_id: BaseId,
200 pub is_valid: bool,
201}
202#[effect]
204pub struct QueryDeviceKeyBundleResult {
205 pub device_keys: PublicKeyBundle,
206}
207#[effect]
209pub struct QueryDeviceRoleResult {
210 pub role_id: BaseId,
211 pub name: Text,
212 pub author_id: BaseId,
213 pub default: bool,
214}
215#[effect]
217pub struct QueryDevicesOnTeamResult {
218 pub device_id: BaseId,
219}
220#[effect]
222pub struct QueryLabelResult {
223 pub label_id: BaseId,
224 pub label_name: Text,
225 pub label_author_id: BaseId,
226}
227#[effect]
229pub struct QueryLabelsAssignedToDeviceResult {
230 pub device_id: BaseId,
231 pub label_id: BaseId,
232 pub label_name: Text,
233 pub label_author_id: BaseId,
234}
235#[effect]
237pub struct QueryLabelsResult {
238 pub label_id: BaseId,
239 pub label_name: Text,
240 pub label_author_id: BaseId,
241}
242#[effect]
244pub struct QueryRoleOwnersResult {
245 pub role_id: BaseId,
246 pub name: Text,
247 pub author_id: BaseId,
248 pub default: bool,
249}
250#[effect]
252pub struct QueryTeamRolesResult {
253 pub role_id: BaseId,
254 pub name: Text,
255 pub author_id: BaseId,
256 pub default: bool,
257}
258#[effect]
260pub struct RoleAssigned {
261 pub device_id: BaseId,
262 pub role_id: BaseId,
263 pub author_id: BaseId,
264}
265#[effect]
267pub struct RoleChanged {
268 pub device_id: BaseId,
269 pub old_role_id: BaseId,
270 pub new_role_id: BaseId,
271 pub author_id: BaseId,
272}
273#[effect]
275pub struct RoleCreated {
276 pub role_id: BaseId,
277 pub name: Text,
278 pub author_id: BaseId,
279 pub owning_role_id: BaseId,
280 pub default: bool,
281}
282#[effect]
284pub struct RoleDeleted {
285 pub name: Text,
286 pub role_id: BaseId,
287}
288#[effect]
290pub struct RoleManagementPermAssigned {
291 pub target_role_id: BaseId,
292 pub managing_role_id: BaseId,
293 pub perm: RoleManagementPerm,
294 pub author_id: BaseId,
295}
296#[effect]
298pub struct RoleManagementPermRevoked {
299 pub target_role_id: BaseId,
300 pub managing_role_id: BaseId,
301 pub perm: RoleManagementPerm,
302 pub author_id: BaseId,
303}
304#[effect]
306pub struct RoleOwnerAdded {
307 pub target_role_id: BaseId,
308 pub new_role_owner: BaseId,
309 pub author_id: BaseId,
310}
311#[effect]
313pub struct RoleOwnerRemoved {
314 pub target_role_id: BaseId,
315 pub owning_role_id: BaseId,
316 pub author_id: BaseId,
317}
318#[effect]
320pub struct RoleRevoked {
321 pub device_id: BaseId,
322 pub role_id: BaseId,
323 pub author_id: BaseId,
324}
325#[effect]
327pub struct TeamCreated {
328 pub team_id: BaseId,
329 pub owner_id: BaseId,
330}
331#[effect]
333pub struct TeamTerminated {
334 pub team_id: BaseId,
335 pub owner_id: BaseId,
336}
337#[actions(interface = Persistent)]
338pub enum PersistentAction {
339 add_perm_to_role(add_perm_to_role),
340 remove_perm_from_role(remove_perm_from_role),
341 add_role_owner(add_role_owner),
342 remove_role_owner(remove_role_owner),
343 assign_role_management_perm(assign_role_management_perm),
344 revoke_role_management_perm(revoke_role_management_perm),
345 create_role(create_role),
346 setup_default_roles(setup_default_roles),
347 delete_role(delete_role),
348 assign_role(assign_role),
349 change_role(change_role),
350 revoke_role(revoke_role),
351 create_team(create_team),
352 terminate_team(terminate_team),
353 add_device(add_device),
354 remove_device(remove_device),
355 add_label_managing_role(add_label_managing_role),
356 revoke_label_managing_role(revoke_label_managing_role),
357 create_label(create_label),
358 delete_label(delete_label),
359 assign_label_to_device(assign_label_to_device),
360 revoke_label_from_device(revoke_label_from_device),
361}
362#[actions(interface = Ephemeral)]
363pub enum EphemeralAction {
364 query_devices_on_team(query_devices_on_team),
365 query_afc_channel_is_valid(query_afc_channel_is_valid),
366 query_device_role(query_device_role),
367 query_device_public_key_bundle(query_device_public_key_bundle),
368 query_team_roles(query_team_roles),
369 query_role_owners(query_role_owners),
370 query_label(query_label),
371 query_labels(query_labels),
372 query_labels_assigned_to_device(query_labels_assigned_to_device),
373 create_afc_uni_channel(create_afc_uni_channel),
374}
375#[action(interface = Ephemeral)]
377pub struct query_devices_on_team {}
378#[action(interface = Ephemeral)]
380pub struct query_afc_channel_is_valid {
381 pub sender_id: BaseId,
382 pub receiver_id: BaseId,
383 pub label_id: BaseId,
384}
385#[action(interface = Ephemeral)]
387pub struct query_device_role {
388 pub device_id: BaseId,
389}
390#[action(interface = Ephemeral)]
392pub struct query_device_public_key_bundle {
393 pub device_id: BaseId,
394}
395#[action(interface = Persistent)]
397pub struct add_perm_to_role {
398 pub role_id: BaseId,
399 pub perm: SimplePerm,
400}
401#[action(interface = Persistent)]
403pub struct remove_perm_from_role {
404 pub role_id: BaseId,
405 pub perm: SimplePerm,
406}
407#[action(interface = Persistent)]
409pub struct add_role_owner {
410 pub target_role_id: BaseId,
411 pub new_owning_role: BaseId,
412}
413#[action(interface = Persistent)]
415pub struct remove_role_owner {
416 pub target_role_id: BaseId,
417 pub owning_role_id: BaseId,
418}
419#[action(interface = Persistent)]
421pub struct assign_role_management_perm {
422 pub target_role_id: BaseId,
423 pub managing_role_id: BaseId,
424 pub perm: RoleManagementPerm,
425}
426#[action(interface = Persistent)]
428pub struct revoke_role_management_perm {
429 pub target_role_id: BaseId,
430 pub managing_role_id: BaseId,
431 pub perm: RoleManagementPerm,
432}
433#[action(interface = Persistent)]
435pub struct create_role {
436 pub role_name: Text,
437 pub owning_role_id: BaseId,
438}
439#[action(interface = Persistent)]
441pub struct setup_default_roles {
442 pub owning_role_id: BaseId,
443}
444#[action(interface = Persistent)]
446pub struct delete_role {
447 pub role_id: BaseId,
448}
449#[action(interface = Persistent)]
451pub struct assign_role {
452 pub device_id: BaseId,
453 pub role_id: BaseId,
454}
455#[action(interface = Persistent)]
457pub struct change_role {
458 pub device_id: BaseId,
459 pub old_role_id: BaseId,
460 pub new_role_id: BaseId,
461}
462#[action(interface = Persistent)]
464pub struct revoke_role {
465 pub device_id: BaseId,
466 pub role_id: BaseId,
467}
468#[action(interface = Ephemeral)]
470pub struct query_team_roles {}
471#[action(interface = Ephemeral)]
473pub struct query_role_owners {
474 pub role_id: BaseId,
475}
476#[action(interface = Persistent)]
478pub struct create_team {
479 pub owner_keys: PublicKeyBundle,
480 pub nonce: Vec<u8>,
481}
482#[action(interface = Persistent)]
484pub struct terminate_team {
485 pub team_id: BaseId,
486}
487#[action(interface = Persistent)]
489pub struct add_device {
490 pub device_keys: PublicKeyBundle,
491 pub initial_role_id: Option<BaseId>,
492}
493#[action(interface = Persistent)]
495pub struct remove_device {
496 pub device_id: BaseId,
497}
498#[action(interface = Persistent)]
500pub struct add_label_managing_role {
501 pub label_id: BaseId,
502 pub managing_role_id: BaseId,
503}
504#[action(interface = Persistent)]
506pub struct revoke_label_managing_role {
507 pub label_id: BaseId,
508 pub managing_role_id: BaseId,
509}
510#[action(interface = Persistent)]
512pub struct create_label {
513 pub name: Text,
514 pub managing_role_id: BaseId,
515}
516#[action(interface = Persistent)]
518pub struct delete_label {
519 pub label_id: BaseId,
520}
521#[action(interface = Persistent)]
523pub struct assign_label_to_device {
524 pub device_id: BaseId,
525 pub label_id: BaseId,
526 pub op: ChanOp,
527}
528#[action(interface = Persistent)]
530pub struct revoke_label_from_device {
531 pub device_id: BaseId,
532 pub label_id: BaseId,
533}
534#[action(interface = Ephemeral)]
536pub struct query_label {
537 pub label_id: BaseId,
538}
539#[action(interface = Ephemeral)]
541pub struct query_labels {}
542#[action(interface = Ephemeral)]
544pub struct query_labels_assigned_to_device {
545 pub device_id: BaseId,
546}
547#[action(interface = Ephemeral)]
549pub struct create_afc_uni_channel {
550 pub receiver_id: BaseId,
551 pub label_id: BaseId,
552}