diff --git a/bindings/uniffi/src/lib.rs b/bindings/uniffi/src/lib.rs index 0069364a..e1163f61 100644 --- a/bindings/uniffi/src/lib.rs +++ b/bindings/uniffi/src/lib.rs @@ -1,27 +1,5 @@ -use ::credentials::vc::{verify_vcjwt, CredentialError, CredentialSubject, VerifiableCredential}; -use ::crypto::Curve; -use ::dids::{ - bearer::{BearerDid, BearerDidError}, - document::{KeySelector, VerificationMethodType}, -}; -use ::jwk::{Jwk, JwkError}; -use ::jwt::{sign_jwt, verify_jwt, Claims, JwtError}; -use ::keys::{ - key::{Key, KeyError, PrivateKey, PublicKey}, - key_manager::{ - key_store::{in_memory_key_store::InMemoryKeyStore, KeyStore, KeyStoreError}, - local_key_manager::LocalKeyManager, - KeyManager, KeyManagerError, - }, -}; -use std::sync::Arc; - -pub async fn bearer_did_from_key_manager( - did_uri: &str, - key_manager: Arc, -) -> Result, BearerDidError> { - let bearer_did = BearerDid::from_key_manager(did_uri, key_manager).await?; - Ok(Arc::new(bearer_did)) +pub fn hello_world() { + println!("Hello web5 :)") } uniffi::include_scaffolding!("web5"); diff --git a/bindings/uniffi/src/web5.udl b/bindings/uniffi/src/web5.udl index 3bba1128..13ce83f6 100644 --- a/bindings/uniffi/src/web5.udl +++ b/bindings/uniffi/src/web5.udl @@ -1,215 +1,3 @@ namespace web5 { - [Throws=BearerDidError, Async] - BearerDid bearer_did_from_key_manager([ByRef] string did_uri, KeyManager key_manager); - - [Throws=JwtError] - string sign_jwt([ByRef] BearerDid bearer_did, [ByRef] KeySelector key_selector, [ByRef] string encoded_header, [ByRef] string encoded_payload); - [Throws=JwtError, Async] - void verify_jwt([ByRef] string jwt); - - [Throws=CredentialError, Async] - VerifiableCredential verify_vcjwt([ByRef] string jwt); + void hello_world(); }; - -[Error] -enum KeyError { - "KeyGenerationFailed", - "SerializationFailed", - "CurveNotFound", - "AlgorithmNotFound", - "JwkError", - "CryptoError", -}; - -[Trait] -interface Key { - [Throws=KeyError] - string alias(); - [Throws=KeyError] - Jwk jwk(); -}; - -[Trait] -interface PublicKey { - [Throws=KeyError] - void verify([ByRef] sequence payload, [ByRef] sequence signature); -}; - -[Trait] -interface PrivateKey { - [Throws=KeyError] - PublicKey to_public(); - [Throws=KeyError] - bytes sign([ByRef] sequence payload); -}; - -[Error] -enum JwkError { - "ThumbprintFailed", -}; - -interface Jwk { - [Throws=JwkError] - string compute_thumbprint(); - - [Throws=KeyError] - string alias(); - [Throws=KeyError] - Jwk jwk(); - - [Throws=KeyError] - void verify([ByRef] sequence payload, [ByRef] sequence signature); - - [Throws=KeyError] - PublicKey to_public(); - [Throws=KeyError] - bytes sign([ByRef] sequence payload); -}; - -enum Curve { - "Secp256k1", - "Ed25519", -}; - -[Error] -enum KeyManagerError { - "KeyGenerationFailed", - "SigningKeyNotFound", - "KeyError", - "KeyStoreError", -}; - -[Trait] -interface KeyManager { - [Throws=KeyManagerError] - string generate_private_key(Curve curve, string? key_alias); - [Throws=KeyManagerError] - PublicKey get_public_key([ByRef] string key_alias); - [Throws=KeyManagerError] - bytes sign([ByRef] string key_alias, [ByRef] sequence payload); - [Throws=KeyManagerError] - sequence export_private_keys(); - [Throws=KeyManagerError] - void import_private_keys(sequence private_keys); -}; - -interface LocalKeyManager { - constructor(KeyStore key_store); - [Name=new_in_memory] - constructor(); - - [Throws=KeyManagerError] - string generate_private_key(Curve curve, string? key_alias); - [Throws=KeyManagerError] - PublicKey get_public_key([ByRef] string key_alias); - [Throws=KeyManagerError] - bytes sign([ByRef] string key_alias, [ByRef] sequence payload); - [Throws=KeyManagerError] - sequence export_private_keys(); - [Throws=KeyManagerError] - void import_private_keys(sequence private_keys); -}; - -[Error] -enum KeyStoreError { - "InternalKeyStoreError", - "KeyError", - "KeyNotFound", - "CryptoError", - "JwkError", - "UnsupportedOperation", -}; - -[Trait] -interface KeyStore { - [Throws=KeyStoreError] - string generate_new(Curve curve, string? key_alias); - [Throws=KeyStoreError] - sequence get_all_aliases(); - [Throws=KeyStoreError] - bytes sign([ByRef] string key_alias, [ByRef] sequence payload); - [Throws=KeyStoreError] - PublicKey get_public_key([ByRef] string key_alias); - [Throws=KeyStoreError] - sequence export_private_keys(); - [Throws=KeyStoreError] - void import_private_keys(sequence private_keys); -}; - -interface InMemoryKeyStore { - constructor(); - - [Throws=KeyStoreError] - string generate_new(Curve curve, string? key_alias); - [Throws=KeyStoreError] - sequence get_all_aliases(); - [Throws=KeyStoreError] - bytes sign([ByRef] string key_alias, [ByRef] sequence payload); - [Throws=KeyStoreError] - PublicKey get_public_key([ByRef] string key_alias); - [Throws=KeyStoreError] - sequence export_private_keys(); - [Throws=KeyStoreError] - void import_private_keys(sequence private_keys); -}; - -[Error] -enum BearerDidError { - "VerificationMethodNotFound", - "KeyManagerError", - "KeyError", - "DocumentError", - "ResolutionError", - "IdentifierError", -}; - -enum VerificationMethodType { - "VerificationMethod", - "AssertionMethod", - "Authentication", - "CapabilityDelegation", - "CapabilityInvocation", -}; - -[Enum] -interface KeySelector { - KeyId(string key_id); - MethodType(VerificationMethodType verification_method_type); -}; - -interface BearerDid { - [Throws=BearerDidError] - bytes sign([ByRef] KeySelector key_selector, [ByRef] sequence payload); -}; - -[Error] -enum JwtError { - "JwsError", - "SerializationError", - "DeserializationError", -}; - -interface Claims { - constructor(string? issuer, string? subject, string? audience, i64? expiration, i64? not_before, i64? issued_at, string? jti); - [Throws=JwtError] - string encode(); - [Throws=JwtError] - string sign([ByRef] BearerDid bearer_did, [ByRef] KeySelector key_selector); -}; - -dictionary CredentialSubject { - string id; - record? params; -}; - -[Error] -enum CredentialError { - "JwtError", - "JwsError", -}; - -interface VerifiableCredential { - constructor(sequence context, string id, sequence type, string issuer, i64 issuance_date, i64? expiration_date, CredentialSubject credential_subject); - [Throws=CredentialError] - string sign([ByRef] BearerDid bearer_did, [ByRef] KeySelector key_selector); -}; \ No newline at end of file