-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Miroslav Kovar <[email protected]>
- Loading branch information
Showing
14 changed files
with
375 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "api-node" | ||
version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
edition.workspace = true | ||
|
||
[lib] | ||
name = "api_node" | ||
path = "src/lib.rs" | ||
crate-type = ["cdylib"] | ||
doctest = false | ||
|
||
[dependencies] | ||
libvcx = { path = "../../../libvcx" } | ||
log = "0.4.16" | ||
napi = { version = "=2.9.1", default-features = false, features = [ "async" ] } | ||
napi-derive = { version = "=2.9.1" } | ||
|
||
[build-dependencies] | ||
napi-build = "2.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extern crate napi_build; | ||
|
||
fn main() { | ||
napi_build::setup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod out_of_band; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
use napi_derive::napi; | ||
use ::vcx::api_lib::api_handle::out_of_band; | ||
|
||
use crate::error::to_napi_err; | ||
|
||
#[napi] | ||
// TODO: Does not need to be async | ||
pub async fn out_of_band_sender_create(config: String) -> napi::Result<u32> { | ||
out_of_band::create_out_of_band(&config) | ||
.await | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_receiver_create(msg: String) -> napi::Result<u32> { | ||
out_of_band::create_out_of_band_msg_from_msg(&msg) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_sender_append_message(handle: u32, msg: String) -> napi::Result<()> { | ||
out_of_band::append_message(handle, &msg) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_sender_append_service(handle: u32, service: String) -> napi::Result<()> { | ||
out_of_band::append_service(handle, &service) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_sender_append_service_did(handle: u32, did: String) -> napi::Result<()> { | ||
out_of_band::append_service_did(handle, &did) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_receiver_extract_message(handle: u32) -> napi::Result<String> { | ||
out_of_band::extract_a2a_message(handle) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_sender_to_message(handle: u32) -> napi::Result<String> { | ||
out_of_band::to_a2a_message(handle) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub async fn out_of_band_receiver_connection_exists(handle: u32, conn_handles: Vec<u32>) -> napi::Result<u32> { | ||
out_of_band::connection_exists(handle, &conn_handles) | ||
.await | ||
.map(|res| res.0) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub async fn out_of_band_receiver_build_connection(handle: u32) -> napi::Result<String> { | ||
out_of_band::build_connection(handle) | ||
.await | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_sender_get_thread_id(handle: u32) -> napi::Result<String> { | ||
out_of_band::get_thread_id_sender(handle) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_receiver_get_thread_id(handle: u32) -> napi::Result<String> { | ||
out_of_band::get_thread_id_receiver(handle) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_sender_serialize(handle: u32) -> napi::Result<String> { | ||
out_of_band::to_string_sender(handle) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_receiver_serialize(handle: u32) -> napi::Result<String> { | ||
out_of_band::to_string_receiver(handle) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_sender_deserialize(oob_data: String) -> napi::Result<u32> { | ||
out_of_band::from_string_sender(&oob_data) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_receiver_deserialize(oob_data: String) -> napi::Result<u32> { | ||
out_of_band::from_string_receiver(&oob_data) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_sender_release(handle: u32) -> napi::Result<()> { | ||
out_of_band::release_sender(handle) | ||
.map_err(to_napi_err) | ||
} | ||
|
||
#[napi] | ||
pub fn out_of_band_receiver_release(handle: u32) -> napi::Result<()> { | ||
out_of_band::release_receiver(handle) | ||
.map_err(to_napi_err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use vcx::api_lib::utils::logger::VcxError; | ||
|
||
pub fn to_napi_err(err: VcxError) -> napi::Error { | ||
error!("{}", err.to_string()); | ||
napi::Error::new(napi::Status::Unknown, format!("{:?}", Into::<u32>::into(err.kind()))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[macro_use] | ||
extern crate log; | ||
|
||
pub mod api; | ||
pub mod error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/* auto-generated by NAPI-RS */ | ||
|
||
export function outOfBandSenderCreate(config: string): Promise<number> | ||
export function outOfBandReceiverCreate(msg: string): number | ||
export function outOfBandSenderAppendMessage(handle: number, msg: string): void | ||
export function outOfBandSenderAppendService(handle: number, service: string): void | ||
export function outOfBandSenderAppendServiceDid(handle: number, did: string): void | ||
export function outOfBandReceiverExtractMessage(handle: number): string | ||
export function outOfBandSenderToMessage(handle: number): string | ||
export function outOfBandReceiverConnectionExists(handle: number, connHandles: Array<number>): Promise<number> | ||
export function outOfBandReceiverBuildConnection(handle: number): Promise<string> | ||
export function outOfBandSenderGetThreadId(handle: number): string | ||
export function outOfBandReceiverGetThreadId(handle: number): string | ||
export function outOfBandSenderSerialize(handle: number): string | ||
export function outOfBandReceiverSerialize(handle: number): string | ||
export function outOfBandSenderDeserialize(oobData: string): number | ||
export function outOfBandReceiverDeserialize(oobData: string): number | ||
export function outOfBandSenderRelease(handle: number): void | ||
export function outOfBandReceiverRelease(handle: number): void |
Oops, something went wrong.