Skip to content

Commit

Permalink
Rename RustCoreError to Web5Error
Browse files Browse the repository at this point in the history
  • Loading branch information
KendallWeihe committed Aug 15, 2024
1 parent 6fdb0ed commit 902a933
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 274 deletions.
2 changes: 1 addition & 1 deletion bindings/web5_uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use web5_uniffi_wrapper::{
portable_did::PortableDid,
resolution::resolution_result::ResolutionResult,
},
errors::{RustCoreError, Web5Error},
errors::Web5Error,
};

use web5::{
Expand Down
59 changes: 27 additions & 32 deletions bindings/web5_uniffi/src/web5.udl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ namespace web5 {
JwkData ed25519_generator_generate();

ResolutionResult did_jwk_resolve([ByRef] string uri);
[Async, Throws=RustCoreError]
[Async, Throws=Web5Error]
ResolutionResult did_web_resolve([ByRef] string uri);
[Throws=RustCoreError]
[Throws=Web5Error]
ResolutionResult did_dht_resolve([ByRef] string uri);
};

[Error]
interface RustCoreError {
interface Web5Error {
Error(string type, string variant, string msg);
};

Expand All @@ -24,15 +24,15 @@ dictionary JwkData {

[Trait, WithForeign]
interface KeyManager {
[Throws=RustCoreError]
[Throws=Web5Error]
Signer get_signer(JwkData public_jwk);
};

interface InMemoryKeyManager {
constructor();
[Throws=RustCoreError]
[Throws=Web5Error]
Signer get_signer(JwkData public_jwk);
[Throws=RustCoreError]
[Throws=Web5Error]
JwkData import_private_jwk(JwkData private_key);
KeyManager get_as_key_manager();
};
Expand All @@ -43,25 +43,25 @@ enum Dsa {

[Trait, WithForeign]
interface Signer {
[Throws=RustCoreError]
[Throws=Web5Error]
bytes sign(bytes payload);
};

[Trait, WithForeign]
interface Verifier {
[Throws=RustCoreError]
[Throws=Web5Error]
boolean verify(bytes message, bytes signature);
};

interface Ed25519Signer {
constructor(JwkData private_key);
[Throws=RustCoreError]
[Throws=Web5Error]
bytes sign(bytes payload);
};

interface Ed25519Verifier {
constructor(JwkData public_jwk);
[Throws=RustCoreError]
[Throws=Web5Error]
boolean verify(bytes message, bytes signature);
};

Expand All @@ -77,7 +77,7 @@ dictionary DidData {
};

interface Did {
[Throws=RustCoreError]
[Throws=Web5Error]
constructor([ByRef] string uri);
DidData get_data();
};
Expand Down Expand Up @@ -112,7 +112,7 @@ dictionary ServiceData {
interface Document {
constructor(DocumentData data);
DocumentData get_data();
[Throws=RustCoreError]
[Throws=Web5Error]
JwkData find_public_key_jwk(string key_id);
};

Expand Down Expand Up @@ -158,9 +158,9 @@ dictionary DidJwkData {
};

interface DidJwk {
[Name=from_public_jwk, Throws=RustCoreError]
[Name=from_public_jwk, Throws=Web5Error]
constructor(JwkData public_jwk);
[Name=from_uri, Throws=RustCoreError]
[Name=from_uri, Throws=Web5Error]
constructor([ByRef] string uri);
DidJwkData get_data();
};
Expand All @@ -171,9 +171,9 @@ dictionary DidWebData {
};

interface DidWeb {
[Name=from_public_jwk, Throws=RustCoreError]
[Name=from_public_jwk, Throws=Web5Error]
constructor([ByRef] string domain, JwkData public_jwk);
[Async, Name=from_uri, Throws=RustCoreError]
[Async, Name=from_uri, Throws=Web5Error]
constructor([ByRef] string uri);
DidWebData get_data();
};
Expand All @@ -184,13 +184,13 @@ dictionary DidDhtData {
};

interface DidDht {
[Name=from_identity_key, Throws=RustCoreError]
[Name=from_identity_key, Throws=Web5Error]
constructor(JwkData identity_key);
[Name=from_uri, Throws=RustCoreError]
[Name=from_uri, Throws=Web5Error]
constructor([ByRef] string uri);
[Throws=RustCoreError]
[Throws=Web5Error]
void publish(Signer signer);
[Throws=RustCoreError]
[Throws=Web5Error]
void deactivate(Signer signer);
DidDhtData get_data();
};
Expand All @@ -202,7 +202,7 @@ dictionary PortableDidData {
};

interface PortableDid {
[Throws=RustCoreError]
[Throws=Web5Error]
constructor([ByRef] string json);
PortableDidData get_data();
};
Expand All @@ -214,33 +214,28 @@ dictionary BearerDidData {
};

interface BearerDid {
[Throws=RustCoreError]
[Throws=Web5Error]
constructor([ByRef] string uri, KeyManager key_manager);
[Throws=RustCoreError, Name=from_portable_did]
[Throws=Web5Error, Name=from_portable_did]
constructor(PortableDid portable_did);
BearerDidData get_data();
[Throws=RustCoreError]
[Throws=Web5Error]
Signer get_signer(string key_id);
};

interface PresentationDefinition {
[Throws=RustCoreError]
[Throws=Web5Error]
constructor(string json_serialized_presentation_definition);
[Throws=RustCoreError]
[Throws=Web5Error]
string get_json_serialized_presentation_definition();
[Throws=RustCoreError]
[Throws=Web5Error]
sequence<string> select_credentials([ByRef] sequence<string> vc_jwts);
};





[Error]
interface Web5Error {
Error(string type, string variant, string msg);
};

dictionary VerifiableCredentialCreateOptionsData {
string? id;
sequence<string>? context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::errors::ResultNew;
use crate::errors::Result;
use std::time::SystemTime;
use web5::{
credentials::verifiable_credential_1_1::{
Expand All @@ -19,7 +19,7 @@ impl VerifiableCredential {
json_serialized_issuer: String,
json_serialized_credential_subject: String,
options: Option<VerifiableCredentialCreateOptions>,
) -> ResultNew<Self> {
) -> Result<Self> {
let issuer = Issuer::from_json_string(&json_serialized_issuer)?;
let credential_subject =
CredentialSubject::from_json_string(&json_serialized_credential_subject)?;
Expand Down
Loading

0 comments on commit 902a933

Please sign in to comment.