#![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,
};
pub const DEFAULT_ADMIN_ROLE_RANK: i64 = 800i64;
pub const DEFAULT_MEMBER_ROLE_RANK: i64 = 600i64;
pub const DEFAULT_OPERATOR_ROLE_RANK: i64 = 700i64;
pub const DEFAULT_OWNER_DEVICE_RANK: i64 = 1000000i64;
pub const DEFAULT_OWNER_ROLE_RANK: i64 = 999999i64;
pub const MAX_RANK: i64 = 1000000i64;
#[derive(Debug)]
pub enum Persistent {}
#[derive(Debug)]
pub enum Ephemeral {}
#[value]
pub struct PublicKeyBundle {
pub ident_key: Vec<u8>,
pub sign_key: Vec<u8>,
pub enc_key: Vec<u8>,
}
#[value]
pub enum ChanOp {
RecvOnly,
SendOnly,
SendRecv,
}
#[value]
pub enum Perm {
AddDevice,
RemoveDevice,
TerminateTeam,
ChangeRank,
CreateRole,
DeleteRole,
AssignRole,
RevokeRole,
ChangeRolePerms,
SetupDefaultRole,
CreateLabel,
DeleteLabel,
AssignLabel,
RevokeLabel,
CanUseAfc,
CreateAfcUniChannel,
}
#[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),
}
#[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>,
}
#[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>,
}
#[effect]
pub struct AssignedLabelToDevice {
pub device: BaseId,
pub label_id: BaseId,
pub author_id: BaseId,
}
#[effect]
pub struct CheckValidAfcChannels {}
#[effect]
pub struct DeviceAdded {
pub device_id: BaseId,
pub device_keys: PublicKeyBundle,
pub rank: i64,
}
#[effect]
pub struct DeviceRemoved {
pub device_id: BaseId,
pub author_id: BaseId,
}
#[effect]
pub struct LabelCreated {
pub label_id: BaseId,
pub label_name: Text,
pub rank: i64,
pub label_author_id: BaseId,
}
#[effect]
pub struct LabelDeleted {
pub label_name: Text,
pub label_author_id: BaseId,
pub label_id: BaseId,
pub author_id: BaseId,
}
#[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,
}
#[effect]
pub struct PermAddedToRole {
pub role_id: BaseId,
pub perm: Perm,
pub author_id: BaseId,
}
#[effect]
pub struct PermRemovedFromRole {
pub role_id: BaseId,
pub perm: Perm,
pub author_id: BaseId,
}
#[effect]
pub struct QueryAfcChannelIsValidResult {
pub sender_id: BaseId,
pub receiver_id: BaseId,
pub label_id: BaseId,
pub is_valid: bool,
}
#[effect]
pub struct QueryDeviceGenerationResult {
pub device_id: BaseId,
pub generation: i64,
}
#[effect]
pub struct QueryDeviceKeyBundleResult {
pub device_keys: PublicKeyBundle,
}
#[effect]
pub struct QueryDeviceRoleResult {
pub role_id: BaseId,
pub name: Text,
pub author_id: BaseId,
pub default: bool,
}
#[effect]
pub struct QueryDevicesOnTeamResult {
pub device_id: BaseId,
}
#[effect]
pub struct QueryLabelResult {
pub label_id: BaseId,
pub label_name: Text,
pub label_author_id: BaseId,
}
#[effect]
pub struct QueryLabelsAssignedToDeviceResult {
pub device_id: BaseId,
pub label_id: BaseId,
pub label_name: Text,
pub label_author_id: BaseId,
}
#[effect]
pub struct QueryLabelsResult {
pub label_id: BaseId,
pub label_name: Text,
pub label_author_id: BaseId,
}
#[effect]
pub struct QueryRankResult {
pub object_id: BaseId,
pub rank: i64,
}
#[effect]
pub struct QueryRoleHasPermResult {
pub role_id: BaseId,
pub perm: Perm,
}
#[effect]
pub struct QueryRolePermsResult {
pub role_id: BaseId,
pub perm: Perm,
}
#[effect]
pub struct QueryTeamRolesResult {
pub role_id: BaseId,
pub name: Text,
pub author_id: BaseId,
pub default: bool,
}
#[effect]
pub struct RankChanged {
pub object_id: BaseId,
pub old_rank: i64,
pub new_rank: i64,
}
#[effect]
pub struct RoleAssigned {
pub device_id: BaseId,
pub role_id: BaseId,
pub author_id: BaseId,
}
#[effect]
pub struct RoleChanged {
pub device_id: BaseId,
pub old_role_id: BaseId,
pub new_role_id: BaseId,
pub author_id: BaseId,
}
#[effect]
pub struct RoleCreated {
pub role_id: BaseId,
pub name: Text,
pub author_id: BaseId,
pub rank: i64,
pub default: bool,
}
#[effect]
pub struct RoleDeleted {
pub name: Text,
pub role_id: BaseId,
}
#[effect]
pub struct RoleRevoked {
pub device_id: BaseId,
pub role_id: BaseId,
pub author_id: BaseId,
}
#[effect]
pub struct TeamCreated {
pub team_id: BaseId,
pub owner_id: BaseId,
}
#[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),
}
#[action(interface = Ephemeral)]
pub struct query_devices_on_team {}
#[action(interface = Ephemeral)]
pub struct query_afc_channel_is_valid {
pub sender_id: BaseId,
pub receiver_id: BaseId,
pub label_id: BaseId,
}
#[action(interface = Ephemeral)]
pub struct query_device_role {
pub device_id: BaseId,
}
#[action(interface = Ephemeral)]
pub struct query_device_public_key_bundle {
pub device_id: BaseId,
}
#[action(interface = Persistent)]
pub struct change_rank {
pub object_id: BaseId,
pub old_rank: i64,
pub new_rank: i64,
}
#[action(interface = Ephemeral)]
pub struct query_rank {
pub object_id: BaseId,
}
#[action(interface = Ephemeral)]
pub struct query_device_generation {
pub device_id: BaseId,
}
#[action(interface = Persistent)]
pub struct add_perm_to_role {
pub role_id: BaseId,
pub perm: Perm,
}
#[action(interface = Persistent)]
pub struct remove_perm_from_role {
pub role_id: BaseId,
pub perm: Perm,
}
#[action(interface = Persistent)]
pub struct create_role {
pub role_name: Text,
pub rank: i64,
}
#[action(interface = Persistent)]
pub struct setup_default_roles {}
#[action(interface = Persistent)]
pub struct delete_role {
pub role_id: BaseId,
}
#[action(interface = Persistent)]
pub struct assign_role {
pub device_id: BaseId,
pub role_id: BaseId,
}
#[action(interface = Persistent)]
pub struct change_role {
pub device_id: BaseId,
pub old_role_id: BaseId,
pub new_role_id: BaseId,
}
#[action(interface = Persistent)]
pub struct revoke_role {
pub device_id: BaseId,
pub role_id: BaseId,
}
#[action(interface = Ephemeral)]
pub struct query_team_roles {}
#[action(interface = Persistent)]
pub struct create_team {
pub owner_keys: PublicKeyBundle,
pub nonce: Vec<u8>,
}
#[action(interface = Persistent)]
pub struct terminate_team {
pub team_id: BaseId,
}
#[action(interface = Persistent)]
pub struct add_device {
pub device_keys: PublicKeyBundle,
pub initial_role_id: Option<BaseId>,
pub rank: i64,
}
#[action(interface = Persistent)]
pub struct remove_device {
pub device_id: BaseId,
}
#[action(interface = Persistent)]
pub struct create_label {
pub name: Text,
pub rank: i64,
}
#[action(interface = Persistent)]
pub struct delete_label {
pub label_id: BaseId,
}
#[action(interface = Persistent)]
pub struct assign_label_to_device {
pub device_id: BaseId,
pub label_id: BaseId,
pub op: ChanOp,
}
#[action(interface = Persistent)]
pub struct revoke_label_from_device {
pub device_id: BaseId,
pub label_id: BaseId,
}
#[action(interface = Ephemeral)]
pub struct query_role_has_perm {
pub role_id: BaseId,
pub perm: Perm,
}
#[action(interface = Ephemeral)]
pub struct query_role_perms {
pub role_id: BaseId,
}
#[action(interface = Ephemeral)]
pub struct query_label {
pub label_id: BaseId,
}
#[action(interface = Ephemeral)]
pub struct query_labels {}
#[action(interface = Ephemeral)]
pub struct query_labels_assigned_to_device {
pub device_id: BaseId,
}
#[action(interface = Ephemeral)]
pub struct create_afc_uni_channel {
pub receiver_id: BaseId,
pub label_id: BaseId,
}