-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To make signing mechanisms for JSON-LD pluggable. Signed-off-by: Daniel Bluhm <[email protected]>
- Loading branch information
Showing
2 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
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,44 @@ | ||
"""Plugin hook for providing an external signature suite implementation. | ||
This enables greater control over where JSON-LD credentials are signed without | ||
requiring knowledge of the complexities of the JSON-LD/VC-LDP subsystem. | ||
""" | ||
|
||
from abc import ABC, abstractmethod | ||
from typing import Optional | ||
|
||
from ...core.error import BaseError | ||
from ...core.profile import Profile | ||
from ...wallet.did_info import DIDInfo | ||
from ..ld_proofs.suites.linked_data_proof import LinkedDataProof | ||
|
||
|
||
class ExternalSuiteError(BaseError): | ||
"""Raised when an error occurs in an external signature suite provider.""" | ||
|
||
|
||
class ExternalSuiteNotFoundError(ExternalSuiteError): | ||
"""Raised when an external signature suite provider is not found. | ||
This should be raised to prevent falling back to built in suites, if desired. | ||
""" | ||
|
||
|
||
class ExternalSuiteProvider(ABC): | ||
"""Plugin hook for providing an external signature suite implementation.""" | ||
|
||
@abstractmethod | ||
def get_suite( | ||
self, | ||
profile: Profile, | ||
proof_type: str, | ||
proof: dict, | ||
verification_method: str, | ||
did_info: DIDInfo, | ||
) -> Optional[LinkedDataProof]: | ||
"""Get a signature suite for the given proof type and verification method. | ||
Implementing classes should raise ExternalSuiteNotFoundError if preventing | ||
fallback to built-in suites is desired. Otherwise, return None to indicate | ||
that the implementing class does not support the given proof type. | ||
""" |
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