Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing shamir recovery GUI bindings #9319

Merged
merged 6 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
526 changes: 526 additions & 0 deletions bindings/electron/src/index.d.ts

Large diffs are not rendered by default.

16,543 changes: 10,668 additions & 5,875 deletions bindings/electron/src/meths.rs

Large diffs are not rendered by default.

168 changes: 168 additions & 0 deletions bindings/generator/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Ref,
Enum,
EnumItemUnit,
NonZeroU8,
)
from .invite import DeviceSaveStrategy, AvailableDevice
from .config import ClientConfig
Expand Down Expand Up @@ -542,3 +543,170 @@ async def client_list_frozen_users(
client_handle: Handle,
) -> Result[list[UserID], ClientListFrozenUsersError]:
raise NotImplementedError


class ClientSetupShamirRecoveryError(ErrorVariant):
class Internal:
pass

class Stopped:
pass

class Offline:
pass

class InvalidCertificate:
pass

class TimestampOutOfBallpark:
server_timestamp: DateTime
client_timestamp: DateTime
ballpark_client_early_offset: float
ballpark_client_late_offset: float

class ThresholdBiggerThanSumOfShares:
pass

class TooManyShares:
pass

class AuthorAmongRecipients:
pass

class RecipientNotFound:
pass

class RecipientRevoked:
pass

class ShamirRecoveryAlreadyExists:
pass


async def client_setup_shamir_recovery(
client_handle: Handle,
per_recipient_shares: dict[UserID, NonZeroU8],
threshold: NonZeroU8,
) -> Result[None, ClientSetupShamirRecoveryError]:
raise NotImplementedError


class ClientDeleteShamirRecoveryError(ErrorVariant):
class Internal:
pass

class Stopped:
pass

class Offline:
pass

class InvalidCertificate:
pass

class TimestampOutOfBallpark:
server_timestamp: DateTime
client_timestamp: DateTime
ballpark_client_early_offset: float
ballpark_client_late_offset: float


async def client_delete_shamir_recovery(
client_handle: Handle,
) -> Result[None, ClientDeleteShamirRecoveryError]:
raise NotImplementedError


class SelfShamirRecoveryInfo(Variant):
class NeverSetup:
pass

class Deleted:
created_on: DateTime
created_by: DeviceID
threshold: NonZeroU8
per_recipient_shares: dict[UserID, NonZeroU8]
deleted_on: DateTime
deleted_by: DeviceID

class SetupAllValid:
created_on: DateTime
created_by: DeviceID
threshold: NonZeroU8
per_recipient_shares: dict[UserID, NonZeroU8]

class SetupWithRevokedRecipients:
created_on: DateTime
created_by: DeviceID
threshold: NonZeroU8
per_recipient_shares: dict[UserID, NonZeroU8]
revoked_recipients: set[UserID]

class SetupButUnusable:
created_on: DateTime
created_by: DeviceID
threshold: NonZeroU8
per_recipient_shares: dict[UserID, NonZeroU8]
revoked_recipients: set[UserID]


class ClientGetSelfShamirRecoveryError(ErrorVariant):
class Internal:
pass

class Stopped:
pass


async def client_get_self_shamir_recovery(
client_handle: Handle,
) -> Result[SelfShamirRecoveryInfo, ClientGetSelfShamirRecoveryError]:
raise NotImplementedError


class OtherShamirRecoveryInfo(Variant):
class Deleted:
user_id: UserID
created_on: DateTime
created_by: DeviceID
threshold: NonZeroU8
per_recipient_shares: dict[UserID, NonZeroU8]
deleted_on: DateTime
deleted_by: DeviceID

class SetupAllValid:
user_id: UserID
created_on: DateTime
created_by: DeviceID
threshold: NonZeroU8
per_recipient_shares: dict[UserID, NonZeroU8]

class SetupWithRevokedRecipients:
user_id: UserID
created_on: DateTime
created_by: DeviceID
threshold: NonZeroU8
per_recipient_shares: dict[UserID, NonZeroU8]
revoked_recipients: set[UserID]

class SetupButUnusable:
user_id: UserID
created_on: DateTime
created_by: DeviceID
threshold: NonZeroU8
per_recipient_shares: dict[UserID, NonZeroU8]
revoked_recipients: set[UserID]


class ClientListShamirRecoveriesForOthersError(ErrorVariant):
class Internal:
pass

class Stopped:
pass


async def client_list_shamir_recoveries_for_others(
client_handle: Handle,
) -> Result[list[OtherShamirRecoveryInfo], ClientListShamirRecoveriesForOthersError]:
raise NotImplementedError
14 changes: 14 additions & 0 deletions bindings/generator/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ class F64BasedType:
pass


# Types that should be converted into f64 on js side, but from u8 on rs side
class U8BasedType(int):
pass


# Types that should be converted into f64 on js side, but from i32 on rs side
class I32BasedType:
pass
Expand Down Expand Up @@ -113,6 +118,15 @@ class CustomConversionType:
#


class U8(U8BasedType):
pass


class NonZeroU8(U8BasedType):
custom_from_rs_u8 = "|x: u8| -> Result<std::num::NonZeroU8, _> { std::num::NonZeroU8::try_from(x).map_err(|e| e.to_string()) }"
custom_to_rs_u8 = "|x: std::num::NonZeroU8| -> Result<u8, &'static str> { Ok(x.get()) }"


class I32(I32BasedType):
pass

Expand Down
Loading
Loading