Skip to content

Commit

Permalink
Expose more APIs via napi-rs
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <[email protected]>
  • Loading branch information
Patrik-Stas committed Dec 30, 2022
1 parent efb6f00 commit fa9fa01
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 1,126 deletions.
2 changes: 1 addition & 1 deletion libvcx/src/api_c/protocols/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ pub extern "C" fn vcx_mark_presentation_request_msg_sent(
);

execute_async::<BoxFuture<'static, Result<(), ()>>>(Box::pin(async move {
match proof::mark_presentation_request_msg_sent(proof_handle).await {
match proof::mark_presentation_request_msg_sent(proof_handle) {
Ok(offer_msg) => {
let offer_msg = json!(offer_msg).to_string();
let offer_msg = CStringUtils::string_to_cstring(offer_msg);
Expand Down
2 changes: 1 addition & 1 deletion libvcx/src/api_vcx/api_handle/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub async fn send_proof_request(handle: u32, connection_handle: u32) -> LibvcxRe
PROOF_MAP.insert(handle, proof)
}

pub async fn mark_presentation_request_msg_sent(handle: u32) -> LibvcxResult<()> {
pub fn mark_presentation_request_msg_sent(handle: u32) -> LibvcxResult<()> {
let mut proof = PROOF_MAP.get_cloned(handle)?;
proof.mark_presentation_request_msg_sent()?;
PROOF_MAP.insert(handle, proof)
Expand Down
9 changes: 8 additions & 1 deletion wrappers/node-napi-rs/api-node/src/api/disclosed_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ fn disclosed_proof_deserialize(data: String) -> napi::Result<u32> {
}

#[napi]
async fn v2_disclosed_proof_update_state(handle: u32, message: String, connection_handle: u32) -> napi::Result<u32> {
async fn v2_disclosed_proof_update_state(handle: u32, connection_handle: u32) -> napi::Result<u32> {
disclosed_proof::update_state(handle, None, connection_handle)
.await
.map_err(to_napi_err)
}

#[napi]
async fn v2_disclosed_proof_update_state_with_message(handle: u32, message: String, connection_handle: u32) -> napi::Result<u32> {
disclosed_proof::update_state(handle, Some(&message), connection_handle)
.await
.map_err(to_napi_err)
Expand Down
6 changes: 3 additions & 3 deletions wrappers/node-napi-rs/api-node/src/api/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async fn proof_create(
}

#[napi]
fn get_proof_msg(handle: u32) -> napi::Result<String> {
fn proof_get_proof_msg(handle: u32) -> napi::Result<String> {
proof::get_presentation_msg(handle).map_err(to_napi_err)
}

Expand Down Expand Up @@ -93,6 +93,6 @@ async fn proof_get_thread_id(handle: u32) -> napi::Result<String> {
}

#[napi]
fn mark_presentation_request_msg_sent(handle: u32) -> napi::Result<String> {
proof::get_presentation_request_msg(handle).map_err(to_napi_err)
fn mark_presentation_request_msg_sent(handle: u32) -> napi::Result<()> {
proof::mark_presentation_request_msg_sent(handle).map_err(to_napi_err)
}
7 changes: 4 additions & 3 deletions wrappers/node-napi-rs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export function disclosedProofRejectProof(handle: number, handleConnection: numb
export function disclosedProofGetProofMsg(handle: number): string
export function disclosedProofSerialize(handle: number): string
export function disclosedProofDeserialize(data: string): number
export function v2DisclosedProofUpdateState(handle: number, message: string, connectionHandle: number): Promise<number>
export function v2DisclosedProofUpdateState(handle: number, connectionHandle: number): Promise<number>
export function v2DisclosedProofUpdateStateWithMessage(handle: number, message: string, connectionHandle: number): Promise<number>
export function disclosedProofGetState(handle: number): number
export function disclosedProofGetRequests(handleConnection: number): Promise<string>
export function disclosedProofRetrieveCredentials(handle: number): Promise<string>
Expand Down Expand Up @@ -120,7 +121,7 @@ export function openMainPool(poolConfig: string): Promise<void>
export function closeMainPool(): Promise<void>
export function credentialCreateWithOffer(sourceId: string, offer: string): number
export function proofCreate(sourceId: string, requestedAttrs: string, requestedPredicates: string, revocationDetails: string, name: string): Promise<number>
export function getProofMsg(handle: number): string
export function proofGetProofMsg(handle: number): string
export function proofRelease(handle: number): void
export function proofSendRequest(handleProof: number, handleConnection: number): Promise<void>
export function proofGetRequestMsg(handle: number): string
Expand All @@ -130,7 +131,7 @@ export function v2ProofUpdateState(handleProof: number, connectionHandle: number
export function v2ProofUpdateStateWithMessage(handleProof: number, message: string, connectionHandle: number): Promise<number>
export function proofGetState(handle: number): number
export function proofGetThreadId(handle: number): Promise<string>
export function markPresentationRequestMsgSent(handle: number): string
export function markPresentationRequestMsgSent(handle: number): void
export function publicAgentCreate(sourceId: string, institutionDid: string): Promise<number>
export function publicAgentDownloadConnectionRequests(handle: number, uids?: string | undefined | null): Promise<string>
export function publicAgentDownloadMessage(handle: number, uid: string): Promise<string>
Expand Down
Loading

0 comments on commit fa9fa01

Please sign in to comment.