Setup for TypeScript type gen for WASM using Tsify
- Includes breaking changes to the WASM API surface, since it now accepts objects instead of stringified JSON.
This commit is contained in:
@@ -293,11 +293,17 @@ macro_rules! byte_array_type {
|
||||
|
||||
byte_array_type!(CryptoKey, CRYPTO_KEY_LENGTH, CRYPTO_KEY_LENGTH_ENCODED);
|
||||
|
||||
#[declare]
|
||||
pub type PublicKey = CryptoKey;
|
||||
#[declare]
|
||||
pub type SecretKey = CryptoKey;
|
||||
#[declare]
|
||||
pub type HashDigest = CryptoKey;
|
||||
#[declare]
|
||||
pub type SharedSecret = CryptoKey;
|
||||
#[declare]
|
||||
pub type RouteId = CryptoKey;
|
||||
#[declare]
|
||||
pub type CryptoKeyDistance = CryptoKey;
|
||||
|
||||
byte_array_type!(Signature, SIGNATURE_LENGTH, SIGNATURE_LENGTH_ENCODED);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Tsify)]
|
||||
pub struct CryptoTyped<K>
|
||||
where
|
||||
K: Clone
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Hash, Default)]
|
||||
#[derive(
|
||||
Clone, Debug, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Hash, Default, Tsify,
|
||||
)]
|
||||
#[serde(from = "Vec<CryptoTyped<K>>", into = "Vec<CryptoTyped<K>>")]
|
||||
pub struct CryptoTypedGroup<K = PublicKey>
|
||||
where
|
||||
|
||||
@@ -6,6 +6,7 @@ use core::fmt;
|
||||
use core::hash::Hash;
|
||||
|
||||
/// Cryptography version fourcc code
|
||||
#[declare]
|
||||
pub type CryptoKind = FourCC;
|
||||
|
||||
/// Sort best crypto kinds first
|
||||
@@ -51,14 +52,24 @@ pub use crypto_typed::*;
|
||||
pub use crypto_typed_group::*;
|
||||
pub use keypair::*;
|
||||
|
||||
#[declare]
|
||||
pub type TypedKey = CryptoTyped<PublicKey>;
|
||||
#[declare]
|
||||
pub type TypedSecret = CryptoTyped<SecretKey>;
|
||||
#[declare]
|
||||
pub type TypedKeyPair = CryptoTyped<KeyPair>;
|
||||
#[declare]
|
||||
pub type TypedSignature = CryptoTyped<Signature>;
|
||||
#[declare]
|
||||
pub type TypedSharedSecret = CryptoTyped<SharedSecret>;
|
||||
|
||||
#[declare]
|
||||
pub type TypedKeyGroup = CryptoTypedGroup<PublicKey>;
|
||||
#[declare]
|
||||
pub type TypedSecretGroup = CryptoTypedGroup<SecretKey>;
|
||||
#[declare]
|
||||
pub type TypedKeyPairGroup = CryptoTypedGroup<KeyPair>;
|
||||
#[declare]
|
||||
pub type TypedSignatureGroup = CryptoTypedGroup<Signature>;
|
||||
#[declare]
|
||||
pub type TypedSharedSecretGroup = CryptoTypedGroup<SharedSecret>;
|
||||
|
||||
Reference in New Issue
Block a user