aranya-daemon 6.0.0

Daemon process for syncing with Aranya peers and maintaining the DAG
Documentation
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
//! This code is @generated by `policy-ifgen`. DO NOT EDIT.
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(clippy::duplicated_attributes)]
#![allow(clippy::enum_variant_names)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(unused_imports)]
extern crate alloc;
use alloc::vec::Vec;
use aranya_policy_ifgen::{
    macros::{action, actions, effect, effects, value},
    text, BaseId, ClientError, Value, Text,
};
/// DEFAULT_ADMIN_ROLE_RANK constant.
pub const DEFAULT_ADMIN_ROLE_RANK: i64 = 800i64;
/// DEFAULT_MEMBER_ROLE_RANK constant.
pub const DEFAULT_MEMBER_ROLE_RANK: i64 = 600i64;
/// DEFAULT_OPERATOR_ROLE_RANK constant.
pub const DEFAULT_OPERATOR_ROLE_RANK: i64 = 700i64;
/// DEFAULT_OWNER_DEVICE_RANK constant.
pub const DEFAULT_OWNER_DEVICE_RANK: i64 = 1000000i64;
/// DEFAULT_OWNER_ROLE_RANK constant.
pub const DEFAULT_OWNER_ROLE_RANK: i64 = 999999i64;
/// MAX_RANK constant.
pub const MAX_RANK: i64 = 1000000i64;
#[derive(Debug)]
pub enum Persistent {}
#[derive(Debug)]
pub enum Ephemeral {}
/// PublicKeyBundle policy struct.
#[value]
pub struct PublicKeyBundle {
    pub ident_key: Vec<u8>,
    pub sign_key: Vec<u8>,
    pub enc_key: Vec<u8>,
}
/// ChanOp policy enum.
#[value]
pub enum ChanOp {
    RecvOnly,
    SendOnly,
    SendRecv,
}
/// Perm policy enum.
#[value]
pub enum Perm {
    AddDevice,
    RemoveDevice,
    TerminateTeam,
    ChangeRank,
    CreateRole,
    DeleteRole,
    AssignRole,
    RevokeRole,
    ChangeRolePerms,
    SetupDefaultRole,
    CreateLabel,
    DeleteLabel,
    AssignLabel,
    RevokeLabel,
    CanUseAfc,
    CreateAfcUniChannel,
}
/// Enum of policy effects that can occur in response to a policy action.
#[effects]
pub enum Effect {
    AfcUniChannelCreated(AfcUniChannelCreated),
    AfcUniChannelReceived(AfcUniChannelReceived),
    AssignedLabelToDevice(AssignedLabelToDevice),
    CheckValidAfcChannels(CheckValidAfcChannels),
    DeviceAdded(DeviceAdded),
    DeviceRemoved(DeviceRemoved),
    LabelCreated(LabelCreated),
    LabelDeleted(LabelDeleted),
    LabelRevokedFromDevice(LabelRevokedFromDevice),
    PermAddedToRole(PermAddedToRole),
    PermRemovedFromRole(PermRemovedFromRole),
    QueryAfcChannelIsValidResult(QueryAfcChannelIsValidResult),
    QueryDeviceGenerationResult(QueryDeviceGenerationResult),
    QueryDeviceKeyBundleResult(QueryDeviceKeyBundleResult),
    QueryDeviceRoleResult(QueryDeviceRoleResult),
    QueryDevicesOnTeamResult(QueryDevicesOnTeamResult),
    QueryLabelResult(QueryLabelResult),
    QueryLabelsAssignedToDeviceResult(QueryLabelsAssignedToDeviceResult),
    QueryLabelsResult(QueryLabelsResult),
    QueryRankResult(QueryRankResult),
    QueryRoleHasPermResult(QueryRoleHasPermResult),
    QueryRolePermsResult(QueryRolePermsResult),
    QueryTeamRolesResult(QueryTeamRolesResult),
    RankChanged(RankChanged),
    RoleAssigned(RoleAssigned),
    RoleChanged(RoleChanged),
    RoleCreated(RoleCreated),
    RoleDeleted(RoleDeleted),
    RoleRevoked(RoleRevoked),
    TeamCreated(TeamCreated),
    TeamTerminated(TeamTerminated),
}
/// AfcUniChannelCreated policy effect.
#[effect]
pub struct AfcUniChannelCreated {
    pub parent_cmd_id: BaseId,
    pub receiver_id: BaseId,
    pub author_enc_key_id: BaseId,
    pub peer_enc_pk: Vec<u8>,
    pub label_id: BaseId,
    pub channel_key_id: BaseId,
    pub encap: Vec<u8>,
}
/// AfcUniChannelReceived policy effect.
#[effect]
pub struct AfcUniChannelReceived {
    pub parent_cmd_id: BaseId,
    pub sender_id: BaseId,
    pub author_enc_pk: Vec<u8>,
    pub peer_enc_key_id: BaseId,
    pub label_id: BaseId,
    pub encap: Vec<u8>,
}
/// AssignedLabelToDevice policy effect.
#[effect]
pub struct AssignedLabelToDevice {
    pub device: BaseId,
    pub label_id: BaseId,
    pub author_id: BaseId,
}
/// CheckValidAfcChannels policy effect.
#[effect]
pub struct CheckValidAfcChannels {}
/// DeviceAdded policy effect.
#[effect]
pub struct DeviceAdded {
    pub device_id: BaseId,
    pub device_keys: PublicKeyBundle,
    pub rank: i64,
}
/// DeviceRemoved policy effect.
#[effect]
pub struct DeviceRemoved {
    pub device_id: BaseId,
    pub author_id: BaseId,
}
/// LabelCreated policy effect.
#[effect]
pub struct LabelCreated {
    pub label_id: BaseId,
    pub label_name: Text,
    pub rank: i64,
    pub label_author_id: BaseId,
}
/// LabelDeleted policy effect.
#[effect]
pub struct LabelDeleted {
    pub label_name: Text,
    pub label_author_id: BaseId,
    pub label_id: BaseId,
    pub author_id: BaseId,
}
/// LabelRevokedFromDevice policy effect.
#[effect]
pub struct LabelRevokedFromDevice {
    pub device_id: BaseId,
    pub label_id: BaseId,
    pub label_name: Text,
    pub label_author_id: BaseId,
    pub author_id: BaseId,
}
/// PermAddedToRole policy effect.
#[effect]
pub struct PermAddedToRole {
    pub role_id: BaseId,
    pub perm: Perm,
    pub author_id: BaseId,
}
/// PermRemovedFromRole policy effect.
#[effect]
pub struct PermRemovedFromRole {
    pub role_id: BaseId,
    pub perm: Perm,
    pub author_id: BaseId,
}
/// QueryAfcChannelIsValidResult policy effect.
#[effect]
pub struct QueryAfcChannelIsValidResult {
    pub sender_id: BaseId,
    pub receiver_id: BaseId,
    pub label_id: BaseId,
    pub is_valid: bool,
}
/// QueryDeviceGenerationResult policy effect.
#[effect]
pub struct QueryDeviceGenerationResult {
    pub device_id: BaseId,
    pub generation: i64,
}
/// QueryDeviceKeyBundleResult policy effect.
#[effect]
pub struct QueryDeviceKeyBundleResult {
    pub device_keys: PublicKeyBundle,
}
/// QueryDeviceRoleResult policy effect.
#[effect]
pub struct QueryDeviceRoleResult {
    pub role_id: BaseId,
    pub name: Text,
    pub author_id: BaseId,
    pub default: bool,
}
/// QueryDevicesOnTeamResult policy effect.
#[effect]
pub struct QueryDevicesOnTeamResult {
    pub device_id: BaseId,
}
/// QueryLabelResult policy effect.
#[effect]
pub struct QueryLabelResult {
    pub label_id: BaseId,
    pub label_name: Text,
    pub label_author_id: BaseId,
}
/// QueryLabelsAssignedToDeviceResult policy effect.
#[effect]
pub struct QueryLabelsAssignedToDeviceResult {
    pub device_id: BaseId,
    pub label_id: BaseId,
    pub label_name: Text,
    pub label_author_id: BaseId,
}
/// QueryLabelsResult policy effect.
#[effect]
pub struct QueryLabelsResult {
    pub label_id: BaseId,
    pub label_name: Text,
    pub label_author_id: BaseId,
}
/// QueryRankResult policy effect.
#[effect]
pub struct QueryRankResult {
    pub object_id: BaseId,
    pub rank: i64,
}
/// QueryRoleHasPermResult policy effect.
#[effect]
pub struct QueryRoleHasPermResult {
    pub role_id: BaseId,
    pub perm: Perm,
}
/// QueryRolePermsResult policy effect.
#[effect]
pub struct QueryRolePermsResult {
    pub role_id: BaseId,
    pub perm: Perm,
}
/// QueryTeamRolesResult policy effect.
#[effect]
pub struct QueryTeamRolesResult {
    pub role_id: BaseId,
    pub name: Text,
    pub author_id: BaseId,
    pub default: bool,
}
/// RankChanged policy effect.
#[effect]
pub struct RankChanged {
    pub object_id: BaseId,
    pub old_rank: i64,
    pub new_rank: i64,
}
/// RoleAssigned policy effect.
#[effect]
pub struct RoleAssigned {
    pub device_id: BaseId,
    pub role_id: BaseId,
    pub author_id: BaseId,
}
/// RoleChanged policy effect.
#[effect]
pub struct RoleChanged {
    pub device_id: BaseId,
    pub old_role_id: BaseId,
    pub new_role_id: BaseId,
    pub author_id: BaseId,
}
/// RoleCreated policy effect.
#[effect]
pub struct RoleCreated {
    pub role_id: BaseId,
    pub name: Text,
    pub author_id: BaseId,
    pub rank: i64,
    pub default: bool,
}
/// RoleDeleted policy effect.
#[effect]
pub struct RoleDeleted {
    pub name: Text,
    pub role_id: BaseId,
}
/// RoleRevoked policy effect.
#[effect]
pub struct RoleRevoked {
    pub device_id: BaseId,
    pub role_id: BaseId,
    pub author_id: BaseId,
}
/// TeamCreated policy effect.
#[effect]
pub struct TeamCreated {
    pub team_id: BaseId,
    pub owner_id: BaseId,
}
/// TeamTerminated policy effect.
#[effect]
pub struct TeamTerminated {
    pub team_id: BaseId,
    pub owner_id: BaseId,
}
#[actions(interface = Persistent)]
pub enum PersistentAction {
    change_rank(change_rank),
    add_perm_to_role(add_perm_to_role),
    remove_perm_from_role(remove_perm_from_role),
    create_role(create_role),
    setup_default_roles(setup_default_roles),
    delete_role(delete_role),
    assign_role(assign_role),
    change_role(change_role),
    revoke_role(revoke_role),
    create_team(create_team),
    terminate_team(terminate_team),
    add_device(add_device),
    remove_device(remove_device),
    create_label(create_label),
    delete_label(delete_label),
    assign_label_to_device(assign_label_to_device),
    revoke_label_from_device(revoke_label_from_device),
}
#[actions(interface = Ephemeral)]
pub enum EphemeralAction {
    query_devices_on_team(query_devices_on_team),
    query_afc_channel_is_valid(query_afc_channel_is_valid),
    query_device_role(query_device_role),
    query_device_public_key_bundle(query_device_public_key_bundle),
    query_rank(query_rank),
    query_device_generation(query_device_generation),
    query_team_roles(query_team_roles),
    query_role_has_perm(query_role_has_perm),
    query_role_perms(query_role_perms),
    query_label(query_label),
    query_labels(query_labels),
    query_labels_assigned_to_device(query_labels_assigned_to_device),
    create_afc_uni_channel(create_afc_uni_channel),
}
/// query_devices_on_team policy action.
#[action(interface = Ephemeral)]
pub struct query_devices_on_team {}
/// query_afc_channel_is_valid policy action.
#[action(interface = Ephemeral)]
pub struct query_afc_channel_is_valid {
    pub sender_id: BaseId,
    pub receiver_id: BaseId,
    pub label_id: BaseId,
}
/// query_device_role policy action.
#[action(interface = Ephemeral)]
pub struct query_device_role {
    pub device_id: BaseId,
}
/// query_device_public_key_bundle policy action.
#[action(interface = Ephemeral)]
pub struct query_device_public_key_bundle {
    pub device_id: BaseId,
}
/// change_rank policy action.
#[action(interface = Persistent)]
pub struct change_rank {
    pub object_id: BaseId,
    pub old_rank: i64,
    pub new_rank: i64,
}
/// query_rank policy action.
#[action(interface = Ephemeral)]
pub struct query_rank {
    pub object_id: BaseId,
}
/// query_device_generation policy action.
#[action(interface = Ephemeral)]
pub struct query_device_generation {
    pub device_id: BaseId,
}
/// add_perm_to_role policy action.
#[action(interface = Persistent)]
pub struct add_perm_to_role {
    pub role_id: BaseId,
    pub perm: Perm,
}
/// remove_perm_from_role policy action.
#[action(interface = Persistent)]
pub struct remove_perm_from_role {
    pub role_id: BaseId,
    pub perm: Perm,
}
/// create_role policy action.
#[action(interface = Persistent)]
pub struct create_role {
    pub role_name: Text,
    pub rank: i64,
}
/// setup_default_roles policy action.
#[action(interface = Persistent)]
pub struct setup_default_roles {}
/// delete_role policy action.
#[action(interface = Persistent)]
pub struct delete_role {
    pub role_id: BaseId,
}
/// assign_role policy action.
#[action(interface = Persistent)]
pub struct assign_role {
    pub device_id: BaseId,
    pub role_id: BaseId,
}
/// change_role policy action.
#[action(interface = Persistent)]
pub struct change_role {
    pub device_id: BaseId,
    pub old_role_id: BaseId,
    pub new_role_id: BaseId,
}
/// revoke_role policy action.
#[action(interface = Persistent)]
pub struct revoke_role {
    pub device_id: BaseId,
    pub role_id: BaseId,
}
/// query_team_roles policy action.
#[action(interface = Ephemeral)]
pub struct query_team_roles {}
/// create_team policy action.
#[action(interface = Persistent)]
pub struct create_team {
    pub owner_keys: PublicKeyBundle,
    pub nonce: Vec<u8>,
}
/// terminate_team policy action.
#[action(interface = Persistent)]
pub struct terminate_team {
    pub team_id: BaseId,
}
/// add_device policy action.
#[action(interface = Persistent)]
pub struct add_device {
    pub device_keys: PublicKeyBundle,
    pub initial_role_id: Option<BaseId>,
    pub rank: i64,
}
/// remove_device policy action.
#[action(interface = Persistent)]
pub struct remove_device {
    pub device_id: BaseId,
}
/// create_label policy action.
#[action(interface = Persistent)]
pub struct create_label {
    pub name: Text,
    pub rank: i64,
}
/// delete_label policy action.
#[action(interface = Persistent)]
pub struct delete_label {
    pub label_id: BaseId,
}
/// assign_label_to_device policy action.
#[action(interface = Persistent)]
pub struct assign_label_to_device {
    pub device_id: BaseId,
    pub label_id: BaseId,
    pub op: ChanOp,
}
/// revoke_label_from_device policy action.
#[action(interface = Persistent)]
pub struct revoke_label_from_device {
    pub device_id: BaseId,
    pub label_id: BaseId,
}
/// query_role_has_perm policy action.
#[action(interface = Ephemeral)]
pub struct query_role_has_perm {
    pub role_id: BaseId,
    pub perm: Perm,
}
/// query_role_perms policy action.
#[action(interface = Ephemeral)]
pub struct query_role_perms {
    pub role_id: BaseId,
}
/// query_label policy action.
#[action(interface = Ephemeral)]
pub struct query_label {
    pub label_id: BaseId,
}
/// query_labels policy action.
#[action(interface = Ephemeral)]
pub struct query_labels {}
/// query_labels_assigned_to_device policy action.
#[action(interface = Ephemeral)]
pub struct query_labels_assigned_to_device {
    pub device_id: BaseId,
}
/// create_afc_uni_channel policy action.
#[action(interface = Ephemeral)]
pub struct create_afc_uni_channel {
    pub receiver_id: BaseId,
    pub label_id: BaseId,
}