-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API surface exposed is equivalent to the Rust API, including plugin callbacks (duck-typed at runtime, exposed in type stubs as a `pyrage.plugin.Callbacks` protocol, all of which's methods are required to be implemented at runtime, otherwise `AttributeError` is thrown). Non-`Clone`ability of plugin instances is resolved by putting them behind an `Arc`. Perhaps a more elegant solution could be produced later, by someone with more knowledge of PyO3 internals. This was tested with rage's example `age-unencrypted-plugin` which happens to exercise the `display_message` callback, and additionally with `age-plugin-tpm` to exercise actual encryption functionality. Typing stubs are amended to cover the new API surface. Conformance to type-stubs was checked by writing a short Python program exercising the functionality and type-checking it using `mypy` with the type stubs installed.
- Loading branch information
1 parent
e92ecde
commit eac37b3
Showing
6 changed files
with
430 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from __future__ import annotations | ||
from typing import Sequence, Self, Optional, Protocol | ||
|
||
|
||
class Callbacks(Protocol): | ||
def display_message(self, message: str) -> None: | ||
... | ||
|
||
def confirm(self, message: str, yes_string: str, no_string: Optional[str]) -> Optional[bool]: | ||
... | ||
|
||
def request_public_string(self, description: str) -> Optional[str]: | ||
... | ||
|
||
def request_passphrase(self, description: str) -> Optional[str]: | ||
... | ||
|
||
|
||
class Recipient: | ||
@classmethod | ||
def from_str(cls, v: str) -> Recipient: | ||
... | ||
|
||
def plugin(self) -> str: | ||
... | ||
|
||
|
||
class RecipientPluginV1: | ||
def __new__(cls, plugin_name: str, recipients: Sequence[Recipient], identities: Sequence[Identity], callbacks: Callbacks) -> Self: | ||
... | ||
|
||
|
||
class Identity: | ||
@classmethod | ||
def from_str(cls, v: str) -> Identity: | ||
... | ||
|
||
@classmethod | ||
def default_for_plugin(cls, plugin: str) -> Identity: | ||
... | ||
|
||
def plugin(self) -> str: | ||
... | ||
|
||
|
||
class IdentityPluginV1: | ||
def __new__(cls, plugin_name: str, identities: Sequence[Identity], callbacks: Callbacks) -> Self: | ||
... |
Oops, something went wrong.