(wasm) Better TS types for serialized structs, RoutingContext++, more crypto fns

This commit is contained in:
Brandon Vandegrift
2023-09-11 01:25:37 -04:00
parent 797e34f965
commit c2c607efac
13 changed files with 133 additions and 87 deletions

View File

@@ -1,7 +1,6 @@
use super::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(target_arch = "wasm32", derive(Tsify), tsify(into_wasm_abi))]
pub struct CryptoTyped<K>
where
K: Clone

View File

@@ -1,9 +1,7 @@
use super::*;
#[derive(Clone, Debug, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Hash, Default)]
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
#[serde(from = "Vec<CryptoTyped<K>>", into = "Vec<CryptoTyped<K>>")]
// TODO: figure out hot to TS type this as `string`, since it's converted to string via the JSON API.
pub struct CryptoTypedGroup<K = PublicKey>
where
K: Clone

View File

@@ -7,9 +7,7 @@ use super::*;
tsify(from_wasm_abi, into_wasm_abi)
)]
pub struct KeyPair {
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
pub key: PublicKey,
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
pub secret: SecretKey,
}
from_impl_to_jsvalue!(KeyPair);

View File

@@ -10,16 +10,14 @@ use super::*;
pub struct DHTRecordDescriptor {
/// DHT Key = Hash(ownerKeyKind) of: [ ownerKeyValue, schema ]
#[schemars(with = "String")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
key: TypedKey,
/// The public key of the owner
#[schemars(with = "String")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
owner: PublicKey,
/// If this key is being created: Some(the secret key of the owner)
/// If this key is just being opened: None
#[schemars(with = "Option<String>")]
#[cfg_attr(target_arch = "wasm32", tsify(optional, type = "string"))]
#[cfg_attr(target_arch = "wasm32", tsify(optional))]
owner_secret: Option<SecretKey>,
/// The schema in use associated with the key
schema: DHTSchema,

View File

@@ -6,7 +6,6 @@ use super::*;
pub struct DHTSchemaSMPLMember {
/// Member key
#[schemars(with = "String")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
pub m_key: PublicKey,
/// Member subkey count
pub m_cnt: u16,

View File

@@ -15,7 +15,6 @@ pub struct ValueData {
/// The public identity key of the writer of the data
#[schemars(with = "String")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
writer: PublicKey,
}
from_impl_to_jsvalue!(ValueData);

View File

@@ -4,7 +4,6 @@ use super::*;
#[derive(
Copy, Default, Clone, Hash, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, JsonSchema,
)]
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
#[serde(try_from = "String")]
#[serde(into = "String")]
pub struct FourCC(pub [u8; 4]);

View File

@@ -83,10 +83,8 @@ pub struct VeilidStateNetwork {
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
pub struct VeilidRouteChange {
#[schemars(with = "Vec<String>")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
pub dead_routes: Vec<RouteId>,
#[schemars(with = "Vec<String>")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
pub dead_remote_routes: Vec<RouteId>,
}
@@ -100,7 +98,6 @@ pub struct VeilidStateConfig {
#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
pub struct VeilidValueChange {
#[schemars(with = "String")]
#[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
pub key: TypedKey,
pub subkeys: Vec<ValueSubkey>,
pub count: u32,