identity_iota::storage

Trait JwkDocumentExt

Source
pub trait JwkDocumentExt: Sealed {
    // Required methods
    fn generate_method<'life0, 'life1, 'life2, 'async_trait, K, I>(
        &'life0 mut self,
        storage: &'life1 Storage<K, I>,
        key_type: KeyType,
        alg: JwsAlgorithm,
        fragment: Option<&'life2 str>,
        scope: MethodScope,
    ) -> Pin<Box<dyn Future<Output = Result<String, JwkStorageDocumentError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             K: JwkStorage + 'async_trait,
             I: KeyIdStorage + 'async_trait,
             Self: 'async_trait;
    fn purge_method<'life0, 'life1, 'life2, 'async_trait, K, I>(
        &'life0 mut self,
        storage: &'life1 Storage<K, I>,
        id: &'life2 DIDUrl,
    ) -> Pin<Box<dyn Future<Output = Result<(), JwkStorageDocumentError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             K: JwkStorage + 'async_trait,
             I: KeyIdStorage + 'async_trait,
             Self: 'async_trait;
    fn create_jws<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait, K, I>(
        &'life0 self,
        storage: &'life1 Storage<K, I>,
        fragment: &'life2 str,
        payload: &'life3 [u8],
        options: &'life4 JwsSignatureOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Jws, JwkStorageDocumentError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             K: JwkStorage + 'async_trait,
             I: KeyIdStorage + 'async_trait,
             Self: 'async_trait;
    fn create_credential_jwt<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait, K, I, T>(
        &'life0 self,
        credential: &'life1 Credential<T>,
        storage: &'life2 Storage<K, I>,
        fragment: &'life3 str,
        options: &'life4 JwsSignatureOptions,
        custom_claims: Option<BTreeMap<String, Value>>,
    ) -> Pin<Box<dyn Future<Output = Result<Jwt, JwkStorageDocumentError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             K: JwkStorage + 'async_trait,
             I: KeyIdStorage + 'async_trait,
             T: ToOwned<Owned = T> + Serialize + DeserializeOwned + Sync + 'async_trait,
             Self: 'async_trait;
    fn create_presentation_jwt<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait, K, I, CRED, T>(
        &'life0 self,
        presentation: &'life1 Presentation<CRED, T>,
        storage: &'life2 Storage<K, I>,
        fragment: &'life3 str,
        signature_options: &'life4 JwsSignatureOptions,
        presentation_options: &'life5 JwtPresentationOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Jwt, JwkStorageDocumentError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait,
             K: JwkStorage + 'async_trait,
             I: KeyIdStorage + 'async_trait,
             T: ToOwned<Owned = T> + Serialize + DeserializeOwned + Sync + 'async_trait,
             CRED: ToOwned<Owned = CRED> + Serialize + DeserializeOwned + Clone + Sync + 'async_trait,
             Self: 'async_trait;
}
Expand description

Extension trait for JWK-based operations on DID documents.

This trait is deliberately sealed and cannot be implemented by external crates. The trait only exists as an extension of existing DID documents implemented in dependent crates. Because those crates cannot also depend on this crate, the extension trait is necessary. External crates however should simply wrap the methods on the trait if they wish to reexport them on their DID document type. This also allows them to use their own error type on those methods.

Required Methods§

Source

fn generate_method<'life0, 'life1, 'life2, 'async_trait, K, I>( &'life0 mut self, storage: &'life1 Storage<K, I>, key_type: KeyType, alg: JwsAlgorithm, fragment: Option<&'life2 str>, scope: MethodScope, ) -> Pin<Box<dyn Future<Output = Result<String, JwkStorageDocumentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, K: JwkStorage + 'async_trait, I: KeyIdStorage + 'async_trait, Self: 'async_trait,

Generate new key material in the given storage and insert a new verification method with the corresponding public key material into the DID document.

  • If no fragment is given the kid of the generated JWK is used, if it is set, otherwise an error is returned.
  • The key_type must be compatible with the given storage. Storages are expected to export key type constants for that use case.

The fragment of the generated method is returned.

Source

fn purge_method<'life0, 'life1, 'life2, 'async_trait, K, I>( &'life0 mut self, storage: &'life1 Storage<K, I>, id: &'life2 DIDUrl, ) -> Pin<Box<dyn Future<Output = Result<(), JwkStorageDocumentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, K: JwkStorage + 'async_trait, I: KeyIdStorage + 'async_trait, Self: 'async_trait,

Remove the method identified by the given id from the document and delete the corresponding key material in the given storage.

§Warning

This will delete the key material permanently and irrecoverably.

Source

fn create_jws<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait, K, I>( &'life0 self, storage: &'life1 Storage<K, I>, fragment: &'life2 str, payload: &'life3 [u8], options: &'life4 JwsSignatureOptions, ) -> Pin<Box<dyn Future<Output = Result<Jws, JwkStorageDocumentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, K: JwkStorage + 'async_trait, I: KeyIdStorage + 'async_trait, Self: 'async_trait,

Sign the arbitrary payload according to options with the storage backed private key corresponding to the public key material in the verification method identified by the given `fragment.

Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. See RFC7515 section 3.1.

Source

fn create_credential_jwt<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait, K, I, T>( &'life0 self, credential: &'life1 Credential<T>, storage: &'life2 Storage<K, I>, fragment: &'life3 str, options: &'life4 JwsSignatureOptions, custom_claims: Option<BTreeMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = Result<Jwt, JwkStorageDocumentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, K: JwkStorage + 'async_trait, I: KeyIdStorage + 'async_trait, T: ToOwned<Owned = T> + Serialize + DeserializeOwned + Sync + 'async_trait, Self: 'async_trait,

Produces a JWT where the payload is produced from the given credential in accordance with VC Data Model v1.1.

Unless the kid is explicitly set in the options, the kid in the protected header is the id of the method identified by fragment and the JWS signature will be produced by the corresponding private key backed by the storage in accordance with the passed options.

The custom_claims can be used to set additional claims on the resulting JWT.

Source

fn create_presentation_jwt<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait, K, I, CRED, T>( &'life0 self, presentation: &'life1 Presentation<CRED, T>, storage: &'life2 Storage<K, I>, fragment: &'life3 str, signature_options: &'life4 JwsSignatureOptions, presentation_options: &'life5 JwtPresentationOptions, ) -> Pin<Box<dyn Future<Output = Result<Jwt, JwkStorageDocumentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, K: JwkStorage + 'async_trait, I: KeyIdStorage + 'async_trait, T: ToOwned<Owned = T> + Serialize + DeserializeOwned + Sync + 'async_trait, CRED: ToOwned<Owned = CRED> + Serialize + DeserializeOwned + Clone + Sync + 'async_trait, Self: 'async_trait,

Produces a JWT where the payload is produced from the given presentation in accordance with VC Data Model v1.1.

Unless the kid is explicitly set in the options, the kid in the protected header is the id of the method identified by fragment and the JWS signature will be produced by the corresponding private key backed by the storage in accordance with the passed options.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§