Просмотр исходного кода

fix: export token creation from raw bytes to ffi (#1469)

* create token fromraw bytes

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
cloudsupper 4 недель назад
Родитель
Сommit
38e9ed3974
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      crates/cdk-ffi/src/token.rs

+ 7 - 0
crates/cdk-ffi/src/token.rs

@@ -95,6 +95,13 @@ impl Token {
         self.to_string()
     }
 
+    /// Decode token from raw bytes
+    #[uniffi::constructor]
+    pub fn from_raw_bytes(bytes: Vec<u8>) -> Result<Token, FfiError> {
+        let token = cdk::nuts::Token::try_from(&bytes)?;
+        Ok(Token { inner: token })
+    }
+
     /// Decode token from string representation
     #[uniffi::constructor]
     pub fn decode(encoded_token: String) -> Result<Token, FfiError> {