Skip to content

Commit

Permalink
fix(js): several fixes for js wrapper (openwallet-foundation#111)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Mar 7, 2023
1 parent fecfcf1 commit 978842a
Show file tree
Hide file tree
Showing 21 changed files with 921 additions and 575 deletions.
197 changes: 121 additions & 76 deletions wrappers/javascript/aries-askar-nodejs/src/NodeJSAriesAskar.ts

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions wrappers/javascript/aries-askar-nodejs/tests/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('Store and Session', () => {
metadata: 'updated metadata',
})

expect(key.jwkThumbprint === fetchedKey1.key.jwkThumbprint).toBeTruthy()
expect(key.jwkThumbprint === fetchedKey1?.key.jwkThumbprint).toBeTruthy()

const found = await session.fetchAllKeys({
algorithm: KeyAlgs.Ed25519,
Expand All @@ -184,13 +184,13 @@ describe('Store and Session', () => {

await session.removeKey({ name: keyName })

await expect(session.fetchKey({ name: keyName })).rejects.toThrowError(AriesAskarError)
await expect(session.fetchKey({ name: keyName })).resolves.toBeNull()

await session.close()

// Clear objects
fetchedKey1.key.handle.free()
fetchedKey2.key.handle.free()
fetchedKey1?.key.handle.free()
fetchedKey2?.key.handle.free()
key.handle.free()
found.forEach((entry) => entry.key.handle.free())
})
Expand Down
17 changes: 11 additions & 6 deletions wrappers/javascript/aries-askar-react-native/cpp/HostObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
#include <algorithm>
#include <vector>


AriesAskarTurboModuleHostObject::AriesAskarTurboModuleHostObject(jsi::Runtime &rt) { return; }
AriesAskarTurboModuleHostObject::AriesAskarTurboModuleHostObject(
jsi::Runtime &rt) {
return;
}
FunctionMap AriesAskarTurboModuleHostObject::functionMapping(jsi::Runtime &rt) {
FunctionMap fMap;

fMap.insert(std::make_tuple("version", &ariesAskar::version));
fMap.insert(std::make_tuple("getCurrentError", &ariesAskar::getCurrentError));
fMap.insert(
std::make_tuple("setDefaultLogger", &ariesAskar::setDefaultLogger));

fMap.insert(std::make_tuple("storeOpen", &ariesAskar::storeOpen));
fMap.insert(
Expand Down Expand Up @@ -130,8 +134,8 @@ FunctionMap AriesAskarTurboModuleHostObject::functionMapping(jsi::Runtime &rt) {
return fMap;
}

jsi::Function AriesAskarTurboModuleHostObject::call(jsi::Runtime &rt, const char *name,
Cb cb) {
jsi::Function AriesAskarTurboModuleHostObject::call(jsi::Runtime &rt,
const char *name, Cb cb) {
return jsi::Function::createFromHostFunction(
rt, jsi::PropNameID::forAscii(rt, name), 1,
[this, cb](jsi::Runtime &rt, const jsi::Value &thisValue,
Expand All @@ -153,8 +157,9 @@ AriesAskarTurboModuleHostObject::getPropertyNames(jsi::Runtime &rt) {
return result;
}

jsi::Value AriesAskarTurboModuleHostObject::get(jsi::Runtime &rt,
const jsi::PropNameID &propNameId) {
jsi::Value
AriesAskarTurboModuleHostObject::get(jsi::Runtime &rt,
const jsi::PropNameID &propNameId) {
auto propName = propNameId.utf8(rt);
auto fMap = AriesAskarTurboModuleHostObject::functionMapping(rt);
for (FunctionMap::iterator it = fMap.begin(); it != fMap.end(); ++it) {
Expand Down
Loading

0 comments on commit 978842a

Please sign in to comment.