@openwallet-foundation/askar-react-native 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +38 -0
- package/android/CMakeLists.txt +60 -0
- package/android/build.gradle +261 -0
- package/android/cpp-adapter.cpp +36 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/foundation/openwallet/askar/AskarModule.java +51 -0
- package/android/src/main/java/foundation/openwallet/askar/AskarPackage.java +23 -0
- package/android/src/main/java/id/animo/SecureEnvironment.java +5 -0
- package/askar.podspec +31 -0
- package/build/askar-react-native/src/NativeBindings.d.ts +144 -0
- package/build/askar-react-native/src/NativeBindings.js +3 -0
- package/build/askar-react-native/src/NativeBindings.js.map +1 -0
- package/build/askar-react-native/src/ReactNativeAskar.d.ts +100 -0
- package/build/askar-react-native/src/ReactNativeAskar.js +482 -0
- package/build/askar-react-native/src/ReactNativeAskar.js.map +1 -0
- package/build/askar-react-native/src/index.d.ts +1 -0
- package/build/askar-react-native/src/index.js +31 -0
- package/build/askar-react-native/src/index.js.map +1 -0
- package/build/askar-react-native/src/serialize.d.ts +14 -0
- package/build/askar-react-native/src/serialize.js +50 -0
- package/build/askar-react-native/src/serialize.js.map +1 -0
- package/build/askar-react-native/src/specs/NativeAskar.d.ts +5 -0
- package/build/askar-react-native/src/specs/NativeAskar.js +7 -0
- package/build/askar-react-native/src/specs/NativeAskar.js.map +1 -0
- package/build/askar-shared/src/askar/Askar.d.ts +437 -0
- package/build/askar-shared/src/askar/Askar.js +3 -0
- package/build/askar-shared/src/askar/Askar.js.map +1 -0
- package/build/askar-shared/src/askar/index.d.ts +2 -0
- package/build/askar-shared/src/askar/index.js +19 -0
- package/build/askar-shared/src/askar/index.js.map +1 -0
- package/build/askar-shared/src/askar/register.d.ts +5 -0
- package/build/askar-shared/src/askar/register.js +8 -0
- package/build/askar-shared/src/askar/register.js.map +1 -0
- package/build/askar-shared/src/crypto/AeadParams.d.ts +9 -0
- package/build/askar-shared/src/crypto/AeadParams.js +11 -0
- package/build/askar-shared/src/crypto/AeadParams.js.map +1 -0
- package/build/askar-shared/src/crypto/CryptoBox.d.ts +24 -0
- package/build/askar-shared/src/crypto/CryptoBox.js +23 -0
- package/build/askar-shared/src/crypto/CryptoBox.js.map +1 -0
- package/build/askar-shared/src/crypto/Ecdh1PU.d.ts +58 -0
- package/build/askar-shared/src/crypto/Ecdh1PU.js +77 -0
- package/build/askar-shared/src/crypto/Ecdh1PU.js.map +1 -0
- package/build/askar-shared/src/crypto/EcdhEs.d.ts +46 -0
- package/build/askar-shared/src/crypto/EcdhEs.js +64 -0
- package/build/askar-shared/src/crypto/EcdhEs.js.map +1 -0
- package/build/askar-shared/src/crypto/EncryptedBuffer.d.ts +20 -0
- package/build/askar-shared/src/crypto/EncryptedBuffer.js +36 -0
- package/build/askar-shared/src/crypto/EncryptedBuffer.js.map +1 -0
- package/build/askar-shared/src/crypto/Jwk.d.ts +18 -0
- package/build/askar-shared/src/crypto/Jwk.js +24 -0
- package/build/askar-shared/src/crypto/Jwk.js.map +1 -0
- package/build/askar-shared/src/crypto/Key.d.ts +73 -0
- package/build/askar-shared/src/crypto/Key.js +101 -0
- package/build/askar-shared/src/crypto/Key.js.map +1 -0
- package/build/askar-shared/src/crypto/handles.d.ts +46 -0
- package/build/askar-shared/src/crypto/handles.js +123 -0
- package/build/askar-shared/src/crypto/handles.js.map +1 -0
- package/build/askar-shared/src/crypto/index.d.ts +8 -0
- package/build/askar-shared/src/crypto/index.js +25 -0
- package/build/askar-shared/src/crypto/index.js.map +1 -0
- package/build/askar-shared/src/enums/EntryOperation.d.ts +5 -0
- package/build/askar-shared/src/enums/EntryOperation.js +10 -0
- package/build/askar-shared/src/enums/EntryOperation.js.map +1 -0
- package/build/askar-shared/src/enums/KeyAlgorithm.d.ts +20 -0
- package/build/askar-shared/src/enums/KeyAlgorithm.js +38 -0
- package/build/askar-shared/src/enums/KeyAlgorithm.js.map +1 -0
- package/build/askar-shared/src/enums/KeyBackend.d.ts +6 -0
- package/build/askar-shared/src/enums/KeyBackend.js +24 -0
- package/build/askar-shared/src/enums/KeyBackend.js.map +1 -0
- package/build/askar-shared/src/enums/KeyMethod.d.ts +4 -0
- package/build/askar-shared/src/enums/KeyMethod.js +9 -0
- package/build/askar-shared/src/enums/KeyMethod.js.map +1 -0
- package/build/askar-shared/src/enums/LogLevel.d.ts +9 -0
- package/build/askar-shared/src/enums/LogLevel.js +14 -0
- package/build/askar-shared/src/enums/LogLevel.js.map +1 -0
- package/build/askar-shared/src/enums/SignatureAlgorithm.d.ts +6 -0
- package/build/askar-shared/src/enums/SignatureAlgorithm.js +11 -0
- package/build/askar-shared/src/enums/SignatureAlgorithm.js.map +1 -0
- package/build/askar-shared/src/enums/index.d.ts +5 -0
- package/build/askar-shared/src/enums/index.js +22 -0
- package/build/askar-shared/src/enums/index.js.map +1 -0
- package/build/askar-shared/src/error.d.ts +12 -0
- package/build/askar-shared/src/error.js +21 -0
- package/build/askar-shared/src/error.js.map +1 -0
- package/build/askar-shared/src/index.d.ts +6 -0
- package/build/askar-shared/src/index.js +23 -0
- package/build/askar-shared/src/index.js.map +1 -0
- package/build/askar-shared/src/migration.d.ts +10 -0
- package/build/askar-shared/src/migration.js +11 -0
- package/build/askar-shared/src/migration.js.map +1 -0
- package/build/askar-shared/src/store/Entry.d.ts +21 -0
- package/build/askar-shared/src/store/Entry.js +38 -0
- package/build/askar-shared/src/store/Entry.js.map +1 -0
- package/build/askar-shared/src/store/EntryList.d.ts +17 -0
- package/build/askar-shared/src/store/EntryList.js +40 -0
- package/build/askar-shared/src/store/EntryList.js.map +1 -0
- package/build/askar-shared/src/store/KeyEntry.d.ts +23 -0
- package/build/askar-shared/src/store/KeyEntry.js +40 -0
- package/build/askar-shared/src/store/KeyEntry.js.map +1 -0
- package/build/askar-shared/src/store/KeyEntryList.d.ts +15 -0
- package/build/askar-shared/src/store/KeyEntryList.js +33 -0
- package/build/askar-shared/src/store/KeyEntryList.js.map +1 -0
- package/build/askar-shared/src/store/OpenSession.d.ts +14 -0
- package/build/askar-shared/src/store/OpenSession.js +27 -0
- package/build/askar-shared/src/store/OpenSession.js.map +1 -0
- package/build/askar-shared/src/store/Scan.d.ts +28 -0
- package/build/askar-shared/src/store/Scan.js +67 -0
- package/build/askar-shared/src/store/Scan.js.map +1 -0
- package/build/askar-shared/src/store/Session.d.ts +86 -0
- package/build/askar-shared/src/store/Session.js +182 -0
- package/build/askar-shared/src/store/Session.js.map +1 -0
- package/build/askar-shared/src/store/Store.d.ts +58 -0
- package/build/askar-shared/src/store/Store.js +87 -0
- package/build/askar-shared/src/store/Store.js.map +1 -0
- package/build/askar-shared/src/store/StoreKeyMethod.d.ts +11 -0
- package/build/askar-shared/src/store/StoreKeyMethod.js +20 -0
- package/build/askar-shared/src/store/StoreKeyMethod.js.map +1 -0
- package/build/askar-shared/src/store/index.d.ts +9 -0
- package/build/askar-shared/src/store/index.js +26 -0
- package/build/askar-shared/src/store/index.js.map +1 -0
- package/cpp/HostObject.cpp +198 -0
- package/cpp/HostObject.h +23 -0
- package/cpp/askar.cpp +1118 -0
- package/cpp/askar.h +111 -0
- package/cpp/include/libaries_askar.h +635 -0
- package/cpp/turboModuleUtility.cpp +598 -0
- package/cpp/turboModuleUtility.h +62 -0
- package/ios/Askar.h +5 -0
- package/ios/Askar.mm +33 -0
- package/package.json +59 -0
package/cpp/askar.cpp
ADDED
|
@@ -0,0 +1,1118 @@
|
|
|
1
|
+
#include "askar.h"
|
|
2
|
+
// TODO(rename): rename to askar when lib name is changed
|
|
3
|
+
#include "include/libaries_askar.h"
|
|
4
|
+
|
|
5
|
+
using namespace askarTurboModuleUtility;
|
|
6
|
+
|
|
7
|
+
namespace askar {
|
|
8
|
+
|
|
9
|
+
jsi::Value version(jsi::Runtime &rt, jsi::Object options) {
|
|
10
|
+
return jsi::String::createFromAscii(rt, askar_version());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
jsi::Value getCurrentError(jsi::Runtime &rt, jsi::Object options) {
|
|
14
|
+
const char *error;
|
|
15
|
+
askar_get_current_error(&error);
|
|
16
|
+
return jsi::String::createFromAscii(rt, error);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
jsi::Value setDefaultLogger(jsi::Runtime &rt, jsi::Object options) {
|
|
20
|
+
ErrorCode code = askar_set_default_logger();
|
|
21
|
+
|
|
22
|
+
return createReturnValue(rt, code, nullptr);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
jsi::Value entryListCount(jsi::Runtime &rt, jsi::Object options) {
|
|
26
|
+
auto entryListHandle =
|
|
27
|
+
jsiToValue<EntryListHandle>(rt, options, "entryListHandle");
|
|
28
|
+
|
|
29
|
+
int32_t out;
|
|
30
|
+
|
|
31
|
+
ErrorCode code = askar_entry_list_count(entryListHandle, &out);
|
|
32
|
+
|
|
33
|
+
return createReturnValue(rt, code, &out);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
jsi::Value entryListFree(jsi::Runtime &rt, jsi::Object options) {
|
|
37
|
+
auto entryListHandle =
|
|
38
|
+
jsiToValue<EntryListHandle>(rt, options, "entryListHandle");
|
|
39
|
+
|
|
40
|
+
askar_entry_list_free(entryListHandle);
|
|
41
|
+
|
|
42
|
+
return createReturnValue(rt, ErrorCode::Success, nullptr);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
jsi::Value entryListGetCategory(jsi::Runtime &rt, jsi::Object options) {
|
|
46
|
+
auto entryListHandle =
|
|
47
|
+
jsiToValue<EntryListHandle>(rt, options, "entryListHandle");
|
|
48
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
49
|
+
|
|
50
|
+
const char *out;
|
|
51
|
+
|
|
52
|
+
ErrorCode code = askar_entry_list_get_category(entryListHandle, index, &out);
|
|
53
|
+
|
|
54
|
+
return createReturnValue(rt, code, &out);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
jsi::Value entryListGetTags(jsi::Runtime &rt, jsi::Object options) {
|
|
58
|
+
auto entryListHandle =
|
|
59
|
+
jsiToValue<EntryListHandle>(rt, options, "entryListHandle");
|
|
60
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
61
|
+
|
|
62
|
+
const char *out;
|
|
63
|
+
|
|
64
|
+
ErrorCode code = askar_entry_list_get_tags(entryListHandle, index, &out);
|
|
65
|
+
|
|
66
|
+
return createReturnValue(rt, code, &out);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
jsi::Value entryListGetValue(jsi::Runtime &rt, jsi::Object options) {
|
|
70
|
+
auto entryListHandle =
|
|
71
|
+
jsiToValue<EntryListHandle>(rt, options, "entryListHandle");
|
|
72
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
73
|
+
|
|
74
|
+
SecretBuffer out;
|
|
75
|
+
|
|
76
|
+
ErrorCode code = askar_entry_list_get_value(entryListHandle, index, &out);
|
|
77
|
+
|
|
78
|
+
return createReturnValue(rt, code, &out);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
jsi::Value entryListGetName(jsi::Runtime &rt, jsi::Object options) {
|
|
82
|
+
auto entryListHandle =
|
|
83
|
+
jsiToValue<EntryListHandle>(rt, options, "entryListHandle");
|
|
84
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
85
|
+
|
|
86
|
+
const char *out;
|
|
87
|
+
|
|
88
|
+
ErrorCode code = askar_entry_list_get_name(entryListHandle, index, &out);
|
|
89
|
+
|
|
90
|
+
return createReturnValue(rt, code, &out);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
jsi::Value storeCopyTo(jsi::Runtime &rt, jsi::Object options) {
|
|
94
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
95
|
+
auto targetUri = jsiToValue<std::string>(rt, options, "targetUri");
|
|
96
|
+
auto recreate = jsiToValue<int8_t>(rt, options, "recreate");
|
|
97
|
+
|
|
98
|
+
auto keyMethod = jsiToValue<std::string>(rt, options, "keyMethod", true);
|
|
99
|
+
auto passKey = jsiToValue<std::string>(rt, options, "passKey", true);
|
|
100
|
+
|
|
101
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
102
|
+
State *state = new State(&cb);
|
|
103
|
+
state->rt = &rt;
|
|
104
|
+
|
|
105
|
+
ErrorCode code = askar_store_copy(
|
|
106
|
+
storeHandle, targetUri.c_str(),
|
|
107
|
+
keyMethod.length() ? keyMethod.c_str() : nullptr,
|
|
108
|
+
passKey.length() ? passKey.c_str() : nullptr,
|
|
109
|
+
recreate, callbackWithResponse, CallbackId(state));
|
|
110
|
+
|
|
111
|
+
return createReturnValue(rt, code, nullptr);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
jsi::Value storeOpen(jsi::Runtime &rt, jsi::Object options) {
|
|
115
|
+
auto specUri = jsiToValue<std::string>(rt, options, "specUri");
|
|
116
|
+
|
|
117
|
+
auto keyMethod = jsiToValue<std::string>(rt, options, "keyMethod", true);
|
|
118
|
+
auto passKey = jsiToValue<std::string>(rt, options, "passKey", true);
|
|
119
|
+
auto profile = jsiToValue<std::string>(rt, options, "profile", true);
|
|
120
|
+
|
|
121
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
122
|
+
State *state = new State(&cb);
|
|
123
|
+
state->rt = &rt;
|
|
124
|
+
|
|
125
|
+
ErrorCode code = askar_store_open(
|
|
126
|
+
specUri.c_str(), keyMethod.length() ? keyMethod.c_str() : nullptr,
|
|
127
|
+
passKey.length() ? passKey.c_str() : nullptr,
|
|
128
|
+
profile.length() ? profile.c_str() : nullptr, callbackWithResponse,
|
|
129
|
+
CallbackId(state));
|
|
130
|
+
|
|
131
|
+
return createReturnValue(rt, code, nullptr);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
jsi::Value storeProvision(jsi::Runtime &rt, jsi::Object options) {
|
|
135
|
+
auto specUri = jsiToValue<std::string>(rt, options, "specUri");
|
|
136
|
+
auto recreate = jsiToValue<int8_t>(rt, options, "recreate");
|
|
137
|
+
|
|
138
|
+
auto keyMethod = jsiToValue<std::string>(rt, options, "keyMethod", true);
|
|
139
|
+
auto passKey = jsiToValue<std::string>(rt, options, "passKey", true);
|
|
140
|
+
auto profile = jsiToValue<std::string>(rt, options, "profile", true);
|
|
141
|
+
|
|
142
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
143
|
+
State *state = new State(&cb);
|
|
144
|
+
state->rt = &rt;
|
|
145
|
+
|
|
146
|
+
ErrorCode code = askar_store_provision(
|
|
147
|
+
specUri.c_str(), keyMethod.length() ? keyMethod.c_str() : nullptr,
|
|
148
|
+
passKey.length() ? passKey.c_str() : nullptr,
|
|
149
|
+
profile.length() ? profile.c_str() : nullptr, recreate,
|
|
150
|
+
callbackWithResponse, CallbackId(state));
|
|
151
|
+
|
|
152
|
+
return createReturnValue(rt, code, nullptr);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
jsi::Value storeGenerateRawKey(jsi::Runtime &rt, jsi::Object options) {
|
|
156
|
+
auto seed = jsiToValue<ByteBuffer>(rt, options, "seed", true);
|
|
157
|
+
|
|
158
|
+
const char *out;
|
|
159
|
+
ErrorCode code = askar_store_generate_raw_key(seed, &out);
|
|
160
|
+
|
|
161
|
+
return createReturnValue(rt, code, &out);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
jsi::Value storeClose(jsi::Runtime &rt, jsi::Object options) {
|
|
165
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
166
|
+
|
|
167
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
168
|
+
State *state = new State(&cb);
|
|
169
|
+
state->rt = &rt;
|
|
170
|
+
|
|
171
|
+
ErrorCode code = askar_store_close(storeHandle, callback, CallbackId(state));
|
|
172
|
+
|
|
173
|
+
return createReturnValue(rt, code, nullptr);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
jsi::Value storeCreateProfile(jsi::Runtime &rt, jsi::Object options) {
|
|
177
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
178
|
+
|
|
179
|
+
auto profile = jsiToValue<std::string>(rt, options, "profile", true);
|
|
180
|
+
|
|
181
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
182
|
+
State *state = new State(&cb);
|
|
183
|
+
state->rt = &rt;
|
|
184
|
+
|
|
185
|
+
ErrorCode code = askar_store_create_profile(
|
|
186
|
+
storeHandle, profile.length() ? profile.c_str() : nullptr,
|
|
187
|
+
callbackWithResponse, CallbackId(state));
|
|
188
|
+
|
|
189
|
+
return createReturnValue(rt, code, nullptr);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
jsi::Value storeGetProfileName(jsi::Runtime &rt, jsi::Object options) {
|
|
193
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
194
|
+
|
|
195
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
196
|
+
State *state = new State(&cb);
|
|
197
|
+
state->rt = &rt;
|
|
198
|
+
|
|
199
|
+
ErrorCode code = askar_store_get_profile_name(
|
|
200
|
+
storeHandle, callbackWithResponse, CallbackId(state));
|
|
201
|
+
|
|
202
|
+
return createReturnValue(rt, code, nullptr);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
jsi::Value storeGetDefaultProfile(jsi::Runtime &rt, jsi::Object options) {
|
|
206
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
207
|
+
|
|
208
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
209
|
+
State *state = new State(&cb);
|
|
210
|
+
state->rt = &rt;
|
|
211
|
+
|
|
212
|
+
ErrorCode code = askar_store_get_default_profile(
|
|
213
|
+
storeHandle, callbackWithResponse, CallbackId(state));
|
|
214
|
+
|
|
215
|
+
return createReturnValue(rt, code, nullptr);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
jsi::Value storeListProfiles(jsi::Runtime &rt, jsi::Object options) {
|
|
219
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
220
|
+
|
|
221
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
222
|
+
State *state = new State(&cb);
|
|
223
|
+
state->rt = &rt;
|
|
224
|
+
|
|
225
|
+
ErrorCode code = askar_store_list_profiles(
|
|
226
|
+
storeHandle, callbackWithResponse, CallbackId(state));
|
|
227
|
+
|
|
228
|
+
return createReturnValue(rt, code, nullptr);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
jsi::Value storeRekey(jsi::Runtime &rt, jsi::Object options) {
|
|
232
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
233
|
+
auto passKey = jsiToValue<std::string>(rt, options, "passKey");
|
|
234
|
+
|
|
235
|
+
auto keyMethod = jsiToValue<std::string>(rt, options, "keyMethod", true);
|
|
236
|
+
|
|
237
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
238
|
+
State *state = new State(&cb);
|
|
239
|
+
state->rt = &rt;
|
|
240
|
+
|
|
241
|
+
ErrorCode code = askar_store_rekey(storeHandle,
|
|
242
|
+
keyMethod.length() ? keyMethod.c_str() : nullptr,
|
|
243
|
+
passKey.c_str(), callback, CallbackId(state));
|
|
244
|
+
|
|
245
|
+
return createReturnValue(rt, code, nullptr);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
jsi::Value storeRemove(jsi::Runtime &rt, jsi::Object options) {
|
|
249
|
+
auto specUri = jsiToValue<std::string>(rt, options, "specUri");
|
|
250
|
+
|
|
251
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
252
|
+
State *state = new State(&cb);
|
|
253
|
+
state->rt = &rt;
|
|
254
|
+
|
|
255
|
+
ErrorCode code = askar_store_remove(specUri.c_str(), callbackWithResponse,
|
|
256
|
+
CallbackId(state));
|
|
257
|
+
|
|
258
|
+
return createReturnValue(rt, code, nullptr);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
jsi::Value storeRemoveProfile(jsi::Runtime &rt, jsi::Object options) {
|
|
262
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
263
|
+
auto profile = jsiToValue<std::string>(rt, options, "profile");
|
|
264
|
+
|
|
265
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
266
|
+
State *state = new State(&cb);
|
|
267
|
+
state->rt = &rt;
|
|
268
|
+
|
|
269
|
+
ErrorCode code = askar_store_remove_profile(
|
|
270
|
+
storeHandle, profile.c_str(), callbackWithResponse, CallbackId(state));
|
|
271
|
+
|
|
272
|
+
return createReturnValue(rt, code, nullptr);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
jsi::Value storeSetDefaultProfile(jsi::Runtime &rt, jsi::Object options) {
|
|
276
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
277
|
+
auto profile = jsiToValue<std::string>(rt, options, "profile");
|
|
278
|
+
|
|
279
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
280
|
+
State *state = new State(&cb);
|
|
281
|
+
state->rt = &rt;
|
|
282
|
+
|
|
283
|
+
ErrorCode code = askar_store_set_default_profile(
|
|
284
|
+
storeHandle, profile.c_str(), callback, CallbackId(state));
|
|
285
|
+
|
|
286
|
+
return createReturnValue(rt, code, nullptr);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
jsi::Value sessionClose(jsi::Runtime &rt, jsi::Object options) {
|
|
290
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
291
|
+
auto commit = jsiToValue<int8_t>(rt, options, "commit");
|
|
292
|
+
|
|
293
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
294
|
+
State *state = new State(&cb);
|
|
295
|
+
state->rt = &rt;
|
|
296
|
+
|
|
297
|
+
ErrorCode code =
|
|
298
|
+
askar_session_close(sessionHandle, commit, callback, CallbackId(state));
|
|
299
|
+
|
|
300
|
+
return createReturnValue(rt, code, nullptr);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
jsi::Value sessionCount(jsi::Runtime &rt, jsi::Object options) {
|
|
304
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
305
|
+
auto category = jsiToValue<std::string>(rt, options, "category");
|
|
306
|
+
auto tagFilter = jsiToValue<std::string>(rt, options, "tagFilter", true);
|
|
307
|
+
|
|
308
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
309
|
+
State *state = new State(&cb);
|
|
310
|
+
state->rt = &rt;
|
|
311
|
+
|
|
312
|
+
ErrorCode code =
|
|
313
|
+
askar_session_count(sessionHandle, category.c_str(),
|
|
314
|
+
tagFilter.length() ? tagFilter.c_str() : nullptr,
|
|
315
|
+
callbackWithResponse, CallbackId(state));
|
|
316
|
+
|
|
317
|
+
return createReturnValue(rt, code, nullptr);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
jsi::Value sessionFetch(jsi::Runtime &rt, jsi::Object options) {
|
|
321
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
322
|
+
auto category = jsiToValue<std::string>(rt, options, "category");
|
|
323
|
+
auto name = jsiToValue<std::string>(rt, options, "name");
|
|
324
|
+
auto forUpdate = jsiToValue<int8_t>(rt, options, "forUpdate");
|
|
325
|
+
|
|
326
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
327
|
+
State *state = new State(&cb);
|
|
328
|
+
state->rt = &rt;
|
|
329
|
+
|
|
330
|
+
ErrorCode code =
|
|
331
|
+
askar_session_fetch(sessionHandle, category.c_str(), name.c_str(),
|
|
332
|
+
forUpdate, callbackWithResponse, CallbackId(state));
|
|
333
|
+
|
|
334
|
+
return createReturnValue(rt, code, nullptr);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
jsi::Value sessionFetchAll(jsi::Runtime &rt, jsi::Object options) {
|
|
338
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
339
|
+
auto category = jsiToValue<std::string>(rt, options, "category");
|
|
340
|
+
auto forUpdate = jsiToValue<int8_t>(rt, options, "forUpdate");
|
|
341
|
+
|
|
342
|
+
auto tagFilter = jsiToValue<std::string>(rt, options, "tagFilter", true);
|
|
343
|
+
auto limit = jsiToValue<int64_t>(rt, options, "limit", true);
|
|
344
|
+
auto orderBy = jsiToValue<std::string>(rt, options, "orderBy", true);
|
|
345
|
+
auto descending = jsiToValue<int8_t>(rt, options, "descending", true);
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
349
|
+
State *state = new State(&cb);
|
|
350
|
+
state->rt = &rt;
|
|
351
|
+
|
|
352
|
+
ErrorCode code = askar_session_fetch_all(
|
|
353
|
+
sessionHandle,
|
|
354
|
+
category.c_str(),
|
|
355
|
+
tagFilter.length() ? tagFilter.c_str() : nullptr,
|
|
356
|
+
limit,
|
|
357
|
+
orderBy.length() ? orderBy.c_str() : nullptr,
|
|
358
|
+
descending,
|
|
359
|
+
forUpdate,
|
|
360
|
+
callbackWithResponse,
|
|
361
|
+
CallbackId(state));
|
|
362
|
+
|
|
363
|
+
return createReturnValue(rt, code, nullptr);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
jsi::Value sessionFetchAllKeys(jsi::Runtime &rt, jsi::Object options) {
|
|
367
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
368
|
+
auto forUpdate = jsiToValue<int8_t>(rt, options, "forUpdate");
|
|
369
|
+
|
|
370
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm", true);
|
|
371
|
+
auto thumbprint = jsiToValue<std::string>(rt, options, "thumbprint", true);
|
|
372
|
+
auto tagFilter = jsiToValue<std::string>(rt, options, "tagFilter", true);
|
|
373
|
+
auto limit = jsiToValue<int64_t>(rt, options, "limit", true);
|
|
374
|
+
|
|
375
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
376
|
+
State *state = new State(&cb);
|
|
377
|
+
state->rt = &rt;
|
|
378
|
+
|
|
379
|
+
ErrorCode code = askar_session_fetch_all_keys(
|
|
380
|
+
sessionHandle, algorithm.length() ? algorithm.c_str() : nullptr,
|
|
381
|
+
thumbprint.length() ? thumbprint.c_str() : nullptr,
|
|
382
|
+
tagFilter.length() ? tagFilter.c_str() : nullptr, limit, forUpdate,
|
|
383
|
+
callbackWithResponse, CallbackId(state));
|
|
384
|
+
|
|
385
|
+
return createReturnValue(rt, code, nullptr);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
jsi::Value sessionFetchKey(jsi::Runtime &rt, jsi::Object options) {
|
|
389
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
390
|
+
auto name = jsiToValue<std::string>(rt, options, "name");
|
|
391
|
+
auto forUpdate = jsiToValue<int8_t>(rt, options, "forUpdate");
|
|
392
|
+
|
|
393
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
394
|
+
State *state = new State(&cb);
|
|
395
|
+
state->rt = &rt;
|
|
396
|
+
|
|
397
|
+
ErrorCode code =
|
|
398
|
+
askar_session_fetch_key(sessionHandle, name.c_str(), forUpdate,
|
|
399
|
+
callbackWithResponse, CallbackId(state));
|
|
400
|
+
|
|
401
|
+
return createReturnValue(rt, code, nullptr);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
jsi::Value sessionInsertKey(jsi::Runtime &rt, jsi::Object options) {
|
|
405
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
406
|
+
auto localKeyHandle =
|
|
407
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
408
|
+
auto name = jsiToValue<std::string>(rt, options, "name");
|
|
409
|
+
|
|
410
|
+
auto metadata = jsiToValue<std::string>(rt, options, "metadata", true);
|
|
411
|
+
auto tags = jsiToValue<std::string>(rt, options, "tags", true);
|
|
412
|
+
auto expiryMs = jsiToValue<int64_t>(rt, options, "expiryMs", true);
|
|
413
|
+
|
|
414
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
415
|
+
State *state = new State(&cb);
|
|
416
|
+
state->rt = &rt;
|
|
417
|
+
|
|
418
|
+
ErrorCode code =
|
|
419
|
+
askar_session_insert_key(sessionHandle, localKeyHandle, name.c_str(),
|
|
420
|
+
metadata.length() ? metadata.c_str() : nullptr,
|
|
421
|
+
tags.length() ? tags.c_str() : nullptr, expiryMs,
|
|
422
|
+
callback, CallbackId(state));
|
|
423
|
+
|
|
424
|
+
return createReturnValue(rt, code, nullptr);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
jsi::Value sessionRemoveAll(jsi::Runtime &rt, jsi::Object options) {
|
|
428
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
429
|
+
auto category = jsiToValue<std::string>(rt, options, "category");
|
|
430
|
+
|
|
431
|
+
auto tagFilter = jsiToValue<std::string>(rt, options, "tagFilter", true);
|
|
432
|
+
|
|
433
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
434
|
+
State *state = new State(&cb);
|
|
435
|
+
state->rt = &rt;
|
|
436
|
+
|
|
437
|
+
ErrorCode code =
|
|
438
|
+
askar_session_remove_all(sessionHandle, category.c_str(),
|
|
439
|
+
tagFilter.length() ? tagFilter.c_str() : nullptr,
|
|
440
|
+
callbackWithResponse, CallbackId(state));
|
|
441
|
+
|
|
442
|
+
return createReturnValue(rt, code, nullptr);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
jsi::Value sessionRemoveKey(jsi::Runtime &rt, jsi::Object options) {
|
|
446
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
447
|
+
auto name = jsiToValue<std::string>(rt, options, "name");
|
|
448
|
+
|
|
449
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
450
|
+
State *state = new State(&cb);
|
|
451
|
+
state->rt = &rt;
|
|
452
|
+
|
|
453
|
+
ErrorCode code = askar_session_remove_key(sessionHandle, name.c_str(),
|
|
454
|
+
callback, CallbackId(state));
|
|
455
|
+
|
|
456
|
+
return createReturnValue(rt, code, nullptr);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
jsi::Value sessionStart(jsi::Runtime &rt, jsi::Object options) {
|
|
460
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
461
|
+
auto asTransaction = jsiToValue<int8_t>(rt, options, "asTransaction");
|
|
462
|
+
|
|
463
|
+
auto profile = jsiToValue<std::string>(rt, options, "profile", true);
|
|
464
|
+
|
|
465
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
466
|
+
State *state = new State(&cb);
|
|
467
|
+
state->rt = &rt;
|
|
468
|
+
|
|
469
|
+
ErrorCode code = askar_session_start(
|
|
470
|
+
storeHandle, profile.length() ? profile.c_str() : nullptr, asTransaction,
|
|
471
|
+
callbackWithResponse, CallbackId(state));
|
|
472
|
+
|
|
473
|
+
return createReturnValue(rt, code, nullptr);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
jsi::Value sessionUpdate(jsi::Runtime &rt, jsi::Object options) {
|
|
477
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
478
|
+
auto operation = jsiToValue<int8_t>(rt, options, "operation");
|
|
479
|
+
auto category = jsiToValue<std::string>(rt, options, "category");
|
|
480
|
+
auto name = jsiToValue<std::string>(rt, options, "name");
|
|
481
|
+
|
|
482
|
+
auto tags = jsiToValue<std::string>(rt, options, "tags", true);
|
|
483
|
+
auto value = jsiToValue<ByteBuffer>(rt, options, "value", true);
|
|
484
|
+
auto expiryMs = jsiToValue<int64_t>(rt, options, "expiryMs", true);
|
|
485
|
+
|
|
486
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
487
|
+
State *state = new State(&cb);
|
|
488
|
+
state->rt = &rt;
|
|
489
|
+
|
|
490
|
+
ErrorCode code = askar_session_update(sessionHandle, operation,
|
|
491
|
+
category.c_str(), name.c_str(), value,
|
|
492
|
+
tags.length() ? tags.c_str() : nullptr,
|
|
493
|
+
expiryMs, callback, CallbackId(state));
|
|
494
|
+
|
|
495
|
+
return createReturnValue(rt, code, nullptr);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
jsi::Value sessionUpdateKey(jsi::Runtime &rt, jsi::Object options) {
|
|
499
|
+
auto sessionHandle = jsiToValue<int64_t>(rt, options, "sessionHandle");
|
|
500
|
+
auto name = jsiToValue<std::string>(rt, options, "name");
|
|
501
|
+
|
|
502
|
+
auto tags = jsiToValue<std::string>(rt, options, "tags", true);
|
|
503
|
+
auto metadata = jsiToValue<std::string>(rt, options, "metadata", true);
|
|
504
|
+
auto expiryMs = jsiToValue<int64_t>(rt, options, "expiryMs", true);
|
|
505
|
+
|
|
506
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
507
|
+
State *state = new State(&cb);
|
|
508
|
+
state->rt = &rt;
|
|
509
|
+
|
|
510
|
+
ErrorCode code =
|
|
511
|
+
askar_session_update_key(sessionHandle, name.c_str(),
|
|
512
|
+
metadata.length() ? metadata.c_str() : nullptr,
|
|
513
|
+
tags.length() ? tags.c_str() : nullptr, expiryMs,
|
|
514
|
+
callback, CallbackId(state));
|
|
515
|
+
|
|
516
|
+
return createReturnValue(rt, code, nullptr);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
jsi::Value scanStart(jsi::Runtime &rt, jsi::Object options) {
|
|
520
|
+
auto storeHandle = jsiToValue<int64_t>(rt, options, "storeHandle");
|
|
521
|
+
auto category = jsiToValue<std::string>(rt, options, "category");
|
|
522
|
+
|
|
523
|
+
auto tagFilter = jsiToValue<std::string>(rt, options, "tagFilter", true);
|
|
524
|
+
auto profile = jsiToValue<std::string>(rt, options, "profile", true);
|
|
525
|
+
auto offset = jsiToValue<int64_t>(rt, options, "offset", true);
|
|
526
|
+
auto limit = jsiToValue<int64_t>(rt, options, "limit", true);
|
|
527
|
+
auto orderBy = jsiToValue<std::string>(rt, options, "orderBy", true);
|
|
528
|
+
auto descending = jsiToValue<int8_t>(rt, options, "descending", true);
|
|
529
|
+
|
|
530
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
531
|
+
State *state = new State(&cb);
|
|
532
|
+
state->rt = &rt;
|
|
533
|
+
|
|
534
|
+
ErrorCode code = askar_scan_start(
|
|
535
|
+
storeHandle,
|
|
536
|
+
profile.length() ? profile.c_str() : nullptr,
|
|
537
|
+
category.c_str(),
|
|
538
|
+
tagFilter.length() ? tagFilter.c_str() : nullptr,
|
|
539
|
+
offset,
|
|
540
|
+
limit,
|
|
541
|
+
orderBy.length() ? orderBy.c_str() : nullptr,
|
|
542
|
+
descending,
|
|
543
|
+
callbackWithResponse,
|
|
544
|
+
CallbackId(state));
|
|
545
|
+
|
|
546
|
+
return createReturnValue(rt, code, nullptr);
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
jsi::Value scanNext(jsi::Runtime &rt, jsi::Object options) {
|
|
550
|
+
auto scanHandle = jsiToValue<int64_t>(rt, options, "scanHandle");
|
|
551
|
+
|
|
552
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
553
|
+
State *state = new State(&cb);
|
|
554
|
+
state->rt = &rt;
|
|
555
|
+
|
|
556
|
+
ErrorCode code =
|
|
557
|
+
askar_scan_next(scanHandle, callbackWithResponse, CallbackId(state));
|
|
558
|
+
|
|
559
|
+
return createReturnValue(rt, code, nullptr);
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
jsi::Value scanFree(jsi::Runtime &rt, jsi::Object options) {
|
|
563
|
+
auto scanHandle = jsiToValue<int64_t>(rt, options, "scanHandle");
|
|
564
|
+
|
|
565
|
+
ErrorCode code = askar_scan_free(scanHandle);
|
|
566
|
+
|
|
567
|
+
return createReturnValue(rt, code, nullptr);
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
jsi::Value keyFromJwk(jsi::Runtime &rt, jsi::Object options) {
|
|
571
|
+
auto jwk = jsiToValue<ByteBuffer>(rt, options, "jwk");
|
|
572
|
+
|
|
573
|
+
LocalKeyHandle out;
|
|
574
|
+
|
|
575
|
+
ErrorCode code = askar_key_from_jwk(jwk, &out);
|
|
576
|
+
|
|
577
|
+
return createReturnValue(rt, code, &out);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
jsi::Value keyFromKeyExchange(jsi::Runtime &rt, jsi::Object options) {
|
|
581
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
582
|
+
auto skHandle = jsiToValue<LocalKeyHandle>(rt, options, "skHandle");
|
|
583
|
+
auto pkHandle = jsiToValue<LocalKeyHandle>(rt, options, "pkHandle");
|
|
584
|
+
|
|
585
|
+
LocalKeyHandle out;
|
|
586
|
+
|
|
587
|
+
ErrorCode code =
|
|
588
|
+
askar_key_from_key_exchange(algorithm.c_str(), skHandle, pkHandle, &out);
|
|
589
|
+
|
|
590
|
+
return createReturnValue(rt, code, &out);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
jsi::Value keyFromPublicBytes(jsi::Runtime &rt, jsi::Object options) {
|
|
594
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
595
|
+
auto publicKey = jsiToValue<ByteBuffer>(rt, options, "publicKey");
|
|
596
|
+
|
|
597
|
+
LocalKeyHandle out;
|
|
598
|
+
|
|
599
|
+
ErrorCode code =
|
|
600
|
+
askar_key_from_public_bytes(algorithm.c_str(), publicKey, &out);
|
|
601
|
+
|
|
602
|
+
return createReturnValue(rt, code, &out);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
jsi::Value keyFromSecretBytes(jsi::Runtime &rt, jsi::Object options) {
|
|
606
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
607
|
+
auto secretKey = jsiToValue<ByteBuffer>(rt, options, "secretKey");
|
|
608
|
+
|
|
609
|
+
LocalKeyHandle out;
|
|
610
|
+
|
|
611
|
+
ErrorCode code =
|
|
612
|
+
askar_key_from_secret_bytes(algorithm.c_str(), secretKey, &out);
|
|
613
|
+
|
|
614
|
+
return createReturnValue(rt, code, &out);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
jsi::Value keyFromSeed(jsi::Runtime &rt, jsi::Object options) {
|
|
618
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
619
|
+
auto seed = jsiToValue<ByteBuffer>(rt, options, "seed");
|
|
620
|
+
auto method = jsiToValue<std::string>(rt, options, "method");
|
|
621
|
+
|
|
622
|
+
LocalKeyHandle out;
|
|
623
|
+
|
|
624
|
+
ErrorCode code =
|
|
625
|
+
askar_key_from_seed(algorithm.c_str(), seed, method.c_str(), &out);
|
|
626
|
+
|
|
627
|
+
return createReturnValue(rt, code, &out);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
jsi::Value keyGenerate(jsi::Runtime &rt, jsi::Object options) {
|
|
631
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
632
|
+
auto ephemeral = jsiToValue<int8_t>(rt, options, "ephemeral");
|
|
633
|
+
|
|
634
|
+
auto keyBackend = jsiToValue<std::string>(rt, options, "keyBackend", true);
|
|
635
|
+
|
|
636
|
+
LocalKeyHandle out;
|
|
637
|
+
|
|
638
|
+
ErrorCode code = askar_key_generate(
|
|
639
|
+
algorithm.c_str(),
|
|
640
|
+
keyBackend.length() ? keyBackend.c_str() : nullptr,
|
|
641
|
+
ephemeral,
|
|
642
|
+
&out
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
return createReturnValue(rt, code, &out);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
jsi::Value keyGetAlgorithm(jsi::Runtime &rt, jsi::Object options) {
|
|
649
|
+
auto localKeyHandle =
|
|
650
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
651
|
+
|
|
652
|
+
const char *out;
|
|
653
|
+
|
|
654
|
+
ErrorCode code = askar_key_get_algorithm(localKeyHandle, &out);
|
|
655
|
+
|
|
656
|
+
return createReturnValue(rt, code, &out);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
jsi::Value keyGetEphemeral(jsi::Runtime &rt, jsi::Object options) {
|
|
660
|
+
auto localKeyHandle =
|
|
661
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
662
|
+
|
|
663
|
+
int8_t out;
|
|
664
|
+
|
|
665
|
+
ErrorCode code = askar_key_get_ephemeral(localKeyHandle, &out);
|
|
666
|
+
|
|
667
|
+
return createReturnValue(rt, code, &out);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
jsi::Value keyGetJwkPublic(jsi::Runtime &rt, jsi::Object options) {
|
|
671
|
+
auto localKeyHandle =
|
|
672
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
673
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
674
|
+
|
|
675
|
+
const char *out;
|
|
676
|
+
|
|
677
|
+
ErrorCode code =
|
|
678
|
+
askar_key_get_jwk_public(localKeyHandle, algorithm.c_str(), &out);
|
|
679
|
+
|
|
680
|
+
return createReturnValue(rt, code, &out);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
jsi::Value keyGetJwkSecret(jsi::Runtime &rt, jsi::Object options) {
|
|
684
|
+
auto localKeyHandle =
|
|
685
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
686
|
+
|
|
687
|
+
SecretBuffer out;
|
|
688
|
+
|
|
689
|
+
ErrorCode code = askar_key_get_jwk_secret(localKeyHandle, &out);
|
|
690
|
+
|
|
691
|
+
return createReturnValue(rt, code, &out);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
jsi::Value keyGetJwkThumbprint(jsi::Runtime &rt, jsi::Object options) {
|
|
695
|
+
auto localKeyHandle =
|
|
696
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
697
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
698
|
+
|
|
699
|
+
const char *out;
|
|
700
|
+
|
|
701
|
+
ErrorCode code =
|
|
702
|
+
askar_key_get_jwk_thumbprint(localKeyHandle, algorithm.c_str(), &out);
|
|
703
|
+
|
|
704
|
+
return createReturnValue(rt, code, &out);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
jsi::Value keyGetPublicBytes(jsi::Runtime &rt, jsi::Object options) {
|
|
708
|
+
auto localKeyHandle =
|
|
709
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
710
|
+
|
|
711
|
+
SecretBuffer out;
|
|
712
|
+
|
|
713
|
+
ErrorCode code = askar_key_get_public_bytes(localKeyHandle, &out);
|
|
714
|
+
|
|
715
|
+
return createReturnValue(rt, code, &out);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
jsi::Value keyGetSecretBytes(jsi::Runtime &rt, jsi::Object options) {
|
|
719
|
+
auto localKeyHandle =
|
|
720
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
721
|
+
|
|
722
|
+
SecretBuffer out;
|
|
723
|
+
|
|
724
|
+
ErrorCode code = askar_key_get_secret_bytes(localKeyHandle, &out);
|
|
725
|
+
|
|
726
|
+
return createReturnValue(rt, code, &out);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
jsi::Value keySignMessage(jsi::Runtime &rt, jsi::Object options) {
|
|
730
|
+
auto localKeyHandle =
|
|
731
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
732
|
+
auto message = jsiToValue<ByteBuffer>(rt, options, "message");
|
|
733
|
+
|
|
734
|
+
auto sigType = jsiToValue<std::string>(rt, options, "sigType", true);
|
|
735
|
+
|
|
736
|
+
SecretBuffer out;
|
|
737
|
+
|
|
738
|
+
ErrorCode code = askar_key_sign_message(
|
|
739
|
+
localKeyHandle, message, sigType.length() ? sigType.c_str() : nullptr,
|
|
740
|
+
&out);
|
|
741
|
+
|
|
742
|
+
return createReturnValue(rt, code, &out);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
jsi::Value keyUnwrapKey(jsi::Runtime &rt, jsi::Object options) {
|
|
746
|
+
auto localKeyHandle =
|
|
747
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
748
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
749
|
+
auto ciphertext = jsiToValue<ByteBuffer>(rt, options, "ciphertext");
|
|
750
|
+
|
|
751
|
+
auto nonce = jsiToValue<ByteBuffer>(rt, options, "nonce", true);
|
|
752
|
+
auto tag = jsiToValue<ByteBuffer>(rt, options, "tag", true);
|
|
753
|
+
|
|
754
|
+
LocalKeyHandle out;
|
|
755
|
+
|
|
756
|
+
ErrorCode code = askar_key_unwrap_key(localKeyHandle, algorithm.c_str(),
|
|
757
|
+
ciphertext, nonce, tag, &out);
|
|
758
|
+
|
|
759
|
+
return createReturnValue(rt, code, &out);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
jsi::Value keyVerifySignature(jsi::Runtime &rt, jsi::Object options) {
|
|
763
|
+
auto localKeyHandle =
|
|
764
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
765
|
+
auto message = jsiToValue<ByteBuffer>(rt, options, "message");
|
|
766
|
+
auto signature = jsiToValue<ByteBuffer>(rt, options, "signature");
|
|
767
|
+
|
|
768
|
+
auto sigType = jsiToValue<std::string>(rt, options, "sigType", true);
|
|
769
|
+
|
|
770
|
+
int8_t out;
|
|
771
|
+
|
|
772
|
+
ErrorCode code = askar_key_verify_signature(
|
|
773
|
+
localKeyHandle, message, signature,
|
|
774
|
+
sigType.length() ? sigType.c_str() : nullptr, &out);
|
|
775
|
+
|
|
776
|
+
return createReturnValue(rt, code, &out);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
jsi::Value keyWrapKey(jsi::Runtime &rt, jsi::Object options) {
|
|
780
|
+
auto localKeyHandle =
|
|
781
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
782
|
+
auto other = jsiToValue<LocalKeyHandle>(rt, options, "other");
|
|
783
|
+
|
|
784
|
+
auto nonce = jsiToValue<ByteBuffer>(rt, options, "nonce", true);
|
|
785
|
+
|
|
786
|
+
EncryptedBuffer out;
|
|
787
|
+
|
|
788
|
+
ErrorCode code = askar_key_wrap_key(localKeyHandle, other, nonce, &out);
|
|
789
|
+
|
|
790
|
+
return createReturnValue(rt, code, &out);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
jsi::Value keyConvert(jsi::Runtime &rt, jsi::Object options) {
|
|
794
|
+
auto localKeyHandle =
|
|
795
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
796
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
797
|
+
|
|
798
|
+
LocalKeyHandle out;
|
|
799
|
+
|
|
800
|
+
ErrorCode code = askar_key_convert(localKeyHandle, algorithm.c_str(), &out);
|
|
801
|
+
|
|
802
|
+
return createReturnValue(rt, code, &out);
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
jsi::Value keyFree(jsi::Runtime &rt, jsi::Object options) {
|
|
806
|
+
auto localKeyHandle =
|
|
807
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
808
|
+
|
|
809
|
+
askar_key_free(localKeyHandle);
|
|
810
|
+
|
|
811
|
+
return createReturnValue(rt, ErrorCode::Success, nullptr);
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
jsi::Value keyCryptoBox(jsi::Runtime &rt, jsi::Object options) {
|
|
815
|
+
auto recipientKey = jsiToValue<LocalKeyHandle>(rt, options, "recipientKey");
|
|
816
|
+
auto senderKey = jsiToValue<LocalKeyHandle>(rt, options, "senderKey");
|
|
817
|
+
auto message = jsiToValue<ByteBuffer>(rt, options, "message");
|
|
818
|
+
auto nonce = jsiToValue<ByteBuffer>(rt, options, "nonce");
|
|
819
|
+
|
|
820
|
+
SecretBuffer out;
|
|
821
|
+
|
|
822
|
+
ErrorCode code =
|
|
823
|
+
askar_key_crypto_box(recipientKey, senderKey, message, nonce, &out);
|
|
824
|
+
|
|
825
|
+
return createReturnValue(rt, code, &out);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
jsi::Value keyCryptoBoxOpen(jsi::Runtime &rt, jsi::Object options) {
|
|
829
|
+
auto recipientKey = jsiToValue<LocalKeyHandle>(rt, options, "recipientKey");
|
|
830
|
+
auto senderKey = jsiToValue<LocalKeyHandle>(rt, options, "senderKey");
|
|
831
|
+
auto message = jsiToValue<ByteBuffer>(rt, options, "message");
|
|
832
|
+
auto nonce = jsiToValue<ByteBuffer>(rt, options, "nonce");
|
|
833
|
+
|
|
834
|
+
SecretBuffer out;
|
|
835
|
+
|
|
836
|
+
ErrorCode code =
|
|
837
|
+
askar_key_crypto_box_open(recipientKey, senderKey, message, nonce, &out);
|
|
838
|
+
|
|
839
|
+
return createReturnValue(rt, code, &out);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
jsi::Value keyCryptoBoxRandomNonce(jsi::Runtime &rt, jsi::Object options) {
|
|
843
|
+
SecretBuffer out;
|
|
844
|
+
|
|
845
|
+
ErrorCode code = askar_key_crypto_box_random_nonce(&out);
|
|
846
|
+
|
|
847
|
+
return createReturnValue(rt, code, &out);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
jsi::Value keyCryptoBoxSeal(jsi::Runtime &rt, jsi::Object options) {
|
|
851
|
+
auto localKeyHandle =
|
|
852
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
853
|
+
auto message = jsiToValue<ByteBuffer>(rt, options, "message");
|
|
854
|
+
|
|
855
|
+
SecretBuffer out;
|
|
856
|
+
|
|
857
|
+
ErrorCode code = askar_key_crypto_box_seal(localKeyHandle, message, &out);
|
|
858
|
+
|
|
859
|
+
return createReturnValue(rt, code, &out);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
jsi::Value keyCryptoBoxSealOpen(jsi::Runtime &rt, jsi::Object options) {
|
|
863
|
+
auto localKeyHandle =
|
|
864
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
865
|
+
auto ciphertext = jsiToValue<ByteBuffer>(rt, options, "ciphertext");
|
|
866
|
+
|
|
867
|
+
SecretBuffer out;
|
|
868
|
+
|
|
869
|
+
ErrorCode code =
|
|
870
|
+
askar_key_crypto_box_seal_open(localKeyHandle, ciphertext, &out);
|
|
871
|
+
|
|
872
|
+
return createReturnValue(rt, code, &out);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
jsi::Value keyDeriveEcdh1pu(jsi::Runtime &rt, jsi::Object options) {
|
|
876
|
+
auto ephemeralKey = jsiToValue<LocalKeyHandle>(rt, options, "ephemeralKey");
|
|
877
|
+
auto senderKey = jsiToValue<LocalKeyHandle>(rt, options, "senderKey");
|
|
878
|
+
auto recipientKey = jsiToValue<LocalKeyHandle>(rt, options, "recipientKey");
|
|
879
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
880
|
+
auto algId = jsiToValue<ByteBuffer>(rt, options, "algId");
|
|
881
|
+
auto apu = jsiToValue<ByteBuffer>(rt, options, "apu");
|
|
882
|
+
auto apv = jsiToValue<ByteBuffer>(rt, options, "apv");
|
|
883
|
+
auto receive = jsiToValue<int8_t>(rt, options, "receive");
|
|
884
|
+
|
|
885
|
+
auto ccTag = jsiToValue<ByteBuffer>(rt, options, "ccTag", true);
|
|
886
|
+
|
|
887
|
+
LocalKeyHandle out;
|
|
888
|
+
|
|
889
|
+
ErrorCode code = askar_key_derive_ecdh_1pu(algorithm.c_str(), ephemeralKey,
|
|
890
|
+
senderKey, recipientKey, algId,
|
|
891
|
+
apu, apv, ccTag, receive, &out);
|
|
892
|
+
|
|
893
|
+
return createReturnValue(rt, code, &out);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
jsi::Value keyDeriveEcdhEs(jsi::Runtime &rt, jsi::Object options) {
|
|
897
|
+
auto ephemeralKey = jsiToValue<LocalKeyHandle>(rt, options, "ephemeralKey");
|
|
898
|
+
auto recipientKey = jsiToValue<LocalKeyHandle>(rt, options, "recipientKey");
|
|
899
|
+
auto algorithm = jsiToValue<std::string>(rt, options, "algorithm");
|
|
900
|
+
auto algId = jsiToValue<ByteBuffer>(rt, options, "algId");
|
|
901
|
+
auto apu = jsiToValue<ByteBuffer>(rt, options, "apu");
|
|
902
|
+
auto apv = jsiToValue<ByteBuffer>(rt, options, "apv");
|
|
903
|
+
auto receive = jsiToValue<int8_t>(rt, options, "receive");
|
|
904
|
+
|
|
905
|
+
LocalKeyHandle out;
|
|
906
|
+
|
|
907
|
+
ErrorCode code =
|
|
908
|
+
askar_key_derive_ecdh_es(algorithm.c_str(), ephemeralKey, recipientKey,
|
|
909
|
+
algId, apu, apv, receive, &out);
|
|
910
|
+
|
|
911
|
+
return createReturnValue(rt, code, &out);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
jsi::Value keyAeadDecrypt(jsi::Runtime &rt, jsi::Object options) {
|
|
915
|
+
auto localKeyHandle =
|
|
916
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
917
|
+
auto ciphertext = jsiToValue<ByteBuffer>(rt, options, "ciphertext");
|
|
918
|
+
auto nonce = jsiToValue<ByteBuffer>(rt, options, "nonce");
|
|
919
|
+
|
|
920
|
+
auto tag = jsiToValue<ByteBuffer>(rt, options, "tag", true);
|
|
921
|
+
auto aad = jsiToValue<ByteBuffer>(rt, options, "aad", true);
|
|
922
|
+
|
|
923
|
+
SecretBuffer out;
|
|
924
|
+
|
|
925
|
+
ErrorCode code =
|
|
926
|
+
askar_key_aead_decrypt(localKeyHandle, ciphertext, nonce, tag, aad, &out);
|
|
927
|
+
|
|
928
|
+
return createReturnValue(rt, code, &out);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
jsi::Value keyAeadEncrypt(jsi::Runtime &rt, jsi::Object options) {
|
|
932
|
+
auto localKeyHandle =
|
|
933
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
934
|
+
auto message = jsiToValue<ByteBuffer>(rt, options, "message");
|
|
935
|
+
|
|
936
|
+
auto nonce = jsiToValue<ByteBuffer>(rt, options, "nonce", true);
|
|
937
|
+
auto aad = jsiToValue<ByteBuffer>(rt, options, "aad", true);
|
|
938
|
+
|
|
939
|
+
EncryptedBuffer out;
|
|
940
|
+
|
|
941
|
+
ErrorCode code =
|
|
942
|
+
askar_key_aead_encrypt(localKeyHandle, message, nonce, aad, &out);
|
|
943
|
+
|
|
944
|
+
return createReturnValue(rt, code, &out);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
jsi::Value keyAeadGetPadding(jsi::Runtime &rt, jsi::Object options) {
|
|
948
|
+
auto localKeyHandle =
|
|
949
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
950
|
+
auto messageLength = jsiToValue<int64_t>(rt, options, "msgLen");
|
|
951
|
+
|
|
952
|
+
int32_t out;
|
|
953
|
+
|
|
954
|
+
ErrorCode code =
|
|
955
|
+
askar_key_aead_get_padding(localKeyHandle, messageLength, &out);
|
|
956
|
+
|
|
957
|
+
return createReturnValue(rt, code, &out);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
jsi::Value keyAeadGetParams(jsi::Runtime &rt, jsi::Object options) {
|
|
961
|
+
auto localKeyHandle =
|
|
962
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
963
|
+
|
|
964
|
+
AeadParams out;
|
|
965
|
+
|
|
966
|
+
ErrorCode code = askar_key_aead_get_params(localKeyHandle, &out);
|
|
967
|
+
|
|
968
|
+
return createReturnValue(rt, code, &out);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
jsi::Value keyAeadRandomNonce(jsi::Runtime &rt, jsi::Object options) {
|
|
972
|
+
auto localKeyHandle =
|
|
973
|
+
jsiToValue<LocalKeyHandle>(rt, options, "localKeyHandle");
|
|
974
|
+
|
|
975
|
+
SecretBuffer out;
|
|
976
|
+
|
|
977
|
+
ErrorCode code = askar_key_aead_random_nonce(localKeyHandle, &out);
|
|
978
|
+
|
|
979
|
+
return createReturnValue(rt, code, &out);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
jsi::Value keyEntryListCount(jsi::Runtime &rt, jsi::Object options) {
|
|
983
|
+
auto keyEntryListHandle =
|
|
984
|
+
jsiToValue<KeyEntryListHandle>(rt, options, "keyEntryListHandle");
|
|
985
|
+
|
|
986
|
+
int32_t out;
|
|
987
|
+
|
|
988
|
+
ErrorCode code = askar_key_entry_list_count(keyEntryListHandle, &out);
|
|
989
|
+
|
|
990
|
+
return createReturnValue(rt, code, &out);
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
jsi::Value keyEntryListFree(jsi::Runtime &rt, jsi::Object options) {
|
|
994
|
+
auto keyEntryListHandle =
|
|
995
|
+
jsiToValue<KeyEntryListHandle>(rt, options, "keyEntryListHandle");
|
|
996
|
+
|
|
997
|
+
int32_t out;
|
|
998
|
+
|
|
999
|
+
ErrorCode code = askar_key_entry_list_count(keyEntryListHandle, &out);
|
|
1000
|
+
|
|
1001
|
+
return createReturnValue(rt, code, &out);
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
jsi::Value keyEntryListGetAlgorithm(jsi::Runtime &rt, jsi::Object options) {
|
|
1005
|
+
auto keyEntryListHandle =
|
|
1006
|
+
jsiToValue<KeyEntryListHandle>(rt, options, "keyEntryListHandle");
|
|
1007
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
1008
|
+
|
|
1009
|
+
const char *out;
|
|
1010
|
+
|
|
1011
|
+
ErrorCode code =
|
|
1012
|
+
askar_key_entry_list_get_algorithm(keyEntryListHandle, index, &out);
|
|
1013
|
+
|
|
1014
|
+
return createReturnValue(rt, code, &out);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
jsi::Value keyEntryListGetMetadata(jsi::Runtime &rt, jsi::Object options) {
|
|
1018
|
+
auto keyEntryListHandle =
|
|
1019
|
+
jsiToValue<KeyEntryListHandle>(rt, options, "keyEntryListHandle");
|
|
1020
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
1021
|
+
|
|
1022
|
+
const char *out;
|
|
1023
|
+
|
|
1024
|
+
ErrorCode code =
|
|
1025
|
+
askar_key_entry_list_get_metadata(keyEntryListHandle, index, &out);
|
|
1026
|
+
|
|
1027
|
+
return createReturnValue(rt, code, &out);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
jsi::Value keyEntryListGetName(jsi::Runtime &rt, jsi::Object options) {
|
|
1031
|
+
auto keyEntryListHandle =
|
|
1032
|
+
jsiToValue<KeyEntryListHandle>(rt, options, "keyEntryListHandle");
|
|
1033
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
1034
|
+
|
|
1035
|
+
const char *out;
|
|
1036
|
+
|
|
1037
|
+
ErrorCode code =
|
|
1038
|
+
askar_key_entry_list_get_name(keyEntryListHandle, index, &out);
|
|
1039
|
+
|
|
1040
|
+
return createReturnValue(rt, code, &out);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
jsi::Value keyEntryListGetTags(jsi::Runtime &rt, jsi::Object options) {
|
|
1044
|
+
auto keyEntryListHandle =
|
|
1045
|
+
jsiToValue<KeyEntryListHandle>(rt, options, "keyEntryListHandle");
|
|
1046
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
1047
|
+
|
|
1048
|
+
const char *out;
|
|
1049
|
+
|
|
1050
|
+
ErrorCode code =
|
|
1051
|
+
askar_key_entry_list_get_tags(keyEntryListHandle, index, &out);
|
|
1052
|
+
|
|
1053
|
+
return createReturnValue(rt, code, &out);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
jsi::Value keyEntryListLoadLocal(jsi::Runtime &rt, jsi::Object options) {
|
|
1057
|
+
auto keyEntryListHandle =
|
|
1058
|
+
jsiToValue<KeyEntryListHandle>(rt, options, "keyEntryListHandle");
|
|
1059
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
1060
|
+
|
|
1061
|
+
LocalKeyHandle out;
|
|
1062
|
+
|
|
1063
|
+
ErrorCode code =
|
|
1064
|
+
askar_key_entry_list_load_local(keyEntryListHandle, index, &out);
|
|
1065
|
+
|
|
1066
|
+
return createReturnValue(rt, code, &out);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
jsi::Value migrateIndySdk(jsi::Runtime &rt, jsi::Object options) {
|
|
1070
|
+
auto specUri = jsiToValue<std::string>(rt, options, "specUri");
|
|
1071
|
+
auto walletName = jsiToValue<std::string>(rt, options, "walletName");
|
|
1072
|
+
auto walletKey = jsiToValue<std::string>(rt, options, "walletKey");
|
|
1073
|
+
auto kdfLevel = jsiToValue<std::string>(rt, options, "kdfLevel");
|
|
1074
|
+
|
|
1075
|
+
jsi::Function cb = options.getPropertyAsFunction(rt, "cb");
|
|
1076
|
+
State *state = new State(&cb);
|
|
1077
|
+
state->rt = &rt;
|
|
1078
|
+
|
|
1079
|
+
ErrorCode code = askar_migrate_indy_sdk(specUri.c_str(), walletName.c_str(),
|
|
1080
|
+
walletKey.c_str(), kdfLevel.c_str(),
|
|
1081
|
+
callback, CallbackId(state));
|
|
1082
|
+
|
|
1083
|
+
return createReturnValue(rt, code, nullptr);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
jsi::Value stringListCount(jsi::Runtime &rt, jsi::Object options) {
|
|
1087
|
+
auto stringListHandle =
|
|
1088
|
+
jsiToValue<StringListHandle>(rt, options, "stringListHandle");
|
|
1089
|
+
|
|
1090
|
+
int32_t out;
|
|
1091
|
+
|
|
1092
|
+
ErrorCode code = askar_string_list_count(stringListHandle, &out);
|
|
1093
|
+
|
|
1094
|
+
return createReturnValue(rt, code, &out);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
jsi::Value stringListFree(jsi::Runtime &rt, jsi::Object options) {
|
|
1098
|
+
auto stringListHandle =
|
|
1099
|
+
jsiToValue<StringListHandle>(rt, options, "stringListHandle");
|
|
1100
|
+
|
|
1101
|
+
askar_string_list_free(stringListHandle);
|
|
1102
|
+
|
|
1103
|
+
return createReturnValue(rt, ErrorCode::Success, nullptr);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
jsi::Value stringListGetItem(jsi::Runtime &rt, jsi::Object options) {
|
|
1107
|
+
auto stringListHandle =
|
|
1108
|
+
jsiToValue<StringListHandle>(rt, options, "stringListHandle");
|
|
1109
|
+
auto index = jsiToValue<int32_t>(rt, options, "index");
|
|
1110
|
+
|
|
1111
|
+
const char *out;
|
|
1112
|
+
|
|
1113
|
+
ErrorCode code = askar_string_list_get_item(stringListHandle, index, &out);
|
|
1114
|
+
|
|
1115
|
+
return createReturnValue(rt, code, &out);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
} // namespace askar
|