Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js): several fixes for js wrapper #111

Merged
merged 13 commits into from
Mar 7, 2023
Merged
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